Skip to content

Commit

Permalink
Add can-despawn (boolean) property to allow custom mobs to despawn,…
Browse files Browse the repository at this point in the history
… even with

a custom name.

Can be used to despawn custom-spawned shulkers in the end, i.e.:

    `/beast-mob set shulker can-despawn true`
  • Loading branch information
totemo committed Jan 3, 2019
1 parent ee755c0 commit 3e5c5b5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>nu.nerd</groupId>
<name>BeastMaster</name>
<artifactId>${project.name}</artifactId>
<version>2.5.0</version>
<version>2.6.0</version>
<packaging>jar</packaging>
<description>Handles custom mob spawning.</description>
<url>https://github.com/NerdNu/${project.name}</url>
Expand Down
6 changes: 6 additions & 0 deletions src/nu/nerd/beastmaster/mobs/MobType.java
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,12 @@ protected void addProperties() {
double percent = (Double) getDerivedProperty("off-hand-drop-percent").getValue();
mob.getEquipment().setItemInOffHandDropChance((float) percent / 100);
}));
// Added after custom name => will clear PersistenceRequired NBT.
addProperty(new MobProperty("can-despawn", DataType.BOOLEAN,
(mob, logger) -> {
boolean canDespawn = (Boolean) getDerivedProperty("can-despawn").getValue();
mob.setRemoveWhenFarAway(canDespawn);
}));

// TODO: use AIR to signify clearing the default armour/weapon.
// TODO: Disguise property.
Expand Down

0 comments on commit 3e5c5b5

Please sign in to comment.