Sky Chest TESR / Tile Entity Registration Changes
This commit is contained in:
@@ -24,18 +24,17 @@ import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.bootstrap.components.ITileEntityRegistrationComponent;
|
||||
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.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -48,7 +47,6 @@ import appeng.bootstrap.components.IBlockRegistrationComponent;
|
||||
import appeng.bootstrap.components.IItemRegistrationComponent;
|
||||
import appeng.bootstrap.components.IPreInitComponent;
|
||||
import appeng.bootstrap.definitions.TileEntityDefinition;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.CreativeTab;
|
||||
import appeng.core.features.AEFeature;
|
||||
@@ -201,27 +199,15 @@ class BlockDefinitionBuilder implements IBlockBuilder
|
||||
// Register all extra handlers
|
||||
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() );
|
||||
if( this.tileEntityDefinition.getName() == null )
|
||||
{
|
||||
this.tileEntityDefinition.setName( this.registryName );
|
||||
}
|
||||
|
||||
// Tell the tile entity definition about the block we've registered
|
||||
this.tileEntityDefinition.addBlock(block);
|
||||
}
|
||||
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
if( block instanceof AEBaseTileBlock )
|
||||
{
|
||||
AEBaseTileBlock tileBlock = (AEBaseTileBlock) block;
|
||||
this.blockRendering.apply( this.factory, block, tileBlock.getTileEntityClass() );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.blockRendering.apply( this.factory, block, null );
|
||||
}
|
||||
this.blockRendering.apply( this.factory, block );
|
||||
|
||||
if( item != null )
|
||||
{
|
||||
@@ -231,18 +217,6 @@ class BlockDefinitionBuilder implements IBlockBuilder
|
||||
|
||||
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 );
|
||||
}
|
||||
else
|
||||
|
||||
@@ -22,13 +22,15 @@ package appeng.bootstrap;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.bootstrap.components.BlockColorComponent;
|
||||
import appeng.bootstrap.components.RenderTypeComponent;
|
||||
import appeng.bootstrap.components.TileEntityRendererComponent;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.color.IBlockColor;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
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.TileEntityRendererDispatcher;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -36,6 +38,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
|
||||
class BlockRendering implements IBlockRendering
|
||||
@@ -47,12 +50,6 @@ class BlockRendering implements IBlockRendering
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private IBlockColor blockColor;
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private TileEntityRenderer<?> tesr;
|
||||
|
||||
// FIXME @OnlyIn( Dist.CLIENT )
|
||||
// FIXME private IStateMapper stateMapper;
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private Map<String, IUnbakedModel> builtInModels = new HashMap<>();
|
||||
|
||||
@@ -75,14 +72,6 @@ class BlockRendering implements IBlockRendering
|
||||
return this;
|
||||
}
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
@Override
|
||||
public IBlockRendering tesr( TileEntityRenderer<?> tesr )
|
||||
{
|
||||
this.tesr = tesr;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockRendering builtInModel( String name, IUnbakedModel model )
|
||||
{
|
||||
@@ -104,17 +93,8 @@ class BlockRendering implements IBlockRendering
|
||||
// FIXME return this;
|
||||
// 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 )
|
||||
{
|
||||
factory.addModelOverride( block.getRegistryName().getPath(), this.modelCustomizer );
|
||||
|
||||
@@ -27,15 +27,17 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import appeng.bootstrap.components.BuiltInModelComponent;
|
||||
import appeng.bootstrap.components.ModelOverrideComponent;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -43,7 +45,6 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.AEColoredItemDefinition;
|
||||
import appeng.bootstrap.components.TileEntityComponent;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.ActivityState;
|
||||
import appeng.core.features.ColoredItemDefinition;
|
||||
@@ -64,16 +65,11 @@ public class FeatureFactory
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private BuiltInModelComponent builtInModelComponent;
|
||||
|
||||
public final TileEntityComponent tileEntityComponent;
|
||||
|
||||
public FeatureFactory()
|
||||
{
|
||||
this.defaultFeatures = new AEFeature[] { AEFeature.CORE };
|
||||
this.bootstrapComponents = new HashMap<>();
|
||||
|
||||
this.tileEntityComponent = new TileEntityComponent();
|
||||
this.addBootstrapComponent( this.tileEntityComponent );
|
||||
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
this.modelOverrideComponent = new ModelOverrideComponent();
|
||||
@@ -87,7 +83,6 @@ public class FeatureFactory
|
||||
{
|
||||
this.defaultFeatures = defaultFeatures.clone();
|
||||
this.bootstrapComponents = parent.bootstrapComponents;
|
||||
this.tileEntityComponent = parent.tileEntityComponent;
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
this.modelOverrideComponent = parent.modelOverrideComponent;
|
||||
@@ -105,6 +100,11 @@ public class FeatureFactory
|
||||
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 )
|
||||
{
|
||||
ColoredItemDefinition definition = new ColoredItemDefinition();
|
||||
|
||||
@@ -20,6 +20,7 @@ package appeng.bootstrap;
|
||||
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
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.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -44,12 +46,6 @@ public interface IBlockRendering
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
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.
|
||||
*/
|
||||
|
||||
@@ -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>
|
||||
*/
|
||||
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.ter = ter;
|
||||
this.tileEntityType = tileEntityType;
|
||||
this.tileEntityRenderer = tileEntityRenderer;
|
||||
}
|
||||
|
||||
@Override
|
||||
// public void modelReg( 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 net.minecraft.block.Block;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
||||
/**
|
||||
* @author GuntherDW
|
||||
*/
|
||||
public class TileEntityDefinition
|
||||
{
|
||||
public class TileEntityDefinition {
|
||||
|
||||
private final Class<? extends AEBaseTile> tileEntityClass;
|
||||
private String name;
|
||||
private boolean isRegistered = false;
|
||||
// To be notified when a Block declares that it uses this tile entity
|
||||
private final Consumer<Block> addBlockListener;
|
||||
|
||||
// This signals the BlockDefinitionBuilder to set the name of the TE to the blockname.
|
||||
public TileEntityDefinition( Class<? extends AEBaseTile> tileEntityClass )
|
||||
{
|
||||
this.tileEntityClass = tileEntityClass;
|
||||
this.name = null;
|
||||
}
|
||||
public TileEntityDefinition(Consumer<Block> addBlockListener) {
|
||||
this.addBlockListener = addBlockListener;
|
||||
}
|
||||
|
||||
public TileEntityDefinition( Class<? extends AEBaseTile> tileEntityClass, String optionalName )
|
||||
{
|
||||
this.tileEntityClass = tileEntityClass;
|
||||
this.name = optionalName;
|
||||
}
|
||||
public void addBlock(Block block) {
|
||||
this.addBlockListener.accept(block);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user