@Override public IMessage onMessage(PacketInvokStarting message, MessageContext ctx) { ctx.getServerHandler().playerEntity.closeScreen(); HammerHelper.startInvoking( ctx.getServerHandler().playerEntity.worldObj, ctx.getServerHandler().playerEntity, message.x, message.y, message.z); return null; }
@Override public IMessage onMessage(PacketTcomAction message, MessageContext ctx) { TileTcom tile = message.getTileEntity(ctx.getServerHandler().playerEntity.worldObj); if (tile == null) { return null; } if (message.mat != null) { tile.extractItems(message.mat, ctx.getServerHandler().playerEntity); } else if (message.enchant >= 0) { tile.extractEnchantment(message.enchant, ctx.getServerHandler().playerEntity); } else { tile.updateClient(ctx.getServerHandler().playerEntity); } return null; }
@Override public IMessage onMessage(ItemBarPacketProcessor message, MessageContext ctx) { try { ItemStack stack = null; if (message.slot > -1 && message.slot < 9) { stack = ctx.getServerHandler().playerEntity.inventory.getStackInSlot(message.slot); } if (stack != null && stack.getItem() != null && stack.getItem() instanceof ItemBraceBase) { ((ItemBraceBase) stack.getItem()) .wheelEvent(ctx.getServerHandler().playerEntity, stack, message.key, message.dwheel); } } finally { } return null; }
@Override public IMessage onMessage(AddTrustedPlayerMessage message, MessageContext ctx) { World world = ctx.getServerHandler().playerEntity.worldObj; TurretBase turret = (TurretBase) world.getTileEntity(message.getX(), message.getY(), message.getZ()); turret.addTrustedPlayer(message.getPlayer()); world.markBlockForUpdate(message.getX(), message.getY(), message.getZ()); return null; }
@Override public IMessage onMessage(ItemNamePacket message, MessageContext ctx) { EntityPlayerMP player = ctx.getServerHandler().playerEntity; TileEntity hammer = player.worldObj.getTileEntity(message.x, message.y, message.z); if (hammer != null && hammer instanceof TileEntitySteamHammer) { ContainerSteamAnvil anvil = (ContainerSteamAnvil) player.openContainer; anvil.updateItemName(message.name); } return null; }
@Override public PacketAllReceiversReady onMessage(PacketGetAllReceivers message, MessageContext ctx) { EntityPlayer player = ctx.getServerHandler().playerEntity; TeleportDestinations destinations = TeleportDestinations.getDestinations(player.worldObj); List<TeleportDestinationClientInfo> destinationList = new ArrayList<TeleportDestinationClientInfo>(destinations.getValidDestinations(null)); addDimensions(destinationList); addRfToolsDimensions(player.worldObj, destinationList); return new PacketAllReceiversReady(destinationList); }
@Override public IMessage onMessage(PacketGuiId message, MessageContext ctx) { EntityPlayerMP p = ctx.getServerHandler().playerEntity; int i = message.getData().getInteger("gui"); p.openGui(MCEconomy2.instance, i, p.worldObj, (int) p.posX, (int) p.posY, (int) p.posZ); return null; }
@Override public IMessage onMessage(MessageSwitchRecipe message, MessageContext ctx) { Container container = ctx.getServerHandler().playerEntity.openContainer; if (container instanceof ContainerRecipeBook) { if (message.getDirection() == 1) { ((ContainerRecipeBook) container).nextRecipe(); } else if (message.getDirection() == -1) { ((ContainerRecipeBook) container).prevRecipe(); } } return null; }
@Override public IMessage onMessage(MessageTelePipeUpdate message, MessageContext ctx) { TileEntity te = ctx.getServerHandler().playerEntity.worldObj.getTileEntity(message.x, message.y, message.z); if (te instanceof TileGenericPipe) { PipeTeleport<?> pipe = (PipeTeleport<?>) ((TileGenericPipe) te).pipe; // only allow the owner to change pipe state EntityPlayerMP entityPlayer = (EntityPlayerMP) ctx.getServerHandler().playerEntity; if (!PipeTeleport.canPlayerModifyPipe(entityPlayer, pipe)) { entityPlayer.addChatComponentMessage( new ChatComponentText("Sorry, You may not change pipe state.")); return null; } int frequency = message._freq; if (frequency < 0) { frequency = 0; } pipe.setFrequency(frequency); pipe.state = (byte) message._state; pipe.isPublic = message._isPublic; } return null; }
public EntityPlayer getPlayerFromMessageContext(MessageContext ctx) { switch (ctx.side) { case CLIENT: { assert false : "Message for CLIENT received on dedicated server"; } case SERVER: { EntityPlayer entityPlayerMP = ctx.getServerHandler().playerEntity; return entityPlayerMP; } default: assert false : "Invalid side in TestMsgHandler: " + ctx.side; } return null; }
public IMessage onMessage(PacketSetExplosiveState packet, MessageContext context) { EntityPlayer player = context.getServerHandler().playerEntity; if (getWorld(player).getBlock(packet.x, packet.y, packet.z) != null && getWorld(player).getBlock(packet.x, packet.y, packet.z) instanceof IExplosive) { if (packet.state.equalsIgnoreCase("activate")) { ((IExplosive) getWorld(player).getBlock(packet.x, packet.y, packet.z)) .activateMine(getWorld(player), packet.x, packet.y, packet.z); } else if (packet.state.equalsIgnoreCase("defuse")) { ((IExplosive) getWorld(player).getBlock(packet.x, packet.y, packet.z)) .defuseMine(getWorld(player), packet.x, packet.y, packet.z); } else if (packet.state.equalsIgnoreCase("detonate")) { ((IExplosive) getWorld(player).getBlock(packet.x, packet.y, packet.z)) .explode(getWorld(player), packet.x, packet.y, packet.z); } } return null; }
@Override public IMessage onMessage(MessageSeedInfuser message, MessageContext ctx) { int x = message.x, y = message.y, z = message.z; if (ctx.side.isServer()) { TileEntity te = ctx.getServerHandler().playerEntity.worldObj.getTileEntity(x, y, z); if (te instanceof TileEntitySeedInfuser) { TileEntitySeedInfuser infuser = (TileEntitySeedInfuser) te; if (infuser.getStackInSlot(1) != null && infuser.getStackInSlot(1).stackSize > 0) { infuser.setInfusing(true); } int index = infuser.getRecipeIndex(); if (index != -1) { return new MessageSeedInfuser(x, y, z, index); } } } else { TileEntity te = FluxedCrystals.proxy.getClientWorld().getTileEntity(x, y, z); if (te instanceof TileEntitySeedInfuser) { ((TileEntitySeedInfuser) te).setRecipeIndex(message.data); te.getWorldObj().markBlockForUpdate(x, y, z); } } return null; }
@Override public IMessage onMessage(PacketClientRequest message, MessageContext ctx) { NuclearNetworkHelper.sendDisplaySettingsToPlayer( message.x, message.y, message.z, ctx.getServerHandler().playerEntity); return null; }
@Override public IMessage onMessage(NBTPacketUp message, MessageContext ctx) { if (message.type == TypesUp.RECONFIGURE.ordinal()) PacketCarriageUpdate.receive(message.body, ctx.getServerHandler().playerEntity); return null; }