mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-27 23:33:08 +00:00
Formatting and code readability cleanup (#5467)
* First pass reformatting code to be more readable (common still not done) * Replace google common collect calls with Java calls where possible * Remove a bunch of unnecessary parenthesis leaving clarifying ones * Add some missing @Nonnull annotations * Fix checking wrong type * Remove unnecessary continue/return statements and simplify comparision check * Pass exception instead of directly printing stack trace * Work on cleaning up common, through config so far * Work on cleaning up common, through integration so far * Work on cleaning up common, through network so far * Work on cleaning up common, through tier so far * Remove empty constructors that get created by default anyways * Work on cleaning up common, through transmitters so far * Work on cleaning up common, through utils so far * Finish cleaning up spacing for common
This commit is contained in:
1 parent
91ef2a5c3d
commit
0d4b50908f
909 files changed
+6234
-15623
No files matched your search
@@ -23,37 +23,31 @@ public class PacketPersonalChest implements IMessageHandler<PersonalChestMessage
|
||||
@Override
|
||||
public IMessage onMessage(PersonalChestMessage message, MessageContext context) {
|
||||
EntityPlayer player = PacketHandler.getPlayer(context);
|
||||
|
||||
PacketHandler.handlePacket(() -> {
|
||||
if (message.packetType == PersonalChestPacketType.SERVER_OPEN) {
|
||||
try {
|
||||
if (message.isBlock) {
|
||||
TileEntityPersonalChest tileEntity = (TileEntityPersonalChest) message.coord4D
|
||||
.getTileEntity(player.world);
|
||||
TileEntityPersonalChest tileEntity = (TileEntityPersonalChest) message.coord4D.getTileEntity(player.world);
|
||||
MekanismUtils.openPersonalChestGui((EntityPlayerMP) player, tileEntity, null, true);
|
||||
} else {
|
||||
ItemStack stack = player.getHeldItem(message.currentHand);
|
||||
|
||||
if (MachineType.get(stack) == MachineType.PERSONAL_CHEST) {
|
||||
InventoryPersonalChest inventory = new InventoryPersonalChest(stack, message.currentHand);
|
||||
MekanismUtils.openPersonalChestGui((EntityPlayerMP) player, null, inventory, false);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Mekanism.logger.error("Error while handling electric chest open packet.");
|
||||
e.printStackTrace();
|
||||
Mekanism.logger.error("Error while handling electric chest open packet.", e);
|
||||
}
|
||||
} else if (message.packetType == PersonalChestPacketType.CLIENT_OPEN) {
|
||||
try {
|
||||
Mekanism.proxy.openPersonalChest(player, message.guiType, message.windowId, message.isBlock,
|
||||
message.coord4D == null ? BlockPos.ORIGIN : message.coord4D.getPos(), message.currentHand);
|
||||
} catch (Exception e) {
|
||||
Mekanism.logger.error("Error while handling electric chest open packet.");
|
||||
e.printStackTrace();
|
||||
Mekanism.logger.error("Error while handling electric chest open packet.", e);
|
||||
}
|
||||
}
|
||||
}, player);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -88,23 +82,19 @@ public class PacketPersonalChest implements IMessageHandler<PersonalChestMessage
|
||||
guiType = i1;
|
||||
windowId = i2;
|
||||
isBlock = b1;
|
||||
|
||||
if (isBlock) {
|
||||
coord4D = c1;
|
||||
} else {
|
||||
currentHand = hand;
|
||||
}
|
||||
|
||||
break;
|
||||
case SERVER_OPEN:
|
||||
isBlock = b1;
|
||||
|
||||
if (isBlock) {
|
||||
coord4D = c1;
|
||||
} else {
|
||||
currentHand = hand;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -112,29 +102,24 @@ public class PacketPersonalChest implements IMessageHandler<PersonalChestMessage
|
||||
@Override
|
||||
public void toBytes(ByteBuf dataStream) {
|
||||
dataStream.writeInt(packetType.ordinal());
|
||||
|
||||
switch (packetType) {
|
||||
case CLIENT_OPEN:
|
||||
dataStream.writeInt(guiType);
|
||||
dataStream.writeInt(windowId);
|
||||
dataStream.writeBoolean(isBlock);
|
||||
|
||||
if (isBlock) {
|
||||
coord4D.write(dataStream);
|
||||
} else {
|
||||
dataStream.writeInt(currentHand.ordinal());
|
||||
}
|
||||
|
||||
break;
|
||||
case SERVER_OPEN:
|
||||
dataStream.writeBoolean(isBlock);
|
||||
|
||||
if (isBlock) {
|
||||
coord4D.write(dataStream);
|
||||
} else {
|
||||
dataStream.writeInt(currentHand.ordinal());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -142,13 +127,10 @@ public class PacketPersonalChest implements IMessageHandler<PersonalChestMessage
|
||||
@Override
|
||||
public void fromBytes(ByteBuf dataStream) {
|
||||
packetType = PersonalChestPacketType.values()[dataStream.readInt()];
|
||||
|
||||
if (packetType == PersonalChestPacketType.SERVER_OPEN) {
|
||||
isBlock = dataStream.readBoolean();
|
||||
|
||||
if (isBlock) {
|
||||
coord4D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(),
|
||||
dataStream.readInt());
|
||||
coord4D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt());
|
||||
} else {
|
||||
currentHand = EnumHand.values()[dataStream.readInt()];
|
||||
}
|
||||
@@ -156,14 +138,12 @@ public class PacketPersonalChest implements IMessageHandler<PersonalChestMessage
|
||||
guiType = dataStream.readInt();
|
||||
windowId = dataStream.readInt();
|
||||
isBlock = dataStream.readBoolean();
|
||||
|
||||
if (isBlock) {
|
||||
coord4D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(),
|
||||
dataStream.readInt());
|
||||
coord4D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt());
|
||||
} else {
|
||||
currentHand = EnumHand.values()[dataStream.readInt()];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user