More stuff ingame and showing up.
This commit is contained in:
@@ -30,6 +30,7 @@ import java.util.function.Supplier;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -93,8 +94,8 @@ class BlockDefinitionBuilder implements IBlockBuilder
|
||||
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
this.blockRendering = new BlockRendering();
|
||||
this.itemRendering = new ItemRendering();
|
||||
this.blockRendering = new BlockRendering();
|
||||
this.itemRendering = new ItemRendering();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +121,7 @@ class BlockDefinitionBuilder implements IBlockBuilder
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public BlockDefinitionBuilder rendering( BlockRenderingCustomizer callback )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
@@ -179,11 +180,6 @@ class BlockDefinitionBuilder implements IBlockBuilder
|
||||
@Override
|
||||
public <T extends IBlockDefinition> T build()
|
||||
{
|
||||
if( !AEConfig.instance().areFeaturesEnabled( this.features ) )
|
||||
{
|
||||
return (T) new TileDefinition( this.registryName, null, null );
|
||||
}
|
||||
|
||||
// Create block and matching item, and set factory name of both
|
||||
Block block = this.blockSupplier.get();
|
||||
block.setRegistryName( AppEng.MOD_ID, this.registryName );
|
||||
@@ -268,7 +264,7 @@ class BlockDefinitionBuilder implements IBlockBuilder
|
||||
}
|
||||
else if( block instanceof AEBaseBlock )
|
||||
{
|
||||
return new AEBaseBlockItem( block );
|
||||
return new AEBaseBlockItem( block, new Item.Properties() /* FIXME THIS IS THE IMPORTANT BIT */ );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -19,25 +19,20 @@
|
||||
package appeng.bootstrap;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.bootstrap.components.BlockColorComponent;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.statemap.IStateMapper;
|
||||
import net.minecraft.client.renderer.color.IBlockColor;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
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.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.bootstrap.components.BlockColorComponent;
|
||||
import appeng.bootstrap.components.StateMapperComponent;
|
||||
import appeng.bootstrap.components.TesrComponent;
|
||||
import appeng.client.render.model.AutoRotatingModel;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
|
||||
class BlockRendering implements IBlockRendering
|
||||
@@ -50,13 +45,13 @@ class BlockRendering implements IBlockRendering
|
||||
private IBlockColor blockColor;
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private TileEntitySpecialRenderer<?> tesr;
|
||||
private TileEntityRenderer<?> tesr;
|
||||
|
||||
// FIXME @OnlyIn( Dist.CLIENT )
|
||||
// FIXME private IStateMapper stateMapper;
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private IStateMapper stateMapper;
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private Map<String, IModel> builtInModels = new HashMap<>();
|
||||
private Map<String, IUnbakedModel> builtInModels = new HashMap<>();
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
@@ -76,47 +71,47 @@ class BlockRendering implements IBlockRendering
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
@Override
|
||||
public IBlockRendering tesr( TileEntitySpecialRenderer<?> tesr )
|
||||
public IBlockRendering tesr( TileEntityRenderer<?> tesr )
|
||||
{
|
||||
this.tesr = tesr;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockRendering builtInModel( String name, IModel model )
|
||||
public IBlockRendering builtInModel( String name, IUnbakedModel model )
|
||||
{
|
||||
this.builtInModels.put( name, model );
|
||||
return this;
|
||||
}
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
@Override
|
||||
public IBlockRendering stateMapper( IStateMapper mapper )
|
||||
{
|
||||
this.stateMapper = mapper;
|
||||
return this;
|
||||
}
|
||||
// FIXME @OnlyIn( Dist.CLIENT )
|
||||
// FIXME @Override
|
||||
// FIXME public IBlockRendering stateMapper( IStateMapper mapper )
|
||||
// FIXME {
|
||||
// FIXME this.stateMapper = mapper;
|
||||
// FIXME return this;
|
||||
// FIXME }
|
||||
|
||||
void apply( FeatureFactory factory, Block block, Class<?> tileEntityClass )
|
||||
{
|
||||
if( this.tesr != null )
|
||||
{
|
||||
if( tileEntityClass == null )
|
||||
{
|
||||
throw new IllegalStateException( "Tried to register a TESR for " + block + " even though no tile entity has been specified." );
|
||||
}
|
||||
factory.addBootstrapComponent( new TesrComponent( tileEntityClass, this.tesr ) );
|
||||
}
|
||||
// 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().getResourcePath(), this.modelCustomizer );
|
||||
factory.addModelOverride( block.getRegistryName().getPath(), this.modelCustomizer );
|
||||
}
|
||||
else if( block instanceof AEBaseTileBlock )
|
||||
{
|
||||
// This is a default rotating model if the base-block uses an AE tile entity which exposes UP/FRONT as
|
||||
// extended props
|
||||
factory.addModelOverride( block.getRegistryName().getResourcePath(), ( l, m ) -> new AutoRotatingModel( m ) );
|
||||
// FIXME factory.addModelOverride( block.getRegistryName().getPath(), ( l, m ) -> new AutoRotatingModel( m ) );
|
||||
}
|
||||
|
||||
// TODO : 1.12
|
||||
@@ -127,9 +122,9 @@ class BlockRendering implements IBlockRendering
|
||||
factory.addBootstrapComponent( new BlockColorComponent( block, this.blockColor ) );
|
||||
}
|
||||
|
||||
if( this.stateMapper != null )
|
||||
{
|
||||
factory.addBootstrapComponent( new StateMapperComponent( block, this.stateMapper ) );
|
||||
}
|
||||
// FIXME if( this.stateMapper != null )
|
||||
// FIXME {
|
||||
// FIXME factory.addBootstrapComponent( new StateMapperComponent( block, this.stateMapper ) );
|
||||
// FIXME }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,8 +40,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.BuiltInModelComponent;
|
||||
import appeng.bootstrap.components.ModelOverrideComponent;
|
||||
import appeng.bootstrap.components.TileEntityComponent;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.ActivityState;
|
||||
@@ -57,11 +55,11 @@ public class FeatureFactory
|
||||
|
||||
private final Map<Class<? extends IBootstrapComponent>, List<IBootstrapComponent>> bootstrapComponents;
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private ModelOverrideComponent modelOverrideComponent;
|
||||
//FIXME @OnlyIn( Dist.CLIENT )
|
||||
//FIXME private ModelOverrideComponent modelOverrideComponent;
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private BuiltInModelComponent builtInModelComponent;
|
||||
//FIXME @OnlyIn( Dist.CLIENT )
|
||||
//FIXME private BuiltInModelComponent builtInModelComponent;
|
||||
|
||||
public final TileEntityComponent tileEntityComponent;
|
||||
|
||||
@@ -75,11 +73,10 @@ public class FeatureFactory
|
||||
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
this.modelOverrideComponent = new ModelOverrideComponent();
|
||||
this.addBootstrapComponent( this.modelOverrideComponent );
|
||||
|
||||
this.builtInModelComponent = new BuiltInModelComponent();
|
||||
this.addBootstrapComponent( this.builtInModelComponent );
|
||||
// FIXME this.modelOverrideComponent = new ModelOverrideComponent();
|
||||
// FIXME this.addBootstrapComponent( this.modelOverrideComponent );
|
||||
// FIXME this.builtInModelComponent = new BuiltInModelComponent();
|
||||
// FIXME this.addBootstrapComponent( this.builtInModelComponent );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,8 +87,8 @@ public class FeatureFactory
|
||||
this.tileEntityComponent = parent.tileEntityComponent;
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
this.modelOverrideComponent = parent.modelOverrideComponent;
|
||||
this.builtInModelComponent = parent.builtInModelComponent;
|
||||
// FIXME this.modelOverrideComponent = parent.modelOverrideComponent;
|
||||
// FIXME this.builtInModelComponent = parent.builtInModelComponent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,13 +139,13 @@ public class FeatureFactory
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
void addBuiltInModel( String path, IUnbakedModel model )
|
||||
{
|
||||
this.builtInModelComponent.addModel( path, model );
|
||||
// FIXME this.builtInModelComponent.addModel( path, model );
|
||||
}
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
void addModelOverride( String resourcePath, BiFunction<ModelResourceLocation, IBakedModel, IBakedModel> customizer )
|
||||
{
|
||||
this.modelOverrideComponent.addOverride( resourcePath, customizer );
|
||||
// FIXME this.modelOverrideComponent.addOverride( resourcePath, customizer );
|
||||
}
|
||||
|
||||
public <T extends IBootstrapComponent> Iterator<T> getBootstrapComponents( Class<T> eventType )
|
||||
|
||||
@@ -42,8 +42,8 @@ public interface IBlockRendering
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
IBlockRendering blockColor( IBlockColor blockColor );
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
IBlockRendering stateMapper( IStateMapper mapper );
|
||||
//FIXME @OnlyIn( Dist.CLIENT )
|
||||
// IBlockRendering stateMapper( IStateMapper mapper );
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
IBlockRendering tesr( TileEntityRenderer<?> ter );
|
||||
|
||||
@@ -44,7 +44,7 @@ public interface IItemBuilder
|
||||
|
||||
IItemBuilder itemGroup( ItemGroup tab );
|
||||
|
||||
IItemBuilder rendering( ItemRenderingCustomizer callback );
|
||||
//FIXME IItemBuilder rendering( ItemRenderingCustomizer callback );
|
||||
|
||||
/**
|
||||
* Registers a custom dispenser behavior for this item.
|
||||
|
||||
@@ -22,13 +22,12 @@ package appeng.bootstrap;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
|
||||
|
||||
/**
|
||||
@@ -42,8 +41,8 @@ public interface IItemRendering
|
||||
* item model to be used for rendering by inspecting the item stack (i.e. for NBT data).
|
||||
* Please
|
||||
*/
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
IItemRendering meshDefinition( ItemMeshDefinition meshDefinition );
|
||||
//FIXME @OnlyIn( Dist.CLIENT )
|
||||
//FIXME IItemRendering meshDefinition( ItemMeshDefinition meshDefinition );
|
||||
|
||||
/**
|
||||
* Registers an item model for meta=0, see {@link #model(int, ModelResourceLocation)}.
|
||||
@@ -90,6 +89,6 @@ public interface IItemRendering
|
||||
* Registers a built-in model under the given resource path.
|
||||
*/
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
IItemRendering builtInModel( String name, IModel model );
|
||||
IItemRendering builtInModel( String name, IUnbakedModel model );
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public interface IModelRegistry
|
||||
|
||||
void setCustomModelResourceLocation( Item item, int metadata, ModelResourceLocation model );
|
||||
|
||||
void setCustomMeshDefinition( Item item, ItemMeshDefinition meshDefinition );
|
||||
// FIXME void setCustomMeshDefinition( Item item, ItemMeshDefinition meshDefinition );
|
||||
|
||||
void setCustomStateMapper( Block block, IStateMapper mapper );
|
||||
// FIXME void setCustomStateMapper( Block block, IStateMapper mapper );
|
||||
}
|
||||
|
||||
@@ -58,9 +58,10 @@ class ItemDefinitionBuilder implements IItemBuilder
|
||||
|
||||
private Supplier<IDispenseItemBehavior> dispenserBehaviorSupplier;
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private ItemRendering itemRendering;
|
||||
|
||||
// FIXME
|
||||
// @OnlyIn( Dist.CLIENT )
|
||||
// private ItemRendering itemRendering;
|
||||
//
|
||||
private ItemGroup itemGroup = CreativeTab.instance;
|
||||
|
||||
ItemDefinitionBuilder( FeatureFactory factory, String registryName, Supplier<Item> itemSupplier )
|
||||
@@ -70,7 +71,7 @@ class ItemDefinitionBuilder implements IItemBuilder
|
||||
this.itemSupplier = itemSupplier;
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
this.itemRendering = new ItemRendering();
|
||||
// FIXME this.itemRendering = new ItemRendering();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,16 +104,16 @@ class ItemDefinitionBuilder implements IItemBuilder
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemBuilder rendering( ItemRenderingCustomizer callback )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
this.customizeForClient( callback );
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
// FIXME @Override
|
||||
// FIXME public IItemBuilder rendering( ItemRenderingCustomizer callback )
|
||||
// FIXME {
|
||||
// FIXME if( Platform.isClient() )
|
||||
// FIXME {
|
||||
// FIXME this.customizeForClient( callback );
|
||||
// FIXME }
|
||||
// FIXME
|
||||
// FIXME return this;
|
||||
// FIXME }
|
||||
|
||||
@Override
|
||||
public IItemBuilder dispenserBehavior( Supplier<IDispenseItemBehavior> behavior )
|
||||
@@ -121,11 +122,11 @@ class ItemDefinitionBuilder implements IItemBuilder
|
||||
return this;
|
||||
}
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private void customizeForClient( ItemRenderingCustomizer callback )
|
||||
{
|
||||
callback.customize( this.itemRendering );
|
||||
}
|
||||
// FIXME @OnlyIn( Dist.CLIENT )
|
||||
// FIXME private void customizeForClient( ItemRenderingCustomizer callback )
|
||||
// FIXME {
|
||||
// FIXME callback.customize( this.itemRendering );
|
||||
// FIXME }
|
||||
|
||||
@Override
|
||||
public ItemDefinition build()
|
||||
@@ -157,7 +158,7 @@ class ItemDefinitionBuilder implements IItemBuilder
|
||||
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
this.itemRendering.apply( this.factory, item );
|
||||
// FIXME this.itemRendering.apply( this.factory, item );
|
||||
}
|
||||
|
||||
return definition;
|
||||
|
||||
@@ -30,16 +30,15 @@ import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
|
||||
import appeng.bootstrap.components.ItemColorComponent;
|
||||
import appeng.bootstrap.components.ItemMeshDefinitionComponent;
|
||||
@@ -53,8 +52,9 @@ class ItemRendering implements IItemRendering
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private IItemColor itemColor;
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private ItemMeshDefinition itemMeshDefinition;
|
||||
// FIXME
|
||||
// @OnlyIn( Dist.CLIENT )
|
||||
// private ItemMeshDefinition itemMeshDefinition;
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private Map<Integer, ModelResourceLocation> itemModels = new HashMap<>();
|
||||
@@ -63,15 +63,16 @@ class ItemRendering implements IItemRendering
|
||||
private Set<ResourceLocation> variants = new HashSet<>();
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private Map<String, IModel> builtInModels = new HashMap<>();
|
||||
private Map<String, IUnbakedModel> builtInModels = new HashMap<>();
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public IItemRendering meshDefinition( ItemMeshDefinition meshDefinition )
|
||||
{
|
||||
this.itemMeshDefinition = meshDefinition;
|
||||
return this;
|
||||
}
|
||||
// FIXME
|
||||
// @Override
|
||||
// @OnlyIn( Dist.CLIENT )
|
||||
// public IItemRendering meshDefinition( ItemMeshDefinition meshDefinition )
|
||||
// {
|
||||
// this.itemMeshDefinition = meshDefinition;
|
||||
// return this;
|
||||
// }
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
@@ -97,7 +98,7 @@ class ItemRendering implements IItemRendering
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemRendering builtInModel( String name, IModel model )
|
||||
public IItemRendering builtInModel( String name, IUnbakedModel model )
|
||||
{
|
||||
this.builtInModels.put( name, model );
|
||||
return this;
|
||||
@@ -105,10 +106,10 @@ class ItemRendering implements IItemRendering
|
||||
|
||||
void apply( FeatureFactory factory, Item item )
|
||||
{
|
||||
if( this.itemMeshDefinition != null )
|
||||
{
|
||||
factory.addBootstrapComponent( new ItemMeshDefinitionComponent( item, this.itemMeshDefinition ) );
|
||||
}
|
||||
//FIXME if( this.itemMeshDefinition != null )
|
||||
//FIXME {
|
||||
//FIXME factory.addBootstrapComponent( new ItemMeshDefinitionComponent( item, this.itemMeshDefinition ) );
|
||||
//FIXME }
|
||||
|
||||
if( !this.itemModels.isEmpty() )
|
||||
{
|
||||
@@ -118,24 +119,28 @@ class ItemRendering implements IItemRendering
|
||||
Set<ResourceLocation> resources = new HashSet<>( this.variants );
|
||||
|
||||
// Register a default item model if neither items by meta nor an item mesh definition exist
|
||||
if( this.itemMeshDefinition == null && this.itemModels.isEmpty() )
|
||||
if( /* FIXME this.itemMeshDefinition == null && */ this.itemModels.isEmpty() )
|
||||
{
|
||||
ModelResourceLocation model;
|
||||
|
||||
// For block items, the default will try to use the default state of the associated block
|
||||
if( item instanceof BlockItem )
|
||||
{
|
||||
Block block = ( (BlockItem) item ).getBlock();
|
||||
|
||||
// We can only do this once the blocks are actually registered...
|
||||
StateMapperHelper helper = new StateMapperHelper( item.getRegistryName() );
|
||||
model = helper.getModelResourceLocation( block.getDefaultState() );
|
||||
}
|
||||
else
|
||||
{
|
||||
model = new ModelResourceLocation( item.getRegistryName(), "inventory" );
|
||||
}
|
||||
factory.addBootstrapComponent( new ItemModelComponent( item, ImmutableMap.of( 0, model ) ) );
|
||||
// ModelResourceLocation model;
|
||||
//
|
||||
// // For block items, the default will try to use the default state of the associated block
|
||||
// if( item instanceof BlockItem )
|
||||
// {
|
||||
// Block block = ( (BlockItem) item ).getBlock();
|
||||
//
|
||||
// // We can only do this once the blocks are actually registered...
|
||||
// model = new ModelResourceLocation(
|
||||
// new ResourceLocation(
|
||||
// block.getRegistryName().getNamespace(),
|
||||
// "block/" + block.getRegistryName().getPath()
|
||||
// )
|
||||
// , "inventory" );
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// model = new ModelResourceLocation( item.getRegistryName(), "inventory" );
|
||||
// }
|
||||
// factory.addBootstrapComponent( new ItemModelComponent( item, ImmutableMap.of( 0, model ) ) );
|
||||
}
|
||||
|
||||
// TODO : 1.12
|
||||
@@ -145,12 +150,12 @@ class ItemRendering implements IItemRendering
|
||||
{
|
||||
factory.addBootstrapComponent( new ItemVariantsComponent( item, resources ) );
|
||||
}
|
||||
else if( this.itemMeshDefinition != null )
|
||||
{
|
||||
// Adding an empty variant list here will prevent Vanilla from trying to load the default item model in this
|
||||
// case
|
||||
factory.addBootstrapComponent( new ItemVariantsComponent( item, Collections.emptyList() ) );
|
||||
}
|
||||
// FIXME else if( this.itemMeshDefinition != null )
|
||||
// FIXME {
|
||||
// FIXME // Adding an empty variant list here will prevent Vanilla from trying to load the default item model in this
|
||||
// FIXME // case
|
||||
// FIXME factory.addBootstrapComponent( new ItemVariantsComponent( item, Collections.emptyList() ) );
|
||||
// FIXME }
|
||||
|
||||
if( this.itemColor != null )
|
||||
{
|
||||
@@ -158,20 +163,4 @@ class ItemRendering implements IItemRendering
|
||||
}
|
||||
}
|
||||
|
||||
private static class StateMapperHelper extends StateMapperBase
|
||||
{
|
||||
|
||||
private final ResourceLocation registryName;
|
||||
|
||||
public StateMapperHelper( ResourceLocation registryName )
|
||||
{
|
||||
this.registryName = registryName;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ModelResourceLocation getModelResourceLocation( BlockState state )
|
||||
{
|
||||
return new ModelResourceLocation( this.registryName, this.getPropertyString( state.getProperties() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,9 +28,7 @@ import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
|
||||
import appeng.client.render.model.BuiltInModelLoader;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public class BuiltInModelComponent implements IPreInitComponent
|
||||
@@ -51,7 +49,7 @@ public class BuiltInModelComponent implements IPreInitComponent
|
||||
{
|
||||
this.hasInitialized = true;
|
||||
|
||||
BuiltInModelLoader loader = new BuiltInModelLoader( this.builtInModels );
|
||||
ModelLoaderRegistry.registerLoader( loader );
|
||||
// FIXME BuiltInModelLoader loader = new BuiltInModelLoader( this.builtInModels );
|
||||
// FIXME ModelLoaderRegistry.registerLoader( loader );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,5 +12,5 @@ import appeng.bootstrap.IBootstrapComponent;
|
||||
@FunctionalInterface
|
||||
public interface IEntityRegistrationComponent extends IBootstrapComponent
|
||||
{
|
||||
void entityRegistration( IForgeRegistry<EntityType<? extends Entity>> entityRegistry );
|
||||
void entityRegistration( IForgeRegistry<EntityType<?>> entityRegistry );
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package appeng.bootstrap.components;
|
||||
|
||||
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
|
||||
@@ -12,5 +13,5 @@ import appeng.bootstrap.IBootstrapComponent;
|
||||
@FunctionalInterface
|
||||
public interface IRecipeRegistrationComponent extends IBootstrapComponent
|
||||
{
|
||||
void recipeRegistration( Dist dist, IForgeRegistry<IRecipe> recipeRegistry );
|
||||
void recipeRegistration( Dist dist, IForgeRegistry<IRecipeSerializer<?>> recipeRegistry );
|
||||
}
|
||||
|
||||
@@ -19,10 +19,7 @@
|
||||
package appeng.bootstrap.components;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import appeng.bootstrap.IModelRegistry;
|
||||
@@ -35,19 +32,19 @@ import appeng.bootstrap.IModelRegistry;
|
||||
public class ItemMeshDefinitionComponent implements IModelRegistrationComponent
|
||||
{
|
||||
|
||||
private final Item item;
|
||||
// FIXME private final Item item;
|
||||
// FIXME
|
||||
// FIXME private final ItemMeshDefinition meshDefinition;
|
||||
|
||||
private final ItemMeshDefinition meshDefinition;
|
||||
|
||||
public ItemMeshDefinitionComponent( @Nonnull Item item, @Nonnull ItemMeshDefinition meshDefinition )
|
||||
{
|
||||
this.item = item;
|
||||
this.meshDefinition = meshDefinition;
|
||||
}
|
||||
// FIXME public ItemMeshDefinitionComponent( @Nonnull Item item, @Nonnull ItemMeshDefinition meshDefinition )
|
||||
// FIXME {
|
||||
// FIXME this.item = item;
|
||||
// FIXME this.meshDefinition = meshDefinition;
|
||||
// FIXME }
|
||||
|
||||
@Override
|
||||
public void modelRegistration( Dist dist, IModelRegistry registry )
|
||||
{
|
||||
registry.setCustomMeshDefinition( this.item, this.meshDefinition );
|
||||
// FIXME registry.setCustomMeshDefinition( this.item, this.meshDefinition );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,12 +27,10 @@ import java.util.function.BiFunction;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraft.client.renderer.model.ModelBakery;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
@@ -42,12 +40,10 @@ import appeng.core.AppEng;
|
||||
public class ModelOverrideComponent implements IPreInitComponent
|
||||
{
|
||||
|
||||
private static final ModelResourceLocation MODEL_MISSING = new ModelResourceLocation( "builtin/missing", "missing" );
|
||||
|
||||
// Maps from resource path to customizer
|
||||
private final Map<String, BiFunction<ModelResourceLocation, IBakedModel, IBakedModel>> customizer = new HashMap<>();
|
||||
private final Map<String, BiFunction<ResourceLocation, IBakedModel, IBakedModel>> customizer = new HashMap<>();
|
||||
|
||||
public void addOverride( String resourcePath, BiFunction<ModelResourceLocation, IBakedModel, IBakedModel> customizer )
|
||||
public void addOverride( String resourcePath, BiFunction<ResourceLocation, IBakedModel, IBakedModel> customizer )
|
||||
{
|
||||
this.customizer.put( resourcePath, customizer );
|
||||
}
|
||||
@@ -61,19 +57,18 @@ public class ModelOverrideComponent implements IPreInitComponent
|
||||
@SubscribeEvent
|
||||
public void onModelBakeEvent( final ModelBakeEvent event )
|
||||
{
|
||||
IRegistry<ModelResourceLocation, IBakedModel> modelRegistry = event.getModelRegistry();
|
||||
Set<ModelResourceLocation> keys = Sets.newHashSet( modelRegistry.getKeys() );
|
||||
// IBakedModel missingModel = modelRegistry.getObject( MODEL_MISSING );
|
||||
IModel missingModel = ModelLoaderRegistry.getMissingModel();
|
||||
Map<ResourceLocation, IBakedModel> modelRegistry = event.getModelRegistry();
|
||||
Set<ResourceLocation> keys = Sets.newHashSet( modelRegistry.keySet() );
|
||||
IBakedModel missingModel = modelRegistry.get(ModelBakery.MODEL_MISSING);
|
||||
|
||||
for( ModelResourceLocation location : keys )
|
||||
for( ResourceLocation location : keys )
|
||||
{
|
||||
if( !location.getResourceDomain().equals( AppEng.MOD_ID ) )
|
||||
if( !location.getNamespace().equals( AppEng.MOD_ID ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
IBakedModel orgModel = modelRegistry.getObject( location );
|
||||
IBakedModel orgModel = modelRegistry.get( location );
|
||||
|
||||
// Don't customize the missing model. This causes Forge to swallow exceptions
|
||||
if( orgModel == missingModel )
|
||||
@@ -81,14 +76,14 @@ public class ModelOverrideComponent implements IPreInitComponent
|
||||
continue;
|
||||
}
|
||||
|
||||
BiFunction<ModelResourceLocation, IBakedModel, IBakedModel> customizer = this.customizer.get( location.getResourcePath() );
|
||||
BiFunction<ResourceLocation, IBakedModel, IBakedModel> customizer = this.customizer.get( location.getPath() );
|
||||
if( customizer != null )
|
||||
{
|
||||
IBakedModel newModel = customizer.apply( location, orgModel );
|
||||
|
||||
if( newModel != orgModel )
|
||||
{
|
||||
modelRegistry.putObject( location, newModel );
|
||||
modelRegistry.put( location, newModel );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,6 @@ package appeng.bootstrap.components;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.statemap.IStateMapper;
|
||||
import net.minecraft.client.resources.IReloadableResourceManager;
|
||||
import net.minecraft.client.resources.IResourceManagerReloadListener;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
import appeng.bootstrap.IModelRegistry;
|
||||
@@ -35,24 +32,24 @@ import appeng.bootstrap.IModelRegistry;
|
||||
public class StateMapperComponent implements IModelRegistrationComponent
|
||||
{
|
||||
|
||||
private final Block block;
|
||||
// FIXME private final Block block;
|
||||
|
||||
private final IStateMapper stateMapper;
|
||||
|
||||
public StateMapperComponent( Block block, IStateMapper stateMapper )
|
||||
{
|
||||
this.block = block;
|
||||
this.stateMapper = stateMapper;
|
||||
}
|
||||
// FIXME private final IStateMapper stateMapper;
|
||||
// FIXME
|
||||
// FIXME public StateMapperComponent( Block block, IStateMapper stateMapper )
|
||||
// FIXME {
|
||||
// FIXME this.block = block;
|
||||
// FIXME this.stateMapper = stateMapper;
|
||||
// FIXME }
|
||||
|
||||
@Override
|
||||
public void modelRegistration( Dist dist, IModelRegistry registry )
|
||||
{
|
||||
registry.setCustomStateMapper( this.block, this.stateMapper );
|
||||
if( this.stateMapper instanceof IResourceManagerReloadListener )
|
||||
{
|
||||
( (IReloadableResourceManager) Minecraft.getInstance().getResourceManager() )
|
||||
.registerReloadListener( (IResourceManagerReloadListener) this.stateMapper );
|
||||
}
|
||||
// FIXME registry.setCustomStateMapper( this.block, this.stateMapper );
|
||||
// FIXME if( this.stateMapper instanceof IResourceManagerReloadListener )
|
||||
// FIXME {
|
||||
// FIXME ( (IReloadableResourceManager) Minecraft.getInstance().getResourceManager() )
|
||||
// FIXME .registerReloadListener( (IResourceManagerReloadListener) this.stateMapper );
|
||||
// FIXME }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class TileEntityComponent implements IPreInitComponent
|
||||
{
|
||||
if( !tileEntityDefinition.isRegistered() )
|
||||
{
|
||||
GameRegistry.registerTileEntity( tileEntityDefinition.getTileEntityClass(), AppEng.MOD_ID + ":" + tileEntityDefinition.getName() );
|
||||
// FIXME GameRegistry.registerTileEntity( tileEntityDefinition.getTileEntityClass(), AppEng.MOD_ID + ":" + tileEntityDefinition.getName() );
|
||||
tileEntityDefinition.setRegistered( true );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user