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:
parent
66df324ef0
commit
6f2bbfab4c
|
@ -20,21 +20,16 @@ package appeng.block;
|
|||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -53,27 +48,19 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.core.features.AEBlockFeatureHandler;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.FeatureNameExtractor;
|
||||
import appeng.core.features.IAEFeature;
|
||||
import appeng.core.features.IFeatureHandler;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
import appeng.util.LookDirection;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public abstract class AEBaseBlock extends Block implements IAEFeature
|
||||
public abstract class AEBaseBlock extends Block
|
||||
{
|
||||
|
||||
private final String featureFullName;
|
||||
private final Optional<String> featureSubName;
|
||||
private boolean isOpaque = true;
|
||||
private boolean isFullSize = true;
|
||||
private boolean hasSubtypes = false;
|
||||
private boolean isInventory = false;
|
||||
private IFeatureHandler handler;
|
||||
|
||||
protected AxisAlignedBB boundingBox = FULL_BLOCK_AABB;
|
||||
|
||||
|
@ -84,15 +71,6 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
|||
}
|
||||
|
||||
protected AEBaseBlock( final Material mat )
|
||||
{
|
||||
this( mat, Optional.<String>absent() );
|
||||
this.setLightOpacity( 255 );
|
||||
this.setLightLevel( 0 );
|
||||
this.setHardness( 2.2F );
|
||||
this.setHarvestLevel( "pickaxe", 0 );
|
||||
}
|
||||
|
||||
protected AEBaseBlock( final Material mat, final Optional<String> subName )
|
||||
{
|
||||
super( mat );
|
||||
|
||||
|
@ -113,14 +91,17 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
|||
this.setSoundType( SoundType.METAL );
|
||||
}
|
||||
|
||||
this.featureFullName = new FeatureNameExtractor( this.getClass(), subName ).get();
|
||||
this.featureSubName = subName;
|
||||
this.setLightOpacity( 255 );
|
||||
this.setLightLevel( 0 );
|
||||
this.setHardness( 2.2F );
|
||||
this.setHarvestLevel( "pickaxe", 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.featureFullName;
|
||||
String regName = getRegistryName() != null ? getRegistryName().getResourcePath() : "unregistered";
|
||||
return getClass().getSimpleName() + "[" + regName + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -134,29 +115,6 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
|||
return new IProperty[0];
|
||||
}
|
||||
|
||||
protected void setFeature( final EnumSet<AEFeature> f )
|
||||
{
|
||||
final AEBlockFeatureHandler featureHandler = new AEBlockFeatureHandler( f, this, this.getFeatureSubName() );
|
||||
this.setHandler( featureHandler );
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IFeatureHandler handler()
|
||||
{
|
||||
return this.handler;
|
||||
}
|
||||
|
||||
protected final void setHandler( final IFeatureHandler handler )
|
||||
{
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit()
|
||||
{
|
||||
// override!
|
||||
}
|
||||
|
||||
public boolean isOpaque()
|
||||
{
|
||||
return this.isOpaque;
|
||||
|
@ -379,7 +337,8 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
|||
{
|
||||
if( this instanceof IOrientableBlock )
|
||||
{
|
||||
return ( (IOrientableBlock) this ).getOrientable( w, pos );
|
||||
IOrientableBlock orientable = (IOrientableBlock) this;
|
||||
return orientable.getOrientable( w, pos );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -445,12 +404,6 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
|||
super.getSubBlocks( item, tabs, itemStacks );
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void setRenderStateByMeta( final int itemDamage )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public String getUnlocalizedName( final ItemStack is )
|
||||
{
|
||||
return this.getUnlocalizedName();
|
||||
|
@ -461,11 +414,6 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
|||
|
||||
}
|
||||
|
||||
public Class<? extends AEBaseItemBlock> getItemBlockClass()
|
||||
{
|
||||
return AEBaseItemBlock.class;
|
||||
}
|
||||
|
||||
public boolean hasSubtypes()
|
||||
{
|
||||
return this.hasSubtypes;
|
||||
|
@ -553,11 +501,6 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
|||
return isOpaque;
|
||||
}
|
||||
|
||||
public Optional<String> getFeatureSubName()
|
||||
{
|
||||
return this.featureSubName;
|
||||
}
|
||||
|
||||
public boolean isInventory()
|
||||
{
|
||||
return this.isInventory;
|
||||
|
@ -573,15 +516,4 @@ public abstract class AEBaseBlock extends Block implements IAEFeature
|
|||
this.hasSubtypes = hasSubtypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the item mesh definition that should be used to determine the item model of an item stack,
|
||||
* instead of the default model. Return null if your Block doesn't use a custom ItemMeshDefinition (the default).
|
||||
* The returned ItemMeshDefinition will automatically be registered with the ItemModelMesher during the registration of the block.
|
||||
*/
|
||||
@SideOnly( Side.CLIENT )
|
||||
public ItemMeshDefinition getItemMeshDefinition()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,25 +19,16 @@
|
|||
package appeng.block;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
|
||||
import appeng.core.features.AEBlockFeatureHandler;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.IAEFeature;
|
||||
import appeng.core.features.IFeatureHandler;
|
||||
|
||||
|
||||
public abstract class AEBaseStairBlock extends BlockStairs implements IAEFeature, IHasSpecialItemModel
|
||||
public abstract class AEBaseStairBlock extends BlockStairs
|
||||
{
|
||||
private final IFeatureHandler features;
|
||||
|
||||
protected AEBaseStairBlock( final Block block, final EnumSet<AEFeature> features, final String type )
|
||||
protected AEBaseStairBlock( final Block block, final String type )
|
||||
{
|
||||
super( block.getDefaultState() );
|
||||
|
||||
|
@ -45,21 +36,15 @@ public abstract class AEBaseStairBlock extends BlockStairs implements IAEFeature
|
|||
Preconditions.checkNotNull( block.getUnlocalizedName() );
|
||||
Preconditions.checkArgument( block.getUnlocalizedName().length() > 0 );
|
||||
|
||||
this.features = new AEBlockFeatureHandler( features, this, Optional.of( type ) );
|
||||
|
||||
this.setUnlocalizedName( "stair." + type );
|
||||
this.setLightOpacity( 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFeatureHandler handler()
|
||||
public String toString()
|
||||
{
|
||||
return this.features;
|
||||
String regName = getRegistryName() != null ? getRegistryName().getResourcePath() : "unregistered";
|
||||
return getClass().getSimpleName() + "[" + regName + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit()
|
||||
{
|
||||
// Override to do stuff
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,22 +20,17 @@ package appeng.block;
|
|||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
@ -49,8 +44,9 @@ import net.minecraft.util.EnumHand;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.common.property.ExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
|
||||
import appeng.api.implementations.items.IMemoryCard;
|
||||
import appeng.api.implementations.items.MemoryCardMessages;
|
||||
|
@ -58,9 +54,6 @@ import appeng.api.implementations.tiles.IColorableTile;
|
|||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.block.networking.BlockCableBus;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.AETileBlockFeatureHandler;
|
||||
import appeng.core.features.IAEFeature;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
|
@ -69,7 +62,7 @@ import appeng.util.Platform;
|
|||
import appeng.util.SettingsFrom;
|
||||
|
||||
|
||||
public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature, ITileEntityProvider
|
||||
public abstract class AEBaseTileBlock extends AEBaseBlock implements ITileEntityProvider
|
||||
{
|
||||
|
||||
@Nonnull
|
||||
|
@ -80,25 +73,35 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
|
|||
super( mat );
|
||||
}
|
||||
|
||||
protected AEBaseTileBlock( final Material mat, final Optional<String> subName )
|
||||
{
|
||||
super( mat, subName );
|
||||
}
|
||||
|
||||
public static final PropertyDirection AE_BLOCK_FORWARD = PropertyDirection.create( "forward" );
|
||||
public static final PropertyDirection AE_BLOCK_UP = PropertyDirection.create( "up" );
|
||||
public static final UnlistedDirection FORWARD = new UnlistedDirection( "forward" );
|
||||
public static final UnlistedDirection UP = new UnlistedDirection( "up" );
|
||||
|
||||
@Override
|
||||
protected IProperty[] getAEStates()
|
||||
public IBlockState getExtendedState( IBlockState state, IBlockAccess world, BlockPos pos )
|
||||
{
|
||||
return new IProperty[] { AE_BLOCK_FORWARD, AE_BLOCK_UP };
|
||||
// A subclass may decide it doesn't want extended block state for whatever reason
|
||||
if( !( state instanceof IExtendedBlockState ) )
|
||||
{
|
||||
return state;
|
||||
}
|
||||
|
||||
AEBaseTile tile = getTileEntity( world, pos );
|
||||
if( tile == null )
|
||||
{
|
||||
return state; // No info available
|
||||
}
|
||||
|
||||
IExtendedBlockState extState = (IExtendedBlockState) state;
|
||||
return extState.withProperty( FORWARD, tile.getForward() ).withProperty( UP, tile.getUp() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getActualState( IBlockState state, IBlockAccess world, BlockPos pos )
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
AEBaseTile tile = (AEBaseTile) world.getTileEntity( pos );
|
||||
return super.getActualState( state, world, pos ).withProperty( AE_BLOCK_FORWARD, tile.getForward() ).withProperty( AE_BLOCK_UP, tile.getUp() );
|
||||
return new ExtendedBlockState( this, getAEStates(), new IUnlistedProperty[] {
|
||||
FORWARD,
|
||||
UP
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -107,24 +110,6 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements IAEFeature,
|
|||
return 0;
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
public TileEntitySpecialRenderer<? extends AEBaseTile> getTESR()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasItemTESR()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setFeature( final EnumSet<AEFeature> f )
|
||||
{
|
||||
final AETileBlockFeatureHandler featureHandler = new AETileBlockFeatureHandler( f, this, this.getFeatureSubName() );
|
||||
this.setHandler( featureHandler );
|
||||
}
|
||||
|
||||
protected void setTileEntity( final Class<? extends AEBaseTile> c )
|
||||
{
|
||||
this.tileEntityType = c;
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
|
||||
package appeng.block;
|
||||
|
||||
|
||||
public interface IHasSpecialItemModel
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package appeng.block;
|
||||
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
|
||||
|
||||
public class UnlistedDirection implements IUnlistedProperty<EnumFacing>
|
||||
{
|
||||
|
||||
private final String name;
|
||||
|
||||
public UnlistedDirection( String name )
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid( EnumFacing value )
|
||||
{
|
||||
return value != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<EnumFacing> getType()
|
||||
{
|
||||
return EnumFacing.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String valueToString( EnumFacing value )
|
||||
{
|
||||
return value.getName();
|
||||
}
|
||||
|
||||
}
|
|
@ -31,10 +31,4 @@ public class BlockCraftingStorage extends BlockCraftingUnit
|
|||
this.setTileEntity( TileCraftingStorageTile.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ItemCraftingStorage> getItemBlockClass()
|
||||
{
|
||||
return ItemCraftingStorage.class;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,41 +19,28 @@
|
|||
package appeng.block.crafting;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.crafting.TileCraftingTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class BlockCraftingUnit extends AEBaseTileBlock
|
||||
{
|
||||
public static final PropertyBool POWERED = PropertyBool.create( "powered" );
|
||||
|
@ -63,17 +50,16 @@ public class BlockCraftingUnit extends AEBaseTileBlock
|
|||
|
||||
public BlockCraftingUnit( final CraftingUnitType type )
|
||||
{
|
||||
super( Material.IRON, Optional.of( type.name() ) );
|
||||
super( Material.IRON );
|
||||
|
||||
this.type = type;
|
||||
this.setTileEntity( TileCraftingTile.class );
|
||||
this.setFeature( EnumSet.of( AEFeature.CraftingCPU ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IProperty[] getAEStates()
|
||||
{
|
||||
return new IProperty[] { AE_BLOCK_FORWARD, AE_BLOCK_UP, POWERED, FORMED };
|
||||
return new IProperty[] { POWERED, FORMED };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
package appeng.block.crafting;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -35,12 +33,10 @@ import net.minecraft.world.World;
|
|||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.crafting.TileMolecularAssembler;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class BlockMolecularAssembler extends AEBaseTileBlock
|
||||
{
|
||||
|
||||
|
@ -51,7 +47,6 @@ public class BlockMolecularAssembler extends AEBaseTileBlock
|
|||
this.setTileEntity( TileMolecularAssembler.class );
|
||||
this.setOpaque( false );
|
||||
this.lightOpacity = 1;
|
||||
this.setFeature( EnumSet.of( AEFeature.MolecularAssembler ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
package appeng.block.grindstone;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -38,12 +36,10 @@ import net.minecraftforge.common.util.FakePlayer;
|
|||
|
||||
import appeng.api.implementations.tiles.ICrankable;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.stats.Stats;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.grindstone.TileCrank;
|
||||
|
||||
|
||||
public class BlockCrank extends AEBaseTileBlock
|
||||
{
|
||||
|
||||
|
@ -55,7 +51,6 @@ public class BlockCrank extends AEBaseTileBlock
|
|||
this.setLightOpacity( 0 );
|
||||
this.setHarvestLevel( "axe", 0 );
|
||||
this.setFullSize( this.setOpaque( false ) );
|
||||
this.setFeature( EnumSet.of( AEFeature.GrindStone ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
package appeng.block.grindstone;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -33,12 +31,10 @@ import net.minecraft.world.World;
|
|||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.grindstone.TileGrinder;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class BlockGrinder extends AEBaseTileBlock
|
||||
{
|
||||
|
||||
|
@ -48,7 +44,6 @@ public class BlockGrinder extends AEBaseTileBlock
|
|||
|
||||
this.setTileEntity( TileGrinder.class );
|
||||
this.setHardness( 3.2F );
|
||||
this.setFeature( EnumSet.of( AEFeature.GrindStone ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
package appeng.block.misc;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -33,12 +31,10 @@ import net.minecraft.world.World;
|
|||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.misc.TileCellWorkbench;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class BlockCellWorkbench extends AEBaseTileBlock
|
||||
{
|
||||
|
||||
|
@ -47,7 +43,6 @@ public class BlockCellWorkbench extends AEBaseTileBlock
|
|||
super( Material.IRON );
|
||||
|
||||
this.setTileEntity( TileCellWorkbench.class );
|
||||
this.setFeature( EnumSet.of( AEFeature.StorageCells ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,19 +20,17 @@ package appeng.block.misc;
|
|||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.lwjgl.util.vector.Matrix4f;
|
||||
import org.lwjgl.util.vector.Vector3f;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -53,7 +51,6 @@ import appeng.client.render.renderable.ItemRenderable;
|
|||
import appeng.client.render.tesr.ModularTESR;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.misc.TileCharger;
|
||||
|
@ -70,7 +67,6 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
|
|||
this.setTileEntity( TileCharger.class );
|
||||
this.setLightOpacity( 2 );
|
||||
this.setFullSize( this.setOpaque( false ) );
|
||||
this.setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -130,13 +126,6 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public TileEntitySpecialRenderer<TileCharger> getTESR()
|
||||
{
|
||||
return new ModularTESR( new ItemRenderable<TileCharger>( tile -> new ImmutablePair( tile.getStackInSlot( 0 ), new Matrix4f().translate( new Vector3f( 0.5f, 0.4f, 0.5f ) ) ) ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( final World w, final BlockPos pos, final Entity thePlayer, final boolean b )
|
||||
{
|
||||
|
@ -198,4 +187,10 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
|
|||
{
|
||||
out.add( new AxisAlignedBB( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
public static TileEntitySpecialRenderer<TileCharger> createTesr()
|
||||
{
|
||||
return new ModularTESR<>( new ItemRenderable<TileCharger>( tile -> new ImmutablePair<>( tile.getStackInSlot( 0 ), new Matrix4f().translate( new Vector3f( 0.5f, 0.4f, 0.5f ) ) ) ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
package appeng.block.misc;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -33,7 +31,6 @@ import net.minecraft.world.World;
|
|||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.misc.TileCondenser;
|
||||
import appeng.util.Platform;
|
||||
|
@ -47,7 +44,6 @@ public class BlockCondenser extends AEBaseTileBlock
|
|||
super( Material.IRON );
|
||||
|
||||
this.setTileEntity( TileCondenser.class );
|
||||
this.setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
package appeng.block.misc;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -33,12 +31,10 @@ import net.minecraft.world.World;
|
|||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.misc.TileInscriber;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class BlockInscriber extends AEBaseTileBlock
|
||||
{
|
||||
|
||||
|
@ -49,7 +45,6 @@ public class BlockInscriber extends AEBaseTileBlock
|
|||
this.setTileEntity( TileInscriber.class );
|
||||
this.setLightOpacity( 2 );
|
||||
this.setFullSize( this.setOpaque( false ) );
|
||||
this.setFeature( EnumSet.of( AEFeature.Inscriber ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package appeng.block.misc;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -37,12 +36,10 @@ import net.minecraft.world.World;
|
|||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.misc.TileInterface;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class BlockInterface extends AEBaseTileBlock
|
||||
{
|
||||
|
||||
|
@ -53,7 +50,6 @@ public class BlockInterface extends AEBaseTileBlock
|
|||
super( Material.IRON );
|
||||
|
||||
this.setTileEntity( TileInterface.class );
|
||||
this.setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,14 +20,11 @@ package appeng.block.misc;
|
|||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockTorch;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
@ -36,15 +33,11 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
import appeng.helpers.MetaRotation;
|
||||
import appeng.tile.misc.TileLightDetector;
|
||||
|
||||
|
||||
public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBlock, ICustomCollision
|
||||
{
|
||||
|
||||
|
@ -57,13 +50,6 @@ public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBl
|
|||
this.setOpaque( false );
|
||||
|
||||
this.setTileEntity( TileLightDetector.class );
|
||||
this.setFeature( EnumSet.of( AEFeature.LightDetector ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IProperty[] getAEStates()
|
||||
{
|
||||
return new IProperty[] { AE_BLOCK_FORWARD, AE_BLOCK_UP };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package appeng.block.misc;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
|
@ -39,11 +38,9 @@ import net.minecraftforge.fml.relauncher.Side;
|
|||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.tile.misc.TilePaint;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class BlockPaint extends AEBaseTileBlock
|
||||
{
|
||||
|
||||
|
@ -55,7 +52,6 @@ public class BlockPaint extends AEBaseTileBlock
|
|||
this.setLightOpacity( 0 );
|
||||
this.setFullSize( false );
|
||||
this.setOpaque( false );
|
||||
this.setFeature( EnumSet.of( AEFeature.PaintBalls ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package appeng.block.misc;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.SoundType;
|
||||
|
@ -32,12 +31,13 @@ import net.minecraft.util.EnumFacing;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.effects.LightningFX;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.tile.misc.TileQuartzGrowthAccelerator;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
@ -52,7 +52,6 @@ public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock
|
|||
super( Material.ROCK );
|
||||
this.setSoundType( SoundType.METAL );
|
||||
this.setTileEntity( TileQuartzGrowthAccelerator.class );
|
||||
this.setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
this.setDefaultState( getDefaultState().withProperty( POWERED, false ) );
|
||||
}
|
||||
|
||||
|
@ -69,9 +68,10 @@ public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock
|
|||
@Override
|
||||
protected IProperty[] getAEStates()
|
||||
{
|
||||
return new IProperty[] { AE_BLOCK_FORWARD, AE_BLOCK_UP, POWERED };
|
||||
return new IProperty[] { POWERED };
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
@Override
|
||||
public void randomDisplayTick( final IBlockState state, final World w, final BlockPos pos, final Random r )
|
||||
{
|
||||
|
|
|
@ -20,7 +20,6 @@ package appeng.block.misc;
|
|||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
|
@ -47,11 +46,9 @@ import appeng.block.AEBaseBlock;
|
|||
import appeng.client.render.effects.LightningFX;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
import appeng.helpers.MetaRotation;
|
||||
|
||||
|
||||
public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, ICustomCollision
|
||||
{
|
||||
|
||||
|
@ -66,7 +63,6 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I
|
|||
super( Material.CIRCUITS );
|
||||
|
||||
this.setDefaultState( this.blockState.getBaseState().withProperty( FACING, EnumFacing.UP ).withProperty( ODD, false ) );
|
||||
this.setFeature( EnumSet.of( AEFeature.DecorativeLights ) );
|
||||
this.setLightLevel( 0.9375F );
|
||||
this.setLightOpacity( 0 );
|
||||
this.setFullSize( false );
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
package appeng.block.misc;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -34,12 +32,10 @@ import net.minecraft.world.World;
|
|||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.misc.TileSecurity;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class BlockSecurity extends AEBaseTileBlock
|
||||
{
|
||||
|
||||
|
@ -48,7 +44,6 @@ public class BlockSecurity extends AEBaseTileBlock
|
|||
super( Material.IRON );
|
||||
|
||||
this.setTileEntity( TileSecurity.class );
|
||||
this.setFeature( EnumSet.of( AEFeature.Security ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,7 +20,6 @@ package appeng.block.misc;
|
|||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -33,11 +32,9 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
import appeng.tile.misc.TileSkyCompass;
|
||||
|
||||
|
||||
public class BlockSkyCompass extends AEBaseTileBlock implements ICustomCollision
|
||||
{
|
||||
|
||||
|
@ -47,7 +44,6 @@ public class BlockSkyCompass extends AEBaseTileBlock implements ICustomCollision
|
|||
this.setTileEntity( TileSkyCompass.class );
|
||||
this.setOpaque( this.setFullSize( false ) );
|
||||
this.lightOpacity = 0;
|
||||
this.setFeature( EnumSet.of( AEFeature.MeteoriteCompass ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,13 +20,10 @@ package appeng.block.misc;
|
|||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
@ -36,7 +33,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
|
@ -49,12 +45,9 @@ import net.minecraftforge.fml.common.registry.EntityRegistry;
|
|||
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.entity.EntityIds;
|
||||
import appeng.entity.EntityTinyTNTPrimed;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
import appeng.hooks.DispenserBehaviorTinyTNT;
|
||||
|
||||
|
||||
public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
|
||||
{
|
||||
|
@ -67,18 +60,10 @@ public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
|
|||
this.setFullSize( this.setOpaque( false ) );
|
||||
this.setSoundType( SoundType.GROUND );
|
||||
this.setHardness( 0F );
|
||||
this.setFeature( EnumSet.of( AEFeature.TinyTNT ) );
|
||||
|
||||
EntityRegistry.registerModEntity( EntityTinyTNTPrimed.class, "EntityTinyTNTPrimed", EntityIds.get( EntityTinyTNTPrimed.class ), AppEng.instance(), 16, 4, true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit()
|
||||
{
|
||||
super.postInit();
|
||||
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject( Item.getItemFromBlock( this ), new DispenserBehaviorTinyTNT() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ )
|
||||
{
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package appeng.block.misc;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Random;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
@ -39,13 +38,11 @@ import net.minecraft.world.World;
|
|||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.misc.TileVibrationChamber;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public final class BlockVibrationChamber extends AEBaseTileBlock
|
||||
{
|
||||
|
||||
|
@ -57,7 +54,6 @@ public final class BlockVibrationChamber extends AEBaseTileBlock
|
|||
super( Material.IRON );
|
||||
this.setTileEntity( TileVibrationChamber.class );
|
||||
this.setHardness( 4.2F );
|
||||
this.setFeature( EnumSet.of( AEFeature.PowerGen ) );
|
||||
this.setDefaultState( getDefaultState().withProperty( ACTIVE, false ) );
|
||||
}
|
||||
|
||||
|
@ -74,7 +70,7 @@ public final class BlockVibrationChamber extends AEBaseTileBlock
|
|||
@Override
|
||||
protected IProperty[] getAEStates()
|
||||
{
|
||||
return new IProperty[]{ AE_BLOCK_FORWARD, AE_BLOCK_UP, ACTIVE };
|
||||
return new IProperty[]{ ACTIVE };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,7 +22,6 @@ package appeng.block.networking;
|
|||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -60,7 +59,6 @@ import appeng.api.util.AEColor;
|
|||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.features.AECableBusFeatureHandler;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.integration.IntegrationRegistry;
|
||||
|
@ -88,7 +86,6 @@ public class BlockCableBus extends AEBaseTileBlock
|
|||
// this will actually be overwritten later through setupTile and the
|
||||
// combined layers
|
||||
this.setTileEntity( TileCableBus.class );
|
||||
this.setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
}
|
||||
|
||||
public static final CableBusContainerUnlistedProperty cableBus = new CableBusContainerUnlistedProperty();
|
||||
|
@ -96,19 +93,14 @@ public class BlockCableBus extends AEBaseTileBlock
|
|||
@Override
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new ExtendedBlockState( this, new IProperty[0], new IUnlistedProperty[] { cableBus } );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getActualState( IBlockState state, IBlockAccess world, BlockPos pos )
|
||||
{
|
||||
return state;
|
||||
return new ExtendedBlockState( this, new IProperty[0], new IUnlistedProperty[] { FORWARD, UP, cableBus } );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getExtendedState( IBlockState state, IBlockAccess world, BlockPos pos )
|
||||
{
|
||||
return ( (IExtendedBlockState) state ).withProperty( cableBus, ( (TileCableBus) world.getTileEntity( pos ) ).getCableBus() );
|
||||
return ( (IExtendedBlockState) super.getExtendedState( state, world, pos ) )
|
||||
.withProperty( cableBus, ( (TileCableBus) world.getTileEntity( pos ) ).getCableBus() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -359,13 +351,6 @@ public class BlockCableBus extends AEBaseTileBlock
|
|||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setFeature( final EnumSet<AEFeature> f )
|
||||
{
|
||||
final AECableBusFeatureHandler featureHandler = new AECableBusFeatureHandler( f, this, this.getFeatureSubName() );
|
||||
this.setHandler( featureHandler );
|
||||
}
|
||||
|
||||
public void setupTile()
|
||||
{
|
||||
noTesrTile = Api.INSTANCE.partHelper().getCombinedInstance( TileCableBus.class.getName() );
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
package appeng.block.networking;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
|
@ -32,12 +30,11 @@ import net.minecraft.util.IStringSerializable;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.tile.networking.TileController;
|
||||
|
||||
|
||||
public class BlockController extends AEBaseTileBlock
|
||||
{
|
||||
|
||||
|
@ -77,7 +74,7 @@ public class BlockController extends AEBaseTileBlock
|
|||
@Override
|
||||
protected IProperty[] getAEStates()
|
||||
{
|
||||
return new IProperty[] { AE_BLOCK_FORWARD, AE_BLOCK_UP, CONTROLLER_STATE, CONTROLLER_TYPE };
|
||||
return new IProperty[] { CONTROLLER_STATE, CONTROLLER_TYPE };
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -90,8 +87,6 @@ public class BlockController extends AEBaseTileBlock
|
|||
{
|
||||
|
||||
// Only used for columns, really
|
||||
EnumFacing up = EnumFacing.UP;
|
||||
EnumFacing forward = EnumFacing.NORTH;
|
||||
ControllerRenderType type = ControllerRenderType.block;
|
||||
|
||||
int x = pos.getX();
|
||||
|
@ -105,20 +100,14 @@ public class BlockController extends AEBaseTileBlock
|
|||
|
||||
if( xx && !yy && !zz )
|
||||
{
|
||||
up = EnumFacing.EAST;
|
||||
forward = EnumFacing.UP;
|
||||
type = ControllerRenderType.column;
|
||||
}
|
||||
else if( !xx && yy && !zz )
|
||||
{
|
||||
up = EnumFacing.UP;
|
||||
forward = EnumFacing.NORTH;
|
||||
type = ControllerRenderType.column;
|
||||
}
|
||||
else if( !xx && !yy && zz )
|
||||
{
|
||||
up = EnumFacing.NORTH;
|
||||
forward = EnumFacing.UP;
|
||||
type = ControllerRenderType.column;
|
||||
}
|
||||
else if( ( xx ? 1 : 0 ) + ( yy ? 1 : 0 ) + ( zz ? 1 : 0 ) >= 2 )
|
||||
|
@ -137,7 +126,43 @@ public class BlockController extends AEBaseTileBlock
|
|||
}
|
||||
}
|
||||
|
||||
return state.withProperty( AE_BLOCK_FORWARD, forward ).withProperty( AE_BLOCK_UP, up ).withProperty( CONTROLLER_TYPE, type );
|
||||
return state.withProperty( CONTROLLER_TYPE, type );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getExtendedState( IBlockState state, IBlockAccess world, BlockPos pos )
|
||||
{
|
||||
// Only used for columns, really
|
||||
EnumFacing up = EnumFacing.UP;
|
||||
EnumFacing forward = EnumFacing.NORTH;
|
||||
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
||||
// Detect whether controllers are on both sides of the x, y, and z axes
|
||||
final boolean xx = this.getTileEntity( world, x - 1, y, z ) instanceof TileController && this.getTileEntity( world, x + 1, y, z ) instanceof TileController;
|
||||
final boolean yy = this.getTileEntity( world, x, y - 1, z ) instanceof TileController && this.getTileEntity( world, x, y + 1, z ) instanceof TileController;
|
||||
final boolean zz = this.getTileEntity( world, x, y, z - 1 ) instanceof TileController && this.getTileEntity( world, x, y, z + 1 ) instanceof TileController;
|
||||
|
||||
if( xx && !yy && !zz )
|
||||
{
|
||||
up = EnumFacing.EAST;
|
||||
forward = EnumFacing.UP;
|
||||
}
|
||||
else if( !xx && yy && !zz )
|
||||
{
|
||||
up = EnumFacing.UP;
|
||||
forward = EnumFacing.NORTH;
|
||||
}
|
||||
else if( !xx && !yy && zz )
|
||||
{
|
||||
up = EnumFacing.NORTH;
|
||||
forward = EnumFacing.UP;
|
||||
}
|
||||
|
||||
IExtendedBlockState extState = (IExtendedBlockState) super.getExtendedState( state, world, pos );
|
||||
return extState.withProperty( FORWARD, forward ).withProperty( UP, up );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -164,7 +189,6 @@ public class BlockController extends AEBaseTileBlock
|
|||
super( Material.IRON );
|
||||
this.setTileEntity( TileController.class );
|
||||
this.setHardness( 6 );
|
||||
this.setFeature( EnumSet.of( AEFeature.Channels ) );
|
||||
this.setDefaultState( getDefaultState().withProperty( CONTROLLER_STATE, ControllerBlockState.offline ).withProperty( CONTROLLER_TYPE, ControllerRenderType.block ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -19,14 +19,10 @@
|
|||
package appeng.block.networking;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.tile.networking.TileCreativeEnergyCell;
|
||||
|
||||
|
||||
public class BlockCreativeEnergyCell extends AEBaseTileBlock
|
||||
{
|
||||
|
||||
|
@ -34,6 +30,5 @@ public class BlockCreativeEnergyCell extends AEBaseTileBlock
|
|||
{
|
||||
super( AEGlassMaterial.INSTANCE );
|
||||
this.setTileEntity( TileCreativeEnergyCell.class );
|
||||
this.setFeature( EnumSet.of( AEFeature.Creative ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,19 +19,14 @@
|
|||
package appeng.block.networking;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.tile.networking.TileDenseEnergyCell;
|
||||
|
||||
|
||||
public class BlockDenseEnergyCell extends BlockEnergyCell
|
||||
{
|
||||
|
||||
public BlockDenseEnergyCell()
|
||||
{
|
||||
this.setTileEntity( TileDenseEnergyCell.class );
|
||||
this.setFeature( EnumSet.of( AEFeature.DenseEnergyCells ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,12 +19,9 @@
|
|||
package appeng.block.networking;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.tile.networking.TileEnergyAcceptor;
|
||||
|
||||
|
||||
|
@ -35,6 +32,5 @@ public class BlockEnergyAcceptor extends AEBaseTileBlock
|
|||
{
|
||||
super( Material.IRON );
|
||||
this.setTileEntity( TileEnergyAcceptor.class );
|
||||
this.setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,14 +19,11 @@
|
|||
package appeng.block.networking;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -34,11 +31,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.block.AEBaseItemBlock;
|
||||
import appeng.block.AEBaseItemBlockChargeable;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.tile.networking.TileEnergyCell;
|
||||
import appeng.util.Platform;
|
||||
|
@ -66,7 +59,6 @@ public class BlockEnergyCell extends AEBaseTileBlock
|
|||
super( AEGlassMaterial.INSTANCE );
|
||||
|
||||
this.setTileEntity( TileEnergyCell.class );
|
||||
this.setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -91,48 +83,7 @@ public class BlockEnergyCell extends AEBaseTileBlock
|
|||
@Override
|
||||
protected IProperty[] getAEStates()
|
||||
{
|
||||
return new IProperty[] { AE_BLOCK_FORWARD, AE_BLOCK_UP, ENERGY_STORAGE };
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends AEBaseItemBlock> getItemBlockClass()
|
||||
{
|
||||
return AEBaseItemBlockChargeable.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method that returns the energy fill factor (between 0 and 1) of a given item stack.
|
||||
* Returns 0 if the item stack has no fill factor.
|
||||
*/
|
||||
private static double getFillFactor( ItemStack is ) {
|
||||
if( !( is.getItem() instanceof IAEItemPowerStorage ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
AEBaseItemBlockChargeable itemChargeable = (AEBaseItemBlockChargeable) is.getItem();
|
||||
double curPower = itemChargeable.getAECurrentPower( is );
|
||||
double maxPower = itemChargeable.getAEMaxPower( is );
|
||||
|
||||
return curPower / maxPower;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines which version of the energy cell model should be used depending on the fill factor
|
||||
* of the item stack.
|
||||
*/
|
||||
@SideOnly( Side.CLIENT )
|
||||
@Override
|
||||
public ItemMeshDefinition getItemMeshDefinition()
|
||||
{
|
||||
return is -> {
|
||||
double fillFactor = getFillFactor( is );
|
||||
|
||||
int storageLevel = TileEnergyCell.getStorageLevelFromFillFactor(fillFactor);
|
||||
|
||||
return new ModelResourceLocation( "appliedenergistics2:tile.BlockEnergyCell", "fullness=" + storageLevel );
|
||||
|
||||
};
|
||||
return new IProperty[] { ENERGY_STORAGE };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
package appeng.block.networking;
|
||||
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.block.AEBaseItemBlockChargeable;
|
||||
import appeng.bootstrap.BlockRenderingCustomizer;
|
||||
import appeng.bootstrap.IBlockRendering;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
import appeng.tile.networking.TileEnergyCell;
|
||||
|
||||
|
||||
public class BlockEnergyCellRendering extends BlockRenderingCustomizer
|
||||
{
|
||||
|
||||
private final ResourceLocation baseModel;
|
||||
|
||||
public BlockEnergyCellRendering( ResourceLocation baseModel )
|
||||
{
|
||||
this.baseModel = baseModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
|
||||
{
|
||||
itemRendering.meshDefinition( this::getItemModel );
|
||||
// Note: Since we use the block models, we dont need to register custom variants
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines which version of the energy cell model should be used depending on the fill factor
|
||||
* of the item stack.
|
||||
*/
|
||||
private ModelResourceLocation getItemModel( ItemStack is )
|
||||
{
|
||||
double fillFactor = getFillFactor( is );
|
||||
|
||||
int storageLevel = TileEnergyCell.getStorageLevelFromFillFactor( fillFactor );
|
||||
return new ModelResourceLocation( baseModel, "fullness=" + storageLevel );
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method that returns the energy fill factor (between 0 and 1) of a given item stack.
|
||||
* Returns 0 if the item stack has no fill factor.
|
||||
*/
|
||||
private static double getFillFactor( ItemStack is )
|
||||
{
|
||||
if( !( is.getItem() instanceof IAEItemPowerStorage ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
AEBaseItemBlockChargeable itemChargeable = (AEBaseItemBlockChargeable) is.getItem();
|
||||
double curPower = itemChargeable.getAECurrentPower( is );
|
||||
double maxPower = itemChargeable.getAEMaxPower( is );
|
||||
|
||||
return curPower / maxPower;
|
||||
}
|
||||
}
|
|
@ -20,9 +20,7 @@ package appeng.block.networking;
|
|||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
@ -38,14 +36,12 @@ import net.minecraft.world.World;
|
|||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
import appeng.tile.networking.TileWireless;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class BlockWireless extends AEBaseTileBlock implements ICustomCollision
|
||||
{
|
||||
|
||||
|
@ -56,7 +52,6 @@ public class BlockWireless extends AEBaseTileBlock implements ICustomCollision
|
|||
this.setLightOpacity( 0 );
|
||||
this.setFullSize( false );
|
||||
this.setOpaque( false );
|
||||
this.setFeature( EnumSet.of( AEFeature.Core, AEFeature.WirelessAccessTerminal ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package appeng.block.networking;
|
||||
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.color.IBlockColor;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.parts.CableBusContainer;
|
||||
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
public 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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package appeng.block.networking;
|
||||
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
|
||||
import appeng.api.client.BakingPipeline;
|
||||
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;
|
||||
|
||||
|
||||
public class CableModelCustomizer
|
||||
{
|
||||
|
||||
private final BakingPipeline rotatingPipeline = new BakingPipeline( TypeTransformer.quads2vecs, new FacingQuadRotator(), TypeTransformer.vecs2quads );
|
||||
private final TintIndexModifier tintIndexModifier = new TintIndexModifier( tint -> tint );
|
||||
private final BakingPipeline tintIndexFixPipeline = new BakingPipeline( TypeTransformer.quads2vecs, tintIndexModifier, TypeTransformer.vecs2quads );
|
||||
|
||||
public IBakedModel customizeModel( ModelResourceLocation location, IBakedModel model )
|
||||
{
|
||||
return new BakingPipelineBakedModel( model, new Merge( new CableAndConnections( rotatingPipeline, tintIndexModifier, tintIndexFixPipeline ), new Facades( rotatingPipeline, tintIndexModifier, tintIndexFixPipeline ), new Parts( rotatingPipeline, tintIndexModifier, tintIndexFixPipeline ) ) );
|
||||
}
|
||||
}
|
|
@ -19,8 +19,6 @@
|
|||
package appeng.block.qnb;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
@ -30,11 +28,9 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
import appeng.tile.qnb.TileQuantumBridge;
|
||||
|
||||
|
||||
public abstract class BlockQuantumBase extends AEBaseTileBlock implements ICustomCollision
|
||||
{
|
||||
|
||||
|
@ -46,7 +42,6 @@ public abstract class BlockQuantumBase extends AEBaseTileBlock implements ICusto
|
|||
this.boundingBox = new AxisAlignedBB( shave, shave, shave, 1.0f - shave, 1.0f - shave, 1.0f - shave );
|
||||
this.setLightOpacity( 0 );
|
||||
this.setFullSize( this.setOpaque( false ) );
|
||||
this.setFeature( EnumSet.of( AEFeature.QuantumNetworkBridge ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,7 +20,6 @@ package appeng.block.spatial;
|
|||
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -38,10 +37,8 @@ import net.minecraftforge.fml.relauncher.Side;
|
|||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
|
||||
|
||||
public class BlockMatrixFrame extends AEBaseBlock implements ICustomCollision
|
||||
{
|
||||
|
||||
|
@ -52,7 +49,6 @@ public class BlockMatrixFrame extends AEBaseBlock implements ICustomCollision
|
|||
this.setBlockUnbreakable();
|
||||
this.setLightOpacity( 0 );
|
||||
this.setOpaque( false );
|
||||
this.setFeature( EnumSet.of( AEFeature.SpatialIO ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
package appeng.block.spatial;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -35,12 +33,10 @@ import net.minecraft.world.World;
|
|||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.spatial.TileSpatialIOPort;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class BlockSpatialIOPort extends AEBaseTileBlock
|
||||
{
|
||||
|
||||
|
@ -48,7 +44,6 @@ public class BlockSpatialIOPort extends AEBaseTileBlock
|
|||
{
|
||||
super( Material.IRON );
|
||||
this.setTileEntity( TileSpatialIOPort.class );
|
||||
this.setFeature( EnumSet.of( AEFeature.SpatialIO ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
package appeng.block.spatial;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -28,11 +26,9 @@ import net.minecraft.world.IBlockAccess;
|
|||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.tile.spatial.TileSpatialPylon;
|
||||
|
||||
|
||||
public class BlockSpatialPylon extends AEBaseTileBlock
|
||||
{
|
||||
|
||||
|
@ -40,7 +36,6 @@ public class BlockSpatialPylon extends AEBaseTileBlock
|
|||
{
|
||||
super( AEGlassMaterial.INSTANCE );
|
||||
this.setTileEntity( TileSpatialPylon.class );
|
||||
this.setFeature( EnumSet.of( AEFeature.SpatialIO ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
package appeng.block.storage;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -36,7 +34,6 @@ import appeng.api.AEApi;
|
|||
import appeng.api.storage.ICellHandler;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.storage.TileChest;
|
||||
|
@ -50,7 +47,6 @@ public class BlockChest extends AEBaseTileBlock
|
|||
{
|
||||
super( Material.IRON );
|
||||
this.setTileEntity( TileChest.class );
|
||||
this.setFeature( EnumSet.of( AEFeature.StorageCells, AEFeature.MEChest ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
package appeng.block.storage;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -34,7 +32,6 @@ import net.minecraft.world.World;
|
|||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.storage.TileDrive;
|
||||
import appeng.util.Platform;
|
||||
|
@ -47,7 +44,6 @@ public class BlockDrive extends AEBaseTileBlock
|
|||
{
|
||||
super( Material.IRON );
|
||||
this.setTileEntity( TileDrive.class );
|
||||
this.setFeature( EnumSet.of( AEFeature.StorageCells, AEFeature.MEDrive ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
package appeng.block.storage;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -35,7 +33,6 @@ import net.minecraft.world.World;
|
|||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.storage.TileIOPort;
|
||||
import appeng.util.Platform;
|
||||
|
@ -48,7 +45,6 @@ public class BlockIOPort extends AEBaseTileBlock
|
|||
{
|
||||
super( Material.IRON );
|
||||
this.setTileEntity( TileIOPort.class );
|
||||
this.setFeature( EnumSet.of( AEFeature.StorageCells, AEFeature.IOPort ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,16 +20,11 @@ package appeng.block.storage;
|
|||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -39,24 +34,19 @@ import net.minecraft.util.EnumHand;
|
|||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.block.IHasSpecialItemModel;
|
||||
import appeng.client.render.tesr.SkyChestTESR;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class BlockSkyChest extends AEBaseTileBlock implements ICustomCollision, IHasSpecialItemModel
|
||||
public class BlockSkyChest extends AEBaseTileBlock implements ICustomCollision
|
||||
{
|
||||
|
||||
public static enum SkyChestType
|
||||
public enum SkyChestType
|
||||
{
|
||||
STONE, BLOCK
|
||||
};
|
||||
|
@ -65,7 +55,7 @@ public class BlockSkyChest extends AEBaseTileBlock implements ICustomCollision,
|
|||
|
||||
public BlockSkyChest( final SkyChestType type )
|
||||
{
|
||||
super( Material.ROCK, Optional.of( type.name() ) );
|
||||
super( Material.ROCK );
|
||||
this.setTileEntity( TileSkyChest.class );
|
||||
this.setOpaque( this.setFullSize( false ) );
|
||||
this.lightOpacity = 0;
|
||||
|
@ -73,7 +63,6 @@ public class BlockSkyChest extends AEBaseTileBlock implements ICustomCollision,
|
|||
this.setHardness( 50 );
|
||||
this.blockResistance = 150.0f;
|
||||
this.type = type;
|
||||
this.setFeature( EnumSet.of( AEFeature.Core, AEFeature.SkyStoneChests ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -81,20 +70,8 @@ public class BlockSkyChest extends AEBaseTileBlock implements ICustomCollision,
|
|||
{
|
||||
return EnumBlockRenderType.ENTITYBLOCK_ANIMATED;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public TileEntitySpecialRenderer<TileSkyChest> getTESR()
|
||||
{
|
||||
return new SkyChestTESR();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasItemTESR()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer player, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ )
|
||||
{
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
package appeng.block.storage;
|
||||
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.bootstrap.BlockRenderingCustomizer;
|
||||
import appeng.bootstrap.IBlockRendering;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
import appeng.client.render.tesr.SkyChestTESR;
|
||||
|
||||
|
||||
public class SkyChestRenderingCustomizer extends BlockRenderingCustomizer
|
||||
{
|
||||
|
||||
private final BlockSkyChest.SkyChestType type;
|
||||
|
||||
public SkyChestRenderingCustomizer( BlockSkyChest.SkyChestType type )
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
@Override
|
||||
public void customize( IBlockRendering rendering, IItemRendering itemRendering )
|
||||
{
|
||||
rendering.tesr( new SkyChestTESR() );
|
||||
|
||||
// Register a custom non-tesr item model
|
||||
String modelName = getModelFromType();
|
||||
itemRendering.model( new ModelResourceLocation( "appliedenergistics2:" + modelName, "inventory" ) );
|
||||
}
|
||||
|
||||
private String getModelFromType()
|
||||
{
|
||||
final String modelName;
|
||||
switch( type )
|
||||
{
|
||||
default:
|
||||
case STONE:
|
||||
modelName = "sky_chest_stone";
|
||||
break;
|
||||
case BLOCK:
|
||||
modelName = "sky_chest_block";
|
||||
break;
|
||||
}
|
||||
return modelName;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,216 @@
|
|||
package appeng.bootstrap;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.block.AEBaseItemBlock;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.CreativeTab;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.ActivityState;
|
||||
import appeng.core.features.BlockDefinition;
|
||||
import appeng.core.features.BlockStackSrc;
|
||||
import appeng.core.features.TileDefinition;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
class BlockDefinitionBuilder implements IBlockBuilder
|
||||
{
|
||||
|
||||
private final FeatureFactory factory;
|
||||
|
||||
private final String registryName;
|
||||
|
||||
private final Supplier<? extends Block> blockSupplier;
|
||||
|
||||
private final List<BiConsumer<Block, Item>> preInitCallbacks = new ArrayList<>();
|
||||
|
||||
private final List<BiConsumer<Block, Item>> initCallbacks = new ArrayList<>();
|
||||
|
||||
private final List<BiConsumer<Block, Item>> postInitCallbacks = new ArrayList<>();
|
||||
|
||||
private final EnumSet<AEFeature> features = EnumSet.noneOf( AEFeature.class );
|
||||
|
||||
private CreativeTabs creativeTab = CreativeTab.instance;
|
||||
|
||||
private Function<Block, ItemBlock> itemFactory;
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
private BlockRendering blockRendering;
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
private ItemRendering itemRendering;
|
||||
|
||||
BlockDefinitionBuilder( FeatureFactory factory, String id, Supplier<? extends Block> blockSupplier )
|
||||
{
|
||||
this.factory = factory;
|
||||
this.registryName = id;
|
||||
this.blockSupplier = blockSupplier;
|
||||
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
blockRendering = new BlockRendering();
|
||||
itemRendering = new ItemRendering();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockDefinitionBuilder preInit( BiConsumer<Block, Item> callback )
|
||||
{
|
||||
preInitCallbacks.add( callback );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockDefinitionBuilder init( BiConsumer<Block, Item> callback )
|
||||
{
|
||||
initCallbacks.add( callback );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockDefinitionBuilder postInit( BiConsumer<Block, Item> callback )
|
||||
{
|
||||
postInitCallbacks.add( callback );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockBuilder features( AEFeature... features )
|
||||
{
|
||||
this.features.clear();
|
||||
addFeatures( features );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockBuilder addFeatures( AEFeature... features )
|
||||
{
|
||||
Collections.addAll( this.features, features );
|
||||
return this;
|
||||
}
|
||||
|
||||
public BlockDefinitionBuilder rendering( BlockRenderingCustomizer callback )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
customizeForClient( callback );
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockBuilder item( Function<Block, ItemBlock> factory )
|
||||
{
|
||||
this.itemFactory = factory;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
private void customizeForClient( BlockRenderingCustomizer callback )
|
||||
{
|
||||
callback.customize( blockRendering, itemRendering );
|
||||
}
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
@Override
|
||||
public <T extends IBlockDefinition> T build()
|
||||
{
|
||||
if( !AEConfig.instance.areFeaturesEnabled( features ) )
|
||||
{
|
||||
return (T) new TileDefinition( registryName, null, null );
|
||||
}
|
||||
|
||||
// Create block and matching item, and set factory name of both
|
||||
Block block = blockSupplier.get();
|
||||
block.setRegistryName( AppEng.MOD_ID, registryName );
|
||||
|
||||
ItemBlock item = constructItemFromBlock( block );
|
||||
item.setRegistryName( AppEng.MOD_ID, registryName );
|
||||
|
||||
// Register the item and block with the game
|
||||
factory.addPreInit( side ->
|
||||
{
|
||||
GameRegistry.register( block );
|
||||
GameRegistry.register( item );
|
||||
} );
|
||||
|
||||
block.setCreativeTab( creativeTab );
|
||||
block.setUnlocalizedName( "appliedenergistics2." + registryName );
|
||||
|
||||
// Register all extra handlers
|
||||
preInitCallbacks.forEach( consumer -> factory.addPreInit( side -> consumer.accept( block, item ) ) );
|
||||
initCallbacks.forEach( consumer -> factory.addInit( side -> consumer.accept( block, item ) ) );
|
||||
postInitCallbacks.forEach( consumer -> factory.addPostInit( side -> consumer.accept( block, item ) ) );
|
||||
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
if( block instanceof AEBaseTileBlock )
|
||||
{
|
||||
AEBaseTileBlock tileBlock = (AEBaseTileBlock) block;
|
||||
blockRendering.apply( factory, block, tileBlock.getTileEntityClass() );
|
||||
}
|
||||
else
|
||||
{
|
||||
blockRendering.apply( factory, block, null );
|
||||
}
|
||||
|
||||
itemRendering.apply( factory, item );
|
||||
}
|
||||
|
||||
if( block instanceof AEBaseTileBlock )
|
||||
{
|
||||
AEBaseTileBlock tileBlock = (AEBaseTileBlock) block;
|
||||
|
||||
factory.addPreInit( side ->
|
||||
{
|
||||
Class<? extends AEBaseTile> tileEntityClass = tileBlock.getTileEntityClass();
|
||||
AEBaseTile.registerTileItem( tileEntityClass, new BlockStackSrc( block, 0, ActivityState.Enabled ) );
|
||||
|
||||
GameRegistry.registerTileEntity( tileEntityClass, registryName );
|
||||
} );
|
||||
|
||||
return (T) new TileDefinition( registryName, (AEBaseTileBlock) block, item );
|
||||
}
|
||||
else
|
||||
{
|
||||
return (T) new BlockDefinition( registryName, block, item );
|
||||
}
|
||||
}
|
||||
|
||||
private ItemBlock constructItemFromBlock( Block block )
|
||||
{
|
||||
if( itemFactory != null )
|
||||
{
|
||||
return itemFactory.apply( block );
|
||||
}
|
||||
else if( block instanceof AEBaseBlock )
|
||||
{
|
||||
return new AEBaseItemBlock( block );
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ItemBlock( block );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package appeng.bootstrap;
|
||||
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.statemap.IStateMapper;
|
||||
import net.minecraft.client.renderer.color.IBlockColor;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.bootstrap.components.BlockColorComponent;
|
||||
import appeng.bootstrap.components.StateMapperComponent;
|
||||
import appeng.bootstrap.components.TesrComponent;
|
||||
import appeng.client.render.model.CachingRotatingBakedModel;
|
||||
|
||||
|
||||
class BlockRendering implements IBlockRendering
|
||||
{
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
private BiFunction<ModelResourceLocation, IBakedModel, IBakedModel> modelCustomizer;
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
private IBlockColor blockColor;
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
private TileEntitySpecialRenderer<?> tesr;
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
private IStateMapper stateMapper;
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
public IBlockRendering modelCustomizer( BiFunction<ModelResourceLocation, IBakedModel, IBakedModel> customizer )
|
||||
{
|
||||
modelCustomizer = customizer;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
@Override
|
||||
public IBlockRendering blockColor( IBlockColor blockColor )
|
||||
{
|
||||
this.blockColor = blockColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
@Override
|
||||
public IBlockRendering tesr( TileEntitySpecialRenderer<?> tesr )
|
||||
{
|
||||
this.tesr = tesr;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
@Override
|
||||
public IBlockRendering stateMapper( IStateMapper mapper )
|
||||
{
|
||||
this.stateMapper = mapper;
|
||||
return this;
|
||||
}
|
||||
|
||||
void apply( FeatureFactory registry, Block block, Class<?> tileEntityClass )
|
||||
{
|
||||
if( tesr != null )
|
||||
{
|
||||
if( tileEntityClass == null )
|
||||
{
|
||||
throw new IllegalStateException( "Tried to register a TESR for " + block + " even though no tile entity has been specified." );
|
||||
}
|
||||
registry.addBootstrapComponent( new TesrComponent( tileEntityClass, tesr ) );
|
||||
}
|
||||
|
||||
if( modelCustomizer != null )
|
||||
{
|
||||
registry.modelOverrideComponent.addOverride( block.getRegistryName().getResourcePath(), modelCustomizer );
|
||||
}
|
||||
else if ( block instanceof AEBaseTileBlock )
|
||||
{
|
||||
// This is a default rotating model if the base-block uses an AE tile entity which exposes UP/FRONT as extended props
|
||||
registry.modelOverrideComponent.addOverride( block.getRegistryName().getResourcePath(), ( l, m ) -> new CachingRotatingBakedModel( m ) );
|
||||
}
|
||||
|
||||
if( blockColor != null )
|
||||
{
|
||||
registry.addBootstrapComponent( new BlockColorComponent( block, blockColor ) );
|
||||
}
|
||||
|
||||
if( stateMapper != null )
|
||||
{
|
||||
registry.addBootstrapComponent( new StateMapperComponent( block, stateMapper ) );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package appeng.bootstrap;
|
||||
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
||||
/**
|
||||
* A callback that allows the rendering of a block to be customized. Sadly this class is required and no lambdas can be used
|
||||
* due to them not being able to be annotated with @SideOnly(CLIENT).
|
||||
*/
|
||||
public abstract class BlockRenderingCustomizer
|
||||
{
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
public abstract void customize( IBlockRendering rendering, IItemRendering itemRendering );
|
||||
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
package appeng.bootstrap;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.AEColoredItemDefinition;
|
||||
import appeng.bootstrap.components.InitComponent;
|
||||
import appeng.bootstrap.components.ModelOverrideComponent;
|
||||
import appeng.bootstrap.components.PostInitComponent;
|
||||
import appeng.bootstrap.components.PreInitComponent;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.ActivityState;
|
||||
import appeng.core.features.ColoredItemDefinition;
|
||||
import appeng.core.features.ItemStackSrc;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class FeatureFactory
|
||||
{
|
||||
|
||||
private final AEFeature[] defaultFeatures;
|
||||
|
||||
private final List<IBootstrapComponent> bootstrapComponents;
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
ModelOverrideComponent modelOverrideComponent;
|
||||
|
||||
public FeatureFactory()
|
||||
{
|
||||
this.defaultFeatures = new AEFeature[] { AEFeature.Core };
|
||||
this.bootstrapComponents = new ArrayList<>();
|
||||
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
modelOverrideComponent = new ModelOverrideComponent();
|
||||
this.bootstrapComponents.add( modelOverrideComponent );
|
||||
}
|
||||
}
|
||||
|
||||
private FeatureFactory( FeatureFactory parent, AEFeature... defaultFeatures )
|
||||
{
|
||||
this.defaultFeatures = defaultFeatures.clone();
|
||||
this.bootstrapComponents = parent.bootstrapComponents;
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
this.modelOverrideComponent = parent.modelOverrideComponent;
|
||||
}
|
||||
}
|
||||
|
||||
public IBlockBuilder block( String id, Supplier<Block> block )
|
||||
{
|
||||
return new BlockDefinitionBuilder( this, id, block ).features( defaultFeatures );
|
||||
}
|
||||
|
||||
public IItemBuilder item( String id, Supplier<Item> item )
|
||||
{
|
||||
return new ItemDefinitionBuilder( this, id, item ).features( defaultFeatures );
|
||||
}
|
||||
|
||||
public AEColoredItemDefinition colored( IItemDefinition target, 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;
|
||||
}
|
||||
|
||||
public FeatureFactory features( AEFeature... features )
|
||||
{
|
||||
return new FeatureFactory( this, features );
|
||||
}
|
||||
|
||||
void addBootstrapComponent( IBootstrapComponent component )
|
||||
{
|
||||
this.bootstrapComponents.add( component );
|
||||
}
|
||||
|
||||
void addPreInit( PreInitComponent component )
|
||||
{
|
||||
this.bootstrapComponents.add( component );
|
||||
}
|
||||
|
||||
void addInit( InitComponent component )
|
||||
{
|
||||
this.bootstrapComponents.add( component );
|
||||
}
|
||||
|
||||
void addPostInit( PostInitComponent component )
|
||||
{
|
||||
this.bootstrapComponents.add( component );
|
||||
}
|
||||
|
||||
public List<IBootstrapComponent> getBootstrapComponents()
|
||||
{
|
||||
return bootstrapComponents;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package appeng.bootstrap;
|
||||
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
public interface IBlockBuilder
|
||||
{
|
||||
|
||||
IBlockBuilder preInit( BiConsumer<Block, Item> callback );
|
||||
|
||||
IBlockBuilder init( BiConsumer<Block, Item> callback );
|
||||
|
||||
IBlockBuilder postInit( BiConsumer<Block, Item> callback );
|
||||
|
||||
IBlockBuilder features( AEFeature... features );
|
||||
|
||||
IBlockBuilder addFeatures( AEFeature... features );
|
||||
|
||||
IBlockBuilder rendering( BlockRenderingCustomizer callback );
|
||||
|
||||
IBlockBuilder item( Function<Block, ItemBlock> factory );
|
||||
|
||||
<T extends IBlockDefinition> T build();
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package appeng.bootstrap;
|
||||
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.statemap.IStateMapper;
|
||||
import net.minecraft.client.renderer.color.IBlockColor;
|
||||
import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
||||
/**
|
||||
* Allows for client-side rendering to be customized in the context of block/item registration.
|
||||
*/
|
||||
public interface IBlockRendering
|
||||
{
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
IBlockRendering modelCustomizer( BiFunction<ModelResourceLocation, IBakedModel, IBakedModel> customizer );
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
IBlockRendering blockColor( IBlockColor blockColor );
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
IBlockRendering stateMapper( IStateMapper mapper );
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
IBlockRendering tesr( TileEntitySpecialRenderer<?> tesr );
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package appeng.bootstrap;
|
||||
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
|
||||
/**
|
||||
* Bootstrap components can be registered to take part in the various initialization phases of Forge.
|
||||
*/
|
||||
public interface IBootstrapComponent
|
||||
{
|
||||
|
||||
default void preInitialize( Side side )
|
||||
{
|
||||
}
|
||||
|
||||
default void initialize( Side side )
|
||||
{
|
||||
}
|
||||
|
||||
default void postInitialize( Side side )
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package appeng.bootstrap;
|
||||
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.ItemDefinition;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
/**
|
||||
* Allows an item to be defined and registered with the game.
|
||||
* The item is only registered once build is called.
|
||||
*/
|
||||
public interface IItemBuilder
|
||||
{
|
||||
|
||||
IItemBuilder features( AEFeature... features );
|
||||
|
||||
IItemBuilder addFeatures( AEFeature... features );
|
||||
|
||||
IItemBuilder creativeTab( CreativeTabs tab );
|
||||
|
||||
IItemBuilder rendering( ItemRenderingCustomizer callback );
|
||||
|
||||
ItemDefinition build();
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package appeng.bootstrap;
|
||||
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
||||
/**
|
||||
* Allows the rendering of an item to be customized.
|
||||
*/
|
||||
public interface IItemRendering
|
||||
{
|
||||
|
||||
/**
|
||||
* Registers a custom item mesh definition that will be used to dynamically determine the
|
||||
* item model to be used for rendering by inspecting the item stack (i.e. for NBT data).
|
||||
* Please
|
||||
*/
|
||||
@SideOnly( Side.CLIENT )
|
||||
IItemRendering meshDefinition( ItemMeshDefinition meshDefinition );
|
||||
|
||||
/**
|
||||
* Registers an item model for meta=0, see {@link #model(int, ModelResourceLocation)}.
|
||||
*/
|
||||
@SideOnly( Side.CLIENT )
|
||||
default IItemRendering model( ModelResourceLocation model )
|
||||
{
|
||||
return model( 0, model );
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an item model for a given meta.
|
||||
*/
|
||||
@SideOnly( Side.CLIENT )
|
||||
IItemRendering model( int meta, ModelResourceLocation model );
|
||||
|
||||
/**
|
||||
* Convenient override for {@link #variants(Collection)}.
|
||||
*/
|
||||
@SideOnly( Side.CLIENT )
|
||||
default IItemRendering variants( ResourceLocation... resources )
|
||||
{
|
||||
return variants( Arrays.asList( resources ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the item variants of this item. This are all models that need to be loaded for this item.
|
||||
* This has no direct effect on rendering, but is used to load models that are used for example by
|
||||
* the ItemMeshDefinition.
|
||||
*
|
||||
* Models registered via {@link #model(int, ModelResourceLocation)} are automatically added here.
|
||||
*/
|
||||
@SideOnly( Side.CLIENT )
|
||||
IItemRendering variants( Collection<ResourceLocation> resources );
|
||||
|
||||
/**
|
||||
* Registers a custom item color definition that inspects an item stack and tint and
|
||||
* returns a color multiplier.
|
||||
*/
|
||||
@SideOnly( Side.CLIENT )
|
||||
IItemRendering color( IItemColor itemColor );
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
package appeng.bootstrap;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.CreativeTab;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.ItemDefinition;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
class ItemDefinitionBuilder implements IItemBuilder
|
||||
{
|
||||
|
||||
private final FeatureFactory factory;
|
||||
|
||||
private final String registryName;
|
||||
|
||||
private final Supplier<Item> itemSupplier;
|
||||
|
||||
private final EnumSet<AEFeature> features = EnumSet.noneOf( AEFeature.class );
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
private ItemRendering itemRendering;
|
||||
|
||||
private CreativeTabs creativeTab = CreativeTab.instance;
|
||||
|
||||
ItemDefinitionBuilder( FeatureFactory factory, String registryName, Supplier<Item> itemSupplier )
|
||||
{
|
||||
this.factory = factory;
|
||||
this.registryName = registryName;
|
||||
this.itemSupplier = itemSupplier;
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
itemRendering = new ItemRendering();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemBuilder features( AEFeature... features )
|
||||
{
|
||||
this.features.clear();
|
||||
addFeatures( features );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemBuilder addFeatures( AEFeature... features )
|
||||
{
|
||||
Collections.addAll( this.features, features );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemBuilder creativeTab( CreativeTabs tab )
|
||||
{
|
||||
this.creativeTab = tab;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemBuilder rendering( ItemRenderingCustomizer callback )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
customizeForClient( callback );
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
private void customizeForClient( ItemRenderingCustomizer callback )
|
||||
{
|
||||
callback.customize( itemRendering );
|
||||
}
|
||||
|
||||
public ItemDefinition build()
|
||||
{
|
||||
if( !AEConfig.instance.areFeaturesEnabled( features ) )
|
||||
{
|
||||
return new ItemDefinition( registryName, null );
|
||||
}
|
||||
|
||||
Item item = itemSupplier.get();
|
||||
item.setRegistryName( AppEng.MOD_ID, registryName );
|
||||
|
||||
ItemDefinition definition = new ItemDefinition( registryName, item );
|
||||
|
||||
item.setUnlocalizedName( "appliedenergistics2." + registryName );
|
||||
item.setCreativeTab( creativeTab );
|
||||
|
||||
factory.addPreInit( side -> GameRegistry.register( item ) );
|
||||
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
itemRendering.apply( factory, item );
|
||||
}
|
||||
|
||||
return definition;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,140 @@
|
|||
package appeng.bootstrap;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
|
||||
import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.bootstrap.components.ItemColorComponent;
|
||||
import appeng.bootstrap.components.ItemMeshDefinitionComponent;
|
||||
import appeng.bootstrap.components.ItemModelComponent;
|
||||
import appeng.bootstrap.components.ItemVariantsComponent;
|
||||
|
||||
|
||||
class ItemRendering implements IItemRendering
|
||||
{
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
private IItemColor itemColor;
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
private ItemMeshDefinition itemMeshDefinition;
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
private Map<Integer, ModelResourceLocation> itemModels = new HashMap<>();
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
private Set<ResourceLocation> variants = new HashSet<>();
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public IItemRendering meshDefinition( ItemMeshDefinition meshDefinition )
|
||||
{
|
||||
this.itemMeshDefinition = meshDefinition;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public IItemRendering model( int meta, ModelResourceLocation model )
|
||||
{
|
||||
this.itemModels.put( meta, model );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemRendering variants( Collection<ResourceLocation> resources )
|
||||
{
|
||||
this.variants.addAll( resources );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public IItemRendering color( IItemColor itemColor )
|
||||
{
|
||||
this.itemColor = itemColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
void apply( FeatureFactory factory, Item item )
|
||||
{
|
||||
if( this.itemMeshDefinition != null )
|
||||
{
|
||||
factory.addBootstrapComponent( new ItemMeshDefinitionComponent( item, itemMeshDefinition ) );
|
||||
}
|
||||
|
||||
if( !this.itemModels.isEmpty() )
|
||||
{
|
||||
factory.addBootstrapComponent( new ItemModelComponent( item, this.itemModels ) );
|
||||
}
|
||||
|
||||
Set<ResourceLocation> resources = new HashSet<>( variants );
|
||||
|
||||
// Register a default item model if neither items by meta nor an item mesh definition exist
|
||||
if( this.itemMeshDefinition == null && this.itemModels.isEmpty() )
|
||||
{
|
||||
ModelResourceLocation model;
|
||||
|
||||
// For block items, the default will try to use the default state of the associated block
|
||||
if( item instanceof ItemBlock )
|
||||
{
|
||||
Block block = ( (ItemBlock) item ).getBlock();
|
||||
|
||||
// We can only do this once the blocks are actually registered...
|
||||
StateMapperHelper helper = new StateMapperHelper( block.getRegistryName() );
|
||||
model = helper.getModelResourceLocation( block.getDefaultState() );
|
||||
}
|
||||
else
|
||||
{
|
||||
model = new ModelResourceLocation( item.getRegistryName(), "inventory" );
|
||||
}
|
||||
|
||||
factory.addBootstrapComponent( new ItemModelComponent( item, ImmutableMap.of( 0, model ) ) );
|
||||
resources.add( model );
|
||||
}
|
||||
|
||||
if( !resources.isEmpty() )
|
||||
{
|
||||
factory.addBootstrapComponent( new ItemVariantsComponent( item, resources ) );
|
||||
}
|
||||
|
||||
if( itemColor != null )
|
||||
{
|
||||
factory.addBootstrapComponent( new ItemColorComponent( item, itemColor ) );
|
||||
}
|
||||
}
|
||||
|
||||
private static class StateMapperHelper extends StateMapperBase
|
||||
{
|
||||
|
||||
private final ResourceLocation registryName;
|
||||
|
||||
public StateMapperHelper( ResourceLocation registryName )
|
||||
{
|
||||
this.registryName = registryName;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ModelResourceLocation getModelResourceLocation( IBlockState state )
|
||||
{
|
||||
return new ModelResourceLocation( registryName, getPropertyString( state.getProperties() ) );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package appeng.bootstrap;
|
||||
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
||||
/**
|
||||
* A callback that allows the rendering of a item to be customized. Sadly this class is required and no lambdas can be used
|
||||
* due to them not being able to be annotated with @SideOnly(CLIENT).
|
||||
*/
|
||||
public abstract class ItemRenderingCustomizer
|
||||
{
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
public abstract void customize( IItemRendering rendering );
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package appeng.bootstrap.components;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.color.IBlockColor;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
|
||||
public class BlockColorComponent implements InitComponent
|
||||
{
|
||||
|
||||
private final Block block;
|
||||
|
||||
private final IBlockColor blockColor;
|
||||
|
||||
public BlockColorComponent( Block block, IBlockColor blockColor )
|
||||
{
|
||||
this.block = block;
|
||||
this.blockColor = blockColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize( Side side )
|
||||
{
|
||||
Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler( blockColor, block );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package appeng.bootstrap.components;
|
||||
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import appeng.bootstrap.IBootstrapComponent;
|
||||
|
||||
|
||||
@FunctionalInterface
|
||||
public interface InitComponent extends IBootstrapComponent
|
||||
{
|
||||
|
||||
@Override
|
||||
void initialize( Side side );
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package appeng.bootstrap.components;
|
||||
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
|
||||
public class ItemColorComponent implements InitComponent
|
||||
{
|
||||
|
||||
private final Item item;
|
||||
|
||||
private final IItemColor itemColor;
|
||||
|
||||
public ItemColorComponent( Item item, IItemColor itemColor )
|
||||
{
|
||||
this.item = item;
|
||||
this.itemColor = itemColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize( Side side )
|
||||
{
|
||||
Minecraft.getMinecraft().getItemColors().registerItemColorHandler( itemColor, item );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package appeng.bootstrap.components;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
|
||||
/**
|
||||
* Registers a custom item mesh definition that can be used to dynamically determine the item model based on
|
||||
* item stack properties.
|
||||
*/
|
||||
public class ItemMeshDefinitionComponent implements InitComponent
|
||||
{
|
||||
|
||||
private final Item item;
|
||||
|
||||
private final ItemMeshDefinition meshDefinition;
|
||||
|
||||
public ItemMeshDefinitionComponent( @Nonnull Item item, @Nonnull ItemMeshDefinition meshDefinition )
|
||||
{
|
||||
this.item = item;
|
||||
this.meshDefinition = meshDefinition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize( Side side )
|
||||
{
|
||||
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register( item, meshDefinition );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package appeng.bootstrap.components;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ItemModelMesher;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
|
||||
/**
|
||||
* Registers the models that should by used for an item, including the ability to
|
||||
* distinguish by meta.
|
||||
*/
|
||||
public class ItemModelComponent implements InitComponent
|
||||
{
|
||||
|
||||
private final Item item;
|
||||
|
||||
private final Map<Integer, ModelResourceLocation> modelsByMeta;
|
||||
|
||||
public ItemModelComponent( @Nonnull Item item, @Nonnull Map<Integer, ModelResourceLocation> modelsByMeta )
|
||||
{
|
||||
this.item = item;
|
||||
this.modelsByMeta = modelsByMeta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize( Side side )
|
||||
{
|
||||
ItemModelMesher itemMesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
|
||||
|
||||
modelsByMeta.forEach( ( meta, model ) ->
|
||||
{
|
||||
itemMesher.register( item, meta, model );
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package appeng.bootstrap.components;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import appeng.bootstrap.IBootstrapComponent;
|
||||
|
||||
|
||||
public class ItemVariantsComponent implements IBootstrapComponent
|
||||
{
|
||||
|
||||
private final Item item;
|
||||
|
||||
private final Collection<ResourceLocation> resources;
|
||||
|
||||
public ItemVariantsComponent( Item item, Collection<ResourceLocation> resources )
|
||||
{
|
||||
this.item = item;
|
||||
this.resources = resources;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInitialize( Side side )
|
||||
{
|
||||
ResourceLocation[] resourceArr = resources.toArray( new ResourceLocation[0] );
|
||||
ModelBakery.registerItemVariants( item, resourceArr );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package appeng.bootstrap.components;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
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.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
|
||||
public class ModelOverrideComponent implements PreInitComponent
|
||||
{
|
||||
|
||||
// Maps from resource path to customizer
|
||||
private final Map<String, BiFunction<ModelResourceLocation, IBakedModel, IBakedModel>> customizer = new HashMap<>();
|
||||
|
||||
public void addOverride( String resourcePath, BiFunction<ModelResourceLocation, IBakedModel, IBakedModel> customizer )
|
||||
{
|
||||
this.customizer.put( resourcePath, customizer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInitialize( Side side )
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register( this );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onModelBakeEvent( final ModelBakeEvent event )
|
||||
{
|
||||
IRegistry<ModelResourceLocation, IBakedModel> modelRegistry = event.getModelRegistry();
|
||||
Set<ModelResourceLocation> keys = Sets.newHashSet( modelRegistry.getKeys() );
|
||||
|
||||
for( ModelResourceLocation location : keys )
|
||||
{
|
||||
if( !location.getResourceDomain().equals( AppEng.MOD_ID ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
BiFunction<ModelResourceLocation, IBakedModel, IBakedModel> customizer = this.customizer.get( location.getResourcePath() );
|
||||
if( customizer != null )
|
||||
{
|
||||
IBakedModel orgModel = modelRegistry.getObject( location );
|
||||
IBakedModel newModel = customizer.apply( location, orgModel );
|
||||
|
||||
if( newModel != orgModel )
|
||||
{
|
||||
modelRegistry.putObject( location, newModel );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package appeng.bootstrap.components;
|
||||
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import appeng.bootstrap.IBootstrapComponent;
|
||||
|
||||
|
||||
@FunctionalInterface
|
||||
public interface PostInitComponent extends IBootstrapComponent
|
||||
{
|
||||
|
||||
@Override
|
||||
void postInitialize( Side side );
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package appeng.bootstrap.components;
|
||||
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import appeng.bootstrap.IBootstrapComponent;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface PreInitComponent extends IBootstrapComponent
|
||||
{
|
||||
|
||||
@Override
|
||||
void preInitialize( Side side );
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package appeng.bootstrap.components;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.statemap.IStateMapper;
|
||||
import net.minecraft.client.resources.IReloadableResourceManager;
|
||||
import net.minecraft.client.resources.IResourceManagerReloadListener;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
|
||||
/**
|
||||
* Registers a custom state mapper for a given block.
|
||||
*/
|
||||
public class StateMapperComponent implements InitComponent
|
||||
{
|
||||
|
||||
private final Block block;
|
||||
|
||||
private final IStateMapper stateMapper;
|
||||
|
||||
public StateMapperComponent( Block block, IStateMapper stateMapper )
|
||||
{
|
||||
this.block = block;
|
||||
this.stateMapper = stateMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize( Side side )
|
||||
{
|
||||
ModelLoader.setCustomStateMapper( block, stateMapper );
|
||||
if( stateMapper instanceof IResourceManagerReloadListener )
|
||||
{
|
||||
( (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager() ).registerReloadListener( (IResourceManagerReloadListener) stateMapper );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package appeng.bootstrap.components;
|
||||
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import appeng.tile.AEBaseTile;
|
||||
|
||||
|
||||
/**
|
||||
* Registers a TESR for a given tile entity class.
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public class TesrComponent<T extends AEBaseTile> implements PreInitComponent
|
||||
{
|
||||
|
||||
private final Class<T> tileEntityClass;
|
||||
|
||||
private final TileEntitySpecialRenderer<? super T> tesr;
|
||||
|
||||
public TesrComponent( Class<T> tileEntityClass, TileEntitySpecialRenderer<? super T> tesr )
|
||||
{
|
||||
this.tileEntityClass = tileEntityClass;
|
||||
this.tesr = tesr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInitialize( Side side )
|
||||
{
|
||||
ClientRegistry.bindTileEntitySpecialRenderer( tileEntityClass, tesr );
|
||||
}
|
||||
}
|
|
@ -29,15 +29,11 @@ import com.google.common.collect.ImmutableMap;
|
|||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.client.renderer.color.ItemColors;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.resources.IReloadableResourceManager;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumHand;
|
||||
|
@ -69,10 +65,8 @@ import appeng.client.render.model.UVLModelLoader;
|
|||
import appeng.client.render.textures.ParticleTextures;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.features.IAEFeature;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketAssemblerAnimation;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
|
@ -83,7 +77,6 @@ import appeng.entity.RenderTinyTNTPrimed;
|
|||
import appeng.helpers.IMouseWheelItem;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.hooks.TickHandler.PlayerColor;
|
||||
import appeng.items.misc.ItemPaintBall;
|
||||
import appeng.items.parts.PartType;
|
||||
import appeng.parts.AEBasePart;
|
||||
import appeng.server.ServerHelper;
|
||||
|
@ -100,10 +93,6 @@ public class ClientHelper extends ServerHelper
|
|||
MinecraftForge.EVENT_BUS.register( this );
|
||||
ModelLoaderRegistry.registerLoader( UVLModelLoader.INSTANCE );
|
||||
( (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager() ).registerReloadListener( ModelsCache.INSTANCE );
|
||||
for( IAEFeature feature : Api.INSTANCE.definitions().getFeatureRegistry().getRegisteredFeatures() )
|
||||
{
|
||||
feature.handler().registerStateMapper();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -127,15 +116,7 @@ public class ClientHelper extends ServerHelper
|
|||
// AELog.info( "Registering with %s with unlocalized %s", item, item.getUnlocalizedName() );
|
||||
// mesher.register( item, DEFAULT_ITEM_SUBTYPE, fluixStairModel );
|
||||
// }
|
||||
for( IAEFeature feature : Api.INSTANCE.definitions().getFeatureRegistry().getRegisteredFeatures() )
|
||||
{
|
||||
feature.handler().registerModel();
|
||||
}
|
||||
|
||||
// Register color handling for paintball items
|
||||
ItemColors itemColors = Minecraft.getMinecraft().getItemColors();
|
||||
Item paintballItem = Api.INSTANCE.definitions().items().paintBall().maybeItem().get();
|
||||
itemColors.registerItemColorHandler( ItemPaintBall::getColorFromItemstack, paintballItem );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -379,10 +360,6 @@ public class ClientHelper extends ServerHelper
|
|||
public void onModelBakeEvent( final ModelBakeEvent event )
|
||||
{
|
||||
UVLModelLoader.INSTANCE.setLoader( event.getModelLoader() );
|
||||
for( IAEFeature feature : Api.INSTANCE.definitions().getFeatureRegistry().getRegisteredFeatures() )
|
||||
{
|
||||
feature.handler().registerCustomModelOverride( event.getModelRegistry() );
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
@ -471,54 +448,4 @@ public class ClientHelper extends ServerHelper
|
|||
event.getMap().registerSprite( location );
|
||||
}
|
||||
}
|
||||
|
||||
private static class IconReg
|
||||
{
|
||||
public final String name;
|
||||
public final Object item;
|
||||
public final int meta;
|
||||
public final ModelResourceLocation loc;
|
||||
|
||||
public IconReg( final Object item2, final int meta2, final String name2 )
|
||||
{
|
||||
this.meta = meta2;
|
||||
this.name = name2;
|
||||
this.item = item2;
|
||||
this.loc = null;
|
||||
}
|
||||
|
||||
public IconReg( final Item item2, final int meta2, final String name2, final ModelResourceLocation res )
|
||||
{
|
||||
this.meta = meta2;
|
||||
this.name = name2;
|
||||
this.item = item2;
|
||||
this.loc = res;
|
||||
}
|
||||
}
|
||||
|
||||
public class ItemPaintBallColor implements IItemColor
|
||||
{
|
||||
|
||||
@Override
|
||||
public int getColorFromItemstack( ItemStack stack, int tintIndex )
|
||||
{
|
||||
final AEColor col = ( (ItemPaintBall) stack.getItem() ).getColor( stack );
|
||||
|
||||
final int colorValue = stack.getItemDamage() >= 20 ? col.mediumVariant : col.mediumVariant;
|
||||
final int r = ( colorValue >> 16 ) & 0xff;
|
||||
final int g = ( colorValue >> 8 ) & 0xff;
|
||||
final int b = ( colorValue ) & 0xff;
|
||||
|
||||
if( stack.getItemDamage() >= 20 )
|
||||
{
|
||||
final float fail = 0.7f;
|
||||
final int full = (int) ( 255 * 0.3 );
|
||||
return (int) ( full + r * fail ) << 16 | (int) ( full + g * fail ) << 8 | (int) ( full + b * fail ) | 0xff << 24;
|
||||
}
|
||||
else
|
||||
{
|
||||
return r << 16 | g << 8 | b | 0xff << 24;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
|
||||
package appeng.client.render.model;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.client.resources.IResourceManagerReloadListener;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
|
||||
public class AEIgnoringStateMapper extends StateMapperBase implements IResourceManagerReloadListener
|
||||
{
|
||||
|
||||
private final ResourceLocation ignoredRL;
|
||||
private final List<String> ignored = new ArrayList<>();
|
||||
|
||||
public AEIgnoringStateMapper( ResourceLocation ignoredRL )
|
||||
{
|
||||
this.ignoredRL = new ResourceLocation( ignoredRL.getResourceDomain(), "blockstates/" + ignoredRL.getResourcePath() + ".ignore.json" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload( IResourceManager resourceManager )
|
||||
{
|
||||
try
|
||||
{
|
||||
ignored.clear();
|
||||
ignored.add( "forward" );
|
||||
ignored.add( "up" );
|
||||
ignored.addAll( IOUtils.readLines( resourceManager.getResource( ignoredRL ).getInputStream() ) );
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
// There's no ignore file, so everything is ok.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ModelResourceLocation getModelResourceLocation( IBlockState state )
|
||||
{
|
||||
Map<IProperty<?>, Comparable<?>> map = Maps.<IProperty<?>, Comparable<?>>newLinkedHashMap( state.getProperties() );
|
||||
Iterator<Entry<IProperty<?>, Comparable<?>>> it = map.entrySet().iterator();
|
||||
while( it.hasNext() )
|
||||
{
|
||||
if( ignored.contains( it.next().getKey().getName() ) )
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
return new ModelResourceLocation( (ResourceLocation) Block.REGISTRY.getNameForObject( state.getBlock() ), this.getPropertyString( map ) );
|
||||
}
|
||||
|
||||
}
|
|
@ -12,6 +12,7 @@ import net.minecraft.block.state.IBlockState;
|
|||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
||||
import appeng.api.client.BakingPipelineElement;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
|
@ -26,10 +27,12 @@ public class DoubleFacingQuadRotator implements BakingPipelineElement<QuadVertex
|
|||
{
|
||||
if( state != null )
|
||||
{
|
||||
final EnumFacing forward = state.getValue( AEBaseTileBlock.AE_BLOCK_FORWARD );
|
||||
final EnumFacing up = state.getValue( AEBaseTileBlock.AE_BLOCK_UP );
|
||||
IExtendedBlockState extState = (IExtendedBlockState) state;
|
||||
|
||||
final EnumFacing forward = extState.getValue( AEBaseTileBlock.FORWARD );
|
||||
final EnumFacing up = extState.getValue( AEBaseTileBlock.UP );
|
||||
final FacingToRotation f2r = FacingToRotation.get( forward, up );
|
||||
List<QuadVertexData> rotated = new ArrayList();
|
||||
List<QuadVertexData> rotated = new ArrayList<>();
|
||||
for( QuadVertexData data : elements )
|
||||
{
|
||||
data.setFace( f2r.rotate( data.getFace() ) );
|
||||
|
|
|
@ -5,12 +5,14 @@ package appeng.client.render.tesr;
|
|||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.VertexBuffer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.client.render.FacingToRotation;
|
||||
import appeng.client.render.renderable.Renderable;
|
||||
import appeng.tile.AEBaseTile;
|
||||
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
public class ModularTESR<T extends AEBaseTile> extends TileEntitySpecialRenderer<T>
|
||||
{
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@ import net.minecraft.client.model.ModelChest;
|
|||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.block.storage.BlockSkyChest;
|
||||
import appeng.block.storage.BlockSkyChest.SkyChestType;
|
||||
|
@ -13,7 +15,7 @@ import appeng.client.render.FacingToRotation;
|
|||
import appeng.core.AppEng;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
public class SkyChestTESR extends TileEntitySpecialRenderer<TileSkyChest>
|
||||
{
|
||||
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package appeng.debug;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -30,7 +29,6 @@ import net.minecraftforge.common.ForgeChunkManager.Ticket;
|
|||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
public class BlockChunkloader extends AEBaseTileBlock implements LoadingCallback
|
||||
|
@ -41,7 +39,6 @@ public class BlockChunkloader extends AEBaseTileBlock implements LoadingCallback
|
|||
super( Material.IRON );
|
||||
this.setTileEntity( TileChunkLoader.class );
|
||||
ForgeChunkManager.setForcedChunkLoadingCallback( AppEng.instance(), this );
|
||||
this.setFeature( EnumSet.of( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
package appeng.debug;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -32,7 +30,6 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
public class BlockCubeGenerator extends AEBaseTileBlock
|
||||
|
@ -42,7 +39,6 @@ public class BlockCubeGenerator extends AEBaseTileBlock
|
|||
{
|
||||
super( Material.IRON );
|
||||
this.setTileEntity( TileCubeGenerator.class );
|
||||
this.setFeature( EnumSet.of( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,12 +19,9 @@
|
|||
package appeng.debug;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
public class BlockItemGen extends AEBaseTileBlock
|
||||
|
@ -34,7 +31,6 @@ public class BlockItemGen extends AEBaseTileBlock
|
|||
{
|
||||
super( Material.IRON );
|
||||
this.setTileEntity( TileItemGen.class );
|
||||
this.setFeature( EnumSet.of( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
package appeng.debug;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -32,7 +30,6 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
|
||||
public class BlockPhantomNode extends AEBaseTileBlock
|
||||
|
@ -42,7 +39,6 @@ public class BlockPhantomNode extends AEBaseTileBlock
|
|||
{
|
||||
super( Material.IRON );
|
||||
this.setTileEntity( TilePhantomNode.class );
|
||||
this.setFeature( EnumSet.of( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package appeng.debug;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -45,7 +44,6 @@ import appeng.api.networking.ticking.ITickManager;
|
|||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.me.Grid;
|
||||
|
@ -58,11 +56,6 @@ import appeng.util.Platform;
|
|||
|
||||
public class ToolDebugCard extends AEBaseItem
|
||||
{
|
||||
public ToolDebugCard()
|
||||
{
|
||||
this.setFeature( EnumSet.of( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUseFirst( final ItemStack heldItem, final EntityPlayer player, final World world, final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand )
|
||||
{
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package appeng.debug;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -33,7 +32,6 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
@ -43,11 +41,6 @@ public class ToolEraser extends AEBaseItem
|
|||
|
||||
private static final int BLOCK_ERASE_LIMIT = 90000;
|
||||
|
||||
public ToolEraser()
|
||||
{
|
||||
this.setFeature( EnumSet.of( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUseFirst( final ItemStack heldItem, final EntityPlayer player, final World world, final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand )
|
||||
{
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
package appeng.debug;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
|
@ -30,7 +28,6 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
import appeng.worldgen.MeteoritePlacer;
|
||||
|
@ -39,11 +36,6 @@ import appeng.worldgen.meteorite.StandardWorld;
|
|||
|
||||
public class ToolMeteoritePlacer extends AEBaseItem
|
||||
{
|
||||
public ToolMeteoritePlacer()
|
||||
{
|
||||
this.setFeature( EnumSet.of( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUseFirst( final ItemStack heldItem, final EntityPlayer player, final World world, final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand )
|
||||
{
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
package appeng.debug;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
|
@ -42,18 +40,12 @@ import appeng.api.networking.IGridNode;
|
|||
import appeng.api.networking.spatial.ISpatialCache;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ToolReplicatorCard extends AEBaseItem
|
||||
{
|
||||
public ToolReplicatorCard()
|
||||
{
|
||||
this.setFeature( EnumSet.of( AEFeature.UnsupportedDeveloperTools, AEFeature.Creative ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUseFirst( final ItemStack heldItem, final EntityPlayer player, final World world, final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand )
|
||||
{
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue