added Wither API

This commit is contained in:
Jake Potrebic 2020-07-05 15:41:43 -07:00 committed by MiniDigger | Martin
parent 97d0c571b4
commit 2eda45c34f
2 changed files with 120 additions and 0 deletions

View file

@ -0,0 +1,45 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sun, 5 Jul 2020 15:39:40 -0700
Subject: [PATCH] added Wither API
diff --git a/src/main/java/org/bukkit/entity/Wither.java b/src/main/java/org/bukkit/entity/Wither.java
index 426d3693317cd303d35d8203026b528d87e401d5..8c95cd6933f11076de936854f379e6fc8600b525 100644
--- a/src/main/java/org/bukkit/entity/Wither.java
+++ b/src/main/java/org/bukkit/entity/Wither.java
@@ -6,4 +6,34 @@ import com.destroystokyo.paper.entity.RangedEntity;
* Represents a Wither boss
*/
public interface Wither extends Monster, Boss, RangedEntity { // Paper
+ // Paper start
+ /**
+ * @return whether the wither is charged
+ */
+ boolean isCharged();
+
+ /**
+ * @return ticks the wither is invulnerable for
+ */
+ int getInvulnerableTicks();
+
+ /**
+ * Sets for how long in the future, the wither should be invulnerable.
+ *
+ * @param ticks ticks the wither is invulnerable for
+ */
+ void setInvulnerableTicks(int ticks);
+
+ /**
+ * @return whether the wither can travel through portals
+ */
+ boolean canTravelThroughPortals();
+
+ /**
+ * Sets whether the wither can travel through portals.
+ *
+ * @param value whether the wither can travel through portals
+ */
+ void setCanTravelThroughPortals(boolean value);
+ // Paper end
}

View file

@ -0,0 +1,75 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sun, 5 Jul 2020 15:39:19 -0700
Subject: [PATCH] added Wither API
diff --git a/src/main/java/net/minecraft/server/EntityWither.java b/src/main/java/net/minecraft/server/EntityWither.java
index 53482a420c356fd50e5ab6dd729a271d6594dac7..2e623ef9be036ea467e9e41817c2eced018f8f93 100644
--- a/src/main/java/net/minecraft/server/EntityWither.java
+++ b/src/main/java/net/minecraft/server/EntityWither.java
@@ -32,6 +32,11 @@ public class EntityWither extends EntityMonster implements IRangedEntity {
return entityliving.getMonsterType() != EnumMonsterType.UNDEAD && entityliving.ei();
};
private static final PathfinderTargetCondition bz = (new PathfinderTargetCondition()).a(20.0D).a(EntityWither.by);
+ // Paper start
+ private boolean canPortal = false;
+
+ public void setCanTravelThroughPortals(boolean canPortal) { this.canPortal = canPortal; }
+ // Paper end
public EntityWither(EntityTypes<? extends EntityWither> entitytypes, World world) {
super(entitytypes, world);
@@ -530,6 +535,7 @@ public class EntityWither extends EntityMonster implements IRangedEntity {
this.datawatcher.set((DataWatcherObject) EntityWither.bo.get(i), j);
}
+ public final boolean isPowered() { return this.S_(); } // Paper - OBFHELPER
public boolean S_() {
return this.getHealth() <= this.getMaxHealth() / 2.0F;
}
@@ -546,7 +552,7 @@ public class EntityWither extends EntityMonster implements IRangedEntity {
@Override
public boolean canPortal() {
- return false;
+ return canPortal; // Paper
}
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java
index 03cf6136e64bab7180933e106234b92c1255268d..8c75f6df9749246fbbad55dcdc4292bd3bab4e2b 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java
@@ -39,4 +39,31 @@ public class CraftWither extends CraftMonster implements Wither, CraftRangedEnti
public BossBar getBossBar() {
return bossBar;
}
+
+ // Paper start
+ @Override
+ public boolean isCharged() {
+ return getHandle().isPowered();
+ }
+
+ @Override
+ public int getInvulnerableTicks() {
+ return getHandle().getInvul();
+ }
+
+ @Override
+ public void setInvulnerableTicks(int ticks) {
+ getHandle().setInvul(ticks);
+ }
+
+ @Override
+ public boolean canTravelThroughPortals() {
+ return getHandle().canPortal();
+ }
+
+ @Override
+ public void setCanTravelThroughPortals(boolean value) {
+ getHandle().setCanTravelThroughPortals(value);
+ }
+ // Paper end
}