codechicken.lib.packet.PacketCustom Java Examples
The following examples show how to use
codechicken.lib.packet.PacketCustom.
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: TileTranslocator.java From Translocators with MIT License | 6 votes |
@Override public Packet getDescriptionPacket() { PacketCustom packet = new PacketCustom(TranslocatorSPH.channel, 1); packet.writeCoord(xCoord, yCoord, zCoord); int attachmask = 0; for(int i = 0; i < 6; i++) if(attachments[i] != null) attachmask|= 1<<i; packet.writeByte(attachmask); for(Attachment a : attachments) if(a != null) a.write(packet); return packet.toPacket(); }
Example #2
Source File: EnderStorageClientProxy.java From EnderStorage with MIT License | 6 votes |
@Override public void init() { if(config.getTag("checkUpdates").getBooleanValue(true)) CCUpdateChecker.updateCheck("EnderStorage"); ClientUtils.enhanceSupportersList("EnderStorage"); super.init(); PacketCustom.assignHandler(EnderStorageCPH.channel, new EnderStorageCPH()); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(blockEnderChest), new ItemEnderStorageRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TileEnderChest.class, new EnderChestRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TileEnderTank.class, new EnderTankRenderer()); }
Example #3
Source File: WRAddonSPH.java From WirelessRedstone with MIT License | 6 votes |
public static void sendTrackerUpdatePacketTo(EntityPlayerMP player, EntityWirelessTracker tracker) { PacketCustom packet = new PacketCustom(WirelessRedstoneCore.channel, 60); packet.writeInt(tracker.getEntityId()); packet.writeShort(tracker.freq); packet.writeBoolean(tracker.isAttachedToEntity()); if (tracker.isAttachedToEntity()) { packet.writeInt(tracker.attachedEntity.getEntityId()); packet.writeFloat(tracker.attachedX); packet.writeFloat(tracker.attachedY); packet.writeFloat(tracker.attachedZ); packet.writeFloat(tracker.attachedYaw); } else { packet.writeFloat((float) tracker.posX); packet.writeFloat((float) tracker.posY); packet.writeFloat((float) tracker.posZ); packet.writeFloat((float) tracker.motionX); packet.writeFloat((float) tracker.motionY); packet.writeFloat((float) tracker.motionZ); packet.writeShort(tracker.attachmentCounter); packet.writeBoolean(tracker.item); } packet.sendToPlayer(player); }
Example #4
Source File: ContainerPotionCreator.java From NotEnoughItems with MIT License | 6 votes |
@SuppressWarnings("unchecked") @Override public void handleInputPacket(PacketCustom packet) { ItemStack potion = potionInv.getStackInSlot(0); if (potion == null) return; boolean add = packet.readBoolean(); int effectID = packet.readUByte(); NBTTagList effects = potion.getTagCompound().getTagList("CustomPotionEffects", 10); NBTTagList newEffects = new NBTTagList(); for(int i = 0; i < effects.tagCount(); i++) { NBTTagCompound tag = effects.getCompoundTagAt(i); PotionEffect e = PotionEffect.readCustomPotionEffectFromNBT(tag); if(e.getPotionID() != effectID) newEffects.appendTag(tag); } if(add) newEffects.appendTag(new PotionEffect(effectID, packet.readInt(), packet.readUByte()).writeCustomPotionEffectToNBT(new NBTTagCompound())); potion.getTagCompound().setTag("CustomPotionEffects", newEffects); }
Example #5
Source File: EnderStorageProxy.java From EnderStorage with MIT License | 6 votes |
public void init() { blockEnderChest = new BlockEnderStorage(); blockEnderChest.setBlockName("enderchest"); GameRegistry.registerBlock(blockEnderChest, ItemEnderStorage.class, "enderChest"); MinecraftForge.EVENT_BUS.register(blockEnderChest); itemEnderPouch = new ItemEnderPouch(); itemEnderPouch.setUnlocalizedName("enderpouch"); GameRegistry.registerItem(itemEnderPouch, "enderPouch"); GameRegistry.registerTileEntity(TileEnderChest.class, "Ender Chest"); GameRegistry.registerTileEntity(TileEnderTank.class, "Ender Tank"); PacketCustom.assignHandler(EnderStorageSPH.channel, new EnderStorageSPH()); EnderStorageRecipe.init(); }
Example #6
Source File: ClientPacketHandler.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 6 votes |
@SuppressWarnings ("unchecked") private void handleOpenContainer(PacketCustom packet, Minecraft mc) { ContainerType<?> rawType = packet.readRegistryIdUnsafe(ForgeRegistries.CONTAINERS); int windowId = packet.readVarInt(); ITextComponent name = packet.readTextComponent(); if (rawType instanceof ICCLContainerType<?>) { ICCLContainerType<?> type = (ICCLContainerType<?>) rawType; ScreenManager.getScreenFactory(rawType, mc, windowId, name)// .map(e -> (ScreenManager.IScreenFactory<Container, ?>) e)// .ifPresent(screenFactory -> { Container container = type.create(windowId, Minecraft.getInstance().player.inventory, packet); Screen screen = screenFactory.create(container, mc.player.inventory, name); mc.player.openContainer = ((IHasContainer<?>) screen).getContainer(); mc.displayGuiScreen(screen); }); } }
Example #7
Source File: ProxyClient.java From NotEnoughItems with MIT License | 6 votes |
@Override public void init(FMLInitializationEvent event) { super.init(event); ItemMobSpawner.initRender(); PacketCustom.assignHandler(NEIClientPacketHandler.channel, new NEIClientPacketHandler()); MinecraftForge.EVENT_BUS.register(new ContainerEventHandler()); MinecraftForge.EVENT_BUS.register(ClientHandler.INSTANCE); MinecraftForge.EVENT_BUS.register(WorldOverlayRenderer.INSTANCE); KeyManager.trackers.add(WorldOverlayRenderer.INSTANCE); KeyBindings.register(); NEIClientEventHandler.INSTANCE.init(); }
Example #8
Source File: BlockChunkLoader.java From ChickenChunks with MIT License | 6 votes |
@Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { int meta = world.getBlockMetadata(x, y, z); if (meta != 0 || player.isSneaking()) return false; if (!world.isRemote) { TileChunkLoader tile = (TileChunkLoader) world.getTileEntity(x, y, z); if (tile.owner == null || tile.owner.equals(player.getCommandSenderName()) || ChunkLoaderManager.opInteract() && ServerUtils.isPlayerOP(player.getCommandSenderName())) { PacketCustom packet = new PacketCustom(ChunkLoaderSPH.channel, 12); packet.writeCoord(x, y, z); packet.sendToPlayer(player); } else player.addChatMessage(new ChatComponentTranslation("chickenchunks.accessdenied")); } return true; }
Example #9
Source File: TranslocatorCPH.java From Translocators with MIT License | 6 votes |
@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 #10
Source File: WRCoreProxy.java From WirelessRedstone with MIT License | 6 votes |
public void init() { PacketCustom.assignHandler(channel, new WRCoreSPH()); obsidianStick = createItem("obsidianStick"); stoneBowl = createItem("stoneBowl"); retherPearl = createItem("retherPearl"); wirelessTransceiver = createItem("wirelessTransceiver"); blazeTransceiver = createItem("blazeTransceiver"); recieverDish = createItem("recieverDish"); blazeRecieverDish = createItem("blazeRecieverDish"); ConfigTag coreconfig = SaveManager.config().getTag("core").useBraces().setPosition(10); WirelessBolt.init(coreconfig); damagebolt = new DamageSource("bolt"); addRecipies(); }
Example #11
Source File: NEICPH.java From NotEnoughItems with MIT License | 5 votes |
@Override public void handlePacket(PacketCustom packet, Minecraft mc, INetHandlerPlayClient netHandler) { switch (packet.getType()) { case 1: handleSMPCheck(packet.readUByte(), packet.readString(), mc.theWorld); break; case 10: handleLoginState(packet); break; case 11: handleActionDisabled(packet); break; case 12: handleActionEnabled(packet); break; case 13: ClientHandler.instance().addSMPMagneticItem(packet.readInt(), mc.theWorld); break; case 14: handleGamemode(mc, packet.readUByte()); break; case 21: ClientUtils.openSMPGui(packet.readUByte(), new GuiEnchantmentModifier(mc.thePlayer.inventory, mc.theWorld)); break; case 23: if (packet.readBoolean()) ClientUtils.openSMPGui(packet.readUByte(), new GuiExtendedCreativeInv(new ContainerCreativeInv(mc.thePlayer, new ExtendedCreativeInv(null, Side.CLIENT)))); else mc.displayGuiScreen(new GuiInventory(mc.thePlayer)); break; case 24: ClientUtils.openSMPGui(packet.readUByte(), new GuiPotionCreator(mc.thePlayer.inventory)); break; } }
Example #12
Source File: ContainerPotionCreator.java From NotEnoughItems with MIT License | 5 votes |
public void setPotionEffect(Potion potion, int duration, int amplifier) { PacketCustom packet = NEIClientPacketHandler.createContainerPacket(); packet.writeBoolean(true); packet.writeByte(Potion.getIdFromPotion(potion)); packet.writeInt(duration); packet.writeByte(amplifier); packet.sendToServer(); }
Example #13
Source File: WRCoreSPH.java From WirelessRedstone with MIT License | 5 votes |
public static void sendWirelessBolt(WirelessBolt bolt) { PacketCustom packet = new PacketCustom(WirelessRedstoneCore.channel, 8); packet.writeFloat((float) bolt.start.x); packet.writeFloat((float) bolt.start.y); packet.writeFloat((float) bolt.start.z); packet.writeFloat((float) bolt.end.x); packet.writeFloat((float) bolt.end.y); packet.writeFloat((float) bolt.end.z); packet.writeLong(bolt.seed); packet.sendToChunk(bolt.world, (int) bolt.start.x >> 4, (int) bolt.start.z >> 4); }
Example #14
Source File: TileEnderTank.java From EnderStorage with MIT License | 5 votes |
@Override public void handleDescriptionPacket(PacketCustom desc) { super.handleDescriptionPacket(desc); rotation = desc.readUByte(); liquid_state.s_liquid = desc.readFluidStack(); pressure_state.a_pressure = desc.readBoolean(); if (!described) { liquid_state.c_liquid = liquid_state.s_liquid; pressure_state.b_rotate = pressure_state.a_rotate = pressure_state.approachRotate(); } described = true; }
Example #15
Source File: EnderStorageCPH.java From EnderStorage with MIT License | 5 votes |
private void handleTilePacket(ClientWorld world, PacketCustom packet, BlockPos pos) { TileEntity tile = world.getTileEntity(pos); if (tile instanceof TileFrequencyOwner) { ((TileFrequencyOwner) tile).readFromPacket(packet); } }
Example #16
Source File: TileCraftingGrid.java From Translocators with MIT License | 5 votes |
@Override public void handleDescriptionPacket(PacketCustom packet) { rotation = packet.readUByte(); for (int i = 0; i < 9; i++) items[i] = packet.readItemStack(); updateResult(); }
Example #17
Source File: TankSynchroniser.java From EnderStorage with MIT License | 5 votes |
@Override public void sendSyncPacket() { if(!tracking) return; PacketCustom packet = new PacketCustom(EnderStorageSPH.channel, 4); packet.writeShort(storage.freq); packet.writeString(storage.owner); packet.writeFluidStack(s_liquid); packet.sendToPlayer(player); }
Example #18
Source File: PlayerChunkViewerTracker.java From ChickenChunks with MIT License | 5 votes |
public PlayerChunkViewerTracker(EntityPlayer player, PlayerChunkViewerManager manager) { owner = player; this.manager = manager; PacketCustom packet = new PacketCustom(ChunkLoaderSPH.channel, 1); packet.sendToPlayer(player); for(WorldServer world : DimensionManager.getWorlds()) loadDimension(world); }
Example #19
Source File: NEICPH.java From NotEnoughItems with MIT License | 5 votes |
private void handleActionEnabled(PacketCustom packet) { String name = packet.readString(); if (packet.readBoolean()) NEIClientConfig.enabledActions.add(name); else NEIClientConfig.enabledActions.remove(name); }
Example #20
Source File: TileEnderTank.java From EnderStorage with MIT License | 5 votes |
@Override public boolean rotate() { if (!world.isRemote) { rotation = (rotation + 1) % 4; PacketCustom.sendToChunk(getUpdatePacket(), world, pos.getX() >> 4, pos.getZ() >> 4); } return true; }
Example #21
Source File: NEIServerPacketHandler.java From NotEnoughItems with MIT License | 5 votes |
/** * Sends the current protocol version and world to the client. * Called every time the player changes dimensions. * If successful on the client, it will request a LoginState. * * @param player The player to send the ServerSide check to. */ public static void sendServerSideCheck(EntityPlayerMP player) { LogHelper.debug("Sending ServerSide check to: " + player.getName()); PacketCustom packet = new PacketCustom(channel, 1); packet.writeByte(NEIActions.protocol); packet.writeString(player.world.getWorldInfo().getWorldName()); packet.sendToPlayer(player); }
Example #22
Source File: NEIClientPacketHandler.java From NotEnoughItems with MIT License | 5 votes |
public static void sendOpenPotionWindow() { ItemStack[] potionStore = new ItemStack[9]; ArrayUtils.fillArray(potionStore, ItemStack.EMPTY); InventoryUtils.readItemStacksFromTag(potionStore, NEIClientConfig.global.nbt.getCompoundTag("potionStore").getTagList("items", 10)); PacketCustom packet = new PacketCustom(channel, 24); for (ItemStack stack : potionStore) { packet.writeItemStack(stack); } packet.sendToServer(); }
Example #23
Source File: TileItemTranslocator.java From Translocators with MIT License | 5 votes |
@Override public void read(PacketCustom packet, boolean described) { super.read(packet, described); regulate = packet.readBoolean(); signal = packet.readBoolean(); a_powering = packet.readBoolean(); }
Example #24
Source File: NEIClientPacketHandler.java From NotEnoughItems with MIT License | 5 votes |
/** * Handles the LoginState sent by the server. * Resets and loads from the packet the following things: * Permissible actions. * Disabled actions. * Enabled actions. * Banned items. * * @param packet Packet to handle. */ private void handleLoginState(PacketCustom packet) { NEIClientConfig.permissibleActions.clear(); int num = packet.readUByte(); for (int i = 0; i < num; i++) { NEIClientConfig.permissibleActions.add(packet.readString()); } NEIClientConfig.disabledActions.clear(); num = packet.readUByte(); for (int i = 0; i < num; i++) { NEIClientConfig.disabledActions.add(packet.readString()); } NEIClientConfig.enabledActions.clear(); num = packet.readUByte(); for (int i = 0; i < num; i++) { NEIClientConfig.enabledActions.add(packet.readString()); } NEIClientConfig.bannedItems.clear(); num = packet.readInt(); for (int i = 0; i < num; i++) { NEIClientConfig.bannedItems.add(packet.readItemStack()); } if (NEIClientUtils.getGuiContainer() != null) { LayoutManager.instance().refresh(NEIClientUtils.getGuiContainer()); } }
Example #25
Source File: WRAddonCPH.java From WirelessRedstone with MIT License | 5 votes |
private static void processSnifferFreqUpdate(PacketCustom packet) { GuiScreen currentscreen = Minecraft.getMinecraft().currentScreen; if (currentscreen == null || !(currentscreen instanceof GuiWirelessSniffer)) return; GuiWirelessSniffer sniffergui = ((GuiWirelessSniffer) currentscreen); sniffergui.setEtherFreq(packet.readUShort(), packet.readBoolean()); }
Example #26
Source File: TranslocatorSPH.java From Translocators with MIT License | 5 votes |
@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 #27
Source File: PlayerChunkViewerTracker.java From ChickenChunks with MIT License | 5 votes |
public void updatePlayer(EntityPlayer player) { PacketCustom packet = new PacketCustom(channel, 6); packet.writeString(player.getCommandSenderName()); packet.writeInt(player.dimension); Vector3 pos = Vector3.fromEntity(player); packet.writeFloat((float) pos.x); packet.writeFloat((float) pos.y); packet.writeFloat((float) pos.z); packet.sendToPlayer(owner); }
Example #28
Source File: NEIClientPacketHandler.java From NotEnoughItems with MIT License | 5 votes |
/** * Sets a specific slot on the players inventory to the given item. * * @param slot The slot to change. * @param stack The stack to set the slot to. * @param container if the inventory is a container. */ public static void sendSetSlot(int slot, ItemStack stack, boolean container) { PacketCustom packet = new PacketCustom(channel, 5); packet.writeBoolean(container); packet.writeShort(slot); packet.writeItemStack(stack); packet.sendToServer(); }
Example #29
Source File: TileChunkLoader.java From ChickenChunks with MIT License | 5 votes |
public Packet getDescriptionPacket() { PacketCustom packet = new PacketCustom(ChunkLoaderSPH.channel, 10); packet.writeCoord(xCoord, yCoord, zCoord); packet.writeByte(shape.ordinal()); packet.writeByte(radius); packet.writeBoolean(active); packet.writeBoolean(owner != null); if(owner != null) packet.writeString(owner); return packet.toPacket(); }
Example #30
Source File: TankSynchroniser.java From EnderStorage with MIT License | 5 votes |
@Override public void sendSyncPacket() { if (!tracking) { return; } PacketCustom packet = new PacketCustom(EnderStorageNetwork.NET_CHANNEL, 4); getStorage(false).freq.writeToPacket(packet); //packet.writeString(storage.owner); packet.writeFluidStack(s_liquid); packet.sendToPlayer(player); }