Skip to content

Commit

Permalink
ignore item_model component for don't run with scissors feature alo…
Browse files Browse the repository at this point in the history
…ngside `custom_model_data` component

by default, the "don't run with scissors" feature will not activate for shears that have an `item_model` component or `custom_model_data` component.

adds a new world config option at `gameplay-mechanics.item.shears.damage-if-sprinting-item-model` that allows specifying a custom item model ResourceLocation (`purpurmc:scissors` by default) for use with this feature.
  • Loading branch information
granny committed Dec 6, 2024
1 parent 2af2e71 commit ffeb49d
Show file tree
Hide file tree
Showing 96 changed files with 429 additions and 424 deletions.
25 changes: 15 additions & 10 deletions patches/server/0128-Dont-run-with-scissors.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,35 @@ Subject: [PATCH] Dont run with scissors!
inspired by https://modrinth.com/mod/dont-run-with-scissors

diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index b4cd58ae2c89cb3875cff2bcbe60511d94a926d4..10757591f1318222f79ff4e3df4c59bacfc41dee 100644
index b4cd58ae2c89cb3875cff2bcbe60511d94a926d4..c8cf05ac72a7b30e8d2239c4e07c9cc52d5990e2 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1721,6 +1721,13 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
this.player.tryResetCurrentImpulseContext();
}

+ // Purpur Start
+ if (this.player.level().purpurConfig.dontRunWithScissors && this.player.isSprinting() && !(this.player.level().purpurConfig.ignoreScissorsInWater && this.player.isInWater()) && !(this.player.level().purpurConfig.ignoreScissorsInLava && this.player.isInLava()) && (isScissor(this.player.getItemInHand(InteractionHand.MAIN_HAND)) || isScissor(this.player.getItemInHand(InteractionHand.OFF_HAND))) && (int) (Math.random() * 10) == 0) {
+ this.player.hurt(this.player.damageSources().scissors(), (float) this.player.level().purpurConfig.scissorsRunningDamage);
+ if (this.player.serverLevel().purpurConfig.dontRunWithScissors && this.player.isSprinting() && !(this.player.serverLevel().purpurConfig.ignoreScissorsInWater && this.player.isInWater()) && !(this.player.serverLevel().purpurConfig.ignoreScissorsInLava && this.player.isInLava()) && (isScissors(this.player.getItemInHand(InteractionHand.MAIN_HAND)) || isScissors(this.player.getItemInHand(InteractionHand.OFF_HAND))) && (int) (Math.random() * 10) == 0) {
+ this.player.hurtServer(this.player.serverLevel(), this.player.damageSources().scissors(), (float) this.player.serverLevel().purpurConfig.scissorsRunningDamage);
+ if (!org.purpurmc.purpur.PurpurConfig.dontRunWithScissors.isBlank()) this.player.sendActionBarMessage(org.purpurmc.purpur.PurpurConfig.dontRunWithScissors);
+ }
+ // Purpur End
+
this.player.checkMovementStatistics(this.player.getX() - d3, this.player.getY() - d4, this.player.getZ() - d5);
this.lastGoodX = this.player.getX();
this.lastGoodY = this.player.getY();
@@ -1760,6 +1767,14 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -1760,6 +1767,17 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
}
}

+ // Purpur start
+ public boolean isScissor(ItemStack stack) {
+ public boolean isScissors(ItemStack stack) {
+ if (!stack.is(Items.SHEARS)) return false;
+ net.minecraft.world.item.component.CustomModelData customModelData = stack.get(net.minecraft.core.component.DataComponents.CUSTOM_MODEL_DATA);
+ return customModelData == null || customModelData.strings().contains("purpurmc:scissors");
+
+ ResourceLocation itemModelReference = stack.get(net.minecraft.core.component.DataComponents.ITEM_MODEL);
+ if (itemModelReference != null && itemModelReference.equals(this.player.serverLevel().purpurConfig.dontRunWithScissorsItemModelReference)) return true;
+
+ return stack.getOrDefault(DataComponents.CUSTOM_MODEL_DATA, net.minecraft.world.item.component.CustomModelData.EMPTY).equals(net.minecraft.world.item.component.CustomModelData.EMPTY);
+ }
+ // Purpur end
+
Expand Down Expand Up @@ -149,25 +152,27 @@ index 64c84cb6cc647ca37a0664b83eb24e7202aeb1e2..28800c519ab8a6648d632a577ffbecae

public static String serverModName = io.papermc.paper.ServerBuildInfo.buildInfo().brandName();
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index 066a6407ed76a3a2b77541f24d4c3429d3a1a189..a980b4d3e1e4df4e2e2d7ecedafe23abe434fccb 100644
index 066a6407ed76a3a2b77541f24d4c3429d3a1a189..2fd0df56e94dca5ce91d0db29b56fa4bd5a2d1f2 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -191,6 +191,10 @@ public class PurpurWorldConfig {
@@ -191,6 +191,11 @@ public class PurpurWorldConfig {
public List<Item> itemImmuneToExplosion = new ArrayList<>();
public List<Item> itemImmuneToFire = new ArrayList<>();
public List<Item> itemImmuneToLightning = new ArrayList<>();
+ public boolean dontRunWithScissors = false;
+ public ResourceLocation dontRunWithScissorsItemModelReference = ResourceLocation.parse("purpurmc:scissors");
+ public boolean ignoreScissorsInWater = false;
+ public boolean ignoreScissorsInLava = false;
+ public double scissorsRunningDamage = 1D;
private void itemSettings() {
itemImmuneToCactus.clear();
getList("gameplay-mechanics.item.immune.cactus", new ArrayList<>()).forEach(key -> {
@@ -228,6 +232,10 @@ public class PurpurWorldConfig {
@@ -228,6 +233,11 @@ public class PurpurWorldConfig {
Item item = BuiltInRegistries.ITEM.getValue(ResourceLocation.parse(key.toString()));
if (item != Items.AIR) itemImmuneToLightning.add(item);
});
+ dontRunWithScissors = getBoolean("gameplay-mechanics.item.shears.damage-if-sprinting", dontRunWithScissors);
+ dontRunWithScissorsItemModelReference = ResourceLocation.parse(getString("gameplay-mechanics.item.shears.damage-if-sprinting-item-model", "purpurmc:scissors"));
+ ignoreScissorsInWater = getBoolean("gameplay-mechanics.item.shears.ignore-in-water", ignoreScissorsInWater);
+ ignoreScissorsInLava = getBoolean("gameplay-mechanics.item.shears.ignore-in-lava", ignoreScissorsInLava);
+ scissorsRunningDamage = getDouble("gameplay-mechanics.item.shears.sprinting-damage", scissorsRunningDamage);
Expand Down
6 changes: 3 additions & 3 deletions patches/server/0129-One-Punch-Man.patch
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ index fe183dcfb32e915af4c58f8b40c35e349e39d189..062f05f855ef50872d9b3074bf1951ea
if (amount < 0.0F) {
amount = 0.0F;
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index a980b4d3e1e4df4e2e2d7ecedafe23abe434fccb..6a4f411c723a1b0a5a05af66807f330a878377e1 100644
index 2fd0df56e94dca5ce91d0db29b56fa4bd5a2d1f2..e6c9b43eea433abb1a01d4bf591541b754beeebf 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -338,6 +338,7 @@ public class PurpurWorldConfig {
@@ -340,6 +340,7 @@ public class PurpurWorldConfig {
public boolean teleportIfOutsideBorder = false;
public boolean totemOfUndyingWorksInInventory = false;
public boolean playerFixStuckPortal = false;
+ public boolean creativeOnePunch = false;
private void playerSettings() {
if (PurpurConfig.version < 19) {
boolean oldVal = getBoolean("gameplay-mechanics.player.idle-timeout.mods-target", idleTimeoutTargetPlayer);
@@ -354,6 +355,7 @@ public class PurpurWorldConfig {
@@ -356,6 +357,7 @@ public class PurpurWorldConfig {
teleportIfOutsideBorder = getBoolean("gameplay-mechanics.player.teleport-if-outside-border", teleportIfOutsideBorder);
totemOfUndyingWorksInInventory = getBoolean("gameplay-mechanics.player.totem-of-undying-works-in-inventory", totemOfUndyingWorksInInventory);
playerFixStuckPortal = getBoolean("gameplay-mechanics.player.fix-stuck-in-portal", playerFixStuckPortal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ index eaee34054233c8f0296b65a09f1287ba515496f2..83bd9b1eff5b7f581c3f0af6f0f15bdf
// Paper end - PlayerLaunchProjectileEvent
if (user instanceof net.minecraft.server.level.ServerPlayer) {
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index 6a4f411c723a1b0a5a05af66807f330a878377e1..35b0f46278c2c536c1b8738aea1b900e6f7065cf 100644
index e6c9b43eea433abb1a01d4bf591541b754beeebf..e196d391b4c1a02211f221ef10dda9df05c5ab5c 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -195,6 +195,10 @@ public class PurpurWorldConfig {
@@ -196,6 +196,10 @@ public class PurpurWorldConfig {
public boolean ignoreScissorsInWater = false;
public boolean ignoreScissorsInLava = false;
public double scissorsRunningDamage = 1D;
Expand All @@ -56,7 +56,7 @@ index 6a4f411c723a1b0a5a05af66807f330a878377e1..35b0f46278c2c536c1b8738aea1b900e
private void itemSettings() {
itemImmuneToCactus.clear();
getList("gameplay-mechanics.item.immune.cactus", new ArrayList<>()).forEach(key -> {
@@ -236,6 +240,10 @@ public class PurpurWorldConfig {
@@ -238,6 +242,10 @@ public class PurpurWorldConfig {
ignoreScissorsInWater = getBoolean("gameplay-mechanics.item.shears.ignore-in-water", ignoreScissorsInWater);
ignoreScissorsInLava = getBoolean("gameplay-mechanics.item.shears.ignore-in-lava", ignoreScissorsInLava);
scissorsRunningDamage = getDouble("gameplay-mechanics.item.shears.sprinting-damage", scissorsRunningDamage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Config to ignore nearby mobs when sleeping


diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index ca88e602674e85b63b9622c0f94b588448480c12..af7d238fafa84428509563548d343005fe17d460 100644
index 2bc946e62099ab3020d38a304a6b686ccf7a39af..79f4ea221b791e605a7865de111c64a86ddd11ef 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -1789,7 +1789,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
Expand All @@ -18,18 +18,18 @@ index ca88e602674e85b63b9622c0f94b588448480c12..af7d238fafa84428509563548d343005
}
}
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index 35b0f46278c2c536c1b8738aea1b900e6f7065cf..59134101345d765c436d42efcd7fbb78b0deec48 100644
index e196d391b4c1a02211f221ef10dda9df05c5ab5c..aa089685179635e74cc4033b5335c1e79fab08a2 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -347,6 +347,7 @@ public class PurpurWorldConfig {
@@ -349,6 +349,7 @@ public class PurpurWorldConfig {
public boolean totemOfUndyingWorksInInventory = false;
public boolean playerFixStuckPortal = false;
public boolean creativeOnePunch = false;
+ public boolean playerSleepNearMonsters = false;
private void playerSettings() {
if (PurpurConfig.version < 19) {
boolean oldVal = getBoolean("gameplay-mechanics.player.idle-timeout.mods-target", idleTimeoutTargetPlayer);
@@ -364,6 +365,7 @@ public class PurpurWorldConfig {
@@ -366,6 +367,7 @@ public class PurpurWorldConfig {
totemOfUndyingWorksInInventory = getBoolean("gameplay-mechanics.player.totem-of-undying-works-in-inventory", totemOfUndyingWorksInInventory);
playerFixStuckPortal = getBoolean("gameplay-mechanics.player.fix-stuck-in-portal", playerFixStuckPortal);
creativeOnePunch = getBoolean("gameplay-mechanics.player.one-punch-in-creative", creativeOnePunch);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ index 8348c8191e6b576ac71aa5c5b5454f7ba38f7730..a5a13d9e56306f6fc53736d0c4af81fa
}

diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index 59134101345d765c436d42efcd7fbb78b0deec48..2a247ce59d429b7ddac845295c95a045e9fe3352 100644
index aa089685179635e74cc4033b5335c1e79fab08a2..fe8988fc29be469af3d33fb87f0c88ee35f0b779 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -1030,6 +1030,8 @@ public class PurpurWorldConfig {
@@ -1032,6 +1032,8 @@ public class PurpurWorldConfig {
public boolean endermanDespawnEvenWithBlock = false;
public boolean endermanBypassMobGriefing = false;
public boolean endermanTakeDamageFromWater = true;
Expand All @@ -30,7 +30,7 @@ index 59134101345d765c436d42efcd7fbb78b0deec48..2a247ce59d429b7ddac845295c95a045
private void endermanSettings() {
endermanRidable = getBoolean("mobs.enderman.ridable", endermanRidable);
endermanRidableInWater = getBoolean("mobs.enderman.ridable-in-water", endermanRidableInWater);
@@ -1039,12 +1041,18 @@ public class PurpurWorldConfig {
@@ -1041,12 +1043,18 @@ public class PurpurWorldConfig {
set("mobs.enderman.attributes.max-health", null);
set("mobs.enderman.attributes.max_health", oldValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ index a5a13d9e56306f6fc53736d0c4af81fa3d972a45..dec6be6b823b00642a0066726e3cad29
event.setCancelled(!shouldAttack);
return event.callEvent();
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index 2a247ce59d429b7ddac845295c95a045e9fe3352..9c9afd3befebe0fef8c84f4ed38231c11260d441 100644
index fe8988fc29be469af3d33fb87f0c88ee35f0b779..c1f1c20bfa038e66e3fc2dab1a2d5ccc1bbbd3f2 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -1032,6 +1032,7 @@ public class PurpurWorldConfig {
@@ -1034,6 +1034,7 @@ public class PurpurWorldConfig {
public boolean endermanTakeDamageFromWater = true;
public boolean endermanAggroEndermites = true;
public boolean endermanAggroEndermitesOnlyIfPlayerSpawned = false;
+ public boolean endermanDisableStareAggro = false;
private void endermanSettings() {
endermanRidable = getBoolean("mobs.enderman.ridable", endermanRidable);
endermanRidableInWater = getBoolean("mobs.enderman.ridable-in-water", endermanRidableInWater);
@@ -1053,6 +1054,7 @@ public class PurpurWorldConfig {
@@ -1055,6 +1056,7 @@ public class PurpurWorldConfig {
endermanTakeDamageFromWater = getBoolean("mobs.enderman.takes-damage-from-water", endermanTakeDamageFromWater);
endermanAggroEndermites = getBoolean("mobs.enderman.aggressive-towards-endermites", endermanAggroEndermites);
endermanAggroEndermitesOnlyIfPlayerSpawned = getBoolean("mobs.enderman.aggressive-towards-endermites-only-spawned-by-player-thrown-ender-pearls", endermanAggroEndermitesOnlyIfPlayerSpawned);
Expand Down
6 changes: 3 additions & 3 deletions patches/server/0136-Config-to-disable-Llama-caravans.patch
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ index 0b81415233df20fe7143c87ee964a6a1f490476f..227638f369a6581f37e892fa457e2d67
this.caravanHead.caravanTail = this;
}
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index a3ad9d2610ba27d4dbfa22cf8e3b9f8365310d40..ba7be016f1a76c95d04254cbbb6a0a51df23b0d0 100644
index dd33aa2d92296090d6d75d294e91f2272b57e6fc..c62a22c8c7821041d890123c61cb04fb43955108 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -1386,6 +1386,7 @@ public class PurpurWorldConfig {
@@ -1388,6 +1388,7 @@ public class PurpurWorldConfig {
public double llamaMovementSpeedMax = 0.175D;
public int llamaBreedingTicks = 6000;
public boolean llamaTakeDamageFromWater = false;
+ public boolean llamaJoinCaravans = true;
private void llamaSettings() {
llamaRidable = getBoolean("mobs.llama.ridable", llamaRidable);
llamaRidableInWater = getBoolean("mobs.llama.ridable-in-water", llamaRidableInWater);
@@ -1405,6 +1406,7 @@ public class PurpurWorldConfig {
@@ -1407,6 +1408,7 @@ public class PurpurWorldConfig {
llamaMovementSpeedMax = getDouble("mobs.llama.attributes.movement_speed.max", llamaMovementSpeedMax);
llamaBreedingTicks = getInt("mobs.llama.breeding-delay-ticks", llamaBreedingTicks);
llamaTakeDamageFromWater = getBoolean("mobs.llama.takes-damage-from-water", llamaTakeDamageFromWater);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ index 78da4454fb6eccb1d17d1f0cb19013883437a23e..0bce10c1cbf9f1788817a2834ec0efa0

private void spawnLingeringCloud() {
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index ba7be016f1a76c95d04254cbbb6a0a51df23b0d0..6c4bd9a18ecb9c3fea1d46f674dc6c8f3b9aea73 100644
index c62a22c8c7821041d890123c61cb04fb43955108..36262ccf9c5d308230ad112078d14a78f41243bd 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -875,6 +875,7 @@ public class PurpurWorldConfig {
@@ -877,6 +877,7 @@ public class PurpurWorldConfig {
public boolean creeperAllowGriefing = true;
public boolean creeperBypassMobGriefing = false;
public boolean creeperTakeDamageFromWater = false;
+ public boolean creeperExplodeWhenKilled = false;
private void creeperSettings() {
creeperRidable = getBoolean("mobs.creeper.ridable", creeperRidable);
creeperRidableInWater = getBoolean("mobs.creeper.ridable-in-water", creeperRidableInWater);
@@ -890,6 +891,7 @@ public class PurpurWorldConfig {
@@ -892,6 +893,7 @@ public class PurpurWorldConfig {
creeperAllowGriefing = getBoolean("mobs.creeper.allow-griefing", creeperAllowGriefing);
creeperBypassMobGriefing = getBoolean("mobs.creeper.bypass-mob-griefing", creeperBypassMobGriefing);
creeperTakeDamageFromWater = getBoolean("mobs.creeper.takes-damage-from-water", creeperTakeDamageFromWater);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ index 8cf8aeb34cba078bc7a554f03054d580d96fe908..c1707b502911d76d0c3a706e44bfdc3a
}
}
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index 6c4bd9a18ecb9c3fea1d46f674dc6c8f3b9aea73..e040507a861ad283d95f42b6ef08b8b2f5b83418 100644
index 36262ccf9c5d308230ad112078d14a78f41243bd..99a1c69938be124ad6fd1ae9a96024cc9fafd62c 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -1781,6 +1781,7 @@ public class PurpurWorldConfig {
@@ -1783,6 +1783,7 @@ public class PurpurWorldConfig {
public double ravagerScale = 1.0D;
public boolean ravagerBypassMobGriefing = false;
public boolean ravagerTakeDamageFromWater = false;
+ public List<Block> ravagerGriefableBlocks = new ArrayList<>();
private void ravagerSettings() {
ravagerRidable = getBoolean("mobs.ravager.ridable", ravagerRidable);
ravagerRidableInWater = getBoolean("mobs.ravager.ridable-in-water", ravagerRidableInWater);
@@ -1794,6 +1795,23 @@ public class PurpurWorldConfig {
@@ -1796,6 +1797,23 @@ public class PurpurWorldConfig {
ravagerScale = Mth.clamp(getDouble("mobs.ravager.attributes.scale", ravagerScale), 0.0625D, 16.0D);
ravagerBypassMobGriefing = getBoolean("mobs.ravager.bypass-mob-griefing", ravagerBypassMobGriefing);
ravagerTakeDamageFromWater = getBoolean("mobs.ravager.takes-damage-from-water", ravagerTakeDamageFromWater);
Expand Down
Loading

0 comments on commit ffeb49d

Please sign in to comment.