minor tweaks throughout the source code

This commit is contained in:
asiekierka 2014-10-29 16:18:21 +01:00
parent 054524754d
commit eafa5fe859
6 changed files with 16 additions and 12 deletions

View file

@ -339,6 +339,7 @@ public class BuildCraftEnergy extends BuildCraftMod {
@Mod.EventHandler @Mod.EventHandler
public void postInit(FMLPostInitializationEvent evt) { public void postInit(FMLPostInitializationEvent evt) {
if (BuildCraftCore.modifyWorld) { if (BuildCraftCore.modifyWorld) {
MinecraftForge.EVENT_BUS.register(OilPopulate.INSTANCE); MinecraftForge.EVENT_BUS.register(OilPopulate.INSTANCE);
MinecraftForge.TERRAIN_GEN_BUS.register(new BiomeInitializer()); MinecraftForge.TERRAIN_GEN_BUS.register(new BiomeInitializer());

View file

@ -239,7 +239,7 @@ public class TileBlueprintLibrary extends TileBuildCraft implements IInventory {
@RPC (RPCSide.CLIENT) @RPC (RPCSide.CLIENT)
public void requestSelectedBlueprint () { public void requestSelectedBlueprint () {
if (isOuputConsistent()) { if (isOutputConsistent()) {
if (selected > -1 && selected < currentPage.size()) { if (selected > -1 && selected < currentPage.size()) {
BlueprintBase bpt = BuildCraftBuilders.clientDB BlueprintBase bpt = BuildCraftBuilders.clientDB
.load(currentPage.get(selected)); .load(currentPage.get(selected));
@ -296,7 +296,7 @@ public class TileBlueprintLibrary extends TileBuildCraft implements IInventory {
selected = index; selected = index;
} }
private boolean isOuputConsistent () { private boolean isOutputConsistent () {
if (selected == -1 || getStackInSlot(2) == null) { if (selected == -1 || getStackInSlot(2) == null) {
return false; return false;
} }

View file

@ -10,8 +10,8 @@ package buildcraft.core.network;
import java.io.IOException; import java.io.IOException;
import buildcraft.api.core.BCLog;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTSizeTracker; import net.minecraft.nbt.NBTSizeTracker;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -34,6 +34,9 @@ public class PacketNBT extends PacketCoordinates {
try { try {
byte[] compressed = CompressedStreamTools.compress(nbttagcompound); byte[] compressed = CompressedStreamTools.compress(nbttagcompound);
if (compressed.length > 65535) {
BCLog.logger.error("NBT data is too large (" + compressed.length + " > 65535)! Please report!");
}
data.writeShort(compressed.length); data.writeShort(compressed.length);
data.writeBytes(compressed); data.writeBytes(compressed);
} catch (IOException e) { } catch (IOException e) {
@ -46,7 +49,7 @@ public class PacketNBT extends PacketCoordinates {
public void readData(ByteBuf data) { public void readData(ByteBuf data) {
super.readData(data); super.readData(data);
short length = data.readShort(); int length = data.readUnsignedShort();
byte[] compressed = new byte[length]; byte[] compressed = new byte[length];
data.readBytes(compressed); data.readBytes(compressed);

View file

@ -78,7 +78,7 @@ public class PacketTileState extends PacketCoordinates {
stateWithId.state.writeData(tmpState); stateWithId.state.writeData(tmpState);
} }
data.writeInt(tmpState.readableBytes()); data.writeShort((short) tmpState.readableBytes());
data.writeBytes(tmpState.readBytes(tmpState.readableBytes())); data.writeBytes(tmpState.readBytes(tmpState.readableBytes()));
} }
@ -87,7 +87,7 @@ public class PacketTileState extends PacketCoordinates {
super.readData(data); super.readData(data);
state = Unpooled.buffer(); state = Unpooled.buffer();
int length = data.readInt(); int length = data.readUnsignedShort();
state.writeBytes(data.readBytes(length)); state.writeBytes(data.readBytes(length));
} }
} }

View file

@ -50,8 +50,6 @@ public class PacketUpdate extends BuildCraftPacket {
if (payload != null) { if (payload != null) {
payload.writeData(data); payload.writeData(data);
} else {
data.writeByte(0);
} }
} }
@ -62,10 +60,12 @@ public class PacketUpdate extends BuildCraftPacket {
posY = data.readInt(); posY = data.readInt();
posZ = data.readInt(); posZ = data.readInt();
payload = new PacketPayload(); if (data.isReadable()) {
payload = new PacketPayload();
if (payload != null) { if (payload != null) {
payload.readData(data); payload.readData(data);
}
} }
} }

View file

@ -32,7 +32,7 @@ public class PacketPowerUpdate extends PacketCoordinates {
displayPower = new short[] { 0, 0, 0, 0, 0, 0 }; displayPower = new short[] { 0, 0, 0, 0, 0, 0 };
overload = data.readBoolean(); overload = data.readBoolean();
for (int i = 0; i < displayPower.length; i++) { for (int i = 0; i < displayPower.length; i++) {
displayPower[i] = data.readByte(); displayPower[i] = data.readUnsignedByte();
} }
} }