mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-26 14:52:58 +00:00
The Great Reformat; moving to google-java-style w/ 4 space indent and 120 column line wrap
This commit is contained in:
1 parent
c632cc6af9
commit
e0b7ea62a4
933 files changed
+95734
-108818
No files matched your search
@@ -1,9 +1,7 @@
|
||||
package mekanism.common.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.network.PacketSecurityMode.SecurityModeMessage;
|
||||
@@ -18,103 +16,89 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
public class PacketSecurityMode implements IMessageHandler<SecurityModeMessage, IMessage>
|
||||
{
|
||||
@Override
|
||||
public IMessage onMessage(SecurityModeMessage message, MessageContext context)
|
||||
{
|
||||
EntityPlayer player = PacketHandler.getPlayer(context);
|
||||
|
||||
PacketHandler.handlePacket(() ->
|
||||
public class PacketSecurityMode implements IMessageHandler<SecurityModeMessage, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(SecurityModeMessage message, MessageContext context) {
|
||||
EntityPlayer player = PacketHandler.getPlayer(context);
|
||||
|
||||
PacketHandler.handlePacket(() ->
|
||||
{
|
||||
if(message.packetType == SecurityPacketType.BLOCK)
|
||||
{
|
||||
if (message.packetType == SecurityPacketType.BLOCK) {
|
||||
TileEntity tileEntity = message.coord4D.getTileEntity(player.world);
|
||||
|
||||
if(tileEntity instanceof ISecurityTile)
|
||||
{
|
||||
UUID owner = ((ISecurityTile)tileEntity).getSecurity().getOwnerUUID();
|
||||
if (tileEntity instanceof ISecurityTile) {
|
||||
UUID owner = ((ISecurityTile) tileEntity).getSecurity().getOwnerUUID();
|
||||
|
||||
if(owner != null && player.getUniqueID().equals(owner))
|
||||
{
|
||||
((ISecurityTile)tileEntity).getSecurity().setMode(message.value);
|
||||
if (owner != null && player.getUniqueID().equals(owner)) {
|
||||
((ISecurityTile) tileEntity).getSecurity().setMode(message.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ItemStack stack = player.getHeldItem(message.currentHand);
|
||||
|
||||
if(stack.getItem() instanceof ISecurityItem)
|
||||
{
|
||||
((ISecurityItem)stack.getItem()).setSecurity(stack, message.value);
|
||||
if (stack.getItem() instanceof ISecurityItem) {
|
||||
((ISecurityItem) stack.getItem()).setSecurity(stack, message.value);
|
||||
}
|
||||
}
|
||||
}, player);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class SecurityModeMessage implements IMessage
|
||||
{
|
||||
public SecurityPacketType packetType;
|
||||
public Coord4D coord4D;
|
||||
public EnumHand currentHand;
|
||||
public SecurityMode value;
|
||||
|
||||
public 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;
|
||||
}
|
||||
|
||||
@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()];
|
||||
}
|
||||
}
|
||||
|
||||
public enum SecurityPacketType
|
||||
{
|
||||
BLOCK,
|
||||
ITEM
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public enum SecurityPacketType {
|
||||
BLOCK,
|
||||
ITEM
|
||||
}
|
||||
|
||||
public static class SecurityModeMessage implements IMessage {
|
||||
|
||||
public SecurityPacketType packetType;
|
||||
public Coord4D coord4D;
|
||||
public EnumHand currentHand;
|
||||
public SecurityMode value;
|
||||
|
||||
public 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;
|
||||
}
|
||||
|
||||
@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