cn.nukkit.entity.weather.EntityLightning Java Examples
The following examples show how to use
cn.nukkit.entity.weather.EntityLightning.
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: EssentialsAPI.java From EssentialsNK with GNU General Public License v3.0 | 6 votes |
public void strikeLighting(Position pos) { FullChunk chunk = pos.getLevel().getChunk((int) pos.getX() >> 4, (int) pos.getZ() >> 4); CompoundTag nbt = new CompoundTag() .putList(new ListTag<DoubleTag>("Pos") .add(new DoubleTag("", pos.getX())) .add(new DoubleTag("", pos.getY())) .add(new DoubleTag("", pos.getZ()))) .putList(new ListTag<DoubleTag>("Motion") .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)) .add(new DoubleTag("", 0))) .putList(new ListTag<FloatTag>("Rotation") .add(new FloatTag("", 0)) .add(new FloatTag("", 0))); EntityLightning lightning = new EntityLightning(chunk, nbt); lightning.spawnToAll(); }
Example #2
Source File: Level.java From Nukkit with GNU General Public License v3.0 | 5 votes |
private void performThunder(long index, FullChunk chunk) { if (areNeighboringChunksLoaded(index)) return; if (ThreadLocalRandom.current().nextInt(10000) == 0) { int LCG = this.getUpdateLCG() >> 2; int chunkX = chunk.getX() * 16; int chunkZ = chunk.getZ() * 16; Vector3 vector = this.adjustPosToNearbyEntity(new Vector3(chunkX + (LCG & 0xf), 0, chunkZ + (LCG >> 8 & 0xf))); Biome biome = Biome.getBiome(this.getBiomeId(vector.getFloorX(), vector.getFloorZ())); if (!biome.canRain()) { return; } int bId = this.getBlockIdAt(vector.getFloorX(), vector.getFloorY(), vector.getFloorZ()); if (bId != Block.TALL_GRASS && bId != Block.WATER) vector.y += 1; CompoundTag nbt = new CompoundTag() .putList(new ListTag<DoubleTag>("Pos").add(new DoubleTag("", vector.x)) .add(new DoubleTag("", vector.y)).add(new DoubleTag("", vector.z))) .putList(new ListTag<DoubleTag>("Motion").add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)).add(new DoubleTag("", 0))) .putList(new ListTag<FloatTag>("Rotation").add(new FloatTag("", 0)) .add(new FloatTag("", 0))); EntityLightning bolt = (EntityLightning) Entity.createEntity("Lightning", chunk, nbt); if(bolt == null) return; LightningStrikeEvent ev = new LightningStrikeEvent(this, bolt); getServer().getPluginManager().callEvent(ev); if (!ev.isCancelled()) { bolt.spawnToAll(); } else { bolt.setEffect(false); } this.addLevelSoundEvent(vector, LevelSoundEventPacket.SOUND_THUNDER, -1, EntityLightning.NETWORK_ID); this.addLevelSoundEvent(vector, LevelSoundEventPacket.SOUND_EXPLODE, -1, EntityLightning.NETWORK_ID); } }
Example #3
Source File: Level.java From Nukkit with GNU General Public License v3.0 | 5 votes |
private void performThunder(long index, FullChunk chunk) { if (areNeighboringChunksLoaded(index)) return; if (ThreadLocalRandom.current().nextInt(10000) == 0) { this.updateLCG = this.updateLCG * 3 + 1013904223; int LCG = this.updateLCG >> 2; int chunkX = chunk.getX() * 16; int chunkZ = chunk.getZ() * 16; Vector3 vector = this.adjustPosToNearbyEntity(new Vector3(chunkX + (LCG & 15), 0, chunkZ + (LCG >> 8 & 15))); int bId = this.getBlockIdAt(vector.getFloorX(), vector.getFloorY(), vector.getFloorZ()); if (bId != Block.TALL_GRASS && bId != Block.WATER) vector.y += 1; CompoundTag nbt = new CompoundTag() .putList(new ListTag<DoubleTag>("Pos").add(new DoubleTag("", vector.x)) .add(new DoubleTag("", vector.y)).add(new DoubleTag("", vector.z))) .putList(new ListTag<DoubleTag>("Motion").add(new DoubleTag("", 0)) .add(new DoubleTag("", 0)).add(new DoubleTag("", 0))) .putList(new ListTag<FloatTag>("Rotation").add(new FloatTag("", 0)) .add(new FloatTag("", 0))); EntityLightning bolt = new EntityLightning(chunk, nbt); LightningStrikeEvent ev = new LightningStrikeEvent(this, bolt); getServer().getPluginManager().callEvent(ev); if (!ev.isCancelled()) { bolt.spawnToAll(); } else { bolt.setEffect(false); } this.addLevelSoundEvent(vector, LevelSoundEventPacket.SOUND_THUNDER, 93, -1, false); this.addLevelSoundEvent(vector, LevelSoundEventPacket.SOUND_EXPLODE, 93, -1, false); } }
Example #4
Source File: Server.java From Jupiter with GNU General Public License v3.0 | 4 votes |
private void registerEntities() { //mob Entity.registerEntity("Blaze", EntityBlaze.class); Entity.registerEntity("CaveSpider", EntityCaveSpider.class); Entity.registerEntity("Creeper", EntityCreeper.class); Entity.registerEntity("Enderman", EntityEnderman.class); Entity.registerEntity("Endermite", EntityEndermite.class); Entity.registerEntity("Evoker", EntityEvoker.class); Entity.registerEntity("Ghast", EntityGhast.class); Entity.registerEntity("Guardian", EntityGuardian.class); Entity.registerEntity("Hask", EntityHask.class); Entity.registerEntity("MagmaCube", EntityMagmaCube.class); Entity.registerEntity("Shulker", EntityShulker.class); Entity.registerEntity("Silverfish", EntitySilverfish.class); Entity.registerEntity("Skeleton", EntitySkeleton.class); Entity.registerEntity("Slime", EntitySlime.class); Entity.registerEntity("Spider", EntitySpider.class); Entity.registerEntity("Stray", EntityStray.class); Entity.registerEntity("Vex", EntityVex.class); Entity.registerEntity("Vindicator", EntityVindicator.class); Entity.registerEntity("Witch", EntityWitch.class); Entity.registerEntity("WitherSkeleton", EntityWitherSkeleton.class); Entity.registerEntity("Zombie", EntityZombie.class); Entity.registerEntity("ZombiePigman", EntityZombiePigman.class); Entity.registerEntity("ZombieVillager", EntityZombieVillager.class); //passive Entity.registerEntity("Bat", EntityBat.class); Entity.registerEntity("Chicken", EntityChicken.class); Entity.registerEntity("Cow", EntityCow.class); Entity.registerEntity("Donkey", EntityDonkey.class); Entity.registerEntity("Horse", EntityHorse.class); Entity.registerEntity("IronGolem", EntityIronGolem.class); Entity.registerEntity("Llama", EntityLlama.class); Entity.registerEntity("Mooshroom", EntityMooshroom.class); Entity.registerEntity("Mule", EntityMule.class); Entity.registerEntity("Ocelot", EntityOcelot.class); Entity.registerEntity("Parrot", EntityParrot.class); Entity.registerEntity("Pig", EntityPig.class); Entity.registerEntity("PolarBear", EntityPolarBear.class); Entity.registerEntity("Rabbit", EntityRabbit.class); Entity.registerEntity("Sheep", EntitySheep.class); Entity.registerEntity("SkeletonHorse", EntitySkeletonHorse.class); Entity.registerEntity("SnowGolem", EntitySnowGolem.class); Entity.registerEntity("Squid", EntitySquid.class); Entity.registerEntity("Villager", EntityVillager.class); Entity.registerEntity("Wolf", EntityWolf.class); Entity.registerEntity("ZombieHorse", EntityZombieHorse.class); //Bosses Entity.registerEntity("ElderGuardian", EntityElderGuardian.class); Entity.registerEntity("EnderDragon", EntityEnderDragon.class); Entity.registerEntity("EnderWither", EntityWither.class); //item Entity.registerEntity("ArmorStand", EntityArmorStand.class); Entity.registerEntity("EnderCrystal", EntityEnderCrystal.class); Entity.registerEntity("FallingSand", EntityFallingBlock.class); Entity.registerEntity("PrimedTnt", EntityPrimedTNT.class); Entity.registerEntity("Painting", EntityPainting.class); Entity.registerEntity("XpOrb", EntityXPOrb.class); Entity.registerEntity("MinecartRideable", EntityMinecartEmpty.class); Entity.registerEntity("MinecartChest", EntityMinecartChest.class); Entity.registerEntity("MinecartHopper", EntityMinecartHopper.class); Entity.registerEntity("MinecartTnt", EntityMinecartTNT.class); Entity.registerEntity("Boat", EntityBoat.class); //projectile Entity.registerEntity("Arrow", EntityArrow.class); Entity.registerEntity("DragonFireball", EntityDragonFireball.class); Entity.registerEntity("Egg", EntityEgg.class); Entity.registerEntity("EnderPearl", EntityEnderPearl.class); Entity.registerEntity("ThrownExpBottle", EntityExpBottle.class); Entity.registerEntity("Fireball", EntityFireball.class); Entity.registerEntity("FireworkRocket", EntityFireworkRocket.class); Entity.registerEntity("FishingHook", EntityFishingHook.class); Entity.registerEntity("ThrownPotion", EntityPotion.class); Entity.registerEntity("ThrownLingeringPotion", EntityPotionLingering.class); Entity.registerEntity("ShulkerBullet", EntityShulkerBullet.class); Entity.registerEntity("Snowball", EntitySnowball.class); //weather Entity.registerEntity("Lightning", EntityLightning.class); //other Entity.registerEntity("Human", EntityHuman.class, true); }
Example #5
Source File: Server.java From Nukkit with GNU General Public License v3.0 | 4 votes |
private void registerEntities() { Entity.registerEntity("Lightning", EntityLightning.class); Entity.registerEntity("Arrow", EntityArrow.class); Entity.registerEntity("EnderPearl", EntityEnderPearl.class); Entity.registerEntity("FallingSand", EntityFallingBlock.class); Entity.registerEntity("Firework", EntityFirework.class); Entity.registerEntity("Item", EntityItem.class); Entity.registerEntity("Painting", EntityPainting.class); Entity.registerEntity("PrimedTnt", EntityPrimedTNT.class); Entity.registerEntity("Snowball", EntitySnowball.class); //Monsters Entity.registerEntity("Blaze", EntityBlaze.class); Entity.registerEntity("CaveSpider", EntityCaveSpider.class); Entity.registerEntity("Creeper", EntityCreeper.class); Entity.registerEntity("Drowned", EntityDrowned.class); Entity.registerEntity("ElderGuardian", EntityElderGuardian.class); Entity.registerEntity("EnderDragon", EntityEnderDragon.class); Entity.registerEntity("Enderman", EntityEnderman.class); Entity.registerEntity("Endermite", EntityEndermite.class); Entity.registerEntity("Evoker", EntityEvoker.class); Entity.registerEntity("Ghast", EntityGhast.class); Entity.registerEntity("Guardian", EntityGuardian.class); Entity.registerEntity("Husk", EntityHusk.class); Entity.registerEntity("MagmaCube", EntityMagmaCube.class); Entity.registerEntity("Phantom", EntityPhantom.class); Entity.registerEntity("Pillager", EntityPillager.class); Entity.registerEntity("Ravager", EntityRavager.class); Entity.registerEntity("Shulker", EntityShulker.class); Entity.registerEntity("Silverfish", EntitySilverfish.class); Entity.registerEntity("Skeleton", EntitySkeleton.class); Entity.registerEntity("Slime", EntitySlime.class); Entity.registerEntity("Spider", EntitySpider.class); Entity.registerEntity("Stray", EntityStray.class); Entity.registerEntity("Vex", EntityVex.class); Entity.registerEntity("Vindicator", EntityVindicator.class); Entity.registerEntity("Witch", EntityWitch.class); Entity.registerEntity("Wither", EntityWither.class); Entity.registerEntity("WitherSkeleton", EntityWitherSkeleton.class); Entity.registerEntity("Zombie", EntityZombie.class); Entity.registerEntity("ZombiePigman", EntityZombiePigman.class); Entity.registerEntity("ZombieVillager", EntityZombieVillager.class); Entity.registerEntity("ZombieVillagerV1", EntityZombieVillagerV1.class); //Passive Entity.registerEntity("Bat", EntityBat.class); Entity.registerEntity("Cat", EntityCat.class); Entity.registerEntity("Chicken", EntityChicken.class); Entity.registerEntity("Cod", EntityCod.class); Entity.registerEntity("Cow", EntityCow.class); Entity.registerEntity("Dolphin", EntityDolphin.class); Entity.registerEntity("Donkey", EntityDonkey.class); Entity.registerEntity("Horse", EntityHorse.class); Entity.registerEntity("Llama", EntityLlama.class); Entity.registerEntity("Mooshroom", EntityMooshroom.class); Entity.registerEntity("Mule", EntityMule.class); Entity.registerEntity("Ocelot", EntityOcelot.class); Entity.registerEntity("Panda", EntityPanda.class); Entity.registerEntity("Parrot", EntityParrot.class); Entity.registerEntity("Pig", EntityPig.class); Entity.registerEntity("PolarBear", EntityPolarBear.class); Entity.registerEntity("Pufferfish", EntityPufferfish.class); Entity.registerEntity("Rabbit", EntityRabbit.class); Entity.registerEntity("Salmon", EntitySalmon.class); Entity.registerEntity("Sheep", EntitySheep.class); Entity.registerEntity("SkeletonHorse", EntitySkeletonHorse.class); Entity.registerEntity("Squid", EntitySquid.class); Entity.registerEntity("TropicalFish", EntityTropicalFish.class); Entity.registerEntity("Turtle", EntityTurtle.class); Entity.registerEntity("Villager", EntityVillager.class); Entity.registerEntity("VillagerV1", EntityVillagerV1.class); Entity.registerEntity("WanderingTrader", EntityWanderingTrader.class); Entity.registerEntity("Wolf", EntityWolf.class); Entity.registerEntity("ZombieHorse", EntityZombieHorse.class); //Projectile Entity.registerEntity("Egg", EntityEgg.class); Entity.registerEntity("ThrownExpBottle", EntityExpBottle.class); Entity.registerEntity("ThrownPotion", EntityPotion.class); Entity.registerEntity("ThrownTrident", EntityThrownTrident.class); Entity.registerEntity("XpOrb", EntityXPOrb.class); Entity.registerEntity("Human", EntityHuman.class, true); //Vehicle Entity.registerEntity("Boat", EntityBoat.class); Entity.registerEntity("MinecartChest", EntityMinecartChest.class); Entity.registerEntity("MinecartHopper", EntityMinecartHopper.class); Entity.registerEntity("MinecartRideable", EntityMinecartEmpty.class); Entity.registerEntity("MinecartTnt", EntityMinecartTNT.class); Entity.registerEntity("EndCrystal", EntityEndCrystal.class); Entity.registerEntity("FishingHook", EntityFishingHook.class); }