mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-19 09:27:43 +01:00
add back MC-3304 fix
This commit is contained in:
@@ -1,119 +0,0 @@
|
||||
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 5d60f038220ef4e7b66834c172cc47c7abfe7da7..a9289c4179a78862361be87aaa83f49d6bf60714 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||
@@ -75,6 +75,7 @@ public abstract class AbstractArrow extends Projectile {
|
||||
@Nullable
|
||||
private List<Entity> piercedAndKilledEntities;
|
||||
public ItemStack pickupItemStack;
|
||||
+ public int lootingLevel; // Purpur
|
||||
|
||||
// Spigot Start
|
||||
@Override
|
||||
@@ -642,6 +643,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 05d3a7c077df1b92819655790230cd22028f6893..211d8e59a9b3460b346e5f8cf581df70b05d1b8f 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/CrossbowItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/CrossbowItem.java
|
||||
@@ -291,6 +291,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 7030d94ba14ecacc1e5cd6d6432b1bcb59c8b646..95f9dd3f8fbf593fd6898335454951868c867a06 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 - PlayerLaunchProjectileEvent
|
||||
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 3fb1e558c3510243c94981211f9a0e5e0ef1895b..e5177e5ffcac360f935f2139db4554c6586b551e 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
|
||||
@@ -57,6 +57,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 5329ad6493950a561bd46045e35a9bd70ac4405f..88763ca8cc31bda23f8f31d2bc990fb4a85c9955 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
@@ -573,4 +573,9 @@ public class PurpurConfig {
|
||||
private static void fixNetworkSerializedCreativeItems() {
|
||||
fixNetworkSerializedItemsInCreative = getBoolean("settings.fix-network-serialized-items-in-creative", fixNetworkSerializedItemsInCreative);
|
||||
}
|
||||
+
|
||||
+ public static boolean fixProjectileLootingTransfer = false;
|
||||
+ private static void fixProjectileLootingTransfer() {
|
||||
+ fixProjectileLootingTransfer = getBoolean("settings.fix-projectile-looting-transfer", fixProjectileLootingTransfer);
|
||||
+ }
|
||||
}
|
||||
Reference in New Issue
Block a user