2020-05-06 11:48:49 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2018-10-11 05:40:49 +02:00
|
|
|
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
|
|
|
Date: Sat, 29 Sep 2018 16:08:23 -0500
|
|
|
|
Subject: [PATCH] Turtle API
|
|
|
|
|
|
|
|
|
2021-03-16 08:19:45 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/PathfinderGoalGotoTarget.java b/src/main/java/net/minecraft/world/entity/ai/goal/PathfinderGoalGotoTarget.java
|
|
|
|
index 62276550627bfe453794a2b3101426fe05a585ff..6a156a488bc073b3b60f4d1081e3f2ab65ba9e96 100644
|
|
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/goal/PathfinderGoalGotoTarget.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/PathfinderGoalGotoTarget.java
|
|
|
|
@@ -14,7 +14,7 @@ public abstract class PathfinderGoalGotoTarget extends PathfinderGoal {
|
|
|
|
protected int c;
|
|
|
|
protected int d;
|
|
|
|
private int g;
|
|
|
|
- protected BlockPosition e;
|
|
|
|
+ protected BlockPosition e;public final BlockPosition getTargetPosition() { return this.e; } // Paper - OBFHELPER
|
|
|
|
private boolean h;
|
|
|
|
private final int i;
|
|
|
|
private final int j;
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/EntityTurtle.java b/src/main/java/net/minecraft/world/entity/animal/EntityTurtle.java
|
2021-03-16 16:50:45 +01:00
|
|
|
index bf224c97854daa379c61affff6a0ac9524c2c35d..09a6310af6712d36c20167256b60dc3235e76021 100644
|
2021-03-16 08:19:45 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/EntityTurtle.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/EntityTurtle.java
|
2021-03-16 16:50:45 +01:00
|
|
|
@@ -14,6 +14,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
import net.minecraft.network.syncher.DataWatcher;
|
|
|
|
import net.minecraft.network.syncher.DataWatcherObject;
|
|
|
|
import net.minecraft.network.syncher.DataWatcherRegistry;
|
|
|
|
+import net.minecraft.server.MCUtil;
|
|
|
|
import net.minecraft.server.level.EntityPlayer;
|
|
|
|
import net.minecraft.server.level.WorldServer;
|
|
|
|
import net.minecraft.sounds.SoundCategory;
|
|
|
|
@@ -93,7 +94,7 @@ public class EntityTurtle extends EntityAnimal {
|
2020-08-25 04:22:08 +02:00
|
|
|
this.datawatcher.set(EntityTurtle.bp, blockposition);
|
2018-10-11 05:40:49 +02:00
|
|
|
}
|
2020-08-25 04:22:08 +02:00
|
|
|
|
2020-08-02 07:39:36 +02:00
|
|
|
- private BlockPosition getHomePos() {
|
|
|
|
+ public BlockPosition getHomePos() { // Paper - public
|
2020-08-25 04:22:08 +02:00
|
|
|
return (BlockPosition) this.datawatcher.get(EntityTurtle.bp);
|
2018-10-11 05:40:49 +02:00
|
|
|
}
|
2020-08-02 07:39:36 +02:00
|
|
|
|
2021-03-16 16:50:45 +01:00
|
|
|
@@ -109,31 +110,37 @@ public class EntityTurtle extends EntityAnimal {
|
2020-08-25 04:22:08 +02:00
|
|
|
return (Boolean) this.datawatcher.get(EntityTurtle.bq);
|
2020-06-26 08:29:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- private void setHasEgg(boolean flag) {
|
|
|
|
+ public void setHasEgg(boolean flag) { // Paper
|
2020-08-25 04:22:08 +02:00
|
|
|
this.datawatcher.set(EntityTurtle.bq, flag);
|
2018-10-11 05:40:49 +02:00
|
|
|
}
|
|
|
|
|
2020-08-25 04:22:08 +02:00
|
|
|
+ public final boolean isDigging() { return this.eL(); } // Paper - OBFHELPER
|
|
|
|
public boolean eL() {
|
|
|
|
return (Boolean) this.datawatcher.get(EntityTurtle.br);
|
2018-10-11 05:40:49 +02:00
|
|
|
}
|
|
|
|
|
2020-06-25 16:09:55 +02:00
|
|
|
+ public final void setDigging(boolean digging) { this.u(digging); } // Paper - OBFHELPER
|
|
|
|
private void u(boolean flag) {
|
2020-08-25 04:22:08 +02:00
|
|
|
this.bv = flag ? 1 : 0;
|
|
|
|
this.datawatcher.set(EntityTurtle.br, flag);
|
2018-10-11 05:40:49 +02:00
|
|
|
}
|
|
|
|
|
2020-08-25 04:22:08 +02:00
|
|
|
+ public final boolean isGoingHome() { return this.eU(); } // Paper - OBFHELPER
|
|
|
|
private boolean eU() {
|
|
|
|
return (Boolean) this.datawatcher.get(EntityTurtle.bt);
|
2018-10-11 05:40:49 +02:00
|
|
|
}
|
|
|
|
|
2020-06-25 16:09:55 +02:00
|
|
|
+ public final void setGoingHome(boolean goingHome) { this.v(goingHome); } // Paper - OBFHELPER
|
|
|
|
private void v(boolean flag) {
|
2020-08-25 04:22:08 +02:00
|
|
|
this.datawatcher.set(EntityTurtle.bt, flag);
|
2018-10-11 05:40:49 +02:00
|
|
|
}
|
|
|
|
|
2020-08-25 04:22:08 +02:00
|
|
|
+ public final boolean isTravelling() { return this.eV(); } // Paper - OBFHELPER
|
|
|
|
private boolean eV() {
|
|
|
|
return (Boolean) this.datawatcher.get(EntityTurtle.bu);
|
2018-10-11 05:40:49 +02:00
|
|
|
}
|
|
|
|
|
2020-06-25 16:09:55 +02:00
|
|
|
+ public final void setTravelling(boolean travelling) { this.w(travelling); } // Paper - OBFHELPER
|
|
|
|
private void w(boolean flag) {
|
2020-08-25 04:22:08 +02:00
|
|
|
this.datawatcher.set(EntityTurtle.bu, flag);
|
2018-10-11 05:40:49 +02:00
|
|
|
}
|
2021-03-16 16:50:45 +01:00
|
|
|
@@ -500,14 +507,17 @@ public class EntityTurtle extends EntityAnimal {
|
2018-10-11 05:40:49 +02:00
|
|
|
|
2020-08-25 04:22:08 +02:00
|
|
|
if (!this.g.isInWater() && this.l()) {
|
|
|
|
if (this.g.bv < 1) {
|
2020-06-25 16:09:55 +02:00
|
|
|
- this.g.u(true);
|
2020-08-25 04:22:08 +02:00
|
|
|
+ this.g.setDigging(new com.destroystokyo.paper.event.entity.TurtleStartDiggingEvent((org.bukkit.entity.Turtle) this.g.getBukkitEntity(), MCUtil.toLocation(this.g.world, this.getTargetPosition())).callEvent()); // Paper
|
|
|
|
} else if (this.g.bv > 200) {
|
2019-05-05 10:33:44 +02:00
|
|
|
World world = this.g.world;
|
2018-10-11 05:40:49 +02:00
|
|
|
|
|
|
|
// CraftBukkit start
|
2019-05-05 10:33:44 +02:00
|
|
|
- if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.g, this.e.up(), (IBlockData) Blocks.TURTLE_EGG.getBlockData().set(BlockTurtleEgg.b, this.g.random.nextInt(4) + 1)).isCancelled()) {
|
2018-10-11 05:40:49 +02:00
|
|
|
+ // Paper start
|
2019-05-05 10:33:44 +02:00
|
|
|
+ int eggCount = this.g.random.nextInt(4) + 1;
|
|
|
|
+ com.destroystokyo.paper.event.entity.TurtleLayEggEvent layEggEvent = new com.destroystokyo.paper.event.entity.TurtleLayEggEvent((org.bukkit.entity.Turtle) this.g.getBukkitEntity(), MCUtil.toLocation(this.g.world, this.e.up()), eggCount);
|
|
|
|
+ if (layEggEvent.callEvent() && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.g, this.e.up(), Blocks.TURTLE_EGG.getBlockData().set(BlockTurtleEgg.b, layEggEvent.getEggCount())).isCancelled()) {
|
2019-07-20 06:01:24 +02:00
|
|
|
world.playSound((EntityHuman) null, blockposition, SoundEffects.ENTITY_TURTLE_LAY_EGG, SoundCategory.BLOCKS, 0.3F, 0.9F + world.random.nextFloat() * 0.2F);
|
2019-05-05 10:33:44 +02:00
|
|
|
- world.setTypeAndData(this.e.up(), (IBlockData) Blocks.TURTLE_EGG.getBlockData().set(BlockTurtleEgg.b, this.g.random.nextInt(4) + 1), 3);
|
|
|
|
+ world.setTypeAndData(this.e.up(), (IBlockData) Blocks.TURTLE_EGG.getBlockData().set(BlockTurtleEgg.b, layEggEvent.getEggCount()), 3);
|
2018-10-11 05:40:49 +02:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2020-06-25 16:09:55 +02:00
|
|
|
this.g.setHasEgg(false);
|
2021-03-16 16:50:45 +01:00
|
|
|
@@ -636,7 +646,7 @@ public class EntityTurtle extends EntityAnimal {
|
2018-10-11 05:40:49 +02:00
|
|
|
|
2019-05-05 10:33:44 +02:00
|
|
|
@Override
|
2018-10-11 05:40:49 +02:00
|
|
|
public boolean a() {
|
2020-06-25 16:09:55 +02:00
|
|
|
- return this.a.isBaby() ? false : (this.a.hasEgg() ? true : (this.a.getRandom().nextInt(700) != 0 ? false : !this.a.getHomePos().a((IPosition) this.a.getPositionVector(), 64.0D)));
|
|
|
|
+ return this.a.isBaby() ? false : (this.a.hasEgg() ? true : (this.a.getRandom().nextInt(700) != 0 ? false : !this.a.getHomePos().a((IPosition) this.a.getPositionVector(), 64.0D))) && new com.destroystokyo.paper.event.entity.TurtleGoHomeEvent((org.bukkit.entity.Turtle) this.a.getBukkitEntity()).callEvent(); // Paper
|
2018-10-11 05:40:49 +02:00
|
|
|
}
|
|
|
|
|
2019-05-05 10:33:44 +02:00
|
|
|
@Override
|
2018-10-11 05:40:49 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java
|
2021-03-16 08:19:45 +01:00
|
|
|
index b46bb75926c14ab54ea309a400eb57405b11ce27..31f1a6b2b9a432cdd25826ced884424eeb50df97 100644
|
2018-10-11 05:40:49 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java
|
2021-03-16 08:19:45 +01:00
|
|
|
@@ -25,4 +25,36 @@ public class CraftTurtle extends CraftAnimals implements Turtle {
|
2018-10-11 05:40:49 +02:00
|
|
|
public EntityType getType() {
|
|
|
|
return EntityType.TURTLE;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Paper start
|
|
|
|
+ @Override
|
2021-03-16 08:19:45 +01:00
|
|
|
+ public org.bukkit.Location getHome() {
|
|
|
|
+ return net.minecraft.server.MCUtil.toLocation(getHandle().world, getHandle().getHomePos());
|
2018-10-11 05:40:49 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2021-03-16 08:19:45 +01:00
|
|
|
+ public void setHome(org.bukkit.Location location) {
|
|
|
|
+ getHandle().setHomePos(net.minecraft.server.MCUtil.toBlockPosition(location));
|
2018-10-11 05:40:49 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean isGoingHome() {
|
|
|
|
+ return getHandle().isGoingHome();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean isDigging() {
|
|
|
|
+ return getHandle().isDigging();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean hasEgg() {
|
|
|
|
+ return getHandle().hasEgg();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void setHasEgg(boolean hasEgg) {
|
|
|
|
+ getHandle().setHasEgg(hasEgg);
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|