mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-26 14:52:58 +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
@@ -21,15 +21,11 @@ public class PacketSecurityMode implements IMessageHandler<SecurityModeMessage,
|
||||
@Override
|
||||
public IMessage onMessage(SecurityModeMessage message, MessageContext context) {
|
||||
EntityPlayer player = PacketHandler.getPlayer(context);
|
||||
|
||||
PacketHandler.handlePacket(() ->
|
||||
{
|
||||
PacketHandler.handlePacket(() -> {
|
||||
if (message.packetType == SecurityPacketType.BLOCK) {
|
||||
TileEntity tileEntity = message.coord4D.getTileEntity(player.world);
|
||||
|
||||
if (tileEntity instanceof ISecurityTile) {
|
||||
UUID owner = ((ISecurityTile) tileEntity).getSecurity().getOwnerUUID();
|
||||
|
||||
if (owner != null && player.getUniqueID().equals(owner)) {
|
||||
((ISecurityTile) tileEntity).getSecurity().setMode(message.value);
|
||||
tileEntity.markDirty();
|
||||
@@ -37,13 +33,11 @@ public class PacketSecurityMode implements IMessageHandler<SecurityModeMessage,
|
||||
}
|
||||
} else {
|
||||
ItemStack stack = player.getHeldItem(message.currentHand);
|
||||
|
||||
if (stack.getItem() instanceof ISecurityItem) {
|
||||
((ISecurityItem) stack.getItem()).setSecurity(stack, message.value);
|
||||
}
|
||||
}
|
||||
}, player);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -64,14 +58,12 @@ public class PacketSecurityMode implements IMessageHandler<SecurityModeMessage,
|
||||
|
||||
public SecurityModeMessage(Coord4D coord, SecurityMode control) {
|
||||
packetType = SecurityPacketType.BLOCK;
|
||||
|
||||
coord4D = coord;
|
||||
value = control;
|
||||
}
|
||||
|
||||
public SecurityModeMessage(EnumHand hand, SecurityMode control) {
|
||||
packetType = SecurityPacketType.ITEM;
|
||||
|
||||
currentHand = hand;
|
||||
value = control;
|
||||
}
|
||||
@@ -79,27 +71,23 @@ public class PacketSecurityMode implements IMessageHandler<SecurityModeMessage,
|
||||
@Override
|
||||
public void toBytes(ByteBuf dataStream) {
|
||||
dataStream.writeInt(packetType.ordinal());
|
||||
|
||||
if (packetType == SecurityPacketType.BLOCK) {
|
||||
coord4D.write(dataStream);
|
||||
} else {
|
||||
dataStream.writeInt(currentHand.ordinal());
|
||||
}
|
||||
|
||||
dataStream.writeInt(value.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf dataStream) {
|
||||
packetType = SecurityPacketType.values()[dataStream.readInt()];
|
||||
|
||||
if (packetType == SecurityPacketType.BLOCK) {
|
||||
coord4D = Coord4D.read(dataStream);
|
||||
} else {
|
||||
currentHand = EnumHand.values()[dataStream.readInt()];
|
||||
}
|
||||
|
||||
value = SecurityMode.values()[dataStream.readInt()];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user