Merge pull request #1244

3e19de0c Rebuild Patches (BillyGalbreath)
8e5db995 AnvilDamageEvent (BillyGalbreath)

* pull/1244/head:
  Rebuild Patches
  AnvilDamageEvent
This commit is contained in:
Aikar 2018-07-30 00:12:03 -04:00
commit c7dcc8ce89
No known key found for this signature in database
GPG key ID: 401ADFC9891FAAFE
14 changed files with 218 additions and 34 deletions

View file

@ -1,4 +1,4 @@
From 93e04ed6a39bcb66e013b66107968993311b8e97 Mon Sep 17 00:00:00 2001
From 6771e034d702256481db7832fa45c13d0bbeb47c Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 25 Jul 2018 01:36:07 -0400
Subject: [PATCH] Expand Location Manipulation API
@ -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
@@ -503,6 +503,51 @@ public class Location implements Cloneable, ConfigurationSerializable {

View file

@ -1,4 +1,4 @@
From b10e72a40d9419d2c2537dc78d67d42275aec749 Mon Sep 17 00:00:00 2001
From 903ef20f911aefe950c3b48f2731c805a09ad6d9 Mon Sep 17 00:00:00 2001
From: willies952002 <admin@domnian.com>
Date: Thu, 26 Jul 2018 02:22:44 -0400
Subject: [PATCH] Expand ArmorStand API
@ -113,5 +113,5 @@ index 099da6ce..7a8f4eb7 100644
// Paper end
}
--
2.17.0
2.18.0

View file

@ -0,0 +1,154 @@
From 813d60f7b48916f251222be3ca99019797eb7f04 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 +1,139 @@
+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");
+ }
+ }
+}
--
2.18.0

View file

@ -1,11 +1,11 @@
From 9f56713daf2d5371b7e443be7e205ece7106f371 Mon Sep 17 00:00:00 2001
From 25140e07725982114ac1f109f9de3dcdf8a823d4 Mon Sep 17 00:00:00 2001
From: Anthony MacAllister <anthonymmacallister@gmail.com>
Date: Thu, 26 Jul 2018 15:30:03 -0400
Subject: [PATCH] EntityTransformedEvent
diff --git a/src/main/java/net/minecraft/server/EntityMushroomCow.java b/src/main/java/net/minecraft/server/EntityMushroomCow.java
index c6babe6..a7159ef 100644
index c6babe6af2..a7159ef964 100644
--- a/src/main/java/net/minecraft/server/EntityMushroomCow.java
+++ b/src/main/java/net/minecraft/server/EntityMushroomCow.java
@@ -43,7 +43,7 @@ public class EntityMushroomCow extends EntityCow {
@ -18,7 +18,7 @@ index c6babe6..a7159ef 100644
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 b51543e..51be546 100644
index b51543ea7a..51be54684e 100644
--- a/src/main/java/net/minecraft/server/EntityVillager.java
+++ b/src/main/java/net/minecraft/server/EntityVillager.java
@@ -623,7 +623,7 @@ public class EntityVillager extends EntityAgeable implements NPC, IMerchant {
@ -31,7 +31,7 @@ index b51543e..51be546 100644
this.die();
}
diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java
index 90aa864..adf314e 100644
index 2818ded921..d2d17094df 100644
--- a/src/main/java/net/minecraft/server/EntityZombie.java
+++ b/src/main/java/net/minecraft/server/EntityZombie.java
@@ -233,7 +233,7 @@ public class EntityZombie extends EntityMonster {
@ -40,7 +40,7 @@ index 90aa864..adf314e 100644
}
-
+ 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();
}
@@ -392,6 +392,7 @@ public class EntityZombie extends EntityMonster {
@ -52,7 +52,7 @@ index 90aa864..adf314e 100644
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 9f61523..b8b0d65 100644
index 9f61523bec..b8b0d65921 100644
--- a/src/main/java/net/minecraft/server/EntityZombieVillager.java
+++ b/src/main/java/net/minecraft/server/EntityZombieVillager.java
@@ -130,7 +130,7 @@ public class EntityZombieVillager extends EntityZombie {
@ -65,5 +65,5 @@ index 9f61523..b8b0d65 100644
if (this.bD != null) {
EntityHuman entityhuman = this.world.b(this.bD);
--
2.8.4.windows.1
2.18.0

View file

@ -1,4 +1,4 @@
From 0c1e9106914dad59278269769b4715c8f3425213 Mon Sep 17 00:00:00 2001
From 586eacd69777a9e5e020fe3397b05fd6a55bd4bf Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 26 Jul 2018 00:11:12 -0400
Subject: [PATCH] Prevent Saving Bad entities to chunks
@ -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
@@ -561,11 +561,22 @@ 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
@@ -1064,7 +1064,7 @@ 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
@@ -992,7 +992,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {

View file

@ -1,4 +1,4 @@
From 342bf0dd7bf7ea5b7e8e120754d97dfda4ddfa91 Mon Sep 17 00:00:00 2001
From c2a830260250be91d01455db5c8bf2f168451ea8 Mon Sep 17 00:00:00 2001
From: Hugo Manrique <hugmanrique@gmail.com>
Date: Thu, 26 Jul 2018 14:10:23 +0200
Subject: [PATCH] Don't call getItemMeta on hasItemMeta
@ -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
@@ -517,7 +517,7 @@ 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
@@ -5,6 +5,7 @@ import static org.hamcrest.Matchers.*;

View file

@ -1,4 +1,4 @@
From c461973839a211b635e7b8446d8acc317726398f Mon Sep 17 00:00:00 2001
From 47975722cb4b98f424a68262b9275ac8f22b02fc Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 28 Jul 2018 12:09:20 -0400
Subject: [PATCH] Always process chunk removal in removeEntity
@ -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
@@ -1134,7 +1134,7 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose

View file

@ -1,4 +1,4 @@
From e45fe59859d3c44a5175828b4c1727227265bc84 Mon Sep 17 00:00:00 2001
From d6b6d12dc73d9d270533fd1bb90ecc52ec9f2559 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 28 Jul 2018 12:18:27 -0400
Subject: [PATCH] Ignore Dead Entities in entityList iteration
@ -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
@@ -172,6 +172,7 @@ 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
@@ -121,6 +121,7 @@ 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
@@ -1141,6 +1141,7 @@ 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
@@ -660,6 +660,7 @@ public class CraftWorld implements World {

View file

@ -1,4 +1,4 @@
From 622fc979613881a9d3a812cf71a468ec58376223 Mon Sep 17 00:00:00 2001
From 51494b5e21263e67c2a6dd97a403232b66cf8511 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 29 Jul 2018 11:58:05 -0400
Subject: [PATCH] Always process chunk registration after moving

View file

@ -1,4 +1,4 @@
From a4b33c025c22c73b86648dde212ee91c5942a9b6 Mon Sep 17 00:00:00 2001
From a02a1b3c9ef37a959c88e9872d74b9c51ff589b4 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 29 Jul 2018 16:56:48 -0400
Subject: [PATCH] Process Chunk.addEntities before chunkLoadEvent

View file

@ -1,4 +1,4 @@
From b33d52f15d20e9c6ba4457eb799b67e32792e595 Mon Sep 17 00:00:00 2001
From a7a1dcd531c2215064128d003ab61949e4155ee1 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 29 Jul 2018 15:48:50 -0400
Subject: [PATCH] Provide option to use a versioned world folder for testing
@ -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
@@ -55,8 +55,56 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver {

View file

@ -1,4 +1,4 @@
From 94c2a47565acf1fdadeb9b1c7554ff34734f4a44 Mon Sep 17 00:00:00 2001
From dd9e73724d7d3039bd0da34f3588109242df8435 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 29 Jul 2018 22:58:47 -0400
Subject: [PATCH] MC-111480: Start Entity ID's at 1

View file

@ -1,4 +1,4 @@
From 60a2a3f91ddbd0a8c79ee9246e6ff03df41dc9b4 Mon Sep 17 00:00:00 2001
From 73306253e6d50a22e18f0d4626caaa3504d5cd4e Mon Sep 17 00:00:00 2001
From: willies952002 <admin@domnian.com>
Date: Thu, 26 Jul 2018 02:25:46 -0400
Subject: [PATCH] Implement Expanded ArmorStand API
@ -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
@@ -36,7 +36,7 @@ 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
@@ -30,11 +30,13 @@ public class CraftArmorStand extends CraftLivingEntity implements ArmorStand {
@ -126,5 +126,5 @@ index 124c3185b..9f5c3b92e 100644
// Paper end
}
--
2.17.0
2.18.0

View file

@ -0,0 +1,30 @@
From 0d77d311b323dc6dbccc0b11fe6ad81bcdea832d 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
@@ -73,6 +73,16 @@ 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);
--
2.18.0