Splits AEBaseBlock into AEBaseBlock + AEBaseTileBlock
This commit is contained in:
@@ -22,27 +22,19 @@ 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 com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
@@ -52,17 +44,11 @@ import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.implementations.items.IMemoryCard;
|
||||
import appeng.api.implementations.items.MemoryCardMessages;
|
||||
import appeng.api.implementations.tiles.IColorableTile;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.block.networking.BlockCableBus;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.BlockRenderInfo;
|
||||
import appeng.client.render.WorldRender;
|
||||
@@ -73,33 +59,23 @@ import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.FeatureNameExtractor;
|
||||
import appeng.core.features.IAEFeature;
|
||||
import appeng.core.features.IFeatureHandler;
|
||||
import appeng.core.features.ItemStackSrc;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
import appeng.util.LookDirection;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.SettingsFrom;
|
||||
|
||||
|
||||
public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
public abstract class AEBaseBlock extends Block implements IAEFeature
|
||||
{
|
||||
private final String featureFullName;
|
||||
private final Optional<String> featureSubName;
|
||||
@SideOnly( Side.CLIENT )
|
||||
public IIcon renderIcon;
|
||||
protected final Optional<String> featureSubName;
|
||||
protected boolean isOpaque = true;
|
||||
protected boolean isFullSize = true;
|
||||
protected boolean hasSubtypes = false;
|
||||
protected boolean isInventory = false;
|
||||
private IFeatureHandler handler;
|
||||
@SideOnly( Side.CLIENT )
|
||||
BlockRenderInfo renderInfo;
|
||||
private IFeatureHandler handler;
|
||||
|
||||
@Nullable
|
||||
private Class<? extends TileEntity> tileEntityType = null;
|
||||
|
||||
protected AEBaseBlock( Material mat )
|
||||
{
|
||||
@@ -107,7 +83,6 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
this.setLightOpacity( 255 );
|
||||
this.setLightLevel( 0 );
|
||||
this.setHardness( 2.2F );
|
||||
this.setTileProvider( false );
|
||||
this.setHarvestLevel( "pickaxe", 0 );
|
||||
}
|
||||
|
||||
@@ -136,12 +111,6 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
this.featureSubName = subName;
|
||||
}
|
||||
|
||||
// update Block value.
|
||||
private void setTileProvider( boolean b )
|
||||
{
|
||||
ReflectionHelper.setPrivateValue( Block.class, this, b, "isTileProvider" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
@@ -150,8 +119,8 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
|
||||
public void registerNoIcons()
|
||||
{
|
||||
BlockRenderInfo info = this.getRendererInstance();
|
||||
FlippableIcon i = new FlippableIcon( new MissingIcon( this ) );
|
||||
final BlockRenderInfo info = this.getRendererInstance();
|
||||
final FlippableIcon i = new FlippableIcon( new MissingIcon( this ) );
|
||||
info.updateIcons( i, i, i, i, i, i );
|
||||
}
|
||||
|
||||
@@ -170,7 +139,7 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
|
||||
return this.renderInfo;
|
||||
}
|
||||
catch ( InstantiationException e )
|
||||
catch( InstantiationException e )
|
||||
{
|
||||
throw new IllegalStateException( "Failed to create a new instance of an illegal class " + this.getRenderer(), e );
|
||||
}
|
||||
@@ -191,23 +160,10 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
return super.getIcon( w, x, y, z, s );
|
||||
}
|
||||
|
||||
protected void setTileEntity( Class<? extends TileEntity> c )
|
||||
{
|
||||
this.tileEntityType = c;
|
||||
|
||||
AEBaseTile.registerTileItem( c, new ItemStackSrc( this, 0 ) );
|
||||
this.isInventory = IInventory.class.isAssignableFrom( c );
|
||||
this.setTileProvider( this.hasBlockTileEntity() );
|
||||
}
|
||||
|
||||
public boolean hasBlockTileEntity()
|
||||
{
|
||||
return this.tileEntityType != null;
|
||||
}
|
||||
|
||||
protected void setFeature( EnumSet<AEFeature> f )
|
||||
{
|
||||
this.handler = new AEBlockFeatureHandler( f, this, this.featureSubName );
|
||||
final AEBlockFeatureHandler featureHandler = new AEBlockFeatureHandler( f, this, this.featureSubName );
|
||||
this.setHandler( featureHandler );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -216,6 +172,11 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
return this.handler;
|
||||
}
|
||||
|
||||
protected final void setHandler( IFeatureHandler handler )
|
||||
{
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit()
|
||||
{
|
||||
@@ -250,33 +211,24 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
@SideOnly( Side.CLIENT )
|
||||
public IIcon getIcon( int direction, int metadata )
|
||||
{
|
||||
if( this.renderIcon != null )
|
||||
{
|
||||
return this.renderIcon;
|
||||
}
|
||||
|
||||
return this.getRendererInstance().getTexture( ForgeDirection.getOrientation( direction ) );
|
||||
}
|
||||
|
||||
protected ICustomCollision getCustomCollision( World w, int x, int y, int z )
|
||||
{
|
||||
if( this instanceof ICustomCollision )
|
||||
{
|
||||
return (ICustomCollision) this;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings( "unchecked" )
|
||||
// NOTE: WAS FINAL, changed for Immibis
|
||||
public void addCollisionBoxesToList( World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e )
|
||||
{
|
||||
ICustomCollision collisionHandler = null;
|
||||
|
||||
if( this instanceof ICustomCollision )
|
||||
{
|
||||
collisionHandler = (ICustomCollision) this;
|
||||
}
|
||||
else
|
||||
{
|
||||
AEBaseTile te = this.getTileEntity( w, x, y, z );
|
||||
if( te instanceof ICustomCollision )
|
||||
{
|
||||
collisionHandler = (ICustomCollision) te;
|
||||
}
|
||||
}
|
||||
final ICustomCollision collisionHandler = this.getCustomCollision( w, x, y, z );
|
||||
|
||||
if( collisionHandler != null && bb != null )
|
||||
{
|
||||
@@ -306,30 +258,16 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
@SideOnly( Side.CLIENT )
|
||||
public final AxisAlignedBB getSelectedBoundingBoxFromPool( World w, int x, int y, int z )
|
||||
{
|
||||
ICustomCollision collisionHandler = null;
|
||||
AxisAlignedBB b = null;
|
||||
|
||||
if( this instanceof ICustomCollision )
|
||||
{
|
||||
collisionHandler = (ICustomCollision) this;
|
||||
}
|
||||
else
|
||||
{
|
||||
AEBaseTile te = this.getTileEntity( w, x, y, z );
|
||||
if( te instanceof ICustomCollision )
|
||||
{
|
||||
collisionHandler = (ICustomCollision) te;
|
||||
}
|
||||
}
|
||||
final ICustomCollision collisionHandler = this.getCustomCollision( w, x, y, z );
|
||||
|
||||
if( collisionHandler != null )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
LookDirection ld = Platform.getPlayerRay( player, Platform.getEyeOffset( player ) );
|
||||
final EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
final LookDirection ld = Platform.getPlayerRay( player, Platform.getEyeOffset( player ) );
|
||||
|
||||
Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxesFromPool( w, x, y, z, Minecraft.getMinecraft().thePlayer, true );
|
||||
final Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxesFromPool( w, x, y, z, Minecraft.getMinecraft().thePlayer, true );
|
||||
AxisAlignedBB br = null;
|
||||
|
||||
double lastDist = 0;
|
||||
@@ -344,11 +282,12 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
|
||||
if( r != null )
|
||||
{
|
||||
double xLen = ( ld.a.xCoord - r.hitVec.xCoord );
|
||||
double yLen = ( ld.a.yCoord - r.hitVec.yCoord );
|
||||
double zLen = ( ld.a.zCoord - r.hitVec.zCoord );
|
||||
final double xLen = ( ld.a.xCoord - r.hitVec.xCoord );
|
||||
final double yLen = ( ld.a.yCoord - r.hitVec.yCoord );
|
||||
final double zLen = ( ld.a.zCoord - r.hitVec.zCoord );
|
||||
|
||||
final double thisDist = xLen * xLen + yLen * yLen + zLen * zLen;
|
||||
|
||||
double thisDist = xLen * xLen + yLen * yLen + zLen * zLen;
|
||||
if( br == null || lastDist > thisDist )
|
||||
{
|
||||
lastDist = thisDist;
|
||||
@@ -364,32 +303,26 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
}
|
||||
}
|
||||
|
||||
final AxisAlignedBB b = AxisAlignedBB.getBoundingBox( 16d, 16d, 16d, 0d, 0d, 0d );
|
||||
|
||||
for( AxisAlignedBB bx : collisionHandler.getSelectedBoundingBoxesFromPool( w, x, y, z, null, false ) )
|
||||
{
|
||||
if( b == null )
|
||||
{
|
||||
b = bx;
|
||||
}
|
||||
else
|
||||
{
|
||||
double minX = Math.min( b.minX, bx.minX );
|
||||
double minY = Math.min( b.minY, bx.minY );
|
||||
double minZ = Math.min( b.minZ, bx.minZ );
|
||||
double maxX = Math.max( b.maxX, bx.maxX );
|
||||
double maxY = Math.max( b.maxY, bx.maxY );
|
||||
double maxZ = Math.max( b.maxZ, bx.maxZ );
|
||||
b.setBounds( minX, minY, minZ, maxX, maxY, maxZ );
|
||||
}
|
||||
final double minX = Math.min( b.minX, bx.minX );
|
||||
final double minY = Math.min( b.minY, bx.minY );
|
||||
final double minZ = Math.min( b.minZ, bx.minZ );
|
||||
final double maxX = Math.max( b.maxX, bx.maxX );
|
||||
final double maxY = Math.max( b.maxY, bx.maxY );
|
||||
final double maxZ = Math.max( b.maxZ, bx.maxZ );
|
||||
|
||||
b.setBounds( minX, minY, minZ, maxX, maxY, maxZ );
|
||||
}
|
||||
|
||||
b.setBounds( b.minX + x, b.minY + y, b.minZ + z, b.maxX + x, b.maxY + y, b.maxZ + z );
|
||||
}
|
||||
else
|
||||
{
|
||||
b = super.getSelectedBoundingBoxFromPool( w, x, y, z );
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
return b;
|
||||
return super.getSelectedBoundingBoxFromPool( w, x, y, z );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -401,24 +334,11 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
@Override
|
||||
public MovingObjectPosition collisionRayTrace( World w, int x, int y, int z, Vec3 a, Vec3 b )
|
||||
{
|
||||
ICustomCollision collisionHandler = null;
|
||||
|
||||
if( this instanceof ICustomCollision )
|
||||
{
|
||||
collisionHandler = (ICustomCollision) this;
|
||||
}
|
||||
else
|
||||
{
|
||||
AEBaseTile te = this.getTileEntity( w, x, y, z );
|
||||
if( te instanceof ICustomCollision )
|
||||
{
|
||||
collisionHandler = (ICustomCollision) te;
|
||||
}
|
||||
}
|
||||
final ICustomCollision collisionHandler = this.getCustomCollision( w, x, y, z );
|
||||
|
||||
if( collisionHandler != null )
|
||||
{
|
||||
Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxesFromPool( w, x, y, z, null, true );
|
||||
final Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxesFromPool( w, x, y, z, null, true );
|
||||
MovingObjectPosition br = null;
|
||||
|
||||
double lastDist = 0;
|
||||
@@ -450,6 +370,7 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
{
|
||||
return br;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -457,114 +378,11 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
return super.collisionRayTrace( w, x, y, z, a, b );
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean onBlockActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
|
||||
{
|
||||
if( player != null )
|
||||
{
|
||||
ItemStack is = player.inventory.getCurrentItem();
|
||||
if( is != null )
|
||||
{
|
||||
if( Platform.isWrench( player, is, x, y, z ) && player.isSneaking() )
|
||||
{
|
||||
Block id = w.getBlock( x, y, z );
|
||||
if( id != null )
|
||||
{
|
||||
AEBaseTile tile = this.getTileEntity( w, x, y, z );
|
||||
ItemStack[] drops = Platform.getBlockDrops( w, x, y, z );
|
||||
|
||||
if( tile == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( tile instanceof TileCableBus || tile instanceof TileSkyChest )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemStack op = new ItemStack( this );
|
||||
for( ItemStack ol : drops )
|
||||
{
|
||||
if( Platform.isSameItemType( ol, op ) )
|
||||
{
|
||||
NBTTagCompound tag = tile.downloadSettings( SettingsFrom.DISMANTLE_ITEM );
|
||||
if( tag != null )
|
||||
{
|
||||
ol.setTagCompound( tag );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( id.removedByPlayer( w, player, x, y, z, false ) )
|
||||
{
|
||||
List<ItemStack> l = Lists.newArrayList( drops );
|
||||
Platform.spawnDrops( w, x, y, z, l );
|
||||
w.setBlockToAir( x, y, z );
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if( is.getItem() instanceof IMemoryCard && !( this instanceof BlockCableBus ) )
|
||||
{
|
||||
IMemoryCard memoryCard = (IMemoryCard) is.getItem();
|
||||
if( player.isSneaking() )
|
||||
{
|
||||
AEBaseTile t = this.getTileEntity( w, x, y, z );
|
||||
if( t != null )
|
||||
{
|
||||
String name = this.getUnlocalizedName();
|
||||
NBTTagCompound data = t.downloadSettings( SettingsFrom.MEMORY_CARD );
|
||||
if( data != null )
|
||||
{
|
||||
memoryCard.setMemoryCardContents( is, name, data );
|
||||
memoryCard.notifyUser( player, MemoryCardMessages.SETTINGS_SAVED );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
String name = memoryCard.getSettingsName( is );
|
||||
NBTTagCompound data = memoryCard.getData( is );
|
||||
if( this.getUnlocalizedName().equals( name ) )
|
||||
{
|
||||
AEBaseTile t = this.getTileEntity( w, x, y, z );
|
||||
t.uploadSettings( SettingsFrom.MEMORY_CARD, data );
|
||||
memoryCard.notifyUser( player, MemoryCardMessages.SETTINGS_LOADED );
|
||||
}
|
||||
else
|
||||
{
|
||||
memoryCard.notifyUser( player, MemoryCardMessages.INVALID_MACHINE );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.onActivated( w, x, y, z, player, side, hitX, hitY, hitZ );
|
||||
}
|
||||
|
||||
public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy( World w, int x, int y, int z, EntityLivingBase player, ItemStack is )
|
||||
{
|
||||
if( is.hasDisplayName() )
|
||||
{
|
||||
TileEntity te = this.getTileEntity( w, x, y, z );
|
||||
if( te instanceof AEBaseTile )
|
||||
{
|
||||
( (AEBaseTile) w.getTileEntity( x, y, z ) ).setName( is.getDisplayName() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
@SuppressWarnings( "unchecked" )
|
||||
@@ -582,11 +400,6 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
@Override
|
||||
public int getComparatorInputOverride( World w, int x, int y, int z, int s )
|
||||
{
|
||||
TileEntity te = this.getTileEntity( w, x, y, z );
|
||||
if( te instanceof IInventory )
|
||||
{
|
||||
return Container.calcRedstoneFromInventory( (IInventory) te );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -594,14 +407,14 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void registerBlockIcons( IIconRegister iconRegistry )
|
||||
{
|
||||
BlockRenderInfo info = this.getRendererInstance();
|
||||
FlippableIcon topIcon;
|
||||
FlippableIcon bottomIcon;
|
||||
FlippableIcon sideIcon;
|
||||
FlippableIcon eastIcon;
|
||||
FlippableIcon westIcon;
|
||||
FlippableIcon southIcon;
|
||||
FlippableIcon northIcon;
|
||||
final BlockRenderInfo info = this.getRendererInstance();
|
||||
final FlippableIcon topIcon;
|
||||
final FlippableIcon bottomIcon;
|
||||
final FlippableIcon sideIcon;
|
||||
final FlippableIcon eastIcon;
|
||||
final FlippableIcon westIcon;
|
||||
final FlippableIcon southIcon;
|
||||
final FlippableIcon northIcon;
|
||||
|
||||
this.blockIcon = topIcon = this.optionalIcon( iconRegistry, this.getTextureName(), null );
|
||||
bottomIcon = this.optionalIcon( iconRegistry, this.getTextureName() + "Bottom", topIcon );
|
||||
@@ -620,19 +433,19 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
return this.isFullSize;
|
||||
}
|
||||
|
||||
public IOrientable getOrientable( IBlockAccess w, int x, int y, int z )
|
||||
{
|
||||
if( this instanceof IOrientableBlock )
|
||||
{
|
||||
return ( (IOrientableBlock) this ).getOrientable( w, x, y, z );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean rotateBlock( World w, int x, int y, int z, ForgeDirection axis )
|
||||
{
|
||||
IOrientable rotatable = null;
|
||||
|
||||
if( this.hasBlockTileEntity() )
|
||||
{
|
||||
rotatable = (IOrientable) this.getTileEntity( w, x, y, z );
|
||||
}
|
||||
else if( this instanceof IOrientableBlock )
|
||||
{
|
||||
rotatable = ( (IOrientableBlock) this ).getOrientable( w, x, y, z );
|
||||
}
|
||||
final IOrientable rotatable = this.getOrientable( w, x, y, z );
|
||||
|
||||
if( rotatable != null && rotatable.canBeRotated() )
|
||||
{
|
||||
@@ -679,42 +492,11 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ForgeDirection[] getValidRotations( World w, int x, int y, int z )
|
||||
public ForgeDirection[] getValidRotations( World w, int x, int y, int z )
|
||||
{
|
||||
if( this.hasBlockTileEntity() )
|
||||
{
|
||||
AEBaseTile obj = this.getTileEntity( w, x, y, z );
|
||||
if( obj != null && obj.canBeRotated() )
|
||||
{
|
||||
return ForgeDirection.VALID_DIRECTIONS;
|
||||
}
|
||||
}
|
||||
|
||||
return new ForgeDirection[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recolourBlock( World world, int x, int y, int z, ForgeDirection side, int colour )
|
||||
{
|
||||
TileEntity te = this.getTileEntity( world, x, y, z );
|
||||
|
||||
if( te instanceof IColorableTile )
|
||||
{
|
||||
IColorableTile ct = (IColorableTile) te;
|
||||
AEColor c = ct.getColor();
|
||||
AEColor newColor = AEColor.values()[colour];
|
||||
|
||||
if( c != newColor )
|
||||
{
|
||||
ct.recolourBlock( side, newColor, null );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return super.recolourBlock( world, x, y, z, side, colour );
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
private FlippableIcon optionalIcon( IIconRegister ir, String name, IIcon substitute )
|
||||
{
|
||||
@@ -754,16 +536,7 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
|
||||
int mapRotation( IBlockAccess w, int x, int y, int z, int s )
|
||||
{
|
||||
IOrientable ori = null;
|
||||
|
||||
if( this.hasBlockTileEntity() )
|
||||
{
|
||||
ori = (IOrientable) this.getTileEntity( w, x, y, z );
|
||||
}
|
||||
else if( this instanceof IOrientableBlock )
|
||||
{
|
||||
ori = ( (IOrientableBlock) this ).getOrientable( w, x, y, z );
|
||||
}
|
||||
final IOrientable ori = this.getOrientable( w, x, y, z );
|
||||
|
||||
if( ori != null && ori.canBeRotated() )
|
||||
{
|
||||
@@ -773,23 +546,6 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
return s;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public <T extends TileEntity> T getTileEntity( IBlockAccess w, int x, int y, int z )
|
||||
{
|
||||
if( !this.hasBlockTileEntity() )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
TileEntity te = w.getTileEntity( x, y, z );
|
||||
if( this.tileEntityType.isInstance( te ) )
|
||||
{
|
||||
return (T) te;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ForgeDirection mapRotation( IOrientable ori, ForgeDirection dir )
|
||||
{
|
||||
// case DOWN: return bottomIcon;
|
||||
@@ -799,8 +555,8 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
// case WEST: return sideIcon;
|
||||
// case EAST: return sideIcon;
|
||||
|
||||
ForgeDirection forward = ori.getForward();
|
||||
ForgeDirection up = ori.getUp();
|
||||
final ForgeDirection forward = ori.getForward();
|
||||
final ForgeDirection up = ori.getUp();
|
||||
ForgeDirection west = ForgeDirection.UNKNOWN;
|
||||
|
||||
if( forward == null || up == null )
|
||||
@@ -850,66 +606,12 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
return ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
public Class<? extends TileEntity> getTileEntityClass()
|
||||
{
|
||||
return this.tileEntityType;
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void setRenderStateByMeta( int itemDamage )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public final TileEntity createNewTileEntity( World var1, int var2 )
|
||||
{
|
||||
if( this.hasBlockTileEntity() )
|
||||
{
|
||||
try
|
||||
{
|
||||
return this.tileEntityType.newInstance();
|
||||
}
|
||||
catch( InstantiationException e )
|
||||
{
|
||||
throw new IllegalStateException( "Failed to create a new instance of an illegal class " + this.tileEntityType , e );
|
||||
}
|
||||
catch( IllegalAccessException e )
|
||||
{
|
||||
throw new IllegalStateException( "Failed to create a new instance of " + this.tileEntityType + ", because lack of permissions", e );
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock( World w, int x, int y, int z, Block a, int b )
|
||||
{
|
||||
AEBaseTile te = this.getTileEntity( w, x, y, z );
|
||||
if( te != null )
|
||||
{
|
||||
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
|
||||
if( te.dropItems() )
|
||||
{
|
||||
te.getDrops( w, x, y, z, drops );
|
||||
}
|
||||
else
|
||||
{
|
||||
te.getNoDrops( w, x, y, z, drops );
|
||||
}
|
||||
|
||||
// Cry ;_; ...
|
||||
Platform.spawnDrops( w, x, y, z, drops );
|
||||
}
|
||||
|
||||
super.breakBlock( w, x, y, z, a, b );
|
||||
if( te != null )
|
||||
{
|
||||
w.setTileEntity( x, y, z, null );
|
||||
}
|
||||
}
|
||||
|
||||
public String getUnlocalizedName( ItemStack is )
|
||||
{
|
||||
return this.getUnlocalizedName();
|
||||
@@ -929,4 +631,5 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
{
|
||||
return this.hasSubtypes;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user