Sky Chest TESR / Tile Entity Registration Changes
This commit is contained in:
@@ -147,6 +147,13 @@ sourceSets {
|
|||||||
include 'appeng/container/ContainerOpenContext.java'
|
include 'appeng/container/ContainerOpenContext.java'
|
||||||
include 'appeng/decorative/solid/BlockSkyStone.java'
|
include 'appeng/decorative/solid/BlockSkyStone.java'
|
||||||
|
|
||||||
|
include 'appeng/block/storage/BlockSkyChest.java'
|
||||||
|
include 'appeng/tile/storage/TileSkyChest.java'
|
||||||
|
include 'appeng/block/storage/SkyChestRenderingCustomizer.java'
|
||||||
|
include 'appeng/client/render/tesr/SkyChestTESR.java'
|
||||||
|
include 'appeng/tile/inventory/AppEngInternalInventory.java'
|
||||||
|
include 'appeng/util/inv/filter/**'
|
||||||
|
|
||||||
// include 'appeng/client/ClientHelper.java'
|
// include 'appeng/client/ClientHelper.java'
|
||||||
// include 'appeng/server/ServerHelper.java'
|
// include 'appeng/server/ServerHelper.java'
|
||||||
include 'appeng/block/AEBaseBlock.java'
|
include 'appeng/block/AEBaseBlock.java'
|
||||||
|
|||||||
@@ -21,10 +21,13 @@ package appeng.block;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import appeng.bootstrap.definitions.TileEntityDefinition;
|
||||||
|
import appeng.core.features.TileDefinition;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
@@ -37,6 +40,7 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.state.StateContainer;
|
import net.minecraft.state.StateContainer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
@@ -59,11 +63,13 @@ import appeng.util.Platform;
|
|||||||
import appeng.util.SettingsFrom;
|
import appeng.util.SettingsFrom;
|
||||||
|
|
||||||
|
|
||||||
public abstract class AEBaseTileBlock extends AEBaseBlock implements ITileEntityProvider
|
public abstract class AEBaseTileBlock<T extends AEBaseTile> extends AEBaseBlock
|
||||||
{
|
{
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private Class<? extends AEBaseTile> tileEntityType;
|
private Class<T> tileEntityClass;
|
||||||
|
@Nonnull
|
||||||
|
private Supplier<T> tileEntityFactory;
|
||||||
|
|
||||||
public AEBaseTileBlock( final Block.Properties props )
|
public AEBaseTileBlock( final Block.Properties props )
|
||||||
{
|
{
|
||||||
@@ -107,10 +113,11 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements ITileEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO : Was this change needed?
|
// TODO : Was this change needed?
|
||||||
public void setTileEntity( final Class<? extends AEBaseTile> c )
|
public void setTileEntity( final Class<T> tileEntityClass, Supplier<T> factory )
|
||||||
{
|
{
|
||||||
this.tileEntityType = c;
|
this.tileEntityClass = tileEntityClass;
|
||||||
this.setInventory( AEBaseInvTile.class.isAssignableFrom( c ) );
|
this.tileEntityFactory = factory;
|
||||||
|
this.setInventory( AEBaseInvTile.class.isAssignableFrom( tileEntityClass ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -121,22 +128,22 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements ITileEntity
|
|||||||
|
|
||||||
private boolean hasBlockTileEntity()
|
private boolean hasBlockTileEntity()
|
||||||
{
|
{
|
||||||
return this.tileEntityType != null;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class<? extends AEBaseTile> getTileEntityClass()
|
public Class<T> getTileEntityClass()
|
||||||
{
|
{
|
||||||
return this.tileEntityType;
|
return this.tileEntityClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public <T extends AEBaseTile> T getTileEntity( final IBlockReader w, final int x, final int y, final int z )
|
public T getTileEntity( final IBlockReader w, final int x, final int y, final int z )
|
||||||
{
|
{
|
||||||
return this.getTileEntity( w, new BlockPos( x, y, z ) );
|
return this.getTileEntity( w, new BlockPos( x, y, z ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public <T extends AEBaseTile> T getTileEntity( final IBlockReader w, final BlockPos pos )
|
public T getTileEntity( final IBlockReader w, final BlockPos pos )
|
||||||
{
|
{
|
||||||
if( !this.hasBlockTileEntity() )
|
if( !this.hasBlockTileEntity() )
|
||||||
{
|
{
|
||||||
@@ -144,9 +151,9 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements ITileEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
final TileEntity te = w.getTileEntity( pos );
|
final TileEntity te = w.getTileEntity( pos );
|
||||||
if( this.tileEntityType.isInstance( te ) )
|
if( this.tileEntityClass.isInstance( te ) )
|
||||||
{
|
{
|
||||||
return (T) te;
|
return this.tileEntityClass.cast(te);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -155,23 +162,7 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements ITileEntity
|
|||||||
@Override
|
@Override
|
||||||
public final TileEntity createTileEntity( BlockState state, IBlockReader world )
|
public final TileEntity createTileEntity( BlockState state, IBlockReader world )
|
||||||
{
|
{
|
||||||
if( this.hasBlockTileEntity() )
|
return this.tileEntityFactory.get();
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return this.tileEntityType.newInstance();
|
|
||||||
}
|
|
||||||
catch( final InstantiationException e )
|
|
||||||
{
|
|
||||||
throw new IllegalStateException( "Failed to create a new instance of an illegal class " + this.tileEntityType, e );
|
|
||||||
}
|
|
||||||
catch( final IllegalAccessException e )
|
|
||||||
{
|
|
||||||
throw new IllegalStateException( "Failed to create a new instance of " + this.tileEntityType + ", because lack of permissions", e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -35,6 +35,6 @@ public class CrankRendering extends BlockRenderingCustomizer
|
|||||||
@OnlyIn( Dist.CLIENT )
|
@OnlyIn( Dist.CLIENT )
|
||||||
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
|
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
|
||||||
{
|
{
|
||||||
rendering.tesr( new CrankTESR() );
|
rendering.tileEntityRenderer( new CrankTESR() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class InscriberRendering extends BlockRenderingCustomizer
|
|||||||
@Override
|
@Override
|
||||||
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
|
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
|
||||||
{
|
{
|
||||||
rendering.tesr( new InscriberTESR() );
|
rendering.tileEntityRenderer( new InscriberTESR() );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class SkyCompassRendering extends BlockRenderingCustomizer
|
|||||||
@OnlyIn( Dist.CLIENT )
|
@OnlyIn( Dist.CLIENT )
|
||||||
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
|
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
|
||||||
{
|
{
|
||||||
rendering.tesr( new SkyCompassTESR() );
|
rendering.tileEntityRenderer( new SkyCompassTESR() );
|
||||||
itemRendering.model( ITEM_MODEL );
|
itemRendering.model( ITEM_MODEL );
|
||||||
itemRendering.builtInModel( "models/block/builtin/sky_compass", new SkyCompassModel() );
|
itemRendering.builtInModel( "models/block/builtin/sky_compass", new SkyCompassModel() );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,29 +24,28 @@ import java.util.List;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.BlockRenderType;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.EnumBlockRenderType;
|
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BlockRayTraceResult;
|
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.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import appeng.api.util.AEPartLocation;
|
|
||||||
import appeng.block.AEBaseTileBlock;
|
import appeng.block.AEBaseTileBlock;
|
||||||
import appeng.core.sync.GuiBridge;
|
|
||||||
import appeng.helpers.ICustomCollision;
|
|
||||||
import appeng.tile.storage.TileSkyChest;
|
import appeng.tile.storage.TileSkyChest;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
|
|
||||||
|
|
||||||
public class BlockSkyChest extends AEBaseTileBlock implements ICustomCollision
|
public class BlockSkyChest extends AEBaseTileBlock<TileSkyChest>
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final double AABB_OFFSET_BOTTOM = 0.00;
|
private static final double AABB_OFFSET_BOTTOM = 0.00;
|
||||||
@@ -60,20 +59,20 @@ public class BlockSkyChest extends AEBaseTileBlock implements ICustomCollision
|
|||||||
|
|
||||||
public final SkyChestType type;
|
public final SkyChestType type;
|
||||||
|
|
||||||
public BlockSkyChest( final SkyChestType type )
|
public BlockSkyChest( final SkyChestType type, Properties props )
|
||||||
{
|
{
|
||||||
super( Material.ROCK );
|
super( props );
|
||||||
this.setOpaque( this.setFullSize( false ) );
|
|
||||||
this.lightOpacity = 0;
|
|
||||||
this.setHardness( 50 );
|
|
||||||
this.blockResistance = 150.0f;
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumBlockRenderType getRenderType( BlockState state )
|
public BlockRenderType getRenderType(BlockState state) {
|
||||||
{
|
return BlockRenderType.ENTITYBLOCK_ANIMATED;
|
||||||
return EnumBlockRenderType.ENTITYBLOCK_ANIMATED;
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -81,29 +80,20 @@ public class BlockSkyChest extends AEBaseTileBlock implements ICustomCollision
|
|||||||
{
|
{
|
||||||
if( Platform.isServer() )
|
if( Platform.isServer() )
|
||||||
{
|
{
|
||||||
Platform.openGUI( player, this.getTileEntity( w, pos ), AEPartLocation.fromFacing(hit), GuiBridge.GUI_SKYCHEST );
|
// FIXME Platform.openGUI( player, this.getTileEntity( w, pos ), AEPartLocation.fromFacing(hit.getFace()), GuiBridge.GUI_SKYCHEST );
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( final World w, final BlockPos pos, final Entity thePlayer, final boolean b )
|
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||||
{
|
// TODO Cache this! It can't be that hard!
|
||||||
final AxisAlignedBB aabb = this.computeAABB( w, pos );
|
AxisAlignedBB aabb = computeAABB(worldIn, pos);
|
||||||
|
return VoxelShapes.create(aabb);
|
||||||
return Collections.singletonList( aabb );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private AxisAlignedBB computeAABB(final IBlockReader w, final BlockPos pos )
|
||||||
public void addCollidingBlockToList( final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e )
|
|
||||||
{
|
|
||||||
final AxisAlignedBB aabb = this.computeAABB( w, pos );
|
|
||||||
|
|
||||||
out.add( aabb );
|
|
||||||
}
|
|
||||||
|
|
||||||
private AxisAlignedBB computeAABB( final World w, final BlockPos pos )
|
|
||||||
{
|
{
|
||||||
final TileSkyChest sk = this.getTileEntity( w, pos );
|
final TileSkyChest sk = this.getTileEntity( w, pos );
|
||||||
Direction o = Direction.UP;
|
Direction o = Direction.UP;
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
package appeng.block.storage;
|
package appeng.block.storage;
|
||||||
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
@@ -31,7 +30,6 @@ import appeng.client.render.tesr.SkyChestTESR;
|
|||||||
|
|
||||||
public class SkyChestRenderingCustomizer extends BlockRenderingCustomizer
|
public class SkyChestRenderingCustomizer extends BlockRenderingCustomizer
|
||||||
{
|
{
|
||||||
|
|
||||||
private final BlockSkyChest.SkyChestType type;
|
private final BlockSkyChest.SkyChestType type;
|
||||||
|
|
||||||
public SkyChestRenderingCustomizer( BlockSkyChest.SkyChestType type )
|
public SkyChestRenderingCustomizer( BlockSkyChest.SkyChestType type )
|
||||||
@@ -43,12 +41,11 @@ public class SkyChestRenderingCustomizer extends BlockRenderingCustomizer
|
|||||||
@Override
|
@Override
|
||||||
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
|
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
|
||||||
{
|
{
|
||||||
rendering.tesr( new SkyChestTESR() );
|
|
||||||
|
|
||||||
// Register a custom non-tesr item model
|
// Register a custom non-tesr item model
|
||||||
String modelName = this.getModelFromType();
|
// FIXME: This should not be required anymore!
|
||||||
ModelResourceLocation model = new ModelResourceLocation( "appliedenergistics2:" + modelName, "inventory" );
|
// FIXME String modelName = this.getModelFromType();
|
||||||
itemRendering.model( model ).variants( model );
|
// FIXME ModelResourceLocation model = new ModelResourceLocation( "appliedenergistics2:" + modelName, "inventory" );
|
||||||
|
// FIXME itemRendering.model( model ).variants( model );
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getModelFromType()
|
private String getModelFromType()
|
||||||
|
|||||||
@@ -24,18 +24,17 @@ import java.util.Collections;
|
|||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import appeng.bootstrap.components.ITileEntityRegistrationComponent;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.renderer.RenderType;
|
|
||||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||||
import net.minecraft.item.BlockItem;
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemGroup;
|
import net.minecraft.item.ItemGroup;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
@@ -48,7 +47,6 @@ import appeng.bootstrap.components.IBlockRegistrationComponent;
|
|||||||
import appeng.bootstrap.components.IItemRegistrationComponent;
|
import appeng.bootstrap.components.IItemRegistrationComponent;
|
||||||
import appeng.bootstrap.components.IPreInitComponent;
|
import appeng.bootstrap.components.IPreInitComponent;
|
||||||
import appeng.bootstrap.definitions.TileEntityDefinition;
|
import appeng.bootstrap.definitions.TileEntityDefinition;
|
||||||
import appeng.core.AEConfig;
|
|
||||||
import appeng.core.AppEng;
|
import appeng.core.AppEng;
|
||||||
import appeng.core.CreativeTab;
|
import appeng.core.CreativeTab;
|
||||||
import appeng.core.features.AEFeature;
|
import appeng.core.features.AEFeature;
|
||||||
@@ -201,27 +199,15 @@ class BlockDefinitionBuilder implements IBlockBuilder
|
|||||||
// Register all extra handlers
|
// Register all extra handlers
|
||||||
this.bootstrapComponents.forEach( component -> this.factory.addBootstrapComponent( component.apply( block, item ) ) );
|
this.bootstrapComponents.forEach( component -> this.factory.addBootstrapComponent( component.apply( block, item ) ) );
|
||||||
|
|
||||||
if( this.tileEntityDefinition != null && block instanceof AEBaseTileBlock )
|
if (this.tileEntityDefinition != null)
|
||||||
{
|
{
|
||||||
( (AEBaseTileBlock) block ).setTileEntity( this.tileEntityDefinition.getTileEntityClass() );
|
// Tell the tile entity definition about the block we've registered
|
||||||
if( this.tileEntityDefinition.getName() == null )
|
this.tileEntityDefinition.addBlock(block);
|
||||||
{
|
|
||||||
this.tileEntityDefinition.setName( this.registryName );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( Platform.isClient() )
|
if( Platform.isClient() )
|
||||||
{
|
{
|
||||||
if( block instanceof AEBaseTileBlock )
|
this.blockRendering.apply( this.factory, block );
|
||||||
{
|
|
||||||
AEBaseTileBlock tileBlock = (AEBaseTileBlock) block;
|
|
||||||
this.blockRendering.apply( this.factory, block, tileBlock.getTileEntityClass() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.blockRendering.apply( this.factory, block, null );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( item != null )
|
if( item != null )
|
||||||
{
|
{
|
||||||
@@ -231,18 +217,6 @@ class BlockDefinitionBuilder implements IBlockBuilder
|
|||||||
|
|
||||||
if( block instanceof AEBaseTileBlock )
|
if( block instanceof AEBaseTileBlock )
|
||||||
{
|
{
|
||||||
this.factory.addBootstrapComponent( (IPreInitComponent) side ->
|
|
||||||
{
|
|
||||||
AEBaseTile.registerTileItem(
|
|
||||||
this.tileEntityDefinition == null ? ( (AEBaseTileBlock) block ).getTileEntityClass() : this.tileEntityDefinition.getTileEntityClass(),
|
|
||||||
new BlockStackSrc( block, ActivityState.Enabled ) );
|
|
||||||
} );
|
|
||||||
|
|
||||||
if( this.tileEntityDefinition != null )
|
|
||||||
{
|
|
||||||
this.factory.tileEntityComponent.addTileEntity( this.tileEntityDefinition );
|
|
||||||
}
|
|
||||||
|
|
||||||
return (T) new TileDefinition( this.registryName, (AEBaseTileBlock) block, item );
|
return (T) new TileDefinition( this.registryName, (AEBaseTileBlock) block, item );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -22,13 +22,15 @@ package appeng.bootstrap;
|
|||||||
import appeng.block.AEBaseTileBlock;
|
import appeng.block.AEBaseTileBlock;
|
||||||
import appeng.bootstrap.components.BlockColorComponent;
|
import appeng.bootstrap.components.BlockColorComponent;
|
||||||
import appeng.bootstrap.components.RenderTypeComponent;
|
import appeng.bootstrap.components.RenderTypeComponent;
|
||||||
|
import appeng.bootstrap.components.TileEntityRendererComponent;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.color.IBlockColor;
|
import net.minecraft.client.renderer.color.IBlockColor;
|
||||||
import net.minecraft.client.renderer.model.IBakedModel;
|
import net.minecraft.client.renderer.model.IBakedModel;
|
||||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||||
|
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
@@ -36,6 +38,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
|
||||||
class BlockRendering implements IBlockRendering
|
class BlockRendering implements IBlockRendering
|
||||||
@@ -47,12 +50,6 @@ class BlockRendering implements IBlockRendering
|
|||||||
@OnlyIn( Dist.CLIENT )
|
@OnlyIn( Dist.CLIENT )
|
||||||
private IBlockColor blockColor;
|
private IBlockColor blockColor;
|
||||||
|
|
||||||
@OnlyIn( Dist.CLIENT )
|
|
||||||
private TileEntityRenderer<?> tesr;
|
|
||||||
|
|
||||||
// FIXME @OnlyIn( Dist.CLIENT )
|
|
||||||
// FIXME private IStateMapper stateMapper;
|
|
||||||
|
|
||||||
@OnlyIn( Dist.CLIENT )
|
@OnlyIn( Dist.CLIENT )
|
||||||
private Map<String, IUnbakedModel> builtInModels = new HashMap<>();
|
private Map<String, IUnbakedModel> builtInModels = new HashMap<>();
|
||||||
|
|
||||||
@@ -75,14 +72,6 @@ class BlockRendering implements IBlockRendering
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn( Dist.CLIENT )
|
|
||||||
@Override
|
|
||||||
public IBlockRendering tesr( TileEntityRenderer<?> tesr )
|
|
||||||
{
|
|
||||||
this.tesr = tesr;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBlockRendering builtInModel( String name, IUnbakedModel model )
|
public IBlockRendering builtInModel( String name, IUnbakedModel model )
|
||||||
{
|
{
|
||||||
@@ -104,17 +93,8 @@ class BlockRendering implements IBlockRendering
|
|||||||
// FIXME return this;
|
// FIXME return this;
|
||||||
// FIXME }
|
// FIXME }
|
||||||
|
|
||||||
void apply( FeatureFactory factory, Block block, Class<?> tileEntityClass )
|
void apply( FeatureFactory factory, Block block )
|
||||||
{
|
{
|
||||||
// FIXME if( this.tesr != null )
|
|
||||||
// FIXME {
|
|
||||||
// FIXME if( tileEntityClass == null )
|
|
||||||
// FIXME {
|
|
||||||
// FIXME throw new IllegalStateException( "Tried to register a TESR for " + block + " even though no tile entity has been specified." );
|
|
||||||
// FIXME }
|
|
||||||
// FIXME factory.addBootstrapComponent( new TesrComponent( tileEntityClass, this.tesr ) );
|
|
||||||
// FIXME }
|
|
||||||
|
|
||||||
if( this.modelCustomizer != null )
|
if( this.modelCustomizer != null )
|
||||||
{
|
{
|
||||||
factory.addModelOverride( block.getRegistryName().getPath(), this.modelCustomizer );
|
factory.addModelOverride( block.getRegistryName().getPath(), this.modelCustomizer );
|
||||||
|
|||||||
@@ -27,15 +27,17 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import appeng.bootstrap.components.BuiltInModelComponent;
|
import appeng.bootstrap.components.BuiltInModelComponent;
|
||||||
import appeng.bootstrap.components.ModelOverrideComponent;
|
import appeng.bootstrap.components.ModelOverrideComponent;
|
||||||
|
import appeng.tile.AEBaseTile;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.renderer.model.IBakedModel;
|
import net.minecraft.client.renderer.model.IBakedModel;
|
||||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
@@ -43,7 +45,6 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
|||||||
import appeng.api.definitions.IItemDefinition;
|
import appeng.api.definitions.IItemDefinition;
|
||||||
import appeng.api.util.AEColor;
|
import appeng.api.util.AEColor;
|
||||||
import appeng.api.util.AEColoredItemDefinition;
|
import appeng.api.util.AEColoredItemDefinition;
|
||||||
import appeng.bootstrap.components.TileEntityComponent;
|
|
||||||
import appeng.core.features.AEFeature;
|
import appeng.core.features.AEFeature;
|
||||||
import appeng.core.features.ActivityState;
|
import appeng.core.features.ActivityState;
|
||||||
import appeng.core.features.ColoredItemDefinition;
|
import appeng.core.features.ColoredItemDefinition;
|
||||||
@@ -64,16 +65,11 @@ public class FeatureFactory
|
|||||||
@OnlyIn( Dist.CLIENT )
|
@OnlyIn( Dist.CLIENT )
|
||||||
private BuiltInModelComponent builtInModelComponent;
|
private BuiltInModelComponent builtInModelComponent;
|
||||||
|
|
||||||
public final TileEntityComponent tileEntityComponent;
|
|
||||||
|
|
||||||
public FeatureFactory()
|
public FeatureFactory()
|
||||||
{
|
{
|
||||||
this.defaultFeatures = new AEFeature[] { AEFeature.CORE };
|
this.defaultFeatures = new AEFeature[] { AEFeature.CORE };
|
||||||
this.bootstrapComponents = new HashMap<>();
|
this.bootstrapComponents = new HashMap<>();
|
||||||
|
|
||||||
this.tileEntityComponent = new TileEntityComponent();
|
|
||||||
this.addBootstrapComponent( this.tileEntityComponent );
|
|
||||||
|
|
||||||
if( Platform.isClient() )
|
if( Platform.isClient() )
|
||||||
{
|
{
|
||||||
this.modelOverrideComponent = new ModelOverrideComponent();
|
this.modelOverrideComponent = new ModelOverrideComponent();
|
||||||
@@ -87,7 +83,6 @@ public class FeatureFactory
|
|||||||
{
|
{
|
||||||
this.defaultFeatures = defaultFeatures.clone();
|
this.defaultFeatures = defaultFeatures.clone();
|
||||||
this.bootstrapComponents = parent.bootstrapComponents;
|
this.bootstrapComponents = parent.bootstrapComponents;
|
||||||
this.tileEntityComponent = parent.tileEntityComponent;
|
|
||||||
if( Platform.isClient() )
|
if( Platform.isClient() )
|
||||||
{
|
{
|
||||||
this.modelOverrideComponent = parent.modelOverrideComponent;
|
this.modelOverrideComponent = parent.modelOverrideComponent;
|
||||||
@@ -105,6 +100,11 @@ public class FeatureFactory
|
|||||||
return new ItemDefinitionBuilder( this, id, item ).features( this.defaultFeatures );
|
return new ItemDefinitionBuilder( this, id, item ).features( this.defaultFeatures );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <T extends AEBaseTile> TileEntityBuilder<T> tileEntity(String id, Class<T> teClass, Function<TileEntityType<T>, T> factory)
|
||||||
|
{
|
||||||
|
return new TileEntityBuilder<>( this, id, teClass, factory ).features( this.defaultFeatures );
|
||||||
|
}
|
||||||
|
|
||||||
public AEColoredItemDefinition colored( IItemDefinition target, int offset )
|
public AEColoredItemDefinition colored( IItemDefinition target, int offset )
|
||||||
{
|
{
|
||||||
ColoredItemDefinition definition = new ColoredItemDefinition();
|
ColoredItemDefinition definition = new ColoredItemDefinition();
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ package appeng.bootstrap;
|
|||||||
|
|
||||||
|
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.color.IBlockColor;
|
import net.minecraft.client.renderer.color.IBlockColor;
|
||||||
@@ -27,6 +28,7 @@ import net.minecraft.client.renderer.model.IBakedModel;
|
|||||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||||
|
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
@@ -44,12 +46,6 @@ public interface IBlockRendering
|
|||||||
@OnlyIn( Dist.CLIENT )
|
@OnlyIn( Dist.CLIENT )
|
||||||
IBlockRendering blockColor( IBlockColor blockColor );
|
IBlockRendering blockColor( IBlockColor blockColor );
|
||||||
|
|
||||||
//FIXME @OnlyIn( Dist.CLIENT )
|
|
||||||
// IBlockRendering stateMapper( IStateMapper mapper );
|
|
||||||
|
|
||||||
@OnlyIn( Dist.CLIENT )
|
|
||||||
IBlockRendering tesr( TileEntityRenderer<?> ter );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a built-in model under the given resource path.
|
* Registers a built-in model under the given resource path.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,126 @@
|
|||||||
|
package appeng.bootstrap;
|
||||||
|
|
||||||
|
import appeng.block.AEBaseTileBlock;
|
||||||
|
import appeng.bootstrap.components.ITileEntityRegistrationComponent;
|
||||||
|
import appeng.bootstrap.definitions.TileEntityDefinition;
|
||||||
|
import appeng.core.AppEng;
|
||||||
|
import appeng.core.features.AEFeature;
|
||||||
|
import appeng.core.features.ActivityState;
|
||||||
|
import appeng.core.features.BlockStackSrc;
|
||||||
|
import appeng.tile.AEBaseTile;
|
||||||
|
import appeng.util.Platform;
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
|
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to define our tile entities and all of their properties that are relevant to registering them.
|
||||||
|
*
|
||||||
|
* @param <T>
|
||||||
|
*/
|
||||||
|
public class TileEntityBuilder<T extends AEBaseTile> {
|
||||||
|
|
||||||
|
private final FeatureFactory factory;
|
||||||
|
|
||||||
|
private final String registryName;
|
||||||
|
|
||||||
|
// The tile entity class
|
||||||
|
private final Class<T> tileClass;
|
||||||
|
|
||||||
|
private TileEntityType<T> type;
|
||||||
|
|
||||||
|
// The factory for creating tile entity objects
|
||||||
|
private final Function<TileEntityType<T>, T> supplier;
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
private final TileEntityRendering<T> tileEntityRendering = new TileEntityRendering<T>();
|
||||||
|
|
||||||
|
private final List<Block> blocks = new ArrayList<>();
|
||||||
|
|
||||||
|
private final EnumSet<AEFeature> features = EnumSet.noneOf(AEFeature.class);
|
||||||
|
|
||||||
|
public TileEntityBuilder(FeatureFactory factory, String registryName, Class<T> tileClass, Function<TileEntityType<T>, T> supplier) {
|
||||||
|
this.factory = factory;
|
||||||
|
this.registryName = registryName;
|
||||||
|
this.tileClass = tileClass;
|
||||||
|
this.supplier = supplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TileEntityBuilder<T> features(AEFeature... features) {
|
||||||
|
this.features.clear();
|
||||||
|
this.addFeatures(features);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TileEntityBuilder<T> addFeatures(AEFeature... features) {
|
||||||
|
Collections.addAll(this.features, features);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TileEntityBuilder<T> rendering(TileEntityRenderingCustomizer<T> customizer) {
|
||||||
|
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> customizer.customize(tileEntityRendering));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public TileEntityDefinition build() {
|
||||||
|
|
||||||
|
this.factory.addBootstrapComponent((ITileEntityRegistrationComponent) registry ->
|
||||||
|
{
|
||||||
|
if (blocks.isEmpty()) {
|
||||||
|
throw new IllegalStateException("No blocks make use of this tile entity: " + tileClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
Supplier<T> factory = () -> supplier.apply(type);
|
||||||
|
type = TileEntityType.Builder.create(factory, blocks.toArray(new Block[0]))
|
||||||
|
.build(null);
|
||||||
|
type.setRegistryName(AppEng.MOD_ID, registryName);
|
||||||
|
registry.register(type);
|
||||||
|
|
||||||
|
DistExecutor.runWhenOn(Dist.CLIENT, () -> this::registerClient);
|
||||||
|
|
||||||
|
AEBaseTile.registerTileItem(
|
||||||
|
tileClass,
|
||||||
|
new BlockStackSrc(blocks.get(0), ActivityState.Enabled));
|
||||||
|
|
||||||
|
for (Block block : blocks) {
|
||||||
|
if (block instanceof AEBaseTileBlock) {
|
||||||
|
AEBaseTileBlock<T> baseTileBlock = (AEBaseTileBlock<T>) block;
|
||||||
|
baseTileBlock.setTileEntity(tileClass, factory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
return new TileEntityDefinition(this::addBlock);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
private void registerClient() {
|
||||||
|
|
||||||
|
if (tileEntityRendering.tileEntityRenderer != null) {
|
||||||
|
ClientRegistry.bindTileEntityRenderer(type, tileEntityRendering.tileEntityRenderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addBlock(Block block) {
|
||||||
|
Preconditions.checkState(type == null, "No more blocks can be added after registration completed.");
|
||||||
|
this.blocks.add(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Applied Energistics 2.
|
||||||
|
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||||
|
*
|
||||||
|
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package appeng.bootstrap;
|
||||||
|
|
||||||
|
|
||||||
|
import appeng.tile.AEBaseTile;
|
||||||
|
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||||
|
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public class TileEntityRendering<T extends AEBaseTile> {
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
Function<TileEntityRendererDispatcher, TileEntityRenderer<T>> tileEntityRenderer;
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public TileEntityRendering<T> tileEntityRenderer(Function<TileEntityRendererDispatcher, TileEntityRenderer<T>> tileEntityRenderer) {
|
||||||
|
this.tileEntityRenderer = tileEntityRenderer;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of Applied Energistics 2.
|
||||||
|
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||||
|
*
|
||||||
|
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package appeng.bootstrap;
|
||||||
|
|
||||||
|
|
||||||
|
import appeng.tile.AEBaseTile;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A callback that allows the rendering of a tile entity to be customized. Sadly this class is required and no lambdas
|
||||||
|
* can be used due to them not being able to be annotated with @OnlyIn(CLIENT).
|
||||||
|
*/
|
||||||
|
public abstract class TileEntityRenderingCustomizer<T extends AEBaseTile>
|
||||||
|
{
|
||||||
|
|
||||||
|
@OnlyIn( Dist.CLIENT )
|
||||||
|
public abstract void customize( TileEntityRendering<T> rendering );
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package appeng.bootstrap.components;
|
||||||
|
|
||||||
|
import appeng.bootstrap.IBootstrapComponent;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
|
import net.minecraftforge.registries.IForgeRegistry;
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface ITileEntityRegistrationComponent extends IBootstrapComponent {
|
||||||
|
void register(IForgeRegistry<TileEntityType<?>> registry);
|
||||||
|
}
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
|
|
||||||
package appeng.bootstrap.components;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
|
||||||
|
|
||||||
import appeng.bootstrap.definitions.TileEntityDefinition;
|
|
||||||
import appeng.core.AppEng;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author GuntherDW
|
|
||||||
*/
|
|
||||||
public class TileEntityComponent implements IPreInitComponent
|
|
||||||
{
|
|
||||||
private List<TileEntityDefinition> tileEntityDefinitions = new ArrayList<>();
|
|
||||||
|
|
||||||
public TileEntityComponent()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addTileEntity( TileEntityDefinition tileEntityDefinition )
|
|
||||||
{
|
|
||||||
if( !this.tileEntityDefinitions.contains( tileEntityDefinition ) )
|
|
||||||
{
|
|
||||||
this.tileEntityDefinitions.add( tileEntityDefinition );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void preInitialize( Dist dist )
|
|
||||||
{
|
|
||||||
for( TileEntityDefinition tileEntityDefinition : this.tileEntityDefinitions )
|
|
||||||
{
|
|
||||||
if( !tileEntityDefinition.isRegistered() )
|
|
||||||
{
|
|
||||||
// FIXME GameRegistry.registerTileEntity( tileEntityDefinition.getTileEntityClass(), AppEng.MOD_ID + ":" + tileEntityDefinition.getName() );
|
|
||||||
tileEntityDefinition.setRegistered( true );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+8
-7
@@ -35,23 +35,24 @@ import appeng.tile.AEBaseTile;
|
|||||||
*
|
*
|
||||||
* @param <T>
|
* @param <T>
|
||||||
*/
|
*/
|
||||||
public class TesrComponent<T extends AEBaseTile> implements IPreInitComponent
|
public class TileEntityRendererComponent<T extends AEBaseTile> implements IPreInitComponent
|
||||||
{
|
{
|
||||||
|
|
||||||
private final TileEntityType<T> tileEntityClass;
|
private final TileEntityType<T> tileEntityType;
|
||||||
|
|
||||||
private final Function<? super TileEntityRendererDispatcher, ? extends TileEntityRenderer<? super T>> ter;
|
private final Function<? super TileEntityRendererDispatcher, ? extends TileEntityRenderer<? super T>> tileEntityRenderer;
|
||||||
|
|
||||||
public TesrComponent( TileEntityType<T> tileEntityClass, Function<? super TileEntityRendererDispatcher, ? extends TileEntityRenderer<? super T>> ter )
|
public TileEntityRendererComponent(TileEntityType<T> tileEntityType,
|
||||||
|
Function<? super TileEntityRendererDispatcher, ? extends TileEntityRenderer<? super T>> tileEntityRenderer)
|
||||||
{
|
{
|
||||||
this.tileEntityClass = tileEntityClass;
|
this.tileEntityType = tileEntityType;
|
||||||
this.ter = ter;
|
this.tileEntityRenderer = tileEntityRenderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
// public void modelReg( Dist dist )
|
// public void modelReg( Dist dist )
|
||||||
public void preInitialize( Dist dist )
|
public void preInitialize( Dist dist )
|
||||||
{
|
{
|
||||||
ClientRegistry.bindTileEntityRenderer( this.tileEntityClass, this.ter );
|
ClientRegistry.bindTileEntityRenderer( tileEntityType, tileEntityRenderer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,53 +20,25 @@ package appeng.bootstrap.definitions;
|
|||||||
|
|
||||||
|
|
||||||
import appeng.tile.AEBaseTile;
|
import appeng.tile.AEBaseTile;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author GuntherDW
|
* @author GuntherDW
|
||||||
*/
|
*/
|
||||||
public class TileEntityDefinition
|
public class TileEntityDefinition {
|
||||||
{
|
|
||||||
|
|
||||||
private final Class<? extends AEBaseTile> tileEntityClass;
|
// To be notified when a Block declares that it uses this tile entity
|
||||||
private String name;
|
private final Consumer<Block> addBlockListener;
|
||||||
private boolean isRegistered = false;
|
|
||||||
|
|
||||||
// This signals the BlockDefinitionBuilder to set the name of the TE to the blockname.
|
public TileEntityDefinition(Consumer<Block> addBlockListener) {
|
||||||
public TileEntityDefinition( Class<? extends AEBaseTile> tileEntityClass )
|
this.addBlockListener = addBlockListener;
|
||||||
{
|
}
|
||||||
this.tileEntityClass = tileEntityClass;
|
|
||||||
this.name = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TileEntityDefinition( Class<? extends AEBaseTile> tileEntityClass, String optionalName )
|
public void addBlock(Block block) {
|
||||||
{
|
this.addBlockListener.accept(block);
|
||||||
this.tileEntityClass = tileEntityClass;
|
}
|
||||||
this.name = optionalName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Class<? extends AEBaseTile> getTileEntityClass()
|
|
||||||
{
|
|
||||||
return this.tileEntityClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName( String name )
|
|
||||||
{
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isRegistered()
|
|
||||||
{
|
|
||||||
return this.isRegistered;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRegistered( boolean registered )
|
|
||||||
{
|
|
||||||
this.isRegistered = registered;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public class CraftingCubeRendering extends BlockRenderingCustomizer
|
|||||||
|
|
||||||
if( this.type == BlockCraftingUnit.CraftingUnitType.MONITOR )
|
if( this.type == BlockCraftingUnit.CraftingUnitType.MONITOR )
|
||||||
{
|
{
|
||||||
rendering.tesr( new CraftingMonitorTESR() );
|
rendering.tileEntityRenderer( new CraftingMonitorTESR() );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ package appeng.client.render.crafting;
|
|||||||
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
@@ -34,7 +34,7 @@ import appeng.tile.crafting.TileCraftingMonitorTile;
|
|||||||
* Renders the item currently being crafted
|
* Renders the item currently being crafted
|
||||||
*/
|
*/
|
||||||
@OnlyIn( Dist.CLIENT )
|
@OnlyIn( Dist.CLIENT )
|
||||||
public class CraftingMonitorTESR extends TileEntitySpecialRenderer<TileCraftingMonitorTile>
|
public class CraftingMonitorTESR extends TileEntityRenderer<TileCraftingMonitorTile>
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import net.minecraft.client.renderer.RenderHelper;
|
|||||||
import net.minecraft.client.renderer.Tessellator;
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||||
import net.minecraft.client.renderer.texture.TextureMap;
|
import net.minecraft.client.renderer.texture.TextureMap;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
@@ -44,7 +44,7 @@ import appeng.tile.grindstone.TileCrank;
|
|||||||
* normal model.
|
* normal model.
|
||||||
*/
|
*/
|
||||||
@OnlyIn( Dist.CLIENT )
|
@OnlyIn( Dist.CLIENT )
|
||||||
public class CrankTESR extends TileEntitySpecialRenderer<TileCrank>
|
public class CrankTESR extends TileEntityRenderer<TileCrank>
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import net.minecraft.client.renderer.Tessellator;
|
|||||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||||
import net.minecraft.client.renderer.texture.TextureMap;
|
import net.minecraft.client.renderer.texture.TextureMap;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
import net.minecraft.item.BlockItem;
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
@@ -30,7 +30,7 @@ import appeng.tile.misc.TileInscriber;
|
|||||||
/**
|
/**
|
||||||
* Renders the dynamic parts of an inscriber (the presses, the animation and the item being smashed)
|
* Renders the dynamic parts of an inscriber (the presses, the animation and the item being smashed)
|
||||||
*/
|
*/
|
||||||
public final class InscriberTESR extends TileEntitySpecialRenderer<TileInscriber>
|
public final class InscriberTESR extends TileEntityRenderer<TileInscriber>
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final float ITEM_RENDER_SCALE = 1.0f / 1.2f;
|
private static final float ITEM_RENDER_SCALE = 1.0f / 1.2f;
|
||||||
|
|||||||
@@ -19,124 +19,100 @@
|
|||||||
package appeng.client.render.tesr;
|
package appeng.client.render.tesr;
|
||||||
|
|
||||||
|
|
||||||
|
import appeng.block.storage.BlockSkyChest;
|
||||||
|
import appeng.block.storage.BlockSkyChest.SkyChestType;
|
||||||
|
import appeng.core.AppEng;
|
||||||
|
import appeng.tile.storage.TileSkyChest;
|
||||||
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
|
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.model.ModelChest;
|
import net.minecraft.client.renderer.Atlases;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.client.renderer.Vector3f;
|
||||||
|
import net.minecraft.client.renderer.model.Material;
|
||||||
|
import net.minecraft.client.renderer.model.ModelRenderer;
|
||||||
|
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||||
|
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||||
|
|
||||||
import appeng.block.storage.BlockSkyChest;
|
// This is mostly a copy&paste job of the vanilla chest TESR
|
||||||
import appeng.block.storage.BlockSkyChest.SkyChestType;
|
@OnlyIn(Dist.CLIENT)
|
||||||
import appeng.client.render.FacingToRotation;
|
public class SkyChestTESR extends TileEntityRenderer<TileSkyChest> {
|
||||||
import appeng.core.AppEng;
|
|
||||||
import appeng.tile.storage.TileSkyChest;
|
|
||||||
|
|
||||||
|
public static final Material TEXTURE_STONE = new Material(Atlases.CHEST_ATLAS, new ResourceLocation(AppEng.MOD_ID, "models/skychest"));
|
||||||
|
public static final Material TEXTURE_BLOCK = new Material(Atlases.CHEST_ATLAS, new ResourceLocation(AppEng.MOD_ID, "models/skyblockchest"));
|
||||||
|
|
||||||
@OnlyIn( Dist.CLIENT )
|
private final ModelRenderer singleLid;
|
||||||
public class SkyChestTESR extends TileEntitySpecialRenderer<TileSkyChest>
|
private final ModelRenderer singleBottom;
|
||||||
{
|
private final ModelRenderer singleLatch;
|
||||||
|
|
||||||
private static final ResourceLocation TEXTURE_STONE = new ResourceLocation( AppEng.MOD_ID, "textures/models/skychest.png" );
|
public SkyChestTESR(TileEntityRendererDispatcher rendererDispatcherIn) {
|
||||||
private static final ResourceLocation TEXTURE_BLOCK = new ResourceLocation( AppEng.MOD_ID, "textures/models/skyblockchest.png" );
|
super(rendererDispatcherIn);
|
||||||
|
|
||||||
private final ModelChest simpleChest = new ModelChest();
|
this.singleBottom = new ModelRenderer(64, 64, 0, 19);
|
||||||
|
this.singleBottom.addBox(1.0F, 0.0F, 1.0F, 14.0F, 10.0F, 14.0F, 0.0F);
|
||||||
|
this.singleLid = new ModelRenderer(64, 64, 0, 0);
|
||||||
|
this.singleLid.addBox(1.0F, 0.0F, 0.0F, 14.0F, 5.0F, 14.0F, 0.0F);
|
||||||
|
this.singleLid.rotationPointY = 9.0F;
|
||||||
|
this.singleLid.rotationPointZ = 1.0F;
|
||||||
|
this.singleLatch = new ModelRenderer(64, 64, 0, 0);
|
||||||
|
this.singleLatch.addBox(7.0F, -1.0F, 15.0F, 2.0F, 4.0F, 1.0F, 0.0F);
|
||||||
|
this.singleLatch.rotationPointY = 8.0F;
|
||||||
|
}
|
||||||
|
|
||||||
public SkyChestTESR()
|
public void render(TileSkyChest tileEntityIn, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) {
|
||||||
{
|
matrixStackIn.push();
|
||||||
|
float f = tileEntityIn.getForward().getHorizontalAngle();
|
||||||
|
matrixStackIn.translate(0.5D, 0.5D, 0.5D);
|
||||||
|
matrixStackIn.rotate(Vector3f.YP.rotationDegrees(-f));
|
||||||
|
matrixStackIn.translate(-0.5D, -0.5D, -0.5D);
|
||||||
|
|
||||||
}
|
float f1 = tileEntityIn.getLidAngle(partialTicks);
|
||||||
|
f1 = 1.0F - f1;
|
||||||
|
f1 = 1.0F - f1 * f1 * f1;
|
||||||
|
Material material = this.getMaterial(tileEntityIn);
|
||||||
|
IVertexBuilder ivertexbuilder = material.getBuffer(bufferIn, RenderType::getEntityCutout);
|
||||||
|
this.renderModels(matrixStackIn, ivertexbuilder, this.singleLid, this.singleLatch, this.singleBottom, f1, combinedLightIn, combinedOverlayIn);
|
||||||
|
|
||||||
@Override
|
matrixStackIn.pop();
|
||||||
public void render( TileSkyChest te, double x, double y, double z, float partialTicks, int destroyStage, float p_render_10_ )
|
}
|
||||||
{
|
|
||||||
GlStateManager.enableDepth();
|
|
||||||
GlStateManager.depthFunc( 515 );
|
|
||||||
GlStateManager.depthMask( true );
|
|
||||||
|
|
||||||
ModelChest modelchest;
|
private void renderModels(MatrixStack matrixStackIn, IVertexBuilder bufferIn, ModelRenderer chestLid, ModelRenderer chestLatch, ModelRenderer chestBottom, float lidAngle, int combinedLightIn, int combinedOverlayIn) {
|
||||||
|
chestLid.rotateAngleX = -(lidAngle * 1.5707964F);
|
||||||
|
chestLatch.rotateAngleX = chestLid.rotateAngleX;
|
||||||
|
chestLid.render(matrixStackIn, bufferIn, combinedLightIn, combinedOverlayIn);
|
||||||
|
chestLatch.render(matrixStackIn, bufferIn, combinedLightIn, combinedOverlayIn);
|
||||||
|
chestBottom.render(matrixStackIn, bufferIn, combinedLightIn, combinedOverlayIn);
|
||||||
|
}
|
||||||
|
|
||||||
modelchest = this.simpleChest;
|
protected Material getMaterial(TileSkyChest tileEntity) {
|
||||||
|
SkyChestType type = SkyChestType.BLOCK;
|
||||||
|
if (tileEntity.getWorld() != null) {
|
||||||
|
Block blockType = tileEntity.getBlockState().getBlock();
|
||||||
|
|
||||||
if( destroyStage >= 0 )
|
if (blockType instanceof BlockSkyChest) {
|
||||||
{
|
type = ((BlockSkyChest) blockType).type;
|
||||||
this.bindTexture( DESTROY_STAGES[destroyStage] );
|
}
|
||||||
GlStateManager.matrixMode( 5890 );
|
}
|
||||||
GlStateManager.pushMatrix();
|
|
||||||
GlStateManager.scale( 4.0F, 4.0F, 1.0F );
|
|
||||||
GlStateManager.translate( 0.0625F, 0.0625F, 0.0625F );
|
|
||||||
GlStateManager.matrixMode( 5888 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SkyChestType chestType = getChestType( te );
|
|
||||||
this.bindTexture( chestType == SkyChestType.STONE ? TEXTURE_STONE : TEXTURE_BLOCK );
|
|
||||||
}
|
|
||||||
|
|
||||||
GlStateManager.pushMatrix();
|
switch (type) {
|
||||||
GlStateManager.enableRescaleNormal();
|
case STONE:
|
||||||
GlStateManager.color( 1.0F, 1.0F, 1.0F, 1.0F );
|
return TEXTURE_STONE;
|
||||||
GlStateManager.translate( (float) x, (float) y + 1.0F, (float) z + 1.0F );
|
default:
|
||||||
GlStateManager.scale( 1.0F, -1.0F, -1.0F );
|
case BLOCK:
|
||||||
if( te != null )
|
return TEXTURE_BLOCK;
|
||||||
{
|
}
|
||||||
GlStateManager.translate( 0.5F, 0.5F, 0.5F );
|
}
|
||||||
// In the vanilla chest model, north and south are flipped
|
|
||||||
Direction forward = te.getForward();
|
|
||||||
Direction up = te.getUp();
|
|
||||||
if( forward == Direction.SOUTH )
|
|
||||||
{
|
|
||||||
forward = Direction.NORTH;
|
|
||||||
}
|
|
||||||
else if( forward == Direction.NORTH )
|
|
||||||
{
|
|
||||||
forward = Direction.SOUTH;
|
|
||||||
}
|
|
||||||
if( up == Direction.SOUTH )
|
|
||||||
{
|
|
||||||
up = Direction.NORTH;
|
|
||||||
}
|
|
||||||
else if( up == Direction.NORTH )
|
|
||||||
{
|
|
||||||
up = Direction.SOUTH;
|
|
||||||
}
|
|
||||||
FacingToRotation.get( forward, up ).glRotateCurrentMat();
|
|
||||||
GlStateManager.translate( -0.5F, -0.5F, -0.5F );
|
|
||||||
}
|
|
||||||
float f = te != null ? te.getPrevLidAngle() + ( te.getLidAngle() - te.getPrevLidAngle() ) * partialTicks : 0;
|
|
||||||
|
|
||||||
f = 1.0F - f;
|
public static void registerTextures(TextureStitchEvent.Pre evt) {
|
||||||
f = 1.0F - f * f * f;
|
if (evt.getMap().getTextureLocation().equals(Atlases.CHEST_ATLAS)) {
|
||||||
modelchest.chestLid.rotateAngleX = -( f * ( (float) Math.PI / 2F ) );
|
evt.addSprite(TEXTURE_STONE.getTextureLocation());
|
||||||
modelchest.renderAll();
|
evt.addSprite(TEXTURE_BLOCK.getTextureLocation());
|
||||||
GlStateManager.disableRescaleNormal();
|
}
|
||||||
GlStateManager.popMatrix();
|
}
|
||||||
GlStateManager.color( 1.0F, 1.0F, 1.0F, 1.0F );
|
|
||||||
|
|
||||||
if( destroyStage >= 0 )
|
|
||||||
{
|
|
||||||
GlStateManager.matrixMode( 5890 );
|
|
||||||
GlStateManager.popMatrix();
|
|
||||||
GlStateManager.matrixMode( 5888 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Defensively determine the sky chest type
|
|
||||||
private static SkyChestType getChestType( TileSkyChest te )
|
|
||||||
{
|
|
||||||
if( te == null )
|
|
||||||
{
|
|
||||||
return SkyChestType.BLOCK;
|
|
||||||
}
|
|
||||||
|
|
||||||
Block blockType = te.getBlockType();
|
|
||||||
if( blockType instanceof BlockSkyChest )
|
|
||||||
{
|
|
||||||
return ( (BlockSkyChest) blockType ).type;
|
|
||||||
}
|
|
||||||
return SkyChestType.BLOCK;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import net.minecraft.entity.EntityType;
|
|||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.particles.ParticleType;
|
import net.minecraft.particles.ParticleType;
|
||||||
import net.minecraft.stats.StatType;
|
import net.minecraft.stats.StatType;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
@@ -102,7 +103,9 @@ public final class AppEng
|
|||||||
modEventBus.addGenericListener(Item.class, registration::registerItems);
|
modEventBus.addGenericListener(Item.class, registration::registerItems);
|
||||||
modEventBus.addGenericListener(EntityType.class, registration::registerEntities);
|
modEventBus.addGenericListener(EntityType.class, registration::registerEntities);
|
||||||
modEventBus.addGenericListener(ParticleType.class, registration::registerParticleTypes);
|
modEventBus.addGenericListener(ParticleType.class, registration::registerParticleTypes);
|
||||||
|
modEventBus.addGenericListener(TileEntityType.class, registration::registerTileEntities);
|
||||||
modEventBus.addListener(registration::registerParticleFactories);
|
modEventBus.addListener(registration::registerParticleFactories);
|
||||||
|
modEventBus.addListener(registration::registerTextures);
|
||||||
|
|
||||||
modEventBus.addListener(this::commonSetup);
|
modEventBus.addListener(this::commonSetup);
|
||||||
|
|
||||||
|
|||||||
@@ -20,14 +20,12 @@ package appeng.core;
|
|||||||
|
|
||||||
|
|
||||||
import appeng.bootstrap.IModelRegistry;
|
import appeng.bootstrap.IModelRegistry;
|
||||||
import appeng.bootstrap.components.IBlockRegistrationComponent;
|
import appeng.bootstrap.components.*;
|
||||||
import appeng.bootstrap.components.IEntityRegistrationComponent;
|
|
||||||
import appeng.bootstrap.components.IItemRegistrationComponent;
|
|
||||||
import appeng.bootstrap.components.IModelRegistrationComponent;
|
|
||||||
import appeng.client.render.effects.ChargedOreFX;
|
import appeng.client.render.effects.ChargedOreFX;
|
||||||
import appeng.client.render.effects.LightningFX;
|
import appeng.client.render.effects.LightningFX;
|
||||||
import appeng.client.render.effects.VibrantFX;
|
import appeng.client.render.effects.VibrantFX;
|
||||||
import appeng.client.render.model.GlassModelLoader;
|
import appeng.client.render.model.GlassModelLoader;
|
||||||
|
import appeng.client.render.tesr.SkyChestTESR;
|
||||||
import appeng.core.stats.AeStats;
|
import appeng.core.stats.AeStats;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
@@ -36,15 +34,13 @@ import net.minecraft.client.renderer.model.ModelResourceLocation;
|
|||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.particles.ParticleType;
|
import net.minecraft.particles.ParticleType;
|
||||||
import net.minecraft.stats.IStatFormatter;
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.stats.StatType;
|
|
||||||
import net.minecraft.stats.Stats;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.registry.Registry;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||||
import net.minecraftforge.client.event.ParticleFactoryRegisterEvent;
|
import net.minecraftforge.client.event.ParticleFactoryRegisterEvent;
|
||||||
|
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||||
import net.minecraftforge.event.RegistryEvent;
|
import net.minecraftforge.event.RegistryEvent;
|
||||||
import net.minecraftforge.fml.loading.FMLEnvironment;
|
import net.minecraftforge.fml.loading.FMLEnvironment;
|
||||||
@@ -225,6 +221,13 @@ final class Registration
|
|||||||
definitions.getRegistry().getBootstrapComponents( IItemRegistrationComponent.class ).forEachRemaining( b -> b.itemRegistration( dist, registry ) );
|
definitions.getRegistry().getBootstrapComponents( IItemRegistrationComponent.class ).forEachRemaining( b -> b.itemRegistration( dist, registry ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void registerTileEntities( RegistryEvent.Register<TileEntityType<?>> event )
|
||||||
|
{
|
||||||
|
final IForgeRegistry<TileEntityType<?>> registry = event.getRegistry();
|
||||||
|
final ApiDefinitions definitions = Api.INSTANCE.definitions();
|
||||||
|
definitions.getRegistry().getBootstrapComponents( ITileEntityRegistrationComponent.class ).forEachRemaining(b -> b.register( registry ) );
|
||||||
|
}
|
||||||
|
|
||||||
// @SubscribeEvent
|
// @SubscribeEvent
|
||||||
// public void registerRecipes( RegistryEvent.Register<IRecipe> event )
|
// public void registerRecipes( RegistryEvent.Register<IRecipe> event )
|
||||||
// {
|
// {
|
||||||
@@ -525,4 +528,8 @@ final class Registration
|
|||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
public void registerTextures(TextureStitchEvent.Pre event) {
|
||||||
|
SkyChestTESR.registerTextures(event);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,14 +24,16 @@ import appeng.api.definitions.IBlocks;
|
|||||||
import appeng.api.definitions.ITileDefinition;
|
import appeng.api.definitions.ITileDefinition;
|
||||||
import appeng.block.misc.BlockQuartzFixture;
|
import appeng.block.misc.BlockQuartzFixture;
|
||||||
import appeng.block.spatial.BlockMatrixFrame;
|
import appeng.block.spatial.BlockMatrixFrame;
|
||||||
import appeng.bootstrap.BlockRenderingCustomizer;
|
import appeng.block.storage.BlockSkyChest;
|
||||||
import appeng.bootstrap.FeatureFactory;
|
import appeng.block.storage.SkyChestRenderingCustomizer;
|
||||||
import appeng.bootstrap.IBlockRendering;
|
import appeng.bootstrap.*;
|
||||||
import appeng.bootstrap.IItemRendering;
|
import appeng.bootstrap.definitions.TileEntityDefinition;
|
||||||
|
import appeng.client.render.tesr.SkyChestTESR;
|
||||||
import appeng.core.features.AEFeature;
|
import appeng.core.features.AEFeature;
|
||||||
import appeng.core.features.registries.PartModels;
|
import appeng.core.features.registries.PartModels;
|
||||||
import appeng.decorative.AEDecorativeBlock;
|
import appeng.decorative.AEDecorativeBlock;
|
||||||
import appeng.decorative.solid.*;
|
import appeng.decorative.solid.*;
|
||||||
|
import appeng.tile.storage.TileSkyChest;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.SoundType;
|
import net.minecraft.block.SoundType;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
@@ -197,17 +199,30 @@ public final class ApiBlocks implements IBlocks
|
|||||||
.addFeatures( AEFeature.SKY_STONE )
|
.addFeatures( AEFeature.SKY_STONE )
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// this.skyStoneChest = registry.block( "sky_stone_chest", () -> new BlockSkyChest( SkyChestType.STONE ) )
|
Block.Properties skyStoneChestProps = Block.Properties.create(Material.ROCK)
|
||||||
// .features( AEFeature.SKY_STONE, AEFeature.SKY_STONE_CHESTS )
|
.hardnessAndResistance(50, 150)
|
||||||
// .tileEntity( new TileEntityDefinition( TileSkyChest.class, "sky_stone_chest" ) )
|
.notSolid();
|
||||||
// .rendering( new SkyChestRenderingCustomizer( SkyChestType.STONE ) )
|
|
||||||
// .build();
|
TileEntityDefinition skyChestTile = registry.tileEntity("sky_chest", TileSkyChest.class, TileSkyChest::new)
|
||||||
// this.smoothSkyStoneChest = registry.block( "smooth_sky_stone_chest", () -> new BlockSkyChest( SkyChestType.BLOCK ) )
|
.rendering(new TileEntityRenderingCustomizer<TileSkyChest>() {
|
||||||
// .features( AEFeature.SKY_STONE, AEFeature.SKY_STONE_CHESTS )
|
@Override
|
||||||
// .tileEntity( new TileEntityDefinition( TileSkyChest.class, "sky_stone_chest" ) )
|
@OnlyIn(Dist.CLIENT)
|
||||||
// .rendering( new SkyChestRenderingCustomizer( SkyChestType.BLOCK ) )
|
public void customize(TileEntityRendering<TileSkyChest> rendering) {
|
||||||
// .build();
|
rendering.tileEntityRenderer(SkyChestTESR::new);
|
||||||
//
|
}
|
||||||
|
})
|
||||||
|
.build();
|
||||||
|
this.skyStoneChest = registry.block( "sky_stone_chest", () -> new BlockSkyChest( BlockSkyChest.SkyChestType.STONE, skyStoneChestProps ) )
|
||||||
|
.features( AEFeature.SKY_STONE, AEFeature.SKY_STONE_CHESTS )
|
||||||
|
.tileEntity( skyChestTile )
|
||||||
|
// .rendering( new SkyChestRenderingCustomizer( BlockSkyChest.SkyChestType.STONE ) )
|
||||||
|
.build();
|
||||||
|
this.smoothSkyStoneChest = registry.block( "smooth_sky_stone_chest", () -> new BlockSkyChest( BlockSkyChest.SkyChestType.BLOCK, skyStoneChestProps ) )
|
||||||
|
.features( AEFeature.SKY_STONE, AEFeature.SKY_STONE_CHESTS )
|
||||||
|
.tileEntity( skyChestTile )
|
||||||
|
// .rendering( new SkyChestRenderingCustomizer( BlockSkyChest.SkyChestType.BLOCK ) )
|
||||||
|
.build();
|
||||||
|
|
||||||
// this.skyCompass = registry.block( "sky_compass", BlockSkyCompass::new )
|
// this.skyCompass = registry.block( "sky_compass", BlockSkyCompass::new )
|
||||||
// .features( AEFeature.METEORITE_COMPASS )
|
// .features( AEFeature.METEORITE_COMPASS )
|
||||||
// .tileEntity( new TileEntityDefinition( TileSkyCompass.class ) )
|
// .tileEntity( new TileEntityDefinition( TileSkyCompass.class ) )
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntityMP;
|
import net.minecraft.entity.player.PlayerEntityMP;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.util.ITickable;
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
import net.minecraft.util.math.ChunkPos;
|
import net.minecraft.util.math.ChunkPos;
|
||||||
import net.minecraft.util.text.TextComponentString;
|
import net.minecraft.util.text.TextComponentString;
|
||||||
import net.minecraftforge.common.ForgeChunkManager;
|
import net.minecraftforge.common.ForgeChunkManager;
|
||||||
@@ -37,14 +37,14 @@ import appeng.tile.AEBaseTile;
|
|||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
|
|
||||||
|
|
||||||
public class TileChunkLoader extends AEBaseTile implements ITickable
|
public class TileChunkLoader extends AEBaseTile implements ITickableTileEntity
|
||||||
{
|
{
|
||||||
|
|
||||||
private boolean requestTicket = true;
|
private boolean requestTicket = true;
|
||||||
private Ticket ct = null;
|
private Ticket ct = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update()
|
public void tick()
|
||||||
{
|
{
|
||||||
if( this.requestTicket )
|
if( this.requestTicket )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ package appeng.debug;
|
|||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.ITickable;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ import appeng.tile.AEBaseTile;
|
|||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
|
|
||||||
|
|
||||||
public class TileCubeGenerator extends AEBaseTile implements ITickable
|
public class TileCubeGenerator extends AEBaseTile implements ITickableTileEntity
|
||||||
{
|
{
|
||||||
|
|
||||||
private int size = 3;
|
private int size = 3;
|
||||||
@@ -42,7 +42,7 @@ public class TileCubeGenerator extends AEBaseTile implements ITickable
|
|||||||
private PlayerEntity who = null;
|
private PlayerEntity who = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update()
|
public void tick()
|
||||||
{
|
{
|
||||||
if( !this.is.isEmpty() && Platform.isServer() )
|
if( !this.is.isEmpty() && Platform.isServer() )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
import com.google.common.math.IntMath;
|
import com.google.common.math.IntMath;
|
||||||
|
|
||||||
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.ITickable;
|
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.energy.CapabilityEnergy;
|
import net.minecraftforge.energy.CapabilityEnergy;
|
||||||
import net.minecraftforge.energy.IEnergyStorage;
|
import net.minecraftforge.energy.IEnergyStorage;
|
||||||
@@ -35,7 +35,7 @@ import net.minecraftforge.energy.IEnergyStorage;
|
|||||||
import appeng.tile.AEBaseTile;
|
import appeng.tile.AEBaseTile;
|
||||||
|
|
||||||
|
|
||||||
public class TileEnergyGenerator extends AEBaseTile implements ITickable, IEnergyStorage
|
public class TileEnergyGenerator extends AEBaseTile implements ITickableTileEntity, IEnergyStorage
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The base energy injected each tick.
|
* The base energy injected each tick.
|
||||||
@@ -44,7 +44,7 @@ public class TileEnergyGenerator extends AEBaseTile implements ITickable, IEnerg
|
|||||||
private static final int BASE_ENERGY = 8;
|
private static final int BASE_ENERGY = 8;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update()
|
public void tick()
|
||||||
{
|
{
|
||||||
int tier = 1;
|
int tier = 1;
|
||||||
final EnumSet<Direction> validEnergyReceivers = EnumSet.noneOf( Direction.class );
|
final EnumSet<Direction> validEnergyReceivers = EnumSet.noneOf( Direction.class );
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import java.util.Map.Entry;
|
|||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.renderer.texture.ITickable;
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.NextTickListEntry;
|
import net.minecraft.world.NextTickListEntry;
|
||||||
@@ -189,7 +189,7 @@ public class CachedPlane
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.getWorld().loadedTileEntityList.remove( te );
|
this.getWorld().loadedTileEntityList.remove( te );
|
||||||
if( te instanceof ITickable )
|
if( te instanceof ITickableTileEntity)
|
||||||
{
|
{
|
||||||
this.getWorld().tickableTileEntities.remove( te );
|
this.getWorld().tickableTileEntities.remove( te );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.ITickable;
|
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@@ -41,7 +41,7 @@ import appeng.tile.AEBaseTile;
|
|||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
|
|
||||||
|
|
||||||
public class TileCrank extends AEBaseTile implements ICustomCollision, ITickable
|
public class TileCrank extends AEBaseTile implements ICustomCollision, ITickableTileEntity
|
||||||
{
|
{
|
||||||
|
|
||||||
private final int ticksPerRotation = 18;
|
private final int ticksPerRotation = 18;
|
||||||
@@ -54,7 +54,7 @@ public class TileCrank extends AEBaseTile implements ICustomCollision, ITickable
|
|||||||
private int rotation = 0;
|
private int rotation = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update()
|
public void tick()
|
||||||
{
|
{
|
||||||
if( this.rotation > 0 )
|
if( this.rotation > 0 )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import java.util.Iterator;
|
|||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
import appeng.core.Api;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
@@ -83,7 +84,7 @@ public class AppEngInternalAEInventory implements IItemHandlerModifiable, Iterab
|
|||||||
|
|
||||||
if( this.inv[x] != null )
|
if( this.inv[x] != null )
|
||||||
{
|
{
|
||||||
this.inv[x].write(c);
|
this.inv[x].writeToNBT(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
target.put( "#" + x, c );
|
target.put( "#" + x, c );
|
||||||
|
|||||||
@@ -19,13 +19,13 @@
|
|||||||
package appeng.tile.misc;
|
package appeng.tile.misc;
|
||||||
|
|
||||||
|
|
||||||
import net.minecraft.util.ITickable;
|
|
||||||
|
|
||||||
import appeng.tile.AEBaseTile;
|
import appeng.tile.AEBaseTile;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
|
|
||||||
|
|
||||||
public class TileLightDetector extends AEBaseTile implements ITickable
|
public class TileLightDetector extends AEBaseTile implements ITickableTileEntity
|
||||||
{
|
{
|
||||||
|
|
||||||
private int lastCheck = 30;
|
private int lastCheck = 30;
|
||||||
@@ -37,7 +37,7 @@ public class TileLightDetector extends AEBaseTile implements ITickable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update()
|
public void tick()
|
||||||
{
|
{
|
||||||
this.lastCheck++;
|
this.lastCheck++;
|
||||||
if( this.lastCheck > 30 )
|
if( this.lastCheck > 30 )
|
||||||
|
|||||||
@@ -19,14 +19,14 @@
|
|||||||
package appeng.tile.networking;
|
package appeng.tile.networking;
|
||||||
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
|
||||||
import appeng.api.parts.IPart;
|
import appeng.api.parts.IPart;
|
||||||
import appeng.tile.AEBaseTile;
|
import appeng.tile.AEBaseTile;
|
||||||
|
|
||||||
|
|
||||||
public class CableBusTESR extends TileEntitySpecialRenderer<AEBaseTile>
|
public class CableBusTESR extends TileEntityRenderer<AEBaseTile>
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ import net.minecraft.block.Block;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.ITickable;
|
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.wrapper.EmptyHandler;
|
import net.minecraftforge.items.wrapper.EmptyHandler;
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ import appeng.util.Platform;
|
|||||||
import appeng.util.inv.InvOperation;
|
import appeng.util.inv.InvOperation;
|
||||||
|
|
||||||
|
|
||||||
public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock, ITickable
|
public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock, ITickableTileEntity
|
||||||
{
|
{
|
||||||
private final byte corner = 16;
|
private final byte corner = 16;
|
||||||
private final AppEngInternalInventory internalInventory = new AppEngInternalInventory( this, 1, 1 );
|
private final AppEngInternalInventory internalInventory = new AppEngInternalInventory( this, 1, 1 );
|
||||||
@@ -73,7 +73,7 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update()
|
public void tick()
|
||||||
{
|
{
|
||||||
if( this.updateStatus )
|
if( this.updateStatus )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ import net.minecraft.entity.player.PlayerEntity;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.ITickable;
|
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraft.fluid.Fluid;
|
import net.minecraft.fluid.Fluid;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
@@ -106,7 +106,7 @@ import appeng.util.inv.filter.IAEItemFilter;
|
|||||||
import appeng.util.item.AEItemStack;
|
import appeng.util.item.AEItemStack;
|
||||||
|
|
||||||
|
|
||||||
public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminalHost, IPriorityHost, IConfigManagerHost, IColorableTile, ITickable
|
public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminalHost, IPriorityHost, IConfigManagerHost, IColorableTile, ITickableTileEntity
|
||||||
{
|
{
|
||||||
private final AppEngInternalInventory inputInventory = new AppEngInternalInventory( this, 1 );
|
private final AppEngInternalInventory inputInventory = new AppEngInternalInventory( this, 1 );
|
||||||
private final AppEngInternalInventory cellInventory = new AppEngInternalInventory( this, 1 );
|
private final AppEngInternalInventory cellInventory = new AppEngInternalInventory( this, 1 );
|
||||||
@@ -347,7 +347,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update()
|
public void tick()
|
||||||
{
|
{
|
||||||
if( this.world.isRemote )
|
if( this.world.isRemote )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,22 +21,25 @@ package appeng.tile.storage;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import appeng.block.storage.BlockSkyChest;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.init.SoundEvents;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraft.util.ITickable;
|
import net.minecraft.tileentity.IChestLid;
|
||||||
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.SoundCategory;
|
import net.minecraft.util.SoundCategory;
|
||||||
|
import net.minecraft.util.SoundEvents;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
import appeng.tile.AEBaseInvTile;
|
import appeng.tile.AEBaseInvTile;
|
||||||
import appeng.tile.inventory.AppEngInternalInventory;
|
import appeng.tile.inventory.AppEngInternalInventory;
|
||||||
import appeng.util.inv.InvOperation;
|
import appeng.util.inv.InvOperation;
|
||||||
|
|
||||||
|
public class TileSkyChest extends AEBaseInvTile implements ITickableTileEntity, IChestLid
|
||||||
public class TileSkyChest extends AEBaseInvTile implements ITickable
|
|
||||||
{
|
{
|
||||||
|
|
||||||
private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 9 * 4 );
|
private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 9 * 4 );
|
||||||
@@ -47,6 +50,10 @@ public class TileSkyChest extends AEBaseInvTile implements ITickable
|
|||||||
private float lidAngle;
|
private float lidAngle;
|
||||||
private float prevLidAngle;
|
private float prevLidAngle;
|
||||||
|
|
||||||
|
public TileSkyChest(TileEntityType<? extends TileSkyChest> type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void writeToStream( final PacketBuffer data ) throws IOException
|
protected void writeToStream( final PacketBuffer data ) throws IOException
|
||||||
{
|
{
|
||||||
@@ -92,9 +99,7 @@ public class TileSkyChest extends AEBaseInvTile implements ITickable
|
|||||||
if( !player.isSpectator() )
|
if( !player.isSpectator() )
|
||||||
{
|
{
|
||||||
this.setPlayerOpen( this.getPlayerOpen() + 1 );
|
this.setPlayerOpen( this.getPlayerOpen() + 1 );
|
||||||
this.world.addBlockEvent( this.pos, this.getBlockType(), 1, this.numPlayersUsing );
|
onOpenOrClose();
|
||||||
this.world.notifyNeighborsOfStateChange( this.pos, this.getBlockType(), true );
|
|
||||||
this.world.notifyNeighborsOfStateChange( this.pos.down(), this.getBlockType(), true );
|
|
||||||
|
|
||||||
if( this.getPlayerOpen() == 1 )
|
if( this.getPlayerOpen() == 1 )
|
||||||
{
|
{
|
||||||
@@ -111,9 +116,7 @@ public class TileSkyChest extends AEBaseInvTile implements ITickable
|
|||||||
if( !player.isSpectator() )
|
if( !player.isSpectator() )
|
||||||
{
|
{
|
||||||
this.setPlayerOpen( this.getPlayerOpen() - 1 );
|
this.setPlayerOpen( this.getPlayerOpen() - 1 );
|
||||||
this.world.addBlockEvent( this.pos, this.getBlockType(), 1, this.numPlayersUsing );
|
onOpenOrClose();
|
||||||
this.world.notifyNeighborsOfStateChange( this.pos, this.getBlockType(), true );
|
|
||||||
this.world.notifyNeighborsOfStateChange( this.pos.down(), this.getBlockType(), true );
|
|
||||||
|
|
||||||
if( this.getPlayerOpen() < 0 )
|
if( this.getPlayerOpen() < 0 )
|
||||||
{
|
{
|
||||||
@@ -130,8 +133,19 @@ public class TileSkyChest extends AEBaseInvTile implements ITickable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// See ChestTileEntity
|
||||||
|
private void onOpenOrClose() {
|
||||||
|
Block block = this.getBlockState().getBlock();
|
||||||
|
if (block instanceof BlockSkyChest) {
|
||||||
|
this.world.addBlockEvent(this.pos, block, 1, this.numPlayersUsing);
|
||||||
|
this.world.notifyNeighborsOfStateChange(this.pos, block);
|
||||||
|
// FIXME: Uhm, we are we doing this?
|
||||||
|
this.world.notifyNeighborsOfStateChange(this.pos.down(), block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update()
|
public void tick()
|
||||||
{
|
{
|
||||||
int i = this.pos.getX();
|
int i = this.pos.getX();
|
||||||
int j = this.pos.getY();
|
int j = this.pos.getY();
|
||||||
@@ -212,4 +226,11 @@ public class TileSkyChest extends AEBaseInvTile implements ITickable
|
|||||||
{
|
{
|
||||||
this.lastEvent = lastEvent;
|
this.lastEvent = lastEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getLidAngle(float v) {
|
||||||
|
// FIXME: Do it nicely as the chest does it (interpolation, baby!)
|
||||||
|
return lidAngle;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user