Clean up some stuff using ForgeDirection's rotation matrix.
This commit is contained in:
parent
c71c5d9fe7
commit
a8d04828ea
4 changed files with 9 additions and 81 deletions
|
@ -141,7 +141,7 @@ public class BlockEnergyCube extends BlockContainer implements IPeripheralProvid
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int i1, float f1, float f2, float f3)
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int side, float f1, float f2, float f3)
|
||||||
{
|
{
|
||||||
if(ItemAttacher.canAttach(entityplayer.getCurrentEquippedItem()))
|
if(ItemAttacher.canAttach(entityplayer.getCurrentEquippedItem()))
|
||||||
{
|
{
|
||||||
|
@ -170,29 +170,7 @@ public class BlockEnergyCube extends BlockContainer implements IPeripheralProvid
|
||||||
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && tool instanceof IToolWrench)
|
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && tool instanceof IToolWrench)
|
||||||
((IToolWrench)tool).wrenchUsed(entityplayer, x, y, z);
|
((IToolWrench)tool).wrenchUsed(entityplayer, x, y, z);
|
||||||
|
|
||||||
int change = 0;
|
int change = ForgeDirection.ROTATION_MATRIX[side][tileEntity.facing];
|
||||||
|
|
||||||
switch(tileEntity.facing)
|
|
||||||
{
|
|
||||||
case 3:
|
|
||||||
change = 5;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
change = 2;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
change = 4;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
change = 1;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
change = 0;
|
|
||||||
break;
|
|
||||||
case 0:
|
|
||||||
change = 3;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
tileEntity.setFacing((short)change);
|
tileEntity.setFacing((short)change);
|
||||||
world.notifyBlocksOfNeighborChange(x, y, z, this);
|
world.notifyBlocksOfNeighborChange(x, y, z, this);
|
||||||
|
|
|
@ -33,8 +33,6 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
public class BlockGasTank extends BlockContainer
|
public class BlockGasTank extends BlockContainer
|
||||||
{
|
{
|
||||||
public Random machineRand = new Random();
|
|
||||||
|
|
||||||
public BlockGasTank()
|
public BlockGasTank()
|
||||||
{
|
{
|
||||||
super(Material.iron);
|
super(Material.iron);
|
||||||
|
@ -83,7 +81,7 @@ public class BlockGasTank extends BlockContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float playerX, float playerY, float playerZ)
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int side, float playerX, float playerY, float playerZ)
|
||||||
{
|
{
|
||||||
if(ItemAttacher.canAttach(entityplayer.getCurrentEquippedItem()))
|
if(ItemAttacher.canAttach(entityplayer.getCurrentEquippedItem()))
|
||||||
{
|
{
|
||||||
|
@ -112,23 +110,7 @@ public class BlockGasTank extends BlockContainer
|
||||||
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && tool instanceof IToolWrench)
|
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && tool instanceof IToolWrench)
|
||||||
((IToolWrench)tool).wrenchUsed(entityplayer, x, y, z);
|
((IToolWrench)tool).wrenchUsed(entityplayer, x, y, z);
|
||||||
|
|
||||||
int change = 0;
|
int change = ForgeDirection.ROTATION_MATRIX[ForgeDirection.UP.ordinal()][tileEntity.facing];
|
||||||
|
|
||||||
switch(tileEntity.facing)
|
|
||||||
{
|
|
||||||
case 3:
|
|
||||||
change = 5;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
change = 2;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
change = 4;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
change = 3;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
tileEntity.setFacing((short)change);
|
tileEntity.setFacing((short)change);
|
||||||
world.notifyBlocksOfNeighborChange(x, y, z, this);
|
world.notifyBlocksOfNeighborChange(x, y, z, this);
|
||||||
|
|
|
@ -641,7 +641,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float posX, float posY, float posZ)
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int side, float posX, float posY, float posZ)
|
||||||
{
|
{
|
||||||
if(ItemAttacher.canAttach(entityplayer.getCurrentEquippedItem()))
|
if(ItemAttacher.canAttach(entityplayer.getCurrentEquippedItem()))
|
||||||
{
|
{
|
||||||
|
@ -671,23 +671,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
||||||
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && tool instanceof IToolWrench)
|
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && tool instanceof IToolWrench)
|
||||||
((IToolWrench)tool).wrenchUsed(entityplayer, x, y, z);
|
((IToolWrench)tool).wrenchUsed(entityplayer, x, y, z);
|
||||||
|
|
||||||
int change = 0;
|
int change = ForgeDirection.ROTATION_MATRIX[ForgeDirection.UP.ordinal()][tileEntity.facing];
|
||||||
|
|
||||||
switch(tileEntity.facing)
|
|
||||||
{
|
|
||||||
case 3:
|
|
||||||
change = 5;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
change = 2;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
change = 4;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
change = 3;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(tileEntity instanceof TileEntityLogisticalSorter)
|
if(tileEntity instanceof TileEntityLogisticalSorter)
|
||||||
{
|
{
|
||||||
|
|
|
@ -295,7 +295,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IP
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float playerX, float playerY, float playerZ)
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int side, float playerX, float playerY, float playerZ)
|
||||||
{
|
{
|
||||||
if(ItemAttacher.canAttach(entityplayer.getCurrentEquippedItem()))
|
if(ItemAttacher.canAttach(entityplayer.getCurrentEquippedItem()))
|
||||||
{
|
{
|
||||||
|
@ -325,23 +325,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IP
|
||||||
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && tool instanceof IToolWrench)
|
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && tool instanceof IToolWrench)
|
||||||
((IToolWrench)tool).wrenchUsed(entityplayer, x, y, z);
|
((IToolWrench)tool).wrenchUsed(entityplayer, x, y, z);
|
||||||
|
|
||||||
int change = 0;
|
int change = ForgeDirection.ROTATION_MATRIX[ForgeDirection.UP.ordinal()][tileEntity.facing];
|
||||||
|
|
||||||
switch(tileEntity.facing)
|
|
||||||
{
|
|
||||||
case 3:
|
|
||||||
change = 5;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
change = 2;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
change = 4;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
change = 3;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
tileEntity.setFacing((short)change);
|
tileEntity.setFacing((short)change);
|
||||||
world.notifyBlocksOfNeighborChange(x, y, z, this);
|
world.notifyBlocksOfNeighborChange(x, y, z, this);
|
||||||
|
@ -351,7 +335,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IP
|
||||||
|
|
||||||
if(metadata == 3 && entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().isItemEqual(new ItemStack(MekanismGenerators.Generator, 1, 2)))
|
if(metadata == 3 && entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().isItemEqual(new ItemStack(MekanismGenerators.Generator, 1, 2)))
|
||||||
{
|
{
|
||||||
if(((TileEntityBasicBlock)world.getTileEntity(x, y, z)).facing != facing)
|
if(((TileEntityBasicBlock)world.getTileEntity(x, y, z)).facing != side)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue