cn.nukkit.network.protocol.BlockEventPacket Java Examples
The following examples show how to use
cn.nukkit.network.protocol.BlockEventPacket.
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: DispenserInventory.java From Jupiter with GNU General Public License v3.0 | 6 votes |
@Override public void onOpen(Player who) { super.onOpen(who); if (this.getViewers().size() == 1) { BlockEventPacket pk = new BlockEventPacket(); pk.x = (int) this.getHolder().getX(); pk.y = (int) this.getHolder().getY(); pk.z = (int) this.getHolder().getZ(); pk.case1 = 1; pk.case2 = 2; Level level = this.getHolder().getLevel(); if (level != null) { level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, pk); } } }
Example #2
Source File: ShulkerBoxInventory.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public void onClose(Player who) { if (this.getViewers().size() == 1) { BlockEventPacket pk = new BlockEventPacket(); pk.x = (int) this.getHolder().getX(); pk.y = (int) this.getHolder().getY(); pk.z = (int) this.getHolder().getZ(); pk.case1 = 1; pk.case2 = 0; Level level = this.getHolder().getLevel(); if (level != null) { level.addLevelSoundEvent(this.getHolder().add(0.5, 0.5, 0.5), LevelSoundEventPacket.SOUND_SHULKERBOX_CLOSED); level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, pk); } } super.onClose(who); }
Example #3
Source File: ShulkerBoxInventory.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public void onOpen(Player who) { super.onOpen(who); if (this.getViewers().size() == 1) { BlockEventPacket pk = new BlockEventPacket(); pk.x = (int) this.getHolder().getX(); pk.y = (int) this.getHolder().getY(); pk.z = (int) this.getHolder().getZ(); pk.case1 = 1; pk.case2 = 2; Level level = this.getHolder().getLevel(); if (level != null) { level.addLevelSoundEvent(this.getHolder().add(0.5, 0.5, 0.5), LevelSoundEventPacket.SOUND_SHULKERBOX_OPEN); level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, pk); } } }
Example #4
Source File: ChestInventory.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public void onOpen(Player who) { super.onOpen(who); if (this.getViewers().size() == 1) { BlockEventPacket pk = new BlockEventPacket(); pk.x = (int) this.getHolder().getX(); pk.y = (int) this.getHolder().getY(); pk.z = (int) this.getHolder().getZ(); pk.case1 = 1; pk.case2 = 2; Level level = this.getHolder().getLevel(); if (level != null) { level.addLevelSoundEvent(this.getHolder().add(0.5, 0.5, 0.5), LevelSoundEventPacket.SOUND_CHEST_OPEN); level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, pk); } } }
Example #5
Source File: ChestInventory.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public void onOpen(Player who) { super.onOpen(who); if (this.getViewers().size() == 1) { BlockEventPacket pk = new BlockEventPacket(); pk.x = (int) this.getHolder().getX(); pk.y = (int) this.getHolder().getY(); pk.z = (int) this.getHolder().getZ(); pk.case1 = 1; pk.case2 = 2; Level level = this.getHolder().getLevel(); if (level != null) { level.addSound(this.getHolder().add(0.5, 0.5, 0.5), Sound.RANDOM_CHESTOPEN); level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, pk); } } }
Example #6
Source File: ChestInventory.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public void onClose(Player who) { if (this.getViewers().size() == 1) { BlockEventPacket pk = new BlockEventPacket(); pk.x = (int) this.getHolder().getX(); pk.y = (int) this.getHolder().getY(); pk.z = (int) this.getHolder().getZ(); pk.case1 = 1; pk.case2 = 0; Level level = this.getHolder().getLevel(); if (level != null) { level.addSound(this.getHolder().add(0.5, 0.5, 0.5), Sound.RANDOM_CHESTCLOSED); level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, pk); } } super.onClose(who); }
Example #7
Source File: DropperInventory.java From Jupiter with GNU General Public License v3.0 | 6 votes |
@Override public void onClose(Player who) { if (this.getViewers().size() == 1) { BlockEventPacket pk = new BlockEventPacket(); pk.x = (int) this.getHolder().getX(); pk.y = (int) this.getHolder().getY(); pk.z = (int) this.getHolder().getZ(); pk.case1 = 1; pk.case2 = 0; Level level = this.getHolder().getLevel(); if (level != null) { level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, pk); } } super.onClose(who); }
Example #8
Source File: DropperInventory.java From Jupiter with GNU General Public License v3.0 | 6 votes |
@Override public void onOpen(Player who) { super.onOpen(who); if (this.getViewers().size() == 1) { BlockEventPacket pk = new BlockEventPacket(); pk.x = (int) this.getHolder().getX(); pk.y = (int) this.getHolder().getY(); pk.z = (int) this.getHolder().getZ(); pk.case1 = 1; pk.case2 = 2; Level level = this.getHolder().getLevel(); if (level != null) { level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, pk); } } }
Example #9
Source File: DispenserInventory.java From Jupiter with GNU General Public License v3.0 | 6 votes |
@Override public void onClose(Player who) { if (this.getViewers().size() == 1) { BlockEventPacket pk = new BlockEventPacket(); pk.x = (int) this.getHolder().getX(); pk.y = (int) this.getHolder().getY(); pk.z = (int) this.getHolder().getZ(); pk.case1 = 1; pk.case2 = 0; Level level = this.getHolder().getLevel(); if (level != null) { level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, pk); } } super.onClose(who); }
Example #10
Source File: ChestInventory.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public void onClose(Player who) { if (this.getViewers().size() == 1) { BlockEventPacket pk = new BlockEventPacket(); pk.x = (int) this.getHolder().getX(); pk.y = (int) this.getHolder().getY(); pk.z = (int) this.getHolder().getZ(); pk.case1 = 1; pk.case2 = 0; Level level = this.getHolder().getLevel(); if (level != null) { level.addLevelSoundEvent(this.getHolder().add(0.5, 0.5, 0.5), LevelSoundEventPacket.SOUND_CHEST_CLOSED); level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, pk); } } super.onClose(who); }
Example #11
Source File: ChestInventory.java From Jupiter with GNU General Public License v3.0 | 6 votes |
@Override public void onClose(Player who) { if (this.getViewers().size() == 1) { BlockEventPacket pk = new BlockEventPacket(); pk.x = (int) this.getHolder().getX(); pk.y = (int) this.getHolder().getY(); pk.z = (int) this.getHolder().getZ(); pk.case1 = 1; pk.case2 = 0; Level level = this.getHolder().getLevel(); if (level != null) { level.addLevelSoundEvent(LevelSoundEventPacket.SOUND_CHEST_CLOSED, 1, -1, this.getHolder().add(0.5, 0.5, 0.5)); level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, pk); } } super.onClose(who); }
Example #12
Source File: ChestInventory.java From Jupiter with GNU General Public License v3.0 | 6 votes |
@Override public void onOpen(Player who) { super.onOpen(who); if (this.getViewers().size() == 1) { BlockEventPacket pk = new BlockEventPacket(); pk.x = (int) this.getHolder().getX(); pk.y = (int) this.getHolder().getY(); pk.z = (int) this.getHolder().getZ(); pk.case1 = 1; pk.case2 = 2; Level level = this.getHolder().getLevel(); if (level != null) { level.addLevelSoundEvent(LevelSoundEventPacket.SOUND_CHEST_OPEN, 1, -1, this.getHolder().add(0.5, 0.5, 0.5)); level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, pk); } } }
Example #13
Source File: ShulkerBoxInventory.java From Jupiter with GNU General Public License v3.0 | 6 votes |
@Override public void onClose(Player who) { if (this.getViewers().size() == 1) { BlockEventPacket pk = new BlockEventPacket(); pk.x = (int) this.getHolder().getX(); pk.y = (int) this.getHolder().getY(); pk.z = (int) this.getHolder().getZ(); pk.case1 = 1; pk.case2 = 0; Level level = this.getHolder().getLevel(); if (level != null) { level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, pk); } } super.onClose(who); }
Example #14
Source File: ShulkerBoxInventory.java From Jupiter with GNU General Public License v3.0 | 6 votes |
@Override public void onOpen(Player who) { super.onOpen(who); if (this.getViewers().size() == 1) { BlockEventPacket pk = new BlockEventPacket(); pk.x = (int) this.getHolder().getX(); pk.y = (int) this.getHolder().getY(); pk.z = (int) this.getHolder().getZ(); pk.case1 = 1; pk.case2 = 2; Level level = this.getHolder().getLevel(); if (level != null) { level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, pk); } } }
Example #15
Source File: PlayerEnderChestInventory.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void onOpen(Player who) { if (who != this.getHolder()) { return; } super.onOpen(who); ContainerOpenPacket containerOpenPacket = new ContainerOpenPacket(); containerOpenPacket.windowId = who.getWindowId(this); containerOpenPacket.type = this.getType().getNetworkType(); BlockEnderChest chest = who.getViewingEnderChest(); if (chest != null) { containerOpenPacket.x = (int) chest.getX(); containerOpenPacket.y = (int) chest.getY(); containerOpenPacket.z = (int) chest.getZ(); } else { containerOpenPacket.x = containerOpenPacket.y = containerOpenPacket.z = 0; } who.dataPacket(containerOpenPacket); this.sendContents(who); if (chest != null && chest.getViewers().size() == 1) { BlockEventPacket blockEventPacket = new BlockEventPacket(); blockEventPacket.x = (int) chest.getX(); blockEventPacket.y = (int) chest.getY(); blockEventPacket.z = (int) chest.getZ(); blockEventPacket.case1 = 1; blockEventPacket.case2 = 2; Level level = this.getHolder().getLevel(); if (level != null) { level.addLevelSoundEvent(this.getHolder().add(0.5, 0.5, 0.5), LevelSoundEventPacket.SOUND_ENDERCHEST_OPEN); level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, blockEventPacket); } } }
Example #16
Source File: PlayerEnderChestInventory.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void onClose(Player who) { ContainerClosePacket containerClosePacket = new ContainerClosePacket(); containerClosePacket.windowId = who.getWindowId(this); who.dataPacket(containerClosePacket); super.onClose(who); BlockEnderChest chest = who.getViewingEnderChest(); if (chest != null && chest.getViewers().size() == 1) { BlockEventPacket blockEventPacket = new BlockEventPacket(); blockEventPacket.x = (int) chest.getX(); blockEventPacket.y = (int) chest.getY(); blockEventPacket.z = (int) chest.getZ(); blockEventPacket.case1 = 1; blockEventPacket.case2 = 0; Level level = this.getHolder().getLevel(); if (level != null) { level.addLevelSoundEvent(this.getHolder().add(0.5, 0.5, 0.5), LevelSoundEventPacket.SOUND_ENDERCHEST_CLOSED); level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, blockEventPacket); } who.setViewingEnderChest(null); } super.onClose(who); }
Example #17
Source File: PlayerEnderChestInventory.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void onClose(Player who) { ContainerClosePacket containerClosePacket = new ContainerClosePacket(); containerClosePacket.windowId = who.getWindowId(this); who.dataPacket(containerClosePacket); super.onClose(who); BlockEnderChest chest = who.getViewingEnderChest(); if (chest != null && chest.getViewers().size() == 1) { BlockEventPacket blockEventPacket = new BlockEventPacket(); blockEventPacket.x = (int) chest.getX(); blockEventPacket.y = (int) chest.getY(); blockEventPacket.z = (int) chest.getZ(); blockEventPacket.case1 = 1; blockEventPacket.case2 = 0; Level level = this.getHolder().getLevel(); if (level != null) { level.addSound(this.getHolder().add(0.5, 0.5, 0.5), Sound.RANDOM_CHESTCLOSED); level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, blockEventPacket); } who.setViewingEnderChest(null); } super.onClose(who); }
Example #18
Source File: BlockNoteblock.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public void emitSound() { Instrument instrument = getInstrument(); BlockEventPacket pk = new BlockEventPacket(); pk.x = (int) this.x; pk.y = (int) this.y; pk.z = (int) this.z; pk.case1 = instrument.ordinal(); pk.case2 = this.getStrength(); this.getLevel().addChunkPacket((int) this.x >> 4, (int) this.z >> 4, pk); this.getLevel().addSound(this, instrument.getSound(), 1, this.getStrength()); //TODO: correct pitch }
Example #19
Source File: DoubleChestInventory.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void onOpen(Player who) { super.onOpen(who); this.left.viewers.add(who); this.right.viewers.add(who); if (this.getViewers().size() == 1) { BlockEventPacket pk1 = new BlockEventPacket(); pk1.x = (int) this.left.getHolder().getX(); pk1.y = (int) this.left.getHolder().getY(); pk1.z = (int) this.left.getHolder().getZ(); pk1.case1 = 1; pk1.case2 = 2; Level level = this.left.getHolder().getLevel(); if (level != null) { level.addSound(this.left.getHolder().add(0.5, 0.5, 0.5), Sound.RANDOM_CHESTOPEN); level.addChunkPacket((int) this.left.getHolder().getX() >> 4, (int) this.left.getHolder().getZ() >> 4, pk1); } BlockEventPacket pk2 = new BlockEventPacket(); pk2.x = (int) this.right.getHolder().getX(); pk2.y = (int) this.right.getHolder().getY(); pk2.z = (int) this.right.getHolder().getZ(); pk2.case1 = 1; pk2.case2 = 2; level = this.right.getHolder().getLevel(); if (level != null) { level.addSound(this.right.getHolder().add(0.5, 0.5, 0.5), Sound.RANDOM_CHESTOPEN); level.addChunkPacket((int) this.right.getHolder().getX() >> 4, (int) this.right.getHolder().getZ() >> 4, pk2); } } }
Example #20
Source File: DoubleChestInventory.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void onClose(Player who) { if (this.getViewers().size() == 1) { BlockEventPacket pk1 = new BlockEventPacket(); pk1.x = (int) this.right.getHolder().getX(); pk1.y = (int) this.right.getHolder().getY(); pk1.z = (int) this.right.getHolder().getZ(); pk1.case1 = 1; pk1.case2 = 0; Level level = this.right.getHolder().getLevel(); if (level != null) { level.addSound(this.right.getHolder().add(0.5, 0.5, 0.5), Sound.RANDOM_CHESTCLOSED); level.addChunkPacket((int) this.right.getHolder().getX() >> 4, (int) this.right.getHolder().getZ() >> 4, pk1); } BlockEventPacket pk2 = new BlockEventPacket(); pk2.x = (int) this.left.getHolder().getX(); pk2.y = (int) this.left.getHolder().getY(); pk2.z = (int) this.left.getHolder().getZ(); pk2.case1 = 1; pk2.case2 = 0; level = this.left.getHolder().getLevel(); if (level != null) { level.addSound(this.left.getHolder().add(0.5, 0.5, 0.5), Sound.RANDOM_CHESTCLOSED); level.addChunkPacket((int) this.left.getHolder().getX() >> 4, (int) this.left.getHolder().getZ() >> 4, pk2); } } this.left.viewers.remove(who); this.right.viewers.remove(who); super.onClose(who); }
Example #21
Source File: PlayerEnderChestInventory.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void onOpen(Player who) { if (who != this.getHolder()) { return; } super.onOpen(who); ContainerOpenPacket containerOpenPacket = new ContainerOpenPacket(); containerOpenPacket.windowId = who.getWindowId(this); containerOpenPacket.type = this.getType().getNetworkType(); BlockEnderChest chest = who.getViewingEnderChest(); if (chest != null) { containerOpenPacket.x = (int) chest.getX(); containerOpenPacket.y = (int) chest.getY(); containerOpenPacket.z = (int) chest.getZ(); } else { containerOpenPacket.x = containerOpenPacket.y = containerOpenPacket.z = 0; } who.dataPacket(containerOpenPacket); this.sendContents(who); if (chest != null && chest.getViewers().size() == 1) { BlockEventPacket blockEventPacket = new BlockEventPacket(); blockEventPacket.x = (int) chest.getX(); blockEventPacket.y = (int) chest.getY(); blockEventPacket.z = (int) chest.getZ(); blockEventPacket.case1 = 1; blockEventPacket.case2 = 2; Level level = this.getHolder().getLevel(); if (level != null) { level.addSound(this.getHolder().add(0.5, 0.5, 0.5), Sound.RANDOM_CHESTOPEN); level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, blockEventPacket); } } }
Example #22
Source File: DoubleChestInventory.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void onClose(Player who) { if (this.getViewers().size() == 1) { BlockEventPacket pk1 = new BlockEventPacket(); pk1.x = (int) this.right.getHolder().getX(); pk1.y = (int) this.right.getHolder().getY(); pk1.z = (int) this.right.getHolder().getZ(); pk1.case1 = 1; pk1.case2 = 0; Level level = this.right.getHolder().getLevel(); if (level != null) { level.addLevelSoundEvent(this.right.getHolder().add(0.5, 0.5, 0.5), LevelSoundEventPacket.SOUND_CHEST_CLOSED); level.addChunkPacket((int) this.right.getHolder().getX() >> 4, (int) this.right.getHolder().getZ() >> 4, pk1); } BlockEventPacket pk2 = new BlockEventPacket(); pk2.x = (int) this.left.getHolder().getX(); pk2.y = (int) this.left.getHolder().getY(); pk2.z = (int) this.left.getHolder().getZ(); pk2.case1 = 1; pk2.case2 = 0; level = this.left.getHolder().getLevel(); if (level != null) { level.addLevelSoundEvent(this.left.getHolder().add(0.5, 0.5, 0.5), LevelSoundEventPacket.SOUND_CHEST_CLOSED); level.addChunkPacket((int) this.left.getHolder().getX() >> 4, (int) this.left.getHolder().getZ() >> 4, pk2); } } this.left.viewers.remove(who); this.right.viewers.remove(who); super.onClose(who); }
Example #23
Source File: DoubleChestInventory.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void onOpen(Player who) { super.onOpen(who); this.left.viewers.add(who); this.right.viewers.add(who); if (this.getViewers().size() == 1) { BlockEventPacket pk1 = new BlockEventPacket(); pk1.x = (int) this.left.getHolder().getX(); pk1.y = (int) this.left.getHolder().getY(); pk1.z = (int) this.left.getHolder().getZ(); pk1.case1 = 1; pk1.case2 = 2; Level level = this.left.getHolder().getLevel(); if (level != null) { level.addLevelSoundEvent(this.left.getHolder().add(0.5, 0.5, 0.5), LevelSoundEventPacket.SOUND_CHEST_OPEN); level.addChunkPacket((int) this.left.getHolder().getX() >> 4, (int) this.left.getHolder().getZ() >> 4, pk1); } BlockEventPacket pk2 = new BlockEventPacket(); pk2.x = (int) this.right.getHolder().getX(); pk2.y = (int) this.right.getHolder().getY(); pk2.z = (int) this.right.getHolder().getZ(); pk2.case1 = 1; pk2.case2 = 2; level = this.right.getHolder().getLevel(); if (level != null) { level.addLevelSoundEvent(this.right.getHolder().add(0.5, 0.5, 0.5), LevelSoundEventPacket.SOUND_CHEST_OPEN); level.addChunkPacket((int) this.right.getHolder().getX() >> 4, (int) this.right.getHolder().getZ() >> 4, pk2); } } }
Example #24
Source File: BlockNoteblock.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public void emitSound() { if (this.up().getId() != AIR) return; Instrument instrument = this.getInstrument(); this.level.addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_NOTE, instrument.ordinal() << 8 | this.getStrength()); BlockEventPacket pk = new BlockEventPacket(); pk.x = this.getFloorX(); pk.y = this.getFloorY(); pk.z = this.getFloorZ(); pk.case1 = instrument.ordinal(); pk.case2 = this.getStrength(); this.getLevel().addChunkPacket(this.getFloorX() >> 4, this.getFloorZ() >> 4, pk); }
Example #25
Source File: PlayerEnderChestInventory.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public void onClose(Player who) { ContainerClosePacket containerClosePacket = new ContainerClosePacket(); containerClosePacket.windowId = who.getWindowId(this); who.dataPacket(containerClosePacket); super.onClose(who); BlockEnderChest chest = who.getViewingEnderChest(); if (chest != null && chest.getViewers().size() == 1) { BlockEventPacket blockEventPacket = new BlockEventPacket(); blockEventPacket.x = (int) chest.getX(); blockEventPacket.y = (int) chest.getY(); blockEventPacket.z = (int) chest.getZ(); blockEventPacket.case1 = 1; blockEventPacket.case2 = 0; Level level = this.getHolder().getLevel(); if (level != null) { level.addLevelSoundEvent(LevelSoundEventPacket.SOUND_CHEST_CLOSED, 1, -1, this.getHolder().add(0.5, 0.5, 0.5)); level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, blockEventPacket); } who.setViewingEnderChest(null); } super.onClose(who); }
Example #26
Source File: PlayerEnderChestInventory.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public void onOpen(Player who) { if (who != this.getHolder()) { return; } super.onOpen(who); ContainerOpenPacket containerOpenPacket = new ContainerOpenPacket(); containerOpenPacket.windowId = who.getWindowId(this); containerOpenPacket.type = this.getType().getNetworkType(); BlockEnderChest chest = who.getViewingEnderChest(); if (chest != null) { containerOpenPacket.x = (int) chest.getX(); containerOpenPacket.y = (int) chest.getY(); containerOpenPacket.z = (int) chest.getZ(); } else { containerOpenPacket.x = containerOpenPacket.y = containerOpenPacket.z = 0; } who.dataPacket(containerOpenPacket); this.sendContents(who); if (chest != null && chest.getViewers().size() == 1) { BlockEventPacket blockEventPacket = new BlockEventPacket(); blockEventPacket.x = (int) chest.getX(); blockEventPacket.y = (int) chest.getY(); blockEventPacket.z = (int) chest.getZ(); blockEventPacket.case1 = 1; blockEventPacket.case2 = 2; Level level = this.getHolder().getLevel(); if (level != null) { level.addLevelSoundEvent(LevelSoundEventPacket.SOUND_CHEST_OPEN, 1, -1, this.getHolder().add(0.5, 0.5, 0.5)); level.addChunkPacket((int) this.getHolder().getX() >> 4, (int) this.getHolder().getZ() >> 4, blockEventPacket); } } }
Example #27
Source File: DoubleChestInventory.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public void onClose(Player who) { if (this.getViewers().size() == 1) { BlockEventPacket pk1 = new BlockEventPacket(); pk1.x = (int) this.right.getHolder().getX(); pk1.y = (int) this.right.getHolder().getY(); pk1.z = (int) this.right.getHolder().getZ(); pk1.case1 = 1; pk1.case2 = 0; Level level = this.right.getHolder().getLevel(); if (level != null) { level.addLevelSoundEvent(LevelSoundEventPacket.SOUND_CHEST_CLOSED, 1, -1, this.right.getHolder().add(0.5, 0.5, 0.5)); level.addChunkPacket((int) this.right.getHolder().getX() >> 4, (int) this.right.getHolder().getZ() >> 4, pk1); } BlockEventPacket pk2 = new BlockEventPacket(); pk2.x = (int) this.left.getHolder().getX(); pk2.y = (int) this.left.getHolder().getY(); pk2.z = (int) this.left.getHolder().getZ(); pk2.case1 = 1; pk2.case2 = 0; level = this.left.getHolder().getLevel(); if (level != null) { level.addLevelSoundEvent(LevelSoundEventPacket.SOUND_CHEST_CLOSED, 1, -1, this.left.getHolder().add(0.5, 0.5, 0.5)); level.addChunkPacket((int) this.left.getHolder().getX() >> 4, (int) this.left.getHolder().getZ() >> 4, pk2); } } this.left.viewers.remove(who); this.right.viewers.remove(who); super.onClose(who); }
Example #28
Source File: DoubleChestInventory.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public void onOpen(Player who) { super.onOpen(who); this.left.viewers.add(who); this.right.viewers.add(who); if (this.getViewers().size() == 1) { BlockEventPacket pk1 = new BlockEventPacket(); pk1.x = (int) this.left.getHolder().getX(); pk1.y = (int) this.left.getHolder().getY(); pk1.z = (int) this.left.getHolder().getZ(); pk1.case1 = 1; pk1.case2 = 2; Level level = this.left.getHolder().getLevel(); if (level != null) { level.addLevelSoundEvent(LevelSoundEventPacket.SOUND_CHEST_OPEN, 1, -1, this.left.getHolder().add(0.5, 0.5, 0.5)); level.addChunkPacket((int) this.left.getHolder().getX() >> 4, (int) this.left.getHolder().getZ() >> 4, pk1); } BlockEventPacket pk2 = new BlockEventPacket(); pk2.x = (int) this.right.getHolder().getX(); pk2.y = (int) this.right.getHolder().getY(); pk2.z = (int) this.right.getHolder().getZ(); pk2.case1 = 1; pk2.case2 = 2; level = this.right.getHolder().getLevel(); if (level != null) { level.addLevelSoundEvent(LevelSoundEventPacket.SOUND_CHEST_OPEN, 1, -1, this.right.getHolder().add(0.5, 0.5, 0.5)); level.addChunkPacket((int) this.right.getHolder().getX() >> 4, (int) this.right.getHolder().getZ() >> 4, pk2); } } }
Example #29
Source File: BlockNoteblock.java From Jupiter with GNU General Public License v3.0 | 5 votes |
public void emitSound() { BlockEventPacket pk = new BlockEventPacket(); pk.x = (int) this.x; pk.y = (int) this.y; pk.z = (int) this.z; pk.case1 = this.getInstrument(); pk.case2 = this.getStrength(); this.getLevel().addChunkPacket((int) this.x >> 4, (int) this.z >> 4, pk); this.getLevel().addSound(new NoteBoxSound(this, this.getInstrument(), this.getStrength())); }
Example #30
Source File: Network.java From Jupiter with GNU General Public License v3.0 | 4 votes |
private void registerPackets() { this.packetPool = new Class[256]; this.registerPacket(ProtocolInfo.ADD_BEHAVIOR_TREE_PACKET, AddBehaviorTreePacket.class);//new this.registerPacket(ProtocolInfo.ADD_ENTITY_PACKET, AddEntityPacket.class); this.registerPacket(ProtocolInfo.ADD_ITEM_ENTITY_PACKET, AddItemEntityPacket.class); this.registerPacket(ProtocolInfo.ADD_PAINTING_PACKET, AddPaintingPacket.class); this.registerPacket(ProtocolInfo.ADD_PLAYER_PACKET, AddPlayerPacket.class); this.registerPacket(ProtocolInfo.ADVENTURE_SETTINGS_PACKET, AdventureSettingsPacket.class); this.registerPacket(ProtocolInfo.ANIMATE_PACKET, AnimatePacket.class); this.registerPacket(ProtocolInfo.AVAILABLE_COMMANDS_PACKET, AvailableCommandsPacket.class); this.registerPacket(ProtocolInfo.BATCH_PACKET, BatchPacket.class); this.registerPacket(ProtocolInfo.BLOCK_ENTITY_DATA_PACKET, BlockEntityDataPacket.class); this.registerPacket(ProtocolInfo.BLOCK_EVENT_PACKET, BlockEventPacket.class); this.registerPacket(ProtocolInfo.BLOCK_PICK_REQUEST_PACKET, BlockPickRequestPacket.class); this.registerPacket(ProtocolInfo.BOOK_EDIT_PACKET, BookEditPacket.class);//new this.registerPacket(ProtocolInfo.BOSS_EVENT_PACKET, BossEventPacket.class); this.registerPacket(ProtocolInfo.CAMERA_PACKET, CameraPacket.class);//new this.registerPacket(ProtocolInfo.CHANGE_DIMENSION_PACKET, ChangeDimensionPacket.class); this.registerPacket(ProtocolInfo.CHUNK_RADIUS_UPDATED_PACKET, ChunkRadiusUpdatedPacket.class); this.registerPacket(ProtocolInfo.CLIENTBOUND_MAP_ITEM_DATA_PACKET, ClientboundMapItemDataPacket.class); this.registerPacket(ProtocolInfo.COMMAND_BLOCK_UPDATE_PACKET, CommandBlockUpdatePacket.class);//new this.registerPacket(ProtocolInfo.COMMAND_REQUEST_PACKET, CommandRequestPacket.class); this.registerPacket(ProtocolInfo.CONTAINER_CLOSE_PACKET, ContainerClosePacket.class); this.registerPacket(ProtocolInfo.CONTAINER_OPEN_PACKET, ContainerOpenPacket.class); this.registerPacket(ProtocolInfo.CONTAINER_SET_DATA_PACKET, ContainerSetDataPacket.class); this.registerPacket(ProtocolInfo.CRAFTING_DATA_PACKET, CraftingDataPacket.class); this.registerPacket(ProtocolInfo.CRAFTING_EVENT_PACKET, CraftingEventPacket.class); this.registerPacket(ProtocolInfo.DISCONNECT_PACKET, DisconnectPacket.class); this.registerPacket(ProtocolInfo.ENTITY_EVENT_PACKET, EntityEventPacket.class); this.registerPacket(ProtocolInfo.ENTITY_FALL_PACKET, EntityFallPacket.class); this.registerPacket(ProtocolInfo.EXPLODE_PACKET, ExplodePacket.class); this.registerPacket(ProtocolInfo.FULL_CHUNK_DATA_PACKET, FullChunkDataPacket.class); this.registerPacket(ProtocolInfo.GAME_RULES_CHANGED_PACKET, GameRulesChangedPacket.class); this.registerPacket(ProtocolInfo.GUI_DATA_PICK_ITEM_PACKET, GUIDataPickItemPacket.class);//new this.registerPacket(ProtocolInfo.HURT_ARMOR_PACKET, HurtArmorPacket.class); this.registerPacket(ProtocolInfo.INTERACT_PACKET, InteractPacket.class); this.registerPacket(ProtocolInfo.INVENTORY_CONTENT_PACKET, InventoryContentPacket.class); this.registerPacket(ProtocolInfo.INVENTORY_SLOT_PACKET, InventorySlotPacket.class); this.registerPacket(ProtocolInfo.INVENTORY_TRANSACTION_PACKET, InventoryTransactionPacket.class); this.registerPacket(ProtocolInfo.ITEM_FRAME_DROP_ITEM_PACKET, ItemFrameDropItemPacket.class); this.registerPacket(ProtocolInfo.LEVEL_EVENT_PACKET, LevelEventPacket.class); this.registerPacket(ProtocolInfo.LEVEL_SOUND_EVENT_PACKET, LevelSoundEventPacket.class); this.registerPacket(ProtocolInfo.LOGIN_PACKET, LoginPacket.class); this.registerPacket(ProtocolInfo.MAP_INFO_REQUEST_PACKET, MapInfoRequestPacket.class); this.registerPacket(ProtocolInfo.MOB_ARMOR_EQUIPMENT_PACKET, MobArmorEquipmentPacket.class); this.registerPacket(ProtocolInfo.MOB_EQUIPMENT_PACKET, MobEquipmentPacket.class); this.registerPacket(ProtocolInfo.MODAL_FORM_REQUEST_PACKET, ModalFormRequestPacket.class);//new this.registerPacket(ProtocolInfo.MODAL_FORM_RESPONSE_PACKET, ModalFormResponsePacket.class);//new this.registerPacket(ProtocolInfo.MOVE_ENTITY_PACKET, MoveEntityPacket.class); this.registerPacket(ProtocolInfo.MOVE_PLAYER_PACKET, MovePlayerPacket.class); this.registerPacket(ProtocolInfo.NPC_REQUEST_PACKET, NPCRequestPacket.class);//new this.registerPacket(ProtocolInfo.PLAYER_ACTION_PACKET, PlayerActionPacket.class); this.registerPacket(ProtocolInfo.PLAYER_HOTBAR_PACKET, PlayerListPacket.class); this.registerPacket(ProtocolInfo.PLAYER_INPUT_PACKET, PlayerInputPacket.class); this.registerPacket(ProtocolInfo.PLAYER_LIST_PACKET, PlayerListPacket.class); this.registerPacket(ProtocolInfo.PLAYER_SKIN_PACKET, PlayerSkinPacket.class);//new this.registerPacket(ProtocolInfo.PLAY_SOUND_PACKET, PlaySoundPacket.class); this.registerPacket(ProtocolInfo.PLAY_STATUS_PACKET, PlayStatusPacket.class); this.registerPacket(ProtocolInfo.REMOVE_ENTITY_PACKET, RemoveEntityPacket.class); this.registerPacket(ProtocolInfo.REQUEST_CHUNK_RADIUS_PACKET, RequestChunkRadiusPacket.class); this.registerPacket(ProtocolInfo.RESOURCE_PACK_CHUNK_DATA_PACKET, ResourcePackChunkDataPacket.class); this.registerPacket(ProtocolInfo.RESOURCE_PACK_CHUNK_REQUEST_PACKET, ResourcePackChunkRequestPacket.class); this.registerPacket(ProtocolInfo.RESOURCE_PACK_CLIENT_RESPONSE_PACKET, ResourcePackClientResponsePacket.class); this.registerPacket(ProtocolInfo.RESOURCE_PACK_DATA_INFO_PACKET, ResourcePackDataInfoPacket.class); this.registerPacket(ProtocolInfo.RESOURCE_PACKS_INFO_PACKET, ResourcePacksInfoPacket.class); this.registerPacket(ProtocolInfo.RESOURCE_PACK_STACK_PACKET, ResourcePackStackPacket.class); this.registerPacket(ProtocolInfo.RESPAWN_PACKET, RespawnPacket.class); this.registerPacket(ProtocolInfo.RIDER_JUMP_PACKET, RiderJumpPacket.class); this.registerPacket(ProtocolInfo.SERVER_SETTINGS_REQUEST_PACKET, ServerSettingsRequestPacket.class);//new this.registerPacket(ProtocolInfo.SERVER_SETTINGS_RESPONSE_PACKET, ServerSettingsResponsePacket.class);//new this.registerPacket(ProtocolInfo.SERVER_TO_CLIENT_HANDSHAKE_PACKET, ServerToClientHandshakePacket.class);//new this.registerPacket(ProtocolInfo.SET_COMMANDS_ENABLED_PACKET, SetCommandsEnabledPacket.class); this.registerPacket(ProtocolInfo.SET_DEFAULT_GAME_TYPE_PACKET, SetDefaultGameTypePacket.class); this.registerPacket(ProtocolInfo.SET_DIFFICULTY_PACKET, SetDifficultyPacket.class); this.registerPacket(ProtocolInfo.SET_ENTITY_DATA_PACKET, SetEntityDataPacket.class); this.registerPacket(ProtocolInfo.SET_ENTITY_LINK_PACKET, SetEntityLinkPacket.class); this.registerPacket(ProtocolInfo.SET_ENTITY_MOTION_PACKET, SetEntityMotionPacket.class); this.registerPacket(ProtocolInfo.SET_HEALTH_PACKET, SetHealthPacket.class); this.registerPacket(ProtocolInfo.SET_PLAYER_GAME_TYPE_PACKET, SetPlayerGameTypePacket.class); this.registerPacket(ProtocolInfo.SET_SPAWN_POSITION_PACKET, SetSpawnPositionPacket.class); this.registerPacket(ProtocolInfo.SET_TITLE_PACKET, SetTitlePacket.class); this.registerPacket(ProtocolInfo.SET_TIME_PACKET, SetTimePacket.class); this.registerPacket(ProtocolInfo.SHOW_CREDITS_PACKET, ShowCreditsPacket.class); this.registerPacket(ProtocolInfo.SHOW_PROFILE_PACKET, ShowProfilePacket.class); this.registerPacket(ProtocolInfo.SPAWN_EXPERIENCE_ORB_PACKET, SpawnExperienceOrbPacket.class); this.registerPacket(ProtocolInfo.START_GAME_PACKET, StartGamePacket.class); this.registerPacket(ProtocolInfo.STOP_SOUND_PACKET, StopSoundPacket.class);//new this.registerPacket(ProtocolInfo.STRUCTURE_BLOCK_UPDATE_PACKET, StructureBlockUpdatePacket.class);//new this.registerPacket(ProtocolInfo.SUB_CLIENT_LOGIN_PACKET, SubClientLoginPacket.class);//new this.registerPacket(ProtocolInfo.TAKE_ITEM_ENTITY_PACKET, TakeItemEntityPacket.class); this.registerPacket(ProtocolInfo.TELEMETRY_EVENT_PACKET, TelemetryEventPacket.class);//new this.registerPacket(ProtocolInfo.TEXT_PACKET, TextPacket.class); this.registerPacket(ProtocolInfo.TRANSFER_PACKET, TransferPacket.class);//new this.registerPacket(ProtocolInfo.UPDATE_ATTRIBUTES_PACKET, UpdateAttributesPacket.class);//new this.registerPacket(ProtocolInfo.UPDATE_BLOCK_PACKET, UpdateBlockPacket.class); this.registerPacket(ProtocolInfo.UPDATE_EQUIPMENT_PACKET, UpdateEquipmentPacket.class);//new this.registerPacket(ProtocolInfo.UPDATE_TRADE_PACKET, UpdateTradePacket.class); }