Archiviert
13
0
Dieses Repository wurde am 2024-12-25 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
Paper-Old/Spigot-Server-Patches/0323-Turtle-API.patch

159 Zeilen
6.8 KiB
Diff

From 84494fe39beeb59f4b4b3117892961e7e0c39ed0 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
diff --git a/src/main/java/net/minecraft/server/EntityTurtle.java b/src/main/java/net/minecraft/server/EntityTurtle.java
index 013b3a1ca8..0037d13806 100644
2018-10-11 05:40:49 +02:00
--- a/src/main/java/net/minecraft/server/EntityTurtle.java
+++ b/src/main/java/net/minecraft/server/EntityTurtle.java
@@ -26,51 +26,63 @@ public class EntityTurtle extends EntityAnimal {
2019-05-05 10:33:44 +02:00
this.K = 1.0F;
2018-10-11 05:40:49 +02:00
}
+ public void setHome(BlockPosition pos) { g(pos); } // Paper - OBFHELPER
public void g(BlockPosition blockposition) {
2019-05-05 10:33:44 +02:00
this.datawatcher.set(EntityTurtle.bA, blockposition);
2018-10-11 05:40:49 +02:00
}
+ public BlockPosition getHome() { return dY(); } // Paper - OBFHELPER
private BlockPosition dY() {
2019-05-05 10:33:44 +02:00
return (BlockPosition) this.datawatcher.get(EntityTurtle.bA);
2018-10-11 05:40:49 +02:00
}
+ public void setTravelPos(BlockPosition pos) { h(pos); } // Paper - OBFHELPER
private void h(BlockPosition blockposition) {
this.datawatcher.set(EntityTurtle.bD, blockposition);
2018-10-11 05:40:49 +02:00
}
+ public BlockPosition getTravelPos() { return dZ(); } // Paper - OBFHELPER
private BlockPosition dZ() {
return (BlockPosition) this.datawatcher.get(EntityTurtle.bD);
2018-10-11 05:40:49 +02:00
}
+ public boolean hasEgg() { return dW(); } // Paper - OBFHELPER
public boolean dW() {
2019-05-05 10:33:44 +02:00
return (Boolean) this.datawatcher.get(EntityTurtle.bB);
2018-10-11 05:40:49 +02:00
}
2019-05-05 10:33:44 +02:00
+ public void setHasEgg(boolean hasEgg) { r(hasEgg); } // Paper - OBFHELPER
private void r(boolean flag) {
this.datawatcher.set(EntityTurtle.bB, flag);
2018-10-11 05:40:49 +02:00
}
2019-05-05 10:33:44 +02:00
+ public boolean isDigging() { return dW(); } // Paper - OBFHELPER
public boolean dX() {
return (Boolean) this.datawatcher.get(EntityTurtle.bC);
2018-10-11 05:40:49 +02:00
}
2019-05-05 10:33:44 +02:00
+ public void setDigging(boolean digging) { s(digging); } // Paper - OBFHELPER
private void s(boolean flag) {
this.bG = flag ? 1 : 0;
this.datawatcher.set(EntityTurtle.bC, flag);
2018-10-11 05:40:49 +02:00
}
+ public boolean isGoingHome() { return ea(); } // Paper - OBFHELPER
private boolean ea() {
return (Boolean) this.datawatcher.get(EntityTurtle.bE);
2018-10-11 05:40:49 +02:00
}
2019-05-05 10:33:44 +02:00
+ public void setGoingHome(boolean goingHome) { t(goingHome); } // Paper - OBFHELPER
private void t(boolean flag) {
this.datawatcher.set(EntityTurtle.bE, flag);
2018-10-11 05:40:49 +02:00
}
+ public boolean isTravelling() { return ef(); } // Paper - OBFHELPER
private boolean ef() {
return (Boolean) this.datawatcher.get(EntityTurtle.bF);
2018-10-11 05:40:49 +02:00
}
2019-05-05 10:33:44 +02:00
+ public void setTravelling(boolean travelling) { u(travelling); } // Paper - OBFHELPER
private void u(boolean flag) {
this.datawatcher.set(EntityTurtle.bF, flag);
2018-10-11 05:40:49 +02:00
}
@@ -441,14 +453,18 @@ public class EntityTurtle extends EntityAnimal {
2018-10-11 05:40:49 +02:00
2019-05-05 10:33:44 +02:00
if (!this.g.isInWater() && this.k()) {
if (this.g.bG < 1) {
2019-05-05 10:33:44 +02:00
- this.g.s(true);
+ this.g.setDigging(new com.destroystokyo.paper.event.entity.TurtleStartDiggingEvent((org.bukkit.entity.Turtle) this.g.getBukkitEntity(), MCUtil.toLocation(this.g.world, this.e)).callEvent()); // Paper
} else if (this.g.bG > 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()) {
2018-10-11 05:40:49 +02:00
world.a((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);
+ // Paper end
2018-10-11 05:40:49 +02:00
}
// CraftBukkit end
2019-05-05 10:33:44 +02:00
this.g.r(false);
@@ -583,7 +599,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() {
- return this.a.isBaby() ? false : (this.a.dW() ? true : (this.a.getRandom().nextInt(700) != 0 ? false : !this.a.dY().a((IPosition) this.a.ci(), 64.0D)));
+ return this.a.isBaby() ? false : (this.a.dW() ? true : (this.a.getRandom().nextInt(700) != 0 ? false : !this.a.dY().a((IPosition) this.a.ci(), 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
index 123a2c75ca..8edcf7af65 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
@@ -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().getHome());
+ }
+
+ @Override
+ public void setHome(Location location) {
+ getHandle().setHome(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
}
--
2.22.0
2018-10-11 05:40:49 +02:00