Skip to content

Commit

Permalink
Add NBT and networking
Browse files Browse the repository at this point in the history
  • Loading branch information
jakimfett committed Nov 5, 2014
1 parent d2bbd3f commit 031ef53
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p
{
MixingHelper.addEffect(itemStack, (PotionEffect) iter.next());
}
itemStack.setItemDamage(diffuser.bottleDamage);
itemStack.setItemDamage(diffuser.potionDamageValue);
player.inventory.mainInventory[player.inventory.currentItem] = itemStack;

// Wiping the diffuser data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class DiffuserTileEntity extends TileEntity implements IFluidHandler, IFl
public boolean isDiffusing;
public int bottleColor;
public int diffusingTicks;
public int bottleDamage;
public int potionDamageValue;

public DiffuserTileEntity()
{
Expand Down Expand Up @@ -208,6 +208,7 @@ public void writeToNBT(NBTTagCompound nbt)
nbt.setTag("diffuserTank", this.fluidTank.writeToNBT(new NBTTagCompound()));
nbt.setInteger("diffuserTankAmount", this.fluidTank.getFluidAmount());
nbt.setInteger("effectsCount", this.fluidTank.potionEffects.size());
nbt.setInteger("potionDamageValue", this.potionDamageValue);
Iterator potionEffects = this.fluidTank.potionEffects.iterator();
int count = 0;
while (potionEffects.hasNext())
Expand Down Expand Up @@ -235,6 +236,8 @@ public void readFromNBT(NBTTagCompound nbt)

this.bottleColor = nbt.getInteger("bottleColor");

this.potionDamageValue = nbt.getInteger("potionDamageValue");

if (this.fluidTank != null)
{
this.fluidTank.readFromNBT(nbt.getCompoundTag("diffuserTank"));
Expand All @@ -256,7 +259,7 @@ public int fillWithOverRide(ItemStack heldItem)
{
PotionFluid potionFluid = new PotionFluid(heldItem);
this.fluidTank = new PotionFluidTank(new PotionFluidStack(potionFluid, 333), 333);
this.bottleDamage = heldItem.getItemDamage();
this.potionDamageValue = heldItem.getItemDamage();
this.bottleColor = potionFluid.getColor();
this.updateState = true;
return this.fluidTank.getFluidAmount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class DiffuserUpdateMessage implements IMessage, IMessageHandler<DiffuserUpdateMessage, IMessage>
{
private int posX, posY, posZ;
private int bottleColor, fluidLevel, fluidID;
private int bottleColor, potionDamageValue, fluidLevel, fluidID;
private boolean isDiffusing;
private int effectsListSize;
private int[] effectIDs;
Expand All @@ -30,6 +30,7 @@ public DiffuserUpdateMessage(DiffuserTileEntity diffuser)
this.posZ = diffuser.zCoord;

this.bottleColor = diffuser.bottleColor;
this.potionDamageValue = diffuser.potionDamageValue;
this.isDiffusing = diffuser.isDiffusing;
this.fluidLevel = diffuser.getFluidAmount();
if (diffuser.getFluid() != null)
Expand Down Expand Up @@ -70,6 +71,7 @@ public void fromBytes(ByteBuf buf)
this.posZ = buf.readInt();

this.bottleColor = buf.readInt();
this.potionDamageValue = buf.readInt();
this.isDiffusing = buf.readBoolean();
this.fluidLevel = buf.readInt();
this.fluidID = buf.readInt();
Expand All @@ -92,6 +94,7 @@ public void toBytes(ByteBuf buf)
buf.writeInt(this.posZ);

buf.writeInt(this.bottleColor);
buf.writeInt(this.potionDamageValue);
buf.writeBoolean(this.isDiffusing);
buf.writeInt(this.fluidLevel);
buf.writeInt(this.fluidID);
Expand All @@ -114,6 +117,7 @@ public IMessage onMessage(DiffuserUpdateMessage message, MessageContext ctx)
((DiffuserTileEntity) tile).setBottleColorValue(message.bottleColor);
((DiffuserTileEntity) tile).setDiffusingState(message.isDiffusing);
((DiffuserTileEntity) tile).syncFluidAmountAt(message.fluidLevel, message.fluidID);
((DiffuserTileEntity) tile).potionDamageValue = this.potionDamageValue;

}
return null;
Expand Down

0 comments on commit 031ef53

Please sign in to comment.