Major Refactoring of Bootstrap Code (#75)

- Refactored boostrap code:
  * Completely reworked item/block/tile registration.
  * Fixed server side startup.
  * Fixed server side startup.
  * More documentation.
  * More heavy cleanup
  * More cleanups.
  * Major refactoring of state mapping and fixes a lot of other issue related to item rendering.
  * Fixes sky chest item models (no item TESR).
  * Only use CachingRotatingBakedModel for tile entities automatically.
  Fix default rotation of quartz pillar for item model.
  * Used method reference instead of lambda for ItemMeshDefinition for multiparts.
  * Removed unnecessary IHasSpecialItemModel
  * Removed unused IconReg class.
  * Updated resource pack version.
This commit is contained in:
shartte
2016-08-22 14:25:10 +02:00
committed by Sebastian Hartte
parent 66df324ef0
commit 6f2bbfab4c
172 changed files with 2289 additions and 2863 deletions
@@ -19,16 +19,23 @@
package appeng.core.api.definitions;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDispenser;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.oredict.OreDictionary;
import appeng.api.definitions.IBlockDefinition;
import appeng.api.definitions.IBlocks;
import appeng.api.definitions.ITileDefinition;
import appeng.block.AEBaseItemBlockChargeable;
import appeng.block.crafting.BlockCraftingMonitor;
import appeng.block.crafting.BlockCraftingStorage;
import appeng.block.crafting.BlockCraftingUnit;
import appeng.block.crafting.BlockCraftingUnit.CraftingUnitType;
import appeng.block.crafting.BlockMolecularAssembler;
import appeng.block.crafting.ItemCraftingStorage;
import appeng.block.grindstone.BlockCrank;
import appeng.block.grindstone.BlockGrinder;
import appeng.block.misc.BlockCellWorkbench;
@@ -50,7 +57,10 @@ import appeng.block.networking.BlockCreativeEnergyCell;
import appeng.block.networking.BlockDenseEnergyCell;
import appeng.block.networking.BlockEnergyAcceptor;
import appeng.block.networking.BlockEnergyCell;
import appeng.block.networking.BlockEnergyCellRendering;
import appeng.block.networking.BlockWireless;
import appeng.block.networking.CableBusColor;
import appeng.block.networking.CableModelCustomizer;
import appeng.block.qnb.BlockQuantumLinkChamber;
import appeng.block.qnb.BlockQuantumRing;
import appeng.block.spatial.BlockMatrixFrame;
@@ -61,6 +71,13 @@ import appeng.block.storage.BlockDrive;
import appeng.block.storage.BlockIOPort;
import appeng.block.storage.BlockSkyChest;
import appeng.block.storage.BlockSkyChest.SkyChestType;
import appeng.block.storage.SkyChestRenderingCustomizer;
import appeng.bootstrap.BlockRenderingCustomizer;
import appeng.bootstrap.FeatureFactory;
import appeng.bootstrap.IBlockRendering;
import appeng.bootstrap.IItemRendering;
import appeng.core.AppEng;
import appeng.core.features.AEFeature;
import appeng.debug.BlockChunkloader;
import appeng.debug.BlockCubeGenerator;
import appeng.debug.BlockItemGen;
@@ -76,6 +93,7 @@ import appeng.decorative.solid.BlockQuartzPillar;
import appeng.decorative.solid.BlockSkyStone;
import appeng.decorative.solid.BlockSkyStone.SkystoneType;
import appeng.decorative.stair.BlockStairCommon;
import appeng.hooks.DispenserBehaviorTinyTNT;
/**
@@ -159,70 +177,138 @@ public final class ApiBlocks implements IBlocks
private final IBlockDefinition phantomNode;
private final IBlockDefinition cubeGenerator;
public ApiBlocks( final DefinitionConstructor constructor )
public ApiBlocks( FeatureFactory registry )
{
// this.quartzOre = new BlockDefinition( "ore.quartz", new OreQuartz() );
this.quartzOre = constructor.registerBlockDefinition( new BlockQuartzOre() );
this.quartzOreCharged = constructor.registerBlockDefinition( new BlockChargedQuartzOre() );
this.matrixFrame = constructor.registerBlockDefinition( new BlockMatrixFrame() );
this.quartz = constructor.registerBlockDefinition( new BlockQuartz() );
this.quartzPillar = constructor.registerBlockDefinition( new BlockQuartzPillar() );
this.quartzChiseled = constructor.registerBlockDefinition( new BlockChiseledQuartz() );
this.quartzGlass = constructor.registerBlockDefinition( new BlockQuartzGlass() );
this.quartzVibrantGlass = constructor.registerBlockDefinition( new BlockQuartzLamp() );
this.quartzTorch = constructor.registerBlockDefinition( new BlockQuartzTorch() );
this.fluix = constructor.registerBlockDefinition( new BlockFluix() );
this.skyStone_stone = constructor.registerBlockDefinition( new BlockSkyStone( SkystoneType.STONE ) );
this.skyStone_block = constructor.registerBlockDefinition( new BlockSkyStone( SkystoneType.BLOCK ) );
this.skyStone_brick = constructor.registerBlockDefinition( new BlockSkyStone( SkystoneType.BRICK ) );
this.skyStone_smallbrick = constructor.registerBlockDefinition( new BlockSkyStone( SkystoneType.SMALL_BRICK ) );
this.skyChest = constructor.registerBlockDefinition( new BlockSkyChest( SkyChestType.STONE ) );
this.skyChestBlock = constructor.registerBlockDefinition( new BlockSkyChest( SkyChestType.BLOCK ) );
this.skyCompass = constructor.registerBlockDefinition( new BlockSkyCompass() );
this.grindStone = constructor.registerTileDefinition( new BlockGrinder() );
this.crankHandle = constructor.registerTileDefinition( new BlockCrank() );
this.inscriber = constructor.registerTileDefinition( new BlockInscriber() );
this.wireless = constructor.registerTileDefinition( new BlockWireless() );
this.charger = constructor.registerTileDefinition( new BlockCharger() );
this.tinyTNT = constructor.registerBlockDefinition( new BlockTinyTNT() );
this.security = constructor.registerTileDefinition( new BlockSecurity() );
this.quantumRing = constructor.registerTileDefinition( new BlockQuantumRing() );
this.quantumLink = constructor.registerTileDefinition( new BlockQuantumLinkChamber() );
this.spatialPylon = constructor.registerTileDefinition( new BlockSpatialPylon() );
this.spatialIOPort = constructor.registerTileDefinition( new BlockSpatialIOPort() );
this.multiPart = constructor.registerTileDefinition( new BlockCableBus() );
this.controller = constructor.registerTileDefinition( new BlockController() );
this.drive = constructor.registerTileDefinition( new BlockDrive() );
this.chest = constructor.registerTileDefinition( new BlockChest() );
this.iface = constructor.registerTileDefinition( new BlockInterface() );
this.cellWorkbench = constructor.registerTileDefinition( new BlockCellWorkbench() );
this.iOPort = constructor.registerTileDefinition( new BlockIOPort() );
this.condenser = constructor.registerTileDefinition( new BlockCondenser() );
this.energyAcceptor = constructor.registerTileDefinition( new BlockEnergyAcceptor() );
this.vibrationChamber = constructor.registerTileDefinition( new BlockVibrationChamber() );
this.quartzGrowthAccelerator = constructor.registerTileDefinition( new BlockQuartzGrowthAccelerator() );
this.energyCell = constructor.registerTileDefinition( new BlockEnergyCell() );
this.energyCellDense = constructor.registerTileDefinition( new BlockDenseEnergyCell() );
this.energyCellCreative = constructor.registerTileDefinition( new BlockCreativeEnergyCell() );
this.craftingUnit = constructor.registerTileDefinition( new BlockCraftingUnit( CraftingUnitType.UNIT ) );
this.craftingAccelerator = constructor.registerTileDefinition( new BlockCraftingUnit( CraftingUnitType.ACCELERATOR ) );
this.craftingStorage1k = constructor.registerTileDefinition( new BlockCraftingStorage( CraftingUnitType.STORAGE_1K ) );
this.craftingStorage4k = constructor.registerTileDefinition( new BlockCraftingStorage( CraftingUnitType.STORAGE_4K ) );
this.craftingStorage16k = constructor.registerTileDefinition( new BlockCraftingStorage( CraftingUnitType.STORAGE_16K ) );
this.craftingStorage64k = constructor.registerTileDefinition( new BlockCraftingStorage( CraftingUnitType.STORAGE_64K ) );
this.craftingMonitor = constructor.registerTileDefinition( new BlockCraftingMonitor() );
this.molecularAssembler = constructor.registerTileDefinition( new BlockMolecularAssembler() );
this.lightDetector = constructor.registerTileDefinition( new BlockLightDetector() );
this.paint = constructor.registerTileDefinition( new BlockPaint() );
this.quartzOre = registry.block( "quartz_ore", BlockQuartzOre::new )
.postInit( ( block, item ) ->
{
OreDictionary.registerOre( "oreCertusQuartz", new ItemStack( block ) );
} )
.build();
this.quartzOreCharged = registry.block( "charged_quartz_ore", BlockChargedQuartzOre::new )
.postInit( ( block, item ) ->
{
OreDictionary.registerOre( "oreCertusQuartz", new ItemStack( block ) );
} )
.build();
this.matrixFrame = registry.block( "matrix_frame", BlockMatrixFrame::new ).features( AEFeature.SpatialIO ).build();
this.skyStoneStair = this.makeStairs( constructor, this.skyStone_stone, "skystone.stone" );
this.skyStoneBlockStair = this.makeStairs( constructor, this.skyStone_block, "skystone.block" );
this.skyStoneBrickStair = this.makeStairs( constructor, this.skyStone_brick, "skystone.brick" );
this.skyStoneSmallBrickStair = this.makeStairs( constructor, this.skyStone_smallbrick, "skystone.brick.small" );
this.fluixStair = this.makeStairs( constructor, this.fluix, "fluix" );
this.quartzStair = this.makeStairs( constructor, this.quartz, "quartz.certus" );
this.chiseledQuartzStair = this.makeStairs( constructor, this.quartzChiseled, "quartz.certus.chiseled" );
this.quartzPillarStair = this.makeStairs( constructor, this.quartzPillar, "quartz.certus.pillar" );
FeatureFactory deco = registry.features( AEFeature.DecorativeQuartzBlocks );
this.quartz = deco.block( "quartz", BlockQuartz::new ).build();
this.quartzPillar = deco.block( "quartz_pillar", BlockQuartzPillar::new ).build();
this.quartzChiseled = deco.block( "chiseled_quartz", BlockChiseledQuartz::new ).build();
this.quartzGlass = deco.block( "quartz_glass", BlockQuartzGlass::new ).build();
this.quartzVibrantGlass = deco.block( "quartz_lamp", BlockQuartzLamp::new ).addFeatures( AEFeature.DecorativeLights ).build();
this.quartzTorch = registry.block( "quartz_torch", BlockQuartzTorch::new ).features( AEFeature.DecorativeLights ).build();
this.fluix = deco.block( "fluix", BlockFluix::new ).build();
this.skyStone_stone = deco.block( "sky_stone_block_stone", () -> new BlockSkyStone( SkystoneType.STONE ) ).build();
this.skyStone_block = deco.block( "sky_stone_block_block", () -> new BlockSkyStone( SkystoneType.BLOCK ) ).build();
this.skyStone_brick = deco.block( "sky_stone_block_brick", () -> new BlockSkyStone( SkystoneType.BRICK ) ).build();
this.skyStone_smallbrick = deco.block( "sky_stone_block_small_brick", () -> new BlockSkyStone( SkystoneType.SMALL_BRICK ) ).build();
this.skyChest = registry.block( "sky_chest_stone", () -> new BlockSkyChest( SkyChestType.STONE ) )
.features( AEFeature.SkyStoneChests )
.rendering( new SkyChestRenderingCustomizer( SkyChestType.STONE ) )
.build();
this.skyChestBlock = registry.block( "sky_chest_block", () -> new BlockSkyChest( SkyChestType.BLOCK ) )
.features( AEFeature.SkyStoneChests )
.rendering( new SkyChestRenderingCustomizer( SkyChestType.BLOCK ) )
.build();
this.skyCompass = registry.block( "sky_compass", BlockSkyCompass::new ).features( AEFeature.MeteoriteCompass ).build();
this.grindStone = registry.block( "grinder", BlockGrinder::new ).features( AEFeature.GrindStone ).build();
this.crankHandle = registry.block( "crank", BlockCrank::new ).features( AEFeature.GrindStone ).build();
this.inscriber = registry.block( "inscriber", BlockInscriber::new ).features( AEFeature.Inscriber ).build();
this.wireless = registry.block( "wireless", BlockWireless::new ).features( AEFeature.WirelessAccessTerminal ).build();
this.charger = registry.block( "charger", BlockCharger::new )
.rendering( new BlockRenderingCustomizer()
{
@Override
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
{
rendering.tesr( BlockCharger.createTesr() );
}
} )
.build();
this.tinyTNT = registry.block( "tiny_tnt", BlockTinyTNT::new ).features( AEFeature.TinyTNT )
.postInit( ( block, item ) ->
{
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject( item, new DispenserBehaviorTinyTNT() );
} )
.build();
this.security = registry.block( "security", BlockSecurity::new ).features( AEFeature.Security ).build();
this.quantumRing = registry.block( "quantum_ring", BlockQuantumRing::new ).features( AEFeature.QuantumNetworkBridge ).build();
this.quantumLink = registry.block( "quantum_link", BlockQuantumLinkChamber::new ).features( AEFeature.QuantumNetworkBridge ).build();
this.spatialPylon = registry.block( "spatial_pylon", BlockSpatialPylon::new ).features( AEFeature.SpatialIO ).build();
this.spatialIOPort = registry.block( "spatial_ioport", BlockSpatialIOPort::new ).features( AEFeature.SpatialIO ).build();
this.controller = registry.block( "controller", BlockController::new ).features( AEFeature.Channels ).build();
this.drive = registry.block( "drive", BlockDrive::new ).features( AEFeature.StorageCells, AEFeature.MEDrive ).build();
this.chest = registry.block( "chest", BlockChest::new ).features( AEFeature.StorageCells, AEFeature.MEChest ).build();
this.iface = registry.block( "interface", BlockInterface::new ).build();
this.cellWorkbench = registry.block( "cell_work_bench", BlockCellWorkbench::new ).features( AEFeature.StorageCells ).build();
this.iOPort = registry.block( "ioport", BlockIOPort::new ).features( AEFeature.StorageCells, AEFeature.IOPort ).build();
this.condenser = registry.block( "condenser", BlockCondenser::new ).build();
this.energyAcceptor = registry.block( "energy_acceptor", BlockEnergyAcceptor::new ).build();
this.vibrationChamber = registry.block( "vibration_chamber", BlockVibrationChamber::new ).features( AEFeature.PowerGen ).build();
this.quartzGrowthAccelerator = registry.block( "quartz_growth_accelerator", BlockQuartzGrowthAccelerator::new ).build();
this.energyCell = registry.block( "energy_cell", BlockEnergyCell::new )
.item( AEBaseItemBlockChargeable::new )
.rendering( new BlockEnergyCellRendering( new ResourceLocation( AppEng.MOD_ID, "energy_cell" ) ) )
.build();
this.energyCellDense = registry.block( "dense_energy_cell", BlockDenseEnergyCell::new )
.features( AEFeature.DenseEnergyCells )
.item( AEBaseItemBlockChargeable::new )
.rendering( new BlockEnergyCellRendering( new ResourceLocation( AppEng.MOD_ID, "dense_energy_cell" ) ) )
.build();
this.energyCellCreative = registry.block( "creative_energy_cell", BlockCreativeEnergyCell::new )
.features( AEFeature.Creative )
.item( AEBaseItemBlockChargeable::new )
.build();
FeatureFactory crafting = registry.features( AEFeature.CraftingCPU );
this.craftingUnit = crafting.block( "crafting_unit", () -> new BlockCraftingUnit( CraftingUnitType.UNIT ) ).build();
this.craftingAccelerator = crafting.block( "crafting_accelerator", () -> new BlockCraftingUnit( CraftingUnitType.ACCELERATOR ) ).build();
this.craftingStorage1k = crafting.block( "crafting_storage_1k", () -> new BlockCraftingStorage( CraftingUnitType.STORAGE_1K ) )
.item( ItemCraftingStorage::new )
.build();
this.craftingStorage4k = crafting.block( "crafting_storage_4k", () -> new BlockCraftingStorage( CraftingUnitType.STORAGE_4K ) )
.item( ItemCraftingStorage::new )
.build();
this.craftingStorage16k = crafting.block( "crafting_storage_16k", () -> new BlockCraftingStorage( CraftingUnitType.STORAGE_16K ) )
.item( ItemCraftingStorage::new )
.build();
this.craftingStorage64k = crafting.block( "crafting_storage_64k", () -> new BlockCraftingStorage( CraftingUnitType.STORAGE_64K ) )
.item( ItemCraftingStorage::new )
.build();
this.craftingMonitor = crafting.block( "crafting_monitor", BlockCraftingMonitor::new ).build();
this.molecularAssembler = registry.block( "molecular_assembler", BlockMolecularAssembler::new ).features( AEFeature.MolecularAssembler ).build();
this.lightDetector = registry.block( "light_detector", BlockLightDetector::new ).features( AEFeature.LightDetector ).build();
this.paint = registry.block( "paint", BlockPaint::new ).features( AEFeature.PaintBalls ).build();
this.skyStoneStair = makeStairs( "stair_skystone_stone", registry, this.skyStone() );
this.skyStoneBlockStair = makeStairs( "stair_skystone_block", registry, this.skyStoneBlock() );
this.skyStoneBrickStair = makeStairs( "stair_skystone_brick", registry, this.skyStoneBrick() );
this.skyStoneSmallBrickStair = makeStairs( "stair_skystone_brick_small", registry, this.skyStoneSmallBrick() );
this.fluixStair = makeStairs( "stair_fluix", registry, this.fluix() );
this.quartzStair = makeStairs( "stair_quartz_certus", registry, this.quartz() );
this.chiseledQuartzStair = makeStairs( "stair_quartz_certus_chiseled", registry, this.quartzChiseled() );
this.quartzPillarStair = makeStairs( "stair_quartz_certus_pillar", registry, this.quartzPillar() );
this.multiPart = registry.block( "multipart_block", BlockCableBus::new )
.rendering( new BlockRenderingCustomizer()
{
@Override
@SideOnly( Side.CLIENT )
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
{
rendering.modelCustomizer( new CableModelCustomizer()::customizeModel )
.blockColor( new CableBusColor() );
}
} )
.build();
// TODO Re-Add Slabs...
/*
@@ -239,25 +325,22 @@ public final class ApiBlocks implements IBlocks
* this.quartzSlab = constructor.registerBlockDefinition( new AEBaseSlabBlock( quartzBlock,
* EnumSet.of(AEFeature.DecorativeQuartzBlocks), false, "QuartzSlabBlock" ) );
* this.chiseledQuartzSlab = constructor.registerBlockDefinition( new AEBaseSlabBlock( chiseledQuartz,
* EnumSet.of(AEFeature.DecorativeQuartzBlocks), false, "ChiseledQuartzSlabBlock" ) );;
* EnumSet.of(AEFeature.DecorativeQuartzBlocks), false, "ChiseledQuartzSlabBlock" ) );
* this.quartzPillarSlab = constructor.registerBlockDefinition( new AEBaseSlabBlock( quartzPillar,
* EnumSet.of(AEFeature.DecorativeQuartzBlocks), false, "QuartzPillarSlabBlock" ) )
*/
this.itemGen = constructor.registerBlockDefinition( new BlockItemGen() );
this.chunkLoader = constructor.registerBlockDefinition( new BlockChunkloader() );
this.phantomNode = constructor.registerBlockDefinition( new BlockPhantomNode() );
this.cubeGenerator = constructor.registerBlockDefinition( new BlockCubeGenerator() );
this.itemGen = registry.block( "debug_item_gen", BlockItemGen::new ).features( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ).build();
this.chunkLoader = registry.block( "debug_chunk_loader", BlockChunkloader::new ).features( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ).build();
this.phantomNode = registry.block( "debug_phantom_node", BlockPhantomNode::new ).features( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ).build();
this.cubeGenerator = registry.block( "debug_cube_gen", BlockCubeGenerator::new ).features( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ).build();
}
private IBlockDefinition makeStairs( final DefinitionConstructor constructor, final IBlockDefinition definition, final String name )
private static IBlockDefinition makeStairs( String registryName, FeatureFactory registry, IBlockDefinition block )
{
for( final Block block : definition.maybeBlock().asSet() )
{
return constructor.registerBlockDefinition( new BlockStairCommon( block, name ) );
}
return null;
return registry.block( registryName, () -> new BlockStairCommon( block.maybeBlock().get(), block.identifier() ) )
.features( AEFeature.DecorativeQuartzBlocks )
.build();
}
@Override
@@ -22,6 +22,8 @@ package appeng.core.api.definitions;
import appeng.api.definitions.IItemDefinition;
import appeng.api.definitions.IItems;
import appeng.api.util.AEColoredItemDefinition;
import appeng.bootstrap.FeatureFactory;
import appeng.core.CreativeTabFacade;
import appeng.core.features.AEFeature;
import appeng.debug.ToolDebugCard;
import appeng.debug.ToolEraser;
@@ -29,8 +31,10 @@ import appeng.debug.ToolMeteoritePlacer;
import appeng.debug.ToolReplicatorCard;
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.ItemFacade;
import appeng.items.storage.ItemBasicStorageCell;
import appeng.items.storage.ItemCreativeStorageCell;
@@ -113,60 +117,75 @@ public final class ApiItems implements IItems
private final IItemDefinition toolDebugCard;
private final IItemDefinition toolReplicatorCard;
public ApiItems( final DefinitionConstructor constructor )
public ApiItems( FeatureFactory registry )
{
this.certusQuartzAxe = constructor.registerItemDefinition( new ToolQuartzAxe( AEFeature.CertusQuartzTools ) );
this.certusQuartzHoe = constructor.registerItemDefinition( new ToolQuartzHoe( AEFeature.CertusQuartzTools ) );
this.certusQuartzShovel = constructor.registerItemDefinition( new ToolQuartzSpade( AEFeature.CertusQuartzTools ) );
this.certusQuartzPick = constructor.registerItemDefinition( new ToolQuartzPickaxe( AEFeature.CertusQuartzTools ) );
this.certusQuartzSword = constructor.registerItemDefinition( new ToolQuartzSword( AEFeature.CertusQuartzTools ) );
this.certusQuartzWrench = constructor.registerItemDefinition( new ToolQuartzWrench( AEFeature.CertusQuartzTools ) );
this.certusQuartzKnife = constructor.registerItemDefinition( new ToolQuartzCuttingKnife( AEFeature.CertusQuartzTools ) );
FeatureFactory certusTools = registry.features( AEFeature.CertusQuartzTools );
this.certusQuartzAxe = certusTools.item( "certus_quartz_axe", () -> new ToolQuartzAxe( AEFeature.CertusQuartzTools ) ).addFeatures( AEFeature.QuartzAxe ).build();
this.certusQuartzHoe = certusTools.item( "certus_quartz_hoe", () -> new ToolQuartzHoe( AEFeature.CertusQuartzTools ) ).addFeatures( AEFeature.QuartzHoe ).build();
this.certusQuartzShovel = certusTools.item( "certus_quartz_spade", () -> new ToolQuartzSpade( AEFeature.CertusQuartzTools ) ).addFeatures( AEFeature.QuartzSpade ).build();
this.certusQuartzPick = certusTools.item( "certus_quartz_pickaxe", () -> new ToolQuartzPickaxe( AEFeature.CertusQuartzTools ) ).addFeatures( AEFeature.QuartzPickaxe ).build();
this.certusQuartzSword = certusTools.item( "certus_quartz_sword", () -> new ToolQuartzSword( AEFeature.CertusQuartzTools ) ).addFeatures( AEFeature.QuartzSword ).build();
this.certusQuartzWrench = certusTools.item( "certus_quartz_wrench", ToolQuartzWrench::new ).addFeatures( AEFeature.QuartzWrench ).build();
this.certusQuartzKnife = certusTools.item( "certus_quartz_cutting_knife", () -> new ToolQuartzCuttingKnife( AEFeature.CertusQuartzTools ) ).addFeatures( AEFeature.QuartzKnife ).build();
this.netherQuartzAxe = constructor.registerItemDefinition( new ToolQuartzAxe( AEFeature.NetherQuartzTools ) );
this.netherQuartzHoe = constructor.registerItemDefinition( new ToolQuartzHoe( AEFeature.NetherQuartzTools ) );
this.netherQuartzShovel = constructor.registerItemDefinition( new ToolQuartzSpade( AEFeature.NetherQuartzTools ) );
this.netherQuartzPick = constructor.registerItemDefinition( new ToolQuartzPickaxe( AEFeature.NetherQuartzTools ) );
this.netherQuartzSword = constructor.registerItemDefinition( new ToolQuartzSword( AEFeature.NetherQuartzTools ) );
this.netherQuartzWrench = constructor.registerItemDefinition( new ToolQuartzWrench( AEFeature.NetherQuartzTools ) );
this.netherQuartzKnife = constructor.registerItemDefinition( new ToolQuartzCuttingKnife( AEFeature.NetherQuartzTools ) );
FeatureFactory netherTools = registry.features( AEFeature.NetherQuartzTools );
this.netherQuartzAxe = netherTools.item( "nether_quartz_axe", () -> new ToolQuartzAxe( AEFeature.NetherQuartzTools ) ).addFeatures( AEFeature.QuartzAxe ).build();
this.netherQuartzHoe = netherTools.item( "nether_quartz_hoe", () -> new ToolQuartzHoe( AEFeature.NetherQuartzTools ) ).addFeatures( AEFeature.QuartzHoe ).build();
this.netherQuartzShovel = netherTools.item( "nether_quartz_spade", () -> new ToolQuartzSpade( AEFeature.NetherQuartzTools ) ).addFeatures( AEFeature.QuartzSpade ).build();
this.netherQuartzPick = netherTools.item( "nether_quartz_pickaxe", () -> new ToolQuartzPickaxe( AEFeature.NetherQuartzTools ) ).addFeatures( AEFeature.QuartzPickaxe ).build();
this.netherQuartzSword = netherTools.item( "nether_quartz_sword", () -> new ToolQuartzSword( AEFeature.NetherQuartzTools ) ).addFeatures( AEFeature.QuartzSword ).build();
this.netherQuartzWrench = netherTools.item( "nether_quartz_wrench", ToolQuartzWrench::new ).addFeatures( AEFeature.QuartzWrench ).build();
this.netherQuartzKnife = netherTools.item( "nether_quartz_cutting_knife", () -> new ToolQuartzCuttingKnife( AEFeature.NetherQuartzTools ) ).addFeatures( AEFeature.QuartzKnife ).build();
this.entropyManipulator = constructor.registerItemDefinition( new ToolEntropyManipulator() );
this.wirelessTerminal = constructor.registerItemDefinition( new ToolWirelessTerminal() );
this.biometricCard = constructor.registerItemDefinition( new ToolBiometricCard() );
this.chargedStaff = constructor.registerItemDefinition( new ToolChargedStaff() );
this.massCannon = constructor.registerItemDefinition( new ToolMassCannon() );
this.memoryCard = constructor.registerItemDefinition( new ToolMemoryCard() );
this.networkTool = constructor.registerItemDefinition( new ToolNetworkTool() );
this.portableCell = constructor.registerItemDefinition( new ToolPortableCell() );
FeatureFactory powerTools = registry.features( AEFeature.PoweredTools );
this.entropyManipulator = powerTools.item( "entropy_manipulator", ToolEntropyManipulator::new ).addFeatures( AEFeature.EntropyManipulator ).build();
this.wirelessTerminal = powerTools.item( "wireless_terminal", ToolWirelessTerminal::new ).addFeatures( AEFeature.WirelessAccessTerminal ).build();
this.chargedStaff = powerTools.item( "charged_staff", ToolChargedStaff::new ).addFeatures( AEFeature.ChargedStaff ).build();
this.massCannon = powerTools.item( "mass_cannon", ToolMassCannon::new ).addFeatures( AEFeature.MatterCannon ).build();
this.portableCell = powerTools.item( "portable_cell", ToolPortableCell::new ).addFeatures( AEFeature.PortableCell, AEFeature.StorageCells ).build();
this.colorApplicator = powerTools.item( "color_applicator", ToolColorApplicator::new ).addFeatures( AEFeature.ColorApplicator ).build();
this.cellCreative = constructor.registerItemDefinition( new ItemCreativeStorageCell() );
this.viewCell = constructor.registerItemDefinition( new ItemViewCell() );
this.biometricCard = registry.item( "biometric_card", ToolBiometricCard::new ).features( AEFeature.Security ).build();
this.memoryCard = registry.item( "memory_card", ToolMemoryCard::new ).build();
this.networkTool = registry.item( "network_tool", ToolNetworkTool::new ).features( AEFeature.NetworkTool ).build();
this.cell1k = constructor.registerItemDefinition( new ItemBasicStorageCell( MaterialType.Cell1kPart, 1 ) );
this.cell4k = constructor.registerItemDefinition( new ItemBasicStorageCell( MaterialType.Cell4kPart, 4 ) );
this.cell16k = constructor.registerItemDefinition( new ItemBasicStorageCell( MaterialType.Cell16kPart, 16 ) );
this.cell64k = constructor.registerItemDefinition( new ItemBasicStorageCell( MaterialType.Cell64kPart, 64 ) );
this.cellCreative = registry.item( "creative_storage_cell", ItemCreativeStorageCell::new ).features( AEFeature.StorageCells, AEFeature.Creative ).build();
this.viewCell = registry.item( "view_cell", ItemViewCell::new ).build();
this.spatialCell2 = constructor.registerItemDefinition( new ItemSpatialStorageCell( 2 ) );
this.spatialCell16 = constructor.registerItemDefinition( new ItemSpatialStorageCell( 16 ) );
this.spatialCell128 = constructor.registerItemDefinition( new ItemSpatialStorageCell( 128 ) );
FeatureFactory storageCells = registry.features( AEFeature.StorageCells );
this.cell1k = storageCells.item( "basic_storage_cell_1k", () -> new ItemBasicStorageCell( MaterialType.Cell1kPart, 1 ) ).build();
this.cell4k = storageCells.item( "basic_storage_cell_4k", () -> new ItemBasicStorageCell( MaterialType.Cell4kPart, 4 ) ).build();
this.cell16k = storageCells.item( "basic_storage_cell_16k", () -> new ItemBasicStorageCell( MaterialType.Cell16kPart, 16 ) ).build();
this.cell64k = storageCells.item( "basic_storage_cell_64k", () -> new ItemBasicStorageCell( MaterialType.Cell64kPart, 64 ) ).build();
this.facade = constructor.registerItemDefinition( new ItemFacade() );
this.crystalSeed = constructor.registerItemDefinition( new ItemCrystalSeed() );
FeatureFactory spatialCells = registry.features( AEFeature.SpatialIO );
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 )
.build();
this.crystalSeed = registry.item( "crystal_seed", ItemCrystalSeed::new )
.rendering( new ItemCrystalSeedRendering() )
.build();
// rv1
this.encodedPattern = constructor.registerItemDefinition( new ItemEncodedPattern() );
this.colorApplicator = constructor.registerItemDefinition( new ToolColorApplicator() );
this.encodedPattern = registry.item( "encoded_pattern", ItemEncodedPattern::new ).features( AEFeature.Patterns ).build();
this.paintBall = constructor.registerItemDefinition( new ItemPaintBall() );
this.coloredPaintBall = constructor.constructColoredDefinition( this.paintBall, 0 );
this.coloredLumenPaintBall = constructor.constructColoredDefinition( this.paintBall, 20 );
this.paintBall = registry.item( "paint_ball", ItemPaintBall::new )
.features( AEFeature.PaintBalls )
.rendering( new ItemPaintBallRendering() )
.build();
this.coloredPaintBall = registry.colored( this.paintBall, 0 );
this.coloredLumenPaintBall = registry.colored( this.paintBall, 20 );
this.toolEraser = constructor.registerItemDefinition( new ToolEraser() );
this.toolMeteoritePlacer = constructor.registerItemDefinition( new ToolMeteoritePlacer() );
this.toolDebugCard = constructor.registerItemDefinition( new ToolDebugCard() );
this.toolReplicatorCard = constructor.registerItemDefinition( new ToolReplicatorCard() );
FeatureFactory debugTools = registry.features( AEFeature.UnsupportedDeveloperTools, 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();
}
@Override
@@ -19,11 +19,20 @@
package appeng.core.api.definitions;
import java.util.Arrays;
import java.util.stream.Collectors;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.definitions.IItemDefinition;
import appeng.api.definitions.IMaterials;
import appeng.bootstrap.FeatureFactory;
import appeng.bootstrap.IItemRendering;
import appeng.bootstrap.ItemRenderingCustomizer;
import appeng.core.features.DamagedItemDefinition;
import appeng.items.materials.MaterialType;
import appeng.items.materials.ItemMultiItem;
import appeng.items.materials.MaterialType;
/**
@@ -103,10 +112,24 @@ public final class ApiMaterials implements IMaterials
private final IItemDefinition qESingularity;
private final IItemDefinition blankPattern;
public ApiMaterials( final DefinitionConstructor constructor )
public ApiMaterials( FeatureFactory registry )
{
final ItemMultiItem materials = new ItemMultiItem();
constructor.registerItemDefinition( materials );
registry.item( "multi_material", () -> materials )
.rendering( new ItemRenderingCustomizer()
{
@Override
@SideOnly( Side.CLIENT )
public void customize( IItemRendering rendering )
{
rendering.meshDefinition( is -> materials.getTypeByStack( is ).getModel() );
// Register a resource location for every material type
rendering.variants( Arrays.stream( MaterialType.values() )
.map( MaterialType::getModel )
.collect( Collectors.toList() ) );
}
} )
.build();
this.cell2SpatialPart = new DamagedItemDefinition( "material.cell.spatial.2", materials.createMaterial( MaterialType.Cell2SpatialPart ) );
this.cell16SpatialPart = new DamagedItemDefinition( "material.cell.spatial.16", materials.createMaterial( MaterialType.Cell16SpatialPart ) );
@@ -23,9 +23,14 @@ import appeng.api.definitions.IItemDefinition;
import appeng.api.definitions.IParts;
import appeng.api.exceptions.MissingDefinition;
import appeng.api.parts.IPartHelper;
import appeng.api.util.AEColor;
import appeng.api.util.AEColoredItemDefinition;
import appeng.bootstrap.FeatureFactory;
import appeng.core.features.ColoredItemDefinition;
import appeng.core.features.DamagedItemDefinition;
import appeng.core.features.ItemStackSrc;
import appeng.items.parts.ItemMultiPart;
import appeng.items.parts.ItemMultipartRendering;
import appeng.items.parts.PartType;
@@ -73,15 +78,17 @@ public final class ApiParts implements IParts
private final IItemDefinition storageMonitor;
private final IItemDefinition conversionMonitor;
public ApiParts( final DefinitionConstructor constructor, final IPartHelper partHelper )
public ApiParts( FeatureFactory registry, IPartHelper partHelper )
{
final ItemMultiPart itemMultiPart = new ItemMultiPart( partHelper );
constructor.registerItemDefinition( itemMultiPart );
registry.item( "multipart", () -> itemMultiPart )
.rendering( new ItemMultipartRendering( itemMultiPart ) )
.build();
this.cableSmart = constructor.constructColoredDefinition( itemMultiPart, PartType.CableSmart );
this.cableCovered = constructor.constructColoredDefinition( itemMultiPart, PartType.CableCovered );
this.cableGlass = constructor.constructColoredDefinition( itemMultiPart, PartType.CableGlass );
this.cableDense = constructor.constructColoredDefinition( itemMultiPart, PartType.CableDense );
this.cableSmart = constructColoredDefinition( itemMultiPart, PartType.CableSmart );
this.cableCovered = constructColoredDefinition( itemMultiPart, PartType.CableCovered );
this.cableGlass = constructColoredDefinition( itemMultiPart, PartType.CableGlass );
this.cableDense = constructColoredDefinition( itemMultiPart, PartType.CableDense );
// this.lumenCableSmart = Optional.absent(); // has yet to be implemented, no PartType defined for it yet
// this.lumenCableCovered = Optional.absent(); // has yet to be implemented, no PartType defined for it yet
// this.lumenCableGlass = Optional.absent(); // has yet to be implemented, no PartType defined for it yet
@@ -120,6 +127,20 @@ public final class ApiParts implements IParts
this.conversionMonitor = new DamagedItemDefinition( "part.monitor.conversion", itemMultiPart.createPart( PartType.ConversionMonitor ) );
}
private static AEColoredItemDefinition constructColoredDefinition( final ItemMultiPart target, final PartType type )
{
final ColoredItemDefinition definition = new ColoredItemDefinition();
for( final AEColor color : AEColor.values() )
{
final ItemStackSrc multiPartSource = target.createPart( type, color );
definition.add( color, multiPartSource );
}
return definition;
}
@Override
public AEColoredItemDefinition cableSmart()
{
@@ -1,120 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, 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.core.api.definitions;
import net.minecraft.item.Item;
import appeng.api.definitions.IBlockDefinition;
import appeng.api.definitions.IItemDefinition;
import appeng.api.definitions.ITileDefinition;
import appeng.api.util.AEColor;
import appeng.api.util.AEColoredItemDefinition;
import appeng.core.FeatureHandlerRegistry;
import appeng.core.FeatureRegistry;
import appeng.core.features.ActivityState;
import appeng.core.features.ColoredItemDefinition;
import appeng.core.features.IAEFeature;
import appeng.core.features.IFeatureHandler;
import appeng.core.features.ItemStackSrc;
import appeng.items.parts.ItemMultiPart;
import appeng.items.parts.PartType;
public class DefinitionConstructor
{
private final FeatureRegistry features;
private final FeatureHandlerRegistry handlers;
public DefinitionConstructor( final FeatureRegistry features, final FeatureHandlerRegistry handlers )
{
this.features = features;
this.handlers = handlers;
}
final ITileDefinition registerTileDefinition( final IAEFeature feature )
{
final IBlockDefinition definition = this.registerBlockDefinition( feature );
if( definition instanceof ITileDefinition )
{
return( (ITileDefinition) definition );
}
throw new IllegalStateException( "No tile definition for " + feature );
}
final IBlockDefinition registerBlockDefinition( final IAEFeature feature )
{
final IItemDefinition definition = this.registerItemDefinition( feature );
if( definition instanceof IBlockDefinition )
{
return( (IBlockDefinition) definition );
}
throw new IllegalStateException( "No block definition for " + feature );
}
final IItemDefinition registerItemDefinition( final IAEFeature feature )
{
final IFeatureHandler handler = feature.handler();
if( handler.isFeatureAvailable() )
{
this.handlers.addFeatureHandler( handler );
this.features.addFeature( feature );
}
final IItemDefinition definition = handler.getDefinition();
return definition;
}
final AEColoredItemDefinition constructColoredDefinition( final IItemDefinition target, final int offset )
{
final ColoredItemDefinition definition = new ColoredItemDefinition();
for( final Item targetItem : target.maybeItem().asSet() )
{
for( final AEColor color : AEColor.VALID_COLORS )
{
final ActivityState state = ActivityState.from( target.isEnabled() );
definition.add( color, new ItemStackSrc( targetItem, offset + color.ordinal(), state ) );
}
}
return definition;
}
final AEColoredItemDefinition constructColoredDefinition( final ItemMultiPart target, final PartType type )
{
final ColoredItemDefinition definition = new ColoredItemDefinition();
for( final AEColor color : AEColor.values() )
{
final ItemStackSrc multiPartSource = target.createPart( type, color );
definition.add( color, multiPartSource );
}
return definition;
}
}