Skip to content

Commit 47ecdbb

Browse files
Merge pull request #944 from TonytheMacaroni/main
Support 1.21.3
2 parents 9d6b9dc + 0092459 commit 47ecdbb

File tree

11 files changed

+328
-25
lines changed

11 files changed

+328
-25
lines changed

core/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dependencies {
1010

1111
shadow(project(path: ":nms:shared", configuration: "apiElements"))
1212
shadow(project(path: ":nms:latest")) { transitive = false }
13+
shadow(project(path: ":nms:v1_21")) { transitive = false }
1314

1415
implementation(group: "com.comphenix.protocol", name: "ProtocolLib", version: "5.1.0") { transitive = false }
1516
implementation(group: "com.github.libraryaddict", name: "LibsDisguises", version: "v10.0.25") { transitive = false }

core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/BiomeCondition.java

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,43 @@
11
package com.nisovin.magicspells.castmodifiers.conditions;
22

3-
import java.util.EnumSet;
3+
import org.jetbrains.annotations.NotNull;
4+
5+
import java.util.Set;
6+
import java.util.HashSet;
47

58
import org.bukkit.Location;
9+
import org.bukkit.Registry;
610
import org.bukkit.block.Biome;
11+
import org.bukkit.NamespacedKey;
712
import org.bukkit.entity.LivingEntity;
813

9-
import org.jetbrains.annotations.NotNull;
14+
import io.papermc.paper.registry.RegistryKey;
15+
import io.papermc.paper.registry.RegistryAccess;
1016

1117
import com.nisovin.magicspells.util.Name;
12-
import com.nisovin.magicspells.util.Util;
13-
import com.nisovin.magicspells.handlers.DebugHandler;
1418
import com.nisovin.magicspells.castmodifiers.Condition;
1519

1620
@Name("biome")
1721
public class BiomeCondition extends Condition {
18-
19-
private final EnumSet<Biome> biomes = EnumSet.noneOf(Biome.class);
22+
23+
private final Set<Biome> biomes = new HashSet<>();
2024

2125
@Override
2226
public boolean initialize(@NotNull String var) {
23-
String[] s = var.split(",");
24-
25-
for (String value : s) {
26-
Biome biome = Util.enumValueSafe(Biome.class, value.toUpperCase());
27-
if (biome == null) {
28-
DebugHandler.debugBadEnumValue(Biome.class, value.toUpperCase());
29-
continue;
30-
}
27+
if (var.isEmpty()) return false;
28+
29+
Registry<Biome> registry = RegistryAccess.registryAccess().getRegistry(RegistryKey.BIOME);
30+
31+
for (String value : var.split(",")) {
32+
NamespacedKey key = NamespacedKey.fromString(value);
33+
if (key == null) return false;
34+
35+
Biome biome = registry.get(key);
36+
if (biome == null) return false;
37+
3138
biomes.add(biome);
3239
}
40+
3341
return true;
3442
}
3543

core/src/main/java/com/nisovin/magicspells/util/AttributeUtil.java

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,59 @@ public class AttributeUtil {
3434
operationNameMap.put("add_multiplied_base", Operation.ADD_SCALAR);
3535
operationNameMap.put("add_multiplied_total", Operation.MULTIPLY_SCALAR_1);
3636

37-
for (Attribute attribute : Attribute.values()) {
37+
for (Attribute attribute : Registry.ATTRIBUTE) {
3838
String key = attribute.getKey().getKey();
3939
String rep = key.replaceAll("_", "");
4040

41-
attributeNameMap.put(attribute.name().toLowerCase(), attribute);
41+
attributeNameMap.put(rep, attribute);
42+
}
43+
44+
loadLegacyAttributeNames();
45+
}
46+
47+
private static void loadLegacyAttributeNames() {
48+
Map<String, Attribute> legacy = new HashMap<>();
49+
legacy.put("generic.max_health", Attribute.GENERIC_MAX_HEALTH);
50+
legacy.put("generic.follow_range", Attribute.GENERIC_FOLLOW_RANGE);
51+
legacy.put("generic.knockback_resistance", Attribute.GENERIC_KNOCKBACK_RESISTANCE);
52+
legacy.put("generic.movement_speed", Attribute.GENERIC_MOVEMENT_SPEED);
53+
legacy.put("generic.flying_speed", Attribute.GENERIC_FLYING_SPEED);
54+
legacy.put("generic.attack_damage", Attribute.GENERIC_ATTACK_DAMAGE);
55+
legacy.put("generic.attack_knockback", Attribute.GENERIC_ATTACK_KNOCKBACK);
56+
legacy.put("generic.attack_speed", Attribute.GENERIC_ATTACK_SPEED);
57+
legacy.put("generic.armor", Attribute.GENERIC_ARMOR);
58+
legacy.put("generic.armor_toughness", Attribute.GENERIC_ARMOR_TOUGHNESS);
59+
legacy.put("generic.fall_damage_multiplier", Attribute.GENERIC_FALL_DAMAGE_MULTIPLIER);
60+
legacy.put("generic.luck", Attribute.GENERIC_LUCK);
61+
legacy.put("generic.max_absorption", Attribute.GENERIC_MAX_ABSORPTION);
62+
legacy.put("generic.safe_fall_distance", Attribute.GENERIC_SAFE_FALL_DISTANCE);
63+
legacy.put("generic.scale", Attribute.GENERIC_SCALE);
64+
legacy.put("generic.step_height", Attribute.GENERIC_STEP_HEIGHT);
65+
legacy.put("generic.gravity", Attribute.GENERIC_GRAVITY);
66+
legacy.put("generic.jump_strength", Attribute.GENERIC_JUMP_STRENGTH);
67+
legacy.put("generic.burning_time", Attribute.GENERIC_BURNING_TIME);
68+
legacy.put("generic.explosion_knockback_resistance", Attribute.GENERIC_EXPLOSION_KNOCKBACK_RESISTANCE);
69+
legacy.put("generic.movement_efficiency", Attribute.GENERIC_MOVEMENT_EFFICIENCY);
70+
legacy.put("generic.oxygen_bonus", Attribute.GENERIC_OXYGEN_BONUS);
71+
legacy.put("generic.water_movement_efficiency", Attribute.GENERIC_WATER_MOVEMENT_EFFICIENCY);
72+
legacy.put("player.block_interaction_range", Attribute.PLAYER_BLOCK_INTERACTION_RANGE);
73+
legacy.put("player.entity_interaction_range", Attribute.PLAYER_ENTITY_INTERACTION_RANGE);
74+
legacy.put("player.block_break_speed", Attribute.PLAYER_BLOCK_BREAK_SPEED);
75+
legacy.put("player.mining_efficiency", Attribute.PLAYER_MINING_EFFICIENCY);
76+
legacy.put("player.sneaking_speed", Attribute.PLAYER_SNEAKING_SPEED);
77+
legacy.put("player.submerged_mining_speed", Attribute.PLAYER_SUBMERGED_MINING_SPEED);
78+
legacy.put("player.sweeping_damage_ratio", Attribute.PLAYER_SWEEPING_DAMAGE_RATIO);
79+
legacy.put("zombie.spawn_reinforcements", Attribute.ZOMBIE_SPAWN_REINFORCEMENTS);
80+
81+
attributeNameMap.putAll(legacy);
82+
83+
for (Map.Entry<String, Attribute> entry : legacy.entrySet()) {
84+
Attribute attribute = entry.getValue();
85+
86+
String key = entry.getKey();
87+
String rep = key.replaceAll("_", "");
88+
89+
attributeNameMap.put(key.replace('.', '_'), attribute);
4290

4391
attributeNameMap.put(key, attribute);
4492
attributeNameMap.put(key.substring(key.indexOf('.') + 1), attribute);

core/src/main/java/com/nisovin/magicspells/util/managers/VariableManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.nio.charset.StandardCharsets;
88

99
import org.bukkit.Bukkit;
10+
import org.bukkit.Registry;
1011
import org.bukkit.entity.Player;
1112
import org.bukkit.boss.BarColor;
1213
import org.bukkit.boss.BarStyle;
@@ -165,7 +166,7 @@ private void initialize() {
165166
addMetaVariableType("unsaturated_regen_rate", new UnsaturatedRegenRateVariable());
166167

167168
// meta variable attribute types
168-
for (Attribute attribute : Attribute.values()) {
169+
for (Attribute attribute : Registry.ATTRIBUTE) {
169170
String name = attribute.name().toLowerCase();
170171
addMetaVariableType("attribute_" + name, new AttributeVariable(attribute));
171172
addMetaVariableType("attribute_" + name + "_base", new AttributeBaseValueVariable(attribute));

core/src/main/java/com/nisovin/magicspells/volatilecode/ManagerVolatile.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
package com.nisovin.magicspells.volatilecode;
22

3+
import java.util.Map;
4+
35
import org.bukkit.Bukkit;
46

57
import com.nisovin.magicspells.MagicSpells;
68
import com.nisovin.magicspells.volatilecode.latest.VolatileCodeLatest;
79

810
public class ManagerVolatile {
911

12+
private static final Map<String, String> COMPATIBLE_VERSIONS = Map.of(
13+
"1.21.1", "1.21"
14+
);
15+
1016
private static final VolatileCodeHelper helper = new VolatileCodeHelper() {
1117

1218
@Override
@@ -25,7 +31,8 @@ public static VolatileCodeHandle constructVolatileCodeHandler() {
2531
VolatileCodeHandle handle;
2632
try {
2733
String mcVersion = Bukkit.getMinecraftVersion();
28-
String version = "v" + mcVersion.replace(".", "_");
34+
String convertedVersion = COMPATIBLE_VERSIONS.getOrDefault(mcVersion, mcVersion);
35+
String version = "v" + convertedVersion.replace(".", "_");
2936
Class<?> volatileCode = Class.forName("com.nisovin.magicspells.volatilecode." + version + ".VolatileCode_" + version);
3037

3138
handle = (VolatileCodeHandle) volatileCode.getConstructor(VolatileCodeHelper.class).newInstance(helper);

core/src/main/resources/spells-regular.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ earth-nova:
505505

506506
flamewalk:
507507
spell-class: ".buff.FlamewalkSpell"
508-
spell-icon: fire
508+
spell-icon: flint_and_steel
509509
description: Burn your enemies around you as you walk.
510510
cast-item: book
511511
cooldown: 30
@@ -657,7 +657,7 @@ gate:
657657

658658
geyser:
659659
spell-class: ".targeted.GeyserSpell"
660-
spell-icon: water
660+
spell-icon: water_bucket
661661
description: Create a geyser of water at your enemy's feet.
662662
cast-item: blaze_rod
663663
range: 20

nms/latest/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
plugins {
2-
id "io.papermc.paperweight.userdev" version "1.7.3"
2+
id "io.papermc.paperweight.userdev" version "1.7.4"
33
}
44

55
dependencies {
6-
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.21-R0.1-SNAPSHOT")
6+
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.21.3-R0.1-SNAPSHOT")
77
implementation project(":nms:shared")
88
}

nms/latest/src/main/java/com/nisovin/magicspells/volatilecode/latest/VolatileCodeLatest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
import com.nisovin.magicspells.volatilecode.VolatileCodeHandle;
3030
import com.nisovin.magicspells.volatilecode.VolatileCodeHelper;
3131

32+
import net.minecraft.util.ARGB;
3233
import net.minecraft.core.BlockPos;
3334
import net.minecraft.advancements.*;
34-
import net.minecraft.util.FastColor;
3535
import net.minecraft.world.phys.Vec3;
3636
import net.minecraft.world.entity.EntityType;
3737
import net.minecraft.network.protocol.game.*;
@@ -83,7 +83,7 @@ public void addPotionGraphicalEffect(LivingEntity entity, int color, long durati
8383

8484
entityData.set(
8585
DATA_EFFECT_PARTICLES,
86-
List.of(ColorParticleOption.create(ParticleTypes.ENTITY_EFFECT, FastColor.ARGB32.color(255, color)))
86+
List.of(ColorParticleOption.create(ParticleTypes.ENTITY_EFFECT, ARGB.opaque(color)))
8787
);
8888

8989
entityData.set(DATA_EFFECT_AMBIENCE_ID, false);
@@ -209,7 +209,7 @@ public void sendToastEffect(Player receiver, ItemStack icon, AdvancementDisplay.
209209
public void sendStatusUpdate(Player player, double health, int food, float saturation) {
210210
double displayedHealth = (float) health;
211211
if (player.isHealthScaled()) {
212-
displayedHealth = player.getHealth() / player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() * player.getHealthScale();
212+
displayedHealth = player.getHealth() / player.getAttribute(Attribute.MAX_HEALTH).getValue() * player.getHealthScale();
213213
}
214214

215215
((CraftPlayer) player).getHandle().connection.send(new ClientboundSetHealthPacket((float) displayedHealth, food, saturation));

nms/v1_21/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
plugins {
2+
id "io.papermc.paperweight.userdev" version "1.7.4"
3+
}
4+
5+
dependencies {
6+
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.21-R0.1-SNAPSHOT")
7+
implementation project(":nms:shared")
8+
}

0 commit comments

Comments
 (0)