Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-16 04:50:05 +01:00
060bc7bbee
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 Bukkit Changes: 4543fb40 SPIGOT-4943: Zombie villager conversion player API. CraftBukkit Changes:585b2ebd
Tweak thresholds for can't keep up message91ada5c2
SPIGOT-4956: EntityTameEvent not triggered when taming a Cat9bda4134
SPIGOT-4943: Zombie villager conversion player API.5a027071
SPIGOT-4947: Allow setting the content on a lectern09d00e9f
SPIGOT-4938: Call EntityPickupItemEvent for dolphinsa278e445
SPIGOT-4948: Lectern.getInventory should return a LecternInventory Spigot Changes: 4f661b22 Rebuild patches
109 Zeilen
7.2 KiB
Diff
109 Zeilen
7.2 KiB
Diff
From 71dac4714cff48c23f3eed560c4043fddad86f3a Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Sat, 15 Jun 2013 19:51:17 -0400
|
|
Subject: [PATCH] EntityShootBowEvent consumeArrow and getArrowItem API
|
|
|
|
Adds ability to get what arrow was shot, and control if it should be consumed.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntitySkeletonAbstract.java b/src/main/java/net/minecraft/server/EntitySkeletonAbstract.java
|
|
index e575d3cff..85157e80d 100644
|
|
--- a/src/main/java/net/minecraft/server/EntitySkeletonAbstract.java
|
|
+++ b/src/main/java/net/minecraft/server/EntitySkeletonAbstract.java
|
|
@@ -157,7 +157,7 @@ public abstract class EntitySkeletonAbstract extends EntityMonster implements IR
|
|
|
|
entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.world.getDifficulty().a() * 4));
|
|
// CraftBukkit start
|
|
- org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getItemInMainHand(), entityarrow, 0.8F);
|
|
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getItemInMainHand(), this.getItemInOffHand(), entityarrow, 0.8F); // Paper
|
|
if (event.isCancelled()) {
|
|
event.getProjectile().remove();
|
|
return;
|
|
diff --git a/src/main/java/net/minecraft/server/ItemBow.java b/src/main/java/net/minecraft/server/ItemBow.java
|
|
index 50b815dc8..4ec02c8ce 100644
|
|
--- a/src/main/java/net/minecraft/server/ItemBow.java
|
|
+++ b/src/main/java/net/minecraft/server/ItemBow.java
|
|
@@ -36,6 +36,7 @@ public class ItemBow extends ItemProjectileWeapon {
|
|
if ((double) f >= 0.1D) {
|
|
boolean flag1 = flag && itemstack1.getItem() == Items.ARROW;
|
|
|
|
+ boolean consumeArrow = true; // Paper
|
|
if (!world.isClientSide) {
|
|
ItemArrow itemarrow = (ItemArrow) ((ItemArrow) (itemstack1.getItem() instanceof ItemArrow ? itemstack1.getItem() : Items.ARROW));
|
|
EntityArrow entityarrow = itemarrow.a(world, itemstack1, (EntityLiving) entityhuman);
|
|
@@ -61,7 +62,7 @@ public class ItemBow extends ItemProjectileWeapon {
|
|
entityarrow.setOnFire(100);
|
|
}
|
|
// CraftBukkit start
|
|
- org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityhuman, itemstack, entityarrow, f);
|
|
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityhuman, itemstack, itemstack1, entityarrow, f); // Paper
|
|
if (event.isCancelled()) {
|
|
event.getProjectile().remove();
|
|
return;
|
|
@@ -71,7 +72,8 @@ public class ItemBow extends ItemProjectileWeapon {
|
|
itemstack.damage(1, entityhuman, (entityhuman1) -> {
|
|
entityhuman1.d(entityhuman.getRaisedHand());
|
|
});
|
|
- if (flag1 || entityhuman.abilities.canInstantlyBuild && (itemstack1.getItem() == Items.SPECTRAL_ARROW || itemstack1.getItem() == Items.TIPPED_ARROW)) {
|
|
+ consumeArrow = event.getConsumeArrow(); // Paper
|
|
+ if (!consumeArrow || flag1 || (entityhuman.abilities.canInstantlyBuild && ((itemstack1.getItem() == Items.SPECTRAL_ARROW) || (itemstack1.getItem() == Items.TIPPED_ARROW)))) { // Paper - add
|
|
entityarrow.fromPlayer = EntityArrow.PickupStatus.CREATIVE_ONLY;
|
|
}
|
|
|
|
@@ -88,7 +90,7 @@ public class ItemBow extends ItemProjectileWeapon {
|
|
}
|
|
|
|
world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F / (ItemBow.i.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
|
|
- if (!flag1 && !entityhuman.abilities.canInstantlyBuild) {
|
|
+ if (!flag1 && !entityhuman.abilities.canInstantlyBuild && consumeArrow) { // Paper
|
|
itemstack1.subtract(1);
|
|
if (itemstack1.isEmpty()) {
|
|
entityhuman.inventory.f(itemstack1);
|
|
diff --git a/src/main/java/net/minecraft/server/ItemCrossbow.java b/src/main/java/net/minecraft/server/ItemCrossbow.java
|
|
index 670b0b33a..5d58d5e35 100644
|
|
--- a/src/main/java/net/minecraft/server/ItemCrossbow.java
|
|
+++ b/src/main/java/net/minecraft/server/ItemCrossbow.java
|
|
@@ -220,7 +220,7 @@ public class ItemCrossbow extends ItemProjectileWeapon {
|
|
((IProjectile) object).shoot((double) vector3fa.a(), (double) vector3fa.b(), (double) vector3fa.c(), f1, f2);
|
|
}
|
|
// CraftBukkit start
|
|
- org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityliving, itemstack, (Entity) object, f);
|
|
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityliving, itemstack, itemstack1, (IProjectile) object, f); // Paper // TODO: consume??
|
|
if (event.isCancelled()) {
|
|
event.getProjectile().remove();
|
|
return;
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
index 4e84f4373..ef62edec4 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -49,6 +49,7 @@ import net.minecraft.server.GeneratorAccess;
|
|
import net.minecraft.server.IBlockData;
|
|
import net.minecraft.server.IChatBaseComponent;
|
|
import net.minecraft.server.IInventory;
|
|
+import net.minecraft.server.IProjectile;
|
|
import net.minecraft.server.ItemActionContext;
|
|
import net.minecraft.server.ItemStack;
|
|
import net.minecraft.server.Items;
|
|
@@ -453,16 +454,16 @@ public class CraftEventFactory {
|
|
/**
|
|
* EntityShootBowEvent
|
|
*/
|
|
- public static EntityShootBowEvent callEntityShootBowEvent(EntityLiving who, ItemStack itemstack, Entity entityArrow, float force) {
|
|
+ public static EntityShootBowEvent callEntityShootBowEvent(EntityLiving who, ItemStack itemstack, ItemStack arrowItem, IProjectile entityArrow, float force) { // paper
|
|
LivingEntity shooter = (LivingEntity) who.getBukkitEntity();
|
|
CraftItemStack itemInHand = CraftItemStack.asCraftMirror(itemstack);
|
|
- org.bukkit.entity.Entity arrow = entityArrow.getBukkitEntity();
|
|
+ org.bukkit.entity.Entity arrow = ((Entity) entityArrow).getBukkitEntity(); // Paper
|
|
|
|
if (itemInHand != null && (itemInHand.getType() == Material.AIR || itemInHand.getAmount() == 0)) {
|
|
itemInHand = null;
|
|
}
|
|
|
|
- EntityShootBowEvent event = new EntityShootBowEvent(shooter, itemInHand, arrow, force);
|
|
+ EntityShootBowEvent event = new EntityShootBowEvent(shooter, itemInHand, CraftItemStack.asCraftMirror(arrowItem), arrow, force); // Paper
|
|
Bukkit.getPluginManager().callEvent(event);
|
|
|
|
return event;
|
|
--
|
|
2.21.0
|
|
|