Basic JEI integration is back
This commit is contained in:
@@ -20,29 +20,16 @@ package appeng.bootstrap;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
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 appeng.bootstrap.components.ItemColorComponent;
|
||||
import appeng.bootstrap.components.ItemMeshDefinitionComponent;
|
||||
import appeng.bootstrap.components.ItemModelComponent;
|
||||
import appeng.bootstrap.components.ItemVariantsComponent;
|
||||
|
||||
|
||||
@@ -52,36 +39,9 @@ class ItemRendering implements IItemRendering
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private IItemColor itemColor;
|
||||
|
||||
// FIXME
|
||||
// @OnlyIn( Dist.CLIENT )
|
||||
// private ItemMeshDefinition itemMeshDefinition;
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private Map<Integer, ModelResourceLocation> itemModels = new HashMap<>();
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private Set<ResourceLocation> variants = new HashSet<>();
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private Map<String, IUnbakedModel> builtInModels = new HashMap<>();
|
||||
|
||||
// FIXME
|
||||
// @Override
|
||||
// @OnlyIn( Dist.CLIENT )
|
||||
// public IItemRendering meshDefinition( ItemMeshDefinition meshDefinition )
|
||||
// {
|
||||
// this.itemMeshDefinition = meshDefinition;
|
||||
// return this;
|
||||
// }
|
||||
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public IItemRendering model( int meta, ModelResourceLocation model )
|
||||
{
|
||||
this.itemModels.put( meta, model );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemRendering variants( Collection<ResourceLocation> resources )
|
||||
{
|
||||
@@ -97,65 +57,14 @@ class ItemRendering implements IItemRendering
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemRendering builtInModel( String name, IUnbakedModel model )
|
||||
{
|
||||
this.builtInModels.put( name, model );
|
||||
return this;
|
||||
}
|
||||
|
||||
void apply( FeatureFactory factory, Item item )
|
||||
{
|
||||
//FIXME if( this.itemMeshDefinition != null )
|
||||
//FIXME {
|
||||
//FIXME factory.addBootstrapComponent( new ItemMeshDefinitionComponent( item, this.itemMeshDefinition ) );
|
||||
//FIXME }
|
||||
|
||||
if( !this.itemModels.isEmpty() )
|
||||
{
|
||||
factory.addBootstrapComponent( new ItemModelComponent( item, this.itemModels ) );
|
||||
}
|
||||
|
||||
Set<ResourceLocation> resources = new HashSet<>( this.variants );
|
||||
|
||||
// Register a default item model if neither items by meta nor an item mesh definition exist
|
||||
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...
|
||||
// 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
|
||||
this.builtInModels.forEach( factory::addBuiltInModel );
|
||||
|
||||
if( !resources.isEmpty() )
|
||||
{
|
||||
factory.addBootstrapComponent( new ItemVariantsComponent( item, resources ) );
|
||||
}
|
||||
// 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 )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user