AE2 First Commit, the dawn of 1.7 hast arrived.

This commit is contained in:
algorithmx2
2013-12-27 16:59:59 -06:00
commit e9acdcbee2
468 changed files with 47440 additions and 0 deletions
+688
View File
@@ -0,0 +1,688 @@
package appeng.block;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
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.IconRegister;
import net.minecraft.client.resources.Resource;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon;
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.ForgeDirection;
import appeng.api.implementations.IMemoryCard;
import appeng.api.implementations.MemoryCardMessages;
import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.BlockRenderInfo;
import appeng.client.render.WorldRender;
import appeng.client.texture.FlipableIcon;
import appeng.core.Configuration;
import appeng.core.features.AEFeature;
import appeng.core.features.AEFeatureHandler;
import appeng.core.features.IAEFeature;
import appeng.helpers.ICustomCollision;
import appeng.tile.AEBaseTile;
import appeng.tile.networking.TileCableBus;
import appeng.util.LookDirection;
import appeng.util.Platform;
import appeng.util.SettingsFrom;
import cpw.mods.fml.common.registry.GameRegistry;
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;
@SideOnly(Side.CLIENT)
public Icon 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 FlipableIcon optionaIcon(IconRegister ir, String Name, Icon substitute)
{
// if the input is an flippable icon find the original.
while (substitute instanceof FlipableIcon)
substitute = ((FlipableIcon) 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" } ) );
Resource res = Minecraft.getMinecraft().getResourceManager().getResource( resLoc );
if ( res != null )
return new FlipableIcon( ir.registerIcon( Name ) );
}
catch (Throwable e)
{
return new FlipableIcon( substitute );
}
}
return new FlipableIcon( ir.registerIcon( Name ) );
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegistry)
{
BlockRenderInfo info = getRendererInstance();
FlipableIcon topIcon;
FlipableIcon bottomIcon;
FlipableIcon sideIcon;
FlipableIcon eastIcon;
FlipableIcon westIcon;
FlipableIcon southIcon;
FlipableIcon northIcon;
this.blockIcon = topIcon = optionaIcon( iconRegistry, this.getTextureName(), null );
bottomIcon = optionaIcon( iconRegistry, this.getTextureName() + "Bottom", topIcon );
sideIcon = optionaIcon( iconRegistry, this.getTextureName() + "Side", topIcon );
eastIcon = optionaIcon( iconRegistry, this.getTextureName() + "East", sideIcon );
westIcon = optionaIcon( iconRegistry, this.getTextureName() + "West", sideIcon );
southIcon = optionaIcon( iconRegistry, this.getTextureName() + "Front", sideIcon );
northIcon = optionaIcon( iconRegistry, this.getTextureName() + "Back", sideIcon );
info.updateIcons( bottomIcon, topIcon, northIcon, southIcon, eastIcon, westIcon );
}
@Override
@SideOnly(Side.CLIENT)
public Icon getIcon(int direction, int metadata)
{
if ( renderIcon != null )
return renderIcon;
return getRendererInstance().getTexture( ForgeDirection.getOrientation( direction ) );
}
@Override
public Icon getBlockTexture(IBlockAccess w, int x, int y, int z, int s)
{
return getIcon( mapRotation( w, x, y, z, s ), 0 );
}
protected void setTileEntiy(Class<? extends TileEntity> c)
{
GameRegistry.registerTileEntity( tileEntityType = c, FeatureFullname );
}
protected void setfeature(EnumSet<AEFeature> f)
{
feature = new AEFeatureHandler( f, this, FeatureSubname );
}
protected AEBaseBlock(Class<?> c, Material mat) {
this( c, mat, null );
setLightOpacity( 15 );
setLightValue( 0 );
setHardness( 1.2F );
}
protected AEBaseBlock(Class<?> c, Material mat, String subname) {
super( Configuration.instance.getBlockID( c, subname ), mat );
if ( mat == Material.glass )
setStepSound( Block.soundGlassFootstep );
else if ( mat == Material.rock )
setStepSound( Block.soundStoneFootstep );
else
setStepSound( Block.soundMetalFootstep );
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 isBlockNormalCube(World world, int x, int y, int z)
{
return isFullSize;
}
public boolean hasBlockTileEntity()
{
return tileEntityType != null;
}
@Override
final public boolean hasTileEntity(int metadata)
{
return hasBlockTileEntity();
}
public Class<? extends TileEntity> getTileEntityClass()
{
return tileEntityType;
}
@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 createTileEntity(World world, int metadata)
{
try
{
return tileEntityType.newInstance();
}
catch (Throwable e)
{
throw new RuntimeException( e );
}
}
@Override
final public TileEntity createNewTileEntity(World world)
{
return createTileEntity( world, 0 );
}
final public <T extends TileEntity> T getTileEntity(IBlockAccess w, int x, int y, int z)
{
if ( !hasBlockTileEntity() )
return null;
TileEntity te = w.getBlockTileEntity( x, y, z );
if ( tileEntityType.isInstance( te ) )
return (T) te;
return null;
}
@Override
final public boolean rotateBlock(World w, int x, int y, int z, ForgeDirection axis)
{
IOrientable rotateable = null;
if ( hasBlockTileEntity() )
{
rotateable = (AEBaseTile) getTileEntity( w, x, y, z );
}
else if ( this instanceof IOrientableBlock )
{
rotateable = ((IOrientableBlock) this).getOrientable( w, x, y, z );
}
if ( rotateable != null && rotateable.canBeRotated() )
{
ForgeDirection forward = rotateable.getForward();
ForgeDirection up = rotateable.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 ) )
{
rotateable.setOrientation( forward, up );
return true;
}
}
}
return false;
}
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, int a, int b)
{
AEBaseTile te = getTileEntity( w, x, y, z );
if ( te != null )
{
if ( te.dropItems )
{
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
te.getDrops( 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.setBlockTileEntity( 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.getSelectedBoundingBoxsFromPool( w, x, y, z );
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
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() )
{
LookDirection ld = Platform.getPlayerRay( Minecraft.getMinecraft().thePlayer );
Iterable<AxisAlignedBB> bbs = collisionHandler.getSelectedBoundingBoxsFromPool( w, x, y, z );
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.getSelectedBoundingBoxsFromPool( w, x, y, z ))
{
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
final 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() )
{
int id = w.getBlockId( x, y, z );
if ( id != 0 )
{
AEBaseTile tile = getTileEntity( w, x, y, z );
ItemStack[] drops = Platform.getBlockDrops( w, x, y, z );
if ( tile == null )
return false;
if ( tile instanceof TileCableBus )
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 ( Block.blocksList[id].removeBlockByPlayer( w, player, x, y, z ) )
{
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 )
{
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( this, player, MemoryCardMessages.SETTINGS_SAVED );
return false;
}
}
}
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( this, player, MemoryCardMessages.SETTINGS_LOADED );
}
else
memc.notifyUser( this, 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 void addInformation(ItemStack is, EntityPlayer player, List<?> lines, boolean advancedItemTooltips)
{
}
public Class<AEBaseItemBlock> getItemBlockClass()
{
return AEBaseItemBlock.class;
}
}
+131
View File
@@ -0,0 +1,131 @@
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.ForgeDirection;
import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import appeng.client.render.ItemRenderer;
import appeng.tile.AEBaseTile;
import appeng.util.Platform;
public class AEBaseItemBlock extends ItemBlock
{
final AEBaseBlock blockType;
public AEBaseItemBlock(int id) {
super( id );
blockType = (AEBaseBlock) Block.blocksList[id + 256];
if ( Platform.isClient() )
MinecraftForgeClient.registerItemRenderer( blockType.blockID, ItemRenderer.instance );
}
@Override
public void addInformation(ItemStack is, EntityPlayer player, List lines, boolean advancedItemTooltips)
{
Block blk = Block.blocksList[getBlockID()];
if ( blk instanceof AEBaseBlock )
((AEBaseBlock) blk).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() )
{
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() )
{
AEBaseTile tile = blockType.getTileEntity( w, x, y, z );
ori = tile;
if ( tile == null )
return true;
if ( ori.canBeRotated() )
{
if ( ori.getForward() == null || ori.getUp() == null || // null
tile.getForward() == ForgeDirection.UNKNOWN || ori.getUp() == ForgeDirection.UNKNOWN )
ori.setOrientation( forward, up );
}
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;
}
}
+118
View File
@@ -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.IAEItemPowerStorage;
import appeng.util.Platform;
public class AEBaseItemBlockChargeable extends AEBaseItemBlock implements IAEItemPowerStorage
{
public AEBaseItemBlockChargeable(int 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( Platform.gui_localize( "Stored Energy" ) + ":" + MessageFormat.format( " {0,number,#} ", internalCurrentPower )
+ Platform.gui_localize( PowerUnits.AE.unlocalizedName ) + " - "
+ MessageFormat.format( " {0,number,#.##%} ", percent ) );
}
private double getMax(ItemStack is)
{
Block blk = Block.blocksList[getBlockID()];
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;
}
}
+114
View File
@@ -0,0 +1,114 @@
package appeng.block.grindstone;
import java.util.EnumSet;
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.ForgeDirection;
import appeng.api.implementations.ICrankable;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockCrank;
import appeng.core.features.AEFeature;
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 ) );
setTileEntiy( 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)
{
AEBaseTile tile = getTileEntity( w, x, y, z );
if ( tile instanceof TileCrank )
{
((TileCrank) tile).power();
}
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.getBlockTileEntity( 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.getBlockTileEntity( 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.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, int 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 );
}
}
+36
View File
@@ -0,0 +1,36 @@
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.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 ) );
setTileEntiy( TileGrinder.class );
}
@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;
}
}
+19
View File
@@ -0,0 +1,19 @@
package appeng.block.mac;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import appeng.block.AEBaseBlock;
import appeng.core.features.AEFeature;
import appeng.tile.mac.TileMolecularAssembler;
public class BlockContainmentWall extends AEBaseBlock
{
public BlockContainmentWall() {
super( BlockContainmentWall.class, Material.iron );
setfeature( EnumSet.of( AEFeature.MolecularAssembler ) );
setTileEntiy( TileMolecularAssembler.class );
}
}
+19
View File
@@ -0,0 +1,19 @@
package appeng.block.mac;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import appeng.block.AEBaseBlock;
import appeng.core.features.AEFeature;
import appeng.tile.mac.TileMolecularAssembler;
public class BlockCraftingAccelerator extends AEBaseBlock
{
public BlockCraftingAccelerator() {
super( BlockCraftingAccelerator.class, Material.iron );
setfeature( EnumSet.of( AEFeature.MolecularAssembler ) );
setTileEntiy( TileMolecularAssembler.class );
}
}
+19
View File
@@ -0,0 +1,19 @@
package appeng.block.mac;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import appeng.block.AEBaseBlock;
import appeng.core.features.AEFeature;
import appeng.tile.mac.TileMolecularAssembler;
public class BlockHeatVent extends AEBaseBlock
{
public BlockHeatVent() {
super( BlockHeatVent.class, Material.iron );
setfeature( EnumSet.of( AEFeature.MolecularAssembler ) );
setTileEntiy( TileMolecularAssembler.class );
}
}
+19
View File
@@ -0,0 +1,19 @@
package appeng.block.mac;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import appeng.block.AEBaseBlock;
import appeng.core.features.AEFeature;
import appeng.tile.mac.TilePatternProvider;
public class BlockPatternProvider extends AEBaseBlock
{
public BlockPatternProvider() {
super( BlockPatternProvider.class, Material.iron );
setfeature( EnumSet.of( AEFeature.MolecularAssembler ) );
setTileEntiy( TilePatternProvider.class );
}
}
+155
View File
@@ -0,0 +1,155 @@
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.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.LightningEffect;
import appeng.core.Configuration;
import appeng.core.features.AEFeature;
import appeng.helpers.ICustomCollision;
import appeng.tile.AEBaseTile;
import appeng.tile.misc.TileCharger;
import appeng.util.Platform;
public class BlockCharger extends AEBaseBlock implements ICustomCollision
{
public BlockCharger() {
super( BlockCharger.class, Material.iron );
setfeature( EnumSet.of( AEFeature.Core ) );
setTileEntiy( TileCharger.class );
setLightOpacity( 2 );
isFullSize = false;
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
public void randomDisplayTick(World w, int x, int y, int z, Random r)
{
if ( !Configuration.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.sameAs( tc.getStackInSlot( 0 ) ) )
{
double xOff = 0.0;
double yOff = 0.0;
double zOff = 0.0;
for (int bolts = 0; bolts < 3; bolts++)
{
LightningEffect fx = new LightningEffect( 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> getSelectedBoundingBoxsFromPool(World w, int x, int y, int z)
{
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.getAABBPool().getAABB( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
}
}
+43
View File
@@ -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.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 ) );
setTileEntiy( 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;
}
}
+40
View File
@@ -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 appeng.block.AEBaseBlock;
import appeng.core.features.AEFeature;
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 ) );
setTileEntiy( TileInscriber.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() )
{
TileInscriber tc = getTileEntity( w, x, y, z );
if ( tc != null )
{
tc.activate( player );
}
}
return true;
}
}
+19
View File
@@ -0,0 +1,19 @@
package appeng.block.misc;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import appeng.block.AEBaseBlock;
import appeng.core.features.AEFeature;
import appeng.tile.misc.TileInterface;
public class BlockInterface extends AEBaseBlock
{
public BlockInterface() {
super( BlockInterface.class, Material.iron );
setfeature( EnumSet.of( AEFeature.Core ) );
setTileEntiy( TileInterface.class );
}
}
+40
View File
@@ -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 appeng.block.AEBaseBlock;
import appeng.core.features.AEFeature;
import appeng.tile.misc.TileNetworkEmitter;
import appeng.util.Platform;
public class BlockNetworkEmitter extends AEBaseBlock
{
public BlockNetworkEmitter() {
super( BlockNetworkEmitter.class, Material.iron );
setfeature( EnumSet.of( AEFeature.Core ) );
setTileEntiy( TileNetworkEmitter.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() )
{
TileNetworkEmitter tc = getTileEntity( w, x, y, z );
if ( tc != null )
{
tc.activate( player );
}
}
return true;
}
}
+19
View File
@@ -0,0 +1,19 @@
package appeng.block.misc;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import appeng.block.AEBaseBlock;
import appeng.core.features.AEFeature;
import appeng.tile.misc.TilePartitionerEditor;
public class BlockPartitionEditor extends AEBaseBlock
{
public BlockPartitionEditor() {
super( BlockPartitionEditor.class, Material.iron );
setfeature( EnumSet.of( AEFeature.StorageCells ) );
setTileEntiy( TilePartitionerEditor.class );
}
}
+40
View File
@@ -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 appeng.block.AEBaseBlock;
import appeng.core.features.AEFeature;
import appeng.tile.misc.TileQuartzCrystalizer;
import appeng.util.Platform;
public class BlockQuartzCrystalizer extends AEBaseBlock
{
public BlockQuartzCrystalizer() {
super( BlockQuartzCrystalizer.class, Material.iron );
setfeature( EnumSet.of( AEFeature.Core ) );
setTileEntiy( TileQuartzCrystalizer.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() )
{
TileQuartzCrystalizer tc = getTileEntity( w, x, y, z );
if ( tc != null )
{
tc.activate( player );
}
}
return true;
}
}
+128
View File
@@ -0,0 +1,128 @@
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.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.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.LightningEffect;
import appeng.core.Configuration;
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
{
public BlockQuartzTorch() {
super( BlockQuartzTorch.class, Material.circuits );
setfeature( EnumSet.of( AEFeature.DecorativeLights ) );
setLightOpacity( 0 );
setLightValue( 0.9375F );
isFullSize = isOpaque = false;
}
@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.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.isBlockSolidOnSide( 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, int 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> getSelectedBoundingBoxsFromPool(World w, int x, int y, int z)
{
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.getAABBPool().getAABB( 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 ( !Configuration.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++)
{
LightningEffect fx = new LightningEffect( 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 );
}
}
}
+157
View File
@@ -0,0 +1,157 @@
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.IconRegister;
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.item.Item;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon;
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.render.entity.EntityIds;
import appeng.client.texture.FullIcon;
import appeng.core.AppEng;
import appeng.core.features.AEFeature;
import appeng.entity.EntityTinyTNTPrimed;
import appeng.helpers.DispenserBehaviorTinyTNT;
import appeng.helpers.ICustomCollision;
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 );
BlockDispenser.dispenseBehaviorRegistry.putObject( Item.itemsList[blockID], new DispenserBehaviorTinyTNT() );
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderTinyTNT.class;
}
@Override
public void registerIcons(IconRegister iconRegistry)
{
// no images required.
}
@Override
public Icon getIcon(int direction, int metadata)
{
return new FullIcon( Block.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, int 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().itemID == Item.flintAndSteel.itemID )
{
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, "random.fuse", 1.0F, 1.0F );
}
}
@Override
public boolean canDropFromExplosion(Explosion exp)
{
return false;
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxsFromPool(World w, int x, int y, int z)
{
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.getAABBPool().getAABB( 0.25, 0, 0.25, 0.75, 0.5, 0.75 ) );
}
}
+107
View File
@@ -0,0 +1,107 @@
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.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import appeng.block.AEBaseBlock;
import appeng.client.texture.ExtraTextures;
import appeng.core.Configuration;
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 ) );
setTileEntiy( TileVibrationChamber.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() )
{
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 Icon getBlockTexture(IBlockAccess w, int x, int y, int z, int s)
{
Icon ico = super.getBlockTexture( w, x, y, z, s );
TileVibrationChamber tvc = getTileEntity( w, x, y, z );
if ( tvc != null && tvc.isOn && ico == getRendererInstance().getTexture( ForgeDirection.SOUTH ) )
{
return ExtraTextures.BlockVibrationChamberFrontOn.getIcon();
}
return ico;
}
@Override
public void randomDisplayTick(World w, int x, int y, int z, Random r)
{
if ( !Configuration.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 );
}
}
}
}
+234
View File
@@ -0,0 +1,234 @@
package appeng.block.networking;
import java.util.EnumSet;
import java.util.List;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import appeng.api.parts.SelectedPart;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RendererCableBus;
import appeng.client.texture.CableBusTextures;
import appeng.core.Api;
import appeng.core.AppEng;
import appeng.core.features.AEFeature;
import appeng.integration.abstraction.IFMP;
import appeng.parts.CableBusContainer;
import appeng.tile.AEBaseTile;
import appeng.tile.networking.TileCableBus;
public class BlockCableBus extends AEBaseBlock
{
public BlockCableBus() {
super( BlockCableBus.class, Material.glass );
setfeature( EnumSet.of( AEFeature.Core ) );
setLightOpacity( 0 );
isFullSize = isOpaque = false;
}
@Override
public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour)
{
try
{
return cb( world, x, y, z ).recolourBlock( side, colour );
}
catch (Throwable t)
{
}
return false;
}
@Override
public void randomDisplayTick(World world, int x, int y, int z, Random r)
{
CableBusContainer cb = cb( world, x, y, z );
if ( cb != null )
cb.randomDisplayTick( world, x, y, z, r );
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z)
{
CableBusContainer cb = cb( world, x, y, z );
if ( cb != null )
return cb.getLightValue();
return 0;
}
@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 != null )
{
if ( sp.part != null )
return sp.part.getItemStack( false );
if ( sp.facade != null )
return sp.facade.getItemStack();
}
return null;
}
@Override
public boolean isBlockReplaceable(World world, int x, int y, int z)
{
return cb( world, x, y, z ).isEmpty();
}
@Override
public boolean removeBlockByPlayer(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.dropItems = false;
// maybe ray trace?
}
return super.removeBlockByPlayer( world, player, x, y, z );
}
@Override
public Icon getBlockTexture(IBlockAccess w, int x, int y, int z, int s)
{
return getIcon( s, 0 );
}
@Override
public Icon getIcon(int direction, int metadata)
{
Icon i = super.getIcon( direction, metadata );
if ( i != null )
return i;
return CableBusTextures.getMissing();
}
private CableBusContainer cb(IBlockAccess w, int x, int y, int z)
{
TileEntity te = w.getBlockTileEntity( x, y, z );
if ( te instanceof TileCableBus )
return ((TileCableBus) te).cb;
if ( AppEng.instance.isIntegrationEnabled( "FMP" ) )
return ((IFMP) AppEng.instance.getIntegration( "FMP" )).getCableContainer( te );
return null;
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RendererCableBus.class;
}
@Override
public void registerIcons(IconRegister iconRegistry)
{
}
private int rs(int side)
{
int s = 0;
switch (side)
{
case -1:
s = 1;
break;
case 1:
s = 2;
break;
case 2:
s = 5;
break;
case 3:
s = 3;
break;
case 4:
s = 4;
break;
default:
}
return s;
}
@Override
public boolean canProvidePower()
{
return true;
}
@Override
public boolean isBlockSolidOnSide(World 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, int meh)
{
cb( w, x, y, z ).onNeighborChanged();
// kinda works
/*
* if ( cb( w, x, y, z ).isEmpty() ) { 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)
{
return cb( w, x, y, z ).activate( player, w.getWorldVec3Pool().getVecFromPool( 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)
{
return cb( w, x, y, z ).canConnectRedstone( ForgeDirection.getOrientation( rs( side ) ) );
}
@Override
public int isProvidingWeakPower(IBlockAccess w, int x, int y, int z, int side)
{
return cb( w, x, y, z ).isProvidingWeakPower( ForgeDirection.getOrientation( side ) );
}
@Override
public int isProvidingStrongPower(IBlockAccess w, int x, int y, int z, int side)
{
return cb( w, x, y, z ).isProvidingStrongPower( ForgeDirection.getOrientation( side ) );
}
@Override
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
}
public void setupTile()
{
setTileEntiy( Api.instance.partHelper.getCombinedInstance( TileCableBus.class.getName() ) );
}
}
+36
View File
@@ -0,0 +1,36 @@
package appeng.block.networking;
import java.util.EnumSet;
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.Core ) );
setTileEntiy( TileController.class );
}
@Override
public void onNeighborBlockChange(World w, int x, int y, int z, int 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 net.minecraft.block.material.Material;
import appeng.block.AEBaseBlock;
import appeng.core.features.AEFeature;
import appeng.tile.networking.TileCreativeEnergyCell;
public class BlockCreativeEnergyCell extends AEBaseBlock
{
public BlockCreativeEnergyCell() {
super( BlockCreativeEnergyCell.class, Material.glass );
setfeature( EnumSet.of( AEFeature.Creative ) );
setTileEntiy( TileCreativeEnergyCell.class );
}
}
@@ -0,0 +1,51 @@
package appeng.block.networking;
import java.util.EnumSet;
import net.minecraft.util.Icon;
import appeng.client.texture.ExtraTextures;
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 ) );
setTileEntiy( TileDenseEnergyCell.class );
}
@Override
public Icon getIcon(int direction, int metadata)
{
switch (metadata)
{
case 0:
return ExtraTextures.MEDenseEnergyCell0.getIcon();
case 1:
return ExtraTextures.MEDenseEnergyCell1.getIcon();
case 2:
return ExtraTextures.MEDenseEnergyCell2.getIcon();
case 3:
return ExtraTextures.MEDenseEnergyCell3.getIcon();
case 4:
return ExtraTextures.MEDenseEnergyCell4.getIcon();
case 5:
return ExtraTextures.MEDenseEnergyCell5.getIcon();
case 6:
return ExtraTextures.MEDenseEnergyCell6.getIcon();
case 7:
return ExtraTextures.MEDenseEnergyCell7.getIcon();
}
return super.getIcon( direction, metadata );
}
}
+19
View File
@@ -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 ) );
setTileEntiy( TileEnergyAcceptor.class );
}
}
+88
View File
@@ -0,0 +1,88 @@
package appeng.block.networking;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Icon;
import appeng.block.AEBaseBlock;
import appeng.block.AEBaseItemBlockChargeable;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockEnergyCube;
import appeng.client.texture.ExtraTextures;
import appeng.core.features.AEFeature;
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, Material.glass );
}
public BlockEnergyCell() {
this( BlockEnergyCell.class );
setfeature( EnumSet.of( AEFeature.Core ) );
setTileEntiy( TileEnergyCell.class );
}
@Override
public void getSubBlocks(int 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 Icon getIcon(int direction, int metadata)
{
switch (metadata)
{
case 0:
return ExtraTextures.MEEnergyCell0.getIcon();
case 1:
return ExtraTextures.MEEnergyCell1.getIcon();
case 2:
return ExtraTextures.MEEnergyCell2.getIcon();
case 3:
return ExtraTextures.MEEnergyCell3.getIcon();
case 4:
return ExtraTextures.MEEnergyCell4.getIcon();
case 5:
return ExtraTextures.MEEnergyCell5.getIcon();
case 6:
return ExtraTextures.MEEnergyCell6.getIcon();
case 7:
return ExtraTextures.MEEnergyCell7.getIcon();
}
return super.getIcon( direction, metadata );
}
@Override
public Class getItemBlockClass()
{
return AEBaseItemBlockChargeable.class;
}
}
+169
View File
@@ -0,0 +1,169 @@
package appeng.block.networking;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockWireless;
import appeng.core.features.AEFeature;
import appeng.helpers.ICustomCollision;
import appeng.tile.networking.TileWireless;
public class BlockWireless extends AEBaseBlock implements ICustomCollision
{
public BlockWireless() {
super( BlockWireless.class, Material.glass );
setfeature( EnumSet.of( AEFeature.Core, AEFeature.WirelessAccessTerminal ) );
setTileEntiy( TileWireless.class );
setLightOpacity( 0 );
isFullSize = false;
isOpaque = false;
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderBlockWireless.class;
}
@Override
public Icon getIcon(int direction, int metadata)
{
return super.getIcon( direction, metadata );
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxsFromPool(World w, int x, int y, int z)
{
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.getAABBPool().getAABB( minX, minY, minZ, maxX, maxY, maxZ ) );
}
else
out.add( AxisAlignedBB.getAABBPool().getAABB( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
}
}
+31
View File
@@ -0,0 +1,31 @@
package appeng.block.qnb;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderQNB;
import appeng.core.features.AEFeature;
import appeng.tile.qnb.TileQuantumBridge;
public class BlockQuantumLinkChamber extends AEBaseBlock
{
public BlockQuantumLinkChamber() {
super( BlockQuantumLinkChamber.class, Material.glass );
setfeature( EnumSet.of( AEFeature.QuantumNetworkBridge ) );
setTileEntiy( 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
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderQNB.class;
}
}
+31
View File
@@ -0,0 +1,31 @@
package appeng.block.qnb;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderQNB;
import appeng.core.features.AEFeature;
import appeng.tile.qnb.TileQuantumBridge;
public class BlockQuantumRing extends AEBaseBlock
{
public BlockQuantumRing() {
super( BlockQuantumRing.class, Material.iron );
setfeature( EnumSet.of( AEFeature.QuantumNetworkBridge ) );
setTileEntiy( 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
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderQNB.class;
}
}
+37
View File
@@ -0,0 +1,37 @@
package appeng.block.solids;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderNull;
import appeng.core.features.AEFeature;
public class BlockMatrixFrame extends AEBaseBlock
{
public BlockMatrixFrame() {
super( BlockMatrixFrame.class, Material.portal );
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(int id, CreativeTabs tab, List list)
{
}
}
+17
View File
@@ -0,0 +1,17 @@
package appeng.block.solids;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import appeng.block.AEBaseBlock;
import appeng.core.features.AEFeature;
public class BlockQuartz extends AEBaseBlock
{
public BlockQuartz() {
super( BlockQuartz.class, Material.rock );
setfeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
}
}
+17
View File
@@ -0,0 +1,17 @@
package appeng.block.solids;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import appeng.block.AEBaseBlock;
import appeng.core.features.AEFeature;
public class BlockQuartzChiseled extends AEBaseBlock
{
public BlockQuartzChiseled() {
super( BlockQuartzChiseled.class, Material.rock );
setfeature( EnumSet.of( AEFeature.DecorativeQuartzBlocks ) );
}
}
+47
View File
@@ -0,0 +1,47 @@
package appeng.block.solids;
import java.util.EnumSet;
import net.minecraft.block.Block;
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 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)
{
if ( w.getBlockMaterial( x, y, z ) == Material.glass )
{
if ( Block.blocksList[w.getBlockId( 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;
}
}
+41
View File
@@ -0,0 +1,41 @@
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.VibrantEffect;
import appeng.core.Configuration;
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 ) );
setLightValue( 1.0f );
setTextureName( "BlockQuartzGlass" );
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World w, int x, int y, int z, Random r)
{
if ( !Configuration.instance.enableEffects )
return;
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;
VibrantEffect fx = new VibrantEffect( 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 );
}
}
+27
View File
@@ -0,0 +1,27 @@
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 );
}
}
+129
View File
@@ -0,0 +1,129 @@
package appeng.block.solids;
import java.util.EnumSet;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderQuartzOre;
import appeng.core.features.AEFeature;
import appeng.helpers.LocationRotation;
public class OreQuartz extends AEBaseBlock implements IOrientableBlock
{
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
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 IOrientable getOrientable(final IBlockAccess w, final int x, final int y, final int z)
{
return new LocationRotation( w, x, y, z );
}
@Override
public int idDropped(int id, Random rand, int meta)
{
return getItemDropped().itemID;
}
@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 && this.blockID != this.idDropped( 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 ( this.idDropped( blockid, w.rand, meta ) != this.blockID )
{
int xp = MathHelper.getRandomIntegerInRange( w.rand, 2, 5 );
this.dropXpOnBlockBreak( w, x, y, z, xp );
}
}
}
+70
View File
@@ -0,0 +1,70 @@
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.ChargedOreEffect;
import appeng.core.Configuration;
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 ( !Configuration.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;
}
ChargedOreEffect fx = new ChargedOreEffect( w, x + xOff, y + yOff, z + zOff, 0.0f, 0.0f, 0.0f );
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
}
}
+28
View File
@@ -0,0 +1,28 @@
package appeng.block.spatial;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.world.World;
import appeng.block.AEBaseBlock;
import appeng.core.features.AEFeature;
import appeng.tile.spatial.TileSpatialIOPort;
public class BlockSpatialIOPort extends AEBaseBlock
{
public BlockSpatialIOPort() {
super( BlockSpatialIOPort.class, Material.iron );
setfeature( EnumSet.of( AEFeature.SpatialIO ) );
setTileEntiy( TileSpatialIOPort.class );
}
@Override
public final void onNeighborBlockChange(World w, int x, int y, int z, int junk)
{
TileSpatialIOPort te = getTileEntity( w, x, y, z );
if ( te != null )
te.updateRedstoneState();
}
}
+46
View File
@@ -0,0 +1,46 @@
package appeng.block.spatial;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
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.tile.spatial.TileSpatialPylon;
public class BlockSpatialPylon extends AEBaseBlock
{
public BlockSpatialPylon() {
super( BlockSpatialPylon.class, Material.glass );
setfeature( EnumSet.of( AEFeature.SpatialIO ) );
setTileEntiy( TileSpatialPylon.class );
}
@Override
public void onNeighborBlockChange(World w, int x, int y, int z, int 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;
}
}
+86
View File
@@ -0,0 +1,86 @@
package appeng.block.storage;
import java.util.EnumSet;
import java.util.List;
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.ForgeDirection;
import appeng.api.AEApi;
import appeng.api.storage.ICellHandler;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.StorageChannel;
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 ) );
setTileEntiy( 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 if ( tg.isPowered() )
{
ItemStack cell = tg.getStackInSlot( 1 );
if ( cell != null )
{
ICellHandler ch = AEApi.instance().registries().cell().getHander( cell );
List<IMEInventoryHandler> ih = tg.getCellArray( StorageChannel.ITEMS );
if ( ch != null && ih != null && ih.size() == 1 )
{
IMEInventoryHandler mine = ih.get( 0 );
ch.openChestGui( p, tg, ch, mine, cell, StorageChannel.ITEMS );
return true;
}
List<IMEInventoryHandler> fh = tg.getCellArray( StorageChannel.FLUIDS );
if ( ch != null && fh != null && ih.size() == 1 )
{
IMEInventoryHandler mine = fh.get( 0 );
ch.openChestGui( p, tg, ch, mine, cell, StorageChannel.FLUIDS );
return true;
}
}
p.sendChatToPlayer( PlayerMessages.ChestCannotReadStorageCell.get() );
}
else
p.sendChatToPlayer( PlayerMessages.MachineNotPowered.get() );
return true;
}
return false;
}
}
+44
View File
@@ -0,0 +1,44 @@
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.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 ) );
setTileEntiy( 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)
{
TileDrive tg = getTileEntity( w, x, y, z );
if ( tg != null && !p.isSneaking() )
{
Platform.openGUI( p, tg, ForgeDirection.getOrientation(side),GuiBridge.GUI_DRIVE );
return true;
}
return false;
}
}
+19
View File
@@ -0,0 +1,19 @@
package appeng.block.storage;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import appeng.block.AEBaseBlock;
import appeng.core.features.AEFeature;
import appeng.tile.storage.TileIOPort;
public class BlockIOPort extends AEBaseBlock
{
public BlockIOPort() {
super( BlockIOPort.class, Material.iron );
setfeature( EnumSet.of( AEFeature.StorageCells, AEFeature.IOPort ) );
setTileEntiy( TileIOPort.class );
}
}