├── .circleci └── config.yml ├── .github └── ISSUE_TEMPLATE │ └── new-issue.md ├── .gitignore ├── README.md ├── pom.xml └── src └── main ├── java └── nukkitcoders │ └── mobplugin │ ├── AutoSpawnTask.java │ ├── Config.java │ ├── EventListener.java │ ├── MobPlugin.java │ ├── RouteFinderThreadPool.java │ ├── entities │ ├── BaseEntity.java │ ├── Boss.java │ ├── FlyingEntity.java │ ├── HorseBase.java │ ├── JumpingEntity.java │ ├── SwimmingEntity.java │ ├── Tameable.java │ ├── WalkingEntity.java │ ├── animal │ │ ├── Animal.java │ │ ├── FlyingAnimal.java │ │ ├── JumpingAnimal.java │ │ ├── SwimmingAnimal.java │ │ ├── WalkingAnimal.java │ │ ├── flying │ │ │ ├── Allay.java │ │ │ ├── Bat.java │ │ │ ├── Bee.java │ │ │ └── Parrot.java │ │ ├── jumping │ │ │ ├── Frog.java │ │ │ └── Rabbit.java │ │ ├── swimming │ │ │ ├── Axolotl.java │ │ │ ├── Cod.java │ │ │ ├── Dolphin.java │ │ │ ├── Fish.java │ │ │ ├── GlowSquid.java │ │ │ ├── Pufferfish.java │ │ │ ├── Salmon.java │ │ │ ├── Squid.java │ │ │ ├── Tadpole.java │ │ │ ├── TropicalFish.java │ │ │ └── Turtle.java │ │ └── walking │ │ │ ├── Camel.java │ │ │ ├── Cat.java │ │ │ ├── Chicken.java │ │ │ ├── Cow.java │ │ │ ├── Donkey.java │ │ │ ├── Fox.java │ │ │ ├── Goat.java │ │ │ ├── Horse.java │ │ │ ├── Llama.java │ │ │ ├── Mooshroom.java │ │ │ ├── Mule.java │ │ │ ├── Ocelot.java │ │ │ ├── Panda.java │ │ │ ├── Pig.java │ │ │ ├── PolarBear.java │ │ │ ├── Sheep.java │ │ │ ├── SkeletonHorse.java │ │ │ ├── Strider.java │ │ │ ├── Villager.java │ │ │ ├── VillagerV2.java │ │ │ ├── WanderingTrader.java │ │ │ └── ZombieHorse.java │ ├── autospawn │ │ ├── AbstractEntitySpawner.java │ │ └── IEntitySpawner.java │ ├── block │ │ └── BlockEntitySpawner.java │ ├── monster │ │ ├── FlyingMonster.java │ │ ├── JumpingMonster.java │ │ ├── Monster.java │ │ ├── SwimmingMonster.java │ │ ├── TameableMonster.java │ │ ├── WalkingMonster.java │ │ ├── flying │ │ │ ├── Blaze.java │ │ │ ├── EnderDragon.java │ │ │ ├── Ghast.java │ │ │ ├── Phantom.java │ │ │ ├── Vex.java │ │ │ └── Wither.java │ │ ├── jumping │ │ │ ├── MagmaCube.java │ │ │ └── Slime.java │ │ ├── swimming │ │ │ ├── ElderGuardian.java │ │ │ └── Guardian.java │ │ └── walking │ │ │ ├── CaveSpider.java │ │ │ ├── Creeper.java │ │ │ ├── Drowned.java │ │ │ ├── Enderman.java │ │ │ ├── Endermite.java │ │ │ ├── Evoker.java │ │ │ ├── Hoglin.java │ │ │ ├── Husk.java │ │ │ ├── IronGolem.java │ │ │ ├── Piglin.java │ │ │ ├── PiglinBrute.java │ │ │ ├── Pillager.java │ │ │ ├── Ravager.java │ │ │ ├── Shulker.java │ │ │ ├── Silverfish.java │ │ │ ├── Skeleton.java │ │ │ ├── SnowGolem.java │ │ │ ├── Spider.java │ │ │ ├── Stray.java │ │ │ ├── Vindicator.java │ │ │ ├── Warden.java │ │ │ ├── Witch.java │ │ │ ├── WitherSkeleton.java │ │ │ ├── Wolf.java │ │ │ ├── Zoglin.java │ │ │ ├── Zombie.java │ │ │ ├── ZombiePigman.java │ │ │ ├── ZombieVillager.java │ │ │ └── ZombieVillagerV2.java │ ├── projectile │ │ ├── DespawnableThrownTrident.java │ │ ├── EntityBlazeFireBall.java │ │ ├── EntityBlueWitherSkull.java │ │ ├── EntityEnderCharge.java │ │ ├── EntityGhastFireBall.java │ │ ├── EntityLlamaSpit.java │ │ ├── EntityShulkerBullet.java │ │ └── EntityWitherSkull.java │ └── spawners │ │ ├── BatSpawner.java │ │ ├── BlazeSpawner.java │ │ ├── ChickenSpawner.java │ │ ├── CodSpawner.java │ │ ├── CowSpawner.java │ │ ├── CreeperSpawner.java │ │ ├── DolphinSpawner.java │ │ ├── DonkeySpawner.java │ │ ├── DrownedSpawner.java │ │ ├── EndermanSpawner.java │ │ ├── FoxSpawner.java │ │ ├── GhastSpawner.java │ │ ├── HoglinSpawner.java │ │ ├── HorseSpawner.java │ │ ├── HuskSpawner.java │ │ ├── LlamaSpawner.java │ │ ├── MagmaCubeSpawner.java │ │ ├── MooshroomSpawner.java │ │ ├── OcelotSpawner.java │ │ ├── PandaSpawner.java │ │ ├── ParrotSpawner.java │ │ ├── PigSpawner.java │ │ ├── PiglinSpawner.java │ │ ├── PolarBearSpawner.java │ │ ├── PufferfishSpawner.java │ │ ├── RabbitSpawner.java │ │ ├── SalmonSpawner.java │ │ ├── SheepSpawner.java │ │ ├── SkeletonSpawner.java │ │ ├── SlimeSpawner.java │ │ ├── SpiderSpawner.java │ │ ├── SquidSpawner.java │ │ ├── StraySpawner.java │ │ ├── StriderSpawner.java │ │ ├── TropicalFishSpawner.java │ │ ├── TurtleSpawner.java │ │ ├── WitchSpawner.java │ │ ├── WitherSkeletonSpawner.java │ │ ├── WolfSpawner.java │ │ ├── ZombiePigmanSpawner.java │ │ └── ZombieSpawner.java │ ├── event │ ├── entity │ │ ├── SpawnGolemEvent.java │ │ └── SpawnWitherEvent.java │ └── spawner │ │ ├── SpawnerChangeTypeEvent.java │ │ └── SpawnerCreateEvent.java │ ├── route │ ├── Node.java │ ├── RouteFinder.java │ ├── SimpleRouteFinder.java │ └── WalkerRouteFinder.java │ ├── runnable │ └── RouteFinderSearchTask.java │ └── utils │ ├── FastMathLite.java │ ├── FireBallExplosion.java │ ├── Utils.java │ └── WitherSkullExplosion.java └── resources ├── config.yml └── plugin.yml /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | jobs: 3 | build: 4 | 5 | working_directory: ~/MobPlugin 6 | 7 | docker: 8 | - image: cimg/openjdk:8.0 9 | 10 | steps: 11 | 12 | - checkout 13 | 14 | - restore_cache: 15 | key: MobPlugin-{{ checksum "pom.xml" }} 16 | 17 | - run: mvn dependency:go-offline 18 | 19 | - save_cache: 20 | paths: 21 | - ~/.m2 22 | key: MobPlugin-{{ checksum "pom.xml" }} 23 | 24 | - run: mvn clean package 25 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/new-issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: New Issue 3 | about: Bug / Feature request / Other 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | ### Info 11 | 12 | This is: 13 | - [ ] bug report 14 | - [ ] feature request 15 | - [ ] other 16 | 17 | ### Your issue / suggestion 18 | 19 | 20 | ### Configuration 21 | Plugin version: 22 | 23 | Nukkit version: 24 | 25 | Config: 26 | ``` 27 | 28 | ``` 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | *.iml 3 | *.class 4 | *.log 5 | *.ctxt 6 | .mtj.tmp/ 7 | *.jar 8 | *.war 9 | *.ear 10 | *.zip 11 | *.tar.gz 12 | *.rar 13 | hs_err_pid* 14 | target/ 15 | pom.xml.tag 16 | pom.xml.releaseBackup 17 | pom.xml.versionsBackup 18 | pom.xml.next 19 | release.properties 20 | dependency-reduced-pom.xml 21 | buildNumber.properties 22 | .mvn/timing.properties 23 | !/.mvn/wrapper/maven-wrapper.jar 24 | .settings 25 | .classpath 26 | .project 27 | .DS_Store 28 | desktop.ini 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NukkitX MobPlugin 2 | MobPlugin is a plugin that implements mobs and animals for NukkitX servers including movement, aggression, spawners etc. 3 | 4 | ## Notice 5 | This plugin is still in development. Therefore, it may function abnormally. Please report bugs on the issues page. 6 | 7 | [![NukkitX.com](https://img.shields.io/badge/MobPlugin-Download-brightgreen.svg)](https://cloudburstmc.org/resources/mobplugin.3/) 8 | [![CircleCI builds](https://img.shields.io/circleci/project/github/Nukkit-coders/MobPlugin.svg)](https://circleci.com/gh/Nukkit-coders/MobPlugin) 9 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | UTF-8 8 | 9 | nukkitcoders.mobplugin 10 | MobPlugin 11 | 1.27.1 12 | 13 | ${basedir}/src/main/java 14 | 15 | 16 | org.apache.maven.plugins 17 | maven-compiler-plugin 18 | 3.1 19 | 20 | 1.8 21 | 1.8 22 | 23 | 24 | 25 | 26 | 27 | . 28 | true 29 | ${basedir}/src/main/resources/ 30 | 31 | plugin.yml 32 | 33 | 34 | 35 | . 36 | true 37 | ${basedir}/src/main/resources/ 38 | 39 | config.yml 40 | 41 | 42 | 43 | 44 | 45 | 46 | opencollab-repo-release 47 | https://repo.opencollab.dev/maven-releases/ 48 | 49 | true 50 | 51 | 52 | false 53 | 54 | 55 | 56 | opencollab-repo-snapshot 57 | https://repo.opencollab.dev/maven-snapshots/ 58 | 59 | false 60 | 61 | 62 | true 63 | 64 | 65 | 66 | 67 | 68 | cn.nukkit 69 | nukkit 70 | 1.0-SNAPSHOT 71 | provided 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/RouteFinderThreadPool.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin; 2 | 3 | import nukkitcoders.mobplugin.runnable.RouteFinderSearchTask; 4 | 5 | import java.util.concurrent.*; 6 | 7 | /** 8 | * @author zzz1999 @ MobPlugin 9 | */ 10 | public class RouteFinderThreadPool { 11 | 12 | public static ThreadPoolExecutor executor = 13 | new ThreadPoolExecutor( 14 | 1, 15 | Runtime.getRuntime().availableProcessors() + 1, 16 | 1, TimeUnit.SECONDS, 17 | new LinkedBlockingQueue<>(), 18 | new ThreadPoolExecutor.AbortPolicy() 19 | ); 20 | 21 | public static void executeRouteFinderThread(RouteFinderSearchTask t) { 22 | if (!executor.isShutdown() && !executor.isTerminating()) { 23 | executor.execute(t); 24 | } 25 | } 26 | 27 | public static void shutDownNow() { 28 | executor.shutdownNow(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/Boss.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities; 2 | 3 | public interface Boss { 4 | } -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/Tameable.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities; 2 | 3 | import cn.nukkit.Player; 4 | 5 | /** 6 | * Interface that is implemented in tameable entities 7 | * 8 | * @author Michael Gertz 9 | */ 10 | public interface Tameable { 11 | 12 | String NAMED_TAG_OWNER = "Owner"; 13 | 14 | String NAMED_TAG_OWNER_UUID = "OwnerUUID"; 15 | 16 | String NAMED_TAG_SITTING = "Sitting"; 17 | 18 | Player getOwner(); 19 | 20 | boolean hasOwner(); 21 | 22 | void setOwner(Player player); 23 | 24 | String getOwnerUUID(); 25 | 26 | void setOwnerUUID(String uuid); 27 | 28 | boolean isSitting(); 29 | 30 | void setSitting(boolean sitting); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/Animal.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal; 2 | 3 | import cn.nukkit.entity.EntityAgeable; 4 | 5 | /** 6 | * @author Michael Gertz (mige) 7 | */ 8 | public interface Animal extends EntityAgeable { 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/FlyingAnimal.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.entity.EntityAgeable; 5 | import cn.nukkit.level.format.FullChunk; 6 | import cn.nukkit.math.Vector3; 7 | import cn.nukkit.nbt.tag.CompoundTag; 8 | import nukkitcoders.mobplugin.entities.FlyingEntity; 9 | 10 | public abstract class FlyingAnimal extends FlyingEntity implements EntityAgeable { 11 | 12 | public FlyingAnimal(FullChunk chunk, CompoundTag nbt) { 13 | super(chunk, nbt); 14 | } 15 | 16 | @Override 17 | public boolean onUpdate(int currentTick) { 18 | if (!this.isAlive()) { 19 | if (++this.deadTicks >= 23) { 20 | this.close(); 21 | return false; 22 | } 23 | return true; 24 | } 25 | 26 | int tickDiff = currentTick - this.lastUpdate; 27 | this.lastUpdate = currentTick; 28 | this.entityBaseTick(tickDiff); 29 | 30 | Vector3 target = this.updateMove(tickDiff); 31 | if (target instanceof Player) { 32 | if (this.distanceSquared(target) <= 2) { 33 | this.x = this.lastX; 34 | this.y = this.lastY; 35 | this.z = this.lastZ; 36 | } 37 | } else if (target != null && this.distanceSquared(target) <= 1) { 38 | this.moveTime = 0; 39 | } 40 | return true; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/JumpingAnimal.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.level.format.FullChunk; 5 | import cn.nukkit.math.Vector3; 6 | import cn.nukkit.nbt.tag.CompoundTag; 7 | import nukkitcoders.mobplugin.entities.JumpingEntity; 8 | 9 | public abstract class JumpingAnimal extends JumpingEntity implements Animal { 10 | 11 | public JumpingAnimal(FullChunk chunk, CompoundTag nbt) { 12 | super(chunk, nbt); 13 | } 14 | 15 | @Override 16 | public boolean onUpdate(int currentTick) { 17 | if (!this.isAlive()) { 18 | if (++this.deadTicks >= 23) { 19 | this.close(); 20 | return false; 21 | } 22 | return true; 23 | } 24 | 25 | int tickDiff = currentTick - this.lastUpdate; 26 | this.lastUpdate = currentTick; 27 | this.entityBaseTick(tickDiff); 28 | 29 | Vector3 target = this.updateMove(tickDiff); 30 | if (target instanceof Player) { 31 | if (this.distanceSquared(target) <= 2) { 32 | this.x = this.lastX; 33 | this.y = this.lastY; 34 | this.z = this.lastZ; 35 | } 36 | } else if (target != null && this.distanceSquared(target) <= 1) { 37 | this.moveTime = 0; 38 | } 39 | return true; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/SwimmingAnimal.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.level.format.FullChunk; 5 | import cn.nukkit.math.Vector3; 6 | import cn.nukkit.nbt.tag.CompoundTag; 7 | import nukkitcoders.mobplugin.entities.SwimmingEntity; 8 | 9 | public abstract class SwimmingAnimal extends SwimmingEntity implements Animal { 10 | 11 | public SwimmingAnimal(FullChunk chunk, CompoundTag nbt) { 12 | super(chunk, nbt); 13 | } 14 | 15 | @Override 16 | public double getSpeed() { 17 | return 0.8; 18 | } 19 | 20 | @Override 21 | protected void initEntity() { 22 | super.initEntity(); 23 | } 24 | 25 | @Override 26 | public boolean onUpdate(int currentTick) { 27 | if (this.closed) { 28 | return false; 29 | } 30 | if (!this.isAlive()) { 31 | if (++this.deadTicks >= 23) { 32 | this.close(); 33 | return false; 34 | } 35 | return true; 36 | } 37 | 38 | int tickDiff = currentTick - this.lastUpdate; 39 | this.lastUpdate = currentTick; 40 | this.entityBaseTick(tickDiff); 41 | 42 | Vector3 target = this.updateMove(tickDiff); 43 | if (target instanceof Player) { 44 | if (this.distanceSquared(target) <= 2) { 45 | this.x = this.lastX; 46 | this.y = this.lastY; 47 | this.z = this.lastZ; 48 | } 49 | } 50 | return true; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/WalkingAnimal.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.entity.Entity; 5 | import cn.nukkit.event.entity.EntityDamageEvent; 6 | import cn.nukkit.level.format.FullChunk; 7 | import cn.nukkit.math.Vector3; 8 | import cn.nukkit.nbt.tag.CompoundTag; 9 | import nukkitcoders.mobplugin.entities.WalkingEntity; 10 | import nukkitcoders.mobplugin.utils.Utils; 11 | 12 | public abstract class WalkingAnimal extends WalkingEntity implements Animal { 13 | 14 | private int panicTicks = 0; 15 | 16 | public WalkingAnimal(FullChunk chunk, CompoundTag nbt) { 17 | super(chunk, nbt); 18 | this.route = null; 19 | } 20 | 21 | @Override 22 | protected void initEntity() { 23 | super.initEntity(); 24 | } 25 | 26 | @Override 27 | public boolean onUpdate(int currentTick) { 28 | if (this.closed) { 29 | return false; 30 | } 31 | if (!this.isAlive()) { 32 | if (++this.deadTicks >= 23) { 33 | this.close(); 34 | return false; 35 | } 36 | return true; 37 | } 38 | 39 | if (this.panicTicks > 0) { 40 | this.panicTicks--; 41 | if (panicTicks == 0) { 42 | this.doPanic(false); 43 | } 44 | } 45 | 46 | int tickDiff = currentTick - this.lastUpdate; 47 | this.lastUpdate = currentTick; 48 | this.entityBaseTick(tickDiff); 49 | 50 | Vector3 target = this.updateMove(tickDiff); 51 | if (target instanceof Player) { 52 | if (this.distanceSquared(target) <= 2) { 53 | this.x = this.lastX; 54 | this.y = this.lastY; 55 | this.z = this.lastZ; 56 | } 57 | } 58 | return true; 59 | } 60 | 61 | public int getPanicTicks() { 62 | return this.panicTicks; 63 | } 64 | 65 | public void doPanic(boolean panic) { 66 | if (panic) { 67 | int time = Utils.rand(60, 100); 68 | this.panicTicks = time; 69 | this.stayTime = 0; 70 | this.moveTime = time; 71 | this.moveMultiplier = 1.8f; 72 | } else { 73 | this.panicTicks = 0; 74 | this.moveMultiplier = 1.0f; 75 | } 76 | } 77 | 78 | @Override 79 | public boolean attack(EntityDamageEvent ev) { 80 | boolean result = super.attack(ev); 81 | 82 | if (result && !ev.isCancelled()) { 83 | this.doPanic(true); 84 | } 85 | 86 | return result; 87 | } 88 | 89 | @Override 90 | public boolean canTarget(Entity entity) { 91 | return (this.isInLove() || entity instanceof Player) && this.getPanicTicks() <= 0; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/flying/Allay.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.flying; 2 | 3 | import cn.nukkit.level.format.FullChunk; 4 | import cn.nukkit.nbt.tag.CompoundTag; 5 | import nukkitcoders.mobplugin.entities.animal.FlyingAnimal; 6 | 7 | public class Allay extends FlyingAnimal { 8 | 9 | public static final int NETWORK_ID = 134; 10 | 11 | public Allay(FullChunk chunk, CompoundTag nbt) { 12 | super(chunk, nbt); 13 | } 14 | 15 | @Override 16 | public int getNetworkId() { 17 | return NETWORK_ID; 18 | } 19 | 20 | @Override 21 | public float getWidth() { 22 | return 0.6f; 23 | } 24 | 25 | @Override 26 | public float getHeight() { 27 | return 0.6f; 28 | } 29 | 30 | @Override 31 | public void initEntity() { 32 | this.setMaxHealth(20); 33 | super.initEntity(); 34 | } 35 | 36 | @Override 37 | public int getKillExperience() { 38 | return 0; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/flying/Bat.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.flying; 2 | 3 | import cn.nukkit.level.format.FullChunk; 4 | import cn.nukkit.nbt.tag.CompoundTag; 5 | import nukkitcoders.mobplugin.entities.animal.FlyingAnimal; 6 | 7 | public class Bat extends FlyingAnimal { 8 | 9 | public static final int NETWORK_ID = 19; 10 | 11 | public Bat(FullChunk chunk, CompoundTag nbt) { 12 | super(chunk, nbt); 13 | } 14 | 15 | @Override 16 | public int getNetworkId() { 17 | return NETWORK_ID; 18 | } 19 | 20 | @Override 21 | public float getWidth() { 22 | return 0.5f; 23 | } 24 | 25 | @Override 26 | public float getHeight() { 27 | return 0.9f; 28 | } 29 | 30 | @Override 31 | public void initEntity() { 32 | this.setMaxHealth(6); 33 | super.initEntity(); 34 | } 35 | 36 | @Override 37 | public int getKillExperience() { 38 | return 0; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/flying/Bee.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.flying; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.entity.Entity; 5 | import cn.nukkit.entity.EntityCreature; 6 | import cn.nukkit.event.entity.EntityDamageByEntityEvent; 7 | import cn.nukkit.event.entity.EntityDamageEvent; 8 | import cn.nukkit.item.Item; 9 | import cn.nukkit.level.format.FullChunk; 10 | import cn.nukkit.nbt.tag.CompoundTag; 11 | import cn.nukkit.potion.Effect; 12 | import nukkitcoders.mobplugin.entities.monster.FlyingMonster; 13 | import nukkitcoders.mobplugin.utils.Utils; 14 | 15 | import java.util.HashMap; 16 | 17 | public class Bee extends FlyingMonster { 18 | 19 | public static final int NETWORK_ID = 122; 20 | 21 | private boolean angry; 22 | 23 | public Bee(FullChunk chunk, CompoundTag nbt) { 24 | super(chunk, nbt); 25 | } 26 | 27 | @Override 28 | public int getKillExperience() { 29 | return Utils.rand(1, 3); 30 | } 31 | 32 | @Override 33 | public int getNetworkId() { 34 | return NETWORK_ID; 35 | } 36 | 37 | @Override 38 | public float getWidth() { 39 | if (this.isBaby()) { 40 | return 0.275f; 41 | } 42 | return 0.55f; 43 | } 44 | 45 | @Override 46 | public float getHeight() { 47 | if (this.isBaby()) { 48 | return 0.25f; 49 | } 50 | return 0.5f; 51 | } 52 | 53 | @Override 54 | public void initEntity() { 55 | this.setMaxHealth(10); 56 | super.initEntity(); 57 | 58 | this.setDamage(new float[]{0, 2, 2, 3}); 59 | } 60 | 61 | @Override 62 | public double getSpeed() { 63 | return 1.2; 64 | } 65 | 66 | @Override 67 | public void attackEntity(Entity player) { 68 | if (this.attackDelay > 23 && this.distanceSquared(player) < 1.3) { 69 | this.attackDelay = 0; 70 | HashMap damage = new HashMap<>(); 71 | damage.put(EntityDamageEvent.DamageModifier.BASE, this.getDamage()); 72 | if (player instanceof Player) { 73 | float points = 0; 74 | for (Item i : ((Player) player).getInventory().getArmorContents()) { 75 | points += this.getArmorPoints(i.getId()); 76 | } 77 | damage.put(EntityDamageEvent.DamageModifier.ARMOR, 78 | (float) (damage.getOrDefault(EntityDamageEvent.DamageModifier.ARMOR, 0f) - Math.floor( 79 | damage.getOrDefault(EntityDamageEvent.DamageModifier.BASE, 1f) * points * 0.04))); 80 | } 81 | if (player.attack(new EntityDamageByEntityEvent(this, player, EntityDamageEvent.DamageCause.ENTITY_ATTACK, damage))) { 82 | if (this.getServer().getDifficulty() == 2) { 83 | player.addEffect(Effect.getEffect(Effect.POISON).setDuration(200)); 84 | } else if (this.getServer().getDifficulty() == 3) { 85 | player.addEffect(Effect.getEffect(Effect.POISON).setDuration(360)); 86 | } 87 | } 88 | } 89 | } 90 | 91 | @Override 92 | public boolean targetOption(EntityCreature creature, double distance) { 93 | return this.isAngry() && super.targetOption(creature, distance); 94 | } 95 | 96 | @Override 97 | public boolean attack(EntityDamageEvent ev) { 98 | if (super.attack(ev)) { 99 | if (ev instanceof EntityDamageByEntityEvent && ((EntityDamageByEntityEvent) ev).getDamager() instanceof Player) { 100 | this.setAngry(true); 101 | } 102 | return true; 103 | } 104 | 105 | return false; 106 | } 107 | 108 | public boolean isAngry() { 109 | return this.angry; 110 | } 111 | 112 | public void setAngry(boolean angry) { 113 | this.angry = angry; 114 | this.setDataFlag(DATA_FLAGS, DATA_FLAG_ANGRY, angry); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/flying/Parrot.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.flying; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.entity.EntityCreature; 5 | import cn.nukkit.entity.data.IntEntityData; 6 | import cn.nukkit.item.Item; 7 | import cn.nukkit.level.format.FullChunk; 8 | import cn.nukkit.nbt.tag.CompoundTag; 9 | import nukkitcoders.mobplugin.entities.animal.FlyingAnimal; 10 | import nukkitcoders.mobplugin.utils.Utils; 11 | 12 | public class Parrot extends FlyingAnimal { 13 | 14 | public static final int NETWORK_ID = 30; 15 | 16 | private int variant; 17 | 18 | private static final int[] VARIANTS = {0, 1, 2, 3, 4}; 19 | 20 | public Parrot(FullChunk chunk, CompoundTag nbt) { 21 | super(chunk, nbt); 22 | } 23 | 24 | @Override 25 | public int getNetworkId() { 26 | return NETWORK_ID; 27 | } 28 | 29 | @Override 30 | public float getWidth() { 31 | return 0.5f; 32 | } 33 | 34 | @Override 35 | public float getHeight() { 36 | return 0.9f; 37 | } 38 | 39 | @Override 40 | public void initEntity() { 41 | this.setMaxHealth(6); 42 | super.initEntity(); 43 | 44 | if (this.namedTag.contains("Variant")) { 45 | this.variant = this.namedTag.getInt("Variant"); 46 | } else { 47 | this.variant = getRandomVariant(); 48 | } 49 | 50 | this.setDataProperty(new IntEntityData(DATA_VARIANT, this.variant)); 51 | } 52 | 53 | @Override 54 | public void saveNBT() { 55 | super.saveNBT(); 56 | this.namedTag.putInt("Variant", this.variant); 57 | } 58 | 59 | @Override 60 | public Item[] getDrops() { 61 | return new Item[]{Item.get(Item.FEATHER, 0, Utils.rand(1, 2))}; 62 | } 63 | 64 | @Override 65 | public int getKillExperience() { 66 | return Utils.rand(1, 3); 67 | } 68 | 69 | @Override 70 | public boolean targetOption(EntityCreature creature, double distance) { 71 | if (creature instanceof Player) { 72 | Player player = (Player) creature; 73 | if (player.closed) { 74 | return false; 75 | } 76 | int id = player.getInventory().getItemInHand().getId(); 77 | return player.spawned && player.isAlive() 78 | && (id == Item.SEEDS 79 | || id == Item.BEETROOT_SEEDS 80 | || id == Item.PUMPKIN_SEEDS 81 | || id == Item.MELON_SEEDS) 82 | && distance <= 49; 83 | } 84 | return false; 85 | } 86 | 87 | private static int getRandomVariant() { 88 | return VARIANTS[Utils.rand(0, VARIANTS.length - 1)]; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/jumping/Frog.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.jumping; 2 | 3 | import cn.nukkit.level.format.FullChunk; 4 | import cn.nukkit.nbt.tag.CompoundTag; 5 | import nukkitcoders.mobplugin.entities.animal.JumpingAnimal; 6 | import nukkitcoders.mobplugin.utils.Utils; 7 | 8 | public class Frog extends JumpingAnimal { 9 | 10 | public static final int NETWORK_ID = 132; 11 | 12 | public Frog(FullChunk chunk, CompoundTag nbt) { 13 | super(chunk, nbt); 14 | } 15 | 16 | @Override 17 | public int getKillExperience() { 18 | return Utils.rand(1, 3); 19 | } 20 | 21 | @Override 22 | public int getNetworkId() { 23 | return NETWORK_ID; 24 | } 25 | 26 | @Override 27 | public float getHeight() { 28 | return 0.55f; 29 | } 30 | 31 | @Override 32 | public float getWidth() { 33 | return 0.5f; 34 | } 35 | 36 | @Override 37 | protected void initEntity() { 38 | this.setMaxHealth(10); 39 | super.initEntity(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/swimming/Axolotl.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.swimming; 2 | 3 | import cn.nukkit.level.format.FullChunk; 4 | import cn.nukkit.nbt.tag.CompoundTag; 5 | 6 | public class Axolotl extends Fish { 7 | 8 | public static final int NETWORK_ID = 130; 9 | 10 | public Axolotl(FullChunk chunk, CompoundTag nbt) { 11 | super(chunk, nbt); 12 | } 13 | 14 | @Override 15 | public void initEntity() { 16 | this.setMaxHealth(14); 17 | super.initEntity(); 18 | } 19 | 20 | @Override 21 | public int getNetworkId() { 22 | return NETWORK_ID; 23 | } 24 | 25 | @Override 26 | public float getWidth() { 27 | return 0.75f; 28 | } 29 | 30 | @Override 31 | public float getHeight() { 32 | return 0.42f; 33 | } 34 | 35 | @Override 36 | int getBucketMeta() { 37 | return 12; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/swimming/Cod.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.swimming; 2 | 3 | import cn.nukkit.item.Item; 4 | import cn.nukkit.level.format.FullChunk; 5 | import cn.nukkit.nbt.tag.CompoundTag; 6 | import nukkitcoders.mobplugin.utils.Utils; 7 | 8 | public class Cod extends Fish { 9 | 10 | public static final int NETWORK_ID = 112; 11 | 12 | public Cod(FullChunk chunk, CompoundTag nbt) { 13 | super(chunk, nbt); 14 | } 15 | 16 | @Override 17 | int getBucketMeta() { 18 | return 2; 19 | } 20 | 21 | @Override 22 | public int getNetworkId() { 23 | return NETWORK_ID; 24 | } 25 | 26 | @Override 27 | public float getWidth() { 28 | return 0.5f; 29 | } 30 | 31 | @Override 32 | public float getHeight() { 33 | return 0.2f; 34 | } 35 | 36 | @Override 37 | public void initEntity() { 38 | this.setMaxHealth(3); 39 | super.initEntity(); 40 | } 41 | 42 | @Override 43 | public Item[] getDrops() { 44 | return new Item[]{Item.get(Item.RAW_FISH, 0, 1), Item.get(Item.BONE, 0, Utils.rand(0, 2))}; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/swimming/Dolphin.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.swimming; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.entity.EntityCreature; 5 | import cn.nukkit.item.Item; 6 | import cn.nukkit.level.format.FullChunk; 7 | import cn.nukkit.nbt.tag.CompoundTag; 8 | import nukkitcoders.mobplugin.entities.animal.SwimmingAnimal; 9 | import nukkitcoders.mobplugin.utils.Utils; 10 | 11 | public class Dolphin extends SwimmingAnimal { 12 | 13 | public static final int NETWORK_ID = 31; 14 | 15 | public Dolphin(FullChunk chunk, CompoundTag nbt) { 16 | super(chunk, nbt); 17 | } 18 | 19 | @Override 20 | public int getNetworkId() { 21 | return NETWORK_ID; 22 | } 23 | 24 | @Override 25 | public double getSpeed() { 26 | return 1.2; 27 | } 28 | 29 | @Override 30 | public void initEntity() { 31 | this.setMaxHealth(10); 32 | super.initEntity(); 33 | } 34 | 35 | @Override 36 | public float getWidth() { 37 | return 0.9f; 38 | } 39 | 40 | @Override 41 | public float getHeight() { 42 | return 0.6f; 43 | } 44 | 45 | @Override 46 | public Item[] getDrops() { 47 | return new Item[]{Item.get(Item.RAW_FISH, 0, Utils.rand(0, 1))}; 48 | } 49 | 50 | @Override 51 | public int getKillExperience() { 52 | return 0; 53 | } 54 | 55 | @Override 56 | public boolean targetOption(EntityCreature creature, double distance) { 57 | if (creature instanceof Player) { 58 | Player player = (Player) creature; 59 | return player.spawned && player.isAlive() && !player.closed && (player.getInventory().getItemInHand().getId() == Item.RAW_FISH || player.getInventory().getItemInHand().getId() == Item.RAW_SALMON) && distance <= 49; 60 | } 61 | return false; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/swimming/Fish.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.swimming; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.item.Item; 5 | import cn.nukkit.level.format.FullChunk; 6 | import cn.nukkit.math.Vector3; 7 | import cn.nukkit.nbt.tag.CompoundTag; 8 | import nukkitcoders.mobplugin.entities.animal.SwimmingAnimal; 9 | import nukkitcoders.mobplugin.utils.Utils; 10 | 11 | public abstract class Fish extends SwimmingAnimal { 12 | 13 | public Fish(FullChunk chunk, CompoundTag nbt) { 14 | super(chunk, nbt); 15 | } 16 | 17 | @Override 18 | public int getKillExperience() { 19 | return Utils.rand(1, 3); 20 | } 21 | 22 | @Override 23 | public boolean onInteract(Player player, Item item, Vector3 clickedPos) { 24 | if (item.getId() == Item.BUCKET && (item.getDamage() == 0 || item.getDamage() == 8) && Utils.entityInsideWaterFast(this)) { 25 | this.close(); 26 | if (item.getCount() <= 1) { 27 | player.getInventory().setItemInHand(Item.get(Item.BUCKET, this.getBucketMeta(), 1)); 28 | return false; 29 | } else { 30 | if (!player.isCreative()) { 31 | player.getInventory().decreaseCount(player.getInventory().getHeldItemIndex()); 32 | } 33 | player.getInventory().addItem(Item.get(Item.BUCKET, this.getBucketMeta(), 1)); 34 | return true; 35 | } 36 | } 37 | return super.onInteract(player, item, clickedPos); 38 | } 39 | 40 | abstract int getBucketMeta(); 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/swimming/GlowSquid.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.swimming; 2 | 3 | import cn.nukkit.level.format.FullChunk; 4 | import cn.nukkit.nbt.tag.CompoundTag; 5 | 6 | public class GlowSquid extends Squid { 7 | 8 | public static final int NETWORK_ID = 129; 9 | 10 | public GlowSquid(FullChunk chunk, CompoundTag nbt) { 11 | super(chunk, nbt); 12 | } 13 | 14 | @Override 15 | public int getNetworkId() { 16 | return NETWORK_ID; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/swimming/Pufferfish.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.swimming; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.entity.Entity; 5 | import cn.nukkit.entity.data.ByteEntityData; 6 | import cn.nukkit.event.entity.EntityDamageByEntityEvent; 7 | import cn.nukkit.event.entity.EntityDamageEvent; 8 | import cn.nukkit.event.entity.EntityDamageEvent.DamageCause; 9 | import cn.nukkit.item.Item; 10 | import cn.nukkit.level.format.FullChunk; 11 | import cn.nukkit.nbt.tag.CompoundTag; 12 | import cn.nukkit.potion.Effect; 13 | import nukkitcoders.mobplugin.utils.Utils; 14 | 15 | public class Pufferfish extends Fish { 16 | 17 | public static final int NETWORK_ID = 108; 18 | 19 | private int puffed = 0; 20 | 21 | public Pufferfish(FullChunk chunk, CompoundTag nbt) { 22 | super(chunk, nbt); 23 | } 24 | 25 | @Override 26 | int getBucketMeta() { 27 | return 5; 28 | } 29 | 30 | @Override 31 | public int getNetworkId() { 32 | return NETWORK_ID; 33 | } 34 | 35 | @Override 36 | public float getWidth() { 37 | return 0.35f; 38 | } 39 | 40 | @Override 41 | public float getHeight() { 42 | return 0.35f; 43 | } 44 | 45 | @Override 46 | public void initEntity() { 47 | this.setMaxHealth(3); 48 | super.initEntity(); 49 | } 50 | 51 | @Override 52 | public Item[] getDrops() { 53 | return new Item[]{Item.get(Item.PUFFERFISH, 0, 1), Item.get(Item.BONE, 0, Utils.rand(0, 2))}; 54 | } 55 | 56 | @Override 57 | public boolean attack(EntityDamageEvent ev) { 58 | super.attack(ev); 59 | 60 | if (ev.getCause() != DamageCause.ENTITY_ATTACK) { 61 | return true; 62 | } 63 | 64 | if (ev instanceof EntityDamageByEntityEvent) { 65 | Entity damager = ((EntityDamageByEntityEvent) ev).getDamager(); 66 | if (damager instanceof Player) { 67 | if (this.puffed > 0) { 68 | return true; 69 | } 70 | this.puffed = 200; 71 | damager.addEffect(Effect.getEffect(Effect.POISON).setDuration(200)); 72 | this.setDataProperty(new ByteEntityData(DATA_PUFFERFISH_SIZE, 2)); 73 | } 74 | } 75 | 76 | return true; 77 | } 78 | 79 | @Override 80 | public boolean entityBaseTick(int tickDiff) { 81 | if (puffed == 0) { 82 | if (this.getDataPropertyByte(DATA_PUFFERFISH_SIZE) == 2) { 83 | this.setDataProperty(new ByteEntityData(DATA_PUFFERFISH_SIZE, 0)); 84 | } 85 | } 86 | 87 | if (puffed > 0) { 88 | puffed--; 89 | } 90 | 91 | return super.entityBaseTick(tickDiff); 92 | } 93 | 94 | public boolean isPuffed() { 95 | return this.puffed > 0; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/swimming/Salmon.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.swimming; 2 | 3 | import cn.nukkit.item.Item; 4 | import cn.nukkit.level.format.FullChunk; 5 | import cn.nukkit.nbt.tag.CompoundTag; 6 | import nukkitcoders.mobplugin.utils.Utils; 7 | 8 | public class Salmon extends Fish { 9 | 10 | public static final int NETWORK_ID = 109; 11 | 12 | public Salmon(FullChunk chunk, CompoundTag nbt) { 13 | super(chunk, nbt); 14 | } 15 | 16 | @Override 17 | int getBucketMeta() { 18 | return 3; 19 | } 20 | 21 | @Override 22 | public int getNetworkId() { 23 | return NETWORK_ID; 24 | } 25 | 26 | @Override 27 | public float getWidth() { 28 | return 0.7f; 29 | } 30 | 31 | @Override 32 | public float getHeight() { 33 | return 0.4f; 34 | } 35 | 36 | @Override 37 | public void initEntity() { 38 | this.setMaxHealth(3); 39 | super.initEntity(); 40 | } 41 | 42 | @Override 43 | public Item[] getDrops() { 44 | return new Item[]{Item.get(Item.RAW_SALMON, 0, 1), Item.get(Item.BONE, 0, Utils.rand(0, 2))}; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/swimming/Squid.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.swimming; 2 | 3 | import cn.nukkit.event.entity.EntityDamageByEntityEvent; 4 | import cn.nukkit.event.entity.EntityDamageEvent; 5 | import cn.nukkit.item.Item; 6 | import cn.nukkit.item.ItemDye; 7 | import cn.nukkit.level.format.FullChunk; 8 | import cn.nukkit.nbt.tag.CompoundTag; 9 | import cn.nukkit.network.protocol.EntityEventPacket; 10 | import cn.nukkit.utils.DyeColor; 11 | import nukkitcoders.mobplugin.entities.animal.SwimmingAnimal; 12 | import nukkitcoders.mobplugin.utils.Utils; 13 | 14 | public class Squid extends SwimmingAnimal { 15 | 16 | public static final int NETWORK_ID = 17; 17 | 18 | public Squid(FullChunk chunk, CompoundTag nbt) { 19 | super(chunk, nbt); 20 | } 21 | 22 | @Override 23 | public int getNetworkId() { 24 | return NETWORK_ID; 25 | } 26 | 27 | @Override 28 | public float getWidth() { 29 | return 0.95f; 30 | } 31 | 32 | @Override 33 | public float getHeight() { 34 | return 0.95f; 35 | } 36 | 37 | @Override 38 | public void initEntity() { 39 | this.setMaxHealth(10); 40 | super.initEntity(); 41 | } 42 | 43 | @Override 44 | public Item[] getDrops() { 45 | return new Item[]{new ItemDye(DyeColor.BLACK.getDyeData(), Utils.rand(1, 3))}; 46 | } 47 | 48 | @Override 49 | public int getKillExperience() { 50 | return Utils.rand(1, 3); 51 | } 52 | 53 | @Override 54 | public boolean attack(EntityDamageEvent source) { 55 | boolean att = super.attack(source); 56 | if (source.isCancelled()) { 57 | return att; 58 | } 59 | 60 | if (source instanceof EntityDamageByEntityEvent) { 61 | EntityEventPacket pk = new EntityEventPacket(); 62 | pk.eid = this.getId(); 63 | pk.event = EntityEventPacket.SQUID_INK_CLOUD; 64 | this.level.addChunkPacket(this.getChunkX(), this.getChunkZ(), pk); 65 | } 66 | return att; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/swimming/Tadpole.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.swimming; 2 | 3 | import cn.nukkit.level.format.FullChunk; 4 | import cn.nukkit.nbt.tag.CompoundTag; 5 | 6 | public class Tadpole extends Fish { 7 | 8 | public static final int NETWORK_ID = 133; 9 | 10 | public Tadpole(FullChunk chunk, CompoundTag nbt) { 11 | super(chunk, nbt); 12 | } 13 | 14 | @Override 15 | public int getKillExperience() { 16 | return 0; 17 | } 18 | 19 | @Override 20 | int getBucketMeta() { 21 | return 13; 22 | } 23 | 24 | @Override 25 | public int getNetworkId() { 26 | return NETWORK_ID; 27 | } 28 | 29 | @Override 30 | public float getHeight() { 31 | return 0.8f; 32 | } 33 | 34 | @Override 35 | public float getWidth() { 36 | return 0.6f; 37 | } 38 | 39 | @Override 40 | protected void initEntity() { 41 | this.setMaxHealth(6); 42 | super.initEntity(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/swimming/TropicalFish.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.swimming; 2 | 3 | import cn.nukkit.item.Item; 4 | import cn.nukkit.level.format.FullChunk; 5 | import cn.nukkit.nbt.tag.CompoundTag; 6 | import nukkitcoders.mobplugin.utils.Utils; 7 | 8 | public class TropicalFish extends Fish { 9 | 10 | public static final int NETWORK_ID = 111; 11 | 12 | private int variantA; 13 | private int variantB; 14 | private int color; 15 | 16 | public TropicalFish(FullChunk chunk, CompoundTag nbt) { 17 | super(chunk, nbt); 18 | } 19 | 20 | @Override 21 | protected void initEntity() { 22 | this.setMaxHealth(3); 23 | super.initEntity(); 24 | 25 | if (this.namedTag.contains("VariantA")) { 26 | this.variantA = this.namedTag.getInt("VariantA"); 27 | } else { 28 | this.variantA = Utils.rand(0, 5); 29 | 30 | } 31 | this.dataProperties.putInt(DATA_VARIANT, this.variantA); 32 | 33 | if (this.namedTag.contains("VariantB")) { 34 | this.variantB = this.namedTag.getInt("VariantB"); 35 | } else { 36 | this.variantB = Utils.rand(0, 5); 37 | 38 | } 39 | this.dataProperties.putInt(DATA_MARK_VARIANT, this.variantB); 40 | 41 | if (this.namedTag.contains("Color")) { 42 | this.color = this.namedTag.getInt("Color"); 43 | } else { 44 | this.color = Utils.rand(0, 15); 45 | 46 | } 47 | this.dataProperties.putByte(DATA_COLOR, this.color); 48 | } 49 | 50 | @Override 51 | public void saveNBT() { 52 | super.saveNBT(); 53 | this.namedTag.putInt("VariantA", this.variantA); 54 | this.namedTag.putInt("VariantB", this.variantB); 55 | this.namedTag.putInt("Color", this.color); 56 | } 57 | 58 | @Override 59 | int getBucketMeta() { 60 | return 4; 61 | } 62 | 63 | @Override 64 | public int getNetworkId() { 65 | return NETWORK_ID; 66 | } 67 | 68 | @Override 69 | public float getWidth() { 70 | return 0.5f; 71 | } 72 | 73 | @Override 74 | public float getHeight() { 75 | return 0.4f; 76 | } 77 | 78 | @Override 79 | public Item[] getDrops() { 80 | return new Item[]{Item.get(Item.CLOWNFISH, 0, 1), Item.get(Item.BONE, 0, Utils.rand(0, 2))}; 81 | } 82 | 83 | @Override 84 | public String getName() { 85 | return this.hasCustomName() ? this.getNameTag() : "Tropical Fish"; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/swimming/Turtle.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.swimming; 2 | 3 | import cn.nukkit.level.format.FullChunk; 4 | import cn.nukkit.nbt.tag.CompoundTag; 5 | import nukkitcoders.mobplugin.entities.animal.SwimmingAnimal; 6 | import nukkitcoders.mobplugin.utils.Utils; 7 | 8 | public class Turtle extends SwimmingAnimal { 9 | 10 | public static final int NETWORK_ID = 74; 11 | 12 | public Turtle(FullChunk chunk, CompoundTag nbt) { 13 | super(chunk, nbt); 14 | } 15 | 16 | @Override 17 | public int getNetworkId() { 18 | return NETWORK_ID; 19 | } 20 | 21 | @Override 22 | public float getWidth() { 23 | return 1.2f; 24 | } 25 | 26 | @Override 27 | public float getHeight() { 28 | return 0.4f; 29 | } 30 | 31 | @Override 32 | public void initEntity() { 33 | this.setMaxHealth(30); 34 | super.initEntity(); 35 | } 36 | 37 | @Override 38 | public int getKillExperience() { 39 | return this.isBaby() ? 0 : Utils.rand(1, 3); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/walking/Camel.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.walking; 2 | 3 | import cn.nukkit.level.format.FullChunk; 4 | import cn.nukkit.nbt.tag.CompoundTag; 5 | import nukkitcoders.mobplugin.entities.animal.WalkingAnimal; 6 | import nukkitcoders.mobplugin.utils.Utils; 7 | 8 | public class Camel extends WalkingAnimal { 9 | 10 | public static final int NETWORK_ID = 138; 11 | 12 | public Camel(FullChunk chunk, CompoundTag nbt) { 13 | super(chunk, nbt); 14 | } 15 | 16 | @Override 17 | public void initEntity() { 18 | this.setMaxHealth(32); 19 | super.initEntity(); 20 | } 21 | 22 | @Override 23 | public float getWidth() { 24 | if (this.isBaby()) { 25 | return 0.85f; 26 | } 27 | return 1.77f; 28 | } 29 | 30 | @Override 31 | public float getHeight() { 32 | if (this.isBaby()) { 33 | return 1.1875f; 34 | } 35 | return 2.375f; 36 | } 37 | 38 | @Override 39 | public int getKillExperience() { 40 | return Utils.rand(1, 3); 41 | } 42 | 43 | @Override 44 | public int getNetworkId() { 45 | return NETWORK_ID; 46 | } 47 | } -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/walking/Cat.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.walking; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.entity.EntityCreature; 5 | import cn.nukkit.item.Item; 6 | import cn.nukkit.level.format.FullChunk; 7 | import cn.nukkit.nbt.tag.CompoundTag; 8 | import nukkitcoders.mobplugin.entities.animal.WalkingAnimal; 9 | import nukkitcoders.mobplugin.utils.Utils; 10 | 11 | public class Cat extends WalkingAnimal { 12 | 13 | public static final int NETWORK_ID = 75; 14 | 15 | public Cat(FullChunk chunk, CompoundTag nbt) { 16 | super(chunk, nbt); 17 | } 18 | 19 | @Override 20 | public int getNetworkId() { 21 | return NETWORK_ID; 22 | } 23 | 24 | @Override 25 | public float getWidth() { 26 | if (this.isBaby()) { 27 | return 0.3f; 28 | } 29 | return 0.6f; 30 | } 31 | 32 | @Override 33 | public float getHeight() { 34 | if (this.isBaby()) { 35 | return 0.35f; 36 | } 37 | return 0.7f; 38 | } 39 | 40 | @Override 41 | public void initEntity() { 42 | this.setMaxHealth(10); 43 | super.initEntity(); 44 | 45 | this.noFallDamage = true; 46 | } 47 | 48 | @Override 49 | public Item[] getDrops() { 50 | if (!this.isBaby()) { 51 | int c = Utils.rand(0, 2); 52 | if (c > 0) { 53 | return new Item[]{Item.get(Item.STRING, 0, c)}; 54 | } 55 | } 56 | 57 | return new Item[0]; 58 | } 59 | 60 | @Override 61 | public int getKillExperience() { 62 | return this.isBaby() ? 0 : Utils.rand(1, 3); 63 | } 64 | 65 | @Override 66 | public boolean targetOption(EntityCreature creature, double distance) { 67 | if (creature instanceof Player) { 68 | Player player = (Player) creature; 69 | return player.spawned && player.isAlive() && !player.closed && (player.getInventory().getItemInHand().getId() == Item.RAW_FISH || player.getInventory().getItemInHand().getId() == Item.RAW_SALMON) && distance <= 49; 70 | } 71 | return false; 72 | } 73 | } -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/walking/Cow.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.walking; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.entity.EntityCreature; 5 | import cn.nukkit.item.Item; 6 | import cn.nukkit.level.Sound; 7 | import cn.nukkit.level.format.FullChunk; 8 | import cn.nukkit.level.particle.ItemBreakParticle; 9 | import cn.nukkit.math.Vector3; 10 | import cn.nukkit.nbt.tag.CompoundTag; 11 | import nukkitcoders.mobplugin.entities.animal.WalkingAnimal; 12 | import nukkitcoders.mobplugin.utils.Utils; 13 | 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | public class Cow extends WalkingAnimal { 18 | 19 | public static final int NETWORK_ID = 11; 20 | 21 | public Cow(FullChunk chunk, CompoundTag nbt) { 22 | super(chunk, nbt); 23 | } 24 | 25 | @Override 26 | public int getNetworkId() { 27 | return NETWORK_ID; 28 | } 29 | 30 | @Override 31 | public float getWidth() { 32 | if (this.isBaby()) { 33 | return 0.2f; 34 | } 35 | return 0.45f; 36 | } 37 | 38 | @Override 39 | public float getHeight() { 40 | if (this.isBaby()) { 41 | return 0.7f; 42 | } 43 | return 1.4f; 44 | } 45 | 46 | @Override 47 | public void initEntity() { 48 | this.setMaxHealth(10); 49 | super.initEntity(); 50 | } 51 | 52 | @Override 53 | public boolean onInteract(Player player, Item item, Vector3 clickedPos) { 54 | if (item.getId() == Item.BUCKET) { 55 | if (!player.isCreative()) { 56 | player.getInventory().decreaseCount(player.getInventory().getHeldItemIndex()); 57 | } 58 | Item newBucket = Item.get(Item.BUCKET, 1, 1); 59 | if (player.getInventory().getItem(player.getInventory().getHeldItemIndex()).count > 0) { 60 | if (player.getInventory().canAddItem(newBucket)) { 61 | player.getInventory().addItem(newBucket); 62 | } else { 63 | player.dropItem(newBucket); 64 | } 65 | } else { 66 | player.getInventory().setItemInHand(newBucket); 67 | } 68 | this.level.addSound(this, Sound.MOB_COW_MILK); 69 | return false; 70 | } else if (item.getId() == Item.WHEAT && !this.isBaby() && !isInLoveCooldown()) { 71 | if (!player.isCreative()) { 72 | player.getInventory().decreaseCount(player.getInventory().getHeldItemIndex()); 73 | } 74 | this.level.addSound(this, Sound.RANDOM_EAT); 75 | this.level.addParticle(new ItemBreakParticle(this.add(0, this.getMountedYOffset(), 0), Item.get(Item.WHEAT))); 76 | this.setInLove(); 77 | this.lastInteract = player; 78 | } 79 | return super.onInteract(player, item, clickedPos); 80 | } 81 | 82 | @Override 83 | public boolean targetOption(EntityCreature creature, double distance) { 84 | if (creature instanceof Player) { 85 | Player player = (Player) creature; 86 | return player.isAlive() && !player.closed && player.getInventory().getItemInHand().getId() == Item.WHEAT && distance <= 49; 87 | } 88 | return super.targetOption(creature, distance); 89 | } 90 | 91 | @Override 92 | public Item[] getDrops() { 93 | List drops = new ArrayList<>(); 94 | 95 | if (!this.isBaby()) { 96 | drops.add(Item.get(Item.LEATHER, 0, Utils.rand(0, 2))); 97 | drops.add(Item.get(this.isOnFire() ? Item.STEAK : Item.RAW_BEEF, 0, Utils.rand(1, 3))); 98 | } 99 | 100 | return drops.toArray(new Item[0]); 101 | } 102 | 103 | @Override 104 | public int getKillExperience() { 105 | return this.isBaby() ? 0 : Utils.rand(1, 3); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/walking/Donkey.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.walking; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.entity.EntityCreature; 5 | import cn.nukkit.item.Item; 6 | import cn.nukkit.level.format.FullChunk; 7 | import cn.nukkit.math.Vector3; 8 | import cn.nukkit.nbt.tag.CompoundTag; 9 | import nukkitcoders.mobplugin.entities.HorseBase; 10 | import nukkitcoders.mobplugin.utils.Utils; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | /** 16 | * @author Michael Gertz 17 | */ 18 | public class Donkey extends HorseBase { 19 | 20 | public static final int NETWORK_ID = 24; 21 | 22 | private boolean chested; 23 | 24 | public Donkey(FullChunk chunk, CompoundTag nbt) { 25 | super(chunk, nbt); 26 | } 27 | 28 | @Override 29 | public int getNetworkId() { 30 | return NETWORK_ID; 31 | } 32 | 33 | @Override 34 | public float getWidth() { 35 | if (this.isBaby()) { 36 | return 0.6982f; 37 | } 38 | return 1.3965f; 39 | } 40 | 41 | @Override 42 | public float getHeight() { 43 | if (this.isBaby()) { 44 | return 0.8f; 45 | } 46 | return 1.6f; 47 | } 48 | 49 | @Override 50 | public void initEntity() { 51 | this.setMaxHealth(15); 52 | super.initEntity(); 53 | 54 | if (this.namedTag.contains("ChestedHorse")) { 55 | this.setChested(this.namedTag.getBoolean("ChestedHorse")); 56 | } 57 | } 58 | 59 | @Override 60 | public boolean targetOption(EntityCreature creature, double distance) { 61 | boolean canTarget = super.targetOption(creature, distance); 62 | 63 | if (canTarget && (creature instanceof Player)) { 64 | Player player = (Player) creature; 65 | return player.spawned && player.isAlive() && !player.closed && 66 | this.isFeedItem(player.getInventory().getItemInHand()) && distance <= 49; 67 | } 68 | return false; 69 | } 70 | 71 | @Override 72 | public Item[] getDrops() { 73 | List drops = new ArrayList<>(); 74 | 75 | if (!this.isBaby()) { 76 | for (int i = 0; i < Utils.rand(0, 2); i++) { 77 | drops.add(Item.get(Item.LEATHER, 0, 1)); 78 | } 79 | } 80 | 81 | if (this.isChested()) { 82 | drops.add(Item.get(Item.CHEST, 0, 1)); 83 | } 84 | 85 | if (this.isSaddled()) { 86 | drops.add(Item.get(Item.SADDLE, 0, 1)); 87 | } 88 | 89 | return drops.toArray(new Item[0]); 90 | } 91 | 92 | @Override 93 | public boolean onInteract(Player player, Item item, Vector3 clickedPos) { 94 | if (!this.isBaby() && !this.isChested() && item.getId() == Item.CHEST) { 95 | if (!player.isCreative()) { 96 | player.getInventory().decreaseCount(player.getInventory().getHeldItemIndex()); 97 | } 98 | this.setChested(true); 99 | return false; 100 | } 101 | 102 | return super.onInteract(player, item, clickedPos); 103 | } 104 | 105 | @Override 106 | public void saveNBT() { 107 | super.saveNBT(); 108 | this.namedTag.putBoolean("ChestedHorse", this.isChested()); 109 | } 110 | 111 | public boolean isChested() { 112 | return this.chested; 113 | } 114 | 115 | public void setChested(boolean chested) { 116 | this.chested = chested; 117 | this.setDataFlag(DATA_FLAGS, DATA_FLAG_CHESTED, chested); 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/walking/Fox.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.walking; 2 | 3 | import cn.nukkit.level.format.FullChunk; 4 | import cn.nukkit.nbt.tag.CompoundTag; 5 | import nukkitcoders.mobplugin.entities.animal.WalkingAnimal; 6 | import nukkitcoders.mobplugin.utils.Utils; 7 | 8 | public class Fox extends WalkingAnimal { 9 | 10 | public static final int NETWORK_ID = 121; 11 | 12 | public Fox(FullChunk chunk, CompoundTag nbt) { 13 | super(chunk, nbt); 14 | } 15 | 16 | @Override 17 | public int getNetworkId() { 18 | return NETWORK_ID; 19 | } 20 | 21 | @Override 22 | public float getWidth() { 23 | return 0.7f; 24 | } 25 | 26 | @Override 27 | public float getHeight() { 28 | return 0.6f; 29 | } 30 | 31 | @Override 32 | public void initEntity() { 33 | this.setMaxHealth(20); 34 | super.initEntity(); 35 | } 36 | 37 | @Override 38 | public int getKillExperience() { 39 | return this.isBaby() ? 0 : Utils.rand(1, 2); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/walking/Goat.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.walking; 2 | 3 | import cn.nukkit.level.format.FullChunk; 4 | import cn.nukkit.nbt.tag.CompoundTag; 5 | import nukkitcoders.mobplugin.entities.animal.WalkingAnimal; 6 | import nukkitcoders.mobplugin.utils.Utils; 7 | 8 | public class Goat extends WalkingAnimal { 9 | 10 | public static final int NETWORK_ID = 128; 11 | 12 | public Goat(FullChunk chunk, CompoundTag nbt) { 13 | super(chunk, nbt); 14 | } 15 | 16 | @Override 17 | public void initEntity() { 18 | this.setMaxHealth(10); 19 | super.initEntity(); 20 | } 21 | 22 | @Override 23 | public float getWidth() { 24 | if (this.isBaby()) { 25 | return 0.65f; 26 | } 27 | return 1.3f; 28 | } 29 | 30 | @Override 31 | public float getHeight() { 32 | if (this.isBaby()) { 33 | return 0.45f; 34 | } 35 | return 0.9f; 36 | } 37 | 38 | @Override 39 | public int getKillExperience() { 40 | return Utils.rand(1, 3); 41 | } 42 | 43 | @Override 44 | public int getNetworkId() { 45 | return NETWORK_ID; 46 | } 47 | 48 | @Override 49 | public double getSpeed() { 50 | return 1.1; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/walking/Horse.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.walking; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.entity.EntityCreature; 5 | import cn.nukkit.entity.data.IntEntityData; 6 | import cn.nukkit.item.Item; 7 | import cn.nukkit.level.format.FullChunk; 8 | import cn.nukkit.nbt.tag.CompoundTag; 9 | import nukkitcoders.mobplugin.entities.HorseBase; 10 | import nukkitcoders.mobplugin.utils.Utils; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | /** 16 | * @author Michael Gertz 17 | */ 18 | public class Horse extends HorseBase { 19 | 20 | public static final int NETWORK_ID = 23; 21 | 22 | private int variant; 23 | 24 | private static final int[] VARIANTS = {0, 1, 2, 3, 4, 5, 6, 256, 257, 258, 259, 260, 261, 262, 512, 513, 514, 515, 516, 517, 518, 25 | 768, 769, 770, 771, 772, 773, 774, 1024, 1025, 1026, 1027, 1028, 1029, 1030}; 26 | 27 | public Horse(FullChunk chunk, CompoundTag nbt) { 28 | super(chunk, nbt); 29 | } 30 | 31 | @Override 32 | public int getNetworkId() { 33 | return NETWORK_ID; 34 | } 35 | 36 | @Override 37 | public float getWidth() { 38 | if (this.isBaby()) { 39 | return 0.6982f; 40 | } 41 | return 1.3965f; 42 | } 43 | 44 | @Override 45 | public float getHeight() { 46 | if (this.isBaby()) { 47 | return 0.8f; 48 | } 49 | return 1.6f; 50 | } 51 | 52 | @Override 53 | public void initEntity() { 54 | this.setMaxHealth(15); 55 | super.initEntity(); 56 | 57 | if (this.namedTag.contains("Variant")) { 58 | this.variant = this.namedTag.getInt("Variant"); 59 | } else { 60 | this.variant = getRandomVariant(); 61 | } 62 | 63 | this.setDataProperty(new IntEntityData(DATA_VARIANT, this.variant)); 64 | } 65 | 66 | @Override 67 | public void saveNBT() { 68 | super.saveNBT(); 69 | this.namedTag.putInt("Variant", this.variant); 70 | } 71 | 72 | @Override 73 | public boolean targetOption(EntityCreature creature, double distance) { 74 | boolean canTarget = super.targetOption(creature, distance); 75 | 76 | if (canTarget && (creature instanceof Player)) { 77 | Player player = (Player) creature; 78 | return player.spawned && player.isAlive() && !player.closed && 79 | this.isFeedItem(player.getInventory().getItemInHand()) && distance <= 49; 80 | } 81 | return false; 82 | } 83 | 84 | @Override 85 | public Item[] getDrops() { 86 | List drops = new ArrayList<>(); 87 | 88 | if (!this.isBaby()) { 89 | for (int i = 0; i < Utils.rand(0, 2); i++) { 90 | drops.add(Item.get(Item.LEATHER, 0, 1)); 91 | } 92 | } 93 | 94 | if (this.isSaddled()) { 95 | drops.add(Item.get(Item.SADDLE, 0, 1)); 96 | } 97 | 98 | return drops.toArray(new Item[0]); 99 | } 100 | 101 | private int getRandomVariant() { 102 | return VARIANTS[Utils.rand(0, VARIANTS.length - 1)]; 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/walking/Mule.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.walking; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.entity.EntityCreature; 5 | import cn.nukkit.item.Item; 6 | import cn.nukkit.level.format.FullChunk; 7 | import cn.nukkit.nbt.tag.CompoundTag; 8 | import nukkitcoders.mobplugin.entities.HorseBase; 9 | import nukkitcoders.mobplugin.utils.Utils; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | /** 15 | * @author Michael Gertz 16 | */ 17 | public class Mule extends HorseBase { 18 | 19 | public static final int NETWORK_ID = 25; 20 | 21 | public Mule(FullChunk chunk, CompoundTag nbt) { 22 | super(chunk, nbt); 23 | } 24 | 25 | @Override 26 | public int getNetworkId() { 27 | return NETWORK_ID; 28 | } 29 | 30 | @Override 31 | public float getWidth() { 32 | if (this.isBaby()) { 33 | return 0.6982f; 34 | } 35 | return 1.3965f; 36 | } 37 | 38 | @Override 39 | public float getHeight() { 40 | if (this.isBaby()) { 41 | return 0.8f; 42 | } 43 | return 1.6f; 44 | } 45 | 46 | @Override 47 | public void initEntity() { 48 | this.setMaxHealth(15); 49 | super.initEntity(); 50 | } 51 | 52 | @Override 53 | public boolean targetOption(EntityCreature creature, double distance) { 54 | boolean canTarget = super.targetOption(creature, distance); 55 | 56 | if (canTarget && (creature instanceof Player)) { 57 | Player player = (Player) creature; 58 | return player.spawned && player.isAlive() && !player.closed && 59 | this.isFeedItem(player.getInventory().getItemInHand()) && distance <= 49; 60 | } 61 | return false; 62 | } 63 | 64 | @Override 65 | public Item[] getDrops() { 66 | List drops = new ArrayList<>(); 67 | 68 | if (!this.isBaby()) { 69 | for (int i = 0; i < Utils.rand(0, 2); i++) { 70 | drops.add(Item.get(Item.LEATHER, 0, 1)); 71 | } 72 | } 73 | 74 | if (this.isSaddled()) { 75 | drops.add(Item.get(Item.SADDLE, 0, 1)); 76 | } 77 | 78 | return drops.toArray(new Item[0]); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/walking/Ocelot.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.walking; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.entity.EntityCreature; 5 | import cn.nukkit.item.Item; 6 | import cn.nukkit.level.format.FullChunk; 7 | import cn.nukkit.nbt.tag.CompoundTag; 8 | import nukkitcoders.mobplugin.entities.animal.WalkingAnimal; 9 | import nukkitcoders.mobplugin.utils.Utils; 10 | 11 | public class Ocelot extends WalkingAnimal { 12 | 13 | public static final int NETWORK_ID = 22; 14 | 15 | public Ocelot(FullChunk chunk, CompoundTag nbt) { 16 | super(chunk, nbt); 17 | } 18 | 19 | @Override 20 | public int getNetworkId() { 21 | return NETWORK_ID; 22 | } 23 | 24 | @Override 25 | public float getWidth() { 26 | if (this.isBaby()) { 27 | return 0.3f; 28 | } 29 | return 0.6f; 30 | } 31 | 32 | @Override 33 | public float getHeight() { 34 | if (this.isBaby()) { 35 | return 0.35f; 36 | } 37 | return 0.7f; 38 | } 39 | 40 | @Override 41 | public double getSpeed() { 42 | return 1.4; 43 | } 44 | 45 | @Override 46 | protected void initEntity() { 47 | this.setMaxHealth(10); 48 | super.initEntity(); 49 | this.noFallDamage = true; 50 | } 51 | 52 | @Override 53 | public boolean targetOption(EntityCreature creature, double distance) { 54 | if (creature instanceof Player) { 55 | Player player = (Player) creature; 56 | return player.spawned && player.isAlive() && !player.closed && (player.getInventory().getItemInHand().getId() == Item.RAW_FISH || player.getInventory().getItemInHand().getId() == Item.RAW_SALMON) && distance <= 49; 57 | } 58 | return false; 59 | } 60 | 61 | public int getKillExperience() { 62 | return this.isBaby() ? 0 : Utils.rand(1, 3); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/walking/Panda.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.walking; 2 | 3 | import cn.nukkit.level.format.FullChunk; 4 | import cn.nukkit.nbt.tag.CompoundTag; 5 | import nukkitcoders.mobplugin.entities.animal.WalkingAnimal; 6 | import nukkitcoders.mobplugin.utils.Utils; 7 | 8 | public class Panda extends WalkingAnimal { 9 | 10 | public static final int NETWORK_ID = 113; 11 | 12 | public Panda(FullChunk chunk, CompoundTag nbt) { 13 | super(chunk, nbt); 14 | } 15 | 16 | @Override 17 | public int getNetworkId() { 18 | return NETWORK_ID; 19 | } 20 | 21 | @Override 22 | public float getLength() { 23 | return 1.825f; 24 | } 25 | 26 | @Override 27 | public float getWidth() { 28 | return 1.125f; 29 | } 30 | 31 | @Override 32 | public float getHeight() { 33 | return 1.25f; 34 | } 35 | 36 | @Override 37 | public void initEntity() { 38 | this.setMaxHealth(20); 39 | super.initEntity(); 40 | } 41 | 42 | @Override 43 | public int getKillExperience() { 44 | return this.isBaby() ? 0 : Utils.rand(1, 3); 45 | } 46 | } -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/walking/SkeletonHorse.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.walking; 2 | 3 | import cn.nukkit.entity.EntityCreature; 4 | import cn.nukkit.entity.EntitySmite; 5 | import cn.nukkit.item.Item; 6 | import cn.nukkit.level.format.FullChunk; 7 | import cn.nukkit.nbt.tag.CompoundTag; 8 | import nukkitcoders.mobplugin.entities.HorseBase; 9 | import nukkitcoders.mobplugin.utils.Utils; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | /** 15 | * @author Michael Gertz 16 | */ 17 | public class SkeletonHorse extends HorseBase implements EntitySmite { 18 | 19 | public static final int NETWORK_ID = 26; 20 | 21 | public SkeletonHorse(FullChunk chunk, CompoundTag nbt) { 22 | super(chunk, nbt); 23 | } 24 | 25 | @Override 26 | public int getNetworkId() { 27 | return NETWORK_ID; 28 | } 29 | 30 | @Override 31 | public float getWidth() { 32 | if (this.isBaby()) { 33 | return 0.6982f; 34 | } 35 | return 1.3965f; 36 | } 37 | 38 | @Override 39 | public float getHeight() { 40 | if (this.isBaby()) { 41 | return 0.8f; 42 | } 43 | return 1.6f; 44 | } 45 | 46 | @Override 47 | public void initEntity() { 48 | this.setMaxHealth(15); 49 | super.initEntity(); 50 | } 51 | 52 | @Override 53 | public Item[] getDrops() { 54 | List drops = new ArrayList<>(); 55 | 56 | if (!this.isBaby()) { 57 | drops.add(Item.get(Item.LEATHER, 0, Utils.rand(0, 2))); 58 | drops.add(Item.get(Item.BONE, 0, Utils.rand(0, 1))); 59 | } 60 | 61 | if (this.isSaddled()) { 62 | drops.add(Item.get(Item.SADDLE, 0, 1)); 63 | } 64 | 65 | return drops.toArray(new Item[0]); 66 | } 67 | 68 | @Override 69 | public String getName() { 70 | return this.hasCustomName() ? this.getNameTag() : "Skeleton Horse"; 71 | } 72 | 73 | @Override 74 | public boolean isFeedItem(Item item) { 75 | return false; 76 | } 77 | 78 | @Override 79 | public boolean targetOption(EntityCreature creature, double distance) { 80 | return false; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/walking/Villager.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.walking; 2 | 3 | import cn.nukkit.entity.Entity; 4 | import cn.nukkit.entity.mob.EntityWitch; 5 | import cn.nukkit.event.entity.CreatureSpawnEvent; 6 | import cn.nukkit.level.format.FullChunk; 7 | import cn.nukkit.nbt.tag.CompoundTag; 8 | import nukkitcoders.mobplugin.entities.animal.WalkingAnimal; 9 | 10 | import static cn.nukkit.entity.passive.EntityVillagerV1.PROFESSION_GENERIC; 11 | 12 | public class Villager extends WalkingAnimal { 13 | 14 | public static final int NETWORK_ID = 15; 15 | 16 | public Villager(FullChunk chunk, CompoundTag nbt) { 17 | super(chunk, nbt); 18 | } 19 | 20 | @Override 21 | public int getNetworkId() { 22 | return NETWORK_ID; 23 | } 24 | 25 | @Override 26 | public float getWidth() { 27 | if (this.isBaby()) { 28 | return 0.3f; 29 | } 30 | return 0.6f; 31 | } 32 | 33 | @Override 34 | public float getHeight() { 35 | if (this.isBaby()) { 36 | return 0.975f; 37 | } 38 | return 1.95f; 39 | } 40 | 41 | @Override 42 | public double getSpeed() { 43 | return 1.1; 44 | } 45 | 46 | @Override 47 | public void initEntity() { 48 | this.setMaxHealth(10); 49 | super.initEntity(); 50 | 51 | if (!this.namedTag.contains("Profession")) { 52 | this.setProfession(PROFESSION_GENERIC); 53 | } 54 | } 55 | 56 | public int getProfession() { 57 | return this.namedTag.getInt("Profession"); 58 | } 59 | 60 | public void setProfession(int profession) { 61 | this.namedTag.putInt("Profession", profession); 62 | } 63 | 64 | @Override 65 | public int getKillExperience() { 66 | return 0; 67 | } 68 | 69 | @Override 70 | public void onStruckByLightning(Entity entity) { 71 | Entity ent = Entity.createEntity("Witch", this); 72 | if (ent != null) { 73 | CreatureSpawnEvent cse = new CreatureSpawnEvent(EntityWitch.NETWORK_ID, this, ent.namedTag, CreatureSpawnEvent.SpawnReason.LIGHTNING); 74 | this.getServer().getPluginManager().callEvent(cse); 75 | 76 | if (cse.isCancelled()) { 77 | ent.close(); 78 | return; 79 | } 80 | 81 | ent.yaw = this.yaw; 82 | ent.pitch = this.pitch; 83 | ent.setImmobile(this.isImmobile()); 84 | if (this.hasCustomName()) { 85 | ent.setNameTag(this.getNameTag()); 86 | ent.setNameTagVisible(this.isNameTagVisible()); 87 | ent.setNameTagAlwaysVisible(this.isNameTagAlwaysVisible()); 88 | } 89 | 90 | this.close(); 91 | ent.spawnToAll(); 92 | } else { 93 | super.onStruckByLightning(entity); 94 | } 95 | } 96 | 97 | @Override 98 | public boolean canDespawn() { 99 | return false; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/walking/VillagerV2.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.walking; 2 | 3 | import cn.nukkit.level.format.FullChunk; 4 | import cn.nukkit.nbt.tag.CompoundTag; 5 | 6 | public class VillagerV2 extends Villager { 7 | 8 | public static final int NETWORK_ID = 115; 9 | 10 | public VillagerV2(FullChunk chunk, CompoundTag nbt) { 11 | super(chunk, nbt); 12 | } 13 | 14 | @Override 15 | public int getNetworkId() { 16 | return NETWORK_ID; 17 | } 18 | 19 | @Override 20 | public String getName() { 21 | return this.hasCustomName() ? this.getNameTag() : "Villager"; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/walking/WanderingTrader.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.walking; 2 | 3 | import cn.nukkit.level.format.FullChunk; 4 | import cn.nukkit.nbt.tag.CompoundTag; 5 | import nukkitcoders.mobplugin.entities.animal.WalkingAnimal; 6 | 7 | public class WanderingTrader extends WalkingAnimal { 8 | 9 | public static final int NETWORK_ID = 118; 10 | 11 | public WanderingTrader(FullChunk chunk, CompoundTag nbt) { 12 | super(chunk, nbt); 13 | } 14 | 15 | @Override 16 | public int getNetworkId() { 17 | return NETWORK_ID; 18 | } 19 | 20 | @Override 21 | public float getWidth() { 22 | return 0.6f; 23 | } 24 | 25 | @Override 26 | public float getHeight() { 27 | return 1.95f; 28 | } 29 | 30 | @Override 31 | public void initEntity() { 32 | this.setMaxHealth(20); 33 | super.initEntity(); 34 | } 35 | 36 | @Override 37 | public int getKillExperience() { 38 | return 0; 39 | } 40 | 41 | @Override 42 | public String getName() { 43 | return this.hasCustomName() ? this.getNameTag() : "Wandering Trader"; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/animal/walking/ZombieHorse.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.animal.walking; 2 | 3 | import cn.nukkit.entity.EntitySmite; 4 | import cn.nukkit.item.Item; 5 | import cn.nukkit.level.format.FullChunk; 6 | import cn.nukkit.nbt.tag.CompoundTag; 7 | import nukkitcoders.mobplugin.entities.HorseBase; 8 | import nukkitcoders.mobplugin.utils.Utils; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | /** 14 | * @author Michael Gertz 15 | */ 16 | public class ZombieHorse extends HorseBase implements EntitySmite { 17 | 18 | public static final int NETWORK_ID = 27; 19 | 20 | public ZombieHorse(FullChunk chunk, CompoundTag nbt) { 21 | super(chunk, nbt); 22 | } 23 | 24 | @Override 25 | public int getNetworkId() { 26 | return NETWORK_ID; 27 | } 28 | 29 | @Override 30 | public float getWidth() { 31 | if (this.isBaby()) { 32 | return 0.6982f; 33 | } 34 | return 1.3965f; 35 | } 36 | 37 | @Override 38 | public float getHeight() { 39 | if (this.isBaby()) { 40 | return 0.8f; 41 | } 42 | return 1.6f; 43 | } 44 | 45 | @Override 46 | public void initEntity() { 47 | this.setMaxHealth(15); 48 | super.initEntity(); 49 | } 50 | 51 | @Override 52 | public Item[] getDrops() { 53 | List drops = new ArrayList<>(); 54 | 55 | if (!this.isBaby()) { 56 | drops.add(Item.get(Item.LEATHER, 0, Utils.rand(0, 2))); 57 | drops.add(Item.get(Item.ROTTEN_FLESH, 0, Utils.rand(0, 2))); 58 | } 59 | 60 | if (this.isSaddled()) { 61 | drops.add(Item.get(Item.SADDLE, 0, 1)); 62 | } 63 | 64 | return drops.toArray(new Item[0]); 65 | } 66 | 67 | @Override 68 | public String getName() { 69 | return this.hasCustomName() ? this.getNameTag() : "Zombie Horse"; 70 | } 71 | 72 | @Override 73 | public boolean isFeedItem(Item item) { 74 | return false; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/autospawn/IEntitySpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.autospawn; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.level.Level; 5 | import cn.nukkit.level.Position; 6 | 7 | /** 8 | * @author Michael Gertz 9 | */ 10 | public interface IEntitySpawner { 11 | 12 | void spawn(); 13 | 14 | void spawn(Player player, Position pos, Level level); 15 | 16 | int getEntityNetworkId(); 17 | 18 | default boolean isWaterMob() { 19 | return false; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/monster/Monster.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.monster; 2 | 3 | import cn.nukkit.entity.Entity; 4 | import cn.nukkit.item.Item; 5 | 6 | import java.util.HashMap; 7 | 8 | public interface Monster { 9 | 10 | void attackEntity(Entity player); 11 | 12 | float getDamage(); 13 | 14 | float getDamage(Integer difficulty); 15 | 16 | float getMinDamage(); 17 | 18 | float getMinDamage(Integer difficulty); 19 | 20 | float getMaxDamage(); 21 | 22 | float getMaxDamage(Integer difficulty); 23 | 24 | @Deprecated 25 | void setDamage(float damage); 26 | 27 | void setDamage(float[] damage); 28 | 29 | void setDamage(float damage, int difficulty); 30 | 31 | @Deprecated 32 | void setMinDamage(float damage); 33 | 34 | void setMinDamage(float[] damage); 35 | 36 | void setMinDamage(float damage, int difficulty); 37 | 38 | @Deprecated 39 | void setMaxDamage(float damage); 40 | 41 | void setMaxDamage(float[] damage); 42 | 43 | void setMaxDamage(float damage, int difficulty); 44 | 45 | final class ArmorPoints extends HashMap { 46 | { 47 | put(Item.LEATHER_CAP, 1f); 48 | put(Item.LEATHER_TUNIC, 3f); 49 | put(Item.LEATHER_PANTS, 2f); 50 | put(Item.LEATHER_BOOTS, 1f); 51 | put(Item.CHAIN_HELMET, 1f); 52 | put(Item.CHAIN_CHESTPLATE, 5f); 53 | put(Item.CHAIN_LEGGINGS, 4f); 54 | put(Item.CHAIN_BOOTS, 1f); 55 | put(Item.GOLD_HELMET, 1f); 56 | put(Item.GOLD_CHESTPLATE, 5f); 57 | put(Item.GOLD_LEGGINGS, 3f); 58 | put(Item.GOLD_BOOTS, 1f); 59 | put(Item.IRON_HELMET, 2f); 60 | put(Item.IRON_CHESTPLATE, 6f); 61 | put(Item.IRON_LEGGINGS, 5f); 62 | put(Item.IRON_BOOTS, 2f); 63 | put(Item.DIAMOND_HELMET, 3f); 64 | put(Item.DIAMOND_CHESTPLATE, 8f); 65 | put(Item.DIAMOND_LEGGINGS, 6f); 66 | put(Item.DIAMOND_BOOTS, 3f); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/monster/flying/Phantom.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.monster.flying; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.entity.Entity; 5 | import cn.nukkit.entity.EntityCreature; 6 | import cn.nukkit.entity.EntitySmite; 7 | import cn.nukkit.event.entity.EntityDamageEvent; 8 | import cn.nukkit.event.entity.EntityDamageByEntityEvent; 9 | import cn.nukkit.item.Item; 10 | import cn.nukkit.level.format.FullChunk; 11 | import cn.nukkit.nbt.tag.CompoundTag; 12 | import nukkitcoders.mobplugin.entities.monster.FlyingMonster; 13 | import nukkitcoders.mobplugin.utils.Utils; 14 | 15 | import java.util.HashMap; 16 | 17 | public class Phantom extends FlyingMonster implements EntitySmite { 18 | 19 | public static final int NETWORK_ID = 58; 20 | 21 | public Phantom(FullChunk chunk, CompoundTag nbt) { 22 | super(chunk, nbt); 23 | } 24 | 25 | @Override 26 | public int getNetworkId() { 27 | return NETWORK_ID; 28 | } 29 | 30 | @Override 31 | public float getWidth() { 32 | return 0.9f; 33 | } 34 | 35 | @Override 36 | public float getHeight() { 37 | return 0.5f; 38 | } 39 | 40 | @Override 41 | public double getSpeed() { 42 | return 1.1; 43 | } 44 | 45 | @Override 46 | public void initEntity() { 47 | this.setMaxHealth(20); 48 | super.initEntity(); 49 | 50 | this.setDamage(new float[] { 0, 4, 6, 9 }); 51 | } 52 | 53 | public boolean targetOption(EntityCreature creature, double distance) { 54 | if (creature instanceof Player) { 55 | Player player = (Player) creature; 56 | return player.spawned && player.isAlive() && !player.closed && (player.isSurvival() || player.isAdventure()) && distance <= 1024; 57 | } 58 | return creature.isAlive() && !creature.closed && distance <= 1024; 59 | } 60 | 61 | @Override 62 | public void attackEntity(Entity player) { 63 | if (this.attackDelay > 23 && player.distanceSquared(this) <= 1) { 64 | this.attackDelay = 0; 65 | HashMap damage = new HashMap<>(); 66 | damage.put(EntityDamageEvent.DamageModifier.BASE, this.getDamage()); 67 | 68 | if (player instanceof Player) { 69 | float points = 0; 70 | for (Item i : ((Player) player).getInventory().getArmorContents()) { 71 | points += this.getArmorPoints(i.getId()); 72 | } 73 | 74 | damage.put(EntityDamageEvent.DamageModifier.ARMOR, 75 | (float) (damage.getOrDefault(EntityDamageEvent.DamageModifier.ARMOR, 0f) - Math.floor(damage.getOrDefault(EntityDamageEvent.DamageModifier.BASE, 1f) * points * 0.04))); 76 | } 77 | player.attack(new EntityDamageByEntityEvent(this, player, EntityDamageEvent.DamageCause.ENTITY_ATTACK, damage)); 78 | } 79 | } 80 | 81 | @Override 82 | public Item[] getDrops() { 83 | return new Item[]{Item.get(Item.PHANTOM_MEMBRANE, 0, Utils.rand(0, 1))}; 84 | } 85 | 86 | @Override 87 | public int getKillExperience() { 88 | return 5; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/monster/flying/Vex.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.monster.flying; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.entity.Entity; 5 | import cn.nukkit.event.entity.EntityDamageEvent; 6 | import cn.nukkit.event.entity.EntityDamageByEntityEvent; 7 | import cn.nukkit.item.Item; 8 | import cn.nukkit.item.ItemSwordIron; 9 | import cn.nukkit.level.format.FullChunk; 10 | import cn.nukkit.nbt.tag.CompoundTag; 11 | import cn.nukkit.network.protocol.MobEquipmentPacket; 12 | import nukkitcoders.mobplugin.entities.monster.FlyingMonster; 13 | 14 | import java.util.HashMap; 15 | 16 | public class Vex extends FlyingMonster { 17 | 18 | public static final int NETWORK_ID = 105; 19 | 20 | public Vex(FullChunk chunk, CompoundTag nbt) { 21 | super(chunk, nbt); 22 | } 23 | 24 | @Override 25 | public int getNetworkId() { 26 | return NETWORK_ID; 27 | } 28 | 29 | @Override 30 | public float getWidth() { 31 | return 0.8f; 32 | } 33 | 34 | @Override 35 | public float getHeight() { 36 | return 0.4f; 37 | } 38 | 39 | @Override 40 | public void initEntity() { 41 | this.setMaxHealth(14); 42 | super.initEntity(); 43 | this.setDamage(new float[] { 0, 5, 9, 13 }); 44 | } 45 | 46 | @Override 47 | public int getKillExperience() { 48 | return this.isBaby() ? 0 : 3; 49 | } 50 | 51 | @Override 52 | public void attackEntity(Entity player) { 53 | if (this.attackDelay > 23 && this.distanceSquared(player) < 1.44) { 54 | this.attackDelay = 0; 55 | HashMap damage = new HashMap<>(); 56 | damage.put(EntityDamageEvent.DamageModifier.BASE, this.getDamage()); 57 | 58 | if (player instanceof Player) { 59 | float points = 0; 60 | for (Item i : ((Player) player).getInventory().getArmorContents()) { 61 | points += this.getArmorPoints(i.getId()); 62 | } 63 | 64 | damage.put(EntityDamageEvent.DamageModifier.ARMOR, 65 | (float) (damage.getOrDefault(EntityDamageEvent.DamageModifier.ARMOR, 0f) - Math.floor(damage.getOrDefault(EntityDamageEvent.DamageModifier.BASE, 1f) * points * 0.04))); 66 | } 67 | player.attack(new EntityDamageByEntityEvent(this, player, EntityDamageEvent.DamageCause.ENTITY_ATTACK, damage)); 68 | } 69 | } 70 | 71 | @Override 72 | public void spawnTo(Player player) { 73 | super.spawnTo(player); 74 | 75 | MobEquipmentPacket pk = new MobEquipmentPacket(); 76 | pk.eid = this.getId(); 77 | pk.item = new ItemSwordIron(); 78 | pk.hotbarSlot = 10; 79 | player.dataPacket(pk); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/monster/swimming/ElderGuardian.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.monster.swimming; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.BlockSponge; 5 | import cn.nukkit.entity.Entity; 6 | import cn.nukkit.entity.EntityCreature; 7 | import cn.nukkit.event.entity.EntityDamageByEntityEvent; 8 | import cn.nukkit.item.Item; 9 | import cn.nukkit.level.format.FullChunk; 10 | import cn.nukkit.nbt.tag.CompoundTag; 11 | import cn.nukkit.network.protocol.LevelEventPacket; 12 | import cn.nukkit.potion.Effect; 13 | import nukkitcoders.mobplugin.entities.monster.SwimmingMonster; 14 | import nukkitcoders.mobplugin.utils.Utils; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | public class ElderGuardian extends SwimmingMonster { 20 | 21 | public static final int NETWORK_ID = 50; 22 | 23 | public ElderGuardian(FullChunk chunk, CompoundTag nbt) { 24 | super(chunk, nbt); 25 | } 26 | 27 | @Override 28 | public int getNetworkId() { 29 | return NETWORK_ID; 30 | } 31 | 32 | @Override 33 | public float getWidth() { 34 | return 1.9975f; 35 | } 36 | 37 | @Override 38 | public float getHeight() { 39 | return 1.9975f; 40 | } 41 | 42 | @Override 43 | public void initEntity() { 44 | this.setMaxHealth(80); 45 | super.initEntity(); 46 | 47 | this.setDataFlag(DATA_FLAGS, DATA_FLAG_ELDER, true); 48 | } 49 | 50 | @Override 51 | public boolean targetOption(EntityCreature creature, double distance) { 52 | return false; 53 | } 54 | 55 | @Override 56 | public void attackEntity(Entity player) { 57 | } 58 | 59 | @Override 60 | public Item[] getDrops() { 61 | List drops = new ArrayList<>(); 62 | 63 | drops.add(Item.get(Item.PRISMARINE_SHARD, 0, Utils.rand(0, 2))); 64 | 65 | if (this.lastDamageCause instanceof EntityDamageByEntityEvent) { 66 | if (((EntityDamageByEntityEvent) this.lastDamageCause).getDamager() instanceof Player) { 67 | drops.add(Item.get(Item.SPONGE, BlockSponge.WET, 1)); 68 | } 69 | } 70 | 71 | return drops.toArray(new Item[0]); 72 | } 73 | 74 | @Override 75 | public int getKillExperience() { 76 | return 10; 77 | } 78 | 79 | @Override 80 | public String getName() { 81 | return this.hasCustomName() ? this.getNameTag() : "Elder Guardian"; 82 | } 83 | 84 | @Override 85 | public boolean entityBaseTick(int tickDiff) { 86 | boolean result = super.entityBaseTick(tickDiff); 87 | if (!this.closed && this.ticksLived % 1200 == 0 && this.isAlive()) { 88 | for (Player p : this.level.getPlayers().values()) { 89 | if (p.getGamemode() % 2 == 0 && p.distanceSquared(this) < 2500 && !p.hasEffect(Effect.MINING_FATIGUE)) { 90 | p.addEffect(Effect.getEffect(Effect.MINING_FATIGUE).setAmplifier(2).setDuration(6000)); 91 | LevelEventPacket pk = new LevelEventPacket(); 92 | pk.evid = LevelEventPacket.EVENT_GUARDIAN_CURSE; 93 | pk.x = (float) this.x; 94 | pk.y = (float) this.y; 95 | pk.z = (float) this.z; 96 | p.dataPacket(pk); 97 | } 98 | } 99 | } 100 | return result; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/monster/swimming/Guardian.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.monster.swimming; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.entity.Entity; 5 | import cn.nukkit.entity.EntityCreature; 6 | import cn.nukkit.entity.data.LongEntityData; 7 | import cn.nukkit.event.entity.EntityDamageByEntityEvent; 8 | import cn.nukkit.event.entity.EntityDamageEvent; 9 | import cn.nukkit.item.Item; 10 | import cn.nukkit.level.format.FullChunk; 11 | import cn.nukkit.nbt.tag.CompoundTag; 12 | import nukkitcoders.mobplugin.entities.animal.swimming.Squid; 13 | import nukkitcoders.mobplugin.entities.monster.SwimmingMonster; 14 | import nukkitcoders.mobplugin.utils.Utils; 15 | 16 | import java.util.HashMap; 17 | 18 | public class Guardian extends SwimmingMonster { 19 | 20 | public static final int NETWORK_ID = 49; 21 | private int laserChargeTick = 40; 22 | private long laserTargetEid = -1; 23 | 24 | public Guardian(FullChunk chunk, CompoundTag nbt) { 25 | super(chunk, nbt); 26 | } 27 | 28 | @Override 29 | public int getNetworkId() { 30 | return NETWORK_ID; 31 | } 32 | 33 | @Override 34 | public float getWidth() { 35 | return 0.85f; 36 | } 37 | 38 | @Override 39 | public float getHeight() { 40 | return 0.85f; 41 | } 42 | 43 | @Override 44 | public void initEntity() { 45 | this.setMaxHealth(30); 46 | super.initEntity(); 47 | } 48 | 49 | @Override 50 | public boolean targetOption(EntityCreature creature, double distance) { 51 | if (creature instanceof Player) { 52 | Player player = (Player) creature; 53 | return (!player.closed) && player.spawned && player.isAlive() && (player.isSurvival() || player.isAdventure()) && distance <= 100; 54 | } else if (creature instanceof Squid) { 55 | return creature.isAlive() && this.distanceSquared(creature) <= 80; 56 | } 57 | return false; 58 | } 59 | 60 | @Override 61 | public void attackEntity(Entity player) { 62 | HashMap damage = new HashMap<>(); 63 | damage.put(EntityDamageEvent.DamageModifier.BASE, 1F); 64 | 65 | float points = 0; 66 | for (Item i : ((Player) player).getInventory().getArmorContents()) { 67 | points += this.getArmorPoints(i.getId()); 68 | } 69 | 70 | damage.put(EntityDamageEvent.DamageModifier.ARMOR, 71 | (float) (damage.getOrDefault(EntityDamageEvent.DamageModifier.ARMOR, 0f) - Math.floor(damage.getOrDefault(EntityDamageEvent.DamageModifier.BASE, 1f) * points * 0.04))); 72 | player.attack(new EntityDamageByEntityEvent(this, player, EntityDamageEvent.DamageCause.MAGIC, damage)); 73 | 74 | } 75 | 76 | @Override 77 | public boolean entityBaseTick(int tickDiff) { 78 | if (getServer().getDifficulty() == 0) { 79 | this.close(); 80 | return true; 81 | } 82 | 83 | boolean hasUpdate = super.entityBaseTick(tickDiff); 84 | if (!this.closed && followTarget != null) { 85 | if (laserTargetEid !=followTarget.getId()) { 86 | this.setDataProperty(new LongEntityData(Entity.DATA_TARGET_EID, laserTargetEid = followTarget.getId())); 87 | laserChargeTick = 40; 88 | } 89 | if (targetOption((EntityCreature) followTarget, this.distanceSquared(followTarget))) { 90 | if (--laserChargeTick < 0) { 91 | attackEntity(followTarget); 92 | this.setDataProperty(new LongEntityData(Entity.DATA_TARGET_EID, laserTargetEid = -1)); 93 | laserChargeTick = 40; 94 | } 95 | } else { 96 | this.setDataProperty(new LongEntityData(Entity.DATA_TARGET_EID, laserTargetEid = -1)); 97 | laserChargeTick = 40; 98 | } 99 | } 100 | return hasUpdate; 101 | } 102 | 103 | @Override 104 | public Item[] getDrops() { 105 | return new Item[]{Item.get(Item.PRISMARINE_SHARD, 0, Utils.rand(0, 2))}; 106 | } 107 | 108 | @Override 109 | public int getKillExperience() { 110 | return 10; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/monster/walking/CaveSpider.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.monster.walking; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.entity.Entity; 5 | import cn.nukkit.entity.EntityArthropod; 6 | import cn.nukkit.event.entity.EntityDamageByEntityEvent; 7 | import cn.nukkit.event.entity.EntityDamageEvent; 8 | import cn.nukkit.item.Item; 9 | import cn.nukkit.level.format.FullChunk; 10 | import cn.nukkit.nbt.tag.CompoundTag; 11 | import cn.nukkit.potion.Effect; 12 | import nukkitcoders.mobplugin.utils.Utils; 13 | 14 | import java.util.ArrayList; 15 | import java.util.HashMap; 16 | import java.util.List; 17 | 18 | public class CaveSpider extends Spider implements EntityArthropod { 19 | 20 | public static final int NETWORK_ID = 40; 21 | 22 | public CaveSpider(FullChunk chunk, CompoundTag nbt) { 23 | super(chunk, nbt); 24 | } 25 | 26 | @Override 27 | public int getNetworkId() { 28 | return NETWORK_ID; 29 | } 30 | 31 | @Override 32 | public float getWidth() { 33 | return 0.7f; 34 | } 35 | 36 | @Override 37 | public float getHeight() { 38 | return 0.5f; 39 | } 40 | 41 | @Override 42 | public double getSpeed() { 43 | return 1.3; 44 | } 45 | 46 | @Override 47 | public void initEntity() { 48 | this.setMaxHealth(12); 49 | super.initEntity(); 50 | 51 | this.setDamage(new float[] { 0, 2, 3, 3 }); 52 | } 53 | 54 | @Override 55 | public void attackEntity(Entity player) { 56 | if (this.attackDelay > 23 && this.distanceSquared(player) < 1.32) { 57 | this.attackDelay = 0; 58 | HashMap damage = new HashMap<>(); 59 | damage.put(EntityDamageEvent.DamageModifier.BASE, this.getDamage()); 60 | 61 | if (player instanceof Player) { 62 | float points = 0; 63 | for (Item i : ((Player) player).getInventory().getArmorContents()) { 64 | points += this.getArmorPoints(i.getId()); 65 | } 66 | 67 | damage.put(EntityDamageEvent.DamageModifier.ARMOR, 68 | (float) (damage.getOrDefault(EntityDamageEvent.DamageModifier.ARMOR, 0f) - Math.floor(damage.getOrDefault(EntityDamageEvent.DamageModifier.BASE, 1f) * points * 0.04))); 69 | } 70 | EntityDamageByEntityEvent ev = new EntityDamageByEntityEvent(this, player, EntityDamageEvent.DamageCause.ENTITY_ATTACK, damage); 71 | if (player.attack(ev) && !ev.isCancelled() && this.server.getDifficulty() > 0) { 72 | player.addEffect(Effect.getEffect(Effect.POISON).setDuration(this.server.getDifficulty() > 1 ? 300 : 140)); 73 | } 74 | } 75 | } 76 | 77 | @Override 78 | public Item[] getDrops() { 79 | List drops = new ArrayList<>(); 80 | 81 | drops.add(Item.get(Item.STRING, 0, Utils.rand(0, 2))); 82 | drops.add(Item.get(Item.SPIDER_EYE, 0, Utils.rand(0, 2) == 0 ? 1 : 0)); 83 | 84 | return drops.toArray(new Item[0]); 85 | } 86 | 87 | @Override 88 | public int getKillExperience() { 89 | return 5; 90 | } 91 | 92 | @Override 93 | public String getName() { 94 | return this.hasCustomName() ? this.getNameTag() : "Cave Spider"; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/monster/walking/Endermite.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.monster.walking; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.entity.Entity; 5 | import cn.nukkit.entity.EntityArthropod; 6 | import cn.nukkit.event.entity.EntityDamageByEntityEvent; 7 | import cn.nukkit.event.entity.EntityDamageEvent; 8 | import cn.nukkit.item.Item; 9 | import cn.nukkit.level.format.FullChunk; 10 | import cn.nukkit.nbt.tag.CompoundTag; 11 | import nukkitcoders.mobplugin.entities.monster.WalkingMonster; 12 | 13 | import java.util.HashMap; 14 | 15 | public class Endermite extends WalkingMonster implements EntityArthropod { 16 | 17 | public static final int NETWORK_ID = 55; 18 | 19 | public Endermite(FullChunk chunk, CompoundTag nbt) { 20 | super(chunk, nbt); 21 | } 22 | 23 | @Override 24 | public int getNetworkId() { 25 | return NETWORK_ID; 26 | } 27 | 28 | @Override 29 | public float getWidth() { 30 | return 0.4f; 31 | } 32 | 33 | @Override 34 | public float getHeight() { 35 | return 0.3f; 36 | } 37 | 38 | @Override 39 | public double getSpeed() { 40 | return 1.1; 41 | } 42 | 43 | @Override 44 | public void initEntity() { 45 | this.setMaxHealth(8); 46 | super.initEntity(); 47 | 48 | this.setDamage(new float[] { 0, 1, 1, 1 }); 49 | } 50 | 51 | @Override 52 | public void attackEntity(Entity player) { 53 | if (this.attackDelay > 23 && this.distanceSquared(player) < 1) { 54 | this.attackDelay = 0; 55 | HashMap damage = new HashMap<>(); 56 | damage.put(EntityDamageEvent.DamageModifier.BASE, this.getDamage()); 57 | 58 | if (player instanceof Player) { 59 | float points = 0; 60 | for (Item i : ((Player) player).getInventory().getArmorContents()) { 61 | points += this.getArmorPoints(i.getId()); 62 | } 63 | 64 | damage.put(EntityDamageEvent.DamageModifier.ARMOR, 65 | (float) (damage.getOrDefault(EntityDamageEvent.DamageModifier.ARMOR, 0f) - Math.floor(damage.getOrDefault(EntityDamageEvent.DamageModifier.BASE, 1f) * points * 0.04))); 66 | } 67 | player.attack(new EntityDamageByEntityEvent(this, player, EntityDamageEvent.DamageCause.ENTITY_ATTACK, damage)); 68 | } 69 | } 70 | 71 | @Override 72 | public int getKillExperience() { 73 | return 3; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/monster/walking/Evoker.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.monster.walking; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.entity.Entity; 5 | import cn.nukkit.event.entity.EntityDamageByEntityEvent; 6 | import cn.nukkit.event.entity.EntityDamageEvent; 7 | import cn.nukkit.item.Item; 8 | import cn.nukkit.level.format.FullChunk; 9 | import cn.nukkit.nbt.tag.CompoundTag; 10 | import nukkitcoders.mobplugin.entities.monster.WalkingMonster; 11 | import nukkitcoders.mobplugin.utils.Utils; 12 | 13 | import java.util.ArrayList; 14 | import java.util.HashMap; 15 | import java.util.List; 16 | 17 | public class Evoker extends WalkingMonster { 18 | 19 | public static final int NETWORK_ID = 104; 20 | 21 | public Evoker(FullChunk chunk, CompoundTag nbt) { 22 | super(chunk, nbt); 23 | } 24 | 25 | @Override 26 | public int getNetworkId() { 27 | return NETWORK_ID; 28 | } 29 | 30 | @Override 31 | public float getWidth() { 32 | return 0.6f; 33 | } 34 | 35 | @Override 36 | public float getHeight() { 37 | return 1.95f; 38 | } 39 | 40 | @Override 41 | public double getSpeed() { 42 | return 1.1; 43 | } 44 | 45 | @Override 46 | protected void initEntity() { 47 | this.setMaxHealth(24); 48 | super.initEntity(); 49 | this.setDamage(new float[] { 0, 2, 3, 4 }); 50 | } 51 | 52 | @Override 53 | public void attackEntity(Entity player) { 54 | if (this.attackDelay > 23 && player.distanceSquared(this) <= 1) { 55 | this.attackDelay = 0; 56 | HashMap damage = new HashMap<>(); 57 | damage.put(EntityDamageEvent.DamageModifier.BASE, this.getDamage()); 58 | 59 | if (player instanceof Player) { 60 | float points = 0; 61 | for (Item i : ((Player) player).getInventory().getArmorContents()) { 62 | points += this.getArmorPoints(i.getId()); 63 | } 64 | 65 | damage.put(EntityDamageEvent.DamageModifier.ARMOR, 66 | (float) (damage.getOrDefault(EntityDamageEvent.DamageModifier.ARMOR, 0f) - Math.floor(damage.getOrDefault(EntityDamageEvent.DamageModifier.BASE, 1f) * points * 0.04))); 67 | } 68 | player.attack(new EntityDamageByEntityEvent(this, player, EntityDamageEvent.DamageCause.ENTITY_ATTACK, damage)); 69 | } 70 | } 71 | 72 | @Override 73 | public Item[] getDrops() { 74 | List drops = new ArrayList<>(); 75 | 76 | drops.add(Item.get(Item.EMERALD, 0, Utils.rand(0, 1))); 77 | drops.add(Item.get(Item.TOTEM, 0, 1)); 78 | 79 | return drops.toArray(new Item[0]); 80 | } 81 | 82 | @Override 83 | public int getKillExperience() { 84 | return 10; 85 | } 86 | 87 | @Override 88 | public int nearbyDistanceMultiplier() { 89 | return 20; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/monster/walking/Hoglin.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.monster.walking; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.entity.Entity; 5 | import cn.nukkit.event.entity.EntityDamageByEntityEvent; 6 | import cn.nukkit.event.entity.EntityDamageEvent; 7 | import cn.nukkit.item.Item; 8 | import cn.nukkit.level.format.FullChunk; 9 | import cn.nukkit.nbt.tag.CompoundTag; 10 | import nukkitcoders.mobplugin.entities.monster.WalkingMonster; 11 | import nukkitcoders.mobplugin.utils.Utils; 12 | 13 | import java.util.ArrayList; 14 | import java.util.HashMap; 15 | import java.util.List; 16 | 17 | public class Hoglin extends WalkingMonster { 18 | 19 | public final static int NETWORK_ID = 124; 20 | 21 | @Override 22 | public int getNetworkId() { 23 | return NETWORK_ID; 24 | } 25 | 26 | public Hoglin(FullChunk chunk, CompoundTag nbt) { 27 | super(chunk, nbt); 28 | } 29 | 30 | @Override 31 | public int getKillExperience() { 32 | return Utils.rand(1, 3); 33 | } 34 | 35 | @Override 36 | protected void initEntity() { 37 | this.setMaxHealth(40); 38 | super.initEntity(); 39 | this.setDamage(new float[]{0, 2, 3, 4}); 40 | } 41 | 42 | @Override 43 | public float getWidth() { 44 | return 0.9f; 45 | } 46 | 47 | @Override 48 | public float getHeight() { 49 | return 0.9f; 50 | } 51 | 52 | @Override 53 | public void attackEntity(Entity player) { 54 | if (this.attackDelay > 30 && player.distanceSquared(this) <= 1.5) { 55 | this.attackDelay = 0; 56 | HashMap damage = new HashMap<>(); 57 | damage.put(EntityDamageEvent.DamageModifier.BASE, this.getDamage()); 58 | 59 | if (player instanceof Player) { 60 | float points = 0; 61 | for (Item i : ((Player) player).getInventory().getArmorContents()) { 62 | points += this.getArmorPoints(i.getId()); 63 | } 64 | 65 | damage.put(EntityDamageEvent.DamageModifier.ARMOR, (float) (damage.getOrDefault(EntityDamageEvent.DamageModifier.ARMOR, 0f) - Math.floor(damage.getOrDefault(EntityDamageEvent.DamageModifier.BASE, 1f) * points * 0.04))); 66 | } 67 | player.attack(new EntityDamageByEntityEvent(this, player, EntityDamageEvent.DamageCause.ENTITY_ATTACK, damage)); 68 | } 69 | } 70 | 71 | @Override 72 | public Item[] getDrops() { 73 | List drops = new ArrayList<>(); 74 | 75 | if (!this.isBaby()) { 76 | for (int i = 0; i < Utils.rand(2, 4); i++) { 77 | drops.add(Item.get(this.isOnFire() ? Item.COOKED_PORKCHOP : Item.RAW_PORKCHOP, 0, 1)); 78 | } 79 | 80 | if (Utils.rand()) { 81 | drops.add(Item.get(Item.LEATHER)); 82 | } 83 | } 84 | 85 | return drops.toArray(new Item[0]); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/monster/walking/Husk.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.monster.walking; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.entity.Entity; 5 | import cn.nukkit.entity.EntityAgeable; 6 | import cn.nukkit.entity.EntitySmite; 7 | import cn.nukkit.event.entity.EntityDamageByEntityEvent; 8 | import cn.nukkit.event.entity.EntityDamageEvent; 9 | import cn.nukkit.item.Item; 10 | import cn.nukkit.level.format.FullChunk; 11 | import cn.nukkit.nbt.tag.CompoundTag; 12 | import cn.nukkit.potion.Effect; 13 | import nukkitcoders.mobplugin.entities.monster.WalkingMonster; 14 | import nukkitcoders.mobplugin.utils.Utils; 15 | 16 | import java.util.ArrayList; 17 | import java.util.HashMap; 18 | import java.util.List; 19 | 20 | public class Husk extends WalkingMonster implements EntityAgeable, EntitySmite { 21 | 22 | public static final int NETWORK_ID = 47; 23 | 24 | public Husk(FullChunk chunk, CompoundTag nbt) { 25 | super(chunk, nbt); 26 | } 27 | 28 | @Override 29 | public int getNetworkId() { 30 | return NETWORK_ID; 31 | } 32 | 33 | @Override 34 | public float getWidth() { 35 | return 0.6f; 36 | } 37 | 38 | @Override 39 | public float getHeight() { 40 | return 1.95f; 41 | } 42 | 43 | @Override 44 | public double getSpeed() { 45 | return this.isBaby() ? 1.6 : 1.1; 46 | } 47 | 48 | @Override 49 | protected void initEntity() { 50 | this.setMaxHealth(20); 51 | super.initEntity(); 52 | this.setDamage(new float[]{0, 3, 4, 6}); 53 | } 54 | 55 | @Override 56 | public void attackEntity(Entity player) { 57 | if (this.attackDelay > 23 && player.distanceSquared(this) <= 1) { 58 | this.attackDelay = 0; 59 | HashMap damage = new HashMap<>(); 60 | damage.put(EntityDamageEvent.DamageModifier.BASE, this.getDamage()); 61 | 62 | if (player instanceof Player) { 63 | float points = 0; 64 | for (Item i : ((Player) player).getInventory().getArmorContents()) { 65 | points += this.getArmorPoints(i.getId()); 66 | } 67 | 68 | damage.put(EntityDamageEvent.DamageModifier.ARMOR, 69 | (float) (damage.getOrDefault(EntityDamageEvent.DamageModifier.ARMOR, 0f) - Math.floor(damage.getOrDefault(EntityDamageEvent.DamageModifier.BASE, 1f) * points * 0.04))); 70 | } 71 | if (player.attack(new EntityDamageByEntityEvent(this, player, EntityDamageEvent.DamageCause.ENTITY_ATTACK, damage))) { 72 | player.addEffect(Effect.getEffect(Effect.HUNGER).setDuration(140)); 73 | } 74 | this.playAttack(); 75 | } 76 | } 77 | 78 | @Override 79 | public Item[] getDrops() { 80 | List drops = new ArrayList<>(); 81 | 82 | if (!this.isBaby()) { 83 | drops.add(Item.get(Item.ROTTEN_FLESH, 0, Utils.rand(0, 2))); 84 | } 85 | 86 | return drops.toArray(new Item[0]); 87 | } 88 | 89 | @Override 90 | public int getKillExperience() { 91 | return this.isBaby() ? 0 : 5; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/monster/walking/PiglinBrute.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.monster.walking; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.entity.Entity; 5 | import cn.nukkit.event.entity.EntityDamageByEntityEvent; 6 | import cn.nukkit.event.entity.EntityDamageEvent; 7 | import cn.nukkit.item.Item; 8 | import cn.nukkit.level.format.FullChunk; 9 | import cn.nukkit.nbt.tag.CompoundTag; 10 | import nukkitcoders.mobplugin.entities.monster.WalkingMonster; 11 | 12 | import java.util.HashMap; 13 | 14 | public class PiglinBrute extends WalkingMonster { 15 | 16 | public static final int NETWORK_ID = 127; 17 | 18 | public PiglinBrute(FullChunk chunk, CompoundTag nbt) { 19 | super(chunk, nbt); 20 | } 21 | 22 | @Override 23 | public void initEntity() { 24 | this.setMaxHealth(50); 25 | super.initEntity(); 26 | this.setDamage(new float[]{0, 3, 7, 10}); 27 | } 28 | 29 | @Override 30 | public float getWidth() { 31 | return 0.6f; 32 | } 33 | 34 | @Override 35 | public float getHeight() { 36 | return 1.95f; 37 | } 38 | 39 | @Override 40 | public int getKillExperience() { 41 | return 10; 42 | } 43 | 44 | @Override 45 | public int getNetworkId() { 46 | return NETWORK_ID; 47 | } 48 | 49 | @Override 50 | public void attackEntity(Entity player) { 51 | if (this.attackDelay > 23 && this.distanceSquared(player) < 1.44) { 52 | this.attackDelay = 0; 53 | HashMap damage = new HashMap<>(); 54 | damage.put(EntityDamageEvent.DamageModifier.BASE, this.getDamage()); 55 | 56 | if (player instanceof Player) { 57 | float points = 0; 58 | for (Item i : ((Player) player).getInventory().getArmorContents()) { 59 | points += this.getArmorPoints(i.getId()); 60 | } 61 | 62 | damage.put(EntityDamageEvent.DamageModifier.ARMOR, 63 | (float) (damage.getOrDefault(EntityDamageEvent.DamageModifier.ARMOR, 0f) - Math.floor(damage.getOrDefault(EntityDamageEvent.DamageModifier.BASE, 1f) * points * 0.04))); 64 | } 65 | player.attack(new EntityDamageByEntityEvent(this, player, EntityDamageEvent.DamageCause.ENTITY_ATTACK, damage)); 66 | } 67 | } 68 | 69 | @Override 70 | public String getName() { 71 | return this.hasCustomName() ? this.getNameTag() : "Piglin Brute"; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/monster/walking/Ravager.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.monster.walking; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.entity.Entity; 5 | import cn.nukkit.event.entity.EntityDamageByEntityEvent; 6 | import cn.nukkit.event.entity.EntityDamageEvent; 7 | import cn.nukkit.item.Item; 8 | import cn.nukkit.level.format.FullChunk; 9 | import cn.nukkit.nbt.tag.CompoundTag; 10 | import nukkitcoders.mobplugin.entities.monster.WalkingMonster; 11 | 12 | import java.util.HashMap; 13 | 14 | public class Ravager extends WalkingMonster { 15 | 16 | public static final int NETWORK_ID = 59; 17 | 18 | public Ravager(FullChunk chunk, CompoundTag nbt) { 19 | super(chunk, nbt); 20 | } 21 | 22 | @Override 23 | public int getNetworkId() { 24 | return NETWORK_ID; 25 | } 26 | 27 | @Override 28 | protected void initEntity() { 29 | this.setMaxHealth(100); 30 | super.initEntity(); 31 | 32 | this.setDamage(new float[] { 0, 7, 12, 18 }); 33 | } 34 | 35 | @Override 36 | public float getHeight() { 37 | return 2.2f; 38 | } 39 | 40 | @Override 41 | public float getWidth() { 42 | return 1.95f; 43 | } 44 | 45 | @Override 46 | public double getSpeed() { 47 | return 1.1; 48 | } 49 | 50 | @Override 51 | public int getKillExperience() { 52 | return 0; 53 | } 54 | 55 | @Override 56 | public void attackEntity(Entity player) { 57 | if (this.attackDelay > 80 && player.distanceSquared(this) <= 1.5) { 58 | this.attackDelay = 0; 59 | HashMap damage = new HashMap<>(); 60 | damage.put(EntityDamageEvent.DamageModifier.BASE, this.getDamage()); 61 | 62 | if (player instanceof Player) { 63 | float points = 0; 64 | for (Item i : ((Player) player).getInventory().getArmorContents()) { 65 | points += this.getArmorPoints(i.getId()); 66 | } 67 | 68 | damage.put(EntityDamageEvent.DamageModifier.ARMOR, (float) (damage.getOrDefault(EntityDamageEvent.DamageModifier.ARMOR, 0f) - Math.floor(damage.getOrDefault(EntityDamageEvent.DamageModifier.BASE, 1f) * points * 0.04))); 69 | } 70 | 71 | player.attack(new EntityDamageByEntityEvent(this, player, EntityDamageEvent.DamageCause.ENTITY_ATTACK, damage)); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/monster/walking/Silverfish.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.monster.walking; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.entity.Entity; 5 | import cn.nukkit.entity.EntityArthropod; 6 | import cn.nukkit.event.entity.EntityDamageByEntityEvent; 7 | import cn.nukkit.event.entity.EntityDamageEvent; 8 | import cn.nukkit.item.Item; 9 | import cn.nukkit.level.format.FullChunk; 10 | import cn.nukkit.nbt.tag.CompoundTag; 11 | import nukkitcoders.mobplugin.entities.monster.WalkingMonster; 12 | 13 | import java.util.HashMap; 14 | 15 | public class Silverfish extends WalkingMonster implements EntityArthropod { 16 | 17 | public static final int NETWORK_ID = 39; 18 | 19 | public Silverfish(FullChunk chunk, CompoundTag nbt) { 20 | super(chunk, nbt); 21 | } 22 | 23 | @Override 24 | public int getNetworkId() { 25 | return NETWORK_ID; 26 | } 27 | 28 | @Override 29 | public float getWidth() { 30 | return 0.4f; 31 | } 32 | 33 | @Override 34 | public float getHeight() { 35 | return 0.3f; 36 | } 37 | 38 | @Override 39 | public double getSpeed() { 40 | return 1.4; 41 | } 42 | 43 | @Override 44 | public void initEntity() { 45 | this.setMaxHealth(8); 46 | super.initEntity(); 47 | 48 | this.setDamage(new float[] { 0, 1, 1, 1 }); 49 | } 50 | 51 | @Override 52 | public void attackEntity(Entity player) { 53 | if (this.attackDelay > 23 && this.distanceSquared(player) < 1) { 54 | this.attackDelay = 0; 55 | HashMap damage = new HashMap<>(); 56 | damage.put(EntityDamageEvent.DamageModifier.BASE, this.getDamage()); 57 | 58 | if (player instanceof Player) { 59 | float points = 0; 60 | for (Item i : ((Player) player).getInventory().getArmorContents()) { 61 | points += this.getArmorPoints(i.getId()); 62 | } 63 | 64 | damage.put(EntityDamageEvent.DamageModifier.ARMOR, 65 | (float) (damage.getOrDefault(EntityDamageEvent.DamageModifier.ARMOR, 0f) - Math.floor(damage.getOrDefault(EntityDamageEvent.DamageModifier.BASE, 1f) * points * 0.04))); 66 | } 67 | player.attack(new EntityDamageByEntityEvent(this, player, EntityDamageEvent.DamageCause.ENTITY_ATTACK, damage)); 68 | } 69 | } 70 | 71 | @Override 72 | public int getKillExperience() { 73 | return 5; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/monster/walking/Warden.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.monster.walking; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.entity.Entity; 5 | import cn.nukkit.event.entity.EntityDamageByEntityEvent; 6 | import cn.nukkit.event.entity.EntityDamageEvent; 7 | import cn.nukkit.item.Item; 8 | import cn.nukkit.level.format.FullChunk; 9 | import cn.nukkit.nbt.tag.CompoundTag; 10 | import nukkitcoders.mobplugin.entities.monster.WalkingMonster; 11 | 12 | import java.util.HashMap; 13 | 14 | public class Warden extends WalkingMonster { 15 | 16 | public static final int NETWORK_ID = 131; 17 | 18 | public Warden(FullChunk chunk, CompoundTag nbt) { 19 | super(chunk, nbt); 20 | } 21 | 22 | @Override 23 | public int getKillExperience() { 24 | return 5; 25 | } 26 | 27 | @Override 28 | public int getNetworkId() { 29 | return NETWORK_ID; 30 | } 31 | 32 | @Override 33 | public float getHeight() { 34 | return 2.9f; 35 | } 36 | 37 | @Override 38 | public float getWidth() { 39 | return 0.9f; 40 | } 41 | 42 | @Override 43 | protected void initEntity() { 44 | this.setMaxHealth(500); 45 | super.initEntity(); 46 | 47 | this.setDamage(new float[] { 0, 16, 30, 45 }); 48 | } 49 | 50 | @Override 51 | public void attackEntity(Entity player) { 52 | if (this.attackDelay > 40 && this.distanceSquared(player) < 4) { 53 | this.attackDelay = 0; 54 | HashMap damage = new HashMap<>(); 55 | damage.put(EntityDamageEvent.DamageModifier.BASE, (float) this.getDamage()); 56 | 57 | if (player instanceof Player) { 58 | float points = 0; 59 | for (Item i : ((Player) player).getInventory().getArmorContents()) { 60 | points += this.getArmorPoints(i.getId()); 61 | } 62 | damage.put(EntityDamageEvent.DamageModifier.ARMOR, 63 | (float) (damage.getOrDefault(EntityDamageEvent.DamageModifier.ARMOR, 0f) - Math.floor(damage.getOrDefault(EntityDamageEvent.DamageModifier.BASE, 1f) * points * 0.04))); 64 | } 65 | player.attack(new EntityDamageByEntityEvent(this, player, EntityDamageEvent.DamageCause.ENTITY_ATTACK, damage)); 66 | this.playAttack(); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/monster/walking/Zoglin.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.monster.walking; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.entity.Entity; 5 | import cn.nukkit.entity.EntitySmite; 6 | import cn.nukkit.event.entity.EntityDamageByEntityEvent; 7 | import cn.nukkit.event.entity.EntityDamageEvent; 8 | import cn.nukkit.item.Item; 9 | import cn.nukkit.level.format.FullChunk; 10 | import cn.nukkit.nbt.tag.CompoundTag; 11 | import nukkitcoders.mobplugin.entities.monster.WalkingMonster; 12 | import nukkitcoders.mobplugin.utils.Utils; 13 | 14 | import java.util.HashMap; 15 | 16 | public class Zoglin extends WalkingMonster implements EntitySmite { 17 | 18 | public final static int NETWORK_ID = 126; 19 | 20 | @Override 21 | public int getNetworkId() { 22 | return NETWORK_ID; 23 | } 24 | 25 | public Zoglin(FullChunk chunk, CompoundTag nbt) { 26 | super(chunk, nbt); 27 | } 28 | 29 | @Override 30 | public int getKillExperience() { 31 | return this.isBaby() ? 1 : Utils.rand(1, 3); 32 | } 33 | 34 | @Override 35 | protected void initEntity() { 36 | this.setMaxHealth(40); 37 | super.initEntity(); 38 | this.setDamage(new float[]{0, 2, 3, 4}); 39 | } 40 | 41 | @Override 42 | public float getWidth() { 43 | return 0.9f; 44 | } 45 | 46 | @Override 47 | public float getHeight() { 48 | return 0.9f; 49 | } 50 | 51 | @Override 52 | public void attackEntity(Entity player) { 53 | if (this.attackDelay > 30 && player.distanceSquared(this) <= 1.5) { 54 | this.attackDelay = 0; 55 | HashMap damage = new HashMap<>(); 56 | damage.put(EntityDamageEvent.DamageModifier.BASE, this.getDamage()); 57 | 58 | if (player instanceof Player) { 59 | float points = 0; 60 | for (Item i : ((Player) player).getInventory().getArmorContents()) { 61 | points += this.getArmorPoints(i.getId()); 62 | } 63 | 64 | damage.put(EntityDamageEvent.DamageModifier.ARMOR, (float) (damage.getOrDefault(EntityDamageEvent.DamageModifier.ARMOR, 0f) - Math.floor(damage.getOrDefault(EntityDamageEvent.DamageModifier.BASE, 1f) * points * 0.04))); 65 | } 66 | player.attack(new EntityDamageByEntityEvent(this, player, EntityDamageEvent.DamageCause.ENTITY_ATTACK, damage)); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/monster/walking/ZombieVillager.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.monster.walking; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.entity.Entity; 5 | import cn.nukkit.entity.EntitySmite; 6 | import cn.nukkit.event.entity.EntityDamageByEntityEvent; 7 | import cn.nukkit.event.entity.EntityDamageEvent; 8 | import cn.nukkit.item.Item; 9 | import cn.nukkit.level.format.FullChunk; 10 | import cn.nukkit.nbt.tag.CompoundTag; 11 | import nukkitcoders.mobplugin.MobPlugin; 12 | import nukkitcoders.mobplugin.entities.monster.WalkingMonster; 13 | import nukkitcoders.mobplugin.utils.Utils; 14 | 15 | import java.util.ArrayList; 16 | import java.util.HashMap; 17 | import java.util.List; 18 | 19 | public class ZombieVillager extends WalkingMonster implements EntitySmite { 20 | 21 | public static final int NETWORK_ID = 44; 22 | 23 | public ZombieVillager(FullChunk chunk, CompoundTag nbt) { 24 | super(chunk, nbt); 25 | } 26 | 27 | @Override 28 | public int getNetworkId() { 29 | return NETWORK_ID; 30 | } 31 | 32 | @Override 33 | public float getWidth() { 34 | return 0.6f; 35 | } 36 | 37 | @Override 38 | public float getHeight() { 39 | return 1.95f; 40 | } 41 | 42 | @Override 43 | public double getSpeed() { 44 | return this.isBaby() ? 1.6 : 1.1; 45 | } 46 | 47 | @Override 48 | public void initEntity() { 49 | this.setMaxHealth(20); 50 | super.initEntity(); 51 | 52 | this.setDamage(new float[] { 0, 3, 4, 6 }); 53 | } 54 | 55 | @Override 56 | public void attackEntity(Entity player) { 57 | if (this.attackDelay > 23 && this.distanceSquared(player) < 1) { 58 | this.attackDelay = 0; 59 | HashMap damage = new HashMap<>(); 60 | damage.put(EntityDamageEvent.DamageModifier.BASE, this.getDamage()); 61 | 62 | if (player instanceof Player) { 63 | float points = 0; 64 | for (Item i : ((Player) player).getInventory().getArmorContents()) { 65 | points += this.getArmorPoints(i.getId()); 66 | } 67 | 68 | damage.put(EntityDamageEvent.DamageModifier.ARMOR, 69 | (float) (damage.getOrDefault(EntityDamageEvent.DamageModifier.ARMOR, 0f) - Math.floor(damage.getOrDefault(EntityDamageEvent.DamageModifier.BASE, 1f) * points * 0.04))); 70 | } 71 | player.attack(new EntityDamageByEntityEvent(this, player, EntityDamageEvent.DamageCause.ENTITY_ATTACK, damage)); 72 | this.playAttack(); 73 | } 74 | } 75 | 76 | @Override 77 | public boolean entityBaseTick(int tickDiff) { 78 | if (getServer().getDifficulty() == 0) { 79 | this.close(); 80 | return true; 81 | } 82 | 83 | boolean hasUpdate = super.entityBaseTick(tickDiff); 84 | 85 | if (!this.closed && MobPlugin.shouldMobBurn(level, this)) { 86 | this.setOnFire(100); 87 | } 88 | 89 | return hasUpdate; 90 | } 91 | 92 | @Override 93 | public Item[] getDrops() { 94 | List drops = new ArrayList<>(); 95 | 96 | if (!this.isBaby()) { 97 | drops.add(Item.get(Item.ROTTEN_FLESH, 0, Utils.rand(0, 2))); 98 | } 99 | 100 | return drops.toArray(new Item[0]); 101 | } 102 | 103 | @Override 104 | public int getKillExperience() { 105 | return this.isBaby() ? 0 : 5; 106 | } 107 | 108 | @Override 109 | public String getName() { 110 | return this.hasCustomName() ? this.getNameTag() : "Zombie Villager"; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/monster/walking/ZombieVillagerV2.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.monster.walking; 2 | 3 | import cn.nukkit.level.format.FullChunk; 4 | import cn.nukkit.nbt.tag.CompoundTag; 5 | 6 | public class ZombieVillagerV2 extends ZombieVillager { 7 | 8 | public static final int NETWORK_ID = 116; 9 | 10 | public ZombieVillagerV2(FullChunk chunk, CompoundTag nbt) { 11 | super(chunk, nbt); 12 | } 13 | 14 | @Override 15 | public int getNetworkId() { 16 | return NETWORK_ID; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/projectile/DespawnableThrownTrident.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.projectile; 2 | 3 | import cn.nukkit.entity.Entity; 4 | import cn.nukkit.entity.projectile.EntityThrownTrident; 5 | import cn.nukkit.level.format.FullChunk; 6 | import cn.nukkit.nbt.tag.CompoundTag; 7 | 8 | public class DespawnableThrownTrident extends EntityThrownTrident { 9 | 10 | public DespawnableThrownTrident(FullChunk chunk, CompoundTag nbt) { 11 | super(chunk, nbt); 12 | } 13 | 14 | 15 | public DespawnableThrownTrident(FullChunk chunk, CompoundTag nbt, Entity shootingEntity) { 16 | super(chunk, nbt, shootingEntity); 17 | } 18 | 19 | @Override 20 | public boolean onUpdate(int currentTick) { 21 | if (!this.closed && this.age > 1200 && this.pickupMode < 1) { 22 | this.close(); 23 | return false; 24 | } 25 | 26 | super.onUpdate(currentTick); 27 | return !this.closed; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/projectile/EntityBlazeFireBall.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.projectile; 2 | 3 | import cn.nukkit.entity.Entity; 4 | import cn.nukkit.entity.projectile.EntityProjectile; 5 | import cn.nukkit.level.format.FullChunk; 6 | import cn.nukkit.nbt.tag.CompoundTag; 7 | 8 | public class EntityBlazeFireBall extends EntityProjectile { 9 | 10 | public static final int NETWORK_ID = 94; 11 | 12 | public EntityBlazeFireBall(FullChunk chunk, CompoundTag nbt) { 13 | this(chunk, nbt, null); 14 | } 15 | 16 | public EntityBlazeFireBall(FullChunk chunk, CompoundTag nbt, Entity shootingEntity) { 17 | super(chunk, nbt, shootingEntity); 18 | } 19 | 20 | @Override 21 | public int getNetworkId() { 22 | return NETWORK_ID; 23 | } 24 | 25 | @Override 26 | public float getWidth() { 27 | return 0.31f; 28 | } 29 | 30 | @Override 31 | public float getHeight() { 32 | return 0.31f; 33 | } 34 | 35 | @Override 36 | public float getGravity() { 37 | return 0.001f; 38 | } 39 | 40 | @Override 41 | public float getDrag() { 42 | return 0.01f; 43 | } 44 | 45 | @Override 46 | public double getBaseDamage() { 47 | return 5; 48 | } 49 | 50 | @Override 51 | public boolean onUpdate(int currentTick) { 52 | if (this.closed) { 53 | return false; 54 | } 55 | 56 | if (this.age > 1200 || this.isCollided || this.hadCollision) { 57 | this.close(); 58 | return false; 59 | } else { 60 | this.fireTicks = 2; 61 | } 62 | 63 | super.onUpdate(currentTick); 64 | return !this.closed; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/projectile/EntityBlueWitherSkull.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.projectile; 2 | 3 | import cn.nukkit.entity.Entity; 4 | import cn.nukkit.entity.EntityExplosive; 5 | import cn.nukkit.event.entity.EntityExplosionPrimeEvent; 6 | import cn.nukkit.level.GameRule; 7 | import cn.nukkit.level.format.FullChunk; 8 | import cn.nukkit.level.particle.SmokeParticle; 9 | import cn.nukkit.nbt.tag.CompoundTag; 10 | import nukkitcoders.mobplugin.utils.Utils; 11 | import nukkitcoders.mobplugin.utils.WitherSkullExplosion; 12 | 13 | public class EntityBlueWitherSkull extends EntityWitherSkull implements EntityExplosive { 14 | 15 | public static final int NETWORK_ID = 91; 16 | 17 | private boolean canExplode; 18 | 19 | public EntityBlueWitherSkull(FullChunk chunk, CompoundTag nbt) { 20 | this(chunk, nbt, null); 21 | } 22 | 23 | public EntityBlueWitherSkull(FullChunk chunk, CompoundTag nbt, Entity shootingEntity) { 24 | super(chunk, nbt, shootingEntity); 25 | } 26 | 27 | @Override 28 | public int getNetworkId() { 29 | return NETWORK_ID; 30 | } 31 | 32 | public void setExplode(boolean bool) { 33 | this.canExplode = bool; 34 | } 35 | 36 | @Override 37 | public boolean onUpdate(int currentTick) { 38 | if (this.closed) { 39 | return false; 40 | } 41 | 42 | if (this.age > 1200 || this.isCollided || this.hadCollision) { 43 | if (this.canExplode) { 44 | this.explode(); 45 | } else { 46 | this.close(); 47 | } 48 | } else if (this.age % 4 == 0) { 49 | this.level.addParticle(new SmokeParticle(this.add(this.getWidth() / 2 + Utils.rand(-100.0, 100.0) / 500, this.getHeight() / 2 + Utils.rand(-100.0, 100.0) / 500, this.getWidth() / 2 + Utils.rand(-100.0, 100.0) / 500))); 50 | } 51 | 52 | super.onUpdate(currentTick); 53 | return !this.closed; 54 | } 55 | 56 | @Override 57 | public void explode() { 58 | if (this.closed) { 59 | return; 60 | } 61 | this.close(); 62 | 63 | EntityExplosionPrimeEvent ev = new EntityExplosionPrimeEvent(this, 1.2); 64 | this.server.getPluginManager().callEvent(ev); 65 | 66 | if (!ev.isCancelled()) { 67 | WitherSkullExplosion explosion = new WitherSkullExplosion(this, (float) ev.getForce(), this.shootingEntity); 68 | if (ev.isBlockBreaking() && this.level.getGameRules().getBoolean(GameRule.MOB_GRIEFING)) { 69 | explosion.explodeA(); 70 | } 71 | 72 | explosion.explodeB(); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/projectile/EntityEnderCharge.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.projectile; 2 | 3 | import cn.nukkit.entity.Entity; 4 | import cn.nukkit.entity.projectile.EntityProjectile; 5 | import cn.nukkit.level.format.FullChunk; 6 | import cn.nukkit.nbt.tag.CompoundTag; 7 | 8 | public class EntityEnderCharge extends EntityProjectile { 9 | 10 | public static final int NETWORK_ID = 79; 11 | 12 | public EntityEnderCharge(FullChunk chunk, CompoundTag nbt) { 13 | this(chunk, nbt, null); 14 | } 15 | 16 | public EntityEnderCharge(FullChunk chunk, CompoundTag nbt, Entity shootingEntity) { 17 | super(chunk, nbt, shootingEntity); 18 | } 19 | 20 | @Override 21 | public int getNetworkId() { 22 | return NETWORK_ID; 23 | } 24 | 25 | @Override 26 | public float getWidth() { 27 | return 0.25f; 28 | } 29 | 30 | @Override 31 | public float getLength() { 32 | return 0.25f; 33 | } 34 | 35 | @Override 36 | public float getHeight() { 37 | return 0.25f; 38 | } 39 | 40 | @Override 41 | public float getGravity() { 42 | return 0.001f; 43 | } 44 | 45 | @Override 46 | public float getDrag() { 47 | return 0.01f; 48 | } 49 | 50 | @Override 51 | protected double getBaseDamage() { 52 | return 5; 53 | } 54 | 55 | @Override 56 | public boolean onUpdate(int currentTick) { 57 | if (this.closed) { 58 | return false; 59 | } 60 | 61 | if (this.age > 1200 || this.isCollided || this.hadCollision) { 62 | this.close(); 63 | return false; 64 | } 65 | 66 | super.onUpdate(currentTick); 67 | return !this.closed; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/projectile/EntityGhastFireBall.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.projectile; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.entity.Entity; 5 | import cn.nukkit.entity.EntityExplosive; 6 | import cn.nukkit.entity.projectile.EntityProjectile; 7 | import cn.nukkit.event.entity.EntityDamageByEntityEvent; 8 | import cn.nukkit.event.entity.EntityDamageEvent; 9 | import cn.nukkit.event.entity.EntityExplosionPrimeEvent; 10 | import cn.nukkit.level.GameRule; 11 | import cn.nukkit.level.format.FullChunk; 12 | import cn.nukkit.nbt.tag.CompoundTag; 13 | import nukkitcoders.mobplugin.utils.FireBallExplosion; 14 | 15 | public class EntityGhastFireBall extends EntityProjectile implements EntityExplosive { 16 | 17 | public static final int NETWORK_ID = 85; 18 | 19 | private boolean canExplode; 20 | 21 | public Player directionChanged; 22 | 23 | @Override 24 | public int getNetworkId() { 25 | return NETWORK_ID; 26 | } 27 | 28 | @Override 29 | public float getWidth() { 30 | return 0.31f; 31 | } 32 | 33 | @Override 34 | public float getHeight() { 35 | return 0.31f; 36 | } 37 | 38 | @Override 39 | public float getGravity() { 40 | return 0.001f; 41 | } 42 | 43 | @Override 44 | public float getDrag() { 45 | return 0.01f; 46 | } 47 | 48 | @Override 49 | protected double getBaseDamage() { 50 | return 6; 51 | } 52 | 53 | public EntityGhastFireBall(FullChunk chunk, CompoundTag nbt) { 54 | this(chunk, nbt, null); 55 | } 56 | 57 | public EntityGhastFireBall(FullChunk chunk, CompoundTag nbt, Entity shootingEntity) { 58 | super(chunk, nbt, shootingEntity); 59 | } 60 | 61 | public void setExplode(boolean bool) { 62 | this.canExplode = bool; 63 | } 64 | 65 | @Override 66 | public boolean onUpdate(int currentTick) { 67 | if (this.closed) { 68 | return false; 69 | } 70 | 71 | if (this.age > 1200 || this.isCollided || this.hadCollision) { 72 | if (this.isCollided && this.canExplode) { 73 | this.explode(); 74 | } else { 75 | this.close(); 76 | } 77 | return false; 78 | } 79 | 80 | super.onUpdate(currentTick); 81 | return !this.closed; 82 | } 83 | 84 | @Override 85 | public void onCollideWithEntity(Entity entity) { 86 | this.explode(); 87 | } 88 | 89 | @Override 90 | public boolean attack(EntityDamageEvent source) { 91 | if (this.directionChanged == null && source instanceof EntityDamageByEntityEvent) { 92 | if (((EntityDamageByEntityEvent) source).getDamager() instanceof Player) { 93 | this.directionChanged = (Player) ((EntityDamageByEntityEvent) source).getDamager(); 94 | this.setMotion(((EntityDamageByEntityEvent) source).getDamager().getLocation().getDirectionVector()); 95 | } 96 | } 97 | 98 | return true; 99 | } 100 | 101 | @Override 102 | public void explode() { 103 | if (this.closed) { 104 | return; 105 | } 106 | this.close(); 107 | EntityExplosionPrimeEvent ev = new EntityExplosionPrimeEvent(this, 1.2); 108 | this.server.getPluginManager().callEvent(ev); 109 | if (!ev.isCancelled()) { 110 | FireBallExplosion explosion = new FireBallExplosion(this, (float) ev.getForce(), this.shootingEntity); 111 | if (ev.isBlockBreaking() && this.level.getGameRules().getBoolean(GameRule.MOB_GRIEFING)) { 112 | explosion.explodeA(); 113 | } 114 | explosion.explodeB(); 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/projectile/EntityLlamaSpit.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.projectile; 2 | 3 | import cn.nukkit.entity.Entity; 4 | import cn.nukkit.entity.projectile.EntityProjectile; 5 | import cn.nukkit.level.format.FullChunk; 6 | import cn.nukkit.nbt.tag.CompoundTag; 7 | 8 | public class EntityLlamaSpit extends EntityProjectile { 9 | 10 | public static final int NETWORK_ID = 102; 11 | 12 | @Override 13 | public int getNetworkId() { 14 | return NETWORK_ID; 15 | } 16 | 17 | @Override 18 | public float getWidth() { 19 | return 0.3f; 20 | } 21 | 22 | @Override 23 | public float getHeight() { 24 | return 0.3f; 25 | } 26 | 27 | @Override 28 | public float getGravity() { 29 | return 0.001f; 30 | } 31 | 32 | @Override 33 | public float getDrag() { 34 | return 0.01f; 35 | } 36 | 37 | @Override 38 | protected double getBaseDamage() { 39 | return 1; 40 | } 41 | 42 | public EntityLlamaSpit(FullChunk chunk, CompoundTag nbt) { 43 | this(chunk, nbt, null); 44 | } 45 | 46 | public EntityLlamaSpit(FullChunk chunk, CompoundTag nbt, Entity shootingEntity) { 47 | super(chunk, nbt, shootingEntity); 48 | } 49 | 50 | @Override 51 | public boolean onUpdate(int currentTick) { 52 | if (this.closed) { 53 | return false; 54 | } 55 | 56 | if (this.age > 100 || this.isCollided || this.hadCollision) { 57 | this.close(); 58 | return false; 59 | } 60 | 61 | super.onUpdate(currentTick); 62 | return !this.closed; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/projectile/EntityShulkerBullet.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.projectile; 2 | 3 | import cn.nukkit.entity.Entity; 4 | import cn.nukkit.entity.projectile.EntityProjectile; 5 | import cn.nukkit.event.entity.EntityDamageEvent; 6 | import cn.nukkit.level.Sound; 7 | import cn.nukkit.level.format.FullChunk; 8 | import cn.nukkit.nbt.tag.CompoundTag; 9 | import cn.nukkit.potion.Effect; 10 | 11 | public class EntityShulkerBullet extends EntityProjectile { 12 | 13 | public static final int NETWORK_ID = 76; 14 | 15 | @Override 16 | public int getNetworkId() { 17 | return NETWORK_ID; 18 | } 19 | 20 | @Override 21 | public float getGravity() { 22 | return -0.001f; 23 | } 24 | 25 | @Override 26 | public float getDrag() { 27 | return 0.001f; 28 | } 29 | 30 | @Override 31 | public float getWidth() { 32 | return 0.25f; 33 | } 34 | 35 | @Override 36 | public float getLength() { 37 | return 0.40f; 38 | } 39 | 40 | @Override 41 | public float getHeight() { 42 | return 0.40f; 43 | } 44 | 45 | @Override 46 | protected double getBaseDamage() { 47 | return 4; 48 | } 49 | 50 | public EntityShulkerBullet(FullChunk chunk, CompoundTag nbt) { 51 | this(chunk, nbt, null); 52 | } 53 | 54 | public EntityShulkerBullet(FullChunk chunk, CompoundTag nbt, Entity shootingEntity) { 55 | super(chunk, nbt, shootingEntity); 56 | } 57 | 58 | @Override 59 | public boolean onUpdate(int currentTick) { 60 | if (this.closed) { 61 | return false; 62 | } 63 | 64 | if (this.age > 1200 || this.isCollided || this.hadCollision) { 65 | this.close(); 66 | return false; 67 | } 68 | 69 | super.onUpdate(currentTick); 70 | return !this.closed; 71 | } 72 | 73 | @Override 74 | public boolean attack(EntityDamageEvent source) { 75 | this.level.addSound(this, Sound.MOB_SHULKER_BULLET_HIT); 76 | this.close(); 77 | return true; 78 | } 79 | 80 | @Override 81 | public void onCollideWithEntity(Entity entity) { 82 | super.onCollideWithEntity(entity); 83 | this.level.addSound(this, Sound.MOB_SHULKER_BULLET_HIT); 84 | entity.addEffect(Effect.getEffect(Effect.LEVITATION).setDuration(200)); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/projectile/EntityWitherSkull.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.projectile; 2 | 3 | import cn.nukkit.entity.Entity; 4 | import cn.nukkit.entity.projectile.EntityProjectile; 5 | import cn.nukkit.level.format.FullChunk; 6 | import cn.nukkit.level.particle.SmokeParticle; 7 | import cn.nukkit.nbt.tag.CompoundTag; 8 | import cn.nukkit.potion.Effect; 9 | import nukkitcoders.mobplugin.utils.Utils; 10 | 11 | public class EntityWitherSkull extends EntityProjectile { 12 | 13 | public static final int NETWORK_ID = 89; 14 | 15 | public EntityWitherSkull(FullChunk chunk, CompoundTag nbt) { 16 | this(chunk, nbt, null); 17 | } 18 | 19 | public EntityWitherSkull(FullChunk chunk, CompoundTag nbt, Entity shootingEntity) { 20 | super(chunk, nbt, shootingEntity); 21 | } 22 | 23 | @Override 24 | public int getNetworkId() { 25 | return NETWORK_ID; 26 | } 27 | 28 | @Override 29 | public float getWidth() { 30 | return 0.25f; 31 | } 32 | 33 | @Override 34 | public float getLength() { 35 | return 0.25f; 36 | } 37 | 38 | @Override 39 | public float getHeight() { 40 | return 0.25f; 41 | } 42 | 43 | @Override 44 | public float getGravity() { 45 | return 0.001f; 46 | } 47 | 48 | @Override 49 | public float getDrag() { 50 | return 0.01f; 51 | } 52 | 53 | @Override 54 | protected double getBaseDamage() { 55 | switch (server.getDifficulty()) { 56 | case 2: // normal 57 | return 8; 58 | case 3: // hard 59 | return 12; 60 | default: 61 | return 5; 62 | } 63 | } 64 | 65 | @Override 66 | public boolean onUpdate(int currentTick) { 67 | if (this.closed) { 68 | return false; 69 | } 70 | 71 | if (this.age > 1200 || this.isCollided || this.hadCollision) { 72 | this.close(); 73 | } else if (this.age % 4 == 0) { 74 | this.level.addParticle(new SmokeParticle(this.add(this.getWidth() / 2 + Utils.rand(-100.0, 100.0) / 500, this.getHeight() / 2 + Utils.rand(-100.0, 100.0) / 500, this.getWidth() / 2 + Utils.rand(-100.0, 100.0) / 500))); 75 | } 76 | 77 | super.onUpdate(currentTick); 78 | return !this.closed; 79 | } 80 | 81 | @Override 82 | public void onCollideWithEntity(Entity entity) { 83 | super.onCollideWithEntity(entity); 84 | entity.addEffect(Effect.getEffect(Effect.WITHER).setDuration(200)); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/BatSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.level.Level; 5 | import cn.nukkit.level.Position; 6 | import nukkitcoders.mobplugin.AutoSpawnTask; 7 | import nukkitcoders.mobplugin.MobPlugin; 8 | import nukkitcoders.mobplugin.entities.animal.flying.Bat; 9 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 10 | 11 | /** 12 | * @author Michael Gertz 13 | */ 14 | public class BatSpawner extends AbstractEntitySpawner { 15 | 16 | public BatSpawner(AutoSpawnTask spawnTask) { 17 | super(spawnTask); 18 | } 19 | 20 | public void spawn(Player player, Position pos, Level level) { 21 | if (level.getBlockLightAt((int) pos.x, (int) pos.y + 1, (int) pos.z) <= 3) { 22 | if (!level.canBlockSeeSky(pos)) { 23 | if (MobPlugin.isAnimalSpawningAllowedByTime(level)) { 24 | this.spawnTask.createEntity("Bat", pos.add(0.5, 1, 0.5)); 25 | } 26 | } 27 | } 28 | } 29 | 30 | @Override 31 | public int getEntityNetworkId() { 32 | return Bat.NETWORK_ID; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/BlazeSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.level.Level; 5 | import cn.nukkit.level.Position; 6 | import nukkitcoders.mobplugin.AutoSpawnTask; 7 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 8 | import nukkitcoders.mobplugin.entities.monster.flying.Blaze; 9 | import nukkitcoders.mobplugin.utils.Utils; 10 | 11 | /** 12 | * @author PikyCZ 13 | */ 14 | public class BlazeSpawner extends AbstractEntitySpawner { 15 | 16 | public BlazeSpawner(AutoSpawnTask spawnTask) { 17 | super(spawnTask); 18 | } 19 | 20 | @Override 21 | public void spawn(Player player, Position pos, Level level) { 22 | if (Utils.rand(1, 3) != 1) { 23 | this.spawnTask.createEntity("Blaze", pos.add(0.5, 1, 0.5)); 24 | } 25 | } 26 | 27 | @Override 28 | public int getEntityNetworkId() { 29 | return Blaze.NETWORK_ID; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/ChickenSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.Block; 5 | import cn.nukkit.level.Level; 6 | import cn.nukkit.level.Position; 7 | import nukkitcoders.mobplugin.AutoSpawnTask; 8 | import nukkitcoders.mobplugin.MobPlugin; 9 | import nukkitcoders.mobplugin.entities.BaseEntity; 10 | import nukkitcoders.mobplugin.entities.animal.walking.Chicken; 11 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 12 | import nukkitcoders.mobplugin.utils.Utils; 13 | 14 | public class ChickenSpawner extends AbstractEntitySpawner { 15 | 16 | public ChickenSpawner(AutoSpawnTask spawnTask) { 17 | super(spawnTask); 18 | } 19 | 20 | public void spawn(Player player, Position pos, Level level) { 21 | if (Utils.rand(1, 3) != 1) { 22 | return; 23 | } 24 | if (MobPlugin.isAnimalSpawningAllowedByTime(level)) { 25 | int blockId = level.getBlockIdAt((int) pos.x, (int) pos.y, (int) pos.z); 26 | if (blockId == Block.GRASS || blockId == Block.SNOW_LAYER) { 27 | for (int i = 0; i < Utils.rand(2, 4); i++) { 28 | BaseEntity entity = this.spawnTask.createEntity("Chicken", pos.add(0.5, 1, 0.5)); 29 | if (entity == null) return; 30 | if (Utils.rand(1, 20) == 1) { 31 | entity.setBaby(true); 32 | } 33 | } 34 | } 35 | } 36 | } 37 | 38 | @Override 39 | public final int getEntityNetworkId() { 40 | return Chicken.NETWORK_ID; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/CodSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.Block; 5 | import cn.nukkit.level.Level; 6 | import cn.nukkit.level.Position; 7 | import nukkitcoders.mobplugin.AutoSpawnTask; 8 | import nukkitcoders.mobplugin.entities.animal.swimming.Cod; 9 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 10 | import nukkitcoders.mobplugin.utils.Utils; 11 | 12 | public class CodSpawner extends AbstractEntitySpawner { 13 | 14 | public CodSpawner(AutoSpawnTask spawnTask) { 15 | super(spawnTask); 16 | } 17 | 18 | public void spawn(Player player, Position pos, Level level) { 19 | if (Utils.rand(1, 3) != 1) { 20 | return; 21 | } 22 | final int blockId = level.getBlockIdAt((int) pos.x, (int) pos.y, (int) pos.z); 23 | if (blockId == Block.WATER || blockId == Block.STILL_WATER) { 24 | final int biomeId = level.getBiomeId((int) pos.x, (int) pos.z); 25 | if (biomeId == 0 || biomeId == 24 || (biomeId >= 42 && biomeId <= 45)) { 26 | final int b = level.getBlockIdAt((int) pos.x, (int) (pos.y -1), (int) pos.z); 27 | if (b == Block.WATER || b == Block.STILL_WATER) { 28 | for (int i = 0; i < Utils.rand(4, 7); i++) { 29 | this.spawnTask.createEntity("Cod", pos.add(0, -1, 0)); 30 | } 31 | } 32 | } 33 | } 34 | } 35 | 36 | @Override 37 | public final int getEntityNetworkId() { 38 | return Cod.NETWORK_ID; 39 | } 40 | 41 | @Override 42 | public boolean isWaterMob() { 43 | return true; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/CowSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.Block; 5 | import cn.nukkit.level.Level; 6 | import cn.nukkit.level.Position; 7 | import nukkitcoders.mobplugin.AutoSpawnTask; 8 | import nukkitcoders.mobplugin.MobPlugin; 9 | import nukkitcoders.mobplugin.entities.BaseEntity; 10 | import nukkitcoders.mobplugin.entities.animal.walking.Cow; 11 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 12 | import nukkitcoders.mobplugin.utils.Utils; 13 | 14 | public class CowSpawner extends AbstractEntitySpawner { 15 | 16 | public CowSpawner(AutoSpawnTask spawnTask) { 17 | super(spawnTask); 18 | } 19 | 20 | public void spawn(Player player, Position pos, Level level) { 21 | if (Utils.rand(1, 3) != 1) { 22 | return; 23 | } 24 | if (MobPlugin.isAnimalSpawningAllowedByTime(level)) { 25 | int blockId = level.getBlockIdAt((int) pos.x, (int) pos.y, (int) pos.z); 26 | if (blockId == Block.GRASS || blockId == Block.SNOW_LAYER) { 27 | for (int i = 0; i < Utils.rand(2, 3); i++) { 28 | BaseEntity entity = this.spawnTask.createEntity("Cow", pos.add(0.5, 1, 0.5)); 29 | if (entity == null) return; 30 | if (Utils.rand(1, 20) == 1) { 31 | entity.setBaby(true); 32 | } 33 | } 34 | } 35 | } 36 | } 37 | 38 | @Override 39 | public final int getEntityNetworkId() { 40 | return Cow.NETWORK_ID; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/CreeperSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.level.Level; 5 | import cn.nukkit.level.Position; 6 | import nukkitcoders.mobplugin.AutoSpawnTask; 7 | import nukkitcoders.mobplugin.MobPlugin; 8 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 9 | import nukkitcoders.mobplugin.entities.monster.walking.Creeper; 10 | 11 | public class CreeperSpawner extends AbstractEntitySpawner { 12 | 13 | public CreeperSpawner(AutoSpawnTask spawnTask) { 14 | super(spawnTask); 15 | } 16 | 17 | public void spawn(Player player, Position pos, Level level) { 18 | if (level.getBlockLightAt((int) pos.x, (int) pos.y + 1, (int) pos.z) <= 7) { 19 | if (MobPlugin.isMobSpawningAllowedByTime(level)) { 20 | this.spawnTask.createEntity("Creeper", pos.add(0.5, 1, 0.5)); 21 | } 22 | } 23 | } 24 | 25 | @Override 26 | public final int getEntityNetworkId() { 27 | return Creeper.NETWORK_ID; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/DolphinSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.Block; 5 | import cn.nukkit.level.Level; 6 | import cn.nukkit.level.Position; 7 | import nukkitcoders.mobplugin.AutoSpawnTask; 8 | import nukkitcoders.mobplugin.MobPlugin; 9 | import nukkitcoders.mobplugin.entities.BaseEntity; 10 | import nukkitcoders.mobplugin.entities.animal.swimming.Dolphin; 11 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 12 | import nukkitcoders.mobplugin.utils.Utils; 13 | 14 | public class DolphinSpawner extends AbstractEntitySpawner { 15 | 16 | public DolphinSpawner(AutoSpawnTask spawnTask) { 17 | super(spawnTask); 18 | } 19 | 20 | public void spawn(Player player, Position pos, Level level) { 21 | if (Utils.rand(1, 3) != 1) { 22 | return; 23 | } 24 | final int biomeId = level.getBiomeId((int) pos.x, (int) pos.z); 25 | final int blockId = level.getBlockIdAt((int) pos.x, (int) pos.y, (int) pos.z); 26 | if ((blockId == Block.WATER || blockId == Block.STILL_WATER) && (biomeId == 0 || biomeId == 24)) { 27 | if (MobPlugin.isAnimalSpawningAllowedByTime(level)) { 28 | final int b = level.getBlockIdAt((int) pos.x, (int) (pos.y -1), (int) pos.z); 29 | if (b == Block.WATER || b == Block.STILL_WATER) { 30 | for (int i = 0; i < Utils.rand(1, 3); i++) { 31 | BaseEntity entity = this.spawnTask.createEntity("Dolphin", pos.add(0, -1, 0)); 32 | if (entity == null) return; 33 | if (Utils.rand(1, 10) == 1) { 34 | entity.setBaby(true); 35 | } 36 | } 37 | } 38 | } 39 | } 40 | } 41 | 42 | @Override 43 | public final int getEntityNetworkId() { 44 | return Dolphin.NETWORK_ID; 45 | } 46 | 47 | @Override 48 | public boolean isWaterMob() { 49 | return true; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/DonkeySpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.Block; 5 | import cn.nukkit.level.Level; 6 | import cn.nukkit.level.Position; 7 | import nukkitcoders.mobplugin.AutoSpawnTask; 8 | import nukkitcoders.mobplugin.MobPlugin; 9 | import nukkitcoders.mobplugin.entities.BaseEntity; 10 | import nukkitcoders.mobplugin.entities.animal.walking.Donkey; 11 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 12 | import nukkitcoders.mobplugin.utils.Utils; 13 | 14 | public class DonkeySpawner extends AbstractEntitySpawner { 15 | 16 | public DonkeySpawner(AutoSpawnTask spawnTask) { 17 | super(spawnTask); 18 | } 19 | 20 | @Override 21 | public void spawn(Player player, Position pos, Level level) { 22 | if (Utils.rand(1, 3) != 1) { 23 | return; 24 | } 25 | int blockId = level.getBlockIdAt((int) pos.x, (int) pos.y, (int) pos.z); 26 | if (blockId == Block.GRASS || blockId == Block.SNOW_LAYER) { 27 | final int biomeId = level.getBiomeId((int) pos.x, (int) pos.z); 28 | if (biomeId == 1 || biomeId == 35 || biomeId == 128 || biomeId == 129) { 29 | if (MobPlugin.isAnimalSpawningAllowedByTime(level)) { 30 | for (int i = 0; i < Utils.rand(1, 3); i++) { 31 | BaseEntity entity = this.spawnTask.createEntity("Donkey", pos.add(0.5, 1, 0.5)); 32 | if (entity == null) return; 33 | if (Utils.rand(1, 20) == 1) { 34 | entity.setBaby(true); 35 | } 36 | } 37 | } 38 | } 39 | } 40 | } 41 | 42 | @Override 43 | public final int getEntityNetworkId() { 44 | return Donkey.NETWORK_ID; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/DrownedSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.Block; 5 | import cn.nukkit.level.Level; 6 | import cn.nukkit.level.Position; 7 | import nukkitcoders.mobplugin.AutoSpawnTask; 8 | import nukkitcoders.mobplugin.MobPlugin; 9 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 10 | import nukkitcoders.mobplugin.entities.monster.walking.Drowned; 11 | 12 | public class DrownedSpawner extends AbstractEntitySpawner { 13 | 14 | public DrownedSpawner(AutoSpawnTask spawnTask) { 15 | super(spawnTask); 16 | } 17 | 18 | public void spawn(Player player, Position pos, Level level) { 19 | final int blockId = level.getBlockIdAt((int) pos.x, (int) pos.y, (int) pos.z); 20 | if (blockId == Block.WATER || blockId == Block.STILL_WATER) { 21 | final int biomeId = level.getBiomeId((int) pos.x, (int) pos.z); 22 | if (biomeId == 0 || biomeId == 7 || biomeId == 10 || biomeId == 11 || biomeId == 24 || (biomeId >= 40 && biomeId <= 47)) { 23 | if (level.getBlockLightAt((int) pos.x, (int) pos.y + 1, (int) pos.z) <= 7) { 24 | if (MobPlugin.isMobSpawningAllowedByTime(level)) { 25 | final int b = level.getBlockIdAt((int) pos.x, (int) (pos.y -1), (int) pos.z); 26 | if (b == Block.WATER || b == Block.STILL_WATER) { 27 | this.spawnTask.createEntity("Drowned", pos.add(0.5, -1, 0.5)); 28 | } 29 | } 30 | } 31 | } 32 | } 33 | } 34 | 35 | @Override 36 | public final int getEntityNetworkId() { 37 | return Drowned.NETWORK_ID; 38 | } 39 | 40 | @Override 41 | public boolean isWaterMob() { 42 | return true; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/EndermanSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.level.Level; 5 | import cn.nukkit.level.Position; 6 | import nukkitcoders.mobplugin.AutoSpawnTask; 7 | import nukkitcoders.mobplugin.MobPlugin; 8 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 9 | import nukkitcoders.mobplugin.entities.monster.walking.Enderman; 10 | import nukkitcoders.mobplugin.utils.Utils; 11 | 12 | public class EndermanSpawner extends AbstractEntitySpawner { 13 | 14 | public EndermanSpawner(AutoSpawnTask spawnTask) { 15 | super(spawnTask); 16 | } 17 | 18 | public void spawn(Player player, Position pos, Level level) { 19 | boolean nether = level.getDimension() == Level.DIMENSION_NETHER; 20 | boolean end = level.getDimension() == Level.DIMENSION_THE_END; 21 | 22 | if (!nether && !end && !MobPlugin.isMobSpawningAllowedByTime(level)) { 23 | return; 24 | } 25 | 26 | if (!end && Utils.rand(1, nether ? 10 : 7) != 1) { 27 | return; 28 | } 29 | 30 | if (level.getBlockLightAt((int) pos.x, (int) pos.y + 1, (int) pos.z) <= 7 || nether || end) { 31 | if (end) { 32 | for (int i = 0; i < Utils.rand(1, 4); i++) { 33 | this.spawnTask.createEntity("Enderman", pos.add(0.5, 1, 0.5)); 34 | } 35 | } else { 36 | this.spawnTask.createEntity("Enderman", pos.add(0.5, 1, 0.5)); 37 | } 38 | } 39 | } 40 | 41 | @Override 42 | public final int getEntityNetworkId() { 43 | return Enderman.NETWORK_ID; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/FoxSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.Block; 5 | import cn.nukkit.level.Level; 6 | import cn.nukkit.level.Position; 7 | import nukkitcoders.mobplugin.AutoSpawnTask; 8 | import nukkitcoders.mobplugin.MobPlugin; 9 | import nukkitcoders.mobplugin.entities.BaseEntity; 10 | import nukkitcoders.mobplugin.entities.animal.walking.Fox; 11 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 12 | import nukkitcoders.mobplugin.utils.Utils; 13 | 14 | public class FoxSpawner extends AbstractEntitySpawner { 15 | 16 | public FoxSpawner(AutoSpawnTask spawnTask) { 17 | super(spawnTask); 18 | } 19 | 20 | public void spawn(Player player, Position pos, Level level) { 21 | if (Utils.rand(1, 3) != 1) { 22 | return; 23 | } 24 | int blockId = level.getBlockIdAt((int) pos.x, (int) pos.y, (int) pos.z); 25 | if (blockId == Block.GRASS || blockId == Block.SNOW_LAYER) { 26 | final int biomeId = level.getBiomeId((int) pos.x, (int) pos.z); 27 | if (biomeId == 5 || biomeId == 160 || biomeId == 161 || biomeId == 31 || biomeId == 19 || biomeId == 30 || biomeId == 133 || biomeId == 158 || biomeId == 32 || biomeId == 33) { 28 | if (MobPlugin.isAnimalSpawningAllowedByTime(level)) { 29 | for (int i = 0; i < Utils.rand(2, 4); i++) { 30 | BaseEntity entity = this.spawnTask.createEntity("Fox", pos.add(0.5, 1, 0.5)); 31 | if (entity == null) return; 32 | if (Utils.rand(1, 20) == 1) { 33 | entity.setBaby(true); 34 | } 35 | } 36 | } 37 | } 38 | } 39 | } 40 | 41 | @Override 42 | public final int getEntityNetworkId() { 43 | return Fox.NETWORK_ID; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/GhastSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.level.Level; 5 | import cn.nukkit.level.Position; 6 | import nukkitcoders.mobplugin.AutoSpawnTask; 7 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 8 | import nukkitcoders.mobplugin.entities.monster.flying.Ghast; 9 | import nukkitcoders.mobplugin.utils.Utils; 10 | 11 | public class GhastSpawner extends AbstractEntitySpawner { 12 | 13 | public GhastSpawner(AutoSpawnTask spawnTask) { 14 | super(spawnTask); 15 | } 16 | 17 | @Override 18 | public void spawn(Player player, Position pos, Level level) { 19 | if (Utils.rand(1, 3) != 1) { 20 | this.spawnTask.createEntity("Ghast", pos.add(0.5, 1, 0.5)); 21 | } 22 | } 23 | 24 | @Override 25 | public int getEntityNetworkId() { 26 | return Ghast.NETWORK_ID; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/HoglinSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.level.Level; 5 | import cn.nukkit.level.Position; 6 | import nukkitcoders.mobplugin.AutoSpawnTask; 7 | import nukkitcoders.mobplugin.entities.BaseEntity; 8 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 9 | import nukkitcoders.mobplugin.entities.monster.walking.Hoglin; 10 | import nukkitcoders.mobplugin.utils.Utils; 11 | 12 | public class HoglinSpawner extends AbstractEntitySpawner { 13 | 14 | public HoglinSpawner(AutoSpawnTask spawnTask) { 15 | super(spawnTask); 16 | } 17 | 18 | @Override 19 | public void spawn(Player player, Position pos, Level level) { 20 | if (Utils.rand(1, 3) != 1 && level.getBlockLightAt((int) pos.x, (int) pos.y + 1, (int) pos.z) <= 7) { 21 | int biome = level.getBiomeId((int) pos.x, (int) pos.z); 22 | if (biome == 179) { 23 | for (int i = 0; i < 4; i++) { 24 | BaseEntity entity = this.spawnTask.createEntity("Hoglin", pos.add(0.5, 1, 0.5)); 25 | if (entity == null) return; 26 | if (Utils.rand(1, 20) == 1) { 27 | entity.setBaby(true); 28 | } 29 | } 30 | } 31 | } 32 | } 33 | 34 | @Override 35 | public final int getEntityNetworkId() { 36 | return Hoglin.NETWORK_ID; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/HorseSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.Block; 5 | import cn.nukkit.level.Level; 6 | import cn.nukkit.level.Position; 7 | import nukkitcoders.mobplugin.AutoSpawnTask; 8 | import nukkitcoders.mobplugin.MobPlugin; 9 | import nukkitcoders.mobplugin.entities.BaseEntity; 10 | import nukkitcoders.mobplugin.entities.animal.walking.Horse; 11 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 12 | import nukkitcoders.mobplugin.utils.Utils; 13 | 14 | public class HorseSpawner extends AbstractEntitySpawner { 15 | 16 | public HorseSpawner(AutoSpawnTask spawnTask) { 17 | super(spawnTask); 18 | } 19 | 20 | @Override 21 | public void spawn(Player player, Position pos, Level level) { 22 | if (Utils.rand(1, 3) != 1) { 23 | return; 24 | } 25 | int blockId = level.getBlockIdAt((int) pos.x, (int) pos.y, (int) pos.z); 26 | if (blockId == Block.GRASS || blockId == Block.SNOW_LAYER) { 27 | final int biomeId = level.getBiomeId((int) pos.x, (int) pos.z); 28 | if (biomeId == 1 || biomeId == 35 || biomeId == 128 || biomeId == 129) { 29 | if (MobPlugin.isAnimalSpawningAllowedByTime(level)) { 30 | for (int i = 0; i < Utils.rand(2, 6); i++) { 31 | BaseEntity entity = this.spawnTask.createEntity("Horse", pos.add(0.5, 1, 0.5)); 32 | if (entity == null) return; 33 | if (Utils.rand(1, 20) == 1) { 34 | entity.setBaby(true); 35 | } 36 | } 37 | } 38 | } 39 | } 40 | } 41 | 42 | @Override 43 | public final int getEntityNetworkId() { 44 | return Horse.NETWORK_ID; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/HuskSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.level.Level; 5 | import cn.nukkit.level.Position; 6 | import nukkitcoders.mobplugin.AutoSpawnTask; 7 | import nukkitcoders.mobplugin.MobPlugin; 8 | import nukkitcoders.mobplugin.entities.BaseEntity; 9 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 10 | import nukkitcoders.mobplugin.entities.monster.walking.Husk; 11 | import nukkitcoders.mobplugin.utils.Utils; 12 | 13 | public class HuskSpawner extends AbstractEntitySpawner { 14 | 15 | public HuskSpawner(AutoSpawnTask spawnTask) { 16 | super(spawnTask); 17 | } 18 | 19 | @Override 20 | public void spawn(Player player, Position pos, Level level) { 21 | final int biomeId = level.getBiomeId((int) pos.x, (int) pos.z); 22 | if (biomeId == 2 || biomeId == 130) { 23 | if (level.getBlockLightAt((int) pos.x, (int) pos.y + 1, (int) pos.z) <= 7) { 24 | if (MobPlugin.isMobSpawningAllowedByTime(level)) { 25 | BaseEntity entity = this.spawnTask.createEntity("Husk", pos.add(0.5, 1, 0.5)); 26 | if (entity == null) return; 27 | if (Utils.rand(1, 20) == 1) { 28 | entity.setBaby(true); 29 | } 30 | } 31 | } 32 | } 33 | } 34 | 35 | @Override 36 | public final int getEntityNetworkId() { 37 | return Husk.NETWORK_ID; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/LlamaSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.Block; 5 | import cn.nukkit.level.Level; 6 | import cn.nukkit.level.Position; 7 | import nukkitcoders.mobplugin.AutoSpawnTask; 8 | import nukkitcoders.mobplugin.MobPlugin; 9 | import nukkitcoders.mobplugin.entities.BaseEntity; 10 | import nukkitcoders.mobplugin.entities.animal.walking.Llama; 11 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 12 | import nukkitcoders.mobplugin.utils.Utils; 13 | 14 | public class LlamaSpawner extends AbstractEntitySpawner { 15 | 16 | public LlamaSpawner(AutoSpawnTask spawnTask) { 17 | super(spawnTask); 18 | } 19 | 20 | @Override 21 | public void spawn(Player player, Position pos, Level level) { 22 | if (Utils.rand(1, 3) != 1) { 23 | return; 24 | } 25 | final int biomeId = level.getBiomeId((int) pos.x, (int) pos.z); 26 | if (biomeId == 35 || biomeId == 36 || biomeId == 163 || biomeId == 164) { 27 | if (MobPlugin.isAnimalSpawningAllowedByTime(level)) { 28 | int blockId = level.getBlockIdAt((int) pos.x, (int) pos.y, (int) pos.z); 29 | if (blockId == Block.GRASS || blockId == Block.SNOW_LAYER) { 30 | for (int i = 0; i < 4; i++) { 31 | BaseEntity entity = this.spawnTask.createEntity("Llama", pos.add(0.5, 1, 0.5)); 32 | if (entity == null) return; 33 | if (Utils.rand(1, 20) == 1) { 34 | entity.setBaby(true); 35 | } 36 | } 37 | } 38 | } 39 | } 40 | } 41 | 42 | @Override 43 | public final int getEntityNetworkId() { 44 | return Llama.NETWORK_ID; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/MagmaCubeSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.level.Level; 5 | import cn.nukkit.level.Position; 6 | import nukkitcoders.mobplugin.AutoSpawnTask; 7 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 8 | import nukkitcoders.mobplugin.entities.monster.jumping.MagmaCube; 9 | import nukkitcoders.mobplugin.utils.Utils; 10 | 11 | public class MagmaCubeSpawner extends AbstractEntitySpawner { 12 | 13 | public MagmaCubeSpawner(AutoSpawnTask spawnTask) { 14 | super(spawnTask); 15 | } 16 | 17 | @Override 18 | public void spawn(Player player, Position pos, Level level) { 19 | if (Utils.rand(1, 3) != 1) { 20 | this.spawnTask.createEntity("MagmaCube", pos.add(0.5, 1, 0.5)); 21 | } 22 | } 23 | 24 | @Override 25 | public final int getEntityNetworkId() { 26 | return MagmaCube.NETWORK_ID; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/MooshroomSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.Block; 5 | import cn.nukkit.level.Level; 6 | import cn.nukkit.level.Position; 7 | import nukkitcoders.mobplugin.AutoSpawnTask; 8 | import nukkitcoders.mobplugin.MobPlugin; 9 | import nukkitcoders.mobplugin.entities.BaseEntity; 10 | import nukkitcoders.mobplugin.entities.animal.walking.Mooshroom; 11 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 12 | import nukkitcoders.mobplugin.utils.Utils; 13 | 14 | public class MooshroomSpawner extends AbstractEntitySpawner { 15 | 16 | public MooshroomSpawner(AutoSpawnTask spawnTask) { 17 | super(spawnTask); 18 | } 19 | 20 | public void spawn(Player player, Position pos, Level level) { 21 | if (Utils.rand(1, 3) != 1) { 22 | return; 23 | } 24 | int biomeId = level.getBiomeId((int) pos.x, (int) pos.z); 25 | if (biomeId == 14 || biomeId == 15) { 26 | if (MobPlugin.isAnimalSpawningAllowedByTime(level)) { 27 | if (level.getBlockIdAt((int) pos.x, (int) pos.y, (int) pos.z) == Block.MYCELIUM) { 28 | for (int i = 0; i < Utils.rand(4, 8); i++) { 29 | BaseEntity entity = this.spawnTask.createEntity("Mooshroom", pos.add(0.5, 1, 0.5)); 30 | if (entity == null) return; 31 | if (Utils.rand(1, 20) == 1) { 32 | entity.setBaby(true); 33 | } 34 | } 35 | } 36 | } 37 | } 38 | } 39 | 40 | @Override 41 | public final int getEntityNetworkId() { 42 | return Mooshroom.NETWORK_ID; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/OcelotSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.Block; 5 | import cn.nukkit.level.Level; 6 | import cn.nukkit.level.Position; 7 | import nukkitcoders.mobplugin.AutoSpawnTask; 8 | import nukkitcoders.mobplugin.MobPlugin; 9 | import nukkitcoders.mobplugin.entities.BaseEntity; 10 | import nukkitcoders.mobplugin.entities.animal.walking.Ocelot; 11 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 12 | import nukkitcoders.mobplugin.utils.Utils; 13 | 14 | public class OcelotSpawner extends AbstractEntitySpawner { 15 | 16 | public OcelotSpawner(AutoSpawnTask spawnTask) { 17 | super(spawnTask); 18 | } 19 | 20 | public void spawn(Player player, Position pos, Level level) { 21 | if (Utils.rand(1, 3) != 1) { 22 | return; 23 | } 24 | final int biomeId = level.getBiomeId((int) pos.x, (int) pos.z); 25 | if (biomeId == 21 || biomeId == 149 || biomeId == 23 || biomeId == 151 || biomeId == 48 || biomeId == 49) { 26 | final int blockId = level.getBlockIdAt((int) pos.x, (int) pos.y, (int) pos.z); 27 | if (blockId == Block.GRASS) { 28 | if (MobPlugin.isAnimalSpawningAllowedByTime(level)) { 29 | for (int i = 0; i < Utils.rand(1, 2); i++) { 30 | BaseEntity entity = this.spawnTask.createEntity("Ocelot", pos.add(0.5, 1, 0.5)); 31 | if (entity == null) return; 32 | if (Utils.rand(1, 20) == 1) { 33 | entity.setBaby(true); 34 | } 35 | } 36 | } 37 | } 38 | } 39 | } 40 | 41 | @Override 42 | public final int getEntityNetworkId() { 43 | return Ocelot.NETWORK_ID; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/PandaSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.Block; 5 | import cn.nukkit.level.Level; 6 | import cn.nukkit.level.Position; 7 | import nukkitcoders.mobplugin.AutoSpawnTask; 8 | import nukkitcoders.mobplugin.MobPlugin; 9 | import nukkitcoders.mobplugin.entities.BaseEntity; 10 | import nukkitcoders.mobplugin.entities.animal.walking.Panda; 11 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 12 | import nukkitcoders.mobplugin.utils.Utils; 13 | 14 | public class PandaSpawner extends AbstractEntitySpawner { 15 | 16 | public PandaSpawner(AutoSpawnTask spawnTask) { 17 | super(spawnTask); 18 | } 19 | 20 | public void spawn(Player player, Position pos, Level level) { 21 | if (Utils.rand(1, 3) != 1) { 22 | return; 23 | } 24 | final int biomeId = level.getBiomeId((int) pos.x, (int) pos.z); 25 | if (((biomeId == 21 || biomeId == 22) && Utils.rand(1, 10) != 1) || biomeId != 48 && biomeId != 49 && biomeId != 21 && biomeId != 22) { 26 | return; 27 | } 28 | if (!MobPlugin.isAnimalSpawningAllowedByTime(level) || level.getBlockIdAt((int) pos.x, (int) pos.y, (int) pos.z) != Block.GRASS) { 29 | return; 30 | } 31 | for (int i = 0; i < Utils.rand(1, 2); i++) { 32 | BaseEntity entity = this.spawnTask.createEntity("Panda", pos.add(0.5, 1, 0.5)); 33 | if (entity == null) return; 34 | if (Utils.rand(1, 20) == 1) { 35 | entity.setBaby(true); 36 | } 37 | } 38 | } 39 | 40 | @Override 41 | public final int getEntityNetworkId() { 42 | return Panda.NETWORK_ID; 43 | } 44 | } -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/ParrotSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.Block; 5 | import cn.nukkit.level.Level; 6 | import cn.nukkit.level.Position; 7 | import nukkitcoders.mobplugin.AutoSpawnTask; 8 | import nukkitcoders.mobplugin.MobPlugin; 9 | import nukkitcoders.mobplugin.entities.animal.flying.Parrot; 10 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 11 | import nukkitcoders.mobplugin.utils.Utils; 12 | 13 | public class ParrotSpawner extends AbstractEntitySpawner { 14 | 15 | public ParrotSpawner(AutoSpawnTask spawnTask) { 16 | super(spawnTask); 17 | } 18 | 19 | public void spawn(Player player, Position pos, Level level) { 20 | if (pos.y < 70 || Utils.rand(1, 3) != 1) { 21 | return; 22 | } 23 | final int biomeId = level.getBiomeId((int) pos.x, (int) pos.z); 24 | if (biomeId == 21 || biomeId == 149 || biomeId == 23 || biomeId == 151 || biomeId == 48 || biomeId == 49) { 25 | final int blockId = level.getBlockIdAt((int) pos.x, (int) pos.y, (int) pos.z); 26 | if (blockId == Block.GRASS || blockId == Block.LEAVES || blockId == Block.WOOD) { 27 | if (MobPlugin.isAnimalSpawningAllowedByTime(level)) { 28 | for (int i = 0; i < Utils.rand(1, 2); i++) { 29 | this.spawnTask.createEntity("Parrot", pos.add(0.5, 1, 0.5)); 30 | } 31 | } 32 | } 33 | } 34 | } 35 | 36 | @Override 37 | public final int getEntityNetworkId() { 38 | return Parrot.NETWORK_ID; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/PigSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.Block; 5 | import cn.nukkit.level.Level; 6 | import cn.nukkit.level.Position; 7 | import nukkitcoders.mobplugin.AutoSpawnTask; 8 | import nukkitcoders.mobplugin.MobPlugin; 9 | import nukkitcoders.mobplugin.entities.BaseEntity; 10 | import nukkitcoders.mobplugin.entities.animal.walking.Pig; 11 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 12 | import nukkitcoders.mobplugin.utils.Utils; 13 | 14 | public class PigSpawner extends AbstractEntitySpawner { 15 | 16 | public PigSpawner(AutoSpawnTask spawnTask) { 17 | super(spawnTask); 18 | } 19 | 20 | public void spawn(Player player, Position pos, Level level) { 21 | if (Utils.rand(1, 3) != 1) { 22 | return; 23 | } 24 | if (MobPlugin.isAnimalSpawningAllowedByTime(level)) { 25 | int blockId = level.getBlockIdAt((int) pos.x, (int) pos.y, (int) pos.z); 26 | if (blockId == Block.GRASS || blockId == Block.SNOW_LAYER) { 27 | for (int i = 0; i < Utils.rand(1, 3); i++) { 28 | BaseEntity entity = this.spawnTask.createEntity("Pig", pos.add(0.5, 1, 0.5)); 29 | if (entity == null) return; 30 | if (Utils.rand(1, 20) == 1) { 31 | entity.setBaby(true); 32 | } 33 | } 34 | } 35 | } 36 | } 37 | 38 | @Override 39 | public final int getEntityNetworkId() { 40 | return Pig.NETWORK_ID; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/PiglinSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.Block; 5 | import cn.nukkit.level.Level; 6 | import cn.nukkit.level.Position; 7 | import nukkitcoders.mobplugin.AutoSpawnTask; 8 | import nukkitcoders.mobplugin.entities.BaseEntity; 9 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 10 | import nukkitcoders.mobplugin.entities.monster.walking.Piglin; 11 | import nukkitcoders.mobplugin.utils.Utils; 12 | 13 | public class PiglinSpawner extends AbstractEntitySpawner { 14 | 15 | public PiglinSpawner(AutoSpawnTask spawnTask) { 16 | super(spawnTask); 17 | } 18 | 19 | @Override 20 | public void spawn(Player player, Position pos, Level level) { 21 | if (level.getBlockIdAt((int) pos.x, (int) pos.y, (int) pos.z) == Block.NETHERRACK && level.getBlockLightAt((int) pos.x, (int) pos.y + 1, (int) pos.z) <= 7) { 22 | for (int i = 0; i < Utils.rand(2, 4); i++) { 23 | BaseEntity entity = this.spawnTask.createEntity("Piglin", pos.add(0.5, 1, 0.5)); 24 | if (entity == null) return; 25 | if (Utils.rand(1, 20) == 1) { 26 | entity.setBaby(true); 27 | } 28 | } 29 | } 30 | } 31 | 32 | @Override 33 | public final int getEntityNetworkId() { 34 | return Piglin.NETWORK_ID; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/PolarBearSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.Block; 5 | import cn.nukkit.level.Level; 6 | import cn.nukkit.level.Position; 7 | import nukkitcoders.mobplugin.AutoSpawnTask; 8 | import nukkitcoders.mobplugin.MobPlugin; 9 | import nukkitcoders.mobplugin.entities.BaseEntity; 10 | import nukkitcoders.mobplugin.entities.animal.walking.PolarBear; 11 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 12 | import nukkitcoders.mobplugin.utils.Utils; 13 | 14 | public class PolarBearSpawner extends AbstractEntitySpawner { 15 | 16 | public PolarBearSpawner(AutoSpawnTask spawnTask) { 17 | super(spawnTask); 18 | } 19 | 20 | @Override 21 | public void spawn(Player player, Position pos, Level level) { 22 | if (Utils.rand(1, 3) != 1) { 23 | return; 24 | } 25 | if (level.getBiomeId((int) pos.x, (int) pos.z) == 12) { 26 | if (MobPlugin.isAnimalSpawningAllowedByTime(level)) { 27 | int blockId = level.getBlockIdAt((int) pos.x, (int) pos.y, (int) pos.z); 28 | if (blockId == Block.GRASS || blockId == Block.SNOW_LAYER) { 29 | for (int i = 0; i < Utils.rand(1, 2); i++) { 30 | BaseEntity entity = this.spawnTask.createEntity("PolarBear", pos.add(0.5, 1, 0.5)); 31 | if (entity == null) return; 32 | if (Utils.rand(1, 20) == 1) { 33 | entity.setBaby(true); 34 | } 35 | } 36 | } 37 | } 38 | } 39 | } 40 | 41 | @Override 42 | public final int getEntityNetworkId() { 43 | return PolarBear.NETWORK_ID; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/PufferfishSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.Block; 5 | import cn.nukkit.level.Level; 6 | import cn.nukkit.level.Position; 7 | import nukkitcoders.mobplugin.AutoSpawnTask; 8 | import nukkitcoders.mobplugin.entities.animal.swimming.Pufferfish; 9 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 10 | import nukkitcoders.mobplugin.utils.Utils; 11 | 12 | public class PufferfishSpawner extends AbstractEntitySpawner { 13 | 14 | public PufferfishSpawner(AutoSpawnTask spawnTask) { 15 | super(spawnTask); 16 | } 17 | 18 | public void spawn(Player player, Position pos, Level level) { 19 | if (Utils.rand(1, 3) != 1) { 20 | return; 21 | } 22 | final int blockId = level.getBlockIdAt((int) pos.x, (int) pos.y, (int) pos.z); 23 | if (blockId == Block.WATER || blockId == Block.STILL_WATER) { 24 | final int biomeId = level.getBiomeId((int) pos.x, (int) pos.z); 25 | if (biomeId == 40 || biomeId == 42 || biomeId == 43) { 26 | final int b = level.getBlockIdAt((int) pos.x, (int) (pos.y - 1), (int) pos.z); 27 | if (b == Block.WATER || b == Block.STILL_WATER) { 28 | for (int i = 0; i < Utils.rand(3, 5); i++) { 29 | this.spawnTask.createEntity("Pufferfish", pos.add(0, -1, 0)); 30 | } 31 | } 32 | } 33 | } 34 | } 35 | 36 | @Override 37 | public final int getEntityNetworkId() { 38 | return Pufferfish.NETWORK_ID; 39 | } 40 | 41 | @Override 42 | public boolean isWaterMob() { 43 | return true; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/RabbitSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.Block; 5 | import cn.nukkit.level.Level; 6 | import cn.nukkit.level.Position; 7 | import nukkitcoders.mobplugin.AutoSpawnTask; 8 | import nukkitcoders.mobplugin.MobPlugin; 9 | import nukkitcoders.mobplugin.entities.animal.jumping.Rabbit; 10 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 11 | import nukkitcoders.mobplugin.utils.Utils; 12 | 13 | public class RabbitSpawner extends AbstractEntitySpawner { 14 | 15 | public RabbitSpawner(AutoSpawnTask spawnTask) { 16 | super(spawnTask); 17 | } 18 | 19 | @Override 20 | public void spawn(Player player, Position pos, Level level) { 21 | if (Utils.rand(1, 3) != 1) { 22 | return; 23 | } 24 | int blockId = level.getBlockIdAt((int) pos.x, (int) pos.y, (int) pos.z); 25 | if (blockId == Block.GRASS || blockId == Block.SNOW_LAYER || blockId == Block.SAND) { 26 | final int biomeId = level.getBiomeId((int) pos.x, (int) pos.z); 27 | if (biomeId == 2 || biomeId == 130 || biomeId == 30 || biomeId == 5 || biomeId == 12 || biomeId == 26 || biomeId == 11) { 28 | if (MobPlugin.isAnimalSpawningAllowedByTime(level)) { 29 | for (int i = 0; i < Utils.rand(1, 3); i++) { 30 | this.spawnTask.createEntity("Rabbit", pos.add(0.5, 1, 0.5)); 31 | } 32 | } 33 | } 34 | } 35 | } 36 | 37 | @Override 38 | public final int getEntityNetworkId() { 39 | return Rabbit.NETWORK_ID; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/SalmonSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.Block; 5 | import cn.nukkit.level.Level; 6 | import cn.nukkit.level.Position; 7 | import nukkitcoders.mobplugin.AutoSpawnTask; 8 | import nukkitcoders.mobplugin.entities.animal.swimming.Salmon; 9 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 10 | import nukkitcoders.mobplugin.utils.Utils; 11 | 12 | public class SalmonSpawner extends AbstractEntitySpawner { 13 | 14 | public SalmonSpawner(AutoSpawnTask spawnTask) { 15 | super(spawnTask); 16 | } 17 | 18 | public void spawn(Player player, Position pos, Level level) { 19 | if (Utils.rand(1, 3) != 1) { 20 | return; 21 | } 22 | final int blockId = level.getBlockIdAt((int) pos.x, (int) pos.y, (int) pos.z); 23 | if (blockId == Block.WATER || blockId == Block.STILL_WATER) { 24 | final int biomeId = level.getBiomeId((int) pos.x, (int) pos.z); 25 | if (biomeId == 7 || biomeId == 11 || biomeId == 44 || biomeId == 45 || biomeId == 10 || biomeId == 47) { 26 | final int b = level.getBlockIdAt((int) pos.x, (int) (pos.y -1), (int) pos.z); 27 | if (b == Block.WATER || b == Block.STILL_WATER) { 28 | for (int i = 0; i < Utils.rand(3, 5); i++) { 29 | this.spawnTask.createEntity("Salmon", pos.add(0, -1, 0)); 30 | } 31 | } 32 | } 33 | } 34 | } 35 | 36 | @Override 37 | public final int getEntityNetworkId() { 38 | return Salmon.NETWORK_ID; 39 | } 40 | 41 | @Override 42 | public boolean isWaterMob() { 43 | return true; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/SheepSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.Block; 5 | import cn.nukkit.level.Level; 6 | import cn.nukkit.level.Position; 7 | import nukkitcoders.mobplugin.AutoSpawnTask; 8 | import nukkitcoders.mobplugin.MobPlugin; 9 | import nukkitcoders.mobplugin.entities.BaseEntity; 10 | import nukkitcoders.mobplugin.entities.animal.walking.Sheep; 11 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 12 | import nukkitcoders.mobplugin.utils.Utils; 13 | 14 | public class SheepSpawner extends AbstractEntitySpawner { 15 | 16 | public SheepSpawner(AutoSpawnTask spawnTask) { 17 | super(spawnTask); 18 | } 19 | 20 | public void spawn(Player player, Position pos, Level level) { 21 | if (Utils.rand(1, 3) != 1) { 22 | return; 23 | } 24 | if (MobPlugin.isAnimalSpawningAllowedByTime(level)) { 25 | int blockId = level.getBlockIdAt((int) pos.x, (int) pos.y, (int) pos.z); 26 | if (blockId == Block.GRASS || blockId == Block.SNOW_LAYER) { 27 | for (int i = 0; i < Utils.rand(2, 3); i++) { 28 | BaseEntity entity = this.spawnTask.createEntity("Sheep", pos.add(0.5, 1, 0.5)); 29 | if (entity == null) return; 30 | if (Utils.rand(1, 20) == 1) { 31 | entity.setBaby(true); 32 | } 33 | } 34 | } 35 | } 36 | } 37 | 38 | @Override 39 | public final int getEntityNetworkId() { 40 | return Sheep.NETWORK_ID; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/SkeletonSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.level.Level; 5 | import cn.nukkit.level.Position; 6 | import nukkitcoders.mobplugin.AutoSpawnTask; 7 | import nukkitcoders.mobplugin.MobPlugin; 8 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 9 | import nukkitcoders.mobplugin.entities.monster.walking.Skeleton; 10 | 11 | public class SkeletonSpawner extends AbstractEntitySpawner { 12 | 13 | public SkeletonSpawner(AutoSpawnTask spawnTask) { 14 | super(spawnTask); 15 | } 16 | 17 | @Override 18 | public void spawn(Player player, Position pos, Level level) { 19 | if (level.getBlockLightAt((int) pos.x, (int) pos.y + 1, (int) pos.z) <= 7) { 20 | if (MobPlugin.isMobSpawningAllowedByTime(level)) { 21 | this.spawnTask.createEntity("Skeleton", pos.add(0.5, 1, 0.5)); 22 | } 23 | } 24 | } 25 | 26 | @Override 27 | public final int getEntityNetworkId() { 28 | return Skeleton.NETWORK_ID; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/SlimeSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.level.Level; 5 | import cn.nukkit.level.Position; 6 | import nukkitcoders.mobplugin.AutoSpawnTask; 7 | import nukkitcoders.mobplugin.MobPlugin; 8 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 9 | import nukkitcoders.mobplugin.entities.monster.jumping.Slime; 10 | 11 | public class SlimeSpawner extends AbstractEntitySpawner { 12 | 13 | public SlimeSpawner(AutoSpawnTask spawnTask) { 14 | super(spawnTask); 15 | } 16 | 17 | @Override 18 | public void spawn(Player player, Position pos, Level level) { 19 | final int biomeId = level.getBiomeId((int) pos.x, (int) pos.z); 20 | if (pos.y < 70 && (biomeId == 6 || biomeId == 134)) { 21 | if (level.getBlockLightAt((int) pos.x, (int) pos.y + 1, (int) pos.z) <= 7) { 22 | if (MobPlugin.isMobSpawningAllowedByTime(level)) { 23 | this.spawnTask.createEntity("Slime", pos.add(0.5, 1, 0.5)); 24 | } 25 | } 26 | } 27 | } 28 | 29 | @Override 30 | public final int getEntityNetworkId() { 31 | return Slime.NETWORK_ID; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/SpiderSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.level.Level; 5 | import cn.nukkit.level.Position; 6 | import nukkitcoders.mobplugin.AutoSpawnTask; 7 | import nukkitcoders.mobplugin.MobPlugin; 8 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 9 | import nukkitcoders.mobplugin.entities.monster.walking.Spider; 10 | 11 | public class SpiderSpawner extends AbstractEntitySpawner { 12 | 13 | public SpiderSpawner(AutoSpawnTask spawnTask) { 14 | super(spawnTask); 15 | } 16 | 17 | public void spawn(Player player, Position pos, Level level) { 18 | if (level.getBlockLightAt((int) pos.x, (int) pos.y + 1, (int) pos.z) <= 7) { 19 | if (MobPlugin.isMobSpawningAllowedByTime(level)) { 20 | this.spawnTask.createEntity("Spider", pos.add(0.5, 1, 0.5)); 21 | } 22 | } 23 | } 24 | 25 | @Override 26 | public final int getEntityNetworkId() { 27 | return Spider.NETWORK_ID; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/SquidSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.Block; 5 | import cn.nukkit.level.Level; 6 | import cn.nukkit.level.Position; 7 | import nukkitcoders.mobplugin.AutoSpawnTask; 8 | import nukkitcoders.mobplugin.MobPlugin; 9 | import nukkitcoders.mobplugin.entities.BaseEntity; 10 | import nukkitcoders.mobplugin.entities.animal.swimming.Squid; 11 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 12 | import nukkitcoders.mobplugin.utils.Utils; 13 | 14 | public class SquidSpawner extends AbstractEntitySpawner { 15 | 16 | public SquidSpawner(AutoSpawnTask spawnTask) { 17 | super(spawnTask); 18 | } 19 | 20 | public void spawn(Player player, Position pos, Level level) { 21 | if (Utils.rand(1, 3) != 1) { 22 | return; 23 | } 24 | final int blockId = level.getBlockIdAt((int) pos.x, (int) pos.y, (int) pos.z); 25 | if (blockId == Block.WATER || blockId == Block.STILL_WATER) { 26 | final int biomeId = level.getBiomeId((int) pos.x, (int) pos.z); 27 | if (biomeId == 0 || biomeId == 10 || biomeId == 24 || (biomeId >= 40 && biomeId <= 47)) { 28 | if (MobPlugin.isAnimalSpawningAllowedByTime(level)) { 29 | final int b = level.getBlockIdAt((int) pos.x, (int) (pos.y - 1), (int) pos.z); 30 | if (b == Block.WATER || b == Block.STILL_WATER) { 31 | for (int i = 0; i < Utils.rand(2, 4); i++) { 32 | BaseEntity entity = this.spawnTask.createEntity("Squid", pos.add(0, -1, 0)); 33 | if (entity == null) return; 34 | if (Utils.rand(1, 20) == 1) { 35 | entity.setBaby(true); 36 | } 37 | } 38 | } 39 | } 40 | } 41 | } 42 | } 43 | 44 | @Override 45 | public final int getEntityNetworkId() { 46 | return Squid.NETWORK_ID; 47 | } 48 | 49 | @Override 50 | public boolean isWaterMob() { 51 | return true; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/StraySpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.level.Level; 5 | import cn.nukkit.level.Position; 6 | import nukkitcoders.mobplugin.AutoSpawnTask; 7 | import nukkitcoders.mobplugin.MobPlugin; 8 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 9 | import nukkitcoders.mobplugin.entities.monster.walking.Stray; 10 | 11 | public class StraySpawner extends AbstractEntitySpawner { 12 | 13 | public StraySpawner(AutoSpawnTask spawnTask) { 14 | super(spawnTask); 15 | } 16 | 17 | @Override 18 | public void spawn(Player player, Position pos, Level level) { 19 | final int biomeId = level.getBiomeId((int) pos.x, (int) pos.z); 20 | if (biomeId == 12 || biomeId == 30 || biomeId == 140 || biomeId == 10 || biomeId == 46 || biomeId == 47) { 21 | if (level.getBlockLightAt((int) pos.x, (int) pos.y + 1, (int) pos.z) <= 7) { 22 | if (MobPlugin.isMobSpawningAllowedByTime(level)) { 23 | this.spawnTask.createEntity("Stray", pos.add(0.5, 1, 0.5)); 24 | } 25 | } 26 | } 27 | } 28 | 29 | @Override 30 | public final int getEntityNetworkId() { 31 | return Stray.NETWORK_ID; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/StriderSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.level.Level; 5 | import cn.nukkit.level.Position; 6 | import nukkitcoders.mobplugin.AutoSpawnTask; 7 | import nukkitcoders.mobplugin.entities.animal.walking.Strider; 8 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 9 | import nukkitcoders.mobplugin.utils.Utils; 10 | 11 | public class StriderSpawner extends AbstractEntitySpawner { 12 | 13 | public StriderSpawner(AutoSpawnTask spawnTask) { 14 | super(spawnTask); 15 | } 16 | 17 | @Override 18 | public void spawn(Player player, Position pos, Level level) { 19 | if (Utils.rand(1, 3) != 1) { 20 | this.spawnTask.createEntity("Strider", pos.add(0.5, 1, 0.5)); 21 | } 22 | } 23 | 24 | @Override 25 | public final int getEntityNetworkId() { 26 | return Strider.NETWORK_ID; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/TropicalFishSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.Block; 5 | import cn.nukkit.level.Level; 6 | import cn.nukkit.level.Position; 7 | import nukkitcoders.mobplugin.AutoSpawnTask; 8 | import nukkitcoders.mobplugin.entities.animal.swimming.TropicalFish; 9 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 10 | import nukkitcoders.mobplugin.utils.Utils; 11 | 12 | public class TropicalFishSpawner extends AbstractEntitySpawner { 13 | 14 | public TropicalFishSpawner(AutoSpawnTask spawnTask) { 15 | super(spawnTask); 16 | } 17 | 18 | public void spawn(Player player, Position pos, Level level) { 19 | if (Utils.rand(1, 3) != 1) { 20 | return; 21 | } 22 | final int blockId = level.getBlockIdAt((int) pos.x, (int) pos.y, (int) pos.z); 23 | if (blockId == Block.WATER || blockId == Block.STILL_WATER) { 24 | final int biomeId = level.getBiomeId((int) pos.x, (int) pos.z); 25 | if (biomeId == 40 || biomeId == 42 || biomeId == 43) { 26 | final int b = level.getBlockIdAt((int) pos.x, (int) (pos.y -1), (int) pos.z); 27 | if (b == Block.WATER || b == Block.STILL_WATER) { 28 | for (int i = 0; i < Utils.rand(1, 3); i++) { 29 | this.spawnTask.createEntity("TropicalFish", pos.add(0, -1, 0)); 30 | } 31 | } 32 | } 33 | } 34 | } 35 | 36 | @Override 37 | public final int getEntityNetworkId() { 38 | return TropicalFish.NETWORK_ID; 39 | } 40 | 41 | @Override 42 | public boolean isWaterMob() { 43 | return true; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/TurtleSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.Block; 5 | import cn.nukkit.level.Level; 6 | import cn.nukkit.level.Position; 7 | import nukkitcoders.mobplugin.AutoSpawnTask; 8 | import nukkitcoders.mobplugin.MobPlugin; 9 | import nukkitcoders.mobplugin.entities.BaseEntity; 10 | import nukkitcoders.mobplugin.entities.animal.swimming.Turtle; 11 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 12 | import nukkitcoders.mobplugin.utils.Utils; 13 | 14 | public class TurtleSpawner extends AbstractEntitySpawner { 15 | 16 | public TurtleSpawner(AutoSpawnTask spawnTask) { 17 | super(spawnTask); 18 | } 19 | 20 | public void spawn(Player player, Position pos, Level level) { 21 | if (Utils.rand(1, 3) != 1) { 22 | return; 23 | } 24 | final int blockId = level.getBlockIdAt((int) pos.x, (int) pos.y, (int) pos.z); 25 | if (blockId == Block.WATER || blockId == Block.STILL_WATER) { 26 | final int biomeId = level.getBiomeId((int) pos.x, (int) pos.z); 27 | if (biomeId == 0 || biomeId == 40 || biomeId == 42) { 28 | if (MobPlugin.isAnimalSpawningAllowedByTime(level)) { 29 | final int b = level.getBlockIdAt((int) pos.x, (int) (pos.y - 1), (int) pos.z); 30 | if (b == Block.WATER || b == Block.STILL_WATER) { 31 | for (int i = 0; i < Utils.rand(2, 6); i++) { 32 | BaseEntity entity = this.spawnTask.createEntity("Turtle", pos.add(0, -1, 0)); 33 | if (entity == null) return; 34 | if (Utils.rand(1, 10) == 1) { 35 | entity.setBaby(true); 36 | } 37 | } 38 | } 39 | } 40 | } 41 | } 42 | } 43 | 44 | @Override 45 | public final int getEntityNetworkId() { 46 | return Turtle.NETWORK_ID; 47 | } 48 | 49 | @Override 50 | public boolean isWaterMob() { 51 | return true; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/WitchSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.level.Level; 5 | import cn.nukkit.level.Position; 6 | import nukkitcoders.mobplugin.AutoSpawnTask; 7 | import nukkitcoders.mobplugin.MobPlugin; 8 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 9 | import nukkitcoders.mobplugin.entities.monster.walking.Witch; 10 | import nukkitcoders.mobplugin.utils.Utils; 11 | 12 | public class WitchSpawner extends AbstractEntitySpawner { 13 | 14 | public WitchSpawner(AutoSpawnTask spawnTask) { 15 | super(spawnTask); 16 | } 17 | 18 | @Override 19 | public void spawn(Player player, Position pos, Level level) { 20 | final int biomeId = level.getBiomeId((int) pos.x, (int) pos.z); 21 | if (Utils.rand(1, 5) != 1 && biomeId != 6 && biomeId != 134) { 22 | return; 23 | } 24 | if (level.getBlockLightAt((int) pos.x, (int) pos.y + 1, (int) pos.z) <= 7) { 25 | if (MobPlugin.isMobSpawningAllowedByTime(level)) { 26 | this.spawnTask.createEntity("Witch", pos.add(0.5, 1, 0.5)); 27 | } 28 | } 29 | } 30 | 31 | @Override 32 | public final int getEntityNetworkId() { 33 | return Witch.NETWORK_ID; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/WitherSkeletonSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.Block; 5 | import cn.nukkit.level.Level; 6 | import cn.nukkit.level.Position; 7 | import nukkitcoders.mobplugin.AutoSpawnTask; 8 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 9 | import nukkitcoders.mobplugin.entities.monster.walking.WitherSkeleton; 10 | import nukkitcoders.mobplugin.utils.Utils; 11 | 12 | public class WitherSkeletonSpawner extends AbstractEntitySpawner { 13 | 14 | public WitherSkeletonSpawner(AutoSpawnTask spawnTask) { 15 | super(spawnTask); 16 | } 17 | 18 | @Override 19 | public void spawn(Player player, Position pos, Level level) { 20 | if (Utils.rand(1, 3) == 1) { 21 | return; 22 | } 23 | if (level.getBlockIdAt((int) pos.x, (int) pos.y, (int) pos.z) == Block.NETHER_BRICKS) { 24 | this.spawnTask.createEntity("WitherSkeleton", pos.add(0.5, 1, 0.5)); 25 | } 26 | } 27 | 28 | @Override 29 | public final int getEntityNetworkId() { 30 | return WitherSkeleton.NETWORK_ID; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/WolfSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.Block; 5 | import cn.nukkit.level.Level; 6 | import cn.nukkit.level.Position; 7 | import nukkitcoders.mobplugin.AutoSpawnTask; 8 | import nukkitcoders.mobplugin.MobPlugin; 9 | import nukkitcoders.mobplugin.entities.BaseEntity; 10 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 11 | import nukkitcoders.mobplugin.entities.monster.walking.Wolf; 12 | import nukkitcoders.mobplugin.utils.Utils; 13 | 14 | public class WolfSpawner extends AbstractEntitySpawner { 15 | 16 | public WolfSpawner(AutoSpawnTask spawnTask) { 17 | super(spawnTask); 18 | } 19 | 20 | @Override 21 | public void spawn(Player player, Position pos, Level level) { 22 | if (Utils.rand(1, 3) != 1) { 23 | return; 24 | } 25 | final int biomeId = level.getBiomeId((int) pos.x, (int) pos.z); 26 | if (MobPlugin.isAnimalSpawningAllowedByTime(level) && ((biomeId == 4 || biomeId == 5 || biomeId == 20 || biomeId == 27 || biomeId == 30 || biomeId == 32 || biomeId == 133 || biomeId == 158))) { 27 | int blockId = level.getBlockIdAt((int) pos.x, (int) pos.y, (int) pos.z); 28 | if (blockId == Block.GRASS || blockId == Block.SNOW_LAYER) { 29 | for (int i = 0; i < 4; i++) { 30 | BaseEntity entity = this.spawnTask.createEntity("Wolf", pos.add(0.5, 1, 0.5)); 31 | if (entity == null) return; 32 | if (Utils.rand(1, 10) == 1) { 33 | entity.setBaby(true); 34 | } 35 | } 36 | } 37 | } 38 | } 39 | 40 | @Override 41 | public final int getEntityNetworkId() { 42 | return Wolf.NETWORK_ID; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/ZombiePigmanSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.level.Level; 5 | import cn.nukkit.level.Position; 6 | import nukkitcoders.mobplugin.AutoSpawnTask; 7 | import nukkitcoders.mobplugin.entities.BaseEntity; 8 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 9 | import nukkitcoders.mobplugin.entities.monster.walking.ZombiePigman; 10 | import nukkitcoders.mobplugin.utils.Utils; 11 | 12 | public class ZombiePigmanSpawner extends AbstractEntitySpawner { 13 | 14 | public ZombiePigmanSpawner(AutoSpawnTask spawnTask) { 15 | super(spawnTask); 16 | } 17 | 18 | @Override 19 | public void spawn(Player player, Position pos, Level level) { 20 | if (level.getBlockLightAt((int) pos.x, (int) pos.y + 1, (int) pos.z) <= 7) { 21 | for (int i = 0; i < Utils.rand(2, 4); i++) { 22 | BaseEntity entity = this.spawnTask.createEntity("ZombiePigman", pos.add(0.5, 1, 0.5)); 23 | if (entity == null) return; 24 | if (Utils.rand(1, 20) == 1) { 25 | entity.setBaby(true); 26 | } 27 | } 28 | } 29 | } 30 | 31 | @Override 32 | public final int getEntityNetworkId() { 33 | return ZombiePigman.NETWORK_ID; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/entities/spawners/ZombieSpawner.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.entities.spawners; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.level.Level; 5 | import cn.nukkit.level.Position; 6 | import nukkitcoders.mobplugin.AutoSpawnTask; 7 | import nukkitcoders.mobplugin.MobPlugin; 8 | import nukkitcoders.mobplugin.entities.BaseEntity; 9 | import nukkitcoders.mobplugin.entities.autospawn.AbstractEntitySpawner; 10 | import nukkitcoders.mobplugin.entities.monster.walking.Zombie; 11 | import nukkitcoders.mobplugin.utils.Utils; 12 | 13 | public class ZombieSpawner extends AbstractEntitySpawner { 14 | 15 | public ZombieSpawner(AutoSpawnTask spawnTask) { 16 | super(spawnTask); 17 | } 18 | 19 | @Override 20 | public void spawn(Player player, Position pos, Level level) { 21 | if (level.getBlockLightAt((int) pos.x, (int) pos.y + 1, (int) pos.z) <= 7) { 22 | if (MobPlugin.isMobSpawningAllowedByTime(level)) { 23 | if (Utils.rand(1, 40) == 30) { 24 | BaseEntity entity = this.spawnTask.createEntity("ZombieVillager", pos.add(0.5, 1, 0.5)); 25 | if (entity == null) return; 26 | if (Utils.rand(1, 20) == 1) { 27 | entity.setBaby(true); 28 | } 29 | } else { 30 | BaseEntity entity = this.spawnTask.createEntity("Zombie", pos.add(0.5, 1, 0.5)); 31 | if (entity == null) return; 32 | if (Utils.rand(1, 20) == 1) { 33 | entity.setBaby(true); 34 | } 35 | } 36 | } 37 | } 38 | } 39 | 40 | @Override 41 | public final int getEntityNetworkId() { 42 | return Zombie.NETWORK_ID; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/event/entity/SpawnGolemEvent.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.event.entity; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.event.Cancellable; 5 | import cn.nukkit.event.Event; 6 | import cn.nukkit.event.HandlerList; 7 | import cn.nukkit.level.Position; 8 | 9 | public class SpawnGolemEvent extends Event implements Cancellable { 10 | 11 | private final Position golemPosition; 12 | private final Player player; 13 | private final GolemType golemType; 14 | private static final HandlerList handlers = new HandlerList(); 15 | 16 | public SpawnGolemEvent(Player player, Position golemPosition, GolemType golemType) { 17 | this.player = player; 18 | this.golemPosition = golemPosition; 19 | this.golemType = golemType; 20 | } 21 | 22 | public Player getPlayer() { 23 | return this.player; 24 | } 25 | 26 | public Position getGolemPosition() { 27 | return this.golemPosition; 28 | } 29 | 30 | public GolemType getGolemType() { 31 | return this.golemType; 32 | } 33 | 34 | public enum GolemType { 35 | IRON_GOLEM, 36 | SNOW_GOLEM 37 | } 38 | 39 | public static HandlerList getHandlers() { 40 | return handlers; 41 | } 42 | } -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/event/entity/SpawnWitherEvent.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.event.entity; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.event.Cancellable; 5 | import cn.nukkit.event.Event; 6 | import cn.nukkit.event.HandlerList; 7 | import cn.nukkit.level.Position; 8 | 9 | public class SpawnWitherEvent extends Event implements Cancellable { 10 | 11 | private final Position pos; 12 | private final Player player; 13 | private static final HandlerList handlers = new HandlerList(); 14 | 15 | public SpawnWitherEvent(Player player, Position pos) { 16 | this.player = player; 17 | this.pos = pos; 18 | } 19 | 20 | public Player getPlayer() { 21 | return this.player; 22 | } 23 | 24 | public Position getPosition() { 25 | return this.pos; 26 | } 27 | 28 | public static HandlerList getHandlers() { 29 | return handlers; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/event/spawner/SpawnerChangeTypeEvent.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.event.spawner; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.Block; 5 | import cn.nukkit.event.Cancellable; 6 | import cn.nukkit.event.HandlerList; 7 | import cn.nukkit.event.block.BlockEvent; 8 | import nukkitcoders.mobplugin.entities.block.BlockEntitySpawner; 9 | 10 | public class SpawnerChangeTypeEvent extends BlockEvent implements Cancellable { 11 | 12 | private static final HandlerList handlers = new HandlerList(); 13 | private final BlockEntitySpawner spawner; 14 | private final Player player; 15 | private final int oldEntityType; 16 | private final int newEntityType; 17 | 18 | public SpawnerChangeTypeEvent(BlockEntitySpawner spawner, Block block, Player player, int oldEntityType, int newEntityType) { 19 | super(block); 20 | this.spawner = spawner; 21 | this.player = player; 22 | this.oldEntityType = oldEntityType; 23 | this.newEntityType = newEntityType; 24 | } 25 | 26 | public Player getPlayer() { 27 | return this.player; 28 | } 29 | 30 | public BlockEntitySpawner getSpawner() { 31 | return this.spawner; 32 | } 33 | 34 | public int getNewEntityType() { 35 | return this.newEntityType; 36 | } 37 | 38 | public int getOldEntityType() { 39 | return this.oldEntityType; 40 | } 41 | 42 | public static HandlerList getHandlers() { 43 | return SpawnerChangeTypeEvent.handlers; 44 | } 45 | } -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/event/spawner/SpawnerCreateEvent.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.event.spawner; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.block.Block; 5 | import cn.nukkit.event.Cancellable; 6 | import cn.nukkit.event.HandlerList; 7 | import cn.nukkit.event.block.BlockEvent; 8 | 9 | public class SpawnerCreateEvent extends BlockEvent implements Cancellable { 10 | 11 | private static final HandlerList handlers = new HandlerList(); 12 | private final Player player; 13 | private final int entityType; 14 | 15 | public SpawnerCreateEvent(Player player, Block block, int entityType) { 16 | super(block); 17 | this.player = player; 18 | this.entityType = entityType; 19 | } 20 | 21 | public Player getPlayer() { 22 | return this.player; 23 | } 24 | 25 | public int getEntityType() { 26 | return this.entityType; 27 | } 28 | 29 | public static HandlerList getHandlers() { 30 | return SpawnerCreateEvent.handlers; 31 | } 32 | } -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/route/Node.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.route; 2 | 3 | import cn.nukkit.math.Vector3; 4 | 5 | import java.util.Objects; 6 | 7 | /** 8 | * @author zzz1999 @ MobPlugin 9 | */ 10 | public class Node implements Comparable { 11 | 12 | private Vector3 vector3; 13 | private Node parent; 14 | private int G; 15 | private int H; 16 | private int F; 17 | 18 | Node(Vector3 vector3, Node parent, int G, int H) { 19 | this.vector3 = vector3; 20 | this.parent = parent; 21 | this.G = G; 22 | this.H = H; 23 | this.F = G + H; 24 | } 25 | 26 | Node(Vector3 vector3) { 27 | this(vector3, null, 0, 0); 28 | } 29 | 30 | 31 | public Node getParent() { 32 | return parent; 33 | } 34 | 35 | public void setParent(Node parent) { 36 | this.parent = parent; 37 | } 38 | 39 | public int getG() { 40 | return G; 41 | } 42 | 43 | public void setG(int g) { 44 | G = g; 45 | } 46 | 47 | public int getH() { 48 | return H; 49 | } 50 | 51 | public void setH(int h) { 52 | H = h; 53 | } 54 | 55 | public int getF() { 56 | return F; 57 | } 58 | 59 | public void setF(int f) { 60 | F = f; 61 | } 62 | 63 | @Override 64 | public int compareTo(Node o) { 65 | Objects.requireNonNull(o); 66 | if (this.getF() != o.getF()) { 67 | return this.getF() - o.getF(); 68 | } 69 | double breaking; 70 | if ((breaking = this.getG() + (this.getH() * 0.1) - (o.getG() + (this.getH() * 0.1))) > 0) { 71 | return 1; 72 | } else if (breaking < 0) { 73 | return -1; 74 | } else { 75 | return 0; 76 | } 77 | } 78 | 79 | @Override 80 | public String toString() { 81 | return vector3.toString() + "| G:" + this.G + " H:" + this.H + " F" + this.getF() + (this.parent != null ? "\tparent:" + String.valueOf(this.parent.getVector3()) : ""); 82 | } 83 | 84 | public Vector3 getVector3() { 85 | return vector3; 86 | } 87 | 88 | public void setVector3(Vector3 vector3) { 89 | this.vector3 = vector3; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/route/SimpleRouteFinder.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.route; 2 | 3 | import nukkitcoders.mobplugin.entities.WalkingEntity; 4 | 5 | /** 6 | * @author zzz1999 @ MobPlugin 7 | */ 8 | public class SimpleRouteFinder extends RouteFinder{ 9 | 10 | public SimpleRouteFinder(WalkingEntity entity) { 11 | super(entity); 12 | } 13 | 14 | @Override 15 | public boolean search() { 16 | this.resetNodes(); 17 | this.addNode(new Node(this.destination)); 18 | return true; 19 | } 20 | } -------------------------------------------------------------------------------- /src/main/java/nukkitcoders/mobplugin/runnable/RouteFinderSearchTask.java: -------------------------------------------------------------------------------- 1 | package nukkitcoders.mobplugin.runnable; 2 | 3 | import nukkitcoders.mobplugin.route.RouteFinder; 4 | 5 | /** 6 | * @author zzz1999 @ MobPlugin 7 | */ 8 | public class RouteFinderSearchTask implements Runnable { 9 | 10 | private final RouteFinder route; 11 | private int retryTime = 0; 12 | 13 | public RouteFinderSearchTask(RouteFinder route) { 14 | this.route = route; 15 | } 16 | 17 | @Override 18 | public void run() { 19 | if (this.route == null) { 20 | return; 21 | } 22 | while (retryTime < 50) { 23 | if (!this.route.isSearching()) { 24 | this.route.research(); 25 | return; 26 | } else { 27 | retryTime += 10; 28 | try { 29 | Thread.sleep(100); 30 | } catch (InterruptedException ignore) {} 31 | } 32 | } 33 | route.interrupt(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/resources/config.yml: -------------------------------------------------------------------------------- 1 | # Config version, do not edit! 2 | config-version: 18 3 | 4 | entities: 5 | # How often the spawn task should run 6 | # In ticks, 20 ticks = 1 second 7 | # Use 0 to disable entity spawning 8 | autospawn-ticks: 200 9 | # How often the despawn task should run 10 | # In ticks, 20 ticks = 1 second 11 | # Use 0 to disable entity despawning 12 | despawn-ticks: 12000 13 | # Do not spawn entities in these worlds 14 | worlds-spawning-disabled: "exampleworld1, exampleworld2" 15 | 16 | # Spawning limit settings 17 | # Per player, in 128 blocks range 18 | autospawn: 19 | bat: 0 20 | blaze: 0 21 | chicken: 2 22 | cod: 4 23 | cow: 2 24 | creeper: 2 25 | dolphin: 2 26 | donkey: 2 27 | enderman: 2 28 | ghast: 2 29 | husk: 2 30 | horse: 2 31 | magmacube: 2 32 | mooshroom: 2 33 | ocelot: 2 34 | parrot: 2 35 | pig: 2 36 | polarbear: 2 37 | pufferfish: 2 38 | rabbit: 2 39 | salmon: 4 40 | sheep: 2 41 | skeleton: 2 42 | slime: 2 43 | spider: 2 44 | squid: 2 45 | stray: 2 46 | tropicalfish: 2 47 | turtle: 2 48 | witch: 1 49 | witherskeleton: 2 50 | wolf: 2 51 | zombie: 2 52 | zombiepigman: 4 53 | fox: 2 54 | panda: 2 55 | drowned: 2 56 | piglin: 4 57 | hoglin: 0 58 | llama: 2 59 | strider: 2 60 | 61 | spawners: 62 | # Enable mob spawner blocks 63 | enabled: true 64 | # Mob spawner spawning range 65 | spawn-range: 4 66 | # Minimum amount of mobs spawned at a time 67 | minimum-spawn-count: 1 68 | # Maximum amount of mobs spawned at a time 69 | maximum-spawn-count: 4 70 | # Minimum spawn delay (ticks) 71 | minimum-delay: 200 72 | # Maximum spawn delay (ticks) 73 | maximum-delay: 5000 74 | # Maximum amount of mobs near the spawner 75 | maximum-nearby-entities: 16 76 | # Player must be this close to spawner for it to spawn mobs 77 | required-player-range: 16 78 | # Don't reduce spawn eggs if there is an entity already in the spawner (non-vanilla behavior) 79 | do-not-waste-spawn-eggs: false 80 | 81 | other: 82 | # Give xp drops straight to player 83 | use-no-xp-orbs: false 84 | # Do not spawn mobs this near to spawn area 85 | # Set -1 to disable 86 | spawn-no-spawning-area: -1 87 | # Kill entities instead of despawning them 88 | # This can have a negative impact on performance due to the drops 89 | kill-mobs-on-despawn: false 90 | # Custom enderman max spawns rule for the_end world 91 | end-enderman-spawning: 10 92 | # If tamed entity owner attacked or attack entity, it will become angry 93 | check-tamed-entity-attack: true 94 | # Let creepers explode blocks 95 | creeper-explode-blocks: true 96 | # Do not allow creating snow golems, iron golems and withers in these worlds 97 | worlds-entity-creation-disabled: "exampleworld1, exampleworld2" 98 | # Allow players to breed mobs 99 | allow-breeding: true 100 | # Show boss bar for wither & ender dragon (work in progress) 101 | show-boss-bar: true 102 | 103 | -------------------------------------------------------------------------------- /src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: MobPlugin 2 | main: nukkitcoders.mobplugin.MobPlugin 3 | version: "${pom.version}" 4 | api: ["1.0.14"] 5 | author: kniffo80, matt404, augesrob, PetteriM1, PikyCZ, zzz1999, SergeyDertan 6 | description: Add mobs and animals with AI & spawning 7 | website: https://cloudburstmc.org/resources/mobplugin.3/ 8 | load: STARTUP 9 | 10 | commands: 11 | mob: 12 | description: Mob plugin main command 13 | usage: /mob 14 | permission: mobplugin.mob 15 | summon: 16 | description: Summon entity 17 | usage: /summon [player] 18 | permission: mobplugin.summon 19 | 20 | permissions: 21 | mobplugin.mob: 22 | default: op 23 | mobplugin.summon: 24 | default: op 25 | --------------------------------------------------------------------------------