Custom Model Loader

This commit is contained in:
Sebastian Hartte
2020-06-01 04:02:37 +02:00
parent 077ff17078
commit 5cdeff01be
202 changed files with 942 additions and 1017 deletions
+5 -15
View File
@@ -25,6 +25,7 @@ import appeng.api.definitions.IMaterials;
import appeng.api.definitions.IParts;
import appeng.bootstrap.FeatureFactory;
import appeng.core.api.definitions.ApiBlocks;
import appeng.core.api.definitions.ApiItems;
import appeng.core.features.registries.PartModels;
@@ -33,9 +34,8 @@ import appeng.core.features.registries.PartModels;
*/
public final class ApiDefinitions implements IDefinitions
{
// TODO : Check if this can be final again after the Register part.
private ApiBlocks blocks;
// private ApiItems items;
private final ApiBlocks blocks;
private final ApiItems items;
//private final ApiMaterials materials;
//private final ApiParts parts;
@@ -44,20 +44,10 @@ public final class ApiDefinitions implements IDefinitions
public ApiDefinitions( final PartModels partModels )
{
this.blocks = new ApiBlocks( this.registry, partModels );
// this.items = new ApiItems( this.registry );
this.items = new ApiItems( this.registry );
//this.materials = new ApiMaterials( this.registry );
//this.parts = new ApiParts( this.registry, partModels );
}
//
// public void addBlocks( final PartModels partModels )
// {
// this.blocks = new ApiBlocks( registry, partModels );
// }
//
// public void addItems()
// {
// this.items = new ApiItems( registry );
// }
public FeatureFactory getRegistry()
{
@@ -73,7 +63,7 @@ public final class ApiDefinitions implements IDefinitions
@Override
public IItems items()
{
return null /* FIXME */;
return items;
}
@Override
+5 -6
View File
@@ -22,6 +22,7 @@ package appeng.core;
import java.io.File;
import appeng.client.ClientHelper;
import appeng.core.features.AEFeature;
import appeng.server.ServerHelper;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityType;
@@ -83,6 +84,9 @@ public final class AppEng
//FIXMEthis.registration = new Registration();
//FIXMEMinecraftForge.EVENT_BUS.register( this.registration );
CreativeTab.init();
CreativeTabFacade.init();
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
Registration registration = new Registration();
modEventBus.addGenericListener(Block.class, registration::registerBlocks);
@@ -140,11 +144,6 @@ public final class AppEng
//
// AELog.info( "Pre Initialization ( started )" );
//
// CreativeTab.init();
// if( AEConfig.instance().isFeatureEnabled( AEFeature.FACADES ) )
// {
// CreativeTabFacade.init();
// }
//
// for( final IntegrationType type : IntegrationType.values() )
// {
@@ -172,7 +171,7 @@ public final class AppEng
//
// // Instantiate all Plugins
// List<Object> injectables = Lists.newArrayList(
// AEApi.instance() );
// Api.INSTANCE );
// new PluginLoader().loadPlugins( injectables, event.getAsmData() );
// }
//
+6 -4
View File
@@ -38,7 +38,7 @@ public final class CreativeTab
static void init()
{
instance = new ItemGroup( 11, "appliedenergistics2" )
instance = new ItemGroup( "appliedenergistics2" )
{
@Override
@@ -49,13 +49,15 @@ public final class CreativeTab
private ItemStack getIconItemStack()
{
final IDefinitions definitions = AEApi.instance().definitions();
final IDefinitions definitions = Api.INSTANCE.definitions();
final IBlocks blocks = definitions.blocks();
final IItems items = definitions.items();
final IMaterials materials = definitions.materials();
return this.findFirst( blocks.controller(), blocks.chest(), blocks.cellWorkbench(), blocks.fluixBlock(), items.cell1k(), items.networkTool(),
materials.fluixCrystal(), materials.certusQuartzCrystal(), materials.skyDust() );
return findFirst(blocks.quartzOre());
// FIXME return this.findFirst( blocks.controller(), blocks.chest(), blocks.cellWorkbench(), blocks.fluixBlock(), items.cell1k(), items.networkTool(),
// FIXME materials.fluixCrystal(), materials.certusQuartzCrystal(), materials.skyDust() );
}
private ItemStack findFirst( final IItemDefinition... choices )
@@ -22,44 +22,34 @@ package appeng.core;
import java.util.Optional;
import net.minecraft.block.Blocks;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.items.parts.ItemFacade;
public final class CreativeTabFacade extends CreativeTabs
public final class CreativeTabFacade
{
public static CreativeTabFacade instance = null;
public CreativeTabFacade()
{
super( "appliedenergistics2.facades" );
}
public static ItemGroup instance = null;
static void init()
{
instance = new CreativeTabFacade();
instance = new ItemGroup("appliedenergistics2.facades") {
@Override
public ItemStack createIcon()
{
// FIXME final Optional<Item> maybeFacade = Api.INSTANCE.definitions().items().facade().maybeItem();
// FIXME if( maybeFacade.isPresent() )
{
// FIXME return ( (ItemFacade) maybeFacade.get() ).getCreativeTabIcon();
}
return new ItemStack( Blocks.OAK_PLANKS );
}
};
}
@Override
public ItemStack getTabIconItem()
{
return this.getIconItemStack();
}
@Override
public ItemStack getIconItemStack()
{
final Optional<Item> maybeFacade = AEApi.instance().definitions().items().facade().maybeItem();
if( maybeFacade.isPresent() )
{
return ( (ItemFacade) maybeFacade.get() ).getCreativeTabIcon();
}
return new ItemStack( Blocks.PLANKS );
}
}
+12 -21
View File
@@ -19,49 +19,39 @@
package appeng.core;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.Nonnull;
import appeng.bootstrap.IModelRegistry;
import appeng.bootstrap.components.IBlockRegistrationComponent;
import appeng.bootstrap.components.IEntityRegistrationComponent;
import appeng.bootstrap.components.IItemRegistrationComponent;
import appeng.bootstrap.components.IModelRegistrationComponent;
import appeng.client.render.effects.ChargedOreFX;
import com.google.common.base.Preconditions;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.advancements.ICriterionInstance;
import net.minecraft.advancements.ICriterionTrigger;
import appeng.client.render.model.GlassModelLoader;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemModelMesher;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.entity.EntityType;
import net.minecraft.item.Item;
import net.minecraft.particles.BasicParticleType;
import net.minecraft.particles.ParticleType;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.dimension.DimensionType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.event.ParticleFactoryRegisterEvent;
import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.GenericEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.loading.FMLEnvironment;
import net.minecraftforge.registries.IForgeRegistry;
import appeng.bootstrap.components.IBlockRegistrationComponent;
import appeng.bootstrap.components.IItemRegistrationComponent;
final class Registration
{
// DimensionType storageDimensionType;
public Registration() {
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "glass"), GlassModelLoader.INSTANCE);
}
// DimensionType storageDimensionType;
// int storageDimensionID;
// Biome storageBiome;
// AdvancementTriggers advancementTriggers;
@@ -191,6 +181,7 @@ final class Registration
@OnlyIn( Dist.CLIENT )
public void modelRegistryEvent( ModelRegistryEvent event )
{
final ApiDefinitions definitions = Api.INSTANCE.definitions();
final IModelRegistry registry = new IModelRegistry() {
@Override
@@ -200,7 +191,7 @@ final class Registration
@Override
public void setCustomModelResourceLocation(Item item, int metadata, ModelResourceLocation model) {
// TODO: this does not actually work
// FIXME: this does not actually work
ItemModelMesher mesher = Minecraft.getInstance().getItemRenderer().getItemModelMesher();
mesher.register(item, model);
}
@@ -22,13 +22,19 @@ package appeng.core.api.definitions;
import appeng.api.definitions.IBlockDefinition;
import appeng.api.definitions.IBlocks;
import appeng.api.definitions.ITileDefinition;
import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.FeatureFactory;
import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering;
import appeng.client.render.model.GlassModel;
import appeng.core.features.AEFeature;
import appeng.core.features.registries.PartModels;
import appeng.decorative.solid.BlockChargedQuartzOre;
import appeng.decorative.solid.BlockQuartzOre;
import appeng.decorative.AEDecorativeBlock;
import appeng.decorative.solid.*;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
/**
@@ -114,34 +120,37 @@ public final class ApiBlocks implements IBlocks
private IBlockDefinition cubeGenerator;
private IBlockDefinition energyGenerator;
private static final Block.Properties QUARTZ_PROPERTIES = Block.Properties.create(Material.ROCK)
.hardnessAndResistance(3, 5);
public ApiBlocks( FeatureFactory registry, PartModels partModels )
{
this.quartzOre = registry.block( "quartz_ore", () -> new BlockQuartzOre(Block.Properties.create(Material.ROCK).hardnessAndResistance(3, 5)))
this.quartzOre = registry.block( "quartz_ore", () -> new BlockQuartzOre(QUARTZ_PROPERTIES))
.features( AEFeature.CERTUS_ORE )
.build();
this.quartzOreCharged = registry.block( "charged_quartz_ore", () -> new BlockChargedQuartzOre(Block.Properties.create(Material.ROCK).hardnessAndResistance(3, 5)) )
this.quartzOreCharged = registry.block( "charged_quartz_ore", () -> new BlockChargedQuartzOre(QUARTZ_PROPERTIES) )
.features( AEFeature.CERTUS_ORE, AEFeature.CHARGED_CERTUS_ORE )
.build();
// this.matrixFrame = registry.block( "matrix_frame", BlockMatrixFrame::new ).features( AEFeature.SPATIAL_IO ).build();
//
// FeatureFactory deco = registry.features( AEFeature.DECORATIVE_BLOCKS );
// this.quartzBlock = deco.block( "quartz_block", BlockQuartz::new ).build();
// this.quartzPillar = deco.block( "quartz_pillar", BlockQuartzPillar::new ).build();
// this.chiseledQuartzBlock = deco.block( "chiseled_quartz_block", BlockChiseledQuartz::new ).build();
//
// this.quartzGlass = registry.features( AEFeature.QUARTZ_GLASS )
// .block( "quartz_glass", BlockQuartzGlass::new )
FeatureFactory deco = registry.features( AEFeature.DECORATIVE_BLOCKS );
this.quartzBlock = deco.block( "quartz_block", () -> new AEDecorativeBlock(QUARTZ_PROPERTIES) ).build();
this.quartzPillar = deco.block( "quartz_pillar", () -> new BlockQuartzPillar(QUARTZ_PROPERTIES) ).build();
this.chiseledQuartzBlock = deco.block( "chiseled_quartz_block", () -> new AEDecorativeBlock(QUARTZ_PROPERTIES) ).build();
this.quartzGlass = registry.features( AEFeature.QUARTZ_GLASS )
.block( "quartz_glass", BlockQuartzGlass::new )
// .useCustomItemModel()
// FIXME .rendering( new BlockRenderingCustomizer()
// FIXME {
// FIXME @Override
// FIXME @OnlyIn( Dist.CLIENT )
// FIXME public void customize( IBlockRendering rendering, IItemRendering itemRendering )
// FIXME {
// FIXME rendering.builtInModel( "models/block/builtin/quartz_glass", new GlassModel() );
// FIXME }
// FIXME } )
// .build();
// .rendering( new BlockRenderingCustomizer()
// {
// @Override
// @OnlyIn( Dist.CLIENT)
// public void customize(IBlockRendering rendering, IItemRendering itemRendering )
// {
// rendering.builtInModel( "models/block/builtin/quartz_glass", new GlassModel() );
// }
// } )
.build();
// this.quartzVibrantGlass = deco.block( "quartz_vibrant_glass", BlockQuartzLamp::new )
// .addFeatures( AEFeature.DECORATIVE_LIGHTS, AEFeature.QUARTZ_GLASS )
// .useCustomItemModel()
@@ -19,62 +19,12 @@
package appeng.core.api.definitions;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.EntityEntryBuilder;
import net.minecraftforge.oredict.OreDictionary;
import appeng.api.definitions.IItemDefinition;
import appeng.api.definitions.IItems;
import appeng.api.util.AEColoredItemDefinition;
import appeng.bootstrap.FeatureFactory;
import appeng.bootstrap.components.IEntityRegistrationComponent;
import appeng.bootstrap.components.IOreDictComponent;
import appeng.client.render.crafting.ItemEncodedPatternRendering;
import appeng.core.CreativeTabFacade;
import appeng.core.features.AEFeature;
import appeng.debug.ToolDebugCard;
import appeng.debug.ToolEraser;
import appeng.debug.ToolMeteoritePlacer;
import appeng.debug.ToolReplicatorCard;
import appeng.entity.EntityGrowingCrystal;
import appeng.entity.EntityIds;
import appeng.fluids.items.BasicFluidStorageCell;
import appeng.fluids.items.FluidDummyItem;
import appeng.fluids.items.FluidDummyItemRendering;
import appeng.hooks.DispenserBlockTool;
import appeng.hooks.DispenserMatterCannon;
import appeng.items.materials.MaterialType;
import appeng.items.misc.ItemCrystalSeed;
import appeng.items.misc.ItemCrystalSeedRendering;
import appeng.items.misc.ItemEncodedPattern;
import appeng.items.misc.ItemPaintBall;
import appeng.items.misc.ItemPaintBallRendering;
import appeng.items.parts.FacadeRendering;
import appeng.items.parts.ItemFacade;
import appeng.items.storage.BasicItemStorageCell;
import appeng.items.storage.ItemCreativeStorageCell;
import appeng.items.storage.ItemSpatialStorageCell;
import appeng.items.storage.ItemViewCell;
import appeng.items.tools.ToolBiometricCard;
import appeng.items.tools.ToolBiometricCardRendering;
import appeng.items.tools.ToolMemoryCard;
import appeng.items.tools.ToolMemoryCardRendering;
import appeng.items.tools.ToolNetworkTool;
import appeng.items.tools.powered.ToolChargedStaff;
import appeng.items.tools.powered.ToolColorApplicator;
import appeng.items.tools.powered.ToolColorApplicatorRendering;
import appeng.items.tools.powered.ToolEntropyManipulator;
import appeng.items.tools.powered.ToolMatterCannon;
import appeng.items.tools.powered.ToolPortableCell;
import appeng.items.tools.powered.ToolWirelessTerminal;
import appeng.items.tools.quartz.ToolQuartzAxe;
import appeng.items.tools.quartz.ToolQuartzCuttingKnife;
import appeng.items.tools.quartz.ToolQuartzHoe;
import appeng.items.tools.quartz.ToolQuartzPickaxe;
import appeng.items.tools.quartz.ToolQuartzSpade;
import appeng.items.tools.quartz.ToolQuartzSword;
import appeng.items.tools.quartz.ToolQuartzWrench;
import appeng.items.tools.quartz.*;
/**
@@ -82,66 +32,67 @@ import appeng.items.tools.quartz.ToolQuartzWrench;
*/
public final class ApiItems implements IItems
{
private final IItemDefinition certusQuartzAxe;
private final IItemDefinition certusQuartzHoe;
private final IItemDefinition certusQuartzShovel;
private final IItemDefinition certusQuartzPick;
private final IItemDefinition certusQuartzSword;
private final IItemDefinition certusQuartzWrench;
private final IItemDefinition certusQuartzKnife;
// FIXME: Make final after porting
private IItemDefinition certusQuartzAxe;
private IItemDefinition certusQuartzHoe;
private IItemDefinition certusQuartzShovel;
private IItemDefinition certusQuartzPick;
private IItemDefinition certusQuartzSword;
private IItemDefinition certusQuartzWrench;
private IItemDefinition certusQuartzKnife;
private final IItemDefinition netherQuartzAxe;
private final IItemDefinition netherQuartzHoe;
private final IItemDefinition netherQuartzShovel;
private final IItemDefinition netherQuartzPick;
private final IItemDefinition netherQuartzSword;
private final IItemDefinition netherQuartzWrench;
private final IItemDefinition netherQuartzKnife;
private IItemDefinition netherQuartzAxe;
private IItemDefinition netherQuartzHoe;
private IItemDefinition netherQuartzShovel;
private IItemDefinition netherQuartzPick;
private IItemDefinition netherQuartzSword;
private IItemDefinition netherQuartzWrench;
private IItemDefinition netherQuartzKnife;
private final IItemDefinition entropyManipulator;
private final IItemDefinition wirelessTerminal;
private final IItemDefinition biometricCard;
private final IItemDefinition chargedStaff;
private final IItemDefinition massCannon;
private final IItemDefinition memoryCard;
private final IItemDefinition networkTool;
private final IItemDefinition portableCell;
private IItemDefinition entropyManipulator;
private IItemDefinition wirelessTerminal;
private IItemDefinition biometricCard;
private IItemDefinition chargedStaff;
private IItemDefinition massCannon;
private IItemDefinition memoryCard;
private IItemDefinition networkTool;
private IItemDefinition portableCell;
private final IItemDefinition cellCreative;
private final IItemDefinition viewCell;
private IItemDefinition cellCreative;
private IItemDefinition viewCell;
private final IItemDefinition cell1k;
private final IItemDefinition cell4k;
private final IItemDefinition cell16k;
private final IItemDefinition cell64k;
private IItemDefinition cell1k;
private IItemDefinition cell4k;
private IItemDefinition cell16k;
private IItemDefinition cell64k;
private final IItemDefinition fluidCell1k;
private final IItemDefinition fluidCell4k;
private final IItemDefinition fluidCell16k;
private final IItemDefinition fluidCell64k;
private IItemDefinition fluidCell1k;
private IItemDefinition fluidCell4k;
private IItemDefinition fluidCell16k;
private IItemDefinition fluidCell64k;
private final IItemDefinition spatialCell2;
private final IItemDefinition spatialCell16;
private final IItemDefinition spatialCell128;
private IItemDefinition spatialCell2;
private IItemDefinition spatialCell16;
private IItemDefinition spatialCell128;
private final IItemDefinition facade;
private final IItemDefinition crystalSeed;
private IItemDefinition facade;
private IItemDefinition crystalSeed;
// rv1
private final IItemDefinition encodedPattern;
private final IItemDefinition colorApplicator;
private IItemDefinition encodedPattern;
private IItemDefinition colorApplicator;
private final IItemDefinition paintBall;
private final AEColoredItemDefinition coloredPaintBall;
private final AEColoredItemDefinition coloredLumenPaintBall;
private IItemDefinition paintBall;
private AEColoredItemDefinition coloredPaintBall;
private AEColoredItemDefinition coloredLumenPaintBall;
// unsupported dev tools
private final IItemDefinition toolEraser;
private final IItemDefinition toolMeteoritePlacer;
private final IItemDefinition toolDebugCard;
private final IItemDefinition toolReplicatorCard;
private IItemDefinition toolEraser;
private IItemDefinition toolMeteoritePlacer;
private IItemDefinition toolDebugCard;
private IItemDefinition toolReplicatorCard;
private final IItemDefinition dummyFluidItem;
private IItemDefinition dummyFluidItem;
public ApiItems( FeatureFactory registry )
{
@@ -163,11 +114,11 @@ public final class ApiItems implements IItems
.build();
this.certusQuartzWrench = certusTools.item( "certus_quartz_wrench", ToolQuartzWrench::new )
.addFeatures( AEFeature.QUARTZ_WRENCH )
.bootstrap( item -> (IOreDictComponent) side -> OreDictionary.registerOre( "itemQuartzWrench", new ItemStack( item ) ) )
// FIXME .bootstrap( item -> (IOreDictComponent) side -> OreDictionary.registerOre( "itemQuartzWrench", new ItemStack( item ) ) )
.build();
this.certusQuartzKnife = certusTools.item( "certus_quartz_cutting_knife", () -> new ToolQuartzCuttingKnife( AEFeature.CERTUS_QUARTZ_TOOLS ) )
.addFeatures( AEFeature.QUARTZ_KNIFE )
.bootstrap( item -> (IOreDictComponent) side -> OreDictionary.registerOre( "itemQuartzKnife", new ItemStack( item ) ) )
// FIXME .bootstrap( item -> (IOreDictComponent) side -> OreDictionary.registerOre( "itemQuartzKnife", new ItemStack( item ) ) )
.build();
FeatureFactory netherTools = registry.features( AEFeature.NETHER_QUARTZ_TOOLS );
@@ -188,102 +139,102 @@ public final class ApiItems implements IItems
.build();
this.netherQuartzWrench = netherTools.item( "nether_quartz_wrench", ToolQuartzWrench::new )
.addFeatures( AEFeature.QUARTZ_WRENCH )
.bootstrap( item -> (IOreDictComponent) side -> OreDictionary.registerOre( "itemQuartzWrench", new ItemStack( item ) ) )
// FIXME .bootstrap( item -> (IOreDictComponent) side -> OreDictionary.registerOre( "itemQuartzWrench", new ItemStack( item ) ) )
.build();
this.netherQuartzKnife = netherTools.item( "nether_quartz_cutting_knife", () -> new ToolQuartzCuttingKnife( AEFeature.NETHER_QUARTZ_TOOLS ) )
.addFeatures( AEFeature.QUARTZ_KNIFE )
.bootstrap( item -> (IOreDictComponent) side -> OreDictionary.registerOre( "itemQuartzKnife", new ItemStack( item ) ) )
// FIXME .bootstrap( item -> (IOreDictComponent) side -> OreDictionary.registerOre( "itemQuartzKnife", new ItemStack( item ) ) )
.build();
FeatureFactory powerTools = registry.features( AEFeature.POWERED_TOOLS );
this.entropyManipulator = powerTools.item( "entropy_manipulator", ToolEntropyManipulator::new )
.addFeatures( AEFeature.ENTROPY_MANIPULATOR )
.dispenserBehavior( DispenserBlockTool::new )
.build();
this.wirelessTerminal = powerTools.item( "wireless_terminal", ToolWirelessTerminal::new ).addFeatures( AEFeature.WIRELESS_ACCESS_TERMINAL ).build();
this.chargedStaff = powerTools.item( "charged_staff", ToolChargedStaff::new ).addFeatures( AEFeature.CHARGED_STAFF ).build();
this.massCannon = powerTools.item( "matter_cannon", ToolMatterCannon::new )
.addFeatures( AEFeature.MATTER_CANNON )
.dispenserBehavior( DispenserMatterCannon::new )
.build();
this.portableCell = powerTools.item( "portable_cell", ToolPortableCell::new ).addFeatures( AEFeature.PORTABLE_CELL, AEFeature.STORAGE_CELLS ).build();
this.colorApplicator = powerTools.item( "color_applicator", ToolColorApplicator::new )
.addFeatures( AEFeature.COLOR_APPLICATOR )
.dispenserBehavior( DispenserBlockTool::new )
.rendering( new ToolColorApplicatorRendering() )
.build();
this.biometricCard = registry.item( "biometric_card", ToolBiometricCard::new )
.rendering( new ToolBiometricCardRendering() )
.features( AEFeature.SECURITY )
.build();
this.memoryCard = registry.item( "memory_card", ToolMemoryCard::new )
.rendering( new ToolMemoryCardRendering() )
.features( AEFeature.MEMORY_CARD )
.build();
this.networkTool = registry.item( "network_tool", ToolNetworkTool::new ).features( AEFeature.NETWORK_TOOL ).build();
this.cellCreative = registry.item( "creative_storage_cell", ItemCreativeStorageCell::new )
.features( AEFeature.STORAGE_CELLS, AEFeature.CREATIVE )
.build();
this.viewCell = registry.item( "view_cell", ItemViewCell::new ).features( AEFeature.VIEW_CELL ).build();
FeatureFactory storageCells = registry.features( AEFeature.STORAGE_CELLS );
this.cell1k = storageCells.item( "storage_cell_1k", () -> new BasicItemStorageCell( MaterialType.CELL1K_PART, 1 ) ).build();
this.cell4k = storageCells.item( "storage_cell_4k", () -> new BasicItemStorageCell( MaterialType.CELL4K_PART, 4 ) ).build();
this.cell16k = storageCells.item( "storage_cell_16k", () -> new BasicItemStorageCell( MaterialType.CELL16K_PART, 16 ) ).build();
this.cell64k = storageCells.item( "storage_cell_64k", () -> new BasicItemStorageCell( MaterialType.CELL64K_PART, 64 ) ).build();
this.fluidCell1k = storageCells.item( "fluid_storage_cell_1k", () -> new BasicFluidStorageCell( MaterialType.FLUID_CELL1K_PART, 1 ) ).build();
this.fluidCell4k = storageCells.item( "fluid_storage_cell_4k", () -> new BasicFluidStorageCell( MaterialType.FLUID_CELL4K_PART, 4 ) ).build();
this.fluidCell16k = storageCells.item( "fluid_storage_cell_16k", () -> new BasicFluidStorageCell( MaterialType.FLUID_CELL16K_PART, 16 ) ).build();
this.fluidCell64k = storageCells.item( "fluid_storage_cell_64k", () -> new BasicFluidStorageCell( MaterialType.FLUID_CELL64K_PART, 64 ) ).build();
FeatureFactory spatialCells = registry.features( AEFeature.SPATIAL_IO );
this.spatialCell2 = spatialCells.item( "spatial_storage_cell_2_cubed", () -> new ItemSpatialStorageCell( 2 ) ).build();
this.spatialCell16 = spatialCells.item( "spatial_storage_cell_16_cubed", () -> new ItemSpatialStorageCell( 16 ) ).build();
this.spatialCell128 = spatialCells.item( "spatial_storage_cell_128_cubed", () -> new ItemSpatialStorageCell( 128 ) ).build();
this.facade = registry.item( "facade", ItemFacade::new )
.features( AEFeature.FACADES )
.creativeTab( CreativeTabFacade.instance )
.rendering( new FacadeRendering() )
.build();
this.crystalSeed = registry.item( "crystal_seed", ItemCrystalSeed::new )
.features( AEFeature.CRYSTAL_SEEDS )
.rendering( new ItemCrystalSeedRendering() )
.bootstrap( item -> (IEntityRegistrationComponent) r ->
{
r.register( EntityEntryBuilder.create()
.entity( EntityGrowingCrystal.class )
.id( new ResourceLocation( "appliedenergistics2", EntityGrowingCrystal.class.getName() ),
EntityIds.get( EntityGrowingCrystal.class ) )
.name( EntityGrowingCrystal.class.getSimpleName() )
.tracker( 16, 4, true )
.build() );
} )
.build();
// rv1
this.encodedPattern = registry.item( "encoded_pattern", ItemEncodedPattern::new )
.features( AEFeature.PATTERNS )
.rendering( new ItemEncodedPatternRendering() )
.build();
this.paintBall = registry.item( "paint_ball", ItemPaintBall::new )
.features( AEFeature.PAINT_BALLS )
.rendering( new ItemPaintBallRendering() )
.build();
this.coloredPaintBall = registry.colored( this.paintBall, 0 );
this.coloredLumenPaintBall = registry.colored( this.paintBall, 20 );
FeatureFactory debugTools = registry.features( AEFeature.UNSUPPORTED_DEVELOPER_TOOLS, AEFeature.CREATIVE );
this.toolEraser = debugTools.item( "debug_eraser", ToolEraser::new ).build();
this.toolMeteoritePlacer = debugTools.item( "debug_meteorite_placer", ToolMeteoritePlacer::new ).build();
this.toolDebugCard = debugTools.item( "debug_card", ToolDebugCard::new ).build();
this.toolReplicatorCard = debugTools.item( "debug_replicator_card", ToolReplicatorCard::new ).build();
this.dummyFluidItem = registry.item( "dummy_fluid_item", FluidDummyItem::new ).rendering( new FluidDummyItemRendering() ).build();
// FeatureFactory powerTools = registry.features( AEFeature.POWERED_TOOLS );
// this.entropyManipulator = powerTools.item( "entropy_manipulator", ToolEntropyManipulator::new )
// .addFeatures( AEFeature.ENTROPY_MANIPULATOR )
// .dispenserBehavior( DispenserBlockTool::new )
// .build();
// this.wirelessTerminal = powerTools.item( "wireless_terminal", ToolWirelessTerminal::new ).addFeatures( AEFeature.WIRELESS_ACCESS_TERMINAL ).build();
// this.chargedStaff = powerTools.item( "charged_staff", ToolChargedStaff::new ).addFeatures( AEFeature.CHARGED_STAFF ).build();
// this.massCannon = powerTools.item( "matter_cannon", ToolMatterCannon::new )
// .addFeatures( AEFeature.MATTER_CANNON )
// .dispenserBehavior( DispenserMatterCannon::new )
// .build();
// this.portableCell = powerTools.item( "portable_cell", ToolPortableCell::new ).addFeatures( AEFeature.PORTABLE_CELL, AEFeature.STORAGE_CELLS ).build();
// this.colorApplicator = powerTools.item( "color_applicator", ToolColorApplicator::new )
// .addFeatures( AEFeature.COLOR_APPLICATOR )
// .dispenserBehavior( DispenserBlockTool::new )
// .rendering( new ToolColorApplicatorRendering() )
// .build();
//
// this.biometricCard = registry.item( "biometric_card", ToolBiometricCard::new )
// .rendering( new ToolBiometricCardRendering() )
// .features( AEFeature.SECURITY )
// .build();
// this.memoryCard = registry.item( "memory_card", ToolMemoryCard::new )
// .rendering( new ToolMemoryCardRendering() )
// .features( AEFeature.MEMORY_CARD )
// .build();
// this.networkTool = registry.item( "network_tool", ToolNetworkTool::new ).features( AEFeature.NETWORK_TOOL ).build();
//
// this.cellCreative = registry.item( "creative_storage_cell", ItemCreativeStorageCell::new )
// .features( AEFeature.STORAGE_CELLS, AEFeature.CREATIVE )
// .build();
// this.viewCell = registry.item( "view_cell", ItemViewCell::new ).features( AEFeature.VIEW_CELL ).build();
//
// FeatureFactory storageCells = registry.features( AEFeature.STORAGE_CELLS );
// this.cell1k = storageCells.item( "storage_cell_1k", () -> new BasicItemStorageCell( MaterialType.CELL1K_PART, 1 ) ).build();
// this.cell4k = storageCells.item( "storage_cell_4k", () -> new BasicItemStorageCell( MaterialType.CELL4K_PART, 4 ) ).build();
// this.cell16k = storageCells.item( "storage_cell_16k", () -> new BasicItemStorageCell( MaterialType.CELL16K_PART, 16 ) ).build();
// this.cell64k = storageCells.item( "storage_cell_64k", () -> new BasicItemStorageCell( MaterialType.CELL64K_PART, 64 ) ).build();
//
// this.fluidCell1k = storageCells.item( "fluid_storage_cell_1k", () -> new BasicFluidStorageCell( MaterialType.FLUID_CELL1K_PART, 1 ) ).build();
// this.fluidCell4k = storageCells.item( "fluid_storage_cell_4k", () -> new BasicFluidStorageCell( MaterialType.FLUID_CELL4K_PART, 4 ) ).build();
// this.fluidCell16k = storageCells.item( "fluid_storage_cell_16k", () -> new BasicFluidStorageCell( MaterialType.FLUID_CELL16K_PART, 16 ) ).build();
// this.fluidCell64k = storageCells.item( "fluid_storage_cell_64k", () -> new BasicFluidStorageCell( MaterialType.FLUID_CELL64K_PART, 64 ) ).build();
//
// FeatureFactory spatialCells = registry.features( AEFeature.SPATIAL_IO );
// this.spatialCell2 = spatialCells.item( "spatial_storage_cell_2_cubed", () -> new ItemSpatialStorageCell( 2 ) ).build();
// this.spatialCell16 = spatialCells.item( "spatial_storage_cell_16_cubed", () -> new ItemSpatialStorageCell( 16 ) ).build();
// this.spatialCell128 = spatialCells.item( "spatial_storage_cell_128_cubed", () -> new ItemSpatialStorageCell( 128 ) ).build();
//
// this.facade = registry.item( "facade", ItemFacade::new )
// .features( AEFeature.FACADES )
// .creativeTab( CreativeTabFacade.instance )
// .rendering( new FacadeRendering() )
// .build();
// this.crystalSeed = registry.item( "crystal_seed", ItemCrystalSeed::new )
// .features( AEFeature.CRYSTAL_SEEDS )
// .rendering( new ItemCrystalSeedRendering() )
// .bootstrap( item -> (IEntityRegistrationComponent) r ->
// {
// r.register( EntityEntryBuilder.create()
// .entity( EntityGrowingCrystal.class )
// .id( new ResourceLocation( "appliedenergistics2", EntityGrowingCrystal.class.getName() ),
// EntityIds.get( EntityGrowingCrystal.class ) )
// .name( EntityGrowingCrystal.class.getSimpleName() )
// .tracker( 16, 4, true )
// .build() );
// } )
// .build();
//
// // rv1
// this.encodedPattern = registry.item( "encoded_pattern", ItemEncodedPattern::new )
// .features( AEFeature.PATTERNS )
// .rendering( new ItemEncodedPatternRendering() )
// .build();
//
// this.paintBall = registry.item( "paint_ball", ItemPaintBall::new )
// .features( AEFeature.PAINT_BALLS )
// .rendering( new ItemPaintBallRendering() )
// .build();
// this.coloredPaintBall = registry.colored( this.paintBall, 0 );
// this.coloredLumenPaintBall = registry.colored( this.paintBall, 20 );
//
// FeatureFactory debugTools = registry.features( AEFeature.UNSUPPORTED_DEVELOPER_TOOLS, AEFeature.CREATIVE );
// this.toolEraser = debugTools.item( "debug_eraser", ToolEraser::new ).build();
// this.toolMeteoritePlacer = debugTools.item( "debug_meteorite_placer", ToolMeteoritePlacer::new ).build();
// this.toolDebugCard = debugTools.item( "debug_card", ToolDebugCard::new ).build();
// this.toolReplicatorCard = debugTools.item( "debug_replicator_card", ToolReplicatorCard::new ).build();
//
// this.dummyFluidItem = registry.item( "dummy_fluid_item", FluidDummyItem::new ).rendering( new FluidDummyItemRendering() ).build();
}
@Override
@@ -35,39 +35,40 @@ import net.minecraftforge.fml.RegistryObject;
public class BlockDefinition extends ItemDefinition implements IBlockDefinition
{
private final RegistryObject<Block> block;
private final Block block;
private final BlockItem blockItem;
public BlockDefinition( String registryName, Block block, BlockItem item )
{
super( registryName, item );
this.block = null; // FIXME // Optional.ofNullable( block );
this.block = block;
this.blockItem = item;
}
@Override
public final RegistryObject<Block> maybeBlock()
public final Block block()
{
return this.block;
}
@Override
public RegistryObject<BlockItem> maybeBlockItem()
public BlockItem blockItem()
{
// FIXME
return null;
// return this.block.map( BlockItem::new );
return blockItem;
}
@Override
public final Optional<ItemStack> maybeStack( int stackSize )
public final ItemStack stack( int stackSize )
{
Preconditions.checkArgument( stackSize > 0 );
return this.block.map( b -> new ItemStack( b, stackSize ) );
return new ItemStack(block, stackSize);
}
@Override
public final boolean isSameAs( final IBlockReader world, final BlockPos pos )
{
return this.block.isPresent() && world.getBlockState( pos ).getBlock() == this.block.get();
return world.getBlockState( pos ).getBlock() == this.block;
}
}
@@ -36,13 +36,13 @@ import appeng.util.Platform;
public class ItemDefinition implements IItemDefinition
{
private final String identifier;
private final Optional<Item> item;
private final Item item;
public ItemDefinition( String registryName, Item item )
{
Preconditions.checkArgument( !Strings.isNullOrEmpty( registryName ), "registryName" );
this.identifier = registryName;
this.item = Optional.ofNullable( item );
this.item = item;
}
@Nonnull
@@ -53,27 +53,28 @@ public class ItemDefinition implements IItemDefinition
}
@Override
public final Optional<Item> maybeItem()
public final Item item()
{
return this.item;
}
@Override
public Optional<ItemStack> maybeStack( final int stackSize )
public ItemStack stack( final int stackSize )
{
return this.item.map( item -> new ItemStack( item, stackSize ) );
return new ItemStack( item, stackSize );
}
@Override
public boolean isEnabled()
{
return this.item.isPresent();
// FIXME sadly we can only set this after registration
return true;
}
@Override
public final boolean isSameAs( final ItemStack comparableStack )
{
return this.isEnabled() && Platform.itemComparisons().isEqualItemType( comparableStack, this.maybeStack( 1 ).get() );
return Platform.itemComparisons().isEqualItemType( comparableStack, this.stack( 1 ) );
}
}
@@ -56,7 +56,7 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry
public void configure()
{
final IDefinitions definitions = AEApi.instance().definitions();
final IDefinitions definitions = Api.INSTANCE.definitions();
final IBlocks blocks = definitions.blocks();
final IParts parts = definitions.parts();
@@ -102,7 +102,7 @@ public final class WirelessRegistry implements IWirelessTermRegistry
}
final long parsedKey = Long.parseLong( unparsedKey );
final ILocatable securityStation = AEApi.instance().registries().locatable().getLocatableBy( parsedKey );
final ILocatable securityStation = Api.INSTANCE.registries().locatable().getLocatableBy( parsedKey );
if( securityStation == null )
{
player.sendMessage( PlayerMessages.StationCanNotBeLocated.get() );
@@ -24,7 +24,7 @@ public class BasicItemCellGuiHandler implements ICellGuiHandler
@Override
public <T extends IAEStack<T>> boolean isHandlerFor( final IStorageChannel<T> channel )
{
return channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class );
return channel == Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class );
}
@Override
@@ -43,7 +43,7 @@ public final class CreativeCellHandler implements ICellHandler
@Override
public ICellInventoryHandler getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel channel )
{
if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) && !is.isEmpty() && is
if( channel == Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ) && !is.isEmpty() && is
.getItem() instanceof ItemCreativeStorageCell )
{
return CreativeCellInventory.getCell( is );
@@ -318,7 +318,7 @@ public enum GuiBridge implements IGuiHandler
return ( (IGuiItem) it.getItem() ).getGuiObject( it, w, new BlockPos( x, y, z ) );
}
final IWirelessTermHandler wh = AEApi.instance().registries().wireless().getWirelessTerminalHandler( it );
final IWirelessTermHandler wh = Api.INSTANCE.registries().wireless().getWirelessTerminalHandler( it );
if( wh != null )
{
return new WirelessTerminalGuiObject( wh, it, player, w, x, y, z );
@@ -113,7 +113,7 @@ public class PacketClick extends AppEngPacket
public void serverPacketData( final INetworkInfo manager, final AppEngPacket packet, final PlayerEntity player )
{
final ItemStack is = player.inventory.getCurrentItem();
final IItems items = AEApi.instance().definitions().items();
final IItems items = Api.INSTANCE.definitions().items();
final IComparableDefinition maybeMemoryCard = items.memoryCard();
final IComparableDefinition maybeColorApplicator = items.colorApplicator();
final BlockPos pos = new BlockPos( this.x, this.y, this.z );
@@ -139,7 +139,7 @@ public class PacketJEIRecipe extends AppEngPacket
if( inv != null && this.recipe != null && security != null )
{
final IMEMonitor<IAEItemStack> storage = inv.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
final IMEMonitor<IAEItemStack> storage = inv.getInventory( Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ) );
final IPartitionList<IAEItemStack> filter = ItemViewCell.createFilter( cct.getViewCells() );
for( int x = 0; x < craftMatrix.getSlots(); x++ )
@@ -88,7 +88,7 @@ public class PacketPatternSlot extends AppEngPacket
this.writeItem( slotItem, data );
for( int x = 0; x < 9; x++ )
{
this.pattern[x] = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( pat.getStackInSlot( x ) );
this.pattern[x] = Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ).createStack( pat.getStackInSlot( x ) );
this.writeItem( this.pattern[x], data );
}