Made battlesigns have editable text

This commit is contained in:
Arthur Uzulin committed 2014-09-12 23:59:13 +10:00
1 parent fc0d73dbf6
commit 3d028e7123
20 files changed
+545 -205

No files matched your search

@@ -3,6 +3,8 @@ package tconstruct.tools.logic;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.world.World;
/* Slots
@@ -11,6 +13,7 @@ import net.minecraft.world.World;
public class BattlesignLogic extends EquipLogic
{
protected String[] text;
public BattlesignLogic()
{
@@ -23,15 +26,34 @@ public class BattlesignLogic extends EquipLogic
return "decoration.battlesign";
}
@Override
/* NBT */
public void readFromNBT (NBTTagCompound tags)
{
super.readFromNBT(tags);
text = new String[tags.getInteger("lineCount")];
for (int i = 0; i < text.length; i++)
{
text[i] = tags.getString("line" + i);
}
}
@Override
public void writeToNBT (NBTTagCompound tags)
{
super.writeToNBT(tags);
if (text == null)
{
text = new String[0];
}
tags.setInteger("lineCount", text.length);
for (int i = 0; i < text.length; i++)
{
tags.setString("line" + i, text[i]);
}
}
@Override
@@ -55,4 +77,30 @@ public class BattlesignLogic extends EquipLogic
public void closeInventory ()
{
}
public void setText (String[] text)
{
this.text = text;
}
public String[] getText ()
{
return text;
}
@Override
public S35PacketUpdateTileEntity getDescriptionPacket ()
{
NBTTagCompound compound = new NBTTagCompound();
this.writeToNBT(compound);
S35PacketUpdateTileEntity packet = new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, compound);
return packet;
}
@Override
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity pkt)
{
this.readFromNBT(pkt.func_148857_g());
}
}