Fixed #94 - multimeter gui and redstone output

This commit is contained in:
Calclavia 2014-01-23 22:18:15 +08:00
parent 07d53200d5
commit 34018f215b
3 changed files with 27 additions and 24 deletions

View file

@ -50,7 +50,7 @@ public class PacketMultiPart extends PacketType
int y = data.readInt();
int z = data.readInt();
TileEntity tileEntity = player.worldObj.getBlockTileEntity(x, y, z);
if (tileEntity instanceof TileMultipart)
{
TMultiPart part = ((TileMultipart) tileEntity).partMap(data.readInt());

View file

@ -25,9 +25,6 @@ import cpw.mods.fml.relauncher.SideOnly;
public class GuiMultimeter extends GuiContainerBase
{
PartMultimeter multimeter;
private int containerWidth;
private int containerHeight;
private GuiTextField textFieldLimit;
public GuiMultimeter(InventoryPlayer inventoryPlayer, PartMultimeter tileEntity)
@ -76,9 +73,9 @@ public class GuiMultimeter extends GuiContainerBase
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
String s = LanguageUtility.getLocal("tile.resonantinduction:multimeter.name");
this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 15, 4210752);
this.fontRenderer.drawString(EnumColor.DARK_GREEN + LanguageUtility.getLocal("gui.resonantinduction.multimeter.averageEnergy"), 35, 15, 4210752);
this.fontRenderer.drawString(EnumColor.INDIGO + LanguageUtility.getLocal("gui.resonantinduction.multimeter.averageEnergy"), 35, 15, 4210752);
this.renderUniversalDisplay(35, 25, this.multimeter.getAverageDetectedEnergy(), mouseX, mouseY, Unit.JOULES);
this.fontRenderer.drawString(EnumColor.DARK_GREEN + LanguageUtility.getLocal("gui.resonantinduction.multimeter.energy"), 35, 35, 4210752);
this.fontRenderer.drawString(EnumColor.INDIGO + LanguageUtility.getLocal("gui.resonantinduction.multimeter.energy"), 35, 35, 4210752);
this.renderUniversalDisplay(35, 45, this.multimeter.getDetectedEnergy(), mouseX, mouseY, Unit.JOULES);
this.fontRenderer.drawString(EnumColor.ORANGE + LanguageUtility.getLocal("gui.resonantinduction.multimeter.redstone"), 35, 58, 4210752);
this.fontRenderer.drawString(EnumColor.RED + LanguageUtility.getLocal("gui.resonantinduction.multimeter." + this.multimeter.getMode().display), 35, 68, 4210752);

View file

@ -29,6 +29,7 @@ import codechicken.lib.vec.Rotation;
import codechicken.lib.vec.Transformation;
import codechicken.lib.vec.Vector3;
import codechicken.microblock.FaceMicroClass;
import codechicken.multipart.IRedstonePart;
import codechicken.multipart.JCuboidPart;
import codechicken.multipart.JNormalOcclusion;
import codechicken.multipart.NormalOcclusionTest;
@ -47,7 +48,7 @@ import cpw.mods.fml.relauncher.SideOnly;
* @author Calclavia
*
*/
public class PartMultimeter extends JCuboidPart implements IPacketReceiver, TFacePart, JNormalOcclusion
public class PartMultimeter extends JCuboidPart implements IPacketReceiver, TFacePart, JNormalOcclusion, IRedstonePart
{
public static Cuboid6[][] bounds = new Cuboid6[6][2];
@ -95,7 +96,7 @@ public class PartMultimeter extends JCuboidPart implements IPacketReceiver, TFac
@Override
public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack item)
{
player.openGui(ResonantInduction.INSTANCE, this.side, world(), x(), y(), z());
player.openGui(Electrical.INSTANCE, side, world(), x(), y(), z());
return true;
}
@ -139,7 +140,7 @@ public class PartMultimeter extends JCuboidPart implements IPacketReceiver, TFac
if (outputRedstone != redstoneOn)
{
redstoneOn = outputRedstone;
this.tile().notifyTileChange();
tile().notifyPartChange(this);
}
if (prevDetectedEnergy != detectedEnergy)
@ -268,23 +269,10 @@ public class PartMultimeter extends JCuboidPart implements IPacketReceiver, TFac
}
else
{
PacketDispatcher.sendPacketToServer(ResonantInduction.PACKET_MULTIPART.getPacket(new universalelectricity.api.vector.Vector3(x(), y(), z()), getPartID()));
PacketDispatcher.sendPacketToServer(ResonantInduction.PACKET_MULTIPART.getPacket(new universalelectricity.api.vector.Vector3(x(), y(), z()), side));
}
}
public int getPartID()
{
for (int i = 0; i < this.tile().partList().size(); i++)
{
if (this.tile().partMap(i) == this)
{
return i;
}
}
return 0;
}
@Override
public void load(NBTTagCompound nbt)
{
@ -351,7 +339,7 @@ public class PartMultimeter extends JCuboidPart implements IPacketReceiver, TFac
@Override
public int redstoneConductionMap()
{
return 0;
return 0x1F;
}
@Override
@ -389,4 +377,22 @@ public class PartMultimeter extends JCuboidPart implements IPacketReceiver, TFac
}
}
@Override
public boolean canConnectRedstone(int arg0)
{
return true;
}
@Override
public int strongPowerLevel(int arg0)
{
return redstoneOn ? 14 : 0;
}
@Override
public int weakPowerLevel(int arg0)
{
return redstoneOn ? 14 : 0;
}
}