Skip to content

Commit

Permalink
Re-add MC-3304 projectile looting fix patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Krakenied committed Jun 16, 2024
1 parent e8cd239 commit 723fdf5
Show file tree
Hide file tree
Showing 29 changed files with 114 additions and 114 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MelnCat <[email protected]>
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 8d8944a0455b3401d84cab636d61447e7d51ab19..10823d1d75660320e067df480d94d40f6b52ed16 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
@@ -80,6 +80,7 @@ public abstract class AbstractArrow extends Projectile {
public ItemStack pickupItemStack;
@Nullable
public ItemStack firedFromWeapon;
+ public int lootingLevel; // Purpur - Add an option to fix MC-3304 projectile looting

// Spigot Start
@Override
@@ -589,6 +590,12 @@ public abstract class AbstractArrow extends Projectile {
return this.firedFromWeapon;
}

+ // Purpur start - Add an option to fix MC-3304 projectile looting
+ public void setLootingLevel(int lootingLevel) {
+ this.lootingLevel = lootingLevel;
+ }
+ // Purpur end - Add an option to fix MC-3304 projectile looting
+
protected SoundEvent getDefaultHitGroundSoundEvent() {
return SoundEvents.ARROW_HIT;
}
diff --git a/src/main/java/net/minecraft/world/item/ProjectileWeaponItem.java b/src/main/java/net/minecraft/world/item/ProjectileWeaponItem.java
index 32dd0b13a0819f597d8a93c6bc3a155781067544..de3ec96fac9f0a1613a6e74a77d25844634bb572 100644
--- a/src/main/java/net/minecraft/world/item/ProjectileWeaponItem.java
+++ b/src/main/java/net/minecraft/world/item/ProjectileWeaponItem.java
@@ -110,6 +110,13 @@ public abstract class ProjectileWeaponItem extends Item {
entityarrow.setCritArrow(true);
}

+ // Purpur start - Add an option to fix MC-3304 projectile looting
+ int lootingLevel = EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.LOOTING, weaponStack);
+ if (lootingLevel > 0) {
+ entityarrow.setLootingLevel(lootingLevel);
+ }
+ // Purpur end - Add an option to fix MC-3304 projectile looting
+
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 1be074074283f12543ac771ac9201580e7736289..799fee6dc9c51d6e4780df53daa5e5b794b29085 100644
--- a/src/main/java/net/minecraft/world/item/TridentItem.java
+++ b/src/main/java/net/minecraft/world/item/TridentItem.java
@@ -86,6 +86,13 @@ public class TridentItem extends Item implements ProjectileItem {
entitythrowntrident.pickup = AbstractArrow.Pickup.CREATIVE_ONLY;
}

+ // Purpur start - Add an option to fix MC-3304 projectile looting
+ int lootingLevel = EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.LOOTING, stack);
+ if (lootingLevel > 0) {
+ entitythrowntrident.setLootingLevel(lootingLevel);
+ }
+ // Purpur end - Add an option to fix MC-3304 projectile looting
+
// 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/EnchantedCountIncreaseFunction.java b/src/main/java/net/minecraft/world/level/storage/loot/functions/EnchantedCountIncreaseFunction.java
index d86189bd446c7cd7215cfbcef72b2125a064e3d1..144352e62ef091914c9458cd167055ce85fd1fee 100644
--- a/src/main/java/net/minecraft/world/level/storage/loot/functions/EnchantedCountIncreaseFunction.java
+++ b/src/main/java/net/minecraft/world/level/storage/loot/functions/EnchantedCountIncreaseFunction.java
@@ -66,6 +66,13 @@ public class EnchantedCountIncreaseFunction extends LootItemConditionalFunction
Entity entity = context.getParamOrNull(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.getParamOrNull(LootContextParams.DIRECT_ATTACKING_ENTITY)
+ instanceof net.minecraft.world.entity.projectile.AbstractArrow arrow) {
+ i = arrow.lootingLevel;
+ }
+ // 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 72e918ad137dbfe8cde8b179f352224c8b2a1dad..2f05f9c7f86a30b75b4fcaff8a95d0563ed8c9ad 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
@@ -496,6 +496,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.get(ResourceLocation.withDefaultNamespace(blockId));
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Fire Immunity API


diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index ede2ac7a4d49604593a70b2777eb808748fb93a8..3e65d58bf6043a0dc3b4c2e4421ee29bdc99272c 100644
index 5763b9536b85371ed74906df6a13938fd46bd815..6d12da56f191c2889418200397a84b2467b60f17 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -430,6 +430,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Add option to teleport to spawn on nether ceiling damage


diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 3e65d58bf6043a0dc3b4c2e4421ee29bdc99272c..1c2c7c7a9bed8194d1a886ddd71ec22914a4ece2 100644
index 6d12da56f191c2889418200397a84b2467b60f17..722208d61c6e363b4e4af0433b8d6390bbdc3eb3 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -938,6 +938,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Log skipped entity's position


diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java
index 43e7670ab6f22afbf112e430394a95bdc951371a..7148fdcc7411a68082682dcfb82a6927722fb6c1 100644
index 9cac9f5989cd8f73f247e4a3f901a54c03bc00ef..b4f4addfd35a1961a237fc0ab83e6285a0faeaee 100644
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
@@ -625,6 +625,12 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ index f0703302e7dbbda88de8c648d20d87c55ed9b1e0..a913ebabaa5f443afa987b972355a8f8
}
}
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
index 72e918ad137dbfe8cde8b179f352224c8b2a1dad..f4c89696b2020c8aee85cdcae726e09f43fbcb6f 100644
index 2f05f9c7f86a30b75b4fcaff8a95d0563ed8c9ad..111250146a1db4d0e2497c0dce0d9f0f1f298ab6 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
@@ -496,6 +496,16 @@ public class PurpurConfig {
usernameValidCharactersPattern = java.util.regex.Pattern.compile(setPattern == null || setPattern.isBlank() ? defaultPattern : setPattern);
@@ -501,6 +501,16 @@ public class PurpurConfig {
fixProjectileLootingTransfer = getBoolean("settings.fix-projectile-looting-transfer", fixProjectileLootingTransfer);
}

+ public static boolean clampAttributes = true;
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ index d95d122601dd47a27e8d82a13b071919c360fe68..4a96d914f8aa6f0c5f13fc85369a311f
}

diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
index f4c89696b2020c8aee85cdcae726e09f43fbcb6f..63e7532a87963fb37ce84e1040c5dd5d9710aacc 100644
index 111250146a1db4d0e2497c0dce0d9f0f1f298ab6..8c1b21f6bfb6d92cdd461c8ef7b2dd98b8f7db40 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
@@ -566,4 +566,9 @@ public class PurpurConfig {
@@ -571,4 +571,9 @@ public class PurpurConfig {
block.fallDistanceMultiplier = fallDistanceMultiplier.floatValue();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ index 824afdc486a50952bf5e32b06509f7952da9bba5..abb60e5cf3ecdb40561510dc53294e30

io.papermc.paper.plugin.PluginInitializerManager.load(optionset); // Paper
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
index 63e7532a87963fb37ce84e1040c5dd5d9710aacc..2e893884a08f9a0c2f05e1c2c09626b8cc2d280d 100644
index 8c1b21f6bfb6d92cdd461c8ef7b2dd98b8f7db40..7e1ffdf66be384e68c2ab005a1b439609e4a1a13 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
@@ -571,4 +571,9 @@ public class PurpurConfig {
@@ -576,4 +576,9 @@ public class PurpurConfig {
private static void playerDeathsAlwaysShowItem() {
playerDeathsAlwaysShowItem = getBoolean("settings.player-deaths-always-show-item", playerDeathsAlwaysShowItem);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ index 3df64fa31137116aed8b7993cb82164d8d5172cd..40a4273275822a8b3013807a9dd0716a
long i;

diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
index 2e893884a08f9a0c2f05e1c2c09626b8cc2d280d..99e976afd6f6b4c458f3ad03c80887c76b441b32 100644
index 7e1ffdf66be384e68c2ab005a1b439609e4a1a13..10f15a76e9443db84d2443dfe5cf9856e0472630 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
@@ -576,4 +576,16 @@ public class PurpurConfig {
@@ -581,4 +581,16 @@ public class PurpurConfig {
private static void registerMinecraftDebugCommands() {
registerMinecraftDebugCommands = getBoolean("settings.register-minecraft-debug-commands", registerMinecraftDebugCommands);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ index 4c1f20fafdbd86011959cc2d4983b6c2f8e87a5f..78679c2c26a36cf08cf3ffe78617d97d
}
}
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
index 99e976afd6f6b4c458f3ad03c80887c76b441b32..cb2b85d997614df948b0a2ea8f4f792d5b7e973b 100644
index 10f15a76e9443db84d2443dfe5cf9856e0472630..aea73061f4bd47c7307d6fdf0929765f5258cafc 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
@@ -343,6 +343,8 @@ public class PurpurConfig {
Expand Down

This file was deleted.

0 comments on commit 723fdf5

Please sign in to comment.