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:
committed by
Sebastian Hartte
parent
66df324ef0
commit
6f2bbfab4c
@@ -21,6 +21,7 @@ package appeng.core;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
@@ -302,6 +303,11 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
||||
return this.featureFlags.contains( f );
|
||||
}
|
||||
|
||||
public boolean areFeaturesEnabled( Collection<AEFeature> features )
|
||||
{
|
||||
return this.featureFlags.containsAll( features );
|
||||
}
|
||||
|
||||
public double wireless_getDrainRate( final double range )
|
||||
{
|
||||
return this.WirelessTerminalDrainMultiplier * range;
|
||||
|
||||
@@ -21,11 +21,11 @@ package appeng.core;
|
||||
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.parts.IPartHelper;
|
||||
import appeng.bootstrap.FeatureFactory;
|
||||
import appeng.core.api.definitions.ApiBlocks;
|
||||
import appeng.core.api.definitions.ApiItems;
|
||||
import appeng.core.api.definitions.ApiMaterials;
|
||||
import appeng.core.api.definitions.ApiParts;
|
||||
import appeng.core.api.definitions.DefinitionConstructor;
|
||||
|
||||
|
||||
/**
|
||||
@@ -37,31 +37,22 @@ public final class ApiDefinitions implements IDefinitions
|
||||
private final ApiItems items;
|
||||
private final ApiMaterials materials;
|
||||
private final ApiParts parts;
|
||||
private final FeatureHandlerRegistry handlers;
|
||||
private final FeatureRegistry features;
|
||||
|
||||
private final FeatureFactory registry = new FeatureFactory();
|
||||
|
||||
public ApiDefinitions( final IPartHelper partHelper )
|
||||
{
|
||||
this.features = new FeatureRegistry();
|
||||
this.handlers = new FeatureHandlerRegistry();
|
||||
|
||||
final DefinitionConstructor constructor = new DefinitionConstructor( this.features, this.handlers );
|
||||
|
||||
this.blocks = new ApiBlocks( constructor );
|
||||
this.items = new ApiItems( constructor );
|
||||
this.materials = new ApiMaterials( constructor );
|
||||
this.parts = new ApiParts( constructor, partHelper );
|
||||
this.blocks = new ApiBlocks( registry );
|
||||
this.items = new ApiItems( registry );
|
||||
this.materials = new ApiMaterials( registry );
|
||||
this.parts = new ApiParts( registry, partHelper );
|
||||
}
|
||||
|
||||
FeatureHandlerRegistry getFeatureHandlerRegistry()
|
||||
public FeatureFactory getRegistry()
|
||||
{
|
||||
return this.handlers;
|
||||
return registry;
|
||||
}
|
||||
|
||||
public FeatureRegistry getFeatureRegistry()
|
||||
{
|
||||
return this.features;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiBlocks blocks()
|
||||
|
||||
@@ -196,7 +196,6 @@ public final class AppEng
|
||||
|
||||
this.registration.initialize( event, this.recipeDirectory, this.customRecipeConfig );
|
||||
IntegrationRegistry.INSTANCE.init();
|
||||
CommonHelper.proxy.init();
|
||||
|
||||
AELog.info( "Initialization ( ended after " + start.elapsed( TimeUnit.MILLISECONDS ) + "ms )" );
|
||||
}
|
||||
|
||||
@@ -1,41 +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;
|
||||
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import appeng.core.features.IFeatureHandler;
|
||||
|
||||
|
||||
public final class FeatureHandlerRegistry
|
||||
{
|
||||
private final Set<IFeatureHandler> registry = new LinkedHashSet<IFeatureHandler>();
|
||||
|
||||
public void addFeatureHandler( final IFeatureHandler feature )
|
||||
{
|
||||
this.registry.add( feature );
|
||||
}
|
||||
|
||||
Set<IFeatureHandler> getRegisteredFeatureHandlers()
|
||||
{
|
||||
return this.registry;
|
||||
}
|
||||
}
|
||||
@@ -1,41 +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;
|
||||
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import appeng.core.features.IAEFeature;
|
||||
|
||||
|
||||
public final class FeatureRegistry
|
||||
{
|
||||
private final Set<IAEFeature> registry = new LinkedHashSet<IAEFeature>();
|
||||
|
||||
public void addFeature( final IAEFeature feature )
|
||||
{
|
||||
this.registry.add( feature );
|
||||
}
|
||||
|
||||
public Set<IAEFeature> getRegisteredFeatures()
|
||||
{
|
||||
return this.registry;
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,6 @@ package appeng.core;
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
@@ -32,7 +31,6 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
@@ -42,11 +40,8 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.oredict.RecipeSorter;
|
||||
import net.minecraftforge.oredict.RecipeSorter.Category;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.IAppEngApi;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.definitions.IBlocks;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IItems;
|
||||
import appeng.api.definitions.IParts;
|
||||
import appeng.api.features.IRecipeHandlerRegistry;
|
||||
@@ -65,8 +60,6 @@ import appeng.api.networking.ticking.ITickManager;
|
||||
import appeng.api.parts.IPartHelper;
|
||||
import appeng.block.networking.BlockCableBus;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.IAEFeature;
|
||||
import appeng.core.features.IFeatureHandler;
|
||||
import appeng.core.features.registries.P2PTunnelRegistry;
|
||||
import appeng.core.features.registries.entries.BasicCellHandler;
|
||||
import appeng.core.features.registries.entries.CreativeCellHandler;
|
||||
@@ -150,18 +143,11 @@ public final class Registration
|
||||
|
||||
MinecraftForge.EVENT_BUS.register( OreDictionaryHandler.INSTANCE );
|
||||
|
||||
final ApiDefinitions definitions = api.definitions();
|
||||
ApiDefinitions definitions = api.definitions();
|
||||
|
||||
// Register all detected handlers and features (items, blocks) in pre-init
|
||||
for( final IFeatureHandler handler : definitions.getFeatureHandlerRegistry().getRegisteredFeatureHandlers() )
|
||||
{
|
||||
handler.register( event.getSide() );
|
||||
}
|
||||
definitions.getRegistry().getBootstrapComponents().forEach( b -> b.preInitialize( event.getSide() ) );
|
||||
|
||||
for( final IAEFeature feature : definitions.getFeatureRegistry().getRegisteredFeatures() )
|
||||
{
|
||||
feature.postInit();
|
||||
}
|
||||
}
|
||||
|
||||
private void registerSpatial( final boolean force )
|
||||
@@ -247,10 +233,13 @@ public final class Registration
|
||||
Preconditions.checkArgument( !recipeDirectory.isFile() );
|
||||
Preconditions.checkNotNull( customRecipeConfig );
|
||||
|
||||
final IAppEngApi api = AEApi.instance();
|
||||
final Api api = Api.INSTANCE;
|
||||
final IPartHelper partHelper = api.partHelper();
|
||||
final IRegistryContainer registries = api.registries();
|
||||
|
||||
ApiDefinitions definitions = api.definitions();
|
||||
definitions.getRegistry().getBootstrapComponents().forEach( b -> b.initialize( event.getSide() ) );
|
||||
|
||||
// Perform ore camouflage!
|
||||
ItemMultiItem.instance.makeUnique();
|
||||
|
||||
@@ -338,9 +327,9 @@ public final class Registration
|
||||
{
|
||||
this.registerSpatial( true );
|
||||
|
||||
final IAppEngApi api = AEApi.instance();
|
||||
final Api api = Api.INSTANCE;
|
||||
final IRegistryContainer registries = api.registries();
|
||||
final IDefinitions definitions = api.definitions();
|
||||
ApiDefinitions definitions = api.definitions();
|
||||
final IParts parts = definitions.parts();
|
||||
final IBlocks blocks = definitions.blocks();
|
||||
final IItems items = definitions.items();
|
||||
@@ -358,6 +347,8 @@ public final class Registration
|
||||
( (BlockCableBus) block ).setupTile();
|
||||
}
|
||||
|
||||
definitions.getRegistry().getBootstrapComponents().forEach( b -> b.postInitialize( event.getSide() ) );
|
||||
|
||||
// Interface
|
||||
Upgrades.CRAFTING.registerItem( parts.iface(), 1 );
|
||||
Upgrades.CRAFTING.registerItem( blocks.iface(), 1 );
|
||||
@@ -447,7 +438,7 @@ public final class Registration
|
||||
|
||||
final IMovableRegistry mr = registries.movable();
|
||||
|
||||
/**
|
||||
/*
|
||||
* You can't move bed rock.
|
||||
*/
|
||||
mr.blacklistBlock( net.minecraft.init.Blocks.BEDROCK );
|
||||
@@ -475,12 +466,12 @@ public final class Registration
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityNote.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityHopper.class );
|
||||
|
||||
/**
|
||||
/*
|
||||
* Whitelist AE2
|
||||
*/
|
||||
mr.whiteListTileEntity( AEBaseTile.class );
|
||||
|
||||
/**
|
||||
/*
|
||||
* world gen
|
||||
*/
|
||||
for( final WorldGenType type : WorldGenType.values() )
|
||||
@@ -500,7 +491,7 @@ public final class Registration
|
||||
registries.worldgen().enableWorldGenForDimension( WorldGenType.Meteorites, dimension );
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* initial recipe bake, if ore dictionary changes after this it re-bakes.
|
||||
*/
|
||||
OreDictionaryHandler.INSTANCE.bakeRecipes();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -1,151 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.ItemModelMesher;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.resources.IReloadableResourceManager;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.block.IHasSpecialItemModel;
|
||||
import appeng.client.render.model.AEIgnoringStateMapper;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.CreativeTab;
|
||||
|
||||
|
||||
public final class AEBlockFeatureHandler implements IFeatureHandler
|
||||
{
|
||||
private final Block featured;
|
||||
private final FeatureNameExtractor extractor;
|
||||
private final boolean enabled;
|
||||
private final BlockDefinition definition;
|
||||
|
||||
private ResourceLocation registryName;
|
||||
|
||||
public AEBlockFeatureHandler( final EnumSet<AEFeature> features, final Block featured, final Optional<String> subName )
|
||||
{
|
||||
final ActivityState state = new FeaturedActiveChecker( features ).getActivityState();
|
||||
|
||||
this.featured = featured;
|
||||
this.extractor = new FeatureNameExtractor( featured.getClass(), subName );
|
||||
this.enabled = state == ActivityState.Enabled;
|
||||
// TODO use real identifier
|
||||
this.definition = new BlockDefinition( featured.getClass().getSimpleName(), featured, state );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFeatureAvailable()
|
||||
{
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockDefinition getDefinition()
|
||||
{
|
||||
return this.definition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register( final Side side )
|
||||
{
|
||||
if( this.enabled )
|
||||
{
|
||||
String name = this.extractor.get();
|
||||
if( Item.REGISTRY.containsKey( new ResourceLocation( AppEng.MOD_ID, name ) ) )
|
||||
{
|
||||
name += "_block";
|
||||
}
|
||||
this.featured.setCreativeTab( CreativeTab.instance );
|
||||
this.featured.setUnlocalizedName( "appliedenergistics2." + name );
|
||||
|
||||
registryName = new ResourceLocation( AppEng.MOD_ID, name );
|
||||
GameRegistry.register( this.featured.setRegistryName( registryName ) );
|
||||
|
||||
// register the block/item conversion...
|
||||
if( this.definition.maybeItem().isPresent() )
|
||||
{
|
||||
GameRegistry.register( this.definition.maybeItem().get().setRegistryName( registryName ) );
|
||||
|
||||
if( side == Side.CLIENT )
|
||||
{
|
||||
ModelBakery.registerItemVariants( this.definition.maybeItem().get(), registryName );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerModel()
|
||||
{
|
||||
ItemModelMesher itemModelMesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
|
||||
Item item = this.definition.maybeItem().get();
|
||||
|
||||
// Retrieve a custom item mesh definition, if the block defines one
|
||||
ItemMeshDefinition itemMeshDefinition = null;
|
||||
if( featured instanceof AEBaseBlock )
|
||||
{
|
||||
itemMeshDefinition = ( (AEBaseBlock) featured ).getItemMeshDefinition();
|
||||
}
|
||||
|
||||
if ( itemMeshDefinition != null )
|
||||
{
|
||||
// This block has a custom item mesh definition, so register it instead of the resource location
|
||||
itemModelMesher.register( item, itemMeshDefinition );
|
||||
}
|
||||
else if( !featured.getBlockState().getProperties().isEmpty() || featured instanceof IHasSpecialItemModel )
|
||||
{
|
||||
itemModelMesher.register( item, 0, new ModelResourceLocation( registryName, "inventory" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
itemModelMesher.register( item, 0, new ModelResourceLocation( registryName, "normal" ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerStateMapper()
|
||||
{
|
||||
AEIgnoringStateMapper mapper = new AEIgnoringStateMapper( registryName );
|
||||
ModelLoader.setCustomStateMapper( this.featured, mapper );
|
||||
( (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager() ).registerReloadListener( mapper );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCustomModelOverride( IRegistry<ModelResourceLocation, IBakedModel> modelRegistry )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.color.IBlockColor;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import appeng.api.client.BakingPipeline;
|
||||
import appeng.api.definitions.ITileDefinition;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.block.networking.BlockCableBus;
|
||||
import appeng.client.render.model.pipeline.BakingPipelineBakedModel;
|
||||
import appeng.client.render.model.pipeline.FacingQuadRotator;
|
||||
import appeng.client.render.model.pipeline.Merge;
|
||||
import appeng.client.render.model.pipeline.TintIndexModifier;
|
||||
import appeng.client.render.model.pipeline.TypeTransformer;
|
||||
import appeng.client.render.model.pipeline.cable.CableAndConnections;
|
||||
import appeng.client.render.model.pipeline.cable.Facades;
|
||||
import appeng.client.render.model.pipeline.cable.Parts;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.CreativeTab;
|
||||
import appeng.parts.CableBusContainer;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public final class AECableBusFeatureHandler implements IFeatureHandler
|
||||
{
|
||||
private final AEBaseTileBlock featured;
|
||||
private final FeatureNameExtractor extractor;
|
||||
private final boolean enabled;
|
||||
private final TileDefinition definition;
|
||||
|
||||
private ResourceLocation registryName;
|
||||
|
||||
public AECableBusFeatureHandler( final EnumSet<AEFeature> features, final BlockCableBus featured, final Optional<String> subName )
|
||||
{
|
||||
final ActivityState state = new FeaturedActiveChecker( features ).getActivityState();
|
||||
|
||||
this.featured = featured;
|
||||
this.extractor = new FeatureNameExtractor( featured.getClass(), subName );
|
||||
this.enabled = state == ActivityState.Enabled;
|
||||
this.definition = new TileDefinition( featured.getClass().getSimpleName(), featured, state );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFeatureAvailable()
|
||||
{
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITileDefinition getDefinition()
|
||||
{
|
||||
return this.definition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registration of the {@link TileEntity} will actually be handled by {@link BlockCableBus#setupTile()}.
|
||||
*/
|
||||
@Override
|
||||
public void register( final Side side )
|
||||
{
|
||||
if( this.enabled )
|
||||
{
|
||||
final String name = this.extractor.get();
|
||||
this.featured.setCreativeTab( CreativeTab.instance );
|
||||
this.featured.setUnlocalizedName( "appliedenergistics2." + name );
|
||||
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
CommonHelper.proxy.bindTileEntitySpecialRenderer( this.featured.getTileEntityClass(), this.featured );
|
||||
}
|
||||
|
||||
registryName = new ResourceLocation( AppEng.MOD_ID, name );
|
||||
|
||||
// Bypass the forge magic with null to register our own itemblock later.
|
||||
GameRegistry.register( this.featured.setRegistryName( registryName ) );
|
||||
GameRegistry.register( this.definition.maybeItem().get().setRegistryName( registryName ) );
|
||||
|
||||
if( side == Side.CLIENT )
|
||||
{
|
||||
ModelBakery.registerItemVariants( this.definition.maybeItem().get(), registryName );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerModel()
|
||||
{
|
||||
Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler( new CableBusColor(), this.featured );
|
||||
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register( this.definition.maybeItem().get(), 0, new ModelResourceLocation( registryName, "normal" ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerStateMapper()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCustomModelOverride( IRegistry<ModelResourceLocation, IBakedModel> modelRegistry )
|
||||
{
|
||||
final BakingPipeline rotatingPipeline = new BakingPipeline( TypeTransformer.quads2vecs, new FacingQuadRotator(), TypeTransformer.vecs2quads );
|
||||
final TintIndexModifier tintIndexModifier = new TintIndexModifier( tint -> tint );
|
||||
final BakingPipeline tintIndexFixPipeline = new BakingPipeline( TypeTransformer.quads2vecs, tintIndexModifier, TypeTransformer.vecs2quads );
|
||||
Set<ModelResourceLocation> keys = Sets.newHashSet( modelRegistry.getKeys() );
|
||||
for( ModelResourceLocation model : keys )
|
||||
{
|
||||
if( model.getResourceDomain().equals( registryName.getResourceDomain() ) && model.getResourcePath().equals( registryName.getResourcePath() ) )
|
||||
{
|
||||
modelRegistry.putObject( model, new BakingPipelineBakedModel( modelRegistry.getObject( model ), new Merge( new CableAndConnections( rotatingPipeline, tintIndexModifier, tintIndexFixPipeline ), new Facades( rotatingPipeline, tintIndexModifier, tintIndexFixPipeline ), new Parts( rotatingPipeline, tintIndexModifier, tintIndexFixPipeline ) ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class CableBusColor implements IBlockColor
|
||||
{
|
||||
|
||||
@Override
|
||||
public int colorMultiplier( IBlockState state, IBlockAccess worldIn, BlockPos pos, int color )
|
||||
{
|
||||
AEPartLocation side = AEPartLocation.fromOrdinal( ( color >> 2 ) & 7 );
|
||||
CableBusContainer bus = ( (IExtendedBlockState) state ).getValue( BlockCableBus.cableBus );
|
||||
switch( color & 3 )
|
||||
{
|
||||
case 0:
|
||||
return bus.getGridNode( side ) != null && bus.getGridNode( side ).isActive() ? 0xffffff : 0;
|
||||
case 1:
|
||||
return bus.getColor().blackVariant;
|
||||
case 2:
|
||||
return bus.getColor().mediumVariant;
|
||||
case 3:
|
||||
return bus.getColor().whiteVariant;
|
||||
default:
|
||||
return color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,172 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.ItemModelMesher;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.client.resources.IReloadableResourceManager;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import appeng.api.definitions.ITileDefinition;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.block.IHasSpecialItemModel;
|
||||
import appeng.client.render.model.AEIgnoringStateMapper;
|
||||
import appeng.client.render.model.CachingRotatingBakedModel;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.CreativeTab;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public final class AETileBlockFeatureHandler implements IFeatureHandler
|
||||
{
|
||||
private final AEBaseTileBlock featured;
|
||||
private final FeatureNameExtractor extractor;
|
||||
private final boolean enabled;
|
||||
private final TileDefinition definition;
|
||||
|
||||
private ResourceLocation registryName;
|
||||
|
||||
public AETileBlockFeatureHandler( final EnumSet<AEFeature> features, final AEBaseTileBlock featured, final Optional<String> subName )
|
||||
{
|
||||
final ActivityState state = new FeaturedActiveChecker( features ).getActivityState();
|
||||
|
||||
this.featured = featured;
|
||||
this.extractor = new FeatureNameExtractor( featured.getClass(), subName );
|
||||
this.enabled = state == ActivityState.Enabled;
|
||||
this.definition = new TileDefinition( featured.getClass().getSimpleName(), featured, state );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFeatureAvailable()
|
||||
{
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITileDefinition getDefinition()
|
||||
{
|
||||
return this.definition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register( final Side side )
|
||||
{
|
||||
if( this.enabled )
|
||||
{
|
||||
String name = this.extractor.get();
|
||||
if( Item.REGISTRY.containsKey( new ResourceLocation( AppEng.MOD_ID, name ) ) )
|
||||
{
|
||||
name += "_block";
|
||||
}
|
||||
this.featured.setCreativeTab( CreativeTab.instance );
|
||||
this.featured.setUnlocalizedName( "appliedenergistics2." + name );
|
||||
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
CommonHelper.proxy.bindTileEntitySpecialRenderer( this.featured.getTileEntityClass(), this.featured );
|
||||
}
|
||||
|
||||
registryName = new ResourceLocation( AppEng.MOD_ID, name );
|
||||
|
||||
GameRegistry.register( this.featured.setRegistryName( registryName ) );
|
||||
GameRegistry.register( this.definition.maybeItem().get().setRegistryName( registryName ) );
|
||||
AEBaseTile.registerTileItem( this.featured.getTileEntityClass(), new BlockStackSrc( this.featured, 0, ActivityState.from( this.isFeatureAvailable() ) ) );
|
||||
|
||||
GameRegistry.registerTileEntityWithAlternatives( this.featured.getTileEntityClass(), this.featured.toString() );
|
||||
|
||||
if( side == Side.CLIENT )
|
||||
{
|
||||
TileEntitySpecialRenderer tesr = this.featured.getTESR();
|
||||
ModelBakery.registerItemVariants( this.definition.maybeItem().get(), registryName );
|
||||
if( tesr != null )
|
||||
{
|
||||
ClientRegistry.bindTileEntitySpecialRenderer( this.featured.getTileEntityClass(), tesr );
|
||||
if( this.featured.hasItemTESR() )
|
||||
{
|
||||
ForgeHooksClient.registerTESRItemStack( this.definition.maybeItem().get(), 0, this.featured.getTileEntityClass() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerModel()
|
||||
{
|
||||
ItemModelMesher itemModelMesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
|
||||
Item item = this.definition.maybeItem().get();
|
||||
ItemMeshDefinition itemMeshDefinition = featured.getItemMeshDefinition();
|
||||
|
||||
if( itemMeshDefinition != null )
|
||||
{
|
||||
// This block has a custom item mesh definition, so register it instead of the resource location
|
||||
itemModelMesher.register( item, itemMeshDefinition );
|
||||
}
|
||||
else if( !featured.getBlockState().getProperties().isEmpty() || featured instanceof IHasSpecialItemModel )
|
||||
{
|
||||
itemModelMesher.register( item, 0, new ModelResourceLocation( registryName, "inventory" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
itemModelMesher.register( item, 0, new ModelResourceLocation( registryName, "normal" ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerStateMapper()
|
||||
{
|
||||
AEIgnoringStateMapper mapper = new AEIgnoringStateMapper( registryName );
|
||||
ModelLoader.setCustomStateMapper( this.featured, mapper );
|
||||
( (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager() ).registerReloadListener( mapper );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCustomModelOverride( IRegistry<ModelResourceLocation, IBakedModel> modelRegistry )
|
||||
{
|
||||
Set<ModelResourceLocation> keys = Sets.newHashSet( modelRegistry.getKeys() );
|
||||
for( ModelResourceLocation model : keys )
|
||||
{
|
||||
if( model.getResourceDomain().equals( registryName.getResourceDomain() ) && model.getResourcePath().equals( registryName.getResourcePath() ) )
|
||||
{
|
||||
modelRegistry.putObject( model, new CachingRotatingBakedModel( modelRegistry.getObject( model ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,111 +19,26 @@
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ObjectArrays;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
import appeng.block.AEBaseBlock;
|
||||
|
||||
|
||||
public class BlockDefinition extends ItemDefinition implements IBlockDefinition
|
||||
{
|
||||
private static final ItemBlockTransformer ITEMBLOCK_TRANSFORMER = new ItemBlockTransformer();
|
||||
private final Optional<Block> block;
|
||||
|
||||
public BlockDefinition( final String identifier, final Block block, final ActivityState state )
|
||||
public BlockDefinition( String registryName, Block block, ItemBlock item )
|
||||
{
|
||||
super( identifier, constructItemFromBlock( block ), state );
|
||||
|
||||
Preconditions.checkNotNull( block );
|
||||
Preconditions.checkNotNull( state );
|
||||
|
||||
if( state == ActivityState.Enabled )
|
||||
{
|
||||
this.block = Optional.of( block );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.block = Optional.absent();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an {@link ItemBlock} from a {@link Block} to register it later as {@link Item}
|
||||
*
|
||||
* @param block source block
|
||||
*
|
||||
* @return item from block
|
||||
*/
|
||||
private static Item constructItemFromBlock( final Block block )
|
||||
{
|
||||
final Class<? extends ItemBlock> itemclass = getItemBlockConstructor( block );
|
||||
return constructItemBlock( block, itemclass );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the constructor to use.
|
||||
*
|
||||
* Either {@link ItemBlock} or in case of an {@link AEBaseBlock} the class returned by
|
||||
* AEBaseBlock.getItemBlockClass().
|
||||
*
|
||||
* @param block the block used to determine the used constructor.
|
||||
*
|
||||
* @return a {@link Class} extending ItemBlock
|
||||
*/
|
||||
private static Class<? extends ItemBlock> getItemBlockConstructor( final Block block )
|
||||
{
|
||||
if( block instanceof AEBaseBlock )
|
||||
{
|
||||
final AEBaseBlock aeBaseBlock = (AEBaseBlock) block;
|
||||
return aeBaseBlock.getItemBlockClass();
|
||||
}
|
||||
|
||||
return ItemBlock.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Actually construct an instance of {@link Item} with the block and earlier determined constructor.
|
||||
*
|
||||
* Shamelessly stolen from the forge magic.
|
||||
*
|
||||
* TODO: throw an exception instead of returning null? As this could cause issue later on.
|
||||
*
|
||||
* @param block the block to create the {@link ItemBlock} from
|
||||
* @param itemclass the class used to construct it.
|
||||
*
|
||||
* @return an {@link Item} for the block. Actually always a sub type of {@link ItemBlock}
|
||||
*/
|
||||
private static Item constructItemBlock( final Block block, final Class<? extends ItemBlock> itemclass )
|
||||
{
|
||||
try
|
||||
{
|
||||
final Object[] itemCtorArgs = {};
|
||||
final Class<?>[] ctorArgClasses = new Class<?>[itemCtorArgs.length + 1];
|
||||
ctorArgClasses[0] = Block.class;
|
||||
for( int idx = 1; idx < ctorArgClasses.length; idx++ )
|
||||
{
|
||||
ctorArgClasses[idx] = itemCtorArgs[idx - 1].getClass();
|
||||
}
|
||||
|
||||
final Constructor<? extends ItemBlock> itemCtor = itemclass.getConstructor( ctorArgClasses );
|
||||
return itemCtor.newInstance( ObjectArrays.concat( block, itemCtorArgs ) );
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
super( registryName, item );
|
||||
this.block = Optional.fromNullable( block );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -135,13 +50,15 @@ public class BlockDefinition extends ItemDefinition implements IBlockDefinition
|
||||
@Override
|
||||
public final Optional<ItemBlock> maybeItemBlock()
|
||||
{
|
||||
return this.block.transform( ITEMBLOCK_TRANSFORMER );
|
||||
return this.block.transform( ItemBlock::new );
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Optional<ItemStack> maybeStack( final int stackSize )
|
||||
public final Optional<ItemStack> maybeStack( int stackSize )
|
||||
{
|
||||
return this.block.transform( new ItemStackTransformer( stackSize ) );
|
||||
Preconditions.checkArgument( stackSize > 0 );
|
||||
|
||||
return this.block.transform( b -> new ItemStack( b, stackSize ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -149,31 +66,4 @@ public class BlockDefinition extends ItemDefinition implements IBlockDefinition
|
||||
{
|
||||
return this.isEnabled() && world.getBlockState( pos ).getBlock() == this.block.get();
|
||||
}
|
||||
|
||||
private static class ItemBlockTransformer implements Function<Block, ItemBlock>
|
||||
{
|
||||
@Override
|
||||
public ItemBlock apply( final Block input )
|
||||
{
|
||||
return new ItemBlock( input );
|
||||
}
|
||||
}
|
||||
|
||||
private static class ItemStackTransformer implements Function<Block, ItemStack>
|
||||
{
|
||||
private final int stackSize;
|
||||
|
||||
public ItemStackTransformer( final int stackSize )
|
||||
{
|
||||
Preconditions.checkArgument( stackSize > 0 );
|
||||
|
||||
this.stackSize = stackSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack apply( final Block input )
|
||||
{
|
||||
return new ItemStack( input, this.stackSize );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
|
||||
public class FeatureNameExtractor
|
||||
{
|
||||
private static final Pattern PATTERN_ITEM_MULTI_PART = Pattern.compile( "ItemMultiPart", Pattern.LITERAL );
|
||||
private static final Pattern PATTERN_ITEM_MULTI_MATERIAL = Pattern.compile( "ItemMultiMaterial", Pattern.LITERAL );
|
||||
private static final Pattern PATTERN_QUARTZ = Pattern.compile( "Quartz", Pattern.LITERAL );
|
||||
|
||||
private static final Pattern PATTERN_LOWERCASE = Pattern.compile( "([\\p{Upper}])([\\p{Upper}]+)" );
|
||||
private static final Pattern PATTERN_LOWERCASER = Pattern.compile( "(.)?([\\p{Upper}])" );
|
||||
|
||||
private final Class<?> clazz;
|
||||
private final Optional<String> subName;
|
||||
|
||||
public FeatureNameExtractor( final Class<?> clazz, final Optional<String> subName )
|
||||
{
|
||||
this.clazz = clazz;
|
||||
this.subName = subName;
|
||||
}
|
||||
|
||||
public String get()
|
||||
{
|
||||
String ret;
|
||||
String name = this.clazz.getSimpleName().replaceFirst( "\\p{Upper}[\\p{Lower}]*(\\p{Upper})", "$1" );
|
||||
|
||||
if( this.subName.isPresent() )
|
||||
{
|
||||
final String subName = this.subName.get();
|
||||
// simple hack to allow me to do get nice names for these without
|
||||
// mode code outside of AEBaseItem
|
||||
if( subName.startsWith( "P2PTunnel" ) )
|
||||
{
|
||||
ret = "p2ptunnel";
|
||||
}
|
||||
else if( subName.equals( "CertusQuartzTools" ) )
|
||||
{
|
||||
ret = PATTERN_QUARTZ.matcher( name ).replaceAll( "CertusQuartz" );
|
||||
}
|
||||
else if( subName.equals( "NetherQuartzTools" ) )
|
||||
{
|
||||
ret = PATTERN_QUARTZ.matcher( name ).replaceAll( "NetherQuartz" );
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = name + '_' + subName;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = name;
|
||||
}
|
||||
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
Matcher m = PATTERN_LOWERCASE.matcher( ret );
|
||||
while( m.find() )
|
||||
{
|
||||
m.appendReplacement( buffer, m.group( 1 ) + m.group( 2 ).toLowerCase() );
|
||||
}
|
||||
m.appendTail( buffer );
|
||||
m = PATTERN_LOWERCASER.matcher( buffer.toString() );
|
||||
buffer = new StringBuffer();
|
||||
while( m.find() )
|
||||
{
|
||||
m.appendReplacement( buffer, ( m.group( 1 ) != null ? m.group( 1 ) + '_' : "" ) + m.group( 2 ).toLowerCase() );
|
||||
}
|
||||
m.appendTail( buffer );
|
||||
ret = buffer.toString().replace( '.', '_' ).replaceAll( "_+", "_" );
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
|
||||
|
||||
public final class FeaturedActiveChecker
|
||||
{
|
||||
private final Set<AEFeature> features;
|
||||
|
||||
public FeaturedActiveChecker( final Set<AEFeature> features )
|
||||
{
|
||||
this.features = features;
|
||||
}
|
||||
|
||||
ActivityState getActivityState()
|
||||
{
|
||||
for( final AEFeature f : this.features )
|
||||
{
|
||||
if( !AEConfig.instance.isFeatureEnabled( f ) )
|
||||
{
|
||||
return ActivityState.Disabled;
|
||||
}
|
||||
}
|
||||
|
||||
return ActivityState.Enabled;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
public interface IAEFeature
|
||||
{
|
||||
IFeatureHandler handler();
|
||||
|
||||
void postInit();
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
|
||||
|
||||
public interface IFeatureHandler
|
||||
{
|
||||
boolean isFeatureAvailable();
|
||||
|
||||
IItemDefinition getDefinition();
|
||||
|
||||
void register( Side side );
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
void registerModel();
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
void registerStateMapper();
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
void registerCustomModelOverride( IRegistry<ModelResourceLocation, IBakedModel> modelRegistry );
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import javax.annotation.Nonnull;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -37,21 +38,11 @@ public class ItemDefinition implements IItemDefinition
|
||||
private final String identifier;
|
||||
private final Optional<Item> item;
|
||||
|
||||
public ItemDefinition( final String identifier, final Item item, final ActivityState state )
|
||||
public ItemDefinition( String registryName, Item item )
|
||||
{
|
||||
this.identifier = Preconditions.checkNotNull( identifier );
|
||||
Preconditions.checkArgument( !identifier.isEmpty() );
|
||||
Preconditions.checkNotNull( item );
|
||||
Preconditions.checkNotNull( state );
|
||||
|
||||
if( state == ActivityState.Enabled )
|
||||
{
|
||||
this.item = Optional.of( item );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.item = Optional.absent();
|
||||
}
|
||||
Preconditions.checkArgument( !Strings.isNullOrEmpty( registryName ), "registryName" );
|
||||
this.identifier = registryName;
|
||||
this.item = Optional.fromNullable( item );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -1,153 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.core.features;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.CreativeTab;
|
||||
import appeng.core.CreativeTabFacade;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.items.parts.ItemFacade;
|
||||
|
||||
|
||||
public final class ItemFeatureHandler implements IFeatureHandler
|
||||
{
|
||||
private final Item item;
|
||||
private final FeatureNameExtractor extractor;
|
||||
private final boolean enabled;
|
||||
private final ItemDefinition definition;
|
||||
|
||||
private ResourceLocation registryName;
|
||||
|
||||
public ItemFeatureHandler( final EnumSet<AEFeature> features, final Item item, final IAEFeature featured, final Optional<String> subName )
|
||||
{
|
||||
final ActivityState state = new FeaturedActiveChecker( features ).getActivityState();
|
||||
|
||||
this.item = item;
|
||||
this.extractor = new FeatureNameExtractor( featured.getClass(), subName );
|
||||
this.enabled = state == ActivityState.Enabled;
|
||||
this.definition = new ItemDefinition( item.getClass().getSimpleName(), item, state );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFeatureAvailable()
|
||||
{
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition getDefinition()
|
||||
{
|
||||
return this.definition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register( final Side side )
|
||||
{
|
||||
if( this.enabled )
|
||||
{
|
||||
String name = this.extractor.get();
|
||||
if( Item.REGISTRY.containsKey( new ResourceLocation( AppEng.MOD_ID, name ) ) )
|
||||
{
|
||||
name += "_item";
|
||||
}
|
||||
|
||||
// this.item.setTextureName( "appliedenergistics2:" + name );
|
||||
this.item.setUnlocalizedName( "appliedenergistics2." + name );
|
||||
|
||||
if( this.item instanceof ItemFacade )
|
||||
{
|
||||
this.item.setCreativeTab( CreativeTabFacade.instance );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.item.setCreativeTab( CreativeTab.instance );
|
||||
}
|
||||
|
||||
registryName = new ResourceLocation( AppEng.MOD_ID, name );
|
||||
GameRegistry.register( this.item.setRegistryName( registryName ) );
|
||||
|
||||
if( side == Side.CLIENT )
|
||||
{
|
||||
if( item instanceof AEBaseItem )
|
||||
{
|
||||
AEBaseItem baseItem = (AEBaseItem) item;
|
||||
|
||||
// Handle registration of item variants
|
||||
ResourceLocation[] variants = baseItem.getItemVariants().toArray( new ResourceLocation[0] );
|
||||
ModelBakery.registerItemVariants( item, variants );
|
||||
}
|
||||
else
|
||||
{
|
||||
ModelBakery.registerItemVariants( item, registryName );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerModel()
|
||||
{
|
||||
ItemMeshDefinition meshDefinition = null;
|
||||
|
||||
// Register a custom item model handler if the item wants one
|
||||
if( item instanceof AEBaseItem )
|
||||
{
|
||||
AEBaseItem baseItem = (AEBaseItem) item;
|
||||
meshDefinition = baseItem.getItemMeshDefinition();
|
||||
}
|
||||
|
||||
if( meshDefinition != null )
|
||||
{
|
||||
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register( item, meshDefinition );
|
||||
}
|
||||
else
|
||||
{
|
||||
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register( item, 0, new ModelResourceLocation( registryName, "inventory" ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerStateMapper()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCustomModelOverride( IRegistry<ModelResourceLocation, IBakedModel> modelRegistry )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -21,10 +21,9 @@ package appeng.core.features;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import appeng.api.definitions.ITileDefinition;
|
||||
@@ -33,39 +32,18 @@ import appeng.block.AEBaseTileBlock;
|
||||
|
||||
public final class TileDefinition extends BlockDefinition implements ITileDefinition
|
||||
{
|
||||
private static final TileEntityTransformer TILEENTITY_TRANSFORMER = new TileEntityTransformer();
|
||||
|
||||
private final Optional<AEBaseTileBlock> block;
|
||||
|
||||
public TileDefinition( @Nonnull final String identifier, final AEBaseTileBlock block, final ActivityState state )
|
||||
public TileDefinition( @Nonnull String registryName, AEBaseTileBlock block, ItemBlock item )
|
||||
{
|
||||
super( identifier, block, state );
|
||||
|
||||
Preconditions.checkNotNull( block );
|
||||
|
||||
if( state == ActivityState.Enabled )
|
||||
{
|
||||
this.block = Optional.of( block );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.block = Optional.absent();
|
||||
}
|
||||
super( registryName, block, item );
|
||||
this.block = Optional.fromNullable( block );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<? extends Class<? extends TileEntity>> maybeEntity()
|
||||
{
|
||||
return this.block.transform( TILEENTITY_TRANSFORMER );
|
||||
}
|
||||
|
||||
private static class TileEntityTransformer implements Function<AEBaseTileBlock, Class<? extends TileEntity>>
|
||||
{
|
||||
@Override
|
||||
public Class<? extends TileEntity> apply( final AEBaseTileBlock input )
|
||||
{
|
||||
final Class<? extends TileEntity> entity = input.getTileEntityClass();
|
||||
|
||||
return entity;
|
||||
}
|
||||
return this.block.transform( AEBaseTileBlock::getTileEntityClass );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user