Relocate Source to proper directory.
This commit is contained in:
@@ -0,0 +1,806 @@
|
||||
package appeng.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import appeng.client.texture.FlippableIcon;
|
||||
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.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.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;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
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;
|
||||
import appeng.client.texture.MissingIcon;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.AEFeatureHandler;
|
||||
import appeng.core.features.IAEFeature;
|
||||
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;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class AEBaseBlock extends BlockContainer implements IAEFeature
|
||||
{
|
||||
|
||||
private String FeatureFullname;
|
||||
private String FeatureSubname;
|
||||
private AEFeatureHandler feature;
|
||||
|
||||
private Class<? extends TileEntity> tileEntityType = null;
|
||||
protected boolean isOpaque = true;
|
||||
protected boolean isFullSize = true;
|
||||
protected boolean hasSubtypes = false;
|
||||
protected boolean isInventory = false;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon renderIcon;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
BlockRenderInfo renderInfo;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return FeatureFullname;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return BaseBlockRender.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderType()
|
||||
{
|
||||
return WorldRender.instance.getRenderId();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private FlippableIcon optionalIcon(IIconRegister ir, String Name, IIcon substitute)
|
||||
{
|
||||
// if the input is an flippable IIcon find the original.
|
||||
while (substitute instanceof FlippableIcon)
|
||||
substitute = ((FlippableIcon) substitute).getOriginal();
|
||||
|
||||
if ( substitute != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
ResourceLocation resLoc = new ResourceLocation( Name );
|
||||
resLoc = new ResourceLocation( resLoc.getResourceDomain(), String.format( "%s/%s%s", new Object[] { "textures/blocks",
|
||||
resLoc.getResourcePath(), ".png" } ) );
|
||||
|
||||
IResource res = Minecraft.getMinecraft().getResourceManager().getResource( resLoc );
|
||||
if ( res != null )
|
||||
return new FlippableIcon( ir.registerIcon( Name ) );
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
return new FlippableIcon( substitute );
|
||||
}
|
||||
}
|
||||
|
||||
return new FlippableIcon( ir.registerIcon( Name ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconRegistry)
|
||||
{
|
||||
BlockRenderInfo info = getRendererInstance();
|
||||
FlippableIcon topIcon;
|
||||
FlippableIcon bottomIcon;
|
||||
FlippableIcon sideIcon;
|
||||
FlippableIcon eastIcon;
|
||||
FlippableIcon westIcon;
|
||||
FlippableIcon southIcon;
|
||||
FlippableIcon northIcon;
|
||||
|
||||
this.blockIcon = topIcon = optionalIcon( iconRegistry, this.getTextureName(), null );
|
||||
bottomIcon = optionalIcon( iconRegistry, this.getTextureName() + "Bottom", topIcon );
|
||||
sideIcon = optionalIcon( iconRegistry, this.getTextureName() + "Side", topIcon );
|
||||
eastIcon = optionalIcon( iconRegistry, this.getTextureName() + "East", sideIcon );
|
||||
westIcon = optionalIcon( iconRegistry, this.getTextureName() + "West", sideIcon );
|
||||
southIcon = optionalIcon( iconRegistry, this.getTextureName() + "Front", sideIcon );
|
||||
northIcon = optionalIcon( iconRegistry, this.getTextureName() + "Back", sideIcon );
|
||||
|
||||
info.updateIcons( bottomIcon, topIcon, northIcon, southIcon, eastIcon, westIcon );
|
||||
}
|
||||
|
||||
public void registerNoIcons()
|
||||
{
|
||||
BlockRenderInfo info = getRendererInstance();
|
||||
FlippableIcon i = new FlippableIcon( new MissingIcon( this ) );
|
||||
info.updateIcons( i, i, i, i, i, i );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int direction, int metadata)
|
||||
{
|
||||
if ( renderIcon != null )
|
||||
return renderIcon;
|
||||
|
||||
return getRendererInstance().getTexture( ForgeDirection.getOrientation( direction ) );
|
||||
}
|
||||
|
||||
public IIcon unmappedGetIcon(IBlockAccess w, int x, int y, int z, int s)
|
||||
{
|
||||
return super.getIcon( w, x, y, z, s );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess w, int x, int y, int z, int s)
|
||||
{
|
||||
return getIcon( mapRotation( w, x, y, z, s ), w.getBlockMetadata( x, y, z ) );
|
||||
}
|
||||
|
||||
protected void setTileEntity(Class<? extends TileEntity> c)
|
||||
{
|
||||
AEBaseTile.registerTileItem( c, new ItemStackSrc( this, 0 ) );
|
||||
GameRegistry.registerTileEntity( tileEntityType = c, FeatureFullname );
|
||||
isInventory = IInventory.class.isAssignableFrom( c );
|
||||
setTileProvider( hasBlockTileEntity() );
|
||||
}
|
||||
|
||||
protected void setFeature(EnumSet<AEFeature> f)
|
||||
{
|
||||
feature = new AEFeatureHandler( f, this, FeatureSubname );
|
||||
}
|
||||
|
||||
protected AEBaseBlock(Class<?> c, Material mat) {
|
||||
this( c, mat, null );
|
||||
setLightOpacity( 255 );
|
||||
setLightLevel( 0 );
|
||||
setHardness( 2.2F );
|
||||
setTileProvider( false );
|
||||
setHarvestLevel( "pickaxe", 0 );
|
||||
}
|
||||
|
||||
// update Block value.
|
||||
private void setTileProvider(boolean b)
|
||||
{
|
||||
ReflectionHelper.setPrivateValue( Block.class, this, b, "isTileProvider" );
|
||||
}
|
||||
|
||||
protected AEBaseBlock(Class<?> c, Material mat, String subname) {
|
||||
super( mat );
|
||||
|
||||
if ( mat == AEGlassMaterial.instance )
|
||||
setStepSound( Block.soundTypeGlass );
|
||||
else if ( mat == Material.glass )
|
||||
setStepSound( Block.soundTypeGlass );
|
||||
else if ( mat == Material.rock )
|
||||
setStepSound( Block.soundTypeStone );
|
||||
else
|
||||
setStepSound( Block.soundTypeMetal );
|
||||
|
||||
FeatureFullname = AEFeatureHandler.getName( c, subname );
|
||||
FeatureSubname = subname;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public AEFeatureHandler feature()
|
||||
{
|
||||
return feature;
|
||||
}
|
||||
|
||||
public boolean isOpaque()
|
||||
{
|
||||
return isOpaque;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public boolean isOpaqueCube()
|
||||
{
|
||||
return isOpaque;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return isFullSize && isOpaque;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public boolean isNormalCube(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
return isFullSize;
|
||||
}
|
||||
|
||||
public boolean hasBlockTileEntity()
|
||||
{
|
||||
return tileEntityType != null;
|
||||
}
|
||||
|
||||
public Class<? extends TileEntity> getTileEntityClass()
|
||||
{
|
||||
return tileEntityType;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void setRenderStateByMeta(int itemDamage)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public BlockRenderInfo getRendererInstance()
|
||||
{
|
||||
if ( renderInfo != null )
|
||||
return renderInfo;
|
||||
|
||||
try
|
||||
{
|
||||
return renderInfo = new BlockRenderInfo( getRenderer().newInstance() );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
throw new RuntimeException( t );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
final public TileEntity createNewTileEntity(World var1, int var2)
|
||||
{
|
||||
if ( hasBlockTileEntity() )
|
||||
{
|
||||
try
|
||||
{
|
||||
return tileEntityType.newInstance();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public <T extends TileEntity> T getTileEntity(IBlockAccess w, int x, int y, int z)
|
||||
{
|
||||
if ( !hasBlockTileEntity() )
|
||||
return null;
|
||||
|
||||
TileEntity te = w.getTileEntity( x, y, z );
|
||||
if ( tileEntityType.isInstance( te ) )
|
||||
return (T) te;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected boolean hasCustomRotation()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void customRotateBlock(IOrientable rotatable, ForgeDirection axis)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
final public boolean rotateBlock(World w, int x, int y, int z, ForgeDirection axis)
|
||||
{
|
||||
IOrientable rotatable = null;
|
||||
|
||||
if ( hasBlockTileEntity() )
|
||||
{
|
||||
rotatable = (AEBaseTile) getTileEntity( w, x, y, z );
|
||||
}
|
||||
else if ( this instanceof IOrientableBlock )
|
||||
{
|
||||
rotatable = ((IOrientableBlock) this).getOrientable( w, x, y, z );
|
||||
}
|
||||
|
||||
if ( rotatable != null && rotatable.canBeRotated() )
|
||||
{
|
||||
if ( hasCustomRotation() )
|
||||
{
|
||||
customRotateBlock( rotatable, axis );
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ForgeDirection forward = rotatable.getForward();
|
||||
ForgeDirection up = rotatable.getUp();
|
||||
|
||||
for (int rs = 0; rs < 4; rs++)
|
||||
{
|
||||
forward = Platform.rotateAround( forward, axis );
|
||||
up = Platform.rotateAround( up, axis );
|
||||
|
||||
if ( this.isValidOrientation( w, x, y, z, forward, up ) )
|
||||
{
|
||||
rotatable.setOrientation( forward, up );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.rotateBlock( w, x, y, z, axis );
|
||||
}
|
||||
|
||||
public ForgeDirection mapRotation(IOrientable ori, ForgeDirection dir)
|
||||
{
|
||||
// case DOWN: return bottomIcon;
|
||||
// case UP: return blockIcon;
|
||||
// case NORTH: return northIcon;
|
||||
// case SOUTH: return southIcon;
|
||||
// case WEST: return sideIcon;
|
||||
// case EAST: return sideIcon;
|
||||
|
||||
ForgeDirection forward = ori.getForward();
|
||||
ForgeDirection up = ori.getUp();
|
||||
ForgeDirection west = ForgeDirection.UNKNOWN;
|
||||
|
||||
if ( forward == null || up == null )
|
||||
return dir;
|
||||
|
||||
int west_x = forward.offsetY * up.offsetZ - forward.offsetZ * up.offsetY;
|
||||
int west_y = forward.offsetZ * up.offsetX - forward.offsetX * up.offsetZ;
|
||||
int west_z = forward.offsetX * up.offsetY - forward.offsetY * up.offsetX;
|
||||
|
||||
for (ForgeDirection dx : ForgeDirection.VALID_DIRECTIONS)
|
||||
if ( dx.offsetX == west_x && dx.offsetY == west_y && dx.offsetZ == west_z )
|
||||
west = dx;
|
||||
|
||||
if ( dir.equals( forward ) )
|
||||
return ForgeDirection.SOUTH;
|
||||
if ( dir.equals( forward.getOpposite() ) )
|
||||
return ForgeDirection.NORTH;
|
||||
|
||||
if ( dir.equals( up ) )
|
||||
return ForgeDirection.UP;
|
||||
if ( dir.equals( up.getOpposite() ) )
|
||||
return ForgeDirection.DOWN;
|
||||
|
||||
if ( dir.equals( west ) )
|
||||
return ForgeDirection.WEST;
|
||||
if ( dir.equals( west.getOpposite() ) )
|
||||
return ForgeDirection.EAST;
|
||||
|
||||
return ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
int mapRotation(IBlockAccess w, int x, int y, int z, int s)
|
||||
{
|
||||
IOrientable ori = null;
|
||||
|
||||
if ( hasBlockTileEntity() )
|
||||
{
|
||||
ori = (AEBaseTile) getTileEntity( w, x, y, z );
|
||||
}
|
||||
else if ( this instanceof IOrientableBlock )
|
||||
{
|
||||
ori = ((IOrientableBlock) this).getOrientable( w, x, y, z );
|
||||
}
|
||||
|
||||
if ( ori != null && ori.canBeRotated() )
|
||||
{
|
||||
return mapRotation( ori, ForgeDirection.getOrientation( s ) ).ordinal();
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public ForgeDirection[] getValidRotations(World w, int x, int y, int z)
|
||||
{
|
||||
if ( hasBlockTileEntity() )
|
||||
{
|
||||
AEBaseTile obj = getTileEntity( w, x, y, z );
|
||||
if ( obj != null && obj.canBeRotated() )
|
||||
{
|
||||
return ForgeDirection.VALID_DIRECTIONS;
|
||||
}
|
||||
}
|
||||
|
||||
return new ForgeDirection[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World w, int x, int y, int z, Block a, int b)
|
||||
{
|
||||
AEBaseTile te = 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 );
|
||||
}
|
||||
|
||||
@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 = getTileEntity( w, x, y, z );
|
||||
if ( te instanceof ICustomCollision )
|
||||
collisionHandler = (ICustomCollision) te;
|
||||
}
|
||||
|
||||
if ( collisionHandler != null )
|
||||
{
|
||||
Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxesFromPool( w, x, y, z, null, true );
|
||||
MovingObjectPosition br = null;
|
||||
|
||||
double lastDist = 0;
|
||||
|
||||
for (AxisAlignedBB bb : bbs)
|
||||
{
|
||||
setBlockBounds( (float) bb.minX, (float) bb.minY, (float) bb.minZ, (float) bb.maxX, (float) bb.maxY, (float) bb.maxZ );
|
||||
|
||||
MovingObjectPosition r = super.collisionRayTrace( w, x, y, z, a, b );
|
||||
|
||||
setBlockBounds( 0, 0, 0, 1, 1, 1 );
|
||||
|
||||
if ( r != null )
|
||||
{
|
||||
double xLen = (a.xCoord - r.hitVec.xCoord);
|
||||
double yLen = (a.yCoord - r.hitVec.yCoord);
|
||||
double zLen = (a.zCoord - r.hitVec.zCoord);
|
||||
|
||||
double thisDist = xLen * xLen + yLen * yLen + zLen * zLen;
|
||||
if ( br == null || lastDist > thisDist )
|
||||
{
|
||||
lastDist = thisDist;
|
||||
br = r;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( br != null )
|
||||
{
|
||||
return br;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
setBlockBounds( 0, 0, 0, 1, 1, 1 );
|
||||
return super.collisionRayTrace( w, x, y, z, a, b );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
final public 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 = getTileEntity( w, x, y, z );
|
||||
if ( te instanceof ICustomCollision )
|
||||
collisionHandler = (ICustomCollision) te;
|
||||
}
|
||||
|
||||
if ( collisionHandler != null )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
{
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
LookDirection ld = Platform.getPlayerRay( player, Platform.getEyeOffset( player ) );
|
||||
|
||||
Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxesFromPool( w, x, y, z, Minecraft.getMinecraft().thePlayer, true );
|
||||
AxisAlignedBB br = null;
|
||||
|
||||
double lastDist = 0;
|
||||
|
||||
for (AxisAlignedBB bb : bbs)
|
||||
{
|
||||
setBlockBounds( (float) bb.minX, (float) bb.minY, (float) bb.minZ, (float) bb.maxX, (float) bb.maxY, (float) bb.maxZ );
|
||||
|
||||
MovingObjectPosition r = super.collisionRayTrace( w, x, y, z, ld.a, ld.b );
|
||||
|
||||
setBlockBounds( 0, 0, 0, 1, 1, 1 );
|
||||
|
||||
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);
|
||||
|
||||
double thisDist = xLen * xLen + yLen * yLen + zLen * zLen;
|
||||
if ( br == null || lastDist > thisDist )
|
||||
{
|
||||
lastDist = thisDist;
|
||||
br = bb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( br != null )
|
||||
{
|
||||
br.setBounds( br.minX + x, br.minY + y, br.minZ + z, br.maxX + x, br.maxY + y, br.maxZ + z );
|
||||
return br;
|
||||
}
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
// 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 = getTileEntity( w, x, y, z );
|
||||
if ( te instanceof ICustomCollision )
|
||||
collisionHandler = (ICustomCollision) te;
|
||||
}
|
||||
|
||||
if ( collisionHandler != null && bb != null )
|
||||
{
|
||||
List<AxisAlignedBB> tmp = new ArrayList<AxisAlignedBB>();
|
||||
collisionHandler.addCollidingBlockToList( w, x, y, z, bb, tmp, e );
|
||||
for (AxisAlignedBB b : tmp)
|
||||
{
|
||||
b.minX += x;
|
||||
b.minY += y;
|
||||
b.minZ += z;
|
||||
b.maxX += x;
|
||||
b.maxY += y;
|
||||
b.maxZ += z;
|
||||
if ( bb.intersectsWith( b ) )
|
||||
out.add( b );
|
||||
}
|
||||
}
|
||||
else
|
||||
super.addCollisionBoxesToList( w, x, y, z, bb, out, e );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
super.onBlockDestroyedByPlayer( par1World, par2, par3, par4, par5 );
|
||||
}
|
||||
|
||||
public boolean onActivated(World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public 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 = 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 = new ArrayList<ItemStack>();
|
||||
for (ItemStack iss : drops)
|
||||
l.add( iss );
|
||||
Platform.spawnDrops( w, x, y, z, l );
|
||||
w.setBlockToAir( x, y, z );
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( is.getItem() instanceof IMemoryCard && !(this instanceof BlockCableBus) )
|
||||
{
|
||||
IMemoryCard memc = (IMemoryCard) is.getItem();
|
||||
if ( player.isSneaking() )
|
||||
{
|
||||
AEBaseTile t = getTileEntity( w, x, y, z );
|
||||
if ( t != null )
|
||||
{
|
||||
String name = getUnlocalizedName();
|
||||
NBTTagCompound data = t.downloadSettings( SettingsFrom.MEMORY_CARD );
|
||||
if ( data != null )
|
||||
{
|
||||
memc.setMemoryCardContents( is, name, data );
|
||||
memc.notifyUser( player, MemoryCardMessages.SETTINGS_SAVED );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
String name = memc.getSettingsName( is );
|
||||
NBTTagCompound data = memc.getData( is );
|
||||
if ( getUnlocalizedName().equals( name ) )
|
||||
{
|
||||
AEBaseTile t = getTileEntity( w, x, y, z );
|
||||
t.uploadSettings( SettingsFrom.MEMORY_CARD, data );
|
||||
memc.notifyUser( player, MemoryCardMessages.SETTINGS_LOADED );
|
||||
}
|
||||
else
|
||||
memc.notifyUser( player, MemoryCardMessages.INVALID_MACHINE );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return onActivated( w, x, y, z, player, side, hitX, hitY, hitZ );
|
||||
}
|
||||
|
||||
public boolean isValidOrientation(World w, int x, int y, int z, ForgeDirection forward, ForgeDirection up)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getUnlocalizedName(ItemStack is)
|
||||
{
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
public void addInformation(ItemStack is, EntityPlayer player, List<?> lines, boolean advancedItemTooltips)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Class<AEBaseItemBlock> getItemBlockClass()
|
||||
{
|
||||
return AEBaseItemBlock.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit()
|
||||
{
|
||||
// override!
|
||||
}
|
||||
|
||||
public boolean hasSubtypes()
|
||||
{
|
||||
return hasSubtypes;
|
||||
}
|
||||
|
||||
public boolean hasComparatorInputOverride()
|
||||
{
|
||||
return isInventory;
|
||||
}
|
||||
|
||||
public int getComparatorInputOverride(World w, int x, int y, int z, int s)
|
||||
{
|
||||
TileEntity te = getTileEntity( w, x, y, z );
|
||||
if ( te instanceof IInventory )
|
||||
return Container.calcRedstoneFromInventory( (IInventory) te );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour)
|
||||
{
|
||||
TileEntity te = 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 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World w, int x, int y, int z, EntityLivingBase player, ItemStack is)
|
||||
{
|
||||
if ( is.hasDisplayName() )
|
||||
{
|
||||
TileEntity te = getTileEntity( w, x, y, z );
|
||||
if ( te instanceof AEBaseTile )
|
||||
((AEBaseTile) w.getTileEntity( x, y, z )).setName( is.getDisplayName() );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
package appeng.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.block.misc.BlockLightDetector;
|
||||
import appeng.block.misc.BlockSkyCompass;
|
||||
import appeng.block.networking.BlockWireless;
|
||||
import appeng.client.render.ItemRenderer;
|
||||
import appeng.me.helpers.IGridProxyable;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class AEBaseItemBlock extends ItemBlock
|
||||
{
|
||||
|
||||
final AEBaseBlock blockType;
|
||||
|
||||
public AEBaseItemBlock(Block id) {
|
||||
super( id );
|
||||
blockType = (AEBaseBlock) id;
|
||||
hasSubtypes = blockType.hasSubtypes;
|
||||
|
||||
if ( Platform.isClient() )
|
||||
MinecraftForgeClient.registerItemRenderer( this, ItemRenderer.instance );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int dmg)
|
||||
{
|
||||
if ( hasSubtypes )
|
||||
return dmg;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack is)
|
||||
{
|
||||
return blockType.getUnlocalizedName( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack is, EntityPlayer player, List lines, boolean advancedItemTooltips)
|
||||
{
|
||||
blockType.addInformation( is, player, lines, advancedItemTooltips );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World w, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
|
||||
{
|
||||
ForgeDirection up = ForgeDirection.UNKNOWN;
|
||||
ForgeDirection forward = ForgeDirection.UNKNOWN;
|
||||
|
||||
IOrientable ori = null;
|
||||
|
||||
if ( blockType.hasBlockTileEntity() )
|
||||
{
|
||||
if ( blockType instanceof BlockLightDetector )
|
||||
{
|
||||
up = ForgeDirection.getOrientation( side );
|
||||
if ( up == ForgeDirection.UP || up == ForgeDirection.DOWN )
|
||||
forward = ForgeDirection.SOUTH;
|
||||
else
|
||||
forward = ForgeDirection.UP;
|
||||
}
|
||||
else if ( blockType instanceof BlockWireless || blockType instanceof BlockSkyCompass )
|
||||
{
|
||||
forward = ForgeDirection.getOrientation( side );
|
||||
if ( forward == ForgeDirection.UP || forward == ForgeDirection.DOWN )
|
||||
up = ForgeDirection.SOUTH;
|
||||
else
|
||||
up = ForgeDirection.UP;
|
||||
}
|
||||
else
|
||||
{
|
||||
up = ForgeDirection.UP;
|
||||
|
||||
byte rotation = (byte) (MathHelper.floor_double( (double) ((player.rotationYaw * 4F) / 360F) + 2.5D ) & 3);
|
||||
|
||||
switch (rotation)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
forward = ForgeDirection.SOUTH;
|
||||
break;
|
||||
case 1:
|
||||
forward = ForgeDirection.WEST;
|
||||
break;
|
||||
case 2:
|
||||
forward = ForgeDirection.NORTH;
|
||||
break;
|
||||
case 3:
|
||||
forward = ForgeDirection.EAST;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( player.rotationPitch > 65 )
|
||||
{
|
||||
up = forward.getOpposite();
|
||||
forward = ForgeDirection.UP;
|
||||
}
|
||||
else if ( player.rotationPitch < -65 )
|
||||
{
|
||||
up = forward.getOpposite();
|
||||
forward = ForgeDirection.DOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( blockType instanceof IOrientableBlock )
|
||||
{
|
||||
ori = ((IOrientableBlock) blockType).getOrientable( w, x, y, z );
|
||||
up = ForgeDirection.getOrientation( side );
|
||||
forward = ForgeDirection.SOUTH;
|
||||
if ( up.offsetY == 0 )
|
||||
forward = ForgeDirection.UP;
|
||||
|
||||
ori.setOrientation( forward, up );
|
||||
}
|
||||
|
||||
if ( !blockType.isValidOrientation( w, x, y, z, forward, up ) )
|
||||
return false;
|
||||
|
||||
if ( super.placeBlockAt( stack, player, w, x, y, z, side, hitX, hitY, hitZ, metadata ) )
|
||||
{
|
||||
if ( blockType.hasBlockTileEntity() && !(blockType instanceof BlockLightDetector) )
|
||||
{
|
||||
AEBaseTile tile = blockType.getTileEntity( w, x, y, z );
|
||||
ori = tile;
|
||||
|
||||
if ( tile == null )
|
||||
return true;
|
||||
|
||||
if ( ori.canBeRotated() && !blockType.hasCustomRotation() )
|
||||
{
|
||||
if ( ori.getForward() == null || ori.getUp() == null || // null
|
||||
tile.getForward() == ForgeDirection.UNKNOWN || ori.getUp() == ForgeDirection.UNKNOWN )
|
||||
ori.setOrientation( forward, up );
|
||||
}
|
||||
|
||||
if ( tile instanceof IGridProxyable )
|
||||
{
|
||||
((IGridProxyable) tile).getProxy().setOwner( player );
|
||||
}
|
||||
|
||||
tile.onPlacement( stack, player, side );
|
||||
}
|
||||
else if ( blockType instanceof IOrientableBlock )
|
||||
{
|
||||
ori.setOrientation( forward, up );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBookEnchantable(ItemStack itemstack1, ItemStack itemstack2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package appeng.block;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class AEBaseItemBlockChargeable extends AEBaseItemBlock implements IAEItemPowerStorage
|
||||
{
|
||||
|
||||
public AEBaseItemBlockChargeable(Block id) {
|
||||
super( id );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack is, EntityPlayer player, List lines, boolean advancedItemTooltips)
|
||||
{
|
||||
NBTTagCompound tag = is.getTagCompound();
|
||||
double internalCurrentPower = 0;
|
||||
double internalMaxPower = getMax( is );
|
||||
|
||||
if ( tag != null )
|
||||
{
|
||||
internalCurrentPower = tag.getDouble( "internalCurrentPower" );
|
||||
}
|
||||
|
||||
double percent = internalCurrentPower / internalMaxPower;
|
||||
|
||||
lines.add( GuiText.StoredEnergy.getLocal() + ":" + MessageFormat.format( " {0,number,#} ", internalCurrentPower )
|
||||
+ Platform.gui_localize( PowerUnits.AE.unlocalizedName ) + " - " + MessageFormat.format( " {0,number,#.##%} ", percent ) );
|
||||
|
||||
}
|
||||
|
||||
private double getMax(ItemStack is)
|
||||
{
|
||||
Block blk = Block.getBlockFromItem( this );
|
||||
if ( blk == AEApi.instance().blocks().blockEnergyCell.block() )
|
||||
return 200000;
|
||||
else
|
||||
return 8 * 200000;
|
||||
}
|
||||
|
||||
private double getInternal(ItemStack is)
|
||||
{
|
||||
NBTTagCompound nbt = Platform.openNbtData( is );
|
||||
return nbt.getDouble( "internalCurrentPower" );
|
||||
}
|
||||
|
||||
private void setInternal(ItemStack is, double amt)
|
||||
{
|
||||
NBTTagCompound nbt = Platform.openNbtData( is );
|
||||
nbt.setDouble( "internalCurrentPower", amt );
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectAEPower(ItemStack is, double amt)
|
||||
{
|
||||
double internalCurrentPower = getInternal( is );
|
||||
double internalMaxPower = getMax( is );
|
||||
internalCurrentPower += amt;
|
||||
if ( internalCurrentPower > internalMaxPower )
|
||||
{
|
||||
amt = internalCurrentPower - internalMaxPower;
|
||||
internalCurrentPower = internalMaxPower;
|
||||
setInternal( is, internalCurrentPower );
|
||||
return amt;
|
||||
}
|
||||
|
||||
setInternal( is, internalCurrentPower );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower(ItemStack is, double amt)
|
||||
{
|
||||
double internalCurrentPower = getInternal( is );
|
||||
if ( internalCurrentPower > amt )
|
||||
{
|
||||
internalCurrentPower -= amt;
|
||||
setInternal( is, internalCurrentPower );
|
||||
return amt;
|
||||
}
|
||||
|
||||
amt = internalCurrentPower;
|
||||
setInternal( is, 0 );
|
||||
return amt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAEMaxPower(ItemStack is)
|
||||
{
|
||||
double internalMaxPower = getMax( is );
|
||||
return internalMaxPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAECurrentPower(ItemStack is)
|
||||
{
|
||||
double internalCurrentPower = getInternal( is );
|
||||
return internalCurrentPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessRestriction getPowerFlow(ItemStack is)
|
||||
{
|
||||
return AccessRestriction.WRITE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package appeng.block;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class AEDecorativeBlock extends AEBaseBlock
|
||||
{
|
||||
|
||||
protected AEDecorativeBlock(Class<?> c, Material mat) {
|
||||
super( c, mat );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess w, int x, int y, int z, int s)
|
||||
{
|
||||
return super.unmappedGetIcon( w, x, y, z, s );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package appeng.block.crafting;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockCraftingCPUMonitor;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.tile.crafting.TileCraftingMonitorTile;
|
||||
|
||||
public class BlockCraftingMonitor extends BlockCraftingUnit
|
||||
{
|
||||
|
||||
public BlockCraftingMonitor() {
|
||||
super( BlockCraftingMonitor.class );
|
||||
setTileEntity( TileCraftingMonitorTile.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderBlockCraftingCPUMonitor.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int direction, int metadata)
|
||||
{
|
||||
if ( direction != ForgeDirection.SOUTH.ordinal() )
|
||||
return AEApi.instance().blocks().blockCraftingUnit.block().getIcon( direction, metadata );
|
||||
|
||||
switch (metadata)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
return super.getIcon( 0, 0 );
|
||||
case 0 | FLAG_FORMED:
|
||||
return ExtraBlockTextures.BlockCraftingMonitorFit_Light.getIcon();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item i, CreativeTabs c, List l)
|
||||
{
|
||||
l.add( new ItemStack( this, 1, 0 ) );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package appeng.block.crafting;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.tile.crafting.TileCraftingStorageTile;
|
||||
|
||||
public class BlockCraftingStorage extends BlockCraftingUnit
|
||||
{
|
||||
|
||||
public BlockCraftingStorage() {
|
||||
super( BlockCraftingStorage.class );
|
||||
setTileEntity( TileCraftingStorageTile.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getItemBlockClass()
|
||||
{
|
||||
return ItemCraftingStorage.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack is)
|
||||
{
|
||||
if ( is.getItemDamage() == 1 )
|
||||
return "tile.appliedenergistics2.BlockCraftingStorage4k";
|
||||
|
||||
if ( is.getItemDamage() == 2 )
|
||||
return "tile.appliedenergistics2.BlockCraftingStorage16k";
|
||||
|
||||
if ( is.getItemDamage() == 3 )
|
||||
return "tile.appliedenergistics2.BlockCraftingStorage64k";
|
||||
|
||||
return getItemUnlocalizedName( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int direction, int metadata)
|
||||
{
|
||||
switch (metadata & (~4))
|
||||
{
|
||||
default:
|
||||
|
||||
case 0:
|
||||
return super.getIcon( 0, 0 );
|
||||
case 1:
|
||||
return ExtraBlockTextures.BlockCraftingStorage4k.getIcon();
|
||||
case 2:
|
||||
return ExtraBlockTextures.BlockCraftingStorage16k.getIcon();
|
||||
case 3:
|
||||
return ExtraBlockTextures.BlockCraftingStorage64k.getIcon();
|
||||
|
||||
case 0 | FLAG_FORMED:
|
||||
return ExtraBlockTextures.BlockCraftingStorage1kFit.getIcon();
|
||||
case 1 | FLAG_FORMED:
|
||||
return ExtraBlockTextures.BlockCraftingStorage4kFit.getIcon();
|
||||
case 2 | FLAG_FORMED:
|
||||
return ExtraBlockTextures.BlockCraftingStorage16kFit.getIcon();
|
||||
case 3 | FLAG_FORMED:
|
||||
return ExtraBlockTextures.BlockCraftingStorage64kFit.getIcon();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item i, CreativeTabs c, List l)
|
||||
{
|
||||
l.add( new ItemStack( this, 1, 0 ) );
|
||||
l.add( new ItemStack( this, 1, 1 ) );
|
||||
l.add( new ItemStack( this, 1, 2 ) );
|
||||
l.add( new ItemStack( this, 1, 3 ) );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package appeng.block.crafting;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
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.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockCraftingCPU;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.crafting.TileCraftingTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockCraftingUnit extends AEBaseBlock
|
||||
{
|
||||
|
||||
public static final int FLAG_FORMED = 8;
|
||||
public static final int FLAG_POWERED = 4;
|
||||
|
||||
public BlockCraftingUnit(Class<? extends BlockCraftingUnit> childClass) {
|
||||
super( childClass, Material.iron );
|
||||
hasSubtypes = true;
|
||||
setFeature( EnumSet.of( AEFeature.CraftingCPU ) );
|
||||
}
|
||||
|
||||
public BlockCraftingUnit() {
|
||||
this( BlockCraftingUnit.class );
|
||||
setTileEntity( TileCraftingTile.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
TileCraftingTile tg = getTileEntity( w, x, y, z );
|
||||
if ( tg != null && !p.isSneaking() && tg.isFormed() && tg.isActive() )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return true;
|
||||
|
||||
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_CRAFTING_CPU );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDamageValue(World w, int x, int y, int z)
|
||||
{
|
||||
int meta = w.getBlockMetadata( x, y, z );
|
||||
return damageDropped( meta );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int meta)
|
||||
{
|
||||
return meta & 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack is)
|
||||
{
|
||||
if ( is.getItemDamage() == 1 )
|
||||
return "tile.appliedenergistics2.BlockCraftingAccelerator";
|
||||
|
||||
return getItemUnlocalizedName( is );
|
||||
}
|
||||
|
||||
protected String getItemUnlocalizedName(ItemStack is)
|
||||
{
|
||||
return super.getUnlocalizedName( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRenderStateByMeta(int itemDamage)
|
||||
{
|
||||
IIcon front = getIcon( ForgeDirection.SOUTH.ordinal(), itemDamage );
|
||||
IIcon other = getIcon( ForgeDirection.NORTH.ordinal(), itemDamage );
|
||||
getRendererInstance().setTemporaryRenderIcons( other, other, front, other, other, other );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int direction, int metadata)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
return super.getIcon( 0, 0 );
|
||||
case 1:
|
||||
return ExtraBlockTextures.BlockCraftingAccelerator.getIcon();
|
||||
case 0 | FLAG_FORMED:
|
||||
return ExtraBlockTextures.BlockCraftingUnitFit.getIcon();
|
||||
case 1 | FLAG_FORMED:
|
||||
return ExtraBlockTextures.BlockCraftingAcceleratorFit.getIcon();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderBlockCraftingCPU.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World w, int x, int y, int z, Block a, int b)
|
||||
{
|
||||
TileCraftingTile cp = getTileEntity( w, x, y, z );
|
||||
if ( cp != null )
|
||||
cp.breakCluster();
|
||||
|
||||
super.breakBlock( w, x, y, z, a, b );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World w, int x, int y, int z, Block junk)
|
||||
{
|
||||
TileCraftingTile cp = getTileEntity( w, x, y, z );
|
||||
if ( cp != null )
|
||||
cp.updateMultiBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item i, CreativeTabs c, List l)
|
||||
{
|
||||
l.add( new ItemStack( this, 1, 0 ) );
|
||||
l.add( new ItemStack( this, 1, 1 ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package appeng.block.crafting;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockAssembler;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.crafting.TileMolecularAssembler;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockMolecularAssembler extends AEBaseBlock
|
||||
{
|
||||
|
||||
public BlockMolecularAssembler() {
|
||||
super( BlockMolecularAssembler.class, Material.iron );
|
||||
setFeature( EnumSet.of( AEFeature.MolecularAssembler ) );
|
||||
setTileEntity( TileMolecularAssembler.class );
|
||||
isOpaque = false;
|
||||
lightOpacity = 1;
|
||||
}
|
||||
|
||||
public static boolean booleanAlphaPass = false;
|
||||
|
||||
@Override
|
||||
public boolean canRenderInPass(int pass)
|
||||
{
|
||||
booleanAlphaPass = pass == 1;
|
||||
return pass == 0 || pass == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderBlockAssembler.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
TileMolecularAssembler tg = getTileEntity( w, x, y, z );
|
||||
if ( tg != null && !p.isSneaking() )
|
||||
{
|
||||
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_MAC );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package appeng.block.crafting;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.block.AEBaseItemBlock;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
public class ItemCraftingStorage extends AEBaseItemBlock
|
||||
{
|
||||
|
||||
public ItemCraftingStorage(Block id) {
|
||||
super( id );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasContainerItem()
|
||||
{
|
||||
return AEConfig.instance.isFeatureEnabled( AEFeature.enableDisassemblyCrafting );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getContainerItem(ItemStack itemStack)
|
||||
{
|
||||
return AEApi.instance().blocks().blockCraftingUnit.stack( 1 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package appeng.block.grindstone;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.implementations.tiles.ICrankable;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockCrank;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.stats.Stats;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.grindstone.TileCrank;
|
||||
|
||||
public class BlockCrank extends AEBaseBlock
|
||||
{
|
||||
|
||||
public BlockCrank() {
|
||||
super( BlockCrank.class, Material.wood );
|
||||
setFeature( EnumSet.of( AEFeature.GrindStone ) );
|
||||
setTileEntity( TileCrank.class );
|
||||
setLightOpacity( 0 );
|
||||
isFullSize = isOpaque = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if ( p instanceof FakePlayer || p == null )
|
||||
return true;
|
||||
|
||||
AEBaseTile tile = getTileEntity( w, x, y, z );
|
||||
if ( tile instanceof TileCrank )
|
||||
{
|
||||
if ( ((TileCrank) tile).power() )
|
||||
{
|
||||
Stats.TurnedCranks.addToPlayer( p, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderBlockCrank.class;
|
||||
}
|
||||
|
||||
private boolean isCrankable(World w, int x, int y, int z, ForgeDirection offset)
|
||||
{
|
||||
TileEntity te = w.getTileEntity( x + offset.offsetX, y + offset.offsetY, z + offset.offsetZ );
|
||||
if ( te instanceof ICrankable )
|
||||
{
|
||||
return ((ICrankable) te).canCrankAttach( offset.getOpposite() );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private ForgeDirection findCrankable(World w, int x, int y, int z)
|
||||
{
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
if ( isCrankable( w, x, y, z, dir ) )
|
||||
return dir;
|
||||
return ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt(World w, int x, int y, int z)
|
||||
{
|
||||
return findCrankable( w, x, y, z ) != ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidOrientation(World w, int x, int y, int z, ForgeDirection forward, ForgeDirection up)
|
||||
{
|
||||
TileEntity te = w.getTileEntity( x, y, z );
|
||||
return !(te instanceof TileCrank) || isCrankable( w, x, y, z, up.getOpposite() );
|
||||
}
|
||||
|
||||
private void dropCrank(World w, int x, int y, int z)
|
||||
{
|
||||
w.func_147480_a( x, y, z, true ); // w.destroyBlock( x, y, z, true );
|
||||
w.markBlockForUpdate( x, y, z );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World w, int x, int y, int z, EntityLivingBase p, ItemStack is)
|
||||
{
|
||||
AEBaseTile tile = getTileEntity( w, x, y, z );
|
||||
if ( tile != null )
|
||||
{
|
||||
ForgeDirection mnt = findCrankable( w, x, y, z );
|
||||
ForgeDirection forward = ForgeDirection.UP;
|
||||
if ( mnt == ForgeDirection.UP || mnt == ForgeDirection.DOWN )
|
||||
forward = ForgeDirection.SOUTH;
|
||||
tile.setOrientation( forward, mnt.getOpposite() );
|
||||
}
|
||||
else
|
||||
dropCrank( w, x, y, z );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World w, int x, int y, int z, Block id)
|
||||
{
|
||||
AEBaseTile tile = getTileEntity( w, x, y, z );
|
||||
if ( tile != null )
|
||||
{
|
||||
if ( !isCrankable( w, x, y, z, tile.getUp().getOpposite() ) )
|
||||
dropCrank( w, x, y, z );
|
||||
}
|
||||
else
|
||||
dropCrank( w, x, y, z );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package appeng.block.grindstone;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.grindstone.TileGrinder;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockGrinder extends AEBaseBlock
|
||||
{
|
||||
|
||||
public BlockGrinder() {
|
||||
super( BlockGrinder.class, Material.rock );
|
||||
setFeature( EnumSet.of( AEFeature.GrindStone ) );
|
||||
setTileEntity( TileGrinder.class );
|
||||
setHardness( 3.2F );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
TileGrinder tg = getTileEntity( w, x, y, z );
|
||||
if ( tg != null && !p.isSneaking() )
|
||||
{
|
||||
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_GRINDER );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package appeng.block.misc;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.misc.TileCellWorkbench;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockCellWorkbench extends AEBaseBlock
|
||||
{
|
||||
|
||||
public BlockCellWorkbench() {
|
||||
super( BlockCellWorkbench.class, Material.iron );
|
||||
setFeature( EnumSet.of( AEFeature.StorageCells ) );
|
||||
setTileEntity( TileCellWorkbench.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if ( p.isSneaking() )
|
||||
return false;
|
||||
|
||||
TileCellWorkbench tg = getTileEntity( w, x, y, z );
|
||||
if ( tg != null )
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_CELLWORKBENCH );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
package appeng.block.misc;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockCharger;
|
||||
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.tile.AEBaseTile;
|
||||
import appeng.tile.misc.TileCharger;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockCharger extends AEBaseBlock implements ICustomCollision
|
||||
{
|
||||
|
||||
public BlockCharger() {
|
||||
super( BlockCharger.class, Material.iron );
|
||||
setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
setTileEntity( TileCharger.class );
|
||||
setLightOpacity( 2 );
|
||||
isFullSize = isOpaque = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if ( player.isSneaking() )
|
||||
return false;
|
||||
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
TileCharger tc = getTileEntity( w, x, y, z );
|
||||
if ( tc != null )
|
||||
{
|
||||
tc.activate( player );
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderBlockCharger.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World w, int x, int y, int z, Random r)
|
||||
{
|
||||
if ( !AEConfig.instance.enableEffects )
|
||||
return;
|
||||
|
||||
if ( r.nextFloat() < 0.98 )
|
||||
return;
|
||||
|
||||
AEBaseTile tile = getTileEntity( w, x, y, z );
|
||||
if ( tile instanceof TileCharger )
|
||||
{
|
||||
TileCharger tc = (TileCharger) tile;
|
||||
if ( AEApi.instance().materials().materialCertusQuartzCrystalCharged.sameAsStack( tc.getStackInSlot( 0 ) ) )
|
||||
{
|
||||
|
||||
double xOff = 0.0;
|
||||
double yOff = 0.0;
|
||||
double zOff = 0.0;
|
||||
|
||||
for (int bolts = 0; bolts < 3; bolts++)
|
||||
{
|
||||
if ( CommonHelper.proxy.shouldAddParticles( r ) )
|
||||
{
|
||||
LightningFX fx = new LightningFX( w, xOff + 0.5 + x, yOff + 0.5 + y, zOff + 0.5 + z, 0.0D, 0.0D, 0.0D );
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
|
||||
{
|
||||
TileCharger tile = getTileEntity( w, x, y, z );
|
||||
if ( tile != null )
|
||||
{
|
||||
double twoPixels = 2.0 / 16.0;
|
||||
ForgeDirection up = tile.getUp();
|
||||
ForgeDirection forward = tile.getForward();
|
||||
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox( twoPixels, twoPixels, twoPixels, 1.0 - twoPixels, 1.0 - twoPixels, 1.0 - twoPixels );
|
||||
|
||||
if ( up.offsetX != 0 )
|
||||
{
|
||||
bb.minX = 0;
|
||||
bb.maxX = 1;
|
||||
}
|
||||
if ( up.offsetY != 0 )
|
||||
{
|
||||
bb.minY = 0;
|
||||
bb.maxY = 1;
|
||||
}
|
||||
if ( up.offsetZ != 0 )
|
||||
{
|
||||
bb.minZ = 0;
|
||||
bb.maxZ = 1;
|
||||
}
|
||||
|
||||
switch (forward)
|
||||
{
|
||||
case DOWN:
|
||||
bb.maxY = 1;
|
||||
break;
|
||||
case UP:
|
||||
bb.minY = 0;
|
||||
break;
|
||||
case NORTH:
|
||||
bb.maxZ = 1;
|
||||
break;
|
||||
case SOUTH:
|
||||
bb.minZ = 0;
|
||||
break;
|
||||
case EAST:
|
||||
bb.minX = 0;
|
||||
break;
|
||||
case WEST:
|
||||
bb.maxX = 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return Arrays.asList( new AxisAlignedBB[] { bb } );
|
||||
}
|
||||
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) } );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
|
||||
{
|
||||
out.add( AxisAlignedBB.getBoundingBox( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package appeng.block.misc;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.misc.TileCondenser;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockCondenser extends AEBaseBlock
|
||||
{
|
||||
|
||||
public BlockCondenser() {
|
||||
super( BlockCondenser.class, Material.iron );
|
||||
setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
setTileEntity( TileCondenser.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if ( player.isSneaking() )
|
||||
return false;
|
||||
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
TileCondenser tc = getTileEntity( w, x, y, z );
|
||||
if ( tc != null && !player.isSneaking() )
|
||||
{
|
||||
Platform.openGUI( player, tc, ForgeDirection.getOrientation(side), GuiBridge.GUI_CONDENSER );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package appeng.block.misc;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockInscriber;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.misc.TileInscriber;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockInscriber extends AEBaseBlock
|
||||
{
|
||||
|
||||
public BlockInscriber() {
|
||||
super( BlockInscriber.class, Material.iron );
|
||||
setFeature( EnumSet.of( AEFeature.Inscriber ) );
|
||||
setTileEntity( TileInscriber.class );
|
||||
setLightOpacity( 2 );
|
||||
isFullSize = isOpaque = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderBlockInscriber.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if ( p.isSneaking() )
|
||||
return false;
|
||||
|
||||
TileInscriber tg = getTileEntity( w, x, y, z );
|
||||
if ( tg != null )
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_INSCRIBER );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package appeng.block.misc;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockInterface;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.misc.TileInterface;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockInterface extends AEBaseBlock
|
||||
{
|
||||
|
||||
public BlockInterface() {
|
||||
super( BlockInterface.class, Material.iron );
|
||||
setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
setTileEntity( TileInterface.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderBlockInterface.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasCustomRotation()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customRotateBlock(IOrientable rotatable, ForgeDirection axis)
|
||||
{
|
||||
if ( rotatable instanceof TileInterface )
|
||||
{
|
||||
((TileInterface) rotatable).setSide( axis );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if ( p.isSneaking() )
|
||||
return false;
|
||||
|
||||
TileInterface tg = getTileEntity( w, x, y, z );
|
||||
if ( tg != null )
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_INTERFACE );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package appeng.block.misc;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.tile.misc.TileLightDetector;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockLightDetector extends BlockQuartzTorch
|
||||
{
|
||||
|
||||
public BlockLightDetector() {
|
||||
super( BlockLightDetector.class );
|
||||
setFeature( EnumSet.of( AEFeature.LightDetector ) );
|
||||
setTileEntity( TileLightDetector.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ)
|
||||
{
|
||||
super.onNeighborChange( world, x, y, z, tileX, tileY, tileZ );
|
||||
|
||||
TileLightDetector tld = getTileEntity( world, x, y, z );
|
||||
if ( tld != null )
|
||||
tld.updateLight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingWeakPower(IBlockAccess w, int x, int y, int z, int side)
|
||||
{
|
||||
if ( w instanceof World && ((TileLightDetector) getTileEntity( w, x, y, z )).isReady() )
|
||||
return (int) ((World) w).getBlockLightValue( x, y, z ) - 6;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World w, int x, int y, int z, Random r)
|
||||
{
|
||||
// cancel out lightning
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package appeng.block.misc;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.MapColor;
|
||||
import net.minecraft.block.material.MaterialLiquid;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockPaint;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.tile.misc.TilePaint;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockPaint extends AEBaseBlock
|
||||
{
|
||||
|
||||
public BlockPaint() {
|
||||
super( BlockPaint.class, new MaterialLiquid( MapColor.airColor ) );
|
||||
setFeature( EnumSet.of( AEFeature.PaintBalls ) );
|
||||
setTileEntity( TilePaint.class );
|
||||
setLightOpacity( 0 );
|
||||
isFullSize = false;
|
||||
isOpaque = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderBlockPaint.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockAccess w, int x, int y, int z)
|
||||
{
|
||||
TilePaint tp = getTileEntity( w, x, y, z );
|
||||
|
||||
if ( tp != null )
|
||||
{
|
||||
return tp.getLightLevel();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_)
|
||||
{
|
||||
// nothing..
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillWithRain(World w, int x, int y, int z)
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
w.setBlock( x, y, z, Platform.air, 0, 3 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World w, int x, int y, int z, Block junk)
|
||||
{
|
||||
TilePaint tp = getTileEntity( w, x, y, z );
|
||||
|
||||
if ( tp != null )
|
||||
tp.onNeighborBlockChange();
|
||||
}
|
||||
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean canCollideCheck(int p_149678_1_, boolean p_149678_2_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_,
|
||||
int p_149690_7_)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAir(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplaceable(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package appeng.block.misc;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockQuartzAccelerator;
|
||||
import appeng.client.render.effects.LightningFX;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.MetaRotation;
|
||||
import appeng.tile.misc.TileQuartzGrowthAccelerator;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockQuartzGrowthAccelerator extends AEBaseBlock implements IOrientableBlock
|
||||
{
|
||||
|
||||
public BlockQuartzGrowthAccelerator() {
|
||||
super( BlockQuartzGrowthAccelerator.class, Material.rock );
|
||||
setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
setTileEntity( TileQuartzGrowthAccelerator.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderBlockQuartzAccelerator.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOrientable getOrientable(final IBlockAccess w, final int x, final int y, final int z)
|
||||
{
|
||||
return new MetaRotation( w, x, y, z );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World w, int x, int y, int z, Random r)
|
||||
{
|
||||
if ( !AEConfig.instance.enableEffects )
|
||||
return;
|
||||
|
||||
TileQuartzGrowthAccelerator tqga = getTileEntity( w, x, y, z );
|
||||
|
||||
if ( tqga != null && tqga.hasPower && CommonHelper.proxy.shouldAddParticles( r ) )
|
||||
{
|
||||
double d0 = (double) (r.nextFloat() - 0.5F);
|
||||
double d1 = (double) (r.nextFloat() - 0.5F);
|
||||
|
||||
ForgeDirection up = tqga.getUp();
|
||||
ForgeDirection forward = tqga.getForward();
|
||||
ForgeDirection west = Platform.crossProduct( forward, up );
|
||||
|
||||
double rx = 0.5 + x;
|
||||
double ry = 0.5 + y;
|
||||
double rz = 0.5 + z;
|
||||
|
||||
double dx = 0;
|
||||
double dz = 0;
|
||||
|
||||
rx += up.offsetX * d0;
|
||||
ry += up.offsetY * d0;
|
||||
rz += up.offsetZ * d0;
|
||||
|
||||
switch (r.nextInt( 4 ))
|
||||
{
|
||||
case 0:
|
||||
dx = 0.6;
|
||||
dz = d1;
|
||||
if ( !w.getBlock( x + west.offsetX, y + west.offsetY, z + west.offsetZ ).isAir( w, x + west.offsetX, y + west.offsetY, z + west.offsetZ ) )
|
||||
return;
|
||||
break;
|
||||
case 1:
|
||||
dx = d1;
|
||||
dz += 0.6;
|
||||
if ( !w.getBlock( x + forward.offsetX, y + forward.offsetY, z + forward.offsetZ ).isAir( w, x + forward.offsetX, y + forward.offsetY,
|
||||
z + forward.offsetZ ) )
|
||||
return;
|
||||
break;
|
||||
case 2:
|
||||
dx = d1;
|
||||
dz = -0.6;
|
||||
if ( !w.getBlock( x - forward.offsetX, y - forward.offsetY, z - forward.offsetZ ).isAir( w, x - forward.offsetX, y - forward.offsetY,
|
||||
z - forward.offsetZ ) )
|
||||
return;
|
||||
break;
|
||||
case 3:
|
||||
dx = -0.6;
|
||||
dz = d1;
|
||||
if ( !w.getBlock( x - west.offsetX, y - west.offsetY, z - west.offsetZ ).isAir( w, x - west.offsetX, y - west.offsetY, z - west.offsetZ ) )
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
rx += dx * west.offsetX;
|
||||
ry += dx * west.offsetY;
|
||||
rz += dx * west.offsetZ;
|
||||
|
||||
rx += dz * forward.offsetX;
|
||||
ry += dz * forward.offsetY;
|
||||
rz += dz * forward.offsetZ;
|
||||
|
||||
LightningFX fx = new LightningFX( w, rx, ry, rz, 0.0D, 0.0D, 0.0D );
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean usesMetadata()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package appeng.block.misc;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderQuartzTorch;
|
||||
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;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, ICustomCollision
|
||||
{
|
||||
|
||||
protected BlockQuartzTorch(Class which) {
|
||||
super( which, Material.circuits );
|
||||
setLightOpacity( 0 );
|
||||
isFullSize = isOpaque = false;
|
||||
}
|
||||
|
||||
public BlockQuartzTorch() {
|
||||
this( BlockQuartzTorch.class );
|
||||
setFeature( EnumSet.of( AEFeature.DecorativeLights ) );
|
||||
setLightLevel( 0.9375F );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderQuartzTorch.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOrientable getOrientable(final IBlockAccess w, final int x, final int y, final int z)
|
||||
{
|
||||
return new MetaRotation( w, x, y, z );
|
||||
}
|
||||
|
||||
private void dropTorch(World w, int x, int y, int z)
|
||||
{
|
||||
w.func_147480_a( x, y, z, true );
|
||||
// w.destroyBlock( x, y, z, true );
|
||||
w.markBlockForUpdate( x, y, z );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt(World w, int x, int y, int z)
|
||||
{
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
if ( canPlaceAt( w, x, y, z, dir ) )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean canPlaceAt(World w, int x, int y, int z, ForgeDirection dir)
|
||||
{
|
||||
return w.isSideSolid( x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir.getOpposite(), false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidOrientation(World w, int x, int y, int z, ForgeDirection forward, ForgeDirection up)
|
||||
{
|
||||
return canPlaceAt( w, x, y, z, up.getOpposite() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World w, int x, int y, int z, Block id)
|
||||
{
|
||||
ForgeDirection up = getOrientable( w, x, y, z ).getUp();
|
||||
if ( !canPlaceAt( w, x, y, z, up.getOpposite() ) )
|
||||
dropTorch( w, x, y, z );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
|
||||
{
|
||||
ForgeDirection up = getOrientable( w, x, y, z ).getUp();
|
||||
double xOff = -0.3 * up.offsetX;
|
||||
double yOff = -0.3 * up.offsetY;
|
||||
double zOff = -0.3 * up.offsetZ;
|
||||
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7 ) } );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
|
||||
{/*
|
||||
* double xOff = -0.15 * getUp().offsetX; double yOff = -0.15 * getUp().offsetY; double zOff = -0.15 *
|
||||
* getUp().offsetZ; out.add( AxisAlignedBB.getBoundingBox( xOff + (double) x + 0.15, yOff + (double) y + 0.15, zOff
|
||||
* + (double) z + 0.15,// ahh xOff + (double) x + 0.85, yOff + (double) y + 0.85, zOff + (double) z + 0.85 ) );
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World w, int x, int y, int z, Random r)
|
||||
{
|
||||
if ( !AEConfig.instance.enableEffects )
|
||||
return;
|
||||
|
||||
if ( r.nextFloat() < 0.98 )
|
||||
return;
|
||||
|
||||
ForgeDirection up = getOrientable( w, x, y, z ).getUp();
|
||||
double xOff = -0.3 * up.offsetX;
|
||||
double yOff = -0.3 * up.offsetY;
|
||||
double zOff = -0.3 * up.offsetZ;
|
||||
for (int bolts = 0; bolts < 3; bolts++)
|
||||
{
|
||||
if ( CommonHelper.proxy.shouldAddParticles( r ) )
|
||||
{
|
||||
LightningFX fx = new LightningFX( w, xOff + 0.5 + x, yOff + 0.5 + y, zOff + 0.5 + z, 0.0D, 0.0D, 0.0D );
|
||||
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean usesMetadata()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package appeng.block.misc;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RendererSecurity;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.misc.TileSecurity;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockSecurity extends AEBaseBlock
|
||||
{
|
||||
|
||||
public BlockSecurity() {
|
||||
super( BlockSecurity.class, Material.iron );
|
||||
setFeature( EnumSet.of( AEFeature.Security ) );
|
||||
setTileEntity( TileSecurity.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RendererSecurity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if ( p.isSneaking() )
|
||||
return false;
|
||||
|
||||
TileSecurity tg = getTileEntity( w, x, y, z );
|
||||
if ( tg != null )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return true;
|
||||
|
||||
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_SECURITY );
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
package appeng.block.misc;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockSkyCompass;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
import appeng.tile.misc.TileSkyCompass;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockSkyCompass extends AEBaseBlock implements ICustomCollision
|
||||
{
|
||||
|
||||
public BlockSkyCompass() {
|
||||
super( BlockSkyCompass.class, Material.iron );
|
||||
setFeature( EnumSet.of( AEFeature.MeteoriteCompass ) );
|
||||
setTileEntity( TileSkyCompass.class );
|
||||
isOpaque = isFullSize = false;
|
||||
lightOpacity = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int direction, int metadata)
|
||||
{
|
||||
return Blocks.iron_block.getIcon( direction, metadata );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderBlockSkyCompass.class;
|
||||
}
|
||||
|
||||
private void dropTorch(World w, int x, int y, int z)
|
||||
{
|
||||
w.func_147480_a( x, y, z, true );
|
||||
// w.destroyBlock( x, y, z, true );
|
||||
w.markBlockForUpdate( x, y, z );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt(World w, int x, int y, int z)
|
||||
{
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
if ( canPlaceAt( w, x, y, z, dir ) )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean canPlaceAt(World w, int x, int y, int z, ForgeDirection dir)
|
||||
{
|
||||
return w.isSideSolid( x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir.getOpposite(), false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidOrientation(World w, int x, int y, int z, ForgeDirection forward, ForgeDirection up)
|
||||
{
|
||||
TileSkyCompass sc = getTileEntity( w, x, y, z );
|
||||
if ( sc != null )
|
||||
return false;
|
||||
return canPlaceAt( w, x, y, z, forward.getOpposite() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World w, int x, int y, int z, Block id)
|
||||
{
|
||||
TileSkyCompass sc = getTileEntity( w, x, y, z );
|
||||
ForgeDirection up = sc.getForward();
|
||||
if ( !canPlaceAt( w, x, y, z, up.getOpposite() ) )
|
||||
dropTorch( w, x, y, z );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
|
||||
{
|
||||
TileSkyCompass tile = getTileEntity( w, x, y, z );
|
||||
if ( tile != null )
|
||||
{
|
||||
ForgeDirection forward = tile.getForward();
|
||||
|
||||
double minX = 0;
|
||||
double minY = 0;
|
||||
double minZ = 0;
|
||||
double maxX = 1;
|
||||
double maxY = 1;
|
||||
double maxZ = 1;
|
||||
|
||||
switch (forward)
|
||||
{
|
||||
case DOWN:
|
||||
minZ = minX = 5.0 / 16.0;
|
||||
maxZ = maxX = 11.0 / 16.0;
|
||||
maxY = 1.0;
|
||||
minY = 14.0 / 16.0;
|
||||
break;
|
||||
case EAST:
|
||||
minZ = minY = 5.0 / 16.0;
|
||||
maxZ = maxY = 11.0 / 16.0;
|
||||
maxX = 2.0 / 16.0;
|
||||
minX = 0.0;
|
||||
break;
|
||||
case NORTH:
|
||||
minY = minX = 5.0 / 16.0;
|
||||
maxY = maxX = 11.0 / 16.0;
|
||||
maxZ = 1.0;
|
||||
minZ = 14.0 / 16.0;
|
||||
break;
|
||||
case SOUTH:
|
||||
minY = minX = 5.0 / 16.0;
|
||||
maxY = maxX = 11.0 / 16.0;
|
||||
maxZ = 2.0 / 16.0;
|
||||
minZ = 0.0;
|
||||
break;
|
||||
case UP:
|
||||
minZ = minX = 5.0 / 16.0;
|
||||
maxZ = maxX = 11.0 / 16.0;
|
||||
maxY = 2.0 / 16.0;
|
||||
minY = 0.0;
|
||||
break;
|
||||
case WEST:
|
||||
minZ = minY = 5.0 / 16.0;
|
||||
maxZ = maxY = 11.0 / 16.0;
|
||||
maxX = 1.0;
|
||||
minX = 14.0 / 16.0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( minX, minY, minZ, maxX, maxY, maxZ ) } );
|
||||
}
|
||||
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) } );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister iconRegistry)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
package appeng.block.misc;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderTinyTNT;
|
||||
import appeng.client.texture.FullIcon;
|
||||
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;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
|
||||
public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
|
||||
{
|
||||
|
||||
public BlockTinyTNT() {
|
||||
super( BlockTinyTNT.class, Material.tnt );
|
||||
setFeature( EnumSet.of( AEFeature.TinyTNT ) );
|
||||
setLightOpacity( 3 );
|
||||
setBlockBounds( 0.25f, 0.0f, 0.25f, 0.75f, 0.5f, 0.75f );
|
||||
isFullSize = isOpaque = false;
|
||||
|
||||
EntityRegistry.registerModEntity( EntityTinyTNTPrimed.class, "EntityTinyTNTPrimed", EntityIds.TINY_TNT, AppEng.instance, 16, 4, true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit()
|
||||
{
|
||||
super.postInit();
|
||||
BlockDispenser.dispenseBehaviorRegistry.putObject( Item.getItemFromBlock( this ), new DispenserBehaviorTinyTNT() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderTinyTNT.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister iconRegistry)
|
||||
{
|
||||
// no images required.
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int direction, int metadata)
|
||||
{
|
||||
return new FullIcon( Blocks.tnt.getIcon( direction, metadata ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World w, int x, int y, int z, Entity entity)
|
||||
{
|
||||
if ( entity instanceof EntityArrow && !w.isRemote )
|
||||
{
|
||||
EntityArrow entityarrow = (EntityArrow) entity;
|
||||
|
||||
if ( entityarrow.isBurning() )
|
||||
{
|
||||
this.startFuse( w, x, y, z, entityarrow.shootingEntity instanceof EntityLivingBase ? (EntityLivingBase) entityarrow.shootingEntity : null );
|
||||
w.setBlockToAir( x, y, z );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World w, int x, int y, int z)
|
||||
{
|
||||
super.onBlockAdded( w, x, y, z );
|
||||
|
||||
if ( w.isBlockIndirectlyGettingPowered( x, y, z ) )
|
||||
{
|
||||
this.startFuse( w, x, y, z, null );
|
||||
w.setBlockToAir( x, y, z );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World w, int x, int y, int z, Block id)
|
||||
{
|
||||
if ( w.isBlockIndirectlyGettingPowered( x, y, z ) )
|
||||
{
|
||||
this.startFuse( w, x, y, z, null );
|
||||
w.setBlockToAir( x, y, z );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if ( player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.flint_and_steel )
|
||||
{
|
||||
this.startFuse( w, x, y, z, player );
|
||||
w.setBlockToAir( x, y, z );
|
||||
player.getCurrentEquippedItem().damageItem( 1, player );
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return super.onActivated( w, x, y, z, player, side, hitX, hitY, hitZ );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockDestroyedByExplosion(World w, int x, int y, int z, Explosion exp)
|
||||
{
|
||||
if ( !w.isRemote )
|
||||
{
|
||||
EntityTinyTNTPrimed entitytntprimed = new EntityTinyTNTPrimed( w, x + 0.5F, y + 0.5F, z + 0.5F, exp.getExplosivePlacedBy() );
|
||||
entitytntprimed.fuse = w.rand.nextInt( entitytntprimed.fuse / 4 ) + entitytntprimed.fuse / 8;
|
||||
w.spawnEntityInWorld( entitytntprimed );
|
||||
}
|
||||
}
|
||||
|
||||
public void startFuse(World w, int x, int y, int z, EntityLivingBase ignitor)
|
||||
{
|
||||
if ( !w.isRemote )
|
||||
{
|
||||
EntityTinyTNTPrimed entitytntprimed = new EntityTinyTNTPrimed( w, x + 0.5F, y + 0.5F, z + 0.5F, ignitor );
|
||||
w.spawnEntityInWorld( entitytntprimed );
|
||||
w.playSoundAtEntity( entitytntprimed, "game.tnt.primed", 1.0F, 1.0F );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDropFromExplosion(Explosion exp)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
|
||||
{
|
||||
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( 0.25, 0, 0.25, 0.75, 0.5, 0.75 ) } );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
|
||||
{
|
||||
out.add( AxisAlignedBB.getBoundingBox( 0.25, 0, 0.25, 0.75, 0.5, 0.75 ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package appeng.block.misc;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
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 class BlockVibrationChamber extends AEBaseBlock
|
||||
{
|
||||
|
||||
public BlockVibrationChamber() {
|
||||
super( BlockVibrationChamber.class, Material.iron );
|
||||
setFeature( EnumSet.of( AEFeature.PowerGen ) );
|
||||
setTileEntity( TileVibrationChamber.class );
|
||||
setHardness( 4.2F );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if ( player.isSneaking() )
|
||||
return false;
|
||||
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
TileVibrationChamber tc = getTileEntity( w, x, y, z );
|
||||
if ( tc != null && !player.isSneaking() )
|
||||
{
|
||||
Platform.openGUI( player, tc, ForgeDirection.getOrientation( side ), GuiBridge.GUI_VIBRATIONCHAMBER );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess w, int x, int y, int z, int s)
|
||||
{
|
||||
IIcon ico = super.getIcon( w, x, y, z, s );
|
||||
TileVibrationChamber tvc = getTileEntity( w, x, y, z );
|
||||
|
||||
if ( tvc != null && tvc.isOn && ico == getRendererInstance().getTexture( ForgeDirection.SOUTH ) )
|
||||
{
|
||||
return ExtraBlockTextures.BlockVibrationChamberFrontOn.getIcon();
|
||||
}
|
||||
|
||||
return ico;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick(World w, int x, int y, int z, Random r)
|
||||
{
|
||||
if ( !AEConfig.instance.enableEffects )
|
||||
return;
|
||||
|
||||
AEBaseTile tile = getTileEntity( w, x, y, z );
|
||||
if ( tile instanceof TileVibrationChamber )
|
||||
{
|
||||
TileVibrationChamber tc = (TileVibrationChamber) tile;
|
||||
if ( tc.isOn )
|
||||
{
|
||||
float f1 = (float) x + 0.5F;
|
||||
float f2 = (float) y + 0.5F;
|
||||
float f3 = (float) z + 0.5F;
|
||||
|
||||
ForgeDirection forward = tc.getForward();
|
||||
ForgeDirection up = tc.getUp();
|
||||
|
||||
int west_x = forward.offsetY * up.offsetZ - forward.offsetZ * up.offsetY;
|
||||
int west_y = forward.offsetZ * up.offsetX - forward.offsetX * up.offsetZ;
|
||||
int west_z = forward.offsetX * up.offsetY - forward.offsetY * up.offsetX;
|
||||
|
||||
f1 += forward.offsetX * 0.6;
|
||||
f2 += forward.offsetY * 0.6;
|
||||
f3 += forward.offsetZ * 0.6;
|
||||
|
||||
float ox = r.nextFloat();
|
||||
float oy = r.nextFloat() * 0.2f;
|
||||
|
||||
f1 += up.offsetX * (-0.3 + oy);
|
||||
f2 += up.offsetY * (-0.3 + oy);
|
||||
f3 += up.offsetZ * (-0.3 + oy);
|
||||
|
||||
f1 += west_x * (0.3 * ox - 0.15);
|
||||
f2 += west_y * (0.3 * ox - 0.15);
|
||||
f3 += west_z * (0.3 * ox - 0.15);
|
||||
|
||||
w.spawnParticle( "smoke", (double) f1, (double) f2, (double) f3, 0.0D, 0.0D, 0.0D );
|
||||
w.spawnParticle( "flame", (double) f1, (double) f2, (double) f3, 0.0D, 0.0D, 0.0D );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,450 @@
|
||||
package appeng.block.networking;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.particle.EffectRenderer;
|
||||
import net.minecraft.client.particle.EntityDiggingFX;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import powercrystals.minefactoryreloaded.api.rednet.connectivity.IRedNetConnection;
|
||||
import powercrystals.minefactoryreloaded.api.rednet.connectivity.RedNetConnectionType;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.PartItemStack;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.BusRenderHelper;
|
||||
import appeng.client.render.blocks.RendererCableBus;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.integration.abstraction.IFMP;
|
||||
import appeng.parts.ICableBusContainer;
|
||||
import appeng.parts.NullCableBusContainer;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.tile.networking.TileCableBusTESR;
|
||||
import appeng.transformer.annotations.integration.Interface;
|
||||
import appeng.transformer.annotations.integration.Method;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@Interface(iface = "powercrystals.minefactoryreloaded.api.rednet.connectivity.IRedNetConnection", iname = "MFR")
|
||||
public class BlockCableBus extends AEBaseBlock implements IRedNetConnection
|
||||
{
|
||||
|
||||
static private ICableBusContainer nullCB = new NullCableBusContainer();
|
||||
static public Class<? extends TileEntity> noTesrTile;
|
||||
static public Class<? extends TileEntity> tesrTile;
|
||||
|
||||
public <T extends TileEntity> T getTileEntity(IBlockAccess w, int x, int y, int z)
|
||||
{
|
||||
TileEntity te = w.getTileEntity( x, y, z );
|
||||
|
||||
if ( noTesrTile.isInstance( te ) )
|
||||
return (T) te;
|
||||
|
||||
if ( tesrTile != null && tesrTile.isInstance( te ) )
|
||||
return (T) te;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public BlockCableBus() {
|
||||
super( BlockCableBus.class, AEGlassMaterial.instance );
|
||||
setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
setLightOpacity( 0 );
|
||||
isFullSize = isOpaque = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass()
|
||||
{
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) )
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean addHitEffects(World world, MovingObjectPosition target, EffectRenderer effectRenderer)
|
||||
{
|
||||
Object pobj = cb( world, target.blockX, target.blockY, target.blockZ );
|
||||
if ( pobj instanceof IPartHost )
|
||||
{
|
||||
IPartHost host = (IPartHost) pobj;
|
||||
|
||||
for (ForgeDirection side : ForgeDirection.values())
|
||||
{
|
||||
IPart p = host.getPart( side );
|
||||
IIcon ico = getIcon( p );
|
||||
|
||||
if ( ico == null )
|
||||
continue;
|
||||
|
||||
byte b0 = (byte) (Platform.getRandomInt() % 2 == 0 ? 1 : 0);
|
||||
|
||||
for (int i1 = 0; i1 < b0; ++i1)
|
||||
{
|
||||
for (int j1 = 0; j1 < b0; ++j1)
|
||||
{
|
||||
for (int k1 = 0; k1 < b0; ++k1)
|
||||
{
|
||||
double d0 = (double) target.blockX + ((double) i1 + 0.5D) / (double) b0;
|
||||
double d1 = (double) target.blockY + ((double) j1 + 0.5D) / (double) b0;
|
||||
double d2 = (double) target.blockZ + ((double) k1 + 0.5D) / (double) b0;
|
||||
|
||||
double dd0 = target.hitVec.xCoord;
|
||||
double dd1 = target.hitVec.yCoord;
|
||||
double dd2 = target.hitVec.zCoord;
|
||||
EntityDiggingFX fx = (new EntityDiggingFX( world, dd0, dd1, dd2, d0 - (double) target.blockX - 0.5D, d1 - (double) target.blockY
|
||||
- 0.5D, d2 - (double) target.blockZ - 0.5D, this, 0 )).applyColourMultiplier( target.blockX, target.blockY, target.blockZ );
|
||||
|
||||
fx.setParticleIcon( ico );
|
||||
|
||||
effectRenderer.addEffect( fx );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean addDestroyEffects(World world, int x, int y, int z, int meta, EffectRenderer effectRenderer)
|
||||
{
|
||||
Object pobj = cb( world, x, y, z );
|
||||
if ( pobj instanceof IPartHost )
|
||||
{
|
||||
IPartHost host = (IPartHost) pobj;
|
||||
|
||||
for (ForgeDirection side : ForgeDirection.values())
|
||||
{
|
||||
IPart p = host.getPart( side );
|
||||
IIcon ico = getIcon( p );
|
||||
|
||||
if ( ico == null )
|
||||
continue;
|
||||
|
||||
byte b0 = 3;
|
||||
|
||||
for (int i1 = 0; i1 < b0; ++i1)
|
||||
{
|
||||
for (int j1 = 0; j1 < b0; ++j1)
|
||||
{
|
||||
for (int k1 = 0; k1 < b0; ++k1)
|
||||
{
|
||||
double d0 = (double) x + ((double) i1 + 0.5D) / (double) b0;
|
||||
double d1 = (double) y + ((double) j1 + 0.5D) / (double) b0;
|
||||
double d2 = (double) z + ((double) k1 + 0.5D) / (double) b0;
|
||||
EntityDiggingFX fx = (new EntityDiggingFX( world, d0, d1, d2, d0 - (double) x - 0.5D, d1 - (double) y - 0.5D, d2 - (double) z
|
||||
- 0.5D, this, meta )).applyColourMultiplier( x, y, z );
|
||||
|
||||
fx.setParticleIcon( ico );
|
||||
|
||||
effectRenderer.addEffect( fx );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private IIcon getIcon(IPart p)
|
||||
{
|
||||
if ( p == null )
|
||||
return null;
|
||||
|
||||
try
|
||||
{
|
||||
IIcon ico = p.getBreakingTexture();
|
||||
if ( ico != null )
|
||||
return ico;
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
// nothing.
|
||||
}
|
||||
|
||||
ItemStack is = p.getItemStack( PartItemStack.Network );
|
||||
if ( is == null || is.getItem() == null )
|
||||
return null;
|
||||
|
||||
return is.getItem().getIcon( is, 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderInPass(int pass)
|
||||
{
|
||||
BusRenderHelper.instance.setPass( pass );
|
||||
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) )
|
||||
return true;
|
||||
|
||||
return pass == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLadder(IBlockAccess world, int x, int y, int z, EntityLivingBase entity)
|
||||
{
|
||||
return cb( world, x, y, z ).isLadder( entity );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour)
|
||||
{
|
||||
return recolourBlock( world, x, y, z, side, colour, null );
|
||||
}
|
||||
|
||||
public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour, EntityPlayer who)
|
||||
{
|
||||
try
|
||||
{
|
||||
return cb( world, x, y, z ).recolourBlock( side, AEColor.values()[colour], who );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random r)
|
||||
{
|
||||
cb( world, x, y, z ).randomDisplayTick( world, x, y, z, r );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
Block block = world.getBlock( x, y, z );
|
||||
if ( block != null && block != this )
|
||||
{
|
||||
return block.getLightValue( world, x, y, z );
|
||||
}
|
||||
if ( block == null )
|
||||
return 0;
|
||||
return cb( world, x, y, z ).getLightValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
|
||||
{
|
||||
Vec3 v3 = target.hitVec.addVector( -x, -y, -z );
|
||||
SelectedPart sp = cb( world, x, y, z ).selectPart( v3 );
|
||||
|
||||
if ( sp.part != null )
|
||||
return sp.part.getItemStack( PartItemStack.Pick );
|
||||
else if ( sp.facade != null )
|
||||
return sp.facade.getItemStack();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplaceable(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
return cb( world, x, y, z ).isEmpty();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z)
|
||||
{
|
||||
if ( player.capabilities.isCreativeMode )
|
||||
{
|
||||
AEBaseTile tile = getTileEntity( world, x, y, z );
|
||||
if ( tile != null )
|
||||
tile.disableDrops();
|
||||
// maybe ray trace?
|
||||
}
|
||||
return super.removedByPlayer( world, player, x, y, z );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess w, int x, int y, int z, int s)
|
||||
{
|
||||
return getIcon( s, 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int direction, int metadata)
|
||||
{
|
||||
IIcon i = super.getIcon( direction, metadata );
|
||||
if ( i != null )
|
||||
return i;
|
||||
|
||||
return ExtraBlockTextures.BlockQuartzGlassB.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RendererCableBus.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister iconRegistry)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvidePower()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideSolid(IBlockAccess w, int x, int y, int z, ForgeDirection side)
|
||||
{
|
||||
return cb( w, x, y, z ).isSolidOnSide( side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World w, int x, int y, int z, Block meh)
|
||||
{
|
||||
cb( w, x, y, z ).onNeighborChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChange(IBlockAccess w, int x, int y, int z, int tileX, int tileY, int tileZ)
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
cb( w, x, y, z ).onNeighborChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int i, Random r, int k)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
return cb( w, x, y, z ).activate( player, Vec3.createVectorHelper( hitX, hitY, hitZ ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World w, int x, int y, int z, Entity e)
|
||||
{
|
||||
cb( w, x, y, z ).onEntityCollision( e );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone(IBlockAccess w, int x, int y, int z, int side)
|
||||
{
|
||||
switch (side)
|
||||
{
|
||||
case -1:
|
||||
case 4:
|
||||
return cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.UP, ForgeDirection.DOWN ) );
|
||||
case 0:
|
||||
return cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.NORTH ) );
|
||||
case 1:
|
||||
return cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.EAST ) );
|
||||
case 2:
|
||||
return cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.SOUTH ) );
|
||||
case 3:
|
||||
return cb( w, x, y, z ).canConnectRedstone( EnumSet.of( ForgeDirection.WEST ) );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingWeakPower(IBlockAccess w, int x, int y, int z, int side)
|
||||
{
|
||||
return cb( w, x, y, z ).isProvidingWeakPower( ForgeDirection.getOrientation( side ).getOpposite() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingStrongPower(IBlockAccess w, int x, int y, int z, int side)
|
||||
{
|
||||
return cb( w, x, y, z ).isProvidingStrongPower( ForgeDirection.getOrientation( side ).getOpposite() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void setupTile()
|
||||
{
|
||||
setTileEntity( noTesrTile = Api.instance.partHelper.getCombinedInstance( TileCableBus.class.getName() ) );
|
||||
if ( Platform.isClient() )
|
||||
{
|
||||
tesrTile = Api.instance.partHelper.getCombinedInstance( TileCableBusTESR.class.getName() );
|
||||
GameRegistry.registerTileEntity( tesrTile, "ClientOnly_TESR_CableBus" );
|
||||
CommonHelper.proxy.bindTileEntitySpecialRenderer( tesrTile, this );
|
||||
}
|
||||
}
|
||||
|
||||
private ICableBusContainer cb(IBlockAccess w, int x, int y, int z)
|
||||
{
|
||||
TileEntity te = w.getTileEntity( x, y, z );
|
||||
ICableBusContainer out = null;
|
||||
|
||||
if ( te instanceof TileCableBus )
|
||||
out = ((TileCableBus) te).cb;
|
||||
|
||||
else if ( AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) )
|
||||
out = ((IFMP) AppEng.instance.getIntegration( IntegrationType.FMP )).getCableContainer( te );
|
||||
|
||||
return out == null ? nullCB : out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Immibis MB Support.
|
||||
*/
|
||||
boolean ImmibisMicroblocks_TransformableBlockMarker = true;
|
||||
|
||||
@Override
|
||||
@Method(iname = "MFR")
|
||||
public RedNetConnectionType getConnectionType(World world, int x, int y, int z, ForgeDirection side)
|
||||
{
|
||||
return cb( world, x, y, z ).canConnectRedstone( EnumSet.allOf( ForgeDirection.class ) ) ? RedNetConnectionType.CableSingle : RedNetConnectionType.None;
|
||||
}
|
||||
|
||||
int myColorMultiplier = 0xffffff;
|
||||
|
||||
public void setRenderColor(int color)
|
||||
{
|
||||
myColorMultiplier = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_)
|
||||
{
|
||||
return myColorMultiplier;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package appeng.block.networking;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockController;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.tile.networking.TileController;
|
||||
|
||||
public class BlockController extends AEBaseBlock
|
||||
{
|
||||
|
||||
public BlockController() {
|
||||
super( BlockController.class, Material.iron );
|
||||
setFeature( EnumSet.of( AEFeature.Channels ) );
|
||||
setTileEntity( TileController.class );
|
||||
setHardness( 6 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World w, int x, int y, int z, Block id_junk)
|
||||
{
|
||||
TileController tc = getTileEntity( w, x, y, z );
|
||||
if ( tc != null )
|
||||
tc.onNeighborChange( false );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderBlockController.class;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package appeng.block.networking;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.tile.networking.TileCreativeEnergyCell;
|
||||
|
||||
public class BlockCreativeEnergyCell extends AEBaseBlock
|
||||
{
|
||||
|
||||
public BlockCreativeEnergyCell() {
|
||||
super( BlockCreativeEnergyCell.class, AEGlassMaterial.instance );
|
||||
setFeature( EnumSet.of( AEFeature.Creative ) );
|
||||
setTileEntity( TileCreativeEnergyCell.class );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package appeng.block.networking;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.util.IIcon;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.tile.networking.TileDenseEnergyCell;
|
||||
|
||||
public class BlockDenseEnergyCell extends BlockEnergyCell
|
||||
{
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
return 200000.0 * 8.0;
|
||||
}
|
||||
|
||||
public BlockDenseEnergyCell() {
|
||||
super( BlockDenseEnergyCell.class );
|
||||
setFeature( EnumSet.of( AEFeature.DenseEnergyCells ) );
|
||||
setTileEntity( TileDenseEnergyCell.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int direction, int metadata)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
case 0:
|
||||
return ExtraBlockTextures.MEDenseEnergyCell0.getIcon();
|
||||
case 1:
|
||||
return ExtraBlockTextures.MEDenseEnergyCell1.getIcon();
|
||||
case 2:
|
||||
return ExtraBlockTextures.MEDenseEnergyCell2.getIcon();
|
||||
case 3:
|
||||
return ExtraBlockTextures.MEDenseEnergyCell3.getIcon();
|
||||
case 4:
|
||||
return ExtraBlockTextures.MEDenseEnergyCell4.getIcon();
|
||||
case 5:
|
||||
return ExtraBlockTextures.MEDenseEnergyCell5.getIcon();
|
||||
case 6:
|
||||
return ExtraBlockTextures.MEDenseEnergyCell6.getIcon();
|
||||
case 7:
|
||||
return ExtraBlockTextures.MEDenseEnergyCell7.getIcon();
|
||||
|
||||
}
|
||||
return super.getIcon( direction, metadata );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package appeng.block.networking;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.tile.networking.TileEnergyAcceptor;
|
||||
|
||||
public class BlockEnergyAcceptor extends AEBaseBlock
|
||||
{
|
||||
|
||||
public BlockEnergyAcceptor() {
|
||||
super( BlockEnergyAcceptor.class, Material.iron );
|
||||
setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
setTileEntity( TileEnergyAcceptor.class );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package appeng.block.networking;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.block.AEBaseItemBlockChargeable;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockEnergyCube;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.tile.networking.TileEnergyCell;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockEnergyCell extends AEBaseBlock
|
||||
{
|
||||
|
||||
public double getMaxPower()
|
||||
{
|
||||
return 200000.0;
|
||||
}
|
||||
|
||||
public BlockEnergyCell(Class c) {
|
||||
super( c, AEGlassMaterial.instance );
|
||||
}
|
||||
|
||||
public BlockEnergyCell() {
|
||||
this( BlockEnergyCell.class );
|
||||
setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
setTileEntity( TileEnergyCell.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item id, CreativeTabs tab, List list)
|
||||
{
|
||||
super.getSubBlocks( id, tab, list );
|
||||
|
||||
ItemStack charged = new ItemStack( this, 1 );
|
||||
NBTTagCompound tag = Platform.openNbtData( charged );
|
||||
tag.setDouble( "internalCurrentPower", getMaxPower() );
|
||||
tag.setDouble( "internalMaxPower", getMaxPower() );
|
||||
list.add( charged );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderBlockEnergyCube.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int direction, int metadata)
|
||||
{
|
||||
switch (metadata)
|
||||
{
|
||||
case 0:
|
||||
return ExtraBlockTextures.MEEnergyCell0.getIcon();
|
||||
case 1:
|
||||
return ExtraBlockTextures.MEEnergyCell1.getIcon();
|
||||
case 2:
|
||||
return ExtraBlockTextures.MEEnergyCell2.getIcon();
|
||||
case 3:
|
||||
return ExtraBlockTextures.MEEnergyCell3.getIcon();
|
||||
case 4:
|
||||
return ExtraBlockTextures.MEEnergyCell4.getIcon();
|
||||
case 5:
|
||||
return ExtraBlockTextures.MEEnergyCell5.getIcon();
|
||||
case 6:
|
||||
return ExtraBlockTextures.MEEnergyCell6.getIcon();
|
||||
case 7:
|
||||
return ExtraBlockTextures.MEEnergyCell7.getIcon();
|
||||
|
||||
}
|
||||
return super.getIcon( direction, metadata );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getItemBlockClass()
|
||||
{
|
||||
return AEBaseItemBlockChargeable.class;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
package appeng.block.networking;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockWireless;
|
||||
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 AEBaseBlock implements ICustomCollision
|
||||
{
|
||||
|
||||
public BlockWireless() {
|
||||
super( BlockWireless.class, AEGlassMaterial.instance );
|
||||
setFeature( EnumSet.of( AEFeature.Core, AEFeature.WirelessAccessTerminal ) );
|
||||
setTileEntity( TileWireless.class );
|
||||
setLightOpacity( 0 );
|
||||
isFullSize = false;
|
||||
isOpaque = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderBlockWireless.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int direction, int metadata)
|
||||
{
|
||||
return super.getIcon( direction, metadata );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
|
||||
{
|
||||
TileWireless tile = getTileEntity( w, x, y, z );
|
||||
if ( tile != null )
|
||||
{
|
||||
ForgeDirection forward = tile.getForward();
|
||||
|
||||
double minX = 0;
|
||||
double minY = 0;
|
||||
double minZ = 0;
|
||||
double maxX = 1;
|
||||
double maxY = 1;
|
||||
double maxZ = 1;
|
||||
|
||||
switch (forward)
|
||||
{
|
||||
case DOWN:
|
||||
minZ = minX = 3.0 / 16.0;
|
||||
maxZ = maxX = 13.0 / 16.0;
|
||||
maxY = 1.0;
|
||||
minY = 5.0 / 16.0;
|
||||
break;
|
||||
case EAST:
|
||||
minZ = minY = 3.0 / 16.0;
|
||||
maxZ = maxY = 13.0 / 16.0;
|
||||
maxX = 11.0 / 16.0;
|
||||
minX = 0.0;
|
||||
break;
|
||||
case NORTH:
|
||||
minY = minX = 3.0 / 16.0;
|
||||
maxY = maxX = 13.0 / 16.0;
|
||||
maxZ = 1.0;
|
||||
minZ = 5.0 / 16.0;
|
||||
break;
|
||||
case SOUTH:
|
||||
minY = minX = 3.0 / 16.0;
|
||||
maxY = maxX = 13.0 / 16.0;
|
||||
maxZ = 11.0 / 16.0;
|
||||
minZ = 0.0;
|
||||
break;
|
||||
case UP:
|
||||
minZ = minX = 3.0 / 16.0;
|
||||
maxZ = maxX = 13.0 / 16.0;
|
||||
maxY = 11.0 / 16.0;
|
||||
minY = 0.0;
|
||||
break;
|
||||
case WEST:
|
||||
minZ = minY = 3.0 / 16.0;
|
||||
maxZ = maxY = 13.0 / 16.0;
|
||||
maxX = 1.0;
|
||||
minX = 5.0 / 16.0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( minX, minY, minZ, maxX, maxY, maxZ ) } );
|
||||
}
|
||||
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) } );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
|
||||
{
|
||||
TileWireless tile = getTileEntity( w, x, y, z );
|
||||
if ( tile != null )
|
||||
{
|
||||
ForgeDirection forward = tile.getForward();
|
||||
|
||||
double minX = 0;
|
||||
double minY = 0;
|
||||
double minZ = 0;
|
||||
double maxX = 1;
|
||||
double maxY = 1;
|
||||
double maxZ = 1;
|
||||
|
||||
switch (forward)
|
||||
{
|
||||
case DOWN:
|
||||
minZ = minX = 3.0 / 16.0;
|
||||
maxZ = maxX = 13.0 / 16.0;
|
||||
maxY = 1.0;
|
||||
minY = 5.0 / 16.0;
|
||||
break;
|
||||
case EAST:
|
||||
minZ = minY = 3.0 / 16.0;
|
||||
maxZ = maxY = 13.0 / 16.0;
|
||||
maxX = 11.0 / 16.0;
|
||||
minX = 0.0;
|
||||
break;
|
||||
case NORTH:
|
||||
minY = minX = 3.0 / 16.0;
|
||||
maxY = maxX = 13.0 / 16.0;
|
||||
maxZ = 1.0;
|
||||
minZ = 5.0 / 16.0;
|
||||
break;
|
||||
case SOUTH:
|
||||
minY = minX = 3.0 / 16.0;
|
||||
maxY = maxX = 13.0 / 16.0;
|
||||
maxZ = 11.0 / 16.0;
|
||||
minZ = 0.0;
|
||||
break;
|
||||
case UP:
|
||||
minZ = minX = 3.0 / 16.0;
|
||||
maxZ = maxX = 13.0 / 16.0;
|
||||
maxY = 11.0 / 16.0;
|
||||
minY = 0.0;
|
||||
break;
|
||||
case WEST:
|
||||
minZ = minY = 3.0 / 16.0;
|
||||
maxZ = maxY = 13.0 / 16.0;
|
||||
maxX = 1.0;
|
||||
minX = 5.0 / 16.0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
out.add( AxisAlignedBB.getBoundingBox( minX, minY, minZ, maxX, maxY, maxZ ) );
|
||||
}
|
||||
else
|
||||
out.add( AxisAlignedBB.getBoundingBox( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if ( p.isSneaking() )
|
||||
return false;
|
||||
|
||||
TileWireless tg = getTileEntity( w, x, y, z );
|
||||
if ( tg != null )
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_WIRELESS );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package appeng.block.qnb;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.EffectType;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderQNB;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
import appeng.tile.qnb.TileQuantumBridge;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockQuantumLinkChamber extends AEBaseBlock implements ICustomCollision
|
||||
{
|
||||
|
||||
public BlockQuantumLinkChamber() {
|
||||
super( BlockQuantumLinkChamber.class, AEGlassMaterial.instance );
|
||||
setFeature( EnumSet.of( AEFeature.QuantumNetworkBridge ) );
|
||||
setTileEntity( TileQuantumBridge.class );
|
||||
float shave = 2.0f / 16.0f;
|
||||
setBlockBounds( shave, shave, shave, 1.0f - shave, 1.0f - shave, 1.0f - shave );
|
||||
setLightOpacity( 0 );
|
||||
isFullSize = isOpaque = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World w, int bx, int by, int bz, Random r)
|
||||
{
|
||||
TileQuantumBridge bridge = getTileEntity( w, bx, by, bz );
|
||||
if ( bridge != null )
|
||||
{
|
||||
if ( bridge.hasQES() )
|
||||
{
|
||||
if ( CommonHelper.proxy.shouldAddParticles( r ) )
|
||||
CommonHelper.proxy.spawnEffect( EffectType.Energy, w, bx + 0.5, by + 0.5, bz + 0.5, null );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World w, int x, int y, int z, Block pointlessnumber)
|
||||
{
|
||||
TileQuantumBridge bridge = getTileEntity( w, x, y, z );
|
||||
if ( bridge != null )
|
||||
bridge.neighborUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World w, int x, int y, int z, Block a, int b)
|
||||
{
|
||||
TileQuantumBridge bridge = getTileEntity( w, x, y, z );
|
||||
if ( bridge != null )
|
||||
bridge.breakCluster();
|
||||
|
||||
super.breakBlock( w, x, y, z, a, b );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderQNB.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if ( p.isSneaking() )
|
||||
return false;
|
||||
|
||||
TileQuantumBridge tg = getTileEntity( w, x, y, z );
|
||||
if ( tg != null )
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_QNB );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
|
||||
{
|
||||
double OnePx = 2.0 / 16.0;
|
||||
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( OnePx, OnePx, OnePx, 1.0 - OnePx, 1.0 - OnePx, 1.0 - OnePx ) } );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
|
||||
{
|
||||
double OnePx = 2.0 / 16.0;
|
||||
out.add( AxisAlignedBB.getBoundingBox( OnePx, OnePx, OnePx, 1.0 - OnePx, 1.0 - OnePx, 1.0 - OnePx ) );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package appeng.block.qnb;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderQNB;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
import appeng.tile.qnb.TileQuantumBridge;
|
||||
|
||||
public class BlockQuantumRing extends AEBaseBlock implements ICustomCollision
|
||||
{
|
||||
|
||||
public BlockQuantumRing() {
|
||||
super( BlockQuantumRing.class, Material.iron );
|
||||
setFeature( EnumSet.of( AEFeature.QuantumNetworkBridge ) );
|
||||
setTileEntity( TileQuantumBridge.class );
|
||||
float shave = 2.0f / 16.0f;
|
||||
setBlockBounds( shave, shave, shave, 1.0f - shave, 1.0f - shave, 1.0f - shave );
|
||||
setLightOpacity( 1 );
|
||||
isFullSize = isOpaque = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World w, int x, int y, int z, Block pointlessnumber)
|
||||
{
|
||||
TileQuantumBridge bridge = getTileEntity( w, x, y, z );
|
||||
if ( bridge != null )
|
||||
bridge.neighborUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World w, int x, int y, int z, Block a, int b)
|
||||
{
|
||||
TileQuantumBridge bridge = getTileEntity( w, x, y, z );
|
||||
if ( bridge != null )
|
||||
bridge.breakCluster();
|
||||
|
||||
super.breakBlock( w, x, y, z, a, b );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderQNB.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
|
||||
{
|
||||
double OnePx = 2.0 / 16.0;
|
||||
TileQuantumBridge bridge = getTileEntity( w, x, y, z );
|
||||
if ( bridge != null && bridge.isCorner() )
|
||||
{
|
||||
OnePx = 4.0 / 16.0;
|
||||
}
|
||||
else if ( bridge != null && bridge.isFormed() )
|
||||
{
|
||||
OnePx = 1.0 / 16.0;
|
||||
}
|
||||
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( OnePx, OnePx, OnePx, 1.0 - OnePx, 1.0 - OnePx, 1.0 - OnePx ) } );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
|
||||
{
|
||||
double OnePx = 2.0 / 16.0;
|
||||
TileQuantumBridge bridge = getTileEntity( w, x, y, z );
|
||||
if ( bridge != null && bridge.isCorner() )
|
||||
{
|
||||
OnePx = 4.0 / 16.0;
|
||||
}
|
||||
else if ( bridge != null && bridge.isFormed() )
|
||||
{
|
||||
OnePx = 1.0 / 16.0;
|
||||
}
|
||||
out.add( AxisAlignedBB.getBoundingBox( OnePx, OnePx, OnePx, 1.0 - OnePx, 1.0 - OnePx, 1.0 - OnePx ) );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package appeng.block.solids;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import appeng.block.AEDecorativeBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
public class BlockFluix extends AEDecorativeBlock
|
||||
{
|
||||
|
||||
public BlockFluix() {
|
||||
super( BlockFluix.class, Material.rock );
|
||||
setFeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package appeng.block.solids;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import appeng.block.AEDecorativeBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
public class BlockQuartz extends AEDecorativeBlock
|
||||
{
|
||||
|
||||
public BlockQuartz() {
|
||||
super( BlockQuartz.class, Material.rock );
|
||||
setFeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package appeng.block.solids;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import appeng.block.AEDecorativeBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
public class BlockQuartzChiseled extends AEDecorativeBlock
|
||||
{
|
||||
|
||||
public BlockQuartzChiseled() {
|
||||
super( BlockQuartzChiseled.class, Material.rock );
|
||||
setFeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package appeng.block.solids;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderQuartzGlass;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockQuartzGlass extends AEBaseBlock
|
||||
{
|
||||
|
||||
public BlockQuartzGlass() {
|
||||
this( BlockQuartzGlass.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderQuartzGlass.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered(IBlockAccess w, int x, int y, int z, int side)
|
||||
{
|
||||
Material mat = w.getBlock( x, y, z ).getMaterial();
|
||||
if ( mat == Material.glass || mat == AEGlassMaterial.instance )
|
||||
{
|
||||
if ( w.getBlock( x, y, z ).getRenderType() == this.getRenderType() )
|
||||
return false;
|
||||
}
|
||||
return super.shouldSideBeRendered( w, x, y, z, side );
|
||||
}
|
||||
|
||||
public BlockQuartzGlass(Class c) {
|
||||
super( c, Material.glass );
|
||||
setFeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
|
||||
setLightOpacity( 0 );
|
||||
isOpaque = false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package appeng.block.solids;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.client.render.effects.VibrantFX;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.features.AEFeature;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockQuartzLamp extends BlockQuartzGlass
|
||||
{
|
||||
|
||||
public BlockQuartzLamp() {
|
||||
super( BlockQuartzLamp.class );
|
||||
setFeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks, AEFeature.DecorativeLights ) );
|
||||
setLightLevel( 1.0f );
|
||||
setBlockTextureName( "BlockQuartzGlass" );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World w, int x, int y, int z, Random r)
|
||||
{
|
||||
if ( !AEConfig.instance.enableEffects )
|
||||
return;
|
||||
|
||||
if ( CommonHelper.proxy.shouldAddParticles( r ) )
|
||||
{
|
||||
double d0 = (double) (r.nextFloat() - 0.5F) * 0.96D;
|
||||
double d1 = (double) (r.nextFloat() - 0.5F) * 0.96D;
|
||||
double d2 = (double) (r.nextFloat() - 0.5F) * 0.96D;
|
||||
|
||||
VibrantFX fx = new VibrantFX( w, 0.5 + x + d0, 0.5 + y + d1, 0.5 + z + d2, 0.0D, 0.0D, 0.0D );
|
||||
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package appeng.block.solids;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.MetaRotation;
|
||||
|
||||
public class BlockQuartzPillar extends AEBaseBlock implements IOrientableBlock
|
||||
{
|
||||
|
||||
public BlockQuartzPillar() {
|
||||
super( BlockQuartzPillar.class, Material.rock );
|
||||
setFeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOrientable getOrientable(final IBlockAccess w, final int x, final int y, final int z)
|
||||
{
|
||||
return new MetaRotation( w, x, y, z );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean usesMetadata()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
package appeng.block.solids;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import rblocks.api.RotatableBlockEnable;
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.api.util.IOrientableBlock;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.WorldSettings;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.LocationRotation;
|
||||
import appeng.helpers.NullRotation;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.integration.abstraction.IRB;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@RotatableBlockEnable
|
||||
public class BlockSkyStone extends AEBaseBlock implements IOrientableBlock
|
||||
{
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
IIcon Block;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
IIcon Brick;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
IIcon SmallBrick;
|
||||
|
||||
@SubscribeEvent
|
||||
public void breakFaster(PlayerEvent.BreakSpeed Ev)
|
||||
{
|
||||
if ( Ev.block == this && Ev.entityPlayer != null )
|
||||
{
|
||||
ItemStack is = Ev.entityPlayer.inventory.getCurrentItem();
|
||||
int level = -1;
|
||||
|
||||
if ( is != null )
|
||||
level = is.getItem().getHarvestLevel( is, "pickaxe" );
|
||||
|
||||
if ( Ev.metadata > 0 || level >= 3 || Ev.originalSpeed > 7.0 )
|
||||
Ev.newSpeed /= 0.1;
|
||||
}
|
||||
}
|
||||
|
||||
public BlockSkyStone() {
|
||||
super( BlockSkyStone.class, Material.rock );
|
||||
setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
setHardness( 50 );
|
||||
hasSubtypes = true;
|
||||
blockResistance = 150.0f;
|
||||
setHarvestLevel( "pickaxe", 3, 0 );
|
||||
MinecraftForge.EVENT_BUS.register( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int meta)
|
||||
{
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack is)
|
||||
{
|
||||
if ( is.getItemDamage() == 1 )
|
||||
return getUnlocalizedName() + ".Block";
|
||||
|
||||
if ( is.getItemDamage() == 2 )
|
||||
return getUnlocalizedName() + ".Brick";
|
||||
|
||||
if ( is.getItemDamage() == 3 )
|
||||
return getUnlocalizedName() + ".SmallBrick";
|
||||
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IOrientable getOrientable(final IBlockAccess w, final int x, final int y, final int z)
|
||||
{
|
||||
if ( AppEng.instance.isIntegrationEnabled( IntegrationType.RB ) )
|
||||
{
|
||||
TileEntity te = w.getTileEntity( x, y, z );
|
||||
if ( te != null )
|
||||
{
|
||||
IOrientable out = ((IRB) AppEng.instance.getIntegration( IntegrationType.RB )).getOrientable( te );
|
||||
if ( out != null )
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
if ( w.getBlockMetadata( x, y, z ) == 0 )
|
||||
return new LocationRotation( w, x, y, z );
|
||||
|
||||
return new NullRotation();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister ir)
|
||||
{
|
||||
super.registerBlockIcons( ir );
|
||||
Block = ir.registerIcon( getTextureName() + ".Block" );
|
||||
Brick = ir.registerIcon( getTextureName() + ".Brick" );
|
||||
SmallBrick = ir.registerIcon( getTextureName() + ".SmallBrick" );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int direction, int metadata)
|
||||
{
|
||||
if ( metadata == 1 )
|
||||
return Block;
|
||||
if ( metadata == 2 )
|
||||
return Brick;
|
||||
if ( metadata == 3 )
|
||||
return SmallBrick;
|
||||
return super.getIcon( direction, metadata );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRenderStateByMeta(int metadata)
|
||||
{
|
||||
getRendererInstance().setTemporaryRenderIcon( getIcon( 0, metadata ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
|
||||
{
|
||||
ItemStack is = super.getPickBlock( target, world, x, y, z );
|
||||
is.setItemDamage( world.getBlockMetadata( x, y, z ) );
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item i, CreativeTabs ct, List l)
|
||||
{
|
||||
super.getSubBlocks( i, ct, l );
|
||||
l.add( new ItemStack( i, 1, 1 ) );
|
||||
l.add( new ItemStack( i, 1, 2 ) );
|
||||
l.add( new ItemStack( i, 1, 3 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World w, int x, int y, int z)
|
||||
{
|
||||
super.onBlockAdded( w, x, y, z );
|
||||
if ( Platform.isServer() )
|
||||
WorldSettings.getInstance().getCompass().updateArea( w, x, y, z );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World w, int x, int y, int z, Block b, int WTF)
|
||||
{
|
||||
super.breakBlock( w, x, y, z, b, WTF );
|
||||
if ( Platform.isServer() )
|
||||
WorldSettings.getInstance().getCompass().updateArea( w, x, y, z );
|
||||
}
|
||||
|
||||
// use AE2's renderer, no rotatable blocks.
|
||||
int getRealRenderType()
|
||||
{
|
||||
return getRenderType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean usesMetadata()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package appeng.block.solids;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderQuartzOre;
|
||||
import appeng.core.features.AEFeature;
|
||||
|
||||
public class OreQuartz extends AEBaseBlock
|
||||
{
|
||||
|
||||
public int boostBrightnessLow;
|
||||
public int boostBrightnessHigh;
|
||||
public boolean enhanceBrightness;
|
||||
|
||||
public OreQuartz(Class self) {
|
||||
super( self, Material.rock );
|
||||
setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
setHardness( 3.0F );
|
||||
setResistance( 5.0F );
|
||||
boostBrightnessLow = 0;
|
||||
boostBrightnessHigh = 1;
|
||||
enhanceBrightness = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit()
|
||||
{
|
||||
OreDictionary.registerOre( "oreCertusQuartz", new ItemStack( this ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderQuartzOre.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMixedBrightnessForBlock(IBlockAccess par1iBlockAccess, int par2, int par3, int par4)
|
||||
{
|
||||
int j1 = super.getMixedBrightnessForBlock( par1iBlockAccess, par2, par3, par4 );
|
||||
if ( enhanceBrightness )
|
||||
{
|
||||
j1 = Math.max( j1 >> 20, j1 >> 4 );
|
||||
|
||||
if ( j1 > 4 )
|
||||
j1 += boostBrightnessHigh;
|
||||
else
|
||||
j1 += boostBrightnessLow;
|
||||
|
||||
if ( j1 > 15 )
|
||||
j1 = 15;
|
||||
return j1 << 20 | j1 << 4;
|
||||
}
|
||||
return j1;
|
||||
}
|
||||
|
||||
public OreQuartz() {
|
||||
this( OreQuartz.class );
|
||||
}
|
||||
|
||||
ItemStack getItemDropped()
|
||||
{
|
||||
return AEApi.instance().materials().materialCertusQuartzCrystal.stack( 1 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int id, Random rand, int meta)
|
||||
{
|
||||
return getItemDropped().getItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int id)
|
||||
{
|
||||
return getItemDropped().getItemDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random rand)
|
||||
{
|
||||
return 1 + rand.nextInt( 2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDroppedWithBonus(int fortune, Random rand)
|
||||
{
|
||||
if ( fortune > 0 && Item.getItemFromBlock( this ) != getItemDropped( 0, rand, fortune ) )
|
||||
{
|
||||
int j = rand.nextInt( fortune + 2 ) - 1;
|
||||
|
||||
if ( j < 0 )
|
||||
{
|
||||
j = 0;
|
||||
}
|
||||
|
||||
return this.quantityDropped( rand ) * (j + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.quantityDropped( rand );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropBlockAsItemWithChance(World w, int x, int y, int z, int blockid, float something, int meta)
|
||||
{
|
||||
super.dropBlockAsItemWithChance( w, x, y, z, blockid, something, meta );
|
||||
|
||||
if ( getItemDropped( blockid, w.rand, meta ) != Item.getItemFromBlock( this ) )
|
||||
{
|
||||
int xp = MathHelper.getRandomIntegerInRange( w.rand, 2, 5 );
|
||||
|
||||
this.dropXpOnBlockBreak( w, x, y, z, xp );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package appeng.block.solids;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.client.render.effects.ChargedOreFX;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.CommonHelper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class OreQuartzCharged extends OreQuartz
|
||||
{
|
||||
|
||||
public OreQuartzCharged() {
|
||||
super( OreQuartzCharged.class );
|
||||
boostBrightnessLow = 2;
|
||||
boostBrightnessHigh = 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
ItemStack getItemDropped()
|
||||
{
|
||||
return AEApi.instance().materials().materialCertusQuartzCrystalCharged.stack( 1 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World w, int x, int y, int z, Random r)
|
||||
{
|
||||
if ( !AEConfig.instance.enableEffects )
|
||||
return;
|
||||
|
||||
double xOff = (double) (r.nextFloat());
|
||||
double yOff = (double) (r.nextFloat());
|
||||
double zOff = (double) (r.nextFloat());
|
||||
|
||||
switch (r.nextInt( 6 ))
|
||||
{
|
||||
case 0:
|
||||
xOff = -0.01;
|
||||
break;
|
||||
case 1:
|
||||
yOff = -0.01;
|
||||
break;
|
||||
case 2:
|
||||
xOff = -0.01;
|
||||
break;
|
||||
case 3:
|
||||
zOff = -0.01;
|
||||
break;
|
||||
case 4:
|
||||
xOff = 1.01;
|
||||
break;
|
||||
case 5:
|
||||
yOff = 1.01;
|
||||
break;
|
||||
case 6:
|
||||
zOff = 1.01;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( CommonHelper.proxy.shouldAddParticles( r ) )
|
||||
{
|
||||
ChargedOreFX fx = new ChargedOreFX( w, x + xOff, y + yOff, z + zOff, 0.0f, 0.0f, 0.0f );
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package appeng.block.spatial;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderNull;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
|
||||
public class BlockMatrixFrame extends AEBaseBlock implements ICustomCollision
|
||||
{
|
||||
|
||||
public BlockMatrixFrame() {
|
||||
super( BlockMatrixFrame.class, Material.anvil);
|
||||
setFeature( EnumSet.of( AEFeature.SpatialIO ) );
|
||||
setResistance( 6000000.0F );
|
||||
setBlockUnbreakable();
|
||||
setLightOpacity( 0 );
|
||||
isOpaque = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderNull.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item id, CreativeTabs tab, List list)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister iconRegistry)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
|
||||
{
|
||||
return Arrays.asList( new AxisAlignedBB[] {} );// AxisAlignedBB.getBoundingBox( 0.25, 0, 0.25, 0.75, 0.5, 0.75 )
|
||||
// } );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
|
||||
{
|
||||
out.add( AxisAlignedBB.getBoundingBox( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package appeng.block.spatial;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.spatial.TileSpatialIOPort;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockSpatialIOPort extends AEBaseBlock
|
||||
{
|
||||
|
||||
public BlockSpatialIOPort() {
|
||||
super( BlockSpatialIOPort.class, Material.iron );
|
||||
setFeature( EnumSet.of( AEFeature.SpatialIO ) );
|
||||
setTileEntity( TileSpatialIOPort.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onNeighborBlockChange(World w, int x, int y, int z, Block junk)
|
||||
{
|
||||
TileSpatialIOPort te = getTileEntity( w, x, y, z );
|
||||
if ( te != null )
|
||||
te.updateRedstoneState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if ( p.isSneaking() )
|
||||
return false;
|
||||
|
||||
TileSpatialIOPort tg = getTileEntity( w, x, y, z );
|
||||
if ( tg != null )
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_SPATIALIOPORT );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package appeng.block.spatial;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderSpatialPylon;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.AEGlassMaterial;
|
||||
import appeng.tile.spatial.TileSpatialPylon;
|
||||
|
||||
public class BlockSpatialPylon extends AEBaseBlock
|
||||
{
|
||||
|
||||
public BlockSpatialPylon() {
|
||||
super( BlockSpatialPylon.class, AEGlassMaterial.instance );
|
||||
setFeature( EnumSet.of( AEFeature.SpatialIO ) );
|
||||
setTileEntity( TileSpatialPylon.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World w, int x, int y, int z, Block junk)
|
||||
{
|
||||
TileSpatialPylon tsp = getTileEntity( w, x, y, z );
|
||||
if ( tsp != null )
|
||||
tsp.onNeighborBlockChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockAccess w, int x, int y, int z)
|
||||
{
|
||||
TileSpatialPylon tsp = getTileEntity( w, x, y, z );
|
||||
if ( tsp != null )
|
||||
return tsp.getLightValue();
|
||||
return super.getLightValue( w, x, y, z );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderSpatialPylon.class;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package appeng.block.storage;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.ICellHandler;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderMEChest;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.storage.TileChest;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockChest extends AEBaseBlock
|
||||
{
|
||||
|
||||
public BlockChest() {
|
||||
super( BlockChest.class, Material.iron );
|
||||
setFeature( EnumSet.of( AEFeature.StorageCells, AEFeature.MEChest ) );
|
||||
setTileEntity( TileChest.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderMEChest.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
TileChest tg = getTileEntity( w, x, y, z );
|
||||
if ( tg != null && !p.isSneaking() )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return true;
|
||||
|
||||
if ( side != tg.getUp().ordinal() )
|
||||
{
|
||||
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_CHEST );
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack cell = tg.getStackInSlot( 1 );
|
||||
if ( cell != null )
|
||||
{
|
||||
ICellHandler ch = AEApi.instance().registries().cell().getHandler( cell );
|
||||
|
||||
tg.openGui( p, ch, cell, side );
|
||||
}
|
||||
else
|
||||
p.addChatMessage( PlayerMessages.ChestCannotReadStorageCell.get() );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package appeng.block.storage;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderDrive;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.storage.TileDrive;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockDrive extends AEBaseBlock
|
||||
{
|
||||
|
||||
public BlockDrive() {
|
||||
super( BlockDrive.class, Material.iron );
|
||||
setFeature( EnumSet.of( AEFeature.StorageCells, AEFeature.MEDrive ) );
|
||||
setTileEntity( TileDrive.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderDrive.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if ( p.isSneaking() )
|
||||
return false;
|
||||
|
||||
TileDrive tg = getTileEntity( w, x, y, z );
|
||||
if ( tg != null )
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_DRIVE );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package appeng.block.storage;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.storage.TileIOPort;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class BlockIOPort extends AEBaseBlock
|
||||
{
|
||||
|
||||
public BlockIOPort() {
|
||||
super( BlockIOPort.class, Material.iron );
|
||||
setFeature( EnumSet.of( AEFeature.StorageCells, AEFeature.IOPort ) );
|
||||
setTileEntity( TileIOPort.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onNeighborBlockChange(World w, int x, int y, int z, Block junk)
|
||||
{
|
||||
TileIOPort te = getTileEntity( w, x, y, z );
|
||||
if ( te != null )
|
||||
te.updateRedstoneState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if ( p.isSneaking() )
|
||||
return false;
|
||||
|
||||
TileIOPort tg = getTileEntity( w, x, y, z );
|
||||
if ( tg != null )
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_IOPORT );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package appeng.block.storage;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockSkyChest;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockSkyChest extends AEBaseBlock implements ICustomCollision
|
||||
{
|
||||
|
||||
public BlockSkyChest() {
|
||||
super( BlockSkyChest.class, Material.rock );
|
||||
setFeature( EnumSet.of( AEFeature.Core, AEFeature.SkyStoneChests ) );
|
||||
setTileEntity( TileSkyChest.class );
|
||||
isOpaque = isFullSize = false;
|
||||
lightOpacity = 0;
|
||||
hasSubtypes = true;
|
||||
setHardness( 50 );
|
||||
blockResistance = 150.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack is)
|
||||
{
|
||||
if ( is.getItemDamage() == 1 )
|
||||
return getUnlocalizedName() + ".Block";
|
||||
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int metadata) {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int direction, int metadata)
|
||||
{
|
||||
if ( metadata == 1 )
|
||||
return AEApi.instance().blocks().blockSkyStone.block().getIcon( direction, 1 );
|
||||
return AEApi.instance().blocks().blockSkyStone.block().getIcon( direction, metadata );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
|
||||
{
|
||||
ItemStack is = super.getPickBlock( target, world, x, y, z );
|
||||
is.setItemDamage( world.getBlockMetadata( x, y, z ) );
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item i, CreativeTabs ct, List l)
|
||||
{
|
||||
super.getSubBlocks( i, ct, l );
|
||||
l.add( new ItemStack( i, 1, 1 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
Platform.openGUI( player, getTileEntity( w, x, y, z ), ForgeDirection.getOrientation( side ), GuiBridge.GUI_SKYCHEST );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderBlockSkyChest.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(World w, int x, int y, int z, Entity e, boolean isVisual)
|
||||
{
|
||||
TileSkyChest sk = getTileEntity( w, x, y, z );
|
||||
double sc = 0.06;
|
||||
ForgeDirection o = ForgeDirection.UNKNOWN;
|
||||
|
||||
if ( sk != null )
|
||||
o = sk.getUp();
|
||||
|
||||
double X = o.offsetX == 0 ? 0.06 : 0.0;
|
||||
double Y = o.offsetY == 0 ? 0.06 : 0.0;
|
||||
double Z = o.offsetZ == 0 ? 0.06 : 0.0;
|
||||
|
||||
return Arrays.asList( new AxisAlignedBB[] { AxisAlignedBB.getBoundingBox( Math.max( 0.0, X - o.offsetX * sc ), Math.max( 0.0, Y - o.offsetY * sc ),
|
||||
Math.max( 0.0, Z - o.offsetZ * sc ), Math.min( 1.0, (1.0 - X) - o.offsetX * sc ), Math.min( 1.0, (1.0 - Y) - o.offsetY * sc ),
|
||||
Math.min( 1.0, (1.0 - Z) - o.offsetZ * sc ) ) } );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollidingBlockToList(World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e)
|
||||
{
|
||||
out.add( AxisAlignedBB.getBoundingBox( 0.05, 0.05, 0.05, 0.95, 0.95, 0.95 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister iconRegistry)
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user