mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@e30b082 Fix setting difficulity inside of API (Fixes #8533) PaperMC/Paper@ebc0f6b Call PlayerLaunchProjectileEvent for trident (#8027) PaperMC/Paper@ab1c072 Remove old redundant fix (#8530) PaperMC/Paper@8ee344f [ci-skip] Rename Paper stop tp Paper end. (#8539) PaperMC/Paper@3d15120 Fix Advancement#getDisplay() api break (#8541) PaperMC/Paper@2b47227 Update Commodore modifications (#8542) PaperMC/Paper@df5fb94 Properly resend entities (#7041)
120 lines
6.6 KiB
Diff
120 lines
6.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: MelnCat <melncatuwu@gmail.com>
|
|
Date: Sat, 1 Oct 2022 11:33:15 -0700
|
|
Subject: [PATCH] Add an option to fix MC-3304 (projectile looting)
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
|
index 98cfacc950b088a98f592fdf6e00d8a057628ed5..f2321de6bbba7681bcc82c5706f01b76d643ec6f 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
|
@@ -71,6 +71,7 @@ public abstract class AbstractArrow extends Projectile {
|
|
private IntOpenHashSet piercingIgnoreEntityIds;
|
|
@Nullable
|
|
private List<Entity> piercedAndKilledEntities;
|
|
+ public int lootingLevel; // Purpur
|
|
|
|
// Spigot Start
|
|
@Override
|
|
@@ -622,6 +623,12 @@ public abstract class AbstractArrow extends Projectile {
|
|
this.knockback = punch;
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ public void setLootingLevel(int looting) {
|
|
+ this.lootingLevel = looting;
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
public int getKnockback() {
|
|
return this.knockback;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/item/BowItem.java b/src/main/java/net/minecraft/world/item/BowItem.java
|
|
index 220513d3fd5645322886522ea4f6b8c55d043b3c..d45a2f49c82d00801578c34e5f5277fc5e82be87 100644
|
|
--- a/src/main/java/net/minecraft/world/item/BowItem.java
|
|
+++ b/src/main/java/net/minecraft/world/item/BowItem.java
|
|
@@ -64,6 +64,13 @@ public class BowItem extends ProjectileWeaponItem implements Vanishable {
|
|
if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.FLAMING_ARROWS, stack) > 0) {
|
|
entityarrow.setSecondsOnFire(100);
|
|
}
|
|
+ // Purpur start
|
|
+ int lootingLevel = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.MOB_LOOTING, stack);
|
|
+
|
|
+ if (lootingLevel > 0) {
|
|
+ entityarrow.setLootingLevel(lootingLevel);
|
|
+ }
|
|
+ // Purpur end
|
|
// CraftBukkit start
|
|
org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityhuman, stack, itemstack1, entityarrow, entityhuman.getUsedItemHand(), f, !flag1);
|
|
if (event.isCancelled()) {
|
|
diff --git a/src/main/java/net/minecraft/world/item/CrossbowItem.java b/src/main/java/net/minecraft/world/item/CrossbowItem.java
|
|
index 2d30300de78de957358cfddac12294b308062e2a..37cbd0d95f3232ed399c6ef19f714c547b9fd8e5 100644
|
|
--- a/src/main/java/net/minecraft/world/item/CrossbowItem.java
|
|
+++ b/src/main/java/net/minecraft/world/item/CrossbowItem.java
|
|
@@ -294,6 +294,14 @@ public class CrossbowItem extends ProjectileWeaponItem implements Vanishable {
|
|
entityarrow.setPierceLevel((byte) i);
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ int lootingLevel = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.MOB_LOOTING, crossbow);
|
|
+
|
|
+ if (lootingLevel > 0) {
|
|
+ entityarrow.setLootingLevel(lootingLevel);
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
return entityarrow;
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/TridentItem.java b/src/main/java/net/minecraft/world/item/TridentItem.java
|
|
index 60512d08a45670a164a9b93191aafa40b2c2287c..d35432087c70ce66b74d1e27df19f462f22b1aa1 100644
|
|
--- a/src/main/java/net/minecraft/world/item/TridentItem.java
|
|
+++ b/src/main/java/net/minecraft/world/item/TridentItem.java
|
|
@@ -82,6 +82,14 @@ public class TridentItem extends Item implements Vanishable {
|
|
entitythrowntrident.pickup = AbstractArrow.Pickup.CREATIVE_ONLY;
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ int lootingLevel = EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.MOB_LOOTING, stack);
|
|
+
|
|
+ if (lootingLevel > 0) {
|
|
+ entitythrowntrident.setLootingLevel(lootingLevel);
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
// CraftBukkit start
|
|
// 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(stack), (org.bukkit.entity.Projectile) entitythrowntrident.getBukkitEntity());
|
|
diff --git a/src/main/java/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java b/src/main/java/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java
|
|
index 31918fa2eb38e42a5ea5366e559f25ea9d7d59ae..15d8e9261a89da30529ac347462c520920ca4e7d 100644
|
|
--- a/src/main/java/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java
|
|
+++ b/src/main/java/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java
|
|
@@ -49,6 +49,13 @@ public class LootingEnchantFunction extends LootItemConditionalFunction {
|
|
|
|
if (entity instanceof LivingEntity) {
|
|
int i = EnchantmentHelper.getMobLooting((LivingEntity) entity);
|
|
+ // Purpur start
|
|
+ if (org.purpurmc.purpur.PurpurConfig.fixProjectileLootingTransfer &&
|
|
+ context.getParamOrNull(LootContextParams.DIRECT_KILLER_ENTITY)
|
|
+ instanceof net.minecraft.world.entity.projectile.AbstractArrow arrow) {
|
|
+ i = arrow.lootingLevel;
|
|
+ }
|
|
+ // Purpur end
|
|
// CraftBukkit start - use lootingModifier if set by plugin
|
|
if (context.hasParam(LootContextParams.LOOTING_MOD)) {
|
|
i = context.getParamOrNull(LootContextParams.LOOTING_MOD);
|
|
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
|
index 697367da89959abc7145c76d49f6d801d9ab0b23..01fe3af88214ec7d73f307d5209955bd925ccc96 100644
|
|
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
|
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
|
@@ -568,4 +568,9 @@ public class PurpurConfig {
|
|
}
|
|
});
|
|
}
|
|
+
|
|
+ public static boolean fixProjectileLootingTransfer = false;
|
|
+ private static void fixProjectileLootingTransfer() {
|
|
+ fixProjectileLootingTransfer = getBoolean("settings.fix-projectile-looting-transfer", fixProjectileLootingTransfer);
|
|
+ }
|
|
}
|