mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-01 20:50:41 +01:00
SPIGOT-3417: Event for shearing snowman
This commit is contained in:
parent
6659ddf11a
commit
e03b1a556d
2 changed files with 22 additions and 7 deletions
|
@ -1,18 +1,17 @@
|
||||||
--- a/net/minecraft/server/EntitySnowman.java
|
--- a/net/minecraft/server/EntitySnowman.java
|
||||||
+++ b/net/minecraft/server/EntitySnowman.java
|
+++ b/net/minecraft/server/EntitySnowman.java
|
||||||
@@ -1,6 +1,11 @@
|
@@ -1,6 +1,10 @@
|
||||||
package net.minecraft.server;
|
package net.minecraft.server;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
+// CraftBukkit start
|
+// CraftBukkit start
|
||||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||||
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
+import org.bukkit.event.player.PlayerShearEntityEvent;
|
||||||
+import org.bukkit.event.block.EntityBlockFormEvent;
|
|
||||||
+// CraftBukkit end
|
+// CraftBukkit end
|
||||||
|
|
||||||
public class EntitySnowman extends EntityGolem implements IRangedEntity {
|
public class EntitySnowman extends EntityGolem implements IRangedEntity {
|
||||||
|
|
||||||
@@ -59,7 +64,7 @@
|
@@ -59,7 +63,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.world.getBiome(new BlockPosition(i, 0, k)).a(new BlockPosition(i, j, k)) > 1.0F) {
|
if (this.world.getBiome(new BlockPosition(i, 0, k)).a(new BlockPosition(i, j, k)) > 1.0F) {
|
||||||
|
@ -21,7 +20,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.world.getGameRules().getBoolean("mobGriefing")) {
|
if (!this.world.getGameRules().getBoolean("mobGriefing")) {
|
||||||
@@ -73,7 +78,7 @@
|
@@ -73,7 +77,7 @@
|
||||||
BlockPosition blockposition = new BlockPosition(i, j, k);
|
BlockPosition blockposition = new BlockPosition(i, j, k);
|
||||||
|
|
||||||
if (this.world.getType(blockposition).getMaterial() == Material.AIR && this.world.getBiome(blockposition).a(blockposition) < 0.8F && Blocks.SNOW_LAYER.canPlace(this.world, blockposition)) {
|
if (this.world.getType(blockposition).getMaterial() == Material.AIR && this.world.getBiome(blockposition).a(blockposition) < 0.8F && Blocks.SNOW_LAYER.canPlace(this.world, blockposition)) {
|
||||||
|
@ -30,3 +29,19 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -106,6 +110,15 @@
|
||||||
|
ItemStack itemstack = entityhuman.b(enumhand);
|
||||||
|
|
||||||
|
if (itemstack.getItem() == Items.SHEARS && this.hasPumpkin() && !this.world.isClientSide) {
|
||||||
|
+ // CraftBukkit start
|
||||||
|
+ PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
|
||||||
|
+ this.world.getServer().getPluginManager().callEvent(event);
|
||||||
|
+
|
||||||
|
+ if (event.isCancelled()) {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ // CraftBukkit end
|
||||||
|
+
|
||||||
|
this.setHasPumpkin(false);
|
||||||
|
itemstack.damage(1, entityhuman);
|
||||||
|
}
|
||||||
|
|
|
@ -12,12 +12,12 @@ public class CraftSnowman extends CraftGolem implements Snowman {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDerp() {
|
public boolean isDerp() {
|
||||||
return getHandle().hasPumpkin();
|
return !getHandle().hasPumpkin();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDerp(boolean derpMode) {
|
public void setDerp(boolean derpMode) {
|
||||||
getHandle().setHasPumpkin(derpMode);
|
getHandle().setHasPumpkin(!derpMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue