Compiles again.

This commit is contained in:
Sebastian Hartte
2020-06-04 19:58:58 +02:00
parent 237463dd94
commit c402390282
89 changed files with 1353 additions and 1772 deletions
@@ -19,31 +19,40 @@
package appeng.block.networking;
import java.util.EnumSet;
import java.util.List;
import java.util.Random;
import javax.annotation.Nullable;
import appeng.api.parts.IFacadeContainer;
import appeng.api.parts.PartItemStack;
import appeng.api.parts.SelectedPart;
import appeng.api.util.AEColor;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.cablebus.CableBusBakedModel;
import appeng.client.render.cablebus.CableBusBreakingParticle;
import appeng.client.render.cablebus.CableBusRenderState;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketClick;
import appeng.helpers.AEGlassMaterial;
import appeng.parts.ICableBusContainer;
import appeng.parts.NullCableBusContainer;
import appeng.tile.AEBaseTile;
import appeng.tile.networking.TileCableBus;
import appeng.tile.networking.TileCableBusTESR;
import appeng.util.Platform;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.BlockStateContainer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleDigging;
import net.minecraft.client.particle.ParticleManager;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.*;
import net.minecraft.fluid.IFluidState;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.DyeColor;
import net.minecraft.state.IProperty;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.NonNullList;
@@ -54,44 +63,20 @@ import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
import appeng.api.parts.IFacadeContainer;
import appeng.api.parts.IFacadePart;
import appeng.api.parts.PartItemStack;
import appeng.api.parts.SelectedPart;
import appeng.api.util.AEColor;
import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.client.UnlistedProperty;
import appeng.client.render.cablebus.CableBusBakedModel;
import appeng.client.render.cablebus.CableBusRenderState;
import appeng.core.AppEng;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketClick;
import appeng.helpers.AEGlassMaterial;
import appeng.integration.abstraction.IAEFacade;
import appeng.parts.ICableBusContainer;
import appeng.parts.NullCableBusContainer;
import appeng.tile.AEBaseTile;
import appeng.tile.networking.CableBusTESR;
import appeng.tile.networking.TileCableBus;
import appeng.tile.networking.TileCableBusTESR;
import appeng.util.Platform;
import javax.annotation.Nullable;
import java.util.EnumSet;
import java.util.List;
import java.util.Random;
public class BlockCableBus extends AEBaseTileBlock<TileCableBus> /* FIXME implements IAEFacade */
{
public static final UnlistedProperty<CableBusRenderState> RENDER_STATE_PROPERTY = new UnlistedProperty<>( "cable_bus_render_state", CableBusRenderState.class );
private static final ICableBusContainer NULL_CABLE_BUS = new NullCableBusContainer();
private static Class<? extends AEBaseTile> noTesrTile;
@@ -100,35 +85,16 @@ public class BlockCableBus extends AEBaseTileBlock<TileCableBus> /* FIXME implem
public BlockCableBus()
{
super( AEGlassMaterial.INSTANCE );
this.setLightOpacity( 0 );
this.setFullSize( false );
this.setOpaque( false );
super( Properties.create(AEGlassMaterial.INSTANCE).notSolid() );
// this will actually be overwritten later through setupTile and the
// combined layers
this.setTileEntity( TileCableBus.class );
// FIXME ...uh this.setTileEntity( TileCableBus.class, TileCableBus::new );
}
@Override
public boolean isFullCube( BlockState state )
{
return false;
}
@Override
protected BlockStateContainer createBlockState()
{
return new ExtendedBlockState( this, new IProperty[0], new IUnlistedProperty[] { RENDER_STATE_PROPERTY } );
}
@Override
public BlockState getExtendedState( BlockState state, IBlockReader world, BlockPos pos )
{
CableBusRenderState renderState = this.cb( world, pos ).getRenderState();
renderState.setWorld( world );
renderState.setPos( pos );
return ( (IExtendedBlockState) state ).with( RENDER_STATE_PROPERTY, renderState );
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
return true;
}
@Override
@@ -138,17 +104,10 @@ public class BlockCableBus extends AEBaseTileBlock<TileCableBus> /* FIXME implem
}
@Override
public void onNeighborChange( final IBlockReader w, final BlockPos pos, final BlockPos neighbor )
{
public void onNeighborChange(BlockState state, IWorldReader w, BlockPos pos, BlockPos neighbor) {
this.cb( w, pos ).onNeighborChanged( w, pos, neighbor );
}
@Override
public Item getItemDropped( final BlockState state, final Random rand, final int fortune )
{
return null;
}
@Override
public int getWeakPower( final BlockState state, final IBlockReader w, final BlockPos pos, final Direction side )
{
@@ -164,8 +123,7 @@ public class BlockCableBus extends AEBaseTileBlock<TileCableBus> /* FIXME implem
}
@Override
public void onEntityCollidedWithBlock( final World w, final BlockPos pos, final BlockState state, final Entity entityIn )
{
public void onEntityCollision(BlockState state, World w, BlockPos pos, Entity entityIn) {
this.cb( w, pos ).onEntityCollision( entityIn );
}
@@ -188,26 +146,27 @@ public class BlockCableBus extends AEBaseTileBlock<TileCableBus> /* FIXME implem
}
@Override
public boolean isLadder( final BlockState state, final IBlockReader world, final BlockPos pos, final LivingEntity entity )
{
public boolean isLadder(BlockState state, IWorldReader world, BlockPos pos, LivingEntity entity) {
return this.cb( world, pos ).isLadder( entity );
}
// FIXME: This is now derived from the collision shape, and cannot be decided programatically anymore.
// FIXME: see Block.hasSolidSide. We need to remove isSolidOnSide
// FIXME @Override
// FIXME public boolean isSideSolid( final BlockState state, final IBlockReader w, final BlockPos pos, final Direction side )
// FIXME {
// FIXME return this.cb( w, pos ).isSolidOnSide( side );
// FIXME }
@Override
public boolean isSideSolid( final BlockState state, final IBlockReader w, final BlockPos pos, final Direction side )
{
return this.cb( w, pos ).isSolidOnSide( side );
public boolean isReplaceable(BlockState state, BlockItemUseContext useContext) {
// FIXME: Potentially check the fluid one too
return super.isReplaceable(state, useContext) && this.cb( useContext.getWorld(), useContext.getPos() ).isEmpty();
}
@Override
public boolean isReplaceable( final IBlockReader w, final BlockPos pos )
{
return this.cb( w, pos ).isEmpty();
}
@Override
public boolean removedByPlayer( final BlockState state, final World world, final BlockPos pos, final PlayerEntity player, final boolean willHarvest )
{
public boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player, boolean willHarvest, IFluidState fluid) {
if( player.abilities.isCreativeMode )
{
final AEBaseTile tile = this.getTileEntity( world, pos );
@@ -217,7 +176,7 @@ public class BlockCableBus extends AEBaseTileBlock<TileCableBus> /* FIXME implem
}
// maybe ray trace?
}
return super.removedByPlayer( state, world, pos, player, willHarvest );
return super.removedByPlayer( state, world, pos, player, willHarvest, fluid );
}
@Override
@@ -232,9 +191,8 @@ public class BlockCableBus extends AEBaseTileBlock<TileCableBus> /* FIXME implem
}
@Override
public ItemStack getPickBlock( final BlockState state, final RayTraceResult target, final World world, final BlockPos pos, final PlayerEntity player )
{
final Vec3d v3 = target.hitVec.subtract( pos.getX(), pos.getY(), pos.getZ() );
public ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos, PlayerEntity player) {
final Vec3d v3 = target.getHitVec().subtract( pos.getX(), pos.getY(), pos.getZ() );
final SelectedPart sp = this.cb( world, pos ).selectPart( v3 );
if( sp.part != null )
@@ -261,7 +219,12 @@ public class BlockCableBus extends AEBaseTileBlock<TileCableBus> /* FIXME implem
return true;
}
ICableBusContainer cb = this.cb( world, target.getBlockPos() );
if (target.getType() != Type.BLOCK) {
return false;
}
BlockPos blockPos = new BlockPos(target.getHitVec().x, target.getHitVec().y, target.getHitVec().z);
ICableBusContainer cb = this.cb( world, blockPos );
// Our built-in model has the actual baked sprites we need
IBakedModel model = Minecraft.getInstance().getBlockRendererDispatcher().getModelForState( this.getDefaultState() );
@@ -280,22 +243,19 @@ public class BlockCableBus extends AEBaseTileBlock<TileCableBus> /* FIXME implem
TextureAtlasSprite texture = Platform.pickRandom( cableBusModel.getParticleTextures( renderState ) );
if( texture != null )
{
double x = target.hitVec.x;
double y = target.hitVec.y;
double z = target.hitVec.z;
Particle fx = new DestroyFX( world, x, y, z, 0.0D, 0.0D, 0.0D, state ).setBlockPos( target.getBlockPos() ).multipleParticleScaleBy( 0.8F );
fx.setParticleTexture( texture );
effectRenderer.addEffect( fx );
double x = target.getHitVec().x;
double y = target.getHitVec().y;
double z = target.getHitVec().z;
// FIXME: Check how this looks, probably like shit, maybe provide parts the ability to supply particle textures???
effectRenderer.addEffect(new CableBusBreakingParticle(world, x, y, z, texture)
.multipleParticleScaleBy( 0.8F ));
}
return true;
}
@Override
@OnlyIn( Dist.CLIENT )
public boolean addDestroyEffects( final World world, final BlockPos pos, final ParticleManager effectRenderer )
{
public boolean addDestroyEffects(BlockState state, World world, BlockPos pos, ParticleManager effectRenderer) {
ICableBusContainer cb = this.cb( world, pos );
// Our built-in model has the actual baked sprites we need
@@ -325,14 +285,14 @@ public class BlockCableBus extends AEBaseTileBlock<TileCableBus> /* FIXME implem
// Randomly select one of the textures if the cable bus has more than just one possibility here
final TextureAtlasSprite texture = Platform.pickRandom( textures );
final double d0 = pos.getX() + ( j + 0.5D ) / 4.0D;
final double d1 = pos.getY() + ( k + 0.5D ) / 4.0D;
final double d2 = pos.getZ() + ( l + 0.5D ) / 4.0D;
final ParticleDigging particle = new DestroyFX( world, d0, d1, d2, d0 - pos.getX() - 0.5D, d1 - pos
.getY() - 0.5D, d2 - pos.getZ() - 0.5D, this.getDefaultState() ).setBlockPos( pos );
final double x = pos.getX() + ( j + 0.5D ) / 4.0D;
final double y = pos.getY() + ( k + 0.5D ) / 4.0D;
final double z = pos.getZ() + ( l + 0.5D ) / 4.0D;
particle.setParticleTexture( texture );
effectRenderer.addEffect( particle );
// FIXME: Check how this looks, probably like shit, maybe provide parts the ability to supply particle textures???
Particle effect = new CableBusBreakingParticle(world, x, y, z, x - pos.getX() - 0.5D,
y - pos.getY() - 0.5D, z - pos.getZ() - 0.5D, texture);
effectRenderer.addEffect(effect);
}
}
}
@@ -378,20 +338,21 @@ public class BlockCableBus extends AEBaseTileBlock<TileCableBus> /* FIXME implem
}
@Override
public void onBlockClicked( World worldIn, BlockPos pos, PlayerEntity playerIn )
{
public void onBlockClicked(BlockState state, World worldIn, BlockPos pos, PlayerEntity player) {
if( Platform.isClient() )
{
final RayTraceResult rtr = Minecraft.getInstance().objectMouseOver;
if( rtr != null && rtr.typeOfHit == Type.BLOCK && pos.equals( rtr.getBlockPos() ) )
if( rtr instanceof BlockRayTraceResult)
{
final Vec3d hitVec = rtr.hitVec.subtract( new Vec3d( pos ) );
BlockRayTraceResult brtr = (BlockRayTraceResult) rtr;
if (brtr.getPos().equals(pos)) {
final Vec3d hitVec = rtr.getHitVec().subtract(new Vec3d(pos));
if( this.cb( worldIn, pos ).clicked( playerIn, Hand.MAIN_HAND, hitVec ) )
{
NetworkHandler.instance()
.sendToServer(
new PacketClick( pos, rtr.sideHit, (float) hitVec.x, (float) hitVec.y, (float) hitVec.z, Hand.MAIN_HAND, true ) );
if (this.cb(worldIn, pos).clicked(player, Hand.MAIN_HAND, hitVec)) {
NetworkHandler.instance()
.sendToServer(
new PacketClick(pos, ((BlockRayTraceResult) rtr).getFace(), (float) hitVec.x, (float) hitVec.y, (float) hitVec.z, Hand.MAIN_HAND, true));
}
}
}
}
@@ -405,7 +366,8 @@ public class BlockCableBus extends AEBaseTileBlock<TileCableBus> /* FIXME implem
@Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand, final @Nullable ItemStack heldItem, final BlockRayTraceResult hit)
{
return this.cb( w, pos ).activate( player, hand, new Vec3d( hitX, hitY, hitZ ) );
return this.cb( w, pos ).activate( player, hand, hit.getHitVec() ) ? ActionResultType.SUCCESS
: ActionResultType.PASS;
}
@Override
@@ -435,9 +397,9 @@ public class BlockCableBus extends AEBaseTileBlock<TileCableBus> /* FIXME implem
public void setupTile()
{
noTesrTile = TileCableBus.class;
this.setTileEntity( noTesrTile );
// FIXME ... uh ... this.setTileEntity( noTesrTile );
GameRegistry.registerTileEntity( noTesrTile, AppEng.MOD_ID.toLowerCase() + ":" + "BlockCableBus" );
// FIXME oh no... GameRegistry.registerTileEntity( noTesrTile, AppEng.MOD_ID.toLowerCase() + ":" + "BlockCableBus" );
if( Platform.isClient() )
{
@@ -449,33 +411,27 @@ public class BlockCableBus extends AEBaseTileBlock<TileCableBus> /* FIXME implem
private static void setupTesr()
{
tesrTile = TileCableBusTESR.class;
GameRegistry.registerTileEntity( tesrTile, AppEng.MOD_ID.toLowerCase() + ":" + "ClientOnly_TESR_CableBus" );
ClientRegistry.bindTileEntitySpecialRenderer( BlockCableBus.getTesrTile(), new CableBusTESR() );
// FIXME oh no... GameRegistry.registerTileEntity( tesrTile, AppEng.MOD_ID.toLowerCase() + ":" + "ClientOnly_TESR_CableBus" );
// FIXME oh no... ClientRegistry.bindTileEntitySpecialRenderer( BlockCableBus.getTesrTile(), new CableBusTESR() );
}
@Override
public boolean canRenderInLayer( BlockState state, BlockRenderLayer layer )
{
return true;
}
@Override
public BlockState getFacadeState( IBlockReader world, BlockPos pos, Direction side )
{
if( side != null )
{
IFacadeContainer container = this.fc( world, pos );
if( container != null )
{
IFacadePart facade = container.getFacade( AEPartLocation.fromFacing( side ) );
if( facade != null )
{
return facade.getBlockState();
}
}
}
return world.getBlockState( pos );
}
// FIXME FACADES @Override
// FIXME FACADES public BlockState getFacadeState( IBlockReader world, BlockPos pos, Direction side )
// FIXME FACADES {
// FIXME FACADES if( side != null )
// FIXME FACADES {
// FIXME FACADES IFacadeContainer container = this.fc( world, pos );
// FIXME FACADES if( container != null )
// FIXME FACADES {
// FIXME FACADES IFacadePart facade = container.getFacade( AEPartLocation.fromFacing( side ) );
// FIXME FACADES if( facade != null )
// FIXME FACADES {
// FIXME FACADES return facade.getBlockState();
// FIXME FACADES }
// FIXME FACADES }
// FIXME FACADES }
// FIXME FACADES return world.getBlockState( pos );
// FIXME FACADES }
public static Class<? extends AEBaseTile> getNoTesrTile()
{
@@ -487,16 +443,6 @@ public class BlockCableBus extends AEBaseTileBlock<TileCableBus> /* FIXME implem
return tesrTile;
}
// Helper to get access to the protected constructor
@OnlyIn( Dist.CLIENT )
private static class DestroyFX extends ParticleDigging
{
DestroyFX( World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, BlockState state )
{
super( worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn, state );
}
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
@@ -21,21 +21,22 @@ package appeng.block.networking;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.BlockStateContainer;
import net.minecraft.block.BlockState;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.state.EnumProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.util.Direction;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import appeng.block.AEBaseTileBlock;
import appeng.tile.networking.TileController;
public class BlockController extends AEBaseTileBlock
public class BlockController extends AEBaseTileBlock<TileController>
{
public enum ControllerBlockState implements IStringSerializable
@@ -67,29 +68,23 @@ public class BlockController extends AEBaseTileBlock
}
public static final PropertyEnum<ControllerBlockState> CONTROLLER_STATE = PropertyEnum.create( "state", ControllerBlockState.class );
public static final EnumProperty<ControllerBlockState> CONTROLLER_STATE = EnumProperty.create( "state", ControllerBlockState.class );
public static final PropertyEnum<ControllerRenderType> CONTROLLER_TYPE = PropertyEnum.create( "type", ControllerRenderType.class );
public static final EnumProperty<ControllerRenderType> CONTROLLER_TYPE = EnumProperty.create( "type", ControllerRenderType.class );
public BlockController()
{
super( Material.IRON );
this.setHardness( 6 );
super( Block.Properties.create(Material.IRON).hardnessAndResistance(6) );
this.setDefaultState( this.getDefaultState()
.with( CONTROLLER_STATE, ControllerBlockState.offline )
.with( CONTROLLER_TYPE, ControllerRenderType.block ) );
}
@Override
protected IProperty[] getAEStates()
{
return new IProperty[] { CONTROLLER_STATE, CONTROLLER_TYPE };
}
@Override
protected BlockStateContainer createBlockState()
{
return new BlockStateContainer( this, this.getAEStates() );
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder);
builder.add(CONTROLLER_STATE);
builder.add(CONTROLLER_TYPE);
}
/**
@@ -98,8 +93,9 @@ public class BlockController extends AEBaseTileBlock
* get a rudimentary connected texture feel for the controller based on how it is placed.
*/
@Override
public BlockState getActualState( BlockState state, IBlockReader world, BlockPos pos )
{
public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld world, BlockPos pos, BlockPos facingPos) {
// FIXME: this might work, or might _NOT_ work, but needs to be investigated
// Only used for columns, really
ControllerRenderType type = ControllerRenderType.block;
@@ -109,12 +105,12 @@ public class BlockController extends AEBaseTileBlock
int z = pos.getZ();
// Detect whether controllers are on both sides of the x, y, and z axes
final boolean xx = this.getTileEntity( world, x - 1, y, z ) instanceof TileController && this.getTileEntity( world, x + 1, y,
z ) instanceof TileController;
final boolean yy = this.getTileEntity( world, x, y - 1, z ) instanceof TileController && this.getTileEntity( world, x, y + 1,
z ) instanceof TileController;
final boolean zz = this.getTileEntity( world, x, y, z - 1 ) instanceof TileController && this.getTileEntity( world, x, y,
z + 1 ) instanceof TileController;
final boolean xx = this.getTileEntity(world, x - 1, y, z) != null
&& this.getTileEntity(world, x + 1, y, z) != null;
final boolean yy = this.getTileEntity(world, x, y - 1, z) != null
&& this.getTileEntity(world, x, y + 1, z) != null;
final boolean zz = this.getTileEntity(world, x, y, z - 1) != null
&& this.getTileEntity(world, x, y, z + 1) != null;
if( xx && !yy && !zz )
{
@@ -153,25 +149,6 @@ public class BlockController extends AEBaseTileBlock
return state;
}
@Override
public int getMetaFromState( final BlockState state )
{
return state.get( CONTROLLER_STATE ).ordinal();
}
@Override
public BlockState getStateFromMeta( final int meta )
{
ControllerBlockState state = ControllerBlockState.values()[meta];
return this.getDefaultState().with( CONTROLLER_STATE, state );
}
@Override
public BlockRenderLayer getBlockLayer()
{
return BlockRenderLayer.CUTOUT;
}
@Override
public void neighborChanged( BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving )
{
@@ -21,13 +21,14 @@ package appeng.block.networking;
import appeng.block.AEBaseTileBlock;
import appeng.helpers.AEGlassMaterial;
import appeng.tile.networking.TileCreativeEnergyCell;
public class BlockCreativeEnergyCell extends AEBaseTileBlock
public class BlockCreativeEnergyCell extends AEBaseTileBlock<TileCreativeEnergyCell>
{
public BlockCreativeEnergyCell()
{
super( AEGlassMaterial.INSTANCE );
super( Properties.create(AEGlassMaterial.INSTANCE) );
}
}
@@ -19,16 +19,18 @@
package appeng.block.networking;
import appeng.tile.networking.TileEnergyAcceptor;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import appeng.block.AEBaseTileBlock;
public class BlockEnergyAcceptor extends AEBaseTileBlock
public class BlockEnergyAcceptor extends AEBaseTileBlock<TileEnergyAcceptor>
{
public BlockEnergyAcceptor()
{
super( Material.IRON );
super(Block.Properties.create(Material.IRON) );
}
}
@@ -19,12 +19,14 @@
package appeng.block.networking;
import net.minecraft.state.IProperty;
import net.minecraft.block.properties.PropertyInteger;
import appeng.tile.networking.TileEnergyCell;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.state.IntegerProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.util.NonNullList;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -32,34 +34,21 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.block.AEBaseTileBlock;
import appeng.helpers.AEGlassMaterial;
public class BlockEnergyCell extends AEBaseTileBlock
public class BlockEnergyCell extends AEBaseTileBlock<TileEnergyCell>
{
public static final PropertyInteger ENERGY_STORAGE = PropertyInteger.create( "fullness", 0, 7 );
@Override
public int getMetaFromState( final BlockState state )
{
return state.get( ENERGY_STORAGE );
}
@Override
public BlockState getStateFromMeta( final int meta )
{
return this.getDefaultState().with( ENERGY_STORAGE, Math.min( 7, Math.max( 0, meta ) ) );
}
public static final IntegerProperty ENERGY_STORAGE = IntegerProperty.create( "fullness", 0, 7 );
public BlockEnergyCell()
{
super( AEGlassMaterial.INSTANCE );
super( Properties.create(AEGlassMaterial.INSTANCE) );
}
@Override
@OnlyIn( Dist.CLIENT )
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> itemStacks)
{
super.getSubBlocks( tabs, itemStacks );
super.fillItemGroup( group, itemStacks );
final ItemStack charged = new ItemStack( this, 1 );
final CompoundNBT tag = charged.getOrCreateTag();
@@ -75,9 +64,9 @@ public class BlockEnergyCell extends AEBaseTileBlock
}
@Override
protected IProperty[] getAEStates()
{
return new IProperty[] { ENERGY_STORAGE };
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder);
builder.add(ENERGY_STORAGE);
}
}
@@ -19,7 +19,6 @@
package appeng.block.networking;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
@@ -28,7 +27,6 @@ import appeng.block.AEBaseBlockItemChargeable;
import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering;
import appeng.tile.networking.TileEnergyCell;
public class BlockEnergyCellRendering extends BlockRenderingCustomizer
@@ -44,7 +42,7 @@ public class BlockEnergyCellRendering extends BlockRenderingCustomizer
@Override
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
{
itemRendering.meshDefinition( this::getItemModel );
// FIXME itemRendering.meshDefinition( this::getItemModel );
// Note: Since we use the block models, we dont need to register custom variants
}
@@ -52,13 +50,13 @@ public class BlockEnergyCellRendering extends BlockRenderingCustomizer
* Determines which version of the energy cell model should be used depending on the fill factor
* of the item stack.
*/
private ModelResourceLocation getItemModel( ItemStack is )
{
double fillFactor = getFillFactor( is );
int storageLevel = TileEnergyCell.getStorageLevelFromFillFactor( fillFactor );
return new ModelResourceLocation( this.baseModel, "fullness=" + storageLevel );
}
// FIXME private ModelResourceLocation getItemModel( ItemStack is )
// FIXME {
// FIXME double fillFactor = getFillFactor( is );
// FIXME
// FIXME int storageLevel = TileEnergyCell.getStorageLevelFromFillFactor( fillFactor );
// FIXME return new ModelResourceLocation( this.baseModel, "fullness=" + storageLevel );
// FIXME }
/**
* Helper method that returns the energy fill factor (between 0 and 1) of a given item stack.
@@ -19,33 +19,30 @@
package appeng.block.networking;
import java.util.Collections;
import java.util.List;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import appeng.block.AEBaseTileBlock;
import appeng.helpers.AEGlassMaterial;
import appeng.tile.networking.TileWireless;
import appeng.util.Platform;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.state.EnumProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.IStringSerializable;
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 net.minecraft.world.IWorld;
import net.minecraft.world.World;
import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.helpers.AEGlassMaterial;
import appeng.helpers.ICustomCollision;
import appeng.tile.networking.TileWireless;
import appeng.util.Platform;
public class BlockWireless extends AEBaseTileBlock implements ICustomCollision
public class BlockWireless extends AEBaseTileBlock<TileWireless>
{
enum State implements IStringSerializable
@@ -61,29 +58,22 @@ public class BlockWireless extends AEBaseTileBlock implements ICustomCollision
}
}
public static final PropertyEnum<State> STATE = PropertyEnum.create( "state", State.class );
public static final EnumProperty<State> STATE = EnumProperty.create( "state", State.class );
public BlockWireless()
{
super( AEGlassMaterial.INSTANCE );
this.setLightOpacity( 0 );
super( Properties.create(AEGlassMaterial.INSTANCE) );
this.setFullSize( false );
this.setOpaque( false );
this.setDefaultState( this.getDefaultState().with( STATE, State.OFF ) );
}
// FIXME This has to be triggered by the tile entity's state changing directly
@Override
public BlockRenderLayer getBlockLayer()
{
return BlockRenderLayer.CUTOUT;
}
@Override
public BlockState getActualState( BlockState state, IBlockReader worldIn, BlockPos pos )
{
public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld world, BlockPos pos, BlockPos facingPos) {
State teState = State.OFF;
TileWireless te = this.getTileEntity( worldIn, pos );
TileWireless te = this.getTileEntity( world, pos );
if( te != null )
{
if( te.isActive() )
@@ -96,36 +86,34 @@ public class BlockWireless extends AEBaseTileBlock implements ICustomCollision
}
}
return super.getActualState( state, worldIn, pos )
return super.updatePostPlacement(stateIn, facing, facingState, world, pos, facingPos)
.with( STATE, teState );
}
@Override
protected IProperty[] getAEStates()
{
return new IProperty[] { STATE };
protected void fillStateContainer(StateContainer.Builder builder) {
super.fillStateContainer(builder);
builder.add(STATE);
}
@Override
public boolean onBlockActivated( final World w, final BlockPos pos, final BlockState state, final PlayerEntity player, final Hand hand, final Direction side, final float hitX, final float hitY, final float hitZ )
{
public ActionResultType onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
final TileWireless tg = this.getTileEntity( w, pos );
if( tg != null && !player.isCrouching() )
{
if( Platform.isServer() )
{
Platform.openGUI( player, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_WIRELESS );
// FIXME Platform.openGUI( player, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_WIRELESS );
}
return true;
return ActionResultType.SUCCESS;
}
return super.onBlockActivated( w, pos, state, player, hand, side, hitX, hitY, hitZ );
return super.onBlockActivated( state, w, pos, player, hand, hit );
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( final World w, final BlockPos pos, final Entity thePlayer, final boolean b )
{
public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
final TileWireless tile = this.getTileEntity( w, pos );
if( tile != null )
{
@@ -180,14 +168,14 @@ public class BlockWireless extends AEBaseTileBlock implements ICustomCollision
break;
}
return Collections.singletonList( new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ ) );
return VoxelShapes.create( new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ ) );
}
return Collections.singletonList( new AxisAlignedBB( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) );
return VoxelShapes.fullCube();
}
@Override
public void addCollidingBlockToList( final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e )
{
public VoxelShape getCollisionShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
final TileWireless tile = this.getTileEntity( w, pos );
if( tile != null )
{
@@ -242,18 +230,17 @@ public class BlockWireless extends AEBaseTileBlock implements ICustomCollision
break;
}
out.add( new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ ) );
return VoxelShapes.create( new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ ) );
}
else
{
out.add( new AxisAlignedBB( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
return VoxelShapes.fullCube();
}
}
@Override
public boolean isFullCube( BlockState state )
{
return false;
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
return true;
}
}
@@ -19,17 +19,22 @@
package appeng.block.networking;
import appeng.parts.CableBusContainer;
import appeng.tile.networking.TileCableBus;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraft.world.ILightReader;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.api.util.AEColor;
import appeng.client.render.cablebus.CableBusRenderState;
import javax.annotation.Nullable;
/**
* Exposes the cable bus color as tint indices 0 (dark variant), 1 (medium variant) and 2 (bright variant).
@@ -39,17 +44,16 @@ public class CableBusColor implements IBlockColor
{
@Override
public int colorMultiplier( BlockState state, IBlockReader worldIn, BlockPos pos, int color )
{
public int getColor(BlockState state, @Nullable ILightReader worldIn, @Nullable BlockPos pos, int color) {
// FIXME: Once COLOR becomes part of the block state, change this
AEColor busColor = AEColor.TRANSPARENT;
if( state instanceof IExtendedBlockState )
{
CableBusRenderState renderState = ( (IExtendedBlockState) state ).getValue( BlockCableBus.RENDER_STATE_PROPERTY );
if( renderState != null )
{
busColor = renderState.getCableColor();
if (worldIn != null && pos != null) {
TileEntity tileEntity = worldIn.getTileEntity(pos);
if (tileEntity instanceof TileCableBus) {
CableBusContainer container = ((TileCableBus) tileEntity).getCableBus();
busColor = container.getColor();
}
}
@@ -45,6 +45,16 @@ public class CableBusRendering extends BlockRenderingCustomizer
@OnlyIn( Dist.CLIENT )
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
{
/* FIXME this was previously
*
@Override
public boolean canRenderInLayer( BlockState state, BlockRenderLayer layer )
{
return true;
}
*/
rendering.renderType(rt -> true);
rendering.builtInModel( "models/block/builtin/cable_bus", new CableBusModel( this.partModels ) );
rendering.blockColor( new CableBusColor() );
rendering.modelCustomizer( ( loc, model ) -> model );
@@ -22,6 +22,7 @@ package appeng.block.networking;
import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering;
import net.minecraft.client.renderer.RenderType;
public class ControllerRendering extends BlockRenderingCustomizer
@@ -31,5 +32,6 @@ public class ControllerRendering extends BlockRenderingCustomizer
{
// Disables the default model rotator
rendering.modelCustomizer( ( loc, model ) -> model );
rendering.renderType(RenderType.getCutout());
}
}
@@ -2,6 +2,7 @@
package appeng.block.networking;
import net.minecraft.client.renderer.RenderType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -18,6 +19,7 @@ public class WirelessRendering extends BlockRenderingCustomizer
@OnlyIn( Dist.CLIENT )
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
{
rendering.renderType(RenderType.getCutout());
rendering.blockColor( new StaticBlockColor( AEColor.TRANSPARENT ) );
}
}