mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Add an option to fix MC-3304 (projectile looting)
This commit is contained in:
@@ -1,90 +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/net/minecraft/world/entity/projectile/AbstractArrow.java b/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||
index d2a8e0fb1e673cec5701fd184cedfd8e49212acd..e136738ed53a488ad0aa67a04237ac6243fe712c 100644
|
||||
--- a/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||
+++ b/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||
@@ -82,6 +82,7 @@ public abstract class AbstractArrow extends Projectile {
|
||||
public ItemStack pickupItemStack;
|
||||
@Nullable
|
||||
public ItemStack firedFromWeapon;
|
||||
+ public net.minecraft.world.item.enchantment.ItemEnchantments actualEnchantments = net.minecraft.world.item.enchantment.ItemEnchantments.EMPTY; // Purpur - Add an option to fix MC-3304 projectile looting
|
||||
|
||||
// Spigot Start
|
||||
@Override
|
||||
@@ -638,6 +639,12 @@ public abstract class AbstractArrow extends Projectile {
|
||||
return this.firedFromWeapon;
|
||||
}
|
||||
|
||||
+ // Purpur start - Add an option to fix MC-3304 projectile looting
|
||||
+ public void setActualEnchantments(net.minecraft.world.item.enchantment.ItemEnchantments actualEnchantments) {
|
||||
+ this.actualEnchantments = actualEnchantments;
|
||||
+ }
|
||||
+ // Purpur end - Add an option to fix MC-3304 projectile looting
|
||||
+
|
||||
protected SoundEvent getDefaultHitGroundSoundEvent() {
|
||||
return SoundEvents.ARROW_HIT;
|
||||
}
|
||||
diff --git a/net/minecraft/world/item/ProjectileWeaponItem.java b/net/minecraft/world/item/ProjectileWeaponItem.java
|
||||
index 78ba170a83f8c026bd110eae494c52577182ed61..c2ae50872cead7202246b9cce4db6e0a81e1cf5f 100644
|
||||
--- a/net/minecraft/world/item/ProjectileWeaponItem.java
|
||||
+++ b/net/minecraft/world/item/ProjectileWeaponItem.java
|
||||
@@ -105,6 +105,8 @@ public abstract class ProjectileWeaponItem extends Item {
|
||||
entityarrow.setCritArrow(true);
|
||||
}
|
||||
|
||||
+ entityarrow.setActualEnchantments(weaponStack.getEnchantments()); // Purpur - Add an option to fix MC-3304 projectile looting
|
||||
+
|
||||
return entityarrow;
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/world/item/TridentItem.java b/net/minecraft/world/item/TridentItem.java
|
||||
index 810082126567eb02bec395065b95b3c3902d4973..be32255c9bd90f7de3f8f5a62d84c7dcf59fa722 100644
|
||||
--- a/net/minecraft/world/item/TridentItem.java
|
||||
+++ b/net/minecraft/world/item/TridentItem.java
|
||||
@@ -101,6 +101,9 @@ public class TridentItem extends Item implements ProjectileItem {
|
||||
return false;
|
||||
}
|
||||
ThrownTrident entitythrowntrident = tridentDelayed.projectile(); // Paper - PlayerLaunchProjectileEvent
|
||||
+
|
||||
+ entitythrowntrident.setActualEnchantments(stack.getEnchantments()); // Purpur - Add an option to fix MC-3304 projectile looting
|
||||
+
|
||||
if (event.shouldConsume()) stack.hurtWithoutBreaking(1, entityhuman); // Paper - PlayerLaunchProjectileEvent
|
||||
entitythrowntrident.pickupItemStack = stack.copy(); // SPIGOT-4511 update since damage call moved
|
||||
// CraftBukkit end
|
||||
diff --git a/net/minecraft/world/level/storage/loot/functions/EnchantedCountIncreaseFunction.java b/net/minecraft/world/level/storage/loot/functions/EnchantedCountIncreaseFunction.java
|
||||
index 5f27e1ce23f2ed68e4c8af1986fafce940dbf826..d8cf49cbd82ed12d23fa10a81a88cc4bcf1c0f10 100644
|
||||
--- a/net/minecraft/world/level/storage/loot/functions/EnchantedCountIncreaseFunction.java
|
||||
+++ b/net/minecraft/world/level/storage/loot/functions/EnchantedCountIncreaseFunction.java
|
||||
@@ -66,6 +66,11 @@ public class EnchantedCountIncreaseFunction extends LootItemConditionalFunction
|
||||
Entity entity = context.getOptionalParameter(LootContextParams.ATTACKING_ENTITY);
|
||||
if (entity instanceof LivingEntity livingEntity) {
|
||||
int i = EnchantmentHelper.getEnchantmentLevel(this.enchantment, livingEntity);
|
||||
+ // Purpur start - Add an option to fix MC-3304 projectile looting
|
||||
+ if (org.purpurmc.purpur.PurpurConfig.fixProjectileLootingTransfer && context.getOptionalParameter(LootContextParams.DIRECT_ATTACKING_ENTITY) instanceof net.minecraft.world.entity.projectile.AbstractArrow arrow) {
|
||||
+ i = arrow.actualEnchantments.getLevel(this.enchantment);
|
||||
+ }
|
||||
+ // Purpur end - Add an option to fix MC-3304 projectile looting
|
||||
if (i == 0) {
|
||||
return stack;
|
||||
}
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
index 99cccf7c0e4928b47c2a43239475208003781d49..8cbce0cb8fa811edf01af3dbdf69c8abd795b348 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
@@ -502,6 +502,11 @@ public class PurpurConfig {
|
||||
usernameValidCharactersPattern = java.util.regex.Pattern.compile(setPattern == null || setPattern.isBlank() ? defaultPattern : setPattern);
|
||||
}
|
||||
|
||||
+ public static boolean fixProjectileLootingTransfer = false;
|
||||
+ private static void fixProjectileLootingTransfer() {
|
||||
+ fixProjectileLootingTransfer = getBoolean("settings.fix-projectile-looting-transfer", fixProjectileLootingTransfer);
|
||||
+ }
|
||||
+
|
||||
private static void blastResistanceSettings() {
|
||||
getMap("settings.blast-resistance-overrides", Collections.emptyMap()).forEach((blockId, value) -> {
|
||||
Block block = BuiltInRegistries.BLOCK.getValue(ResourceLocation.parse(blockId));
|
||||
Reference in New Issue
Block a user