From 29d22e5482f1e403330311720d99b30d3ec4d448 Mon Sep 17 00:00:00 2001 From: Samsuik Date: Thu, 6 Jun 2024 20:16:10 +0100 Subject: [PATCH] more work --- build-data/dev-imports.txt | 3 +- .../0003-Sakura-Configuration-Files.patch | 7 ++-- .../0071-Legacy-player-combat-mechanics.patch | 19 +++++----- ...073-Change-shields-to-reduce-damage.patch} | 14 ++++---- .../0074-Old-enchanted-golden-apples.patch | 36 ++++++++++++++----- .../0075-Configure-fast-health-regen.patch | 19 ++++++++++ 6 files changed, 69 insertions(+), 29 deletions(-) rename patches/server/{0073-Use-old-damage-reduction-with-shields.patch => 0073-Change-shields-to-reduce-damage.patch} (64%) create mode 100644 patches/server/0075-Configure-fast-health-regen.patch diff --git a/build-data/dev-imports.txt b/build-data/dev-imports.txt index 5de6b59..1b60a4d 100644 --- a/build-data/dev-imports.txt +++ b/build-data/dev-imports.txt @@ -20,4 +20,5 @@ minecraft net.minecraft.world.entity.projectile.ProjectileUtil minecraft net.minecraft.world.level.block.CarpetBlock minecraft net.minecraft.world.item.Item minecraft net.minecraft.world.item.SwordItem -minecraft net.minecraft.world.item.DiggerItem \ No newline at end of file +minecraft net.minecraft.world.item.DiggerItem +minecraft net.minecraft.world.food.Foods \ No newline at end of file diff --git a/patches/server/0003-Sakura-Configuration-Files.patch b/patches/server/0003-Sakura-Configuration-Files.patch index 19f0baa..2bc716a 100644 --- a/patches/server/0003-Sakura-Configuration-Files.patch +++ b/patches/server/0003-Sakura-Configuration-Files.patch @@ -647,10 +647,10 @@ index 0000000000000000000000000000000000000000..dd5a70f70c2e7bdc30b8f5655b0b7a08 +} diff --git a/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java b/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java new file mode 100644 -index 0000000000000000000000000000000000000000..a656fcd86c66748bd0caeab54d5541c83bdd89a5 +index 0000000000000000000000000000000000000000..bf81412925a691c3db06f54f06960ad0a37c92bf --- /dev/null +++ b/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java -@@ -0,0 +1,212 @@ +@@ -0,0 +1,213 @@ +package me.samsuik.sakura.configuration; + +import com.mojang.logging.LogUtils; @@ -777,8 +777,9 @@ index 0000000000000000000000000000000000000000..a656fcd86c66748bd0caeab54d5541c8 + public class Combat extends ConfigurationPart { + public boolean legacyCombatMechanics = false; + public boolean allowSweepAttacks = true; -+ public boolean oldBlockingDamageReduction = false; ++ public boolean shieldDamageReduction = false; + public boolean oldEnchantedGoldenApple = false; ++ public boolean fastHealthRegen = true; + } + + public Knockback knockback = new Knockback(); diff --git a/patches/server/0071-Legacy-player-combat-mechanics.patch b/patches/server/0071-Legacy-player-combat-mechanics.patch index 45a8b44..12ced99 100644 --- a/patches/server/0071-Legacy-player-combat-mechanics.patch +++ b/patches/server/0071-Legacy-player-combat-mechanics.patch @@ -48,17 +48,16 @@ index 0000000000000000000000000000000000000000..6cda6ba8e29587fd04b727ef18848476 + } +} diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 9fa79ba7f50fa20f3794fd955db1a4cc0fa8ee02..241bd21a9500989d22df54827f90e93381c333ed 100644 +index 9fa79ba7f50fa20f3794fd955db1a4cc0fa8ee02..532fef2f50a0904a7c64bac30aa61dc71fcfc7dd 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -276,6 +276,65 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -276,6 +276,64 @@ public abstract class LivingEntity extends Entity implements Attackable { ++this.noActionTime; // Above all the floats } // Spigot end + // Sakura start - legacy combat mechanics -+ private static final UUID LEGACY_ATTACK_SPEED_UUID = UUID.fromString("84ef96f8-9f48-4ae4-a26c-e04551324816"); -+ private static final UUID LEGACY_ATTACK_DAMAGE_UUID = UUID.fromString("bcfaeeb7-f9bc-410c-9915-b5841936d41d"); -+ private static final AttributeModifier LEGACY_ATTACK_SPEED_MODIFIER = new AttributeModifier(LEGACY_ATTACK_SPEED_UUID, "Legacy attack speed", 100.0, AttributeModifier.Operation.ADDITION); ++ private static final UUID LEGACY_COMBAT_MECHANICS_UUID = UUID.fromString("84ef96f8-9f48-4ae4-a26c-e04551324816"); ++ private static final AttributeModifier LEGACY_ATTACK_SPEED_MODIFIER = new AttributeModifier(LEGACY_COMBAT_MECHANICS_UUID, "Legacy attack speed", 100.0, AttributeModifier.Operation.ADDITION); + + private void updateAttackSpeedModifier() { + AttributeInstance attackSpeed = this.getAttribute(Attributes.ATTACK_SPEED); @@ -108,7 +107,7 @@ index 9fa79ba7f50fa20f3794fd955db1a4cc0fa8ee02..241bd21a9500989d22df54827f90e933 + double attackDifference = (double) legacyAttack - baseAttack; + + if (baseAttack != 0.0f && legacyAttack != Float.MIN_VALUE) { -+ return new AttributeModifier(LEGACY_ATTACK_DAMAGE_UUID, "Legacy attack damage", attackDifference, AttributeModifier.Operation.ADDITION); ++ return new AttributeModifier(LEGACY_COMBAT_MECHANICS_UUID, "Legacy attack damage", attackDifference, AttributeModifier.Operation.ADDITION); + } + } + return null; @@ -117,12 +116,12 @@ index 9fa79ba7f50fa20f3794fd955db1a4cc0fa8ee02..241bd21a9500989d22df54827f90e933 protected LivingEntity(EntityType type, Level world) { super(type, world); -@@ -2145,7 +2204,16 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -2145,7 +2203,16 @@ public abstract class LivingEntity extends Entity implements Attackable { protected float getDamageAfterArmorAbsorb(DamageSource source, float amount) { if (!source.is(DamageTypeTags.BYPASSES_ARMOR)) { // this.hurtArmor(damagesource, f); // CraftBukkit - Moved into actuallyHurt(DamageSource, float) + // Sakura start - legacy combat mechanics -+ if (!level().sakuraConfig().players.combat.legacyCombatMechanics) { ++ if (!this.level().sakuraConfig().players.combat.legacyCombatMechanics) { amount = CombatRules.getDamageAfterAbsorb(amount, (float) this.getArmorValue(), (float) this.getAttributeValue(Attributes.ARMOR_TOUGHNESS)); + } else { + // See: applyArmorModifier(DamageSource, float) @@ -134,7 +133,7 @@ index 9fa79ba7f50fa20f3794fd955db1a4cc0fa8ee02..241bd21a9500989d22df54827f90e933 } return amount; -@@ -3201,6 +3269,12 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3201,6 +3268,12 @@ public abstract class LivingEntity extends Entity implements Attackable { if (!itemstack1.isEmpty()) { this.getAttributes().addTransientAttributeModifiers(itemstack1.getAttributeModifiers(enumitemslot)); } @@ -147,7 +146,7 @@ index 9fa79ba7f50fa20f3794fd955db1a4cc0fa8ee02..241bd21a9500989d22df54827f90e933 } } -@@ -3354,7 +3428,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3354,7 +3427,7 @@ public abstract class LivingEntity extends Entity implements Attackable { this.lastArmorItemStacks.set(slot.getIndex(), armor); } diff --git a/patches/server/0073-Use-old-damage-reduction-with-shields.patch b/patches/server/0073-Change-shields-to-reduce-damage.patch similarity index 64% rename from patches/server/0073-Use-old-damage-reduction-with-shields.patch rename to patches/server/0073-Change-shields-to-reduce-damage.patch index 9f50f18..5caa3b0 100644 --- a/patches/server/0073-Use-old-damage-reduction-with-shields.patch +++ b/patches/server/0073-Change-shields-to-reduce-damage.patch @@ -1,24 +1,24 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Samsuik Date: Fri, 23 Feb 2024 02:07:03 +0000 -Subject: [PATCH] Use old damage reduction with shields +Subject: [PATCH] Change shields to reduce damage diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 241bd21a9500989d22df54827f90e93381c333ed..8ea2e719d0396f7cf96d3d0f943ac68eda250851 100644 +index 532fef2f50a0904a7c64bac30aa61dc71fcfc7dd..0adf993b1b03b4e68d83e67872c0f592c2d7c91f 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -2280,7 +2280,13 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -2279,7 +2279,13 @@ public abstract class LivingEntity extends Entity implements Attackable { Function blocking = new Function() { @Override public Double apply(Double f) { -+ // Sakura start - old blocking damage reduction -+ if (!level().sakuraConfig().players.combat.oldBlockingDamageReduction || damagesource.getDirectEntity() instanceof AbstractArrow) { ++ // Sakura start - shield damage reduction ++ if (!level().sakuraConfig().players.combat.shieldDamageReduction || damagesource.getDirectEntity() instanceof AbstractArrow) { return -((LivingEntity.this.isDamageSourceBlocked(damagesource)) ? f : 0.0); + } else { -+ return LivingEntity.this.isBlocking() ? f * 0.5 : 0.0; ++ return -(LivingEntity.this.isBlocking() ? f * 0.5 : 0.0); + } -+ // Sakura end - old blocking damage reduction ++ // Sakura end - shield damage reduction } }; float blockingModifier = blocking.apply((double) f).floatValue(); diff --git a/patches/server/0074-Old-enchanted-golden-apples.patch b/patches/server/0074-Old-enchanted-golden-apples.patch index 81f2db0..1e5eeb0 100644 --- a/patches/server/0074-Old-enchanted-golden-apples.patch +++ b/patches/server/0074-Old-enchanted-golden-apples.patch @@ -5,21 +5,41 @@ Subject: [PATCH] Old enchanted golden apples diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 8ea2e719d0396f7cf96d3d0f943ac68eda250851..26b030fd6e5443228e4a82376ddb5642d97ea423 100644 +index 0adf993b1b03b4e68d83e67872c0f592c2d7c91f..99bc5f6665524dfb42d7e7dd3f71fb45147b3b58 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -4524,7 +4524,14 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -4523,7 +4523,13 @@ public abstract class LivingEntity extends Entity implements Attackable { Item item = stack.getItem(); if (item.isEdible()) { -+ // Sakura start - old enchanted golden apples - List> list = item.getFoodProperties().getEffects(); +- List> list = item.getFoodProperties().getEffects(); ++ // Sakura start - old enchanted golden apple ++ FoodProperties food = item.getFoodProperties(); + if (this.level().sakuraConfig().players.combat.oldEnchantedGoldenApple && item.getFoodProperties() == net.minecraft.world.food.Foods.ENCHANTED_GOLDEN_APPLE) { -+ list = new ArrayList<>(2); -+ list.add(new Pair(new MobEffectInstance(MobEffects.REGENERATION, 600, 4), 1.0F)); -+ list.add(new Pair(new MobEffectInstance(MobEffects.ABSORPTION, 2400, 1), 1.0F)); ++ food = net.minecraft.world.food.Foods.LEGACY_ENCHANTED_GOLDEN_APPLE; + } -+ // Sakura end - old enchanted golden apples ++ List> list = food.getEffects(); ++ // Sakura end - old enchanted golden apple Iterator iterator = list.iterator(); while (iterator.hasNext()) { +diff --git a/src/main/java/net/minecraft/world/food/Foods.java b/src/main/java/net/minecraft/world/food/Foods.java +index 4569cf30b33167a415256a8542820557ad38f89e..2851125fcb2c2ddade0d82b9a3d303c069a1a06f 100644 +--- a/src/main/java/net/minecraft/world/food/Foods.java ++++ b/src/main/java/net/minecraft/world/food/Foods.java +@@ -37,6 +37,15 @@ public class Foods { + .effect(new MobEffectInstance(MobEffects.ABSORPTION, 2400, 3), 1.0F) + .alwaysEat() + .build(); ++ public static final FoodProperties LEGACY_ENCHANTED_GOLDEN_APPLE = new FoodProperties.Builder() ++ .nutrition(4) ++ .saturationMod(1.2F) ++ .effect(new MobEffectInstance(MobEffects.REGENERATION, 600, 4), 1.0F) ++ .effect(new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 6000, 0), 1.0F) ++ .effect(new MobEffectInstance(MobEffects.FIRE_RESISTANCE, 6000, 0), 1.0F) ++ .effect(new MobEffectInstance(MobEffects.ABSORPTION, 2400, 0), 1.0F) ++ .alwaysEat() ++ .build(); + public static final FoodProperties GOLDEN_APPLE = new FoodProperties.Builder() + .nutrition(4) + .saturationMod(1.2F) diff --git a/patches/server/0075-Configure-fast-health-regen.patch b/patches/server/0075-Configure-fast-health-regen.patch new file mode 100644 index 0000000..fb5bb34 --- /dev/null +++ b/patches/server/0075-Configure-fast-health-regen.patch @@ -0,0 +1,19 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Samsuik +Date: Thu, 6 Jun 2024 18:18:28 +0100 +Subject: [PATCH] Configure fast health regen + + +diff --git a/src/main/java/net/minecraft/world/food/FoodData.java b/src/main/java/net/minecraft/world/food/FoodData.java +index c3448707fd8a632b457cc97b35d08a9c6933d5ee..4c7e4c463167ab17ff15236e08b84d7ef317c38d 100644 +--- a/src/main/java/net/minecraft/world/food/FoodData.java ++++ b/src/main/java/net/minecraft/world/food/FoodData.java +@@ -78,7 +78,7 @@ public class FoodData { + + boolean flag = player.level().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION); + +- if (flag && this.saturationLevel > 0.0F && player.isHurt() && this.foodLevel >= 20) { ++ if (flag && this.saturationLevel > 0.0F && player.isHurt() && this.foodLevel >= 20 && player.level().sakuraConfig().players.combat.fastHealthRegen) { // Sakura - configure fast health regen + ++this.tickTimer; + if (this.tickTimer >= this.saturatedRegenRate) { // CraftBukkit + float f = Math.min(this.saturationLevel, 6.0F);