Removed fluidID from ItemStack.

This fixes a rather huge issue where FluidStacks on the client could be desynced if a modder was unaware of it.

This is a breaking change but can be mitigated with a transformer to the getter getFluidID().

Signed-off-by: King Lemming <[email protected]>
This commit is contained in:
King Lemming authored and cpw committed 2015-04-05 22:30:39 -04:00
1 parent 38b9febfe5
commit 3fc40b955a
6 files changed
+88 -82

No files matched your search

@@ -1,12 +1,10 @@
package net.minecraftforge.common.network;
import java.util.Map;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import cpw.mods.fml.common.network.ByteBufUtils;
import io.netty.buffer.ByteBuf;
@@ -40,15 +38,15 @@ public abstract class ForgeMessage {
}
public static class FluidIdMapMessage extends ForgeMessage {
BiMap<String, Integer> fluidIds = HashBiMap.create();
BiMap<Fluid, Integer> fluidIds = HashBiMap.create();
@Override
void toBytes(ByteBuf bytes)
{
Map<String, Integer> ids = FluidRegistry.getRegisteredFluidIDs();
Map<Fluid, Integer> ids = FluidRegistry.getRegisteredFluidIDs();
bytes.writeInt(ids.size());
for (Map.Entry<String, Integer> entry : ids.entrySet())
for (Map.Entry<Fluid, Integer> entry : ids.entrySet())
{
ByteBufUtils.writeUTF8String(bytes,entry.getKey());
ByteBufUtils.writeUTF8String(bytes,entry.getKey().getName());
bytes.writeInt(entry.getValue());
}
}
@@ -60,7 +58,7 @@ public abstract class ForgeMessage {
for (int i = 0; i < listSize; i++) {
String fluidName = ByteBufUtils.readUTF8String(bytes);
int fluidId = bytes.readInt();
fluidIds.put(fluidName, fluidId);
fluidIds.put(FluidRegistry.getFluid(fluidName), fluidId);
}
}
}