Paper/Spigot-Server-Patches/0380-Turtle-API.patch

158 lines
6.7 KiB
Diff
Raw Normal View History

From 1a1e746ec859f87d4c53d2081b1488ea9edcc2da 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 b016e0ae7..a533e0eb5 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
@@ -27,51 +27,63 @@ public class EntityTurtle extends EntityAnimal {
this.Q = 1.0F;
}
+ public void setHome(BlockPosition pos) { g(pos); } // Paper - OBFHELPER
public void g(BlockPosition blockposition) {
this.datawatcher.set(EntityTurtle.bD, blockposition);
}
2018-10-23 01:16:21 +02:00
+ public BlockPosition getHome() { return dA(); } // Paper - OBFHELPER
private BlockPosition dA() {
2018-10-11 05:40:49 +02:00
return (BlockPosition) this.datawatcher.get(EntityTurtle.bD);
}
+ public void setTravelPos(BlockPosition pos) { h(pos); } // Paper - OBFHELPER
private void h(BlockPosition blockposition) {
this.datawatcher.set(EntityTurtle.bH, blockposition);
}
2018-10-23 01:16:21 +02:00
+ public BlockPosition getTravelPos() { return dB(); } // Paper - OBFHELPER
private BlockPosition dB() {
2018-10-11 05:40:49 +02:00
return (BlockPosition) this.datawatcher.get(EntityTurtle.bH);
}
+ public boolean hasEgg() { return dy(); } // Paper - OBFHELPER
public boolean dy() {
return (Boolean) this.datawatcher.get(EntityTurtle.bE);
2018-10-11 05:40:49 +02:00
}
+ public void setHasEgg(boolean hasEgg) { s(hasEgg); } // Paper - OBFHELPER
private void s(boolean flag) {
this.datawatcher.set(EntityTurtle.bE, flag);
2018-10-11 05:40:49 +02:00
}
+ public boolean isDigging() { return dz(); } // Paper - OBFHELPER
public boolean dz() {
return (Boolean) this.datawatcher.get(EntityTurtle.bG);
2018-10-11 05:40:49 +02:00
}
+ public void setDigging(boolean digging) { t(digging); } // Paper - OBFHELPER
private void t(boolean flag) {
this.bK = flag ? 1 : 0;
this.datawatcher.set(EntityTurtle.bG, flag);
2018-10-11 05:40:49 +02:00
}
2018-10-23 01:16:21 +02:00
+ public boolean isGoingHome() { return dC(); } // Paper - OBFHELPER
private boolean dC() {
return (Boolean) this.datawatcher.get(EntityTurtle.bI);
2018-10-11 05:40:49 +02:00
}
+ public void setGoingHome(boolean goingHome) { u(goingHome); } // Paper - OBFHELPER
private void u(boolean flag) {
this.datawatcher.set(EntityTurtle.bI, flag);
2018-10-11 05:40:49 +02:00
}
2018-10-23 01:16:21 +02:00
+ public boolean isTravelling() { return dH(); } // Paper - OBFHELPER
private boolean dH() {
return (Boolean) this.datawatcher.get(EntityTurtle.bJ);
2018-10-11 05:40:49 +02:00
}
+ public void setTravelling(boolean travelling) { v(travelling); } // Paper - OBFHELPER
private void v(boolean flag) {
this.datawatcher.set(EntityTurtle.bJ, flag);
2018-10-11 05:40:49 +02:00
}
@@ -423,14 +435,17 @@ public class EntityTurtle extends EntityAnimal {
2018-10-11 05:40:49 +02:00
if (!this.f.isInWater() && this.k()) {
if (this.f.bK < 1) {
- this.f.t(true);
+ this.f.setDigging(new com.destroystokyo.paper.event.entity.TurtleStartDiggingEvent((org.bukkit.entity.Turtle) this.f.getBukkitEntity(), MCUtil.toLocation(this.f.world, this.d)).callEvent()); // Paper
} else if (this.f.bK > 200) {
World world = this.f.world;
// CraftBukkit start
- if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.f, this.d.up(), Blocks.TURTLE_EGG.getBlockData().set(BlockTurtleEgg.b, Integer.valueOf(this.f.random.nextInt(4) + 1))).isCancelled()) {
+ // Paper start
+ int eggCount = this.f.random.nextInt(4) + 1;
+ com.destroystokyo.paper.event.entity.TurtleLayEggEvent layEggEvent = new com.destroystokyo.paper.event.entity.TurtleLayEggEvent((org.bukkit.entity.Turtle) this.f.getBukkitEntity(), MCUtil.toLocation(this.f.world, this.d.up()), eggCount);
+ if (layEggEvent.callEvent() && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.f, this.d.up(), Blocks.TURTLE_EGG.getBlockData().set(BlockTurtleEgg.b, layEggEvent.getEggCount())).isCancelled()) {
world.a((EntityHuman) null, blockposition, SoundEffects.ENTITY_TURTLE_LAY_EGG, SoundCategory.BLOCKS, 0.3F, 0.9F + world.random.nextFloat() * 0.2F);
- world.setTypeAndData(this.d.up(), (IBlockData) Blocks.TURTLE_EGG.getBlockData().set(BlockTurtleEgg.b, this.f.random.nextInt(4) + 1), 3);
2018-10-11 05:40:49 +02:00
+ world.setTypeAndData(this.d.up(), (IBlockData) Blocks.TURTLE_EGG.getBlockData().set(BlockTurtleEgg.b, layEggEvent.getEggCount()), 3);
}
// CraftBukkit end
this.f.s(false);
@@ -556,7 +571,7 @@ public class EntityTurtle extends EntityAnimal {
2018-10-11 05:40:49 +02:00
}
public boolean a() {
2018-10-23 01:16:21 +02:00
- return this.a.isBaby() ? false : (this.a.dy() ? true : (this.a.getRandom().nextInt(700) != 0 ? false : this.a.c(this.a.dA()) >= 4096.0D));
+ return this.a.isBaby() ? false : (this.a.dy() ? true : (this.a.getRandom().nextInt(700) != 0 ? false : this.a.c(this.a.dA()) >= 4096.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
}
public void c() {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTurtle.java
index 123a2c75c..8edcf7af6 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
}
--
Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Warning: this commit contains more mapping changes from upstream, As always, ensure that you have working backups and test this build before deployment; Developers working on paper will, yet again, need to delete their work/Minecraft/1.13.2 folder Bukkit Changes: 7fca5fd4 SPIGOT-4558: Preserve user order in the face of copied defaults in configurations 15c9b1eb Ignore spurious slot IDs sent by client, e.g. in enchanting tables 5d2a10c5 SPIGOT-3747: Add API for force loaded chunks d6dd2bb3 SPIGOT-3538: Add getHitBlockFace for ProjectileHitEvent 771db4aa SPIGOT-794: Call EntityPlaceEvent for Minecart placement 55462509 Add InventoryView#getSlotType 2f3ce5b6 Remove EntityTransformEvent and CustomItemTagContainer from draft API f04ad7b6 Make ProjectileLaunchEvent extend EntitySpawnEvent ccb85808 Define EntitySpawnEvent b8cc3ebe Add PlayerItemDamageEvent 184a495d Ease ClassLoader Deadlocks Where Possible 11ac4728 Expand Boolean Prompt Values in Conversation API aae62d51 Added getAllSessionData() to the Conversation API. 9290ff91 Add InventoryView#getInventory API 995e530f Add API to get / set base arrow damage CraftBukkit Changes: c4a67eed SPIGOT-4556: Fix plugins closing inventory during drop events 5be2ddcb Replace version constants with methods to prevent compiler inlining a5b9c7b3 Use API method to create offset command completions 2bc7d1df SPIGOT-3747: Add API for force loaded chunks a408f375 SPIGOT-3538: Add getHitBlockFace for ProjectileHitEvent b54b9409 SPIGOT-2864: Make Arrow / Item setTicksLived behave like FallingBlock 79ded7a8 SPIGOT-1811: Death message not shown on respawn screen b4a4f15d SPIGOT-943: InventoryCloseEvent called on death regardless of open inventory 0afed592 SPIGOT-794: Call EntityPlaceEvent for Minecart placement 2b2d084a Add InventoryView#getSlotType 01a9959a Do not use deprecated ItemSpawnEvent constructor 9642498d SPIGOT-4547: Call EntitySpawnEvent as general spawn fallback event 963f4a5f Add PlayerItemDamageEvent 63db0445 Add API to get / set base arrow damage 531c25d7 Add CraftMagicNumbers.MAPPINGS_VERSION for use by NMS plugins d05c8b14 Mappings Update bd36e200 SPIGOT-4551: Ignore invalid attribute modifier slots Spigot Changes: 518206a1 Remove redundant trove depend 1959ad21 MC-11211,SPIGOT-4552: Fix placing double slabs at y = 255 29ab5e43 SPIGOT-3661: Allow arguments in restart-script 7cc46316 SPIGOT-852: Growth modifiers for beetroots, potatoes, carrots 82e117e1 Squelch "fatal: Resolve operation not in progress" message 0a1a68e7 Mappings Update & Patch Rebuild
2019-01-01 04:15:55 +01:00
2.20.1
2018-10-11 05:40:49 +02:00