Fix default block properties.
This commit is contained in:
@@ -21,9 +21,13 @@ package appeng.block;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.material.MaterialColor;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
@@ -39,6 +43,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
|
||||
|
||||
public abstract class AEBaseBlock extends Block
|
||||
@@ -53,29 +58,44 @@ public abstract class AEBaseBlock extends Block
|
||||
protected AEBaseBlock( final Block.Properties props )
|
||||
{
|
||||
super( props );
|
||||
}
|
||||
|
||||
// FIXME: Move to block registration
|
||||
// FIXME if( mat == AEGlassMaterial.INSTANCE || mat == Material.GLASS )
|
||||
// FIXME {
|
||||
// FIXME this.setSoundType( SoundType.GLASS );
|
||||
// FIXME }
|
||||
// FIXME else if( mat == Material.ROCK )
|
||||
// FIXME {
|
||||
// FIXME this.setSoundType( SoundType.STONE );
|
||||
// FIXME }
|
||||
// FIXME else if( mat == Material.WOOD )
|
||||
// FIXME {
|
||||
// FIXME this.setSoundType( SoundType.WOOD );
|
||||
// FIXME }
|
||||
// FIXME else
|
||||
// FIXME {
|
||||
// FIXME this.setSoundType( SoundType.METAL );
|
||||
// FIXME }
|
||||
/**
|
||||
* Utility function to create block properties with some sensible defaults for AE blocks.
|
||||
*/
|
||||
public static Block.Properties defaultProps(Material material) {
|
||||
return defaultProps(material, material.getColor());
|
||||
}
|
||||
|
||||
// FIXME this.setLightOpacity( 255 );
|
||||
// FIXME this.setLightLevel( 0 );
|
||||
// FIXME this.setHardness( 2.2F );
|
||||
// FIXME this.setHarvestLevel( "pickaxe", 0 );
|
||||
/**
|
||||
* Utility function to create block properties with some sensible defaults for AE blocks.
|
||||
*/
|
||||
public static Block.Properties defaultProps(Material material, MaterialColor color) {
|
||||
return Block.Properties.create(material, color)
|
||||
// These values previousls were encoded in AEBaseBlock
|
||||
.hardnessAndResistance(2.2f, 11.f)
|
||||
.harvestTool(ToolType.PICKAXE)
|
||||
.harvestLevel(0)
|
||||
.sound(getDefaultSoundByMaterial(material));
|
||||
}
|
||||
|
||||
private static SoundType getDefaultSoundByMaterial(Material mat) {
|
||||
if( mat == AEGlassMaterial.INSTANCE || mat == Material.GLASS )
|
||||
{
|
||||
return SoundType.GLASS;
|
||||
}
|
||||
else if( mat == Material.ROCK )
|
||||
{
|
||||
return SoundType.STONE;
|
||||
}
|
||||
else if( mat == Material.WOOD )
|
||||
{
|
||||
return SoundType.WOOD;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SoundType.METAL;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -43,7 +43,7 @@ public class BlockCellWorkbench extends AEBaseTileBlock<TileCellWorkbench>
|
||||
|
||||
public BlockCellWorkbench()
|
||||
{
|
||||
super( Properties.create(Material.IRON) );
|
||||
super( defaultProps(Material.IRON) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,46 +19,44 @@
|
||||
package appeng.block.misc;
|
||||
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.util.AEAxisAlignedBB;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.effects.LightningFX;
|
||||
import appeng.client.render.renderable.ItemRenderable;
|
||||
import appeng.client.render.tesr.ModularTESR;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.misc.TileCharger;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.TransformationMatrix;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.util.AEAxisAlignedBB;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.renderable.ItemRenderable;
|
||||
import appeng.client.render.tesr.ModularTESR;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.misc.TileCharger;
|
||||
import appeng.util.Platform;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
|
||||
public class BlockCharger extends AEBaseTileBlock<TileCharger>
|
||||
@@ -66,7 +64,7 @@ public class BlockCharger extends AEBaseTileBlock<TileCharger>
|
||||
|
||||
public BlockCharger()
|
||||
{
|
||||
super( Properties.create(Material.IRON).notSolid() );
|
||||
super( defaultProps(Material.IRON).notSolid() );
|
||||
|
||||
this.setFullSize( this.setOpaque( false ) );
|
||||
}
|
||||
@@ -110,12 +108,10 @@ public class BlockCharger extends AEBaseTileBlock<TileCharger>
|
||||
return;
|
||||
}
|
||||
|
||||
final AEBaseTile tile = this.getTileEntity( w, pos );
|
||||
if( tile instanceof TileCharger )
|
||||
final TileCharger tile = this.getTileEntity( w, pos );
|
||||
if(tile != null)
|
||||
{
|
||||
final TileCharger tc = (TileCharger) tile;
|
||||
|
||||
if( AEApi.instance().definitions().materials().certusQuartzCrystalCharged().isSameAs( tc.getInternalInventory().getStackInSlot( 0 ) ) )
|
||||
if( AEApi.instance().definitions().materials().certusQuartzCrystalCharged().isSameAs( tile.getInternalInventory().getStackInSlot( 0 ) ) )
|
||||
{
|
||||
final double xOff = 0.0;
|
||||
final double yOff = 0.0;
|
||||
@@ -125,9 +121,9 @@ public class BlockCharger extends AEBaseTileBlock<TileCharger>
|
||||
{
|
||||
if( AppEng.proxy.shouldAddParticles( r ) )
|
||||
{
|
||||
// FIXME final LightningFX fx = new LightningFX( w, xOff + 0.5 + pos.getX(), yOff + 0.5 + pos.getY(), zOff + 0.5 + pos
|
||||
// FIXME .getZ(), 0.0D, 0.0D, 0.0D );
|
||||
// FIXME Minecraft.getInstance().effectRenderer.addEffect( fx );
|
||||
final LightningFX fx = new LightningFX( w, xOff + 0.5 + pos.getX(), yOff + 0.5 + pos.getY(), zOff + 0.5 + pos
|
||||
.getZ(), 0.0, 0.0, 0.0 );
|
||||
Minecraft.getInstance().particles.addEffect( fx );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -202,10 +198,9 @@ public class BlockCharger extends AEBaseTileBlock<TileCharger>
|
||||
}
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private static Pair<ItemStack, Matrix4f> getRenderedItem( TileCharger tile )
|
||||
private static Pair<ItemStack, TransformationMatrix> getRenderedItem(TileCharger tile )
|
||||
{
|
||||
Matrix4f transform = new Matrix4f();
|
||||
transform.translate( new Vector3f( 0.5f, 0.4f, 0.5f ) );
|
||||
TransformationMatrix transform = new TransformationMatrix(new Vector3f( 0.5f, 0.375f, 0.5f ), null, null, null);
|
||||
return new ImmutablePair<>( tile.getInternalInventory().getStackInSlot( 0 ), transform );
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public class BlockCondenser extends AEBaseTileBlock<TileCondenser>
|
||||
|
||||
public BlockCondenser()
|
||||
{
|
||||
super( Properties.create(Material.IRON) );
|
||||
super( defaultProps(Material.IRON) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -52,7 +52,7 @@ public class BlockInterface extends AEBaseTileBlock<TileInterface>
|
||||
|
||||
public BlockInterface()
|
||||
{
|
||||
super( Properties.create(Material.IRON) );
|
||||
super( defaultProps(Material.IRON) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -52,7 +52,7 @@ public class BlockLightDetector extends AEBaseTileBlock<TileLightDetector> imple
|
||||
|
||||
public BlockLightDetector()
|
||||
{
|
||||
super( Properties.create(Material.MISCELLANEOUS).notSolid() );
|
||||
super( defaultProps(Material.MISCELLANEOUS).notSolid() );
|
||||
|
||||
this.setDefaultState( this.getDefaultState().with(BlockStateProperties.FACING, Direction.UP ).with( ODD, false ) );
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class BlockQuartzFixture extends AEBaseBlock implements IOrientableBlock
|
||||
|
||||
public BlockQuartzFixture()
|
||||
{
|
||||
super(Block.Properties.create(Material.MISCELLANEOUS).doesNotBlockMovement().hardnessAndResistance(0, 0).lightValue(14).sound(SoundType.GLASS));
|
||||
super(defaultProps(Material.MISCELLANEOUS).doesNotBlockMovement().hardnessAndResistance(0).lightValue(14).sound(SoundType.GLASS));
|
||||
|
||||
this.setDefaultState( getDefaultState().with( FACING, Direction.UP ).with( ODD, false ) );
|
||||
this.setFullSize( false );
|
||||
|
||||
@@ -48,7 +48,7 @@ public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock<TileQuartzGrow
|
||||
|
||||
public BlockQuartzGrowthAccelerator()
|
||||
{
|
||||
super( Properties.create(Material.ROCK).sound(SoundType.METAL) );
|
||||
super( defaultProps(Material.ROCK).sound(SoundType.METAL) );
|
||||
this.setDefaultState( this.getDefaultState().with( POWERED, false ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class BlockSecurityStation extends AEBaseTileBlock<TileSecurityStation>
|
||||
|
||||
public BlockSecurityStation()
|
||||
{
|
||||
super( Properties.create(Material.IRON) );
|
||||
super( defaultProps(Material.IRON) );
|
||||
|
||||
this.setDefaultState( this.getDefaultState().with( POWERED, false ) );
|
||||
}
|
||||
|
||||
@@ -55,9 +55,9 @@ public class BlockTinyTNT extends AEBaseBlock
|
||||
|
||||
private static final VoxelShape SHAPE = VoxelShapes.create(new AxisAlignedBB( 0.25f, 0.0f, 0.25f, 0.75f, 0.5f, 0.75f ));
|
||||
|
||||
public BlockTinyTNT()
|
||||
public BlockTinyTNT(Block.Properties props)
|
||||
{
|
||||
super( Properties.create(Material.TNT).hardnessAndResistance(0).sound(SoundType.GROUND).notSolid() );
|
||||
super(props);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -56,7 +56,7 @@ public final class BlockVibrationChamber extends AEBaseTileBlock<TileVibrationCh
|
||||
|
||||
public BlockVibrationChamber()
|
||||
{
|
||||
super( Properties.create(Material.IRON).hardnessAndResistance(4.2F) );
|
||||
super( defaultProps(Material.IRON).hardnessAndResistance(4.2F) );
|
||||
this.setDefaultState( this.getDefaultState().with( ACTIVE, false ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ public class BlockCableBus extends AEBaseTileBlock<TileCableBus> /* FIXME implem
|
||||
private static final ICableBusContainer NULL_CABLE_BUS = new NullCableBusContainer();
|
||||
|
||||
public BlockCableBus() {
|
||||
super(Properties.create(AEGlassMaterial.INSTANCE).notSolid());
|
||||
super(defaultProps(AEGlassMaterial.INSTANCE).notSolid());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -74,7 +74,7 @@ public class BlockController extends AEBaseTileBlock<TileController>
|
||||
|
||||
public BlockController()
|
||||
{
|
||||
super( Block.Properties.create(Material.IRON).hardnessAndResistance(6) );
|
||||
super( defaultProps(Material.IRON).hardnessAndResistance(6) );
|
||||
this.setDefaultState( this.getDefaultState()
|
||||
.with( CONTROLLER_STATE, ControllerBlockState.offline )
|
||||
.with( CONTROLLER_TYPE, ControllerRenderType.block ) );
|
||||
|
||||
@@ -29,6 +29,6 @@ public class BlockCreativeEnergyCell extends AEBaseTileBlock<TileCreativeEnergyC
|
||||
|
||||
public BlockCreativeEnergyCell()
|
||||
{
|
||||
super( Properties.create(AEGlassMaterial.INSTANCE) );
|
||||
super( defaultProps(AEGlassMaterial.INSTANCE) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,6 @@ public class BlockEnergyAcceptor extends AEBaseTileBlock<TileEnergyAcceptor>
|
||||
|
||||
public BlockEnergyAcceptor()
|
||||
{
|
||||
super(Block.Properties.create(Material.IRON) );
|
||||
super(defaultProps(Material.IRON) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class BlockEnergyCell extends AEBaseTileBlock<TileEnergyCell>
|
||||
|
||||
public BlockEnergyCell()
|
||||
{
|
||||
super( Properties.create(AEGlassMaterial.INSTANCE) );
|
||||
super( defaultProps(AEGlassMaterial.INSTANCE) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -67,7 +67,7 @@ public class BlockWireless extends AEBaseTileBlock<TileWireless>
|
||||
|
||||
public BlockWireless()
|
||||
{
|
||||
super( Properties.create(AEGlassMaterial.INSTANCE).notSolid() );
|
||||
super( defaultProps(AEGlassMaterial.INSTANCE).notSolid() );
|
||||
this.setFullSize( false );
|
||||
this.setOpaque( false );
|
||||
this.setDefaultState( this.getDefaultState().with( STATE, State.OFF ) );
|
||||
|
||||
@@ -45,7 +45,7 @@ public class BlockPaint extends AEBaseTileBlock<TilePaint>
|
||||
{
|
||||
public BlockPaint()
|
||||
{
|
||||
super(Properties.create(Material.WATER, MaterialColor.AIR));
|
||||
super(defaultProps(Material.WATER, MaterialColor.AIR));
|
||||
this.setFullSize( false );
|
||||
this.setOpaque( false );
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class BlockQuantumLinkChamber extends BlockQuantumBase
|
||||
|
||||
public BlockQuantumLinkChamber()
|
||||
{
|
||||
super(Properties.create(AEGlassMaterial.INSTANCE) );
|
||||
super(defaultProps(AEGlassMaterial.INSTANCE) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,7 +37,7 @@ public class BlockQuantumRing extends BlockQuantumBase {
|
||||
private static final VoxelShape SHAPE_FORMED = createShape(1.0 / 16.0);
|
||||
|
||||
public BlockQuantumRing() {
|
||||
super(Properties.create(Material.IRON));
|
||||
super(defaultProps(Material.IRON));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -48,7 +48,7 @@ public class BlockSpatialIOPort extends AEBaseTileBlock<TileSpatialIOPort>
|
||||
|
||||
public BlockSpatialIOPort()
|
||||
{
|
||||
super( Properties.create(Material.IRON) );
|
||||
super( defaultProps(Material.IRON) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,7 +35,7 @@ public class BlockSpatialPylon extends AEBaseTileBlock<TileSpatialPylon>
|
||||
|
||||
public BlockSpatialPylon()
|
||||
{
|
||||
super( Properties.create(AEGlassMaterial.INSTANCE) );
|
||||
super( defaultProps(AEGlassMaterial.INSTANCE) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -52,7 +52,7 @@ public class BlockChest extends AEBaseTileBlock<TileChest>
|
||||
|
||||
public BlockChest()
|
||||
{
|
||||
super( Properties.create(Material.IRON) );
|
||||
super( defaultProps(Material.IRON) );
|
||||
this.setDefaultState( this.getDefaultState().with( SLOT_STATE, DriveSlotState.EMPTY ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public class BlockDrive extends AEBaseTileBlock<TileDrive>
|
||||
|
||||
public BlockDrive()
|
||||
{
|
||||
super( Properties.create(Material.IRON) );
|
||||
super( defaultProps(Material.IRON) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -45,7 +45,7 @@ public class BlockIOPort extends AEBaseTileBlock<TileIOPort>
|
||||
|
||||
public BlockIOPort()
|
||||
{
|
||||
super( Properties.create(Material.IRON) );
|
||||
super( defaultProps(Material.IRON) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user