Relocate Source to proper directory.

This commit is contained in:
AlgorithmX2
2014-09-23 19:26:27 -05:00
parent fe927ce65d
commit 386d18a059
785 changed files with 35585 additions and 35580 deletions
@@ -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 );
}
}
}
}