Java Code Examples for codechicken.lib.packet.PacketCustom#getType()

The following examples show how to use codechicken.lib.packet.PacketCustom#getType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TranslocatorCPH.java    From Translocators with MIT License 6 votes vote down vote up
@Override
public void handlePacket(PacketCustom packet, Minecraft mc, INetHandlerPlayClient handler) {
    switch (packet.getType()) {
        case 1:
        case 2:
        case 3:
            TileEntity tile = mc.theWorld.getTileEntity(packet.readInt(), packet.readInt(), packet.readInt());
            if (tile instanceof ICustomPacketTile)
                ((ICustomPacketTile) tile).handleDescriptionPacket(packet);
            break;
        case 4:
            int windowId = packet.readUByte();
            GuiTranslocator gui = new GuiTranslocator(new ContainerItemTranslocator(
                    new InventorySimple(9, packet.readUShort(), packet.readString()), mc.thePlayer.inventory));
            ClientUtils.openSMPGui(windowId, gui);
            break;
        case 5:
            mc.thePlayer.openContainer.putStackInSlot(packet.readUByte(), packet.readItemStack(true));
            break;
    }
}
 
Example 2
Source File: EnderStorageCPH.java    From EnderStorage with MIT License 6 votes vote down vote up
@Override
public void handlePacket(PacketCustom packet, Minecraft mc, IClientPlayNetHandler handler) {
    switch (packet.getType()) {
        case 1:
            handleTilePacket(mc.world, packet, packet.readPos());
            break;
        case 2:
            int windowID = packet.readUByte();
            //                ((EnderItemStorage) EnderStorageManager.instance(true).getStorage(Frequency.readFromPacket(packet), EnderItemStorage.TYPE)).openClientGui(windowID, mc.player.inventory, packet.readString(), packet.readUByte());
            break;
        case 3:
            EnderStorageManager.instance(true).getStorage(Frequency.readFromPacket(packet), EnderItemStorage.TYPE).setClientOpen(packet.readBoolean() ? 1 : 0);
            break;
        case 4:
            TankSynchroniser.syncClient(Frequency.readFromPacket(packet), packet.readFluidStack());
            break;
        case 5:
        case 6:
            handleTankTilePacket(mc.world, packet.readPos(), packet);
            break;
    }
}
 
Example 3
Source File: WRCoreSPH.java    From WirelessRedstone with MIT License 6 votes vote down vote up
private void handlePacket(WorldServer world, EntityPlayerMP player, PacketCustom packet) {
    switch (packet.getType()) {
        case 1:
            setTileFreq(player, world, packet.readCoord(), packet.readShort());
            break;
        case 2:
            setItemFreq(player, packet.readShort(), packet.readShort());
            break;
        case 4:
            handleFreqInfo(packet);
            break;
        case 5:
            decrementSlot(player, packet.readShort());
            break;
        case 9:
            RedstoneEther.get(false).setFreqOwner(packet.readShort(), packet.readString());
            break;
    }
}
 
Example 4
Source File: NEIServerConfig.java    From NotEnoughItems with MIT License 6 votes vote down vote up
public static boolean authenticatePacket(EntityPlayerMP sender, PacketCustom packet) {
    switch (packet.getType()) {
        case 1:
            return canPlayerPerformAction(sender.getName(), "item");
        case 4:
            return canPlayerPerformAction(sender.getName(), "delete");
        case 6:
            return canPlayerPerformAction(sender.getName(), "magnet");
        case 7:
            return canPlayerPerformAction(sender.getName(), "time");
        case 8:
            return canPlayerPerformAction(sender.getName(), "heal");
        case 9:
            return canPlayerPerformAction(sender.getName(), "rain");
        case 14:
        case 23:
            return canPlayerPerformAction(sender.getName(), "creative+");
        case 21:
        case 22:
            return canPlayerPerformAction(sender.getName(), "enchant");
        case 24:
            return canPlayerPerformAction(sender.getName(), "potion");
    }
    return true;
}
 
Example 5
Source File: TileTranslocator.java    From Translocators with MIT License 6 votes vote down vote up
@Override
public void handleDescriptionPacket(PacketCustom packet)
{
    if(packet.getType() == 1)
    {
        int attachmask = packet.readUByte();
        for(int i = 0; i < 6; i++)
        {
            if((attachmask&1<<i) != 0)
            {
                boolean described = attachments[i] != null;
                if(!described)
                    createAttachment(i);
                attachments[i].read(packet, described);
            }
            else
                attachments[i] = null;
        }
        
        worldObj.func_147479_m(xCoord, yCoord, zCoord);
    }
}
 
Example 6
Source File: WRAddonSPH.java    From WirelessRedstone with MIT License 6 votes vote down vote up
private void handlePacket(WorldServer world, EntityPlayerMP player, PacketCustom packet) {
    switch (packet.getType()) {
        case 50:
            if (packet.readBoolean())
                RedstoneEtherAddons.server().addSniffer(player);
            else
                RedstoneEtherAddons.server().remSniffer(player);
            break;
        case 51:
            if (packet.readBoolean())
                RedstoneEtherAddons.server().activateRemote(world, player);
            else
                RedstoneEtherAddons.server().deactivateRemote(world, player);
            break;
        case 52:
            RedstoneEtherAddons.server().setTriangRequired(player, packet.readUShort(), packet.readBoolean());
            break;
        case 58:
            RedstoneEtherAddons.server().clearMapNodes(player);
            break;
    }
}
 
Example 7
Source File: EnderStorageCPH.java    From EnderStorage with MIT License 6 votes vote down vote up
@Override
public void handlePacket(PacketCustom packet, Minecraft mc, INetHandlerPlayClient handler) {
    switch (packet.getType()) {
        case 1:
            handleTilePacket(mc.theWorld, packet, packet.readCoord());
            break;
        case 2:
            int windowID = packet.readUByte();

            ((EnderItemStorage) EnderStorageManager.instance(true).getStorage(packet.readString(), packet.readUShort(), "item"))
                    .openClientGui(windowID, mc.thePlayer.inventory, packet.readString(), packet.readUByte());
            break;
        case 3:
            ((EnderItemStorage) EnderStorageManager.instance(true).getStorage(packet.readString(), packet.readUShort(), "item"))
                    .setClientOpen(packet.readBoolean() ? 1 : 0);
            break;
        case 4:
            TankSynchroniser.syncClient(packet.readUShort(), packet.readString(), packet.readFluidStack());
            break;
        case 5:
        case 6:
            handleTankTilePacket(mc.theWorld, packet.readCoord(), packet);
            break;
    }
}
 
Example 8
Source File: NEIServerConfig.java    From NotEnoughItems with MIT License 6 votes vote down vote up
public static boolean authenticatePacket(EntityPlayerMP sender, PacketCustom packet) {
    switch (packet.getType()) {
        case 1:
            return canPlayerPerformAction(sender.getCommandSenderName(), "item");
        case 4:
            return canPlayerPerformAction(sender.getCommandSenderName(), "delete");
        case 6:
            return canPlayerPerformAction(sender.getCommandSenderName(), "magnet");
        case 7:
            return canPlayerPerformAction(sender.getCommandSenderName(), "time");
        case 8:
            return canPlayerPerformAction(sender.getCommandSenderName(), "heal");
        case 9:
            return canPlayerPerformAction(sender.getCommandSenderName(), "rain");
        case 14:
        case 23:
            return canPlayerPerformAction(sender.getCommandSenderName(), "creative+");
        case 21:
        case 22:
            return canPlayerPerformAction(sender.getCommandSenderName(), "enchant");
        case 24:
            return canPlayerPerformAction(sender.getCommandSenderName(), "potion");
    }
    return true;
}
 
Example 9
Source File: EnderStorageSPH.java    From EnderStorage with MIT License 5 votes vote down vote up
@Override
public void handlePacket(PacketCustom packet, ServerPlayerEntity sender, IServerPlayNetHandler handler) {
    switch (packet.getType()) {
        case 1:
            TankSynchroniser.handleVisiblityPacket(sender, packet);
            break;
    }
}
 
Example 10
Source File: TranslocatorSPH.java    From Translocators with MIT License 5 votes vote down vote up
@Override
public void handlePacket(PacketCustom packet, EntityPlayerMP sender, INetHandlerPlayServer handler) {
    switch (packet.getType()) {
        case 1:
            Translocator.blockCraftingGrid.placeBlock(sender.worldObj, sender, packet.readInt(), packet.readInt(), packet.readInt(), packet.readUByte());
            break;
        case 2:
            TileEntity tile = sender.worldObj.getTileEntity(packet.readInt(), packet.readInt(), packet.readInt());
            if (tile instanceof TileCraftingGrid)
                ((TileCraftingGrid) tile).craft(sender);
            break;
    }
}
 
Example 11
Source File: WRCoreCPH.java    From WirelessRedstone with MIT License 5 votes vote down vote up
private void handlePacket(WorldClient world, EntityPlayer player, PacketCustom packet) {
    switch (packet.getType()) {
        case 1:
            handleFreqInfoList(packet);
            break;
        case 2:
            handleLastFreqInfo(packet.readUShort(), packet.readUByte());
            break;
        case 3:
            RedstoneEther.get(true).setFrequencyRange(player.getCommandSenderName(), packet.readUShort(), packet.readUShort(), packet.readBoolean());
            break;
        case 4:
            handleFreqInfo(packet);
            break;
        case 7:
            RedstoneEther.client().jamEntity(player, packet.readBoolean());
            break;
        case 8:
            WirelessBolt bolt = new WirelessBolt(world,
                    new Vector3(packet.readFloat(), packet.readFloat(), packet.readFloat()),
                    new Vector3(packet.readFloat(), packet.readFloat(), packet.readFloat()),
                    packet.readLong());

            bolt.defaultFractal();
            bolt.finalizeBolt();
            break;
        case 9:
            RedstoneEther.get(true).setFreqOwner(packet.readShort(), packet.readString());
            break;
        case 10:
            handleFreqOwnerList(packet);
            break;
    }
}
 
Example 12
Source File: ChunkLoaderSPH.java    From ChickenChunks with MIT License 5 votes vote down vote up
@Override
public void handlePacket(PacketCustom packet, EntityPlayerMP sender, INetHandlerPlayServer handler) {
    switch(packet.getType())
    {
        case 1:
            PlayerChunkViewerManager.instance().closeViewer(sender.getCommandSenderName());
            break;
        case 2:
            handleChunkLoaderChangePacket(sender.worldObj, packet);
            break;
        
    }
}
 
Example 13
Source File: EnderStorageSPH.java    From EnderStorage with MIT License 5 votes vote down vote up
@Override
public void handlePacket(PacketCustom packet, EntityPlayerMP sender, INetHandlerPlayServer handler) {
    switch (packet.getType()) {
        case 1:
            TankSynchroniser.handleVisiblityPacket(sender, packet);
            break;
    }
}
 
Example 14
Source File: WRAddonCPH.java    From WirelessRedstone with MIT License 5 votes vote down vote up
private void handlePacket(WorldClient world, EntityPlayer player, PacketCustom packet) {
    switch (packet.getType()) {
        case 53:
            processSnifferFreqUpdate(packet);
            break;
        case 54:
            processSnifferEtherCopy(packet);
            break;
        case 55:
            RedstoneEtherAddons.client().setTriangAngle(packet.readUShort(), packet.readFloat());
            break;
        case 56:
            processMapInfo(world, player, packet);
            break;
        case 57:
            processMapUpdate(world, player, packet);
            break;
        case 59:
            if (packet.readBoolean())
                throwREP(packet.readInt(), packet.readInt(), world, player);
            else
                world.removeEntityFromWorld(packet.readInt());
            break;
        case 60:
            processTrackerUpdate(packet, world, player);
            break;
        case 61:
            if (packet.readBoolean())
                throwTracker(world, player, packet.readInt(), packet.readInt(), packet.readUShort());
            else
                world.removeEntityFromWorld(packet.readInt());
            break;
    }
}
 
Example 15
Source File: LoginPacketHandler.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void handleLoginPacket(PacketCustom packet, Minecraft mc, IClientLoginNetHandler handler, NetworkEvent.Context context) {
    switch (packet.getType()) {
        case L_CONFIG_SYNC: {
            ConfigSyncManager.readSyncPacket(packet);
            break;
        }
    }
}
 
Example 16
Source File: TileEnderTank.java    From EnderStorage with MIT License 5 votes vote down vote up
public void sync(PacketCustom packet) {
    if (packet.getType() == 5) {
        liquid_state.sync(packet.readFluidStack());
    } else if (packet.getType() == 6) {
        pressure_state.a_pressure = packet.readBoolean();
    }
}
 
Example 17
Source File: ChunkLoaderCPH.java    From ChickenChunks with MIT License 4 votes vote down vote up
@Override
public void handlePacket(PacketCustom packet, Minecraft mc, INetHandlerPlayClient handler) {
    switch (packet.getType()) {
        case 1:
            PlayerChunkViewer.openViewer((int) mc.thePlayer.posX, (int) mc.thePlayer.posZ, CommonUtils.getDimension(mc.theWorld));
            break;
        case 2:
            PlayerChunkViewer.instance().loadDimension(packet, mc.theWorld);
            break;
        case 3:
            PlayerChunkViewer.instance().unloadDimension(packet.readInt());
            break;
        case 4:
            PlayerChunkViewer.instance().handleChunkChange(
                    packet.readInt(),
                    new ChunkCoordIntPair(packet.readInt(), packet.readInt()),
                    packet.readBoolean());
            break;
        case 5:
            PlayerChunkViewer.instance().handleTicketChange(
                    packet.readInt(),
                    packet.readInt(),
                    new ChunkCoordIntPair(packet.readInt(), packet.readInt()),
                    packet.readBoolean());
            break;
        case 6:
            PlayerChunkViewer.instance().handlePlayerUpdate(
                    packet.readString(), packet.readInt(),
                    new Vector3(packet.readFloat(), packet.readFloat(), packet.readFloat()));
            break;
        case 7:
            PlayerChunkViewer.instance().removePlayer(packet.readString());
            break;
        case 8:
            PlayerChunkViewer.instance().handleNewTicket(packet, mc.theWorld);
            break;
        case 10:
            TileChunkLoader.handleDescriptionPacket(packet, mc.theWorld);
            break;
        case 11:
            TileSpotLoader.handleDescriptionPacket(packet, mc.theWorld);
            break;
        case 12:
            BlockCoord pos = packet.readCoord();
            TileEntity tile = mc.theWorld.getTileEntity(pos.x, pos.y, pos.z);
            if (tile instanceof TileChunkLoader)
                mc.displayGuiScreen(new GuiChunkLoader((TileChunkLoader) tile));
            break;

    }
}
 
Example 18
Source File: NEISPH.java    From NotEnoughItems with MIT License 4 votes vote down vote up
@Override
public void handlePacket(PacketCustom packet, EntityPlayerMP sender, INetHandlerPlayServer netHandler) {
    if (!NEIServerConfig.authenticatePacket(sender, packet))
        return;

    switch (packet.getType()) {
        case 1:
            handleGiveItem(sender, packet);
            break;
        case 4:
            NEIServerUtils.deleteAllItems(sender);
            break;
        case 5:
            setInventorySlot(sender, packet);
            break;
        case 6:
            NEIServerUtils.toggleMagnetMode(sender);
            break;
        case 7:
            NEIServerUtils.setHourForward(sender.worldObj, packet.readUByte(), true);
            break;
        case 8:
            NEIServerUtils.healPlayer(sender);
            break;
        case 9:
            NEIServerUtils.toggleRaining(sender.worldObj, true);
            break;
        case 10:
            sendLoginState(sender);
            break;
        case 11:
            sender.updateCraftingInventory(sender.openContainer, sender.openContainer.getInventory());
            break;
        case 12:
            handlePropertyChange(sender, packet);
            break;
        case 13:
            NEIServerUtils.setGamemode(sender, packet.readUByte());
            break;
        case 14:
            NEIServerUtils.cycleCreativeInv(sender, packet.readInt());
            break;
        case 15:
            handleMobSpawnerID(sender.worldObj, packet.readCoord(), packet.readString());
            break;
        case 20:
            handleContainerPacket(sender, packet);
            break;
        case 21:
            openEnchantmentGui(sender);
            break;
        case 22:
            modifyEnchantment(sender, packet.readUByte(), packet.readUByte(), packet.readBoolean());
            break;
        case 23:
            processCreativeInv(sender, packet.readBoolean());
            break;
        case 24:
            openPotionGui(sender, packet);
            break;
        case 25:
            handleDummySlotSet(sender, packet);
            break;
    }
}
 
Example 19
Source File: TileEnderTank.java    From EnderStorage with MIT License 4 votes vote down vote up
public void sync(PacketCustom packet) {
    if (packet.getType() == 5)
        liquid_state.sync(packet.readFluidStack());
    else if (packet.getType() == 6)
        pressure_state.a_pressure = packet.readBoolean();
}
 
Example 20
Source File: NEIServerPacketHandler.java    From NotEnoughItems with MIT License 4 votes vote down vote up
@Override
public void handlePacket(PacketCustom packet, EntityPlayerMP sender, INetHandlerPlayServer netHandler) {
    if (!NEIServerConfig.authenticatePacket(sender, packet)) {
        return;
    }

    switch (packet.getType()) {
        case 1:
            handleGiveItem(sender, packet);
            break;
        case 4:
            NEIServerUtils.deleteAllItems(sender);
            break;
        case 5:
            setInventorySlot(sender, packet);
            break;
        case 6:
            NEIServerUtils.toggleMagnetMode(sender);
            break;
        case 7:
            NEIServerUtils.setHourForward(sender.world, packet.readUByte(), true);
            break;
        case 8:
            NEIServerUtils.healPlayer(sender);
            break;
        case 9:
            NEIServerUtils.toggleRaining(sender.world, true);
            break;
        case 10:
            sendLoginState(sender);
            break;
        case 11:
            sender.sendAllContents(sender.openContainer, sender.openContainer.getInventory());
            break;
        case 12:
            handleActionDisableStateChange(sender, packet);
            break;
        case 13:
            NEIServerUtils.setGamemode(sender, packet.readUByte());
            break;
        case 14:
            NEIServerUtils.cycleCreativeInv(sender, packet.readInt());
            break;
        case 15:
            handleMobSpawnerID(sender.world, packet.readPos(), packet.readString());
            break;
        case 20:
            handleContainerPacket(sender, packet);
            break;
        case 21:
            openEnchantmentGui(sender);
            break;
        case 22:
            modifyEnchantment(sender, packet.readUByte(), packet.readUByte(), packet.readBoolean());
            break;
        case 23:
            processCreativeInv(sender, packet.readBoolean());
            break;
        case 24:
            openPotionGui(sender, packet);
            break;
        case 25:
            handleDummySlotSet(sender, packet);
            break;
    }
}