cn.nukkit.network.protocol.LevelEventPacket Java Examples
The following examples show how to use
cn.nukkit.network.protocol.LevelEventPacket.
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: BlockDragonEgg.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public void teleport() { for (int i = 0; i < 1000; ++i) { Block t = this.getLevel().getBlock(this.add(ThreadLocalRandom.current().nextInt(-16, 16), ThreadLocalRandom.current().nextInt(-16, 16), ThreadLocalRandom.current().nextInt(-16, 16))); if (t.getId() == AIR) { int diffX = this.getFloorX() - t.getFloorX(); int diffY = this.getFloorY() - t.getFloorY(); int diffZ = this.getFloorZ() - t.getFloorZ(); LevelEventPacket pk = new LevelEventPacket(); pk.evid = LevelEventPacket.EVENT_PARTICLE_DRAGON_EGG_TELEPORT; pk.data = (((((Math.abs(diffX) << 16) | (Math.abs(diffY) << 8)) | Math.abs(diffZ)) | ((diffX < 0 ? 1 : 0) << 24)) | ((diffY < 0 ? 1 : 0) << 25)) | ((diffZ < 0 ? 1 : 0) << 26); pk.x = this.getFloorX(); pk.y = this.getFloorY(); pk.z = this.getFloorZ(); this.getLevel().addChunkPacket(this.getFloorX() >> 4, this.getFloorZ() >> 4, pk); this.getLevel().setBlock(this, get(AIR), true); this.getLevel().setBlock(t, this, true); return; } } }
Example #2
Source File: Level.java From Jupiter with GNU General Public License v3.0 | 6 votes |
public boolean setRaining(boolean raining) { WeatherChangeEvent ev = new WeatherChangeEvent(this, raining); this.getServer().getPluginManager().callEvent(ev); if (ev.isCancelled()) { return false; } this.raining = raining; LevelEventPacket pk = new LevelEventPacket(); // These numbers are from Minecraft if (raining) { pk.evid = LevelEventPacket.EVENT_START_RAIN; pk.data = rand.nextInt(50000) + 10000; setRainTime(rand.nextInt(12000) + 12000); } else { pk.evid = LevelEventPacket.EVENT_STOP_RAIN; setRainTime(rand.nextInt(168000) + 12000); } Server.broadcastPacket(this.getPlayers().values(), pk); return true; }
Example #3
Source File: Level.java From Jupiter with GNU General Public License v3.0 | 6 votes |
public void sendWeather(Player[] players) { if (players == null) { players = this.getPlayers().values().stream().toArray(Player[]::new); } LevelEventPacket pk = new LevelEventPacket(); if (this.isRaining()) { pk.evid = LevelEventPacket.EVENT_START_RAIN; pk.data = rand.nextInt(50000) + 10000; } else { pk.evid = LevelEventPacket.EVENT_STOP_RAIN; } Server.broadcastPacket(players, pk); if (this.isThundering()) { pk.evid = LevelEventPacket.EVENT_START_THUNDER; pk.data = rand.nextInt(50000) + 10000; } else { pk.evid = LevelEventPacket.EVENT_STOP_THUNDER; } Server.broadcastPacket(players, pk); }
Example #4
Source File: DestroyBlockParticle.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public DataPacket[] encode() { LevelEventPacket pk = new LevelEventPacket(); pk.evid = LevelEventPacket.EVENT_PARTICLE_DESTROY; pk.x = (float) this.x; pk.y = (float) this.y; pk.z = (float) this.z; pk.data = this.data; return new DataPacket[]{pk}; }
Example #5
Source File: BoneMealParticle.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public DataPacket[] encode() { LevelEventPacket pk = new LevelEventPacket(); pk.evid = LevelEventPacket.EVENT_PARTICLE_BONEMEAL; pk.x = (float) this.x; pk.y = (float) this.y; pk.z = (float) this.z; pk.data = 0; return new DataPacket[]{pk}; }
Example #6
Source File: GenericParticle.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public DataPacket[] encode() { LevelEventPacket pk = new LevelEventPacket(); pk.evid = (short) (LevelEventPacket.EVENT_ADD_PARTICLE_MASK | this.id); pk.x = (float) this.x; pk.y = (float) this.y; pk.z = (float) this.z; pk.data = this.data; return new DataPacket[]{pk}; }
Example #7
Source File: DestroyBlockParticle.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public DataPacket[] encode() { LevelEventPacket pk = new LevelEventPacket(); pk.evid = LevelEventPacket.EVENT_PARTICLE_DESTROY; pk.x = (float) this.x; pk.y = (float) this.y; pk.z = (float) this.z; pk.data = this.data; return new DataPacket[]{pk}; }
Example #8
Source File: MobSpawnParticle.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public DataPacket[] encode() { LevelEventPacket packet = new LevelEventPacket(); packet.evid = LevelEventPacket.EVENT_PARTICLE_SPAWN; packet.x = (float) this.x; packet.y = (float) this.y; packet.z = (float) this.z; packet.data = (this.width & 0xff) + ((this.height & 0xff) << 8); return new DataPacket[]{packet}; }
Example #9
Source File: PunchBlockParticle.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public DataPacket[] encode() { LevelEventPacket pk = new LevelEventPacket(); pk.evid = LevelEventPacket.EVENT_PARTICLE_PUNCH_BLOCK; pk.x = (float) this.x; pk.y = (float) this.y; pk.z = (float) this.z; pk.data = this.data; return new DataPacket[]{pk}; }
Example #10
Source File: SpellParticle.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public DataPacket[] encode() { LevelEventPacket pk = new LevelEventPacket(); pk.evid = LevelEventPacket.EVENT_PARTICLE_SPLASH; pk.x = (float) this.x; pk.y = (float) this.y; pk.z = (float) this.z; pk.data = this.data; return new DataPacket[]{pk}; }
Example #11
Source File: Level.java From Jupiter with GNU General Public License v3.0 | 5 votes |
public void sendBlockExtraData(int x, int y, int z, int id, int data, Player[] players) { LevelEventPacket pk = new LevelEventPacket(); pk.evid = LevelEventPacket.EVENT_SET_DATA; pk.x = x + 0.5f; pk.y = y + 0.5f; pk.z = z + 0.5f; pk.data = (data << 8) | id; Server.broadcastPacket(players, pk); }
Example #12
Source File: Level.java From Jupiter with GNU General Public License v3.0 | 5 votes |
public void sendBlockExtraData(int x, int y, int z, int id, int data, Collection<Player> players) { LevelEventPacket pk = new LevelEventPacket(); pk.evid = LevelEventPacket.EVENT_SET_DATA; pk.x = x + 0.5f; pk.y = y + 0.5f; pk.z = z + 0.5f; pk.data = (data << 8) | id; Server.broadcastPacket(players, pk); }
Example #13
Source File: Level.java From Jupiter with GNU General Public License v3.0 | 5 votes |
public boolean setThundering(boolean thundering) { ThunderChangeEvent ev = new ThunderChangeEvent(this, thundering); this.getServer().getPluginManager().callEvent(ev); if (ev.isCancelled()) { return false; } if (thundering && !isRaining()) { setRaining(true); } this.thundering = thundering; LevelEventPacket pk = new LevelEventPacket(); // These numbers are from Minecraft if (thundering) { pk.evid = LevelEventPacket.EVENT_START_THUNDER; pk.data = rand.nextInt(50000) + 10000; setThunderTime(rand.nextInt(12000) + 3600); } else { pk.evid = LevelEventPacket.EVENT_STOP_THUNDER; setThunderTime(rand.nextInt(168000) + 12000); } Server.broadcastPacket(this.getPlayers().values(), pk); return true; }
Example #14
Source File: BoneMealParticle.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public DataPacket[] encode() { LevelEventPacket pk = new LevelEventPacket(); pk.evid = LevelEventPacket.EVENT_PARTICLE_BONEMEAL; pk.x = (float) this.x; pk.y = (float) this.y; pk.z = (float) this.z; pk.data = 0; return new DataPacket[]{pk}; }
Example #15
Source File: GenericParticle.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public DataPacket[] encode() { LevelEventPacket pk = new LevelEventPacket(); pk.evid = (short) (LevelEventPacket.EVENT_ADD_PARTICLE_MASK | this.id); pk.x = (float) this.x; pk.y = (float) this.y; pk.z = (float) this.z; pk.data = this.data; return new DataPacket[]{pk}; }
Example #16
Source File: MobSpawnParticle.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public DataPacket[] encode() { LevelEventPacket packet = new LevelEventPacket(); packet.evid = LevelEventPacket.EVENT_PARTICLE_SPAWN; packet.x = (float) this.x; packet.y = (float) this.y; packet.z = (float) this.z; packet.data = (this.width & 0xff) + ((this.height & 0xff) << 8); return new DataPacket[]{packet}; }
Example #17
Source File: PunchBlockParticle.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public DataPacket[] encode() { LevelEventPacket pk = new LevelEventPacket(); pk.evid = LevelEventPacket.EVENT_PARTICLE_PUNCH_BLOCK; pk.x = (float) this.x; pk.y = (float) this.y; pk.z = (float) this.z; pk.data = this.data; return new DataPacket[]{pk}; }
Example #18
Source File: SpellParticle.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public DataPacket[] encode() { LevelEventPacket pk = new LevelEventPacket(); pk.evid = LevelEventPacket.EVENT_PARTICLE_SPLASH; pk.x = (float) this.x; pk.y = (float) this.y; pk.z = (float) this.z; pk.data = this.data; return new DataPacket[]{pk}; }
Example #19
Source File: BlockSponge.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) { Level level = block.getLevel(); boolean blockSet = level.setBlock(block, this); if (blockSet) { if (this.getDamage() == WET && level.getDimension() == Level.DIMENSION_NETHER) { level.setBlock(block, Block.get(BlockID.SPONGE, DRY)); this.getLevel().addSound(block.getLocation(), Sound.RANDOM_FIZZ); for (int i = 0; i < 8; ++i) { this.getLevel().addParticle( //TODO: Use correct smoke particle new SmokeParticle(block.getLocation().add(Math.random(), 1, Math.random()))); } } else if (this.getDamage() == DRY && performWaterAbsorb(block)) { level.setBlock(block, Block.get(BlockID.SPONGE, WET)); for (int i = 0; i < 4; i++) { LevelEventPacket packet = new LevelEventPacket(); packet.evid = 2001; packet.x = (float) block.getX(); packet.y = (float) block.getY(); packet.z = (float) block.getZ(); packet.data = GlobalBlockPalette.getOrCreateRuntimeId(BlockID.WATER, 0); level.addChunkPacket(getChunkX(), getChunkZ(), packet); } } } return blockSet; }
Example #20
Source File: BoneMealParticle.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public DataPacket[] encode() { LevelEventPacket pk = new LevelEventPacket(); pk.evid = LevelEventPacket.EVENT_PARTICLE_BONEMEAL; pk.x = (float) this.x; pk.y = (float) this.y; pk.z = (float) this.z; pk.data = 0; return new DataPacket[]{pk}; }
Example #21
Source File: GenericParticle.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public DataPacket[] encode() { LevelEventPacket pk = new LevelEventPacket(); pk.evid = (short) (LevelEventPacket.EVENT_ADD_PARTICLE_MASK | this.id); pk.x = (float) this.x; pk.y = (float) this.y; pk.z = (float) this.z; pk.data = this.data; return new DataPacket[]{pk}; }
Example #22
Source File: DestroyBlockParticle.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public DataPacket[] encode() { LevelEventPacket pk = new LevelEventPacket(); pk.evid = LevelEventPacket.EVENT_PARTICLE_DESTROY; pk.x = (float) this.x; pk.y = (float) this.y; pk.z = (float) this.z; pk.data = this.data; return new DataPacket[]{pk}; }
Example #23
Source File: LevelEventSound.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public DataPacket[] encode() { LevelEventPacket pk = new LevelEventPacket(); pk.evid = this.id; pk.x = (float) this.x; pk.y = (float) this.y; pk.z = (float) this.z; pk.data = (int) this.pitch; return new DataPacket[]{pk}; }
Example #24
Source File: MobSpawnParticle.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public DataPacket[] encode() { LevelEventPacket packet = new LevelEventPacket(); packet.evid = LevelEventPacket.EVENT_PARTICLE_SPAWN; packet.x = (float) this.x; packet.y = (float) this.y; packet.z = (float) this.z; packet.data = (this.width & 0xff) + ((this.height & 0xff) << 8); return new DataPacket[]{packet}; }
Example #25
Source File: PunchBlockParticle.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public DataPacket[] encode() { LevelEventPacket pk = new LevelEventPacket(); pk.evid = LevelEventPacket.EVENT_PARTICLE_PUNCH_BLOCK; pk.x = (float) this.x; pk.y = (float) this.y; pk.z = (float) this.z; pk.data = this.data; return new DataPacket[]{pk}; }
Example #26
Source File: SpellParticle.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public DataPacket[] encode() { LevelEventPacket pk = new LevelEventPacket(); pk.evid = LevelEventPacket.EVENT_PARTICLE_SPLASH; pk.x = (float) this.x; pk.y = (float) this.y; pk.z = (float) this.z; pk.data = this.data; return new DataPacket[]{pk}; }
Example #27
Source File: AnvilUseSound.java From Jupiter with GNU General Public License v3.0 | 4 votes |
public AnvilUseSound(Vector3 pos, float pitch) { super(pos, LevelEventPacket.EVENT_SOUND_ANVIL_USE, pitch); }
Example #28
Source File: AnvilFallSound.java From Jupiter with GNU General Public License v3.0 | 4 votes |
public AnvilFallSound(Vector3 pos, float pitch) { super(pos, LevelEventPacket.EVENT_SOUND_ANVIL_FALL, pitch); }
Example #29
Source File: DoorCrashSound.java From Jupiter with GNU General Public License v3.0 | 4 votes |
public DoorCrashSound(Vector3 pos, float pitch) { super(pos, LevelEventPacket.EVENT_SOUND_DOOR_CRASH, pitch); }
Example #30
Source File: DoorBumpSound.java From Jupiter with GNU General Public License v3.0 | 4 votes |
public DoorBumpSound(Vector3 pos, float pitch) { super(pos, LevelEventPacket.EVENT_SOUND_DOOR_BUMP, pitch); }