Multimeter now rotates text based on ground placement

This commit is contained in:
Calclavia 2014-02-22 18:40:24 +08:00
parent d95cea31e0
commit 64b3690463
3 changed files with 15 additions and 2 deletions

View file

@ -6,6 +6,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Icon; import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import resonantinduction.core.prefab.part.IHighlight; import resonantinduction.core.prefab.part.IHighlight;
@ -37,7 +38,9 @@ public class ItemMultimeter extends JItemMultiPart implements IHighlight
if (part != null) if (part != null)
{ {
part.preparePlacement(side, itemStack.getItemDamage()); int l = MathHelper.floor_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)));
part.preparePlacement(side, facing);
} }
return part; return part;

View file

@ -300,6 +300,7 @@ public class PartMultimeter extends PartFace implements IConnector<MultimeterNet
{ {
packet.readByte(); packet.readByte();
placementSide = ForgeDirection.getOrientation(packet.readByte()); placementSide = ForgeDirection.getOrientation(packet.readByte());
facing = packet.readByte();
detectMode = DetectMode.values()[packet.readByte()]; detectMode = DetectMode.values()[packet.readByte()];
getNetwork().center = new universalelectricity.api.vector.Vector3(packet.readNBTTagCompound()); getNetwork().center = new universalelectricity.api.vector.Vector3(packet.readNBTTagCompound());
getNetwork().size = new universalelectricity.api.vector.Vector3(packet.readNBTTagCompound()); getNetwork().size = new universalelectricity.api.vector.Vector3(packet.readNBTTagCompound());
@ -311,7 +312,8 @@ public class PartMultimeter extends PartFace implements IConnector<MultimeterNet
{ {
packet.writeByte(0); packet.writeByte(0);
packet.writeByte(placementSide.ordinal()); packet.writeByte(placementSide.ordinal());
packet.writeByte((byte) detectMode.ordinal()); packet.writeByte(facing);
packet.writeByte(detectMode.ordinal());
packet.writeNBTTagCompound(getNetwork().center.writeToNBT(new NBTTagCompound())); packet.writeNBTTagCompound(getNetwork().center.writeToNBT(new NBTTagCompound()));
packet.writeNBTTagCompound(getNetwork().size.writeToNBT(new NBTTagCompound())); packet.writeNBTTagCompound(getNetwork().size.writeToNBT(new NBTTagCompound()));
packet.writeBoolean(getNetwork().isEnabled); packet.writeBoolean(getNetwork().isEnabled);
@ -338,6 +340,7 @@ public class PartMultimeter extends PartFace implements IConnector<MultimeterNet
if (packetID == 0) if (packetID == 0)
{ {
placementSide = ForgeDirection.getOrientation(packet.readByte()); placementSide = ForgeDirection.getOrientation(packet.readByte());
facing = packet.readByte();
detectMode = DetectMode.values()[packet.readByte()]; detectMode = DetectMode.values()[packet.readByte()];
getNetwork().center = new universalelectricity.api.vector.Vector3(packet.readNBTTagCompound()); getNetwork().center = new universalelectricity.api.vector.Vector3(packet.readNBTTagCompound());
getNetwork().size = new universalelectricity.api.vector.Vector3(packet.readNBTTagCompound()); getNetwork().size = new universalelectricity.api.vector.Vector3(packet.readNBTTagCompound());

View file

@ -178,6 +178,13 @@ public class RenderMultimeter implements ISimpleItemRenderer
Vector3 centerTranslation = part.getNetwork().center.clone().subtract(part.x(), part.y(), part.z()).add(-0.5); Vector3 centerTranslation = part.getNetwork().center.clone().subtract(part.x(), part.y(), part.z()).add(-0.5);
GL11.glTranslated(centerTranslation.x, centerTranslation.y, centerTranslation.z); GL11.glTranslated(centerTranslation.x, centerTranslation.y, centerTranslation.z);
RenderUtility.rotateFaceBlockToSideOutwards(part.getDirection().getOpposite()); RenderUtility.rotateFaceBlockToSideOutwards(part.getDirection().getOpposite());
if (part.getDirection().offsetY != 0)
{
GL11.glRotatef(90, 0, 1, 0);
RenderUtility.rotateBlockBasedOnDirection(part.getFacing());
}
GL11.glTranslated(0, 0.07, 0); GL11.glTranslated(0, 0.07, 0);
List<String> information = new ArrayList<String>(); List<String> information = new ArrayList<String>();