mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-24 05:54:41 +00:00
1 parent
276929901f
commit
6cd56ebed6
22 files changed
+3021
-5
No files matched your search
@@ -0,0 +1,52 @@
|
||||
|
||||
package net.minecraftforge.fluids;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraftforge.common.network.ForgePacket;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
public class FluidIdMapPacket extends ForgePacket {
|
||||
|
||||
private BiMap<String, Integer> fluidIds = HashBiMap.create();
|
||||
|
||||
@Override
|
||||
public byte[] generatePacket(Object... data) {
|
||||
|
||||
ByteArrayDataOutput dat = ByteStreams.newDataOutput();
|
||||
|
||||
dat.writeInt(FluidRegistry.maxID);
|
||||
for (Map.Entry<String, Integer> entry : FluidRegistry.fluidIDs.entrySet()) {
|
||||
dat.writeUTF(entry.getKey());
|
||||
dat.writeInt(entry.getValue());
|
||||
}
|
||||
return dat.toByteArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgePacket consumePacket(byte[] data) {
|
||||
|
||||
ByteArrayDataInput dat = ByteStreams.newDataInput(data);
|
||||
int listSize = dat.readInt();
|
||||
for (int i = 0; i < listSize; i++) {
|
||||
String fluidName = dat.readUTF();
|
||||
int fluidId = dat.readInt();
|
||||
fluidIds.put(fluidName, fluidId);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(INetworkManager network, EntityPlayer player) {
|
||||
|
||||
FluidRegistry.initFluidIDs(fluidIds);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user