Skip to content
Permalink
Browse files

Fixed a transformer rotation adjustment bug.

  • Loading branch information...
Ri5ux Ri5ux
Ri5ux authored and Ri5ux committed Jul 15, 2019
1 parent 898cb27 commit 4b053fa69c25e71781028c2ee659d91ea64a92f0
Showing with 28 additions and 25 deletions.
  1. +28 −25 src/main/java/org/avp/block/BlockTransformer.java
@@ -63,43 +63,46 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En
{
TileEntity te = world.getTileEntity(pos);

if (te != null && te instanceof TileEntityTransformer)
if (hand == EnumHand.MAIN_HAND)
{
if (playerIn.getHeldItemMainhand().getItem() == Items.AIR)
if (te != null && te instanceof TileEntityTransformer)
{
TileEntityTransformer transformer = (TileEntityTransformer) te;

ArrayList<EnumFacing> facing = new ArrayList<EnumFacing>();

for (EnumFacing dir : EnumFacing.VALUES)
if (playerIn.getHeldItemMainhand().getItem() == Items.AIR)
{
if (dir != EnumFacing.UP && dir != EnumFacing.DOWN)
{
facing.add(dir);
}
}
TileEntityTransformer transformer = (TileEntityTransformer) te;

if (transformer.getRotationYAxis() != null)
{
int index = facing.indexOf(transformer.getRotationYAxis());
ArrayList<EnumFacing> facing = new ArrayList<EnumFacing>();

if (index + 1 >= facing.size())
for (EnumFacing dir : EnumFacing.VALUES)
{
index = -1;
if (dir != EnumFacing.UP && dir != EnumFacing.DOWN)
{
facing.add(dir);
}
}

if (facing.get(index + 1) != null)
if (transformer.getRotationYAxis() != null)
{
transformer.setRotationYAxis(facing.get(index + 1));
int index = facing.indexOf(transformer.getRotationYAxis());

if (index + 1 >= facing.size())
{
index = -1;
}

if (facing.get(index + 1) != null)
{
transformer.setRotationYAxis(facing.get(index + 1));
}

if (!world.isRemote)
{
AliensVsPredator.network().sendToAll(new PacketRotateRotatable(transformer.getRotationYAxis().ordinal(), transformer.getPos().getX(), transformer.getPos().getY(), transformer.getPos().getZ()));
}
}

if (!world.isRemote)
{
AliensVsPredator.network().sendToAll(new PacketRotateRotatable(transformer.getRotationYAxis().ordinal(), transformer.getPos().getX(), transformer.getPos().getY(), transformer.getPos().getZ()));
}
transformer.getUpdatePacket();
}

transformer.getUpdatePacket();
}
}
return super.onBlockActivated(world, pos, state, playerIn, hand, side, hitX, hitY, hitZ);

0 comments on commit 4b053fa

Please sign in to comment.
You can’t perform that action at this time.