geforkt von Mirrors/Paper
1718f61bf8
Doesn't compile yet. CraftBukkit Changes: 90d6905b Repackage NMS 69cf961d Repackage patches Spigot Changes: 79d53c28 Repackage NMS
282 Zeilen
19 KiB
Diff
282 Zeilen
19 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
|
Date: Sat, 21 Jul 2018 03:11:03 -0500
|
|
Subject: [PATCH] PlayerLaunchProjectileEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/InteractionResultWrapper.java b/src/main/java/net/minecraft/world/InteractionResultWrapper.java
|
|
index dd17c111670e637b574f5c7f38d27848900ce194..8cecc3d909a51b1892b4a299a5e6ec3518db9b39 100644
|
|
--- a/src/main/java/net/minecraft/world/InteractionResultWrapper.java
|
|
+++ b/src/main/java/net/minecraft/world/InteractionResultWrapper.java
|
|
@@ -10,6 +10,7 @@ public class InteractionResultWrapper<T> {
|
|
this.b = t0;
|
|
}
|
|
|
|
+ public EnumInteractionResult getResult() { return this.a(); } // Paper - OBFHELPER
|
|
public EnumInteractionResult a() {
|
|
return this.a;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/item/ItemEgg.java b/src/main/java/net/minecraft/world/item/ItemEgg.java
|
|
index 2083ab6e0dc7e48d409a5ee33e712e34abd6f6bf..4b1a6ee784da4595931396a905f1358b7a13f3dd 100644
|
|
--- a/src/main/java/net/minecraft/world/item/ItemEgg.java
|
|
+++ b/src/main/java/net/minecraft/world/item/ItemEgg.java
|
|
@@ -25,21 +25,35 @@ public class ItemEgg extends Item {
|
|
|
|
entityegg.setItem(itemstack);
|
|
entityegg.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, 1.5F, 1.0F);
|
|
- // CraftBukkit start
|
|
- if (!world.addEntity(entityegg)) {
|
|
+ // Paper start
|
|
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Projectile) entityegg.getBukkitEntity());
|
|
+ if (event.callEvent() && world.addEntity(entityegg)) {
|
|
+ if (event.shouldConsume() && !entityhuman.abilities.canInstantlyBuild) {
|
|
+ itemstack.subtract(1);
|
|
+ } else if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) {
|
|
+ ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
|
+ }
|
|
+
|
|
+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (net.minecraft.world.entity.Entity.SHARED_RANDOM.nextFloat() * 0.4F + 0.8F));
|
|
+ entityhuman.b(StatisticList.ITEM_USED.b(this));
|
|
+ } else {
|
|
if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) {
|
|
((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
|
}
|
|
- return InteractionResultWrapper.fail(itemstack);
|
|
+ return new InteractionResultWrapper<ItemStack>(net.minecraft.world.EnumInteractionResult.FAIL, itemstack);
|
|
}
|
|
- // CraftBukkit end
|
|
+ // Paper end
|
|
+
|
|
+
|
|
}
|
|
world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (ItemEgg.RANDOM.nextFloat() * 0.4F + 0.8F)); // CraftBukkit - from above
|
|
|
|
+ /* // Paper start - moved up
|
|
entityhuman.b(StatisticList.ITEM_USED.b(this));
|
|
if (!entityhuman.abilities.canInstantlyBuild) {
|
|
itemstack.subtract(1);
|
|
}
|
|
+ */ // Paper end
|
|
|
|
return InteractionResultWrapper.a(itemstack, world.s_());
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/item/ItemEnderPearl.java b/src/main/java/net/minecraft/world/item/ItemEnderPearl.java
|
|
index 5349282b9a5b43c4c3539e1677971463e2ca5a17..9896d77381e7fadf1ef2619210713e190c1445d0 100644
|
|
--- a/src/main/java/net/minecraft/world/item/ItemEnderPearl.java
|
|
+++ b/src/main/java/net/minecraft/world/item/ItemEnderPearl.java
|
|
@@ -25,22 +25,37 @@ public class ItemEnderPearl extends Item {
|
|
|
|
entityenderpearl.setItem(itemstack);
|
|
entityenderpearl.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, 1.5F, 1.0F);
|
|
- if (!world.addEntity(entityenderpearl)) {
|
|
+ // Paper start
|
|
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Projectile) entityenderpearl.getBukkitEntity());
|
|
+ if (event.callEvent() && world.addEntity(entityenderpearl)) {
|
|
+ if (event.shouldConsume() && !entityhuman.abilities.canInstantlyBuild) {
|
|
+ itemstack.subtract(1);
|
|
+ } else if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) {
|
|
+ ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
|
+ }
|
|
+
|
|
+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (net.minecraft.world.entity.Entity.SHARED_RANDOM.nextFloat() * 0.4F + 0.8F));
|
|
+ entityhuman.b(StatisticList.ITEM_USED.b(this));
|
|
+ entityhuman.getCooldownTracker().setCooldown(this, 20);
|
|
+ } else {
|
|
+ // Paper end
|
|
if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) {
|
|
((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
|
}
|
|
- return InteractionResultWrapper.fail(itemstack);
|
|
+ return new InteractionResultWrapper<ItemStack>(net.minecraft.world.EnumInteractionResult.FAIL, itemstack);
|
|
}
|
|
}
|
|
|
|
- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemEnderPearl.RANDOM.nextFloat() * 0.4F + 0.8F));
|
|
- entityhuman.getCooldownTracker().setCooldown(this, 20);
|
|
- // CraftBukkit end
|
|
-
|
|
- entityhuman.b(StatisticList.ITEM_USED.b(this));
|
|
- if (!entityhuman.abilities.canInstantlyBuild) {
|
|
- itemstack.subtract(1);
|
|
- }
|
|
+ // Paper start - moved up
|
|
+// world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemEnderPearl.RANDOM.nextFloat() * 0.4F + 0.8F));
|
|
+// entityhuman.getCooldownTracker().setCooldown(this, 20);
|
|
+// // CraftBukkit end
|
|
+//
|
|
+// entityhuman.b(StatisticList.ITEM_USED.b(this));
|
|
+// if (!entityhuman.abilities.canInstantlyBuild) {
|
|
+// itemstack.subtract(1);
|
|
+// }
|
|
+ // Paper end - moved up
|
|
|
|
return InteractionResultWrapper.a(itemstack, world.s_());
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/item/ItemExpBottle.java b/src/main/java/net/minecraft/world/item/ItemExpBottle.java
|
|
index 3f41fe5bf1a0cc283d6a72824779026fdad75708..6a12b87847f9d5a37299c81f8082cf9eceb4e5c4 100644
|
|
--- a/src/main/java/net/minecraft/world/item/ItemExpBottle.java
|
|
+++ b/src/main/java/net/minecraft/world/item/ItemExpBottle.java
|
|
@@ -24,19 +24,38 @@ public class ItemExpBottle extends Item {
|
|
public InteractionResultWrapper<ItemStack> a(World world, EntityHuman entityhuman, EnumHand enumhand) {
|
|
ItemStack itemstack = entityhuman.b(enumhand);
|
|
|
|
- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_EXPERIENCE_BOTTLE_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemExpBottle.RANDOM.nextFloat() * 0.4F + 0.8F));
|
|
+ //world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_EXPERIENCE_BOTTLE_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemExpBottle.RANDOM.nextFloat() * 0.4F + 0.8F)); // Paper - moved down
|
|
if (!world.isClientSide) {
|
|
EntityThrownExpBottle entitythrownexpbottle = new EntityThrownExpBottle(world, entityhuman);
|
|
|
|
entitythrownexpbottle.setItem(itemstack);
|
|
entitythrownexpbottle.a(entityhuman, entityhuman.pitch, entityhuman.yaw, -20.0F, 0.7F, 1.0F);
|
|
- world.addEntity(entitythrownexpbottle);
|
|
+ // Paper start
|
|
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Projectile) entitythrownexpbottle.getBukkitEntity());
|
|
+ if (event.callEvent() && world.addEntity(entitythrownexpbottle)) {
|
|
+ if (event.shouldConsume() && !entityhuman.abilities.canInstantlyBuild) {
|
|
+ itemstack.subtract(1);
|
|
+ } else if (entityhuman instanceof EntityPlayer) {
|
|
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
|
+ }
|
|
+
|
|
+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_EXPERIENCE_BOTTLE_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (Entity.SHARED_RANDOM.nextFloat() * 0.4F + 0.8F));
|
|
+ entityhuman.b(StatisticList.ITEM_USED.b(this));
|
|
+ } else {
|
|
+ if (entityhuman instanceof EntityPlayer) {
|
|
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
|
+ }
|
|
+ return new InteractionResultWrapper<ItemStack>(EnumInteractionResult.FAIL, itemstack);
|
|
+ }
|
|
+ // Paper end
|
|
}
|
|
|
|
+ /* // Paper start - moved up
|
|
entityhuman.b(StatisticList.ITEM_USED.b(this));
|
|
if (!entityhuman.abilities.canInstantlyBuild) {
|
|
itemstack.subtract(1);
|
|
}
|
|
+ */ // Paper end
|
|
|
|
return InteractionResultWrapper.a(itemstack, world.s_());
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/item/ItemFireworks.java b/src/main/java/net/minecraft/world/item/ItemFireworks.java
|
|
index 79e9be800385b94c4493bd8970620d76bfbd65ae..3cb52eb8c76c5d9aeed90798156cb2710773185a 100644
|
|
--- a/src/main/java/net/minecraft/world/item/ItemFireworks.java
|
|
+++ b/src/main/java/net/minecraft/world/item/ItemFireworks.java
|
|
@@ -29,8 +29,12 @@ public class ItemFireworks extends Item {
|
|
EntityFireworks entityfireworks = new EntityFireworks(world, itemactioncontext.getEntity(), vec3d.x + (double) enumdirection.getAdjacentX() * 0.15D, vec3d.y + (double) enumdirection.getAdjacentY() * 0.15D, vec3d.z + (double) enumdirection.getAdjacentZ() * 0.15D, itemstack);
|
|
entityfireworks.spawningEntity = itemactioncontext.getEntity().getUniqueID(); // Paper
|
|
|
|
- world.addEntity(entityfireworks);
|
|
- itemstack.subtract(1);
|
|
+ // Paper start - PlayerLaunchProjectileEvent
|
|
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) itemactioncontext.getEntity().getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Firework) entityfireworks.getBukkitEntity());
|
|
+ if (!event.callEvent() || !world.addEntity(entityfireworks)) return EnumInteractionResult.PASS;
|
|
+ if (event.shouldConsume() && !itemactioncontext.getEntity().abilities.canInstantlyBuild) itemstack.subtract(1);
|
|
+ else if (itemactioncontext.getEntity() instanceof EntityPlayer) ((EntityPlayer) itemactioncontext.getEntity()).getBukkitEntity().updateInventory();
|
|
+ // Paper end
|
|
}
|
|
|
|
return EnumInteractionResult.a(world.isClientSide);
|
|
diff --git a/src/main/java/net/minecraft/world/item/ItemLingeringPotion.java b/src/main/java/net/minecraft/world/item/ItemLingeringPotion.java
|
|
index a75f374f0639e8143772aa863666afe25d2020cf..5ac094d7cb7bd5f376b6aabbc09b2f024f8bfb18 100644
|
|
--- a/src/main/java/net/minecraft/world/item/ItemLingeringPotion.java
|
|
+++ b/src/main/java/net/minecraft/world/item/ItemLingeringPotion.java
|
|
@@ -15,7 +15,12 @@ public class ItemLingeringPotion extends ItemPotionThrowable {
|
|
|
|
@Override
|
|
public InteractionResultWrapper<ItemStack> a(World world, EntityHuman entityhuman, EnumHand enumhand) {
|
|
- world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_LINGERING_POTION_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemLingeringPotion.RANDOM.nextFloat() * 0.4F + 0.8F));
|
|
- return super.a(world, entityhuman, enumhand);
|
|
+ // Paper start
|
|
+ InteractionResultWrapper<ItemStack> wrapper = super.a(world, entityhuman, enumhand);
|
|
+ if (wrapper.getResult() != EnumInteractionResult.FAIL) {
|
|
+ world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_LINGERING_POTION_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemLingeringPotion.RANDOM.nextFloat() * 0.4F + 0.8F));
|
|
+ }
|
|
+ return wrapper;
|
|
+ // Paper end
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/item/ItemPotionThrowable.java b/src/main/java/net/minecraft/world/item/ItemPotionThrowable.java
|
|
index d050243946ad7023d5dd3958d7056cddcaf185a4..2b795ee9cfb98addc7fabe3363284bf6a493237e 100644
|
|
--- a/src/main/java/net/minecraft/world/item/ItemPotionThrowable.java
|
|
+++ b/src/main/java/net/minecraft/world/item/ItemPotionThrowable.java
|
|
@@ -22,13 +22,31 @@ public class ItemPotionThrowable extends ItemPotion {
|
|
|
|
entitypotion.setItem(itemstack);
|
|
entitypotion.a(entityhuman, entityhuman.pitch, entityhuman.yaw, -20.0F, 0.5F, 1.0F);
|
|
- world.addEntity(entitypotion);
|
|
+ // Paper start
|
|
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Projectile) entitypotion.getBukkitEntity());
|
|
+ if (event.callEvent() && world.addEntity(entitypotion)) {
|
|
+ if (event.shouldConsume() && !entityhuman.abilities.canInstantlyBuild) {
|
|
+ itemstack.subtract(1);
|
|
+ } else if (entityhuman instanceof EntityPlayer) {
|
|
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
|
+ }
|
|
+
|
|
+ entityhuman.b(StatisticList.ITEM_USED.b(this));
|
|
+ } else {
|
|
+ if (entityhuman instanceof EntityPlayer) {
|
|
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
|
+ }
|
|
+ return new InteractionResultWrapper<ItemStack>(EnumInteractionResult.FAIL, itemstack);
|
|
+ }
|
|
+ // Paper end
|
|
}
|
|
|
|
+ /* // Paper start - moved up
|
|
entityhuman.b(StatisticList.ITEM_USED.b(this));
|
|
if (!entityhuman.abilities.canInstantlyBuild) {
|
|
itemstack.subtract(1);
|
|
}
|
|
+ */ // Paper end
|
|
|
|
return InteractionResultWrapper.a(itemstack, world.s_());
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/item/ItemSnowball.java b/src/main/java/net/minecraft/world/item/ItemSnowball.java
|
|
index e5200b2a7d6d5c2d549e585ed157ec5217edae8e..8a1d59cb1ea5a8959c52272aa762ec35307246d7 100644
|
|
--- a/src/main/java/net/minecraft/world/item/ItemSnowball.java
|
|
+++ b/src/main/java/net/minecraft/world/item/ItemSnowball.java
|
|
@@ -26,14 +26,20 @@ public class ItemSnowball extends Item {
|
|
|
|
entitysnowball.setItem(itemstack);
|
|
entitysnowball.a(entityhuman, entityhuman.pitch, entityhuman.yaw, 0.0F, 1.5F, 1.0F);
|
|
- if (world.addEntity(entitysnowball)) {
|
|
- if (!entityhuman.abilities.canInstantlyBuild) {
|
|
+ // Paper start
|
|
+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Projectile) entitysnowball.getBukkitEntity());
|
|
+ if (event.callEvent() && world.addEntity(entitysnowball)) {
|
|
+ if (event.shouldConsume() && !entityhuman.abilities.canInstantlyBuild) {
|
|
+ // Paper end
|
|
itemstack.subtract(1);
|
|
+ } else if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) { // Paper
|
|
+ ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // Paper
|
|
}
|
|
|
|
world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (ItemSnowball.RANDOM.nextFloat() * 0.4F + 0.8F));
|
|
- } else if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) {
|
|
- ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
|
|
+ } else { // Paper
|
|
+ if (entityhuman instanceof net.minecraft.server.level.EntityPlayer) ((net.minecraft.server.level.EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // Paper
|
|
+ return new InteractionResultWrapper<ItemStack>(net.minecraft.world.EnumInteractionResult.FAIL, itemstack); // Paper
|
|
}
|
|
}
|
|
// CraftBukkit end
|
|
diff --git a/src/main/java/net/minecraft/world/item/ItemSplashPotion.java b/src/main/java/net/minecraft/world/item/ItemSplashPotion.java
|
|
index 98f29fac4bf087ad15f1cc7e85b408e22ec07efd..052e7056271bc21fceaf4fa78e9e833ac5c0cad9 100644
|
|
--- a/src/main/java/net/minecraft/world/item/ItemSplashPotion.java
|
|
+++ b/src/main/java/net/minecraft/world/item/ItemSplashPotion.java
|
|
@@ -15,7 +15,12 @@ public class ItemSplashPotion extends ItemPotionThrowable {
|
|
|
|
@Override
|
|
public InteractionResultWrapper<ItemStack> a(World world, EntityHuman entityhuman, EnumHand enumhand) {
|
|
+ // Paper start
|
|
+ InteractionResultWrapper<ItemStack> wrapper = super.a(world, entityhuman, enumhand);
|
|
+ if (wrapper.getResult() != EnumInteractionResult.FAIL) {
|
|
world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_SPLASH_POTION_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (ItemSplashPotion.RANDOM.nextFloat() * 0.4F + 0.8F));
|
|
- return super.a(world, entityhuman, enumhand);
|
|
+ }
|
|
+ return wrapper;
|
|
+ // Paper end
|
|
}
|
|
}
|