use of net.minecraft.network.NetHandlerPlayServer in project RecurrentComplex by Ivorforce.
the class PacketEditInventoryItemHandler method processServer.
@Override
public void processServer(P message, MessageContext ctx, WorldServer server) {
NetHandlerPlayServer playServer = ctx.getServerHandler();
EntityPlayerMP player = playServer.player;
affectItem(player, player.inventory.getStackInSlot(message.getInventorySlot()), message);
player.openContainer.detectAndSendChanges();
}
use of net.minecraft.network.NetHandlerPlayServer in project RecurrentComplex by Ivorforce.
the class PacketInspectEntityHandler method processServer.
@Override
public void processServer(PacketInspectEntity message, MessageContext ctx, WorldServer world) {
NetHandlerPlayServer playServer = ctx.getServerHandler();
EntityPlayerMP player = playServer.player;
if (RecurrentComplex.checkPerms(player))
return;
Entity entity = world.getEntityFromUuid(message.getUuid());
if (entity != null)
entity.readFromNBT(message.getData());
}
use of net.minecraft.network.NetHandlerPlayServer in project RecurrentComplex by Ivorforce.
the class PacketSaveInvGenComponentHandler method processServer.
@Override
public void processServer(PacketSaveInvGenComponent message, MessageContext ctx, WorldServer server) {
NetHandlerPlayServer playServer = ctx.getServerHandler();
EntityPlayerMP player = playServer.player;
if (RecurrentComplex.checkPerms(player))
return;
SaveDirectoryData.Result saveDirectoryDataResult = message.getSaveDirectoryDataResult();
String id = message.getKey();
ResourceDirectory saveDir = saveDirectoryDataResult.directory;
ResourceDirectory delDir = saveDir.opposite();
GenericItemCollectionRegistry.INSTANCE.register(id, "", message.getInventoryGenerator(), saveDir.isActive(), saveDir.getLevel());
if (RCCommands.informSaveResult((message.getInventoryGenerator() != null && id != null) && RecurrentComplex.saver.trySave(saveDir.toPath(), RCFileSaver.INVENTORY_GENERATION_COMPONENT, id), player, saveDir, RCFileSaver.INVENTORY_GENERATION_COMPONENT, id)) {
if (saveDirectoryDataResult.deleteOther)
RCCommands.informDeleteResult(RecurrentComplex.saver.tryDeleteWithID(delDir.toPath(), RCFileSaver.INVENTORY_GENERATION_COMPONENT, id), player, RCFileSaver.INVENTORY_GENERATION_COMPONENT, id, delDir);
ItemStack heldItem = playServer.player.getHeldItem(EnumHand.MAIN_HAND);
if (heldItem != null && heldItem.getItem() instanceof ItemInventoryGenComponentTag)
ItemInventoryGenComponentTag.setComponentKey(heldItem, id);
player.openContainer.detectAndSendChanges();
}
}
use of net.minecraft.network.NetHandlerPlayServer in project RecurrentComplex by Ivorforce.
the class PacketInspectBlockHandler method processServer.
@Override
public void processServer(PacketInspectBlock message, MessageContext ctx, WorldServer world) {
NetHandlerPlayServer playServer = ctx.getServerHandler();
EntityPlayerMP player = playServer.player;
if (RecurrentComplex.checkPerms(player))
return;
setBlock(world, message.getPos(), message.getState(), message.getTileEntityData());
}
use of net.minecraft.network.NetHandlerPlayServer in project ArsMagica2 by Mithion.
the class AMPacketProcessorServer method onServerPacketData.
@SubscribeEvent
public void onServerPacketData(ServerCustomPacketEvent event) {
ByteBufInputStream bbis = new ByteBufInputStream(event.packet.payload());
byte packetID = -1;
try {
if (event.packet.getTarget() != Side.SERVER) {
return;
}
//constant details all packets share: ID, player, and remaining data
packetID = bbis.readByte();
NetHandlerPlayServer srv = (NetHandlerPlayServer) event.packet.handler();
EntityPlayerMP player = srv.playerEntity;
byte[] remaining = new byte[bbis.available()];
bbis.readFully(remaining);
switch(packetID) {
case AMPacketIDs.SPELL_SHAPE_GROUP_CHANGE:
handleCastingModeChange(remaining, (EntityPlayerMP) player);
break;
case AMPacketIDs.MAGIC_LEVEL_UP:
handleMagicLevelUp(remaining, (EntityPlayerMP) player);
break;
case AMPacketIDs.SYNC_BETA_PARTICLES:
handleSyncBetaParticles(remaining, (EntityPlayerMP) player);
break;
case AMPacketIDs.POSSIBLE_CLIENT_EXPROP_DESYNC:
handlePossibleClientExpropDesync(remaining);
break;
case AMPacketIDs.REQUEST_BETA_PARTICLES:
handleRequestBetaParticles(remaining, (EntityPlayerMP) player);
break;
case AMPacketIDs.SPELL_CUSTOMIZE:
handleSpellCustomize(remaining, (EntityPlayerMP) player);
break;
case AMPacketIDs.SPELLBOOK_CHANGE_ACTIVE_SLOT:
handleSpellBookChangeActiveSlot(remaining, (EntityPlayerMP) player);
break;
case AMPacketIDs.SYNC_SPELL_KNOWLEDGE:
handleSyncSpellKnowledge(remaining, (EntityPlayerMP) player);
break;
case AMPacketIDs.DECO_BLOCK_UPDATE:
handleDecoBlockUpdate(remaining, (EntityPlayerMP) player);
break;
case AMPacketIDs.INSCRIPTION_TABLE_UPDATE:
handleInscriptionTableUpdate(remaining, (EntityPlayerMP) player);
break;
case AMPacketIDs.TK_DISTANCE_SYNC:
ExtendedProperties.For((EntityPlayerMP) player).TK_Distance = new AMDataReader(remaining).getFloat();
break;
case AMPacketIDs.SAVE_KEYSTONE_COMBO:
handleSaveKeystoneCombo(remaining, (EntityPlayerMP) player);
break;
case AMPacketIDs.SET_KEYSTONE_COMBO:
handleSetKeystoneCombo(remaining, (EntityPlayerMP) player);
break;
case AMPacketIDs.SET_MAG_WORK_REC:
handleSetMagiciansWorkbenchRecipe(remaining, (EntityPlayerMP) player);
break;
case AMPacketIDs.RUNE_BAG_GUI_OPEN:
handleRuneBagGUIOpen(remaining, (EntityPlayerMP) player);
break;
case AMPacketIDs.M_BENCH_LOCK_RECIPE:
handleMBenchLockRecipe(remaining, (EntityPlayerMP) player);
break;
case AMPacketIDs.IMBUE_ARMOR:
handleImbueArmor(remaining, (EntityPlayerMP) player);
break;
case AMPacketIDs.REQUEST_PWR_PATHS:
handlePowerPathSync(remaining, (EntityPlayerMP) player);
break;
case AMPacketIDs.SYNC_EXTENDED_PROPS:
handleExpropOperation(remaining, (EntityPlayerMP) player);
break;
case AMPacketIDs.AFFINITY_ACTIVATE:
handleAffinityActivate(remaining, player);
break;
}
} catch (Throwable t) {
LogHelper.error("Server Packet Failed to Handle!");
LogHelper.error("Packet Type: " + packetID);
t.printStackTrace();
} finally {
try {
if (bbis != null)
bbis.close();
} catch (Throwable t) {
t.printStackTrace();
}
}
}
Aggregations