Fixed some transformer rotations, incomplete

This commit is contained in:
Calclavia 2014-01-21 16:19:32 +08:00
parent 958cca3180
commit 19ee8e95d0
4 changed files with 20 additions and 60 deletions

View file

@ -31,8 +31,7 @@ public class ItemTransformer extends ItemMultipartBase
{ {
int l = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; int l = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int facing = l == 0 ? 2 : (l == 1 ? 5 : (l == 2 ? 3 : (l == 3 ? 4 : 0))); int facing = l == 0 ? 2 : (l == 1 ? 5 : (l == 2 ? 3 : (l == 3 ? 4 : 0)));
part.preparePlacement(side, facing);
part.preparePlacement(facing, itemStack.getItemDamage());
} }
return part; return part;

View file

@ -49,33 +49,33 @@ public class PartTransformer extends JCuboidPart implements JNormalOcclusion, TF
} }
} }
/** Side of the block this is placed on */ /** Side of the block this is placed on. */
public ForgeDirection placementSide; public ForgeDirection placementSide;
/** Direction this block faces */ /** The relative direction this block faces. */
public byte face = 0; public byte facing = 0;
/** Step the voltage up */ /** Step the voltage up */
private boolean stepUp; private boolean stepUp;
/** Amount to mulitply the step by (up x2. down /2) */ /** Amount to mulitply the step by (up x2. down /2) */
public int multiplier = 2; public int multiplier = 2;
public void preparePlacement(int side, int itemDamage) public void preparePlacement(int side, int facing)
{ {
placementSide = ForgeDirection.getOrientation((byte) (side ^ 1)); this.placementSide = ForgeDirection.getOrientation((byte) (side ^ 1));
face = (byte) side; this.facing = (byte) (facing - 2);
} }
@Override @Override
public void readDesc(MCDataInput packet) public void readDesc(MCDataInput packet)
{ {
this.placementSide = ForgeDirection.getOrientation(packet.readByte()); this.placementSide = ForgeDirection.getOrientation(packet.readByte());
this.face = packet.readByte(); this.facing = packet.readByte();
} }
@Override @Override
public void writeDesc(MCDataOutput packet) public void writeDesc(MCDataOutput packet)
{ {
packet.writeByte(this.placementSide.ordinal()); packet.writeByte(this.placementSide.ordinal());
packet.writeByte(this.face); packet.writeByte(this.facing);
} }
public boolean stepUp() public boolean stepUp()
@ -172,52 +172,13 @@ public class PartTransformer extends JCuboidPart implements JNormalOcclusion, TF
protected ForgeDirection getFacing() protected ForgeDirection getFacing()
{ {
if (this.placementSide != ForgeDirection.UP && this.placementSide != ForgeDirection.DOWN) return ForgeDirection.getOrientation(this.facing + 2);
{
switch (this.face)
{
case 0:
return ForgeDirection.UP;
case 1:
switch (this.placementSide)
{
case NORTH:
return ForgeDirection.EAST;
case SOUTH:
return ForgeDirection.WEST;
case EAST:
return ForgeDirection.SOUTH;
case WEST:
return ForgeDirection.NORTH;
}
case 2:
return ForgeDirection.DOWN;
case 3:
switch (this.placementSide)
{
case NORTH:
return ForgeDirection.WEST;
case SOUTH:
return ForgeDirection.EAST;
case EAST:
return ForgeDirection.NORTH;
case WEST:
return ForgeDirection.SOUTH;
}
}
}
else
{
return ForgeDirection.getOrientation(this.face - 2);
}
return ForgeDirection.NORTH;
} }
@Override @Override
public boolean canConnect(ForgeDirection direction) public boolean canConnect(ForgeDirection direction)
{ {
return direction == getFacing() || direction == getFacing().getOpposite(); return direction.ordinal() == Rotation.rotateSide(placementSide.ordinal(), facing) || direction.ordinal() == Rotation.rotateSide(placementSide.ordinal(), Rotation.rotateSide(facing, 2));
} }
@Override @Override
@ -286,10 +247,10 @@ public class PartTransformer extends JCuboidPart implements JNormalOcclusion, TF
return true; return true;
} }
this.damageWrench(player, player.inventory.getCurrentItem(), x(), y(), z()); this.damageWrench(player, player.inventory.getCurrentItem(), x(), y(), z());
if (this.face < 3) if (this.facing < 3)
this.face++; this.facing++;
else else
this.face = 0; this.facing = 0;
this.sendDescUpdate(); this.sendDescUpdate();
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)

View file

@ -51,6 +51,7 @@ public class RenderTransformer
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F); GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F);
RenderUtility.rotateFaceBlockToSide(part.placementSide); RenderUtility.rotateFaceBlockToSide(part.placementSide);
GL11.glRotatef(90, 0, 1, 0);
RenderUtility.rotateBlockBasedOnDirection(part.getFacing()); RenderUtility.rotateBlockBasedOnDirection(part.getFacing());
doRender(); doRender();
GL11.glPopMatrix(); GL11.glPopMatrix();

View file

@ -282,11 +282,6 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
@Override @Override
public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack item) public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack item)
{ {
if (!world().isRemote)
{
System.out.println(this.getNetwork());
}
if (item != null) if (item != null)
{ {
if (item.getItem().itemID == Block.lever.blockID) if (item.getItem().itemID == Block.lever.blockID)
@ -387,7 +382,11 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
{ {
// We found a wire! Merge networks! // We found a wire! Merge networks!
this.connections[absDir] = tp; this.connections[absDir] = tp;
this.getNetwork().merge(((PartFlatWire) tp).getNetwork());
if(tp instanceof PartFlatWire)
{
this.getNetwork().merge(((PartFlatWire) tp).getNetwork());
}
continue; continue;
} }
} }