mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 15:49:00 +01:00
Merge pull request #1244
07cf46c4
Rebuild Patches (BillyGalbreath)9362271f
AnvilDamageEvent (BillyGalbreath) * pull/1244/head: Rebuild Patches AnvilDamageEvent
This commit is contained in:
commit
ef22f9d531
10 changed files with 199 additions and 19 deletions
152
Spigot-API-Patches/AnvilDamageEvent.patch
Normal file
152
Spigot-API-Patches/AnvilDamageEvent.patch
Normal file
|
@ -0,0 +1,152 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Fri, 20 Jul 2018 23:36:55 -0500
|
||||
Subject: [PATCH] AnvilDamageEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/event/block/AnvilDamagedEvent.java b/src/main/java/com/destroystokyo/paper/event/block/AnvilDamagedEvent.java
|
||||
new file mode 100644
|
||||
index 00000000..fd3c5c02
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/event/block/AnvilDamagedEvent.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package com.destroystokyo.paper.event.block;
|
||||
+
|
||||
+import org.bukkit.Material;
|
||||
+import org.bukkit.block.data.BlockData;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.inventory.InventoryEvent;
|
||||
+import org.bukkit.inventory.AnvilInventory;
|
||||
+import org.bukkit.inventory.InventoryView;
|
||||
+
|
||||
+/**
|
||||
+ * Called when an anvil is damaged from being used
|
||||
+ */
|
||||
+public class AnvilDamagedEvent extends InventoryEvent implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private boolean cancel;
|
||||
+ private DamageState damageState;
|
||||
+
|
||||
+ public AnvilDamagedEvent(InventoryView inventory, BlockData blockData) {
|
||||
+ super(inventory);
|
||||
+ this.damageState = DamageState.getState(blockData);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public AnvilInventory getInventory() {
|
||||
+ return (AnvilInventory) super.getInventory();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the new state of damage on the anvil
|
||||
+ *
|
||||
+ * @return Damage state
|
||||
+ */
|
||||
+ public DamageState getDamageState() {
|
||||
+ return damageState;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the new state of damage on the anvil
|
||||
+ *
|
||||
+ * @param damageState Damage state
|
||||
+ */
|
||||
+ public void setDamageState(DamageState damageState) {
|
||||
+ this.damageState = damageState;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets if anvil is breaking on this use
|
||||
+ *
|
||||
+ * @return True if breaking
|
||||
+ */
|
||||
+ public boolean isBreaking() {
|
||||
+ return damageState == DamageState.BROKEN;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets if anvil is breaking on this use
|
||||
+ *
|
||||
+ * @param breaking True if breaking
|
||||
+ */
|
||||
+ public void setBreaking(boolean breaking) {
|
||||
+ if (breaking) {
|
||||
+ damageState = DamageState.BROKEN;
|
||||
+ } else if (damageState == DamageState.BROKEN) {
|
||||
+ damageState = DamageState.DAMAGED;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public boolean isCancelled() {
|
||||
+ return cancel;
|
||||
+ }
|
||||
+
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ this.cancel = cancel;
|
||||
+ }
|
||||
+
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Represents the amount of damage on an anvil block
|
||||
+ */
|
||||
+ public enum DamageState {
|
||||
+ FULL(Material.ANVIL),
|
||||
+ CHIPPED(Material.CHIPPED_ANVIL),
|
||||
+ DAMAGED(Material.DAMAGED_ANVIL),
|
||||
+ BROKEN(Material.AIR);
|
||||
+
|
||||
+ private Material material;
|
||||
+
|
||||
+ DamageState(Material material) {
|
||||
+ this.material = material;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get block material of this state
|
||||
+ *
|
||||
+ * @return Material
|
||||
+ */
|
||||
+ public Material getMaterial() {
|
||||
+ return material;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get damaged state by block data
|
||||
+ *
|
||||
+ * @param blockData Block data
|
||||
+ * @return DamageState
|
||||
+ * @throws IllegalArgumentException If non anvil block data is given
|
||||
+ */
|
||||
+ public static DamageState getState(BlockData blockData) {
|
||||
+ return blockData == null ? BROKEN : getState(blockData.getMaterial());
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get damaged state by block material
|
||||
+ *
|
||||
+ * @param material Block material
|
||||
+ * @return DamageState
|
||||
+ * @throws IllegalArgumentException If non anvil material is given
|
||||
+ */
|
||||
+ public static DamageState getState(Material material) {
|
||||
+ if (material == null) {
|
||||
+ return BROKEN;
|
||||
+ }
|
||||
+ for (DamageState state : values()) {
|
||||
+ if (state.material == material) {
|
||||
+ return state;
|
||||
+ }
|
||||
+ }
|
||||
+ throw new IllegalArgumentException("Material not an anvil");
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
--
|
|
@ -6,7 +6,7 @@ Subject: [PATCH] Expand Location Manipulation API
|
|||
Adds set(x, y, z), add(base, x, y, z), subtract(base, x, y, z);
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java
|
||||
index d0d86e1a4..253f0c2d5 100644
|
||||
index d0d86e1a..253f0c2d 100644
|
||||
--- a/src/main/java/org/bukkit/Location.java
|
||||
+++ b/src/main/java/org/bukkit/Location.java
|
||||
@@ -0,0 +0,0 @@ public class Location implements Cloneable, ConfigurationSerializable {
|
||||
|
|
|
@ -8,7 +8,7 @@ which can keep them in the chunk when they shouldnt be if done
|
|||
during entity ticking.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||||
index 89d0127af..f8458a2b4 100644
|
||||
index 89d0127afd..f8458a2b49 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -0,0 +0,0 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose
|
||||
|
|
28
Spigot-Server-Patches/AnvilDamageEvent.patch
Normal file
28
Spigot-Server-Patches/AnvilDamageEvent.patch
Normal file
|
@ -0,0 +1,28 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Fri, 20 Jul 2018 23:37:03 -0500
|
||||
Subject: [PATCH] AnvilDamageEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/ContainerAnvil.java b/src/main/java/net/minecraft/server/ContainerAnvil.java
|
||||
index fb3413d81e..9f20348d0c 100644
|
||||
--- a/src/main/java/net/minecraft/server/ContainerAnvil.java
|
||||
+++ b/src/main/java/net/minecraft/server/ContainerAnvil.java
|
||||
@@ -0,0 +0,0 @@ public class ContainerAnvil extends Container {
|
||||
if (!world.isClientSide) {
|
||||
if (!entityhuman.abilities.canInstantlyBuild && iblockdata.a(TagsBlock.y) && entityhuman.getRandom().nextFloat() < 0.12F) {
|
||||
IBlockData iblockdata1 = BlockAnvil.a_(iblockdata);
|
||||
+ // Paper start
|
||||
+ com.destroystokyo.paper.event.block.AnvilDamagedEvent event = new com.destroystokyo.paper.event.block.AnvilDamagedEvent(getBukkitView(), org.bukkit.craftbukkit.block.data.CraftBlockData.fromData(iblockdata1));
|
||||
+ if (!event.callEvent()) {
|
||||
+ return itemstack;
|
||||
+ } else if (event.getDamageState() == com.destroystokyo.paper.event.block.AnvilDamagedEvent.DamageState.BROKEN) {
|
||||
+ iblockdata1 = null;
|
||||
+ } else {
|
||||
+ iblockdata1 = ((org.bukkit.craftbukkit.block.data.CraftBlockData) event.getDamageState().getMaterial().createBlockData()).getState().set(BlockAnvil.FACING, iblockdata.get(BlockAnvil.FACING));
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
if (iblockdata1 == null) {
|
||||
world.setAir(blockposition);
|
||||
--
|
|
@ -11,7 +11,7 @@ Returns true if getDamage() == 0 or has damage tag or other tag is set.
|
|||
Check the `ItemMetaTest#testTaggedButNotMeta` method to see how this method behaves.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||
index 5f3331de1..ae2178096 100644
|
||||
index 5f3331de13..ae21780964 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||
@@ -0,0 +0,0 @@ public final class CraftItemStack extends ItemStack {
|
||||
|
@ -24,7 +24,7 @@ index 5f3331de1..ae2178096 100644
|
|||
|
||||
static boolean hasItemMeta(net.minecraft.server.ItemStack item) {
|
||||
diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java
|
||||
index eb6cf1bb3..79ce3752e 100644
|
||||
index eb6cf1bb33..79ce3752e8 100644
|
||||
--- a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java
|
||||
+++ b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java
|
||||
@@ -0,0 +0,0 @@ import static org.hamcrest.Matchers.*;
|
||||
|
|
|
@ -5,7 +5,7 @@ Subject: [PATCH] EntityTransformedEvent
|
|||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityMushroomCow.java b/src/main/java/net/minecraft/server/EntityMushroomCow.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
index c6babe6af2..a7159ef964 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityMushroomCow.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityMushroomCow.java
|
||||
@@ -0,0 +0,0 @@ public class EntityMushroomCow extends EntityCow {
|
||||
|
@ -18,7 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityVillager.java b/src/main/java/net/minecraft/server/EntityVillager.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
index b51543ea7a..51be54684e 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityVillager.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityVillager.java
|
||||
@@ -0,0 +0,0 @@ public class EntityVillager extends EntityAgeable implements NPC, IMerchant {
|
||||
|
@ -31,7 +31,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
this.die();
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
index 2818ded921..d2d17094df 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityZombie.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityZombie.java
|
||||
@@ -0,0 +0,0 @@ public class EntityZombie extends EntityMonster {
|
||||
|
@ -40,7 +40,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
}
|
||||
-
|
||||
+ if (!new com.destroystokyo.paper.event.entity.EntityTransformedEvent(this.getBukkitEntity(), entityzombie.getBukkitEntity(), com.destroystokyo.paper.event.entity.EntityTransformedEvent.TransformedReason.DROWNED).callEvent()) return; // Paper
|
||||
this.world.addEntity(entityzombie);
|
||||
this.world.addEntity(entityzombie, CreatureSpawnEvent.SpawnReason.DROWNED); // CraftBukkit - added spawn reason
|
||||
this.die();
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class EntityZombie extends EntityMonster {
|
||||
|
@ -52,7 +52,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
this.world.a((EntityHuman) null, 1026, new BlockPosition(this), 0);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityZombieVillager.java b/src/main/java/net/minecraft/server/EntityZombieVillager.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
index 9f61523bec..b8b0d65921 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityZombieVillager.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityZombieVillager.java
|
||||
@@ -0,0 +0,0 @@ public class EntityZombieVillager extends EntityZombie {
|
||||
|
|
|
@ -11,7 +11,7 @@ This will ensure that dead entities are skipped from iteration since
|
|||
they shouldn't of been in the list in the first place.
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperCommand.java b/src/main/java/com/destroystokyo/paper/PaperCommand.java
|
||||
index 7ff8e70b2..4e854c6db 100644
|
||||
index 7ff8e70b24..4e854c6dbe 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperCommand.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperCommand.java
|
||||
@@ -0,0 +0,0 @@ public class PaperCommand extends Command {
|
||||
|
@ -23,7 +23,7 @@ index 7ff8e70b2..4e854c6db 100644
|
|||
MutablePair<Integer, Map<ChunkCoordIntPair, Integer>> info = list.computeIfAbsent(key, k -> MutablePair.of(0, Maps.newHashMap()));
|
||||
ChunkCoordIntPair chunk = new ChunkCoordIntPair(e.getChunkX(), e.getChunkZ());
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index 80955199e..3a4c9a02e 100644
|
||||
index 181a9b7546..3a6ada187b 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
||||
|
@ -35,7 +35,7 @@ index 80955199e..3a4c9a02e 100644
|
|||
public float length;
|
||||
public float J;
|
||||
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||||
index f8458a2b4..ece187129 100644
|
||||
index f8458a2b49..ece1871294 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -0,0 +0,0 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose
|
||||
|
@ -63,7 +63,7 @@ index f8458a2b4..ece187129 100644
|
|||
if (entity instanceof EntityInsentient) {
|
||||
EntityInsentient entityinsentient = (EntityInsentient) entity;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index f4dc7e4ac..8923df898 100644
|
||||
index f4dc7e4ac6..8923df898f 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -0,0 +0,0 @@ public class CraftWorld implements World {
|
||||
|
|
|
@ -8,7 +8,7 @@ Add the following:
|
|||
- Enable/Disable slot interactions
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityArmorStand.java b/src/main/java/net/minecraft/server/EntityArmorStand.java
|
||||
index e9a746f13..3b2b94d8c 100644
|
||||
index e9a746f138..3b2b94d8c6 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityArmorStand.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityArmorStand.java
|
||||
@@ -0,0 +0,0 @@ public class EntityArmorStand extends EntityLiving {
|
||||
|
@ -29,7 +29,7 @@ index e9a746f13..3b2b94d8c 100644
|
|||
return (this.bH & 1 << enumitemslot.c()) != 0;
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
|
||||
index 124c3185b..9f5c3b92e 100644
|
||||
index 124c3185bc..9f5c3b92e3 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftArmorStand.java
|
||||
@@ -0,0 +0,0 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand {
|
||||
|
|
|
@ -18,7 +18,7 @@ an invalid entity.
|
|||
This should reduce log occurrences of dupe uuid messages.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||
index a97e024ec..bd52bf656 100644
|
||||
index a97e024ec4..bd52bf6561 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||
@@ -0,0 +0,0 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
|
||||
|
@ -57,7 +57,7 @@ index a97e024ec..bd52bf656 100644
|
|||
nbttagcompound.set("Entities", nbttaglist1);
|
||||
NBTTagList nbttaglist2 = new NBTTagList();
|
||||
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||||
index 71b3aedfb..09198b866 100644
|
||||
index 52cf52ea73..89d0127afd 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -0,0 +0,0 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose
|
||||
|
@ -70,7 +70,7 @@ index 71b3aedfb..09198b866 100644
|
|||
return true;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
index 7a9f28421..b57e1ff36 100644
|
||||
index 7a9f28421b..b57e1ff364 100644
|
||||
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
@@ -0,0 +0,0 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
||||
|
|
|
@ -59,7 +59,7 @@ index 5a17ce3d22..f7ece47ed9 100644
|
|||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||
index bd52bf6561..54840851ba 100644
|
||||
index e27e952a1b..bf79865105 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java
|
||||
@@ -0,0 +0,0 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {
|
||||
|
|
Loading…
Reference in a new issue