PaperMC/Spigot-Server-Patches/0299-Turtle-API.patch
Daniel Ennis c97ce029e9
1.16.2 Release (#4123)
PaperMC believes that 1.16.2 is now ready for general release as we fixed the main issue plagueing the 1.16.x release, the MapLike data conversion issues.

Until now, it was not safe for a server to convert a world to 1.16.2 without data conversion issues around villages and potentially other things. If you did, those MapLike errors meant something went wrong.

This is now resolved.

Big thanks to all those that helped, notably @BillyGalbreath and @Proximyst who did large parts of the update process with me.

Please as always, backup your worlds and test before updating to 1.16.2!

If you update to 1.16.2, there is no going back to an older build than this.

---------------------------------

Co-authored-by: William Blake Galbreath <Blake.Galbreath@GMail.com>
Co-authored-by: Mariell Hoversholm <proximyst@proximyst.com>
Co-authored-by: krolik-exe <69214078+krolik-exe@users.noreply.github.com>
Co-authored-by: BillyGalbreath <BillyGalbreath@users.noreply.github.com>
Co-authored-by: stonar96 <minecraft.stonar96@gmail.com>
Co-authored-by: Shane Freeder <theboyetronic@gmail.com>
Co-authored-by: Jason <jasonpenilla2@me.com>
Co-authored-by: kashike <kashike@vq.lc>
Co-authored-by: Aurora <21148213+aurorasmiles@users.noreply.github.com>
Co-authored-by: KennyTV <kennytv@t-online.de>
Co-authored-by: commandblockguy <commandblockguy1@gmail.com>
Co-authored-by: DigitalRegent <misterwener@gmail.com>
Co-authored-by: ishland <ishlandmc@yeah.net>
2020-08-24 22:40:19 -04:00

151 lines
7.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Sat, 29 Sep 2018 16:08:23 -0500
Subject: [PATCH] Turtle API
diff --git a/src/main/java/net/minecraft/server/EntityTurtle.java b/src/main/java/net/minecraft/server/EntityTurtle.java
index 40a632434e43211710815944ad4aefa207f78780..1fd2a41050de39b47a0fe6e52f7a6727a8475757 100644
--- a/src/main/java/net/minecraft/server/EntityTurtle.java
+++ b/src/main/java/net/minecraft/server/EntityTurtle.java
@@ -31,7 +31,7 @@ public class EntityTurtle extends EntityAnimal {
this.datawatcher.set(EntityTurtle.bp, blockposition);
}
- private BlockPosition getHomePos() {
+ public BlockPosition getHomePos() { // Paper - public
return (BlockPosition) this.datawatcher.get(EntityTurtle.bp);
}
@@ -47,31 +47,37 @@ public class EntityTurtle extends EntityAnimal {
return (Boolean) this.datawatcher.get(EntityTurtle.bq);
}
- private void setHasEgg(boolean flag) {
+ public void setHasEgg(boolean flag) { // Paper
this.datawatcher.set(EntityTurtle.bq, flag);
}
+ public final boolean isDigging() { return this.eL(); } // Paper - OBFHELPER
public boolean eL() {
return (Boolean) this.datawatcher.get(EntityTurtle.br);
}
+ public final void setDigging(boolean digging) { this.u(digging); } // Paper - OBFHELPER
private void u(boolean flag) {
this.bv = flag ? 1 : 0;
this.datawatcher.set(EntityTurtle.br, flag);
}
+ public final boolean isGoingHome() { return this.eU(); } // Paper - OBFHELPER
private boolean eU() {
return (Boolean) this.datawatcher.get(EntityTurtle.bt);
}
+ public final void setGoingHome(boolean goingHome) { this.v(goingHome); } // Paper - OBFHELPER
private void v(boolean flag) {
this.datawatcher.set(EntityTurtle.bt, flag);
}
+ public final boolean isTravelling() { return this.eV(); } // Paper - OBFHELPER
private boolean eV() {
return (Boolean) this.datawatcher.get(EntityTurtle.bu);
}
+ public final void setTravelling(boolean travelling) { this.w(travelling); } // Paper - OBFHELPER
private void w(boolean flag) {
this.datawatcher.set(EntityTurtle.bu, flag);
}
@@ -438,14 +444,17 @@ public class EntityTurtle extends EntityAnimal {
if (!this.g.isInWater() && this.l()) {
if (this.g.bv < 1) {
- this.g.u(true);
+ 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) {
World world = this.g.world;
// CraftBukkit start
- 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()) {
+ // Paper start
+ 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()) {
world.playSound((EntityHuman) null, blockposition, SoundEffects.ENTITY_TURTLE_LAY_EGG, SoundCategory.BLOCKS, 0.3F, 0.9F + world.random.nextFloat() * 0.2F);
- 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);
}
// CraftBukkit end
this.g.setHasEgg(false);
@@ -574,7 +583,7 @@ public class EntityTurtle extends EntityAnimal {
@Override
public boolean a() {
- 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
}
@Override
diff --git a/src/main/java/net/minecraft/server/PathfinderGoalGotoTarget.java b/src/main/java/net/minecraft/server/PathfinderGoalGotoTarget.java
index 1295cb02ab9e39519d73e2c260a50b64d44929a1..9b0511e996a5e3952c6f975e7c93299c532a8ea1 100644
--- a/src/main/java/net/minecraft/server/PathfinderGoalGotoTarget.java
+++ b/src/main/java/net/minecraft/server/PathfinderGoalGotoTarget.java
@@ -9,7 +9,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/org/bukkit/craftbukkit/entity/CraftTurtle.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java
index 123a2c75cad410d079cfb23223ab509e4b4c63f7..f2b09a1e66dfbcd943612b5170d20bb284fbcc68 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java
@@ -1,6 +1,8 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityTurtle;
+import net.minecraft.server.MCUtil;
+import org.bukkit.Location;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Turtle;
@@ -25,4 +27,36 @@ public class CraftTurtle extends CraftAnimals implements Turtle {
public EntityType getType() {
return EntityType.TURTLE;
}
+
+ // Paper start
+ @Override
+ public Location getHome() {
+ return MCUtil.toLocation(getHandle().world, getHandle().getHomePos());
+ }
+
+ @Override
+ public void setHome(Location location) {
+ getHandle().setHomePos(MCUtil.toBlockPosition(location));
+ }
+
+ @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
}