Most of the 1.8 Port.

This commit is contained in:
AlgorithmX2
2015-06-15 19:44:59 -05:00
parent 17465e68e8
commit 38afde724b
824 changed files with 12120 additions and 9158 deletions
@@ -23,9 +23,10 @@ import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
@@ -45,19 +46,26 @@ public class BlockCellWorkbench extends AEBaseTileBlock
}
@Override
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
public boolean onActivated(
World w,
BlockPos pos,
EntityPlayer p,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
if( p.isSneaking() )
{
return false;
}
TileCellWorkbench tg = this.getTileEntity( w, x, y, z );
TileCellWorkbench tg = this.getTileEntity( w, pos );
if( tg != null )
{
if( Platform.isServer() )
{
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_CELL_WORKBENCH );
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_CELL_WORKBENCH );
}
return true;
}
@@ -25,17 +25,18 @@ import java.util.List;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.AEApi;
import appeng.api.util.AEAxisAlignedBB;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockCharger;
@@ -69,7 +70,14 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
}
@Override
public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
public boolean onActivated(
World w,
BlockPos pos,
EntityPlayer player,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
if( player.isSneaking() )
{
@@ -78,7 +86,7 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
if( Platform.isServer() )
{
TileCharger tc = this.getTileEntity( w, x, y, z );
TileCharger tc = this.getTileEntity( w, pos );
if( tc != null )
{
tc.activate( player );
@@ -87,10 +95,14 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
return true;
}
@Override
@Override
@SideOnly( Side.CLIENT )
public void randomDisplayTick( World w, int x, int y, int z, Random r )
public void randomDisplayTick(
World w,
BlockPos pos,
IBlockState state,
Random r )
{
if( !AEConfig.instance.enableEffects )
{
@@ -102,7 +114,7 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
return;
}
AEBaseTile tile = this.getTileEntity( w, x, y, z );
AEBaseTile tile = this.getTileEntity( w, pos );
if( tile instanceof TileCharger )
{
TileCharger tc = (TileCharger) tile;
@@ -117,7 +129,7 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
{
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 );
LightningFX fx = new LightningFX( w, xOff + 0.5 + pos.getX(), yOff + 0.5 + pos.getY(), zOff + 0.5 + pos.getZ(), 0.0D, 0.0D, 0.0D );
Minecraft.getMinecraft().effectRenderer.addEffect( fx );
}
}
@@ -126,27 +138,31 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(
World w,
BlockPos pos,
Entity thePlayer,
boolean b )
{
TileCharger tile = this.getTileEntity( w, x, y, z );
TileCharger tile = this.getTileEntity( w, pos );
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 );
EnumFacing up = tile.getUp();
EnumFacing forward = tile.getForward();
AEAxisAlignedBB bb = AEAxisAlignedBB.fromBounds( twoPixels, twoPixels, twoPixels, 1.0 - twoPixels, 1.0 - twoPixels, 1.0 - twoPixels );
if( up.offsetX != 0 )
if( up.getFrontOffsetX() != 0 )
{
bb.minX = 0;
bb.maxX = 1;
}
if( up.offsetY != 0 )
if( up.getFrontOffsetY() != 0 )
{
bb.minY = 0;
bb.maxY = 1;
}
if( up.offsetZ != 0 )
if( up.getFrontOffsetZ() != 0 )
{
bb.minZ = 0;
bb.maxZ = 1;
@@ -176,14 +192,19 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
break;
}
return Collections.singletonList( bb );
return Collections.singletonList( bb.getBoundingBox() );
}
return Collections.singletonList( AxisAlignedBB.getBoundingBox( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) );
return Collections.singletonList( AxisAlignedBB.fromBounds( 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<AxisAlignedBB> out, Entity e )
public void addCollidingBlockToList(
World w,
BlockPos pos,
AxisAlignedBB bb,
List<AxisAlignedBB> out,
Entity e )
{
out.add( AxisAlignedBB.getBoundingBox( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
out.add( AxisAlignedBB.fromBounds( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) );
}
}
@@ -23,9 +23,10 @@ import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
@@ -45,7 +46,14 @@ public class BlockCondenser extends AEBaseTileBlock
}
@Override
public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
public boolean onActivated(
World w,
BlockPos pos,
EntityPlayer player,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
if( player.isSneaking() )
{
@@ -54,10 +62,10 @@ public class BlockCondenser extends AEBaseTileBlock
if( Platform.isServer() )
{
TileCondenser tc = this.getTileEntity( w, x, y, z );
TileCondenser tc = this.getTileEntity( w, pos );
if( tc != null && !player.isSneaking() )
{
Platform.openGUI( player, tc, ForgeDirection.getOrientation( side ), GuiBridge.GUI_CONDENSER );
Platform.openGUI( player, tc, AEPartLocation.fromFacing( side ), GuiBridge.GUI_CONDENSER );
return true;
}
}
@@ -23,9 +23,10 @@ import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockInscriber;
@@ -53,21 +54,28 @@ public class BlockInscriber extends AEBaseTileBlock
{
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 )
public boolean onActivated(
World w,
BlockPos pos,
EntityPlayer p,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
if( p.isSneaking() )
{
return false;
}
TileInscriber tg = this.getTileEntity( w, x, y, z );
TileInscriber tg = this.getTileEntity( w, pos );
if( tg != null )
{
if( Platform.isServer() )
{
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_INSCRIBER );
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_INSCRIBER );
}
return true;
}
@@ -23,9 +23,10 @@ import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.util.AEPartLocation;
import appeng.api.util.IOrientable;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.BaseBlockRender;
@@ -54,19 +55,26 @@ public class BlockInterface extends AEBaseTileBlock
}
@Override
public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ )
public boolean onActivated(
World w,
BlockPos pos,
EntityPlayer p,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
if( p.isSneaking() )
{
return false;
}
TileInterface tg = this.getTileEntity( w, x, y, z );
TileInterface tg = this.getTileEntity( w, pos );
if( tg != null )
{
if( Platform.isServer() )
{
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_INTERFACE );
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_INTERFACE );
}
return true;
}
@@ -80,11 +88,11 @@ public class BlockInterface extends AEBaseTileBlock
}
@Override
protected void customRotateBlock( IOrientable rotatable, ForgeDirection axis )
protected void customRotateBlock( IOrientable rotatable, EnumFacing axis )
{
if( rotatable instanceof TileInterface )
{
( (TileInterface) rotatable ).setSide( axis );
( (TileInterface) rotatable ).setSide( AEPartLocation.fromFacing( axis ) );
}
}
}
@@ -25,20 +25,19 @@ import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockTorch;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderQuartzTorch;
import appeng.core.features.AEFeature;
import appeng.helpers.ICustomCollision;
@@ -46,14 +45,13 @@ import appeng.helpers.MetaRotation;
import appeng.tile.misc.TileLightDetector;
public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBlock, ICustomCollision
public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBlock,ICustomCollision
{
public BlockLightDetector()
{
super( Material.circuits );
this.setLightLevel( 0.9375F );
this.setLightOpacity( 0 );
this.isFullSize = false;
this.isOpaque = false;
@@ -63,22 +61,49 @@ public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBl
}
@Override
public int isProvidingWeakPower( IBlockAccess w, int x, int y, int z, int side )
public int getMetaFromState(
IBlockState state )
{
if( w instanceof World && ( (TileLightDetector) this.getTileEntity( w, x, y, z ) ).isReady() )
return 0;
}
@Override
public IBlockState getStateFromMeta(
int meta )
{
return getDefaultState();
}
@Override
protected IProperty[] getAEStates()
{
return new IProperty[]{ BlockTorch.FACING };
}
@Override
public int isProvidingWeakPower(
IBlockAccess w,
BlockPos pos,
IBlockState state,
EnumFacing side )
{
if( w instanceof World && ( (TileLightDetector) this.getTileEntity( w, pos ) ).isReady() )
{
return ( (World) w ).getBlockLightValue( x, y, z ) - 6;
return ( (World) w ).getLightFromNeighbors( pos ) - 6;
}
return 0;
}
@Override
public void onNeighborChange( IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ )
public void onNeighborChange(
IBlockAccess world,
BlockPos pos,
BlockPos neighbor )
{
super.onNeighborChange( world, x, y, z, tileX, tileY, tileZ );
super.onNeighborChange( world, pos, neighbor );
TileLightDetector tld = this.getTileEntity( world, x, y, z );
TileLightDetector tld = this.getTileEntity( world, pos );
if( tld != null )
{
tld.updateLight();
@@ -86,8 +111,11 @@ public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBl
}
@Override
@SideOnly( Side.CLIENT )
public void randomDisplayTick( World w, int x, int y, int z, Random r )
public void randomDisplayTick(
World worldIn,
BlockPos pos,
IBlockState state,
Random rand )
{
// cancel out lightning
}
@@ -99,58 +127,76 @@ public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBl
}
@Override
public boolean isValidOrientation( World w, int x, int y, int z, ForgeDirection forward, ForgeDirection up )
public boolean isValidOrientation(
World w,
BlockPos pos,
EnumFacing forward,
EnumFacing up )
{
return this.canPlaceAt( w, x, y, z, up.getOpposite() );
return this.canPlaceAt( w, pos, up.getOpposite() );
}
private boolean canPlaceAt( World w, int x, int y, int z, ForgeDirection dir )
private boolean canPlaceAt( World w, BlockPos pos, EnumFacing dir )
{
return w.isSideSolid( x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir.getOpposite(), false );
return w.isSideSolid( pos.offset( dir ), dir.getOpposite(), false );
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(
World w,
BlockPos pos,
Entity thePlayer,
boolean b )
{
EnumFacing up = this.getOrientable( w, pos ).getUp();
double xOff = -0.3 * up.getFrontOffsetX();
double yOff = -0.3 * up.getFrontOffsetY();
double zOff = -0.3 * up.getFrontOffsetZ();
return Collections.singletonList( AxisAlignedBB.fromBounds( xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7 ) );
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
{
ForgeDirection up = this.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 Collections.singletonList( 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 )
public void addCollidingBlockToList(
World w,
BlockPos pos,
AxisAlignedBB bb,
List<AxisAlignedBB> 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
public void onNeighborBlockChange( World w, int x, int y, int z, Block id )
public void onNeighborBlockChange(
World w,
BlockPos pos,
IBlockState state,
Block neighborBlock )
{
ForgeDirection up = this.getOrientable( w, x, y, z ).getUp();
if( !this.canPlaceAt( w, x, y, z, up.getOpposite() ) )
EnumFacing up = this.getOrientable( w, pos ).getUp();
if( !this.canPlaceAt( w, pos, up.getOpposite() ) )
{
this.dropTorch( w, x, y, z );
this.dropTorch( w, pos );
}
}
private void dropTorch( World w, int x, int y, int z )
private void dropTorch( World w, BlockPos pos )
{
w.func_147480_a( x, y, z, true );
// w.destroyBlock( x, y, z, true );
w.markBlockForUpdate( x, y, z );
w.destroyBlock( pos, true );
w.markBlockForUpdate( pos );
}
@Override
public boolean canPlaceBlockAt( World w, int x, int y, int z )
public boolean canPlaceBlockAt(
World w,
BlockPos pos )
{
for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
for( EnumFacing dir : EnumFacing.VALUES )
{
if( this.canPlaceAt( w, x, y, z, dir ) )
if( this.canPlaceAt( w, pos, dir ) )
{
return true;
}
@@ -165,8 +211,8 @@ public class BlockLightDetector extends AEBaseTileBlock implements IOrientableBl
}
@Override
public IOrientable getOrientable( final IBlockAccess w, final int x, final int y, final int z )
public IOrientable getOrientable( final IBlockAccess w, BlockPos pos )
{
return new MetaRotation( w, x, y, z );
return new MetaRotation( w, pos,true );
}
}
+54 -21
View File
@@ -26,16 +26,17 @@ import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.MaterialLiquid;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockPaint;
@@ -58,6 +59,12 @@ public class BlockPaint extends AEBaseTileBlock
this.setFeature( EnumSet.of( AEFeature.PaintBalls ) );
}
@Override
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.CUTOUT;
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
@@ -70,23 +77,32 @@ public class BlockPaint extends AEBaseTileBlock
{
// do nothing
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool( World world, int x, int y, int z )
public AxisAlignedBB getCollisionBoundingBox(
World worldIn,
BlockPos pos,
IBlockState state )
{
return null;
}
@Override
public boolean canCollideCheck( int metadata, boolean isHoldingRightClick )
public boolean canCollideCheck(
IBlockState state,
boolean hitIfLiquid )
{
return false;
}
@Override
public void onNeighborBlockChange( World w, int x, int y, int z, Block junk )
public void onNeighborBlockChange(
World w,
BlockPos pos,
IBlockState state,
Block neighborBlock )
{
TilePaint tp = this.getTileEntity( w, x, y, z );
TilePaint tp = this.getTileEntity( w, pos );
if( tp != null )
{
@@ -95,30 +111,42 @@ public class BlockPaint extends AEBaseTileBlock
}
@Override
public Item getItemDropped( int meta, Random random, int fortune )
public Item getItemDropped(
IBlockState state,
Random rand,
int fortune )
{
return null;
}
@Override
public void dropBlockAsItemWithChance( World world, int x, int y, int z, int meta, float chance, int fortune )
public void dropBlockAsItemWithChance(
World worldIn,
BlockPos pos,
IBlockState state,
float chance,
int fortune )
{
}
@Override
public void fillWithRain( World w, int x, int y, int z )
public void fillWithRain(
World w,
BlockPos pos )
{
if( Platform.isServer() )
{
w.setBlock( x, y, z, Platform.AIR_BLOCK, 0, 3 );
w.setBlockToAir( pos );
}
}
@Override
public int getLightValue( IBlockAccess w, int x, int y, int z )
public int getLightValue(
IBlockAccess w,
BlockPos pos )
{
TilePaint tp = this.getTileEntity( w, x, y, z );
TilePaint tp = this.getTileEntity( w, pos );
if( tp != null )
{
@@ -129,14 +157,19 @@ public class BlockPaint extends AEBaseTileBlock
}
@Override
public boolean isReplaceable( IBlockAccess world, int x, int y, int z )
public boolean isAir(
IBlockAccess world,
BlockPos pos )
{
return true;
}
@Override
public boolean isAir( IBlockAccess world, int x, int y, int z )
public boolean isReplaceable(
World worldIn,
BlockPos pos )
{
return true;
}
}
@@ -24,16 +24,11 @@ import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.world.IBlockAccess;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockQuartzAccelerator;
@@ -41,12 +36,11 @@ 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;
public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock implements IOrientableBlock
public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock
{
public BlockQuartzGrowthAccelerator()
@@ -64,42 +58,50 @@ public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock implements IOr
}
@Override
@SideOnly( Side.CLIENT )
public void randomDisplayTick( World w, int x, int y, int z, Random r )
public void randomDisplayTick(
World w,
BlockPos pos,
IBlockState state,
Random r )
{
if( !AEConfig.instance.enableEffects )
{
return;
}
TileQuartzGrowthAccelerator cga = this.getTileEntity( w, x, y, z );
TileQuartzGrowthAccelerator cga = this.getTileEntity( w, pos );
if( cga != null && cga.hasPower && CommonHelper.proxy.shouldAddParticles( r ) )
{
double d0 = r.nextFloat() - 0.5F;
double d1 = r.nextFloat() - 0.5F;
ForgeDirection up = cga.getUp();
ForgeDirection forward = cga.getForward();
ForgeDirection west = Platform.crossProduct( forward, up );
EnumFacing up = cga.getUp();
EnumFacing forward = cga.getForward();
EnumFacing west = Platform.crossProduct( forward, up );
double rx = 0.5 + x;
double ry = 0.5 + y;
double rz = 0.5 + z;
double rx = 0.5 + pos.getX();
double ry = 0.5 + pos.getY();
double rz = 0.5 + pos.getZ();
double dx = 0;
double dz = 0;
rx += up.offsetX * d0;
ry += up.offsetY * d0;
rz += up.offsetZ * d0;
rx += up.getFrontOffsetX() * d0;
ry += up.getFrontOffsetY() * d0;
rz += up.getFrontOffsetZ() * d0;
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
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 ) )
BlockPos pt = new BlockPos( x + west.getFrontOffsetX(), y + west.getFrontOffsetY(), z + west.getFrontOffsetZ() );
if( !w.getBlockState(pt).getBlock().isAir( w, pt) )
{
return;
}
@@ -107,7 +109,8 @@ public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock implements IOr
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 ) )
pt = new BlockPos( x + forward.getFrontOffsetX(), y + forward.getFrontOffsetY(), z + forward.getFrontOffsetZ() );
if( !w.getBlockState(pt).getBlock().isAir( w, pt) )
{
return;
}
@@ -115,7 +118,8 @@ public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock implements IOr
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 ) )
pt = new BlockPos( x - forward.getFrontOffsetX(), y - forward.getFrontOffsetY(), z - forward.getFrontOffsetZ() );
if( !w.getBlockState(pt).getBlock().isAir( w, pt) )
{
return;
}
@@ -123,35 +127,25 @@ public class BlockQuartzGrowthAccelerator extends AEBaseTileBlock implements IOr
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 ) )
pt = new BlockPos( x - west.getFrontOffsetX(), y - west.getFrontOffsetY(), z - west.getFrontOffsetZ() );
if( !w.getBlockState(pt).getBlock().isAir( w, pt) )
{
return;
}
break;
}
rx += dx * west.offsetX;
ry += dx * west.offsetY;
rz += dx * west.offsetZ;
rx += dx * west.getFrontOffsetX();
ry += dx * west.getFrontOffsetY();
rz += dx * west.getFrontOffsetZ();
rx += dz * forward.offsetX;
ry += dz * forward.offsetY;
rz += dz * forward.offsetZ;
rx += dz * forward.getFrontOffsetX();
ry += dz * forward.getFrontOffsetY();
rz += dz * forward.getFrontOffsetZ();
LightningFX fx = new LightningFX( w, rx, ry, rz, 0.0D, 0.0D, 0.0D );
Minecraft.getMinecraft().effectRenderer.addEffect( fx );
}
}
@Override
public boolean usesMetadata()
{
return true;
}
@Override
public IOrientable getOrientable( final IBlockAccess w, final int x, final int y, final int z )
{
return new MetaRotation( w, x, y, z );
}
}
@@ -25,17 +25,19 @@ import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockTorch;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.util.IOrientable;
import appeng.api.util.IOrientableBlock;
import appeng.block.AEBaseBlock;
@@ -61,6 +63,26 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I
this.isFullSize = false;
this.isOpaque = false;
}
@Override
public int getMetaFromState(
IBlockState state )
{
return 0;
}
@Override
public IBlockState getStateFromMeta(
int meta )
{
return getDefaultState();
}
@Override
protected IProperty[] getAEStates()
{
return new IProperty[]{ BlockTorch.FACING };
}
@Override
protected Class<? extends BaseBlockRender> getRenderer()
@@ -69,38 +91,43 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I
}
@Override
public boolean isValidOrientation( World w, int x, int y, int z, ForgeDirection forward, ForgeDirection up )
public boolean isValidOrientation( World w, BlockPos pos, EnumFacing forward, EnumFacing up )
{
return this.canPlaceAt( w, x, y, z, up.getOpposite() );
return this.canPlaceAt( w, pos, up.getOpposite() );
}
private boolean canPlaceAt( World w, int x, int y, int z, ForgeDirection dir )
private boolean canPlaceAt( World w, BlockPos pos, EnumFacing dir )
{
return w.isSideSolid( x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir.getOpposite(), false );
BlockPos test = pos.offset( dir );
return w.isSideSolid( test, dir.getOpposite(), false );
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, BlockPos pos, Entity e, boolean isVisual )
{
ForgeDirection up = this.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 Collections.singletonList( AxisAlignedBB.getBoundingBox( xOff + 0.3, yOff + 0.3, zOff + 0.3, xOff + 0.7, yOff + 0.7, zOff + 0.7 ) );
EnumFacing up = this.getOrientable( w, pos ).getUp();
double xOff = -0.3 * up.getFrontOffsetX();
double yOff = -0.3 * up.getFrontOffsetY();
double zOff = -0.3 * up.getFrontOffsetZ();
return Collections.singletonList( AxisAlignedBB.fromBounds( 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 )
public void addCollidingBlockToList( World w, BlockPos pos, 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 )
public void randomDisplayTick(
World w,
BlockPos pos,
IBlockState state,
Random r )
{
if( !AEConfig.instance.enableEffects )
{
@@ -112,15 +139,15 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I
return;
}
ForgeDirection up = this.getOrientable( w, x, y, z ).getUp();
double xOff = -0.3 * up.offsetX;
double yOff = -0.3 * up.offsetY;
double zOff = -0.3 * up.offsetZ;
EnumFacing up = this.getOrientable( w, pos ).getUp();
double xOff = -0.3 * up.getFrontOffsetX();
double yOff = -0.3 * up.getFrontOffsetY();
double zOff = -0.3 * up.getFrontOffsetZ();
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 );
LightningFX fx = new LightningFX( w, xOff + 0.5 + pos.getX(), yOff + 0.5 + pos.getY(), zOff + 0.5 + pos.getZ(), 0.0D, 0.0D, 0.0D );
Minecraft.getMinecraft().effectRenderer.addEffect( fx );
}
@@ -128,28 +155,31 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I
}
@Override
public void onNeighborBlockChange( World w, int x, int y, int z, Block id )
public void onNeighborBlockChange(
World w,
BlockPos pos,
IBlockState state,
Block neighborBlock )
{
ForgeDirection up = this.getOrientable( w, x, y, z ).getUp();
if( !this.canPlaceAt( w, x, y, z, up.getOpposite() ) )
EnumFacing up = this.getOrientable( w, pos ).getUp();
if( !this.canPlaceAt( w, pos, up.getOpposite() ) )
{
this.dropTorch( w, x, y, z );
this.dropTorch( w, pos );
}
}
private void dropTorch( World w, int x, int y, int z )
private void dropTorch( World w, BlockPos pos )
{
w.func_147480_a( x, y, z, true );
// w.destroyBlock( x, y, z, true );
w.markBlockForUpdate( x, y, z );
w.destroyBlock( pos, true );
w.markBlockForUpdate( pos );
}
@Override
public boolean canPlaceBlockAt( World w, int x, int y, int z )
public boolean canPlaceBlockAt( World w, BlockPos pos )
{
for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
for( EnumFacing dir : EnumFacing.VALUES )
{
if( this.canPlaceAt( w, x, y, z, dir ) )
if( this.canPlaceAt( w, pos, dir ) )
{
return true;
}
@@ -164,8 +194,8 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I
}
@Override
public IOrientable getOrientable( final IBlockAccess w, final int x, final int y, final int z )
public IOrientable getOrientable( final IBlockAccess w, BlockPos pos )
{
return new MetaRotation( w, x, y, z );
return new MetaRotation( w, pos,true );
}
}
@@ -23,9 +23,11 @@ import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RendererSecurity;
@@ -46,21 +48,34 @@ public class BlockSecurity extends AEBaseTileBlock
this.setFeature( EnumSet.of( AEFeature.Security ) );
}
@Override
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.CUTOUT;
}
@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 )
public boolean onActivated(
World w,
BlockPos pos,
EntityPlayer p,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
if( p.isSneaking() )
{
return false;
}
TileSecurity tg = this.getTileEntity( w, x, y, z );
TileSecurity tg = this.getTileEntity( w, pos );
if( tg != null )
{
if( Platform.isClient() )
@@ -68,7 +83,7 @@ public class BlockSecurity extends AEBaseTileBlock
return true;
}
Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_SECURITY );
Platform.openGUI( p, tg, AEPartLocation.fromFacing( side ), GuiBridge.GUI_SECURITY );
return true;
}
return false;
@@ -25,17 +25,12 @@ 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.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.render.blocks.RenderBlockSkyCompass;
@@ -63,58 +58,50 @@ public class BlockSkyCompass extends AEBaseTileBlock implements ICustomCollision
}
@Override
@SideOnly( Side.CLIENT )
public IIcon getIcon( int direction, int metadata )
public boolean isValidOrientation( World w, BlockPos pos, EnumFacing forward, EnumFacing up )
{
return Blocks.iron_block.getIcon( direction, metadata );
}
@Override
public void registerBlockIcons( IIconRegister iconRegistry )
{
// :P
}
@Override
public boolean isValidOrientation( World w, int x, int y, int z, ForgeDirection forward, ForgeDirection up )
{
TileSkyCompass sc = this.getTileEntity( w, x, y, z );
TileSkyCompass sc = this.getTileEntity( w, pos );
if( sc != null )
{
return false;
}
return this.canPlaceAt( w, x, y, z, forward.getOpposite() );
return this.canPlaceAt( w, pos, forward.getOpposite() );
}
private boolean canPlaceAt( World w, int x, int y, int z, ForgeDirection dir )
private boolean canPlaceAt( World w, BlockPos pos, EnumFacing dir )
{
return w.isSideSolid( x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir.getOpposite(), false );
return w.isSideSolid( pos.offset( dir ), dir.getOpposite(), false );
}
@Override
public void onNeighborBlockChange( World w, int x, int y, int z, Block id )
public void onNeighborBlockChange(
World w,
BlockPos pos,
IBlockState state,
Block neighborBlock )
{
TileSkyCompass sc = this.getTileEntity( w, x, y, z );
ForgeDirection up = sc.getForward();
if( !this.canPlaceAt( w, x, y, z, up.getOpposite() ) )
TileSkyCompass sc = this.getTileEntity( w, pos );
EnumFacing up = sc.getForward();
if( !this.canPlaceAt( w, pos, up.getOpposite() ) )
{
this.dropTorch( w, x, y, z );
this.dropTorch( w, pos );
}
}
private void dropTorch( World w, int x, int y, int z )
private void dropTorch( World w, BlockPos pos )
{
w.func_147480_a( x, y, z, true );
// w.destroyBlock( x, y, z, true );
w.markBlockForUpdate( x, y, z );
w.destroyBlock( pos, true );
w.markBlockForUpdate( pos );
}
@Override
public boolean canPlaceBlockAt( World w, int x, int y, int z )
public boolean canPlaceBlockAt(
World w,
BlockPos pos )
{
for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS )
for( EnumFacing dir : EnumFacing.VALUES )
{
if( this.canPlaceAt( w, x, y, z, dir ) )
if( this.canPlaceAt( w, pos, dir ) )
{
return true;
}
@@ -123,12 +110,16 @@ public class BlockSkyCompass extends AEBaseTileBlock implements ICustomCollision
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(
World w,
BlockPos pos,
Entity thePlayer,
boolean b )
{
TileSkyCompass tile = this.getTileEntity( w, x, y, z );
TileSkyCompass tile = this.getTileEntity( w, pos );
if( tile != null )
{
ForgeDirection forward = tile.getForward();
EnumFacing forward = tile.getForward();
double minX = 0;
double minY = 0;
@@ -179,14 +170,19 @@ public class BlockSkyCompass extends AEBaseTileBlock implements ICustomCollision
break;
}
return Collections.singletonList( AxisAlignedBB.getBoundingBox( minX, minY, minZ, maxX, maxY, maxZ ) );
return Collections.singletonList( AxisAlignedBB.fromBounds( minX, minY, minZ, maxX, maxY, maxZ ) );
}
return Collections.singletonList( AxisAlignedBB.getBoundingBox( 0.0, 0, 0.0, 1.0, 1.0, 1.0 ) );
return Collections.singletonList( AxisAlignedBB.fromBounds( 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 )
public void addCollidingBlockToList(
World w,
BlockPos pos,
AxisAlignedBB bb,
List<AxisAlignedBB> out,
Entity e )
{
}
}
@@ -26,25 +26,22 @@ 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.block.state.IBlockState;
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.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import cpw.mods.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.registry.EntityRegistry;
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;
@@ -72,7 +69,7 @@ public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
@Override
protected Class<? extends BaseBlockRender> getRenderer()
{
return RenderTinyTNT.class;
return null;
}
@Override
@@ -83,78 +80,86 @@ public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
}
@Override
public IIcon getIcon( int direction, int metadata )
{
return new FullIcon( Blocks.tnt.getIcon( direction, metadata ) );
}
@Override
public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
public boolean onActivated(
World w,
BlockPos pos,
EntityPlayer player,
EnumFacing 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 );
this.startFuse( w, pos, player );
w.setBlockToAir( pos );
player.getCurrentEquippedItem().damageItem( 1, player );
return true;
}
else
{
return super.onActivated( w, x, y, z, player, side, hitX, hitY, hitZ );
return super.onActivated( w, pos, player, side, hitX, hitY, hitZ );
}
}
@Override
public void registerBlockIcons( IIconRegister iconRegistry )
{
// no images required.
}
public void startFuse( World w, int x, int y, int z, EntityLivingBase igniter )
public void startFuse( World w, BlockPos pos, EntityLivingBase igniter )
{
if( !w.isRemote )
{
EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed( w, x + 0.5F, y + 0.5F, z + 0.5F, igniter );
EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed( w, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, igniter );
w.spawnEntityInWorld( primedTinyTNTEntity );
w.playSoundAtEntity( primedTinyTNTEntity, "game.tnt.primed", 1.0F, 1.0F );
}
}
@Override
public void onBlockAdded( World w, int x, int y, int z )
public void onBlockAdded(
World w,
BlockPos pos,
IBlockState state )
{
super.onBlockAdded( w, x, y, z );
super.onBlockAdded( w, pos, state );
if( w.isBlockIndirectlyGettingPowered( x, y, z ) )
if( w.isBlockIndirectlyGettingPowered( pos ) > 0 )
{
this.startFuse( w, x, y, z, null );
w.setBlockToAir( x, y, z );
this.startFuse( w, pos, null );
w.setBlockToAir( pos );
}
}
@Override
public void onNeighborBlockChange( World w, int x, int y, int z, Block id )
public void onNeighborBlockChange(
World w,
BlockPos pos,
IBlockState state,
Block neighborBlock )
{
if( w.isBlockIndirectlyGettingPowered( x, y, z ) )
if( w.isBlockIndirectlyGettingPowered( pos ) > 0 )
{
this.startFuse( w, x, y, z, null );
w.setBlockToAir( x, y, z );
this.startFuse( w, pos, null );
w.setBlockToAir( pos );
}
}
@Override
public void onBlockDestroyedByExplosion( World w, int x, int y, int z, Explosion exp )
public void onBlockExploded(
World w,
BlockPos pos,
Explosion exp )
{
if( !w.isRemote )
{
EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed( w, x + 0.5F, y + 0.5F, z + 0.5F, exp.getExplosivePlacedBy() );
EntityTinyTNTPrimed primedTinyTNTEntity = new EntityTinyTNTPrimed( w, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, exp.getExplosivePlacedBy() );
primedTinyTNTEntity.fuse = w.rand.nextInt( primedTinyTNTEntity.fuse / 4 ) + primedTinyTNTEntity.fuse / 8;
w.spawnEntityInWorld( primedTinyTNTEntity );
}
}
@Override
public void onEntityCollidedWithBlock( World w, int x, int y, int z, Entity entity )
public void onEntityCollidedWithBlock(
World w,
BlockPos pos,
Entity entity )
{
if( entity instanceof EntityArrow && !w.isRemote )
{
@@ -162,8 +167,8 @@ public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
if( entityarrow.isBurning() )
{
this.startFuse( w, x, y, z, entityarrow.shootingEntity instanceof EntityLivingBase ? (EntityLivingBase) entityarrow.shootingEntity : null );
w.setBlockToAir( x, y, z );
this.startFuse( w, pos, entityarrow.shootingEntity instanceof EntityLivingBase ? (EntityLivingBase) entityarrow.shootingEntity : null );
w.setBlockToAir( pos );
}
}
}
@@ -175,14 +180,23 @@ public class BlockTinyTNT extends AEBaseBlock implements ICustomCollision
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( World w, int x, int y, int z, Entity e, boolean isVisual )
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(
World w,
BlockPos pos,
Entity thePlayer,
boolean b )
{
return Collections.singletonList( AxisAlignedBB.getBoundingBox( 0.25, 0, 0.25, 0.75, 0.5, 0.75 ) );
return Collections.singletonList( AxisAlignedBB.fromBounds( 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<AxisAlignedBB> out, Entity e )
public void addCollidingBlockToList(
World w,
BlockPos pos,
AxisAlignedBB bb,
List<AxisAlignedBB> out,
Entity e )
{
out.add( AxisAlignedBB.getBoundingBox( 0.25, 0, 0.25, 0.75, 0.5, 0.75 ) );
out.add( AxisAlignedBB.fromBounds( 0.25, 0, 0.25, 0.75, 0.5, 0.75 ) );
}
}
@@ -23,14 +23,17 @@ import java.util.EnumSet;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.IIcon;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.util.AEPartLocation;
import appeng.block.AEBaseTileBlock;
import appeng.client.texture.ExtraBlockTextures;
import appeng.client.texture.IAESprite;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
@@ -49,14 +52,14 @@ public final class BlockVibrationChamber extends AEBaseTileBlock
this.setHardness( 4.2F );
this.setFeature( EnumSet.of( AEFeature.PowerGen ) );
}
@Override
public IIcon getIcon( IBlockAccess w, int x, int y, int z, int s )
public appeng.client.texture.IAESprite getIcon(IBlockAccess w, BlockPos pos, EnumFacing side)
{
IIcon ico = super.getIcon( w, x, y, z, s );
TileVibrationChamber tvc = this.getTileEntity( w, x, y, z );
IAESprite ico = super.getIcon( w, pos, side );
TileVibrationChamber tvc = this.getTileEntity( w, pos );
if( tvc != null && tvc.isOn && ico == this.getRendererInstance().getTexture( ForgeDirection.SOUTH ) )
if( tvc != null && tvc.isOn && ico == this.getRendererInstance().getTexture( AEPartLocation.SOUTH ) )
{
return ExtraBlockTextures.BlockVibrationChamberFrontOn.getIcon();
}
@@ -65,7 +68,14 @@ public final class BlockVibrationChamber extends AEBaseTileBlock
}
@Override
public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ )
public boolean onActivated(
World w,
BlockPos pos,
EntityPlayer player,
EnumFacing side,
float hitX,
float hitY,
float hitZ )
{
if( player.isSneaking() )
{
@@ -74,10 +84,10 @@ public final class BlockVibrationChamber extends AEBaseTileBlock
if( Platform.isServer() )
{
TileVibrationChamber tc = this.getTileEntity( w, x, y, z );
TileVibrationChamber tc = this.getTileEntity( w, pos );
if( tc != null && !player.isSneaking() )
{
Platform.openGUI( player, tc, ForgeDirection.getOrientation( side ), GuiBridge.GUI_VIBRATION_CHAMBER );
Platform.openGUI( player, tc, AEPartLocation.fromFacing( side ), GuiBridge.GUI_VIBRATION_CHAMBER );
return true;
}
}
@@ -86,47 +96,51 @@ public final class BlockVibrationChamber extends AEBaseTileBlock
}
@Override
public void randomDisplayTick( World w, int x, int y, int z, Random r )
public void randomDisplayTick(
World w,
BlockPos pos,
IBlockState state,
Random r )
{
if( !AEConfig.instance.enableEffects )
{
return;
}
AEBaseTile tile = this.getTileEntity( w, x, y, z );
AEBaseTile tile = this.getTileEntity( w, pos );
if( tile instanceof TileVibrationChamber )
{
TileVibrationChamber tc = (TileVibrationChamber) tile;
if( tc.isOn )
{
float f1 = x + 0.5F;
float f2 = y + 0.5F;
float f3 = z + 0.5F;
float f1 = pos.getX() + 0.5F;
float f2 = pos.getY() + 0.5F;
float f3 = pos.getZ() + 0.5F;
ForgeDirection forward = tc.getForward();
ForgeDirection up = tc.getUp();
EnumFacing forward = tc.getForward();
EnumFacing 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;
int west_x = forward.getFrontOffsetY() * up.getFrontOffsetZ() - forward.getFrontOffsetZ() * up.getFrontOffsetY();
int west_y = forward.getFrontOffsetZ() * up.getFrontOffsetX() - forward.getFrontOffsetX() * up.getFrontOffsetZ();
int west_z = forward.getFrontOffsetX() * up.getFrontOffsetY() - forward.getFrontOffsetY() * up.getFrontOffsetX();
f1 += forward.offsetX * 0.6;
f2 += forward.offsetY * 0.6;
f3 += forward.offsetZ * 0.6;
f1 += forward.getFrontOffsetX() * 0.6;
f2 += forward.getFrontOffsetY() * 0.6;
f3 += forward.getFrontOffsetZ() * 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 += up.getFrontOffsetX() * ( -0.3 + oy );
f2 += up.getFrontOffsetY() * ( -0.3 + oy );
f3 += up.getFrontOffsetZ() * ( -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", f1, f2, f3, 0.0D, 0.0D, 0.0D );
w.spawnParticle( "flame", f1, f2, f3, 0.0D, 0.0D, 0.0D );
w.spawnParticle( EnumParticleTypes.SMOKE_NORMAL, f1, f2, f3, 0.0D, 0.0D, 0.0D, new int[0] );
w.spawnParticle( EnumParticleTypes.FLAME, f1, f2, f3, 0.0D, 0.0D, 0.0D, new int[0] );
}
}
}