Skip to content

Commit df53022

Browse files
committed
Add support for Minecraft 1.21.4
1 parent cbc9263 commit df53022

File tree

12 files changed

+86
-11
lines changed

12 files changed

+86
-11
lines changed

src/main/java/com/laytonsmith/abstraction/MCParticleData.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ public MCColor to() {
2020
}
2121
}
2222

23-
public static class TargetColor {
23+
public static class Trail {
2424
MCLocation location;
2525
MCColor color;
26+
int duration;
2627

27-
public TargetColor(MCLocation location, MCColor color) {
28+
public Trail(MCLocation location, MCColor color, int duration) {
2829
this.location = location;
2930
this.color = color;
31+
this.duration = duration;
3032
}
3133

3234
public MCLocation location() {
@@ -36,6 +38,10 @@ public MCLocation location() {
3638
public MCColor color() {
3739
return this.color;
3840
}
41+
42+
public int duration() {
43+
return this.duration;
44+
}
3945
}
4046

4147
public static class VibrationBlockDestination {

src/main/java/com/laytonsmith/abstraction/blocks/MCMaterial.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1721,7 +1721,21 @@ public enum MCVanillaMaterial {
17211721
PALE_OAK_WOOD(MCVersion.MC1_21_3),
17221722
POTTED_PALE_OAK_SAPLING(MCVersion.MC1_21_3),
17231723
STRIPPED_PALE_OAK_LOG(MCVersion.MC1_21_3),
1724-
STRIPPED_PALE_OAK_WOOD(MCVersion.MC1_21_3);
1724+
STRIPPED_PALE_OAK_WOOD(MCVersion.MC1_21_3),
1725+
1726+
// 1.21.4 additions
1727+
CLOSED_EYEBLOSSOM(MCVersion.MC1_21_4),
1728+
OPEN_EYEBLOSSOM(MCVersion.MC1_21_4),
1729+
POTTED_CLOSED_EYEBLOSSOM(MCVersion.MC1_21_4),
1730+
POTTED_OPEN_EYEBLOSSOM(MCVersion.MC1_21_4),
1731+
RESIN_BLOCK(MCVersion.MC1_21_4),
1732+
RESIN_BRICK(MCVersion.MC1_21_4),
1733+
RESIN_BRICKS(MCVersion.MC1_21_4),
1734+
RESIN_BRICK_SLAB(MCVersion.MC1_21_4),
1735+
RESIN_BRICK_STAIRS(MCVersion.MC1_21_4),
1736+
RESIN_BRICK_WALL(MCVersion.MC1_21_4),
1737+
RESIN_CLUMP(MCVersion.MC1_21_4),
1738+
CHISELED_RESIN_BRICKS(MCVersion.MC1_21_4);
17251739

17261740
private final MCVersion since;
17271741
private final MCVersion until;

src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCEntity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ public boolean teleport(MCLocation location, MCTeleportCause cause) {
244244
isPaperTeleportFlag = BukkitMCEntity.isPaperTeleportFlag;
245245
if(isPaperTeleportFlag == null) {
246246
try {
247+
// 1.19.3
247248
Class.forName("io.papermc.paper.entity.TeleportFlag$EntityState");
248249
BukkitMCEntity.isPaperTeleportFlag = isPaperTeleportFlag = true;
249250
} catch(ClassNotFoundException ex) {

src/main/java/com/laytonsmith/abstraction/enums/MCEntityType.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ public enum MCVanillaEntityType {
177177
COD,
178178
COW,
179179
CREAKING(true, MCVersion.MC1_21_3),
180-
CREAKING_TRANSIENT(true, MCVersion.MC1_21_3),
181180
CREEPER,
182181
DOLPHIN,
183182
DRAGON_FIREBALL,

src/main/java/com/laytonsmith/abstraction/enums/MCParticle.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ public enum MCVanillaParticle {
222222
TRIAL_OMEN(MCVersion.MC1_20_6),
223223
BLOCK_CRUMBLE(MCVersion.MC1_21_3),
224224
TRAIL(MCVersion.MC1_21_3),
225+
PALE_OAK_LEAVES(MCVersion.MC1_21_4),
225226
UNKNOWN(MCVersion.NEVER);
226227

227228
private final MCVersion since;

src/main/java/com/laytonsmith/abstraction/enums/MCSound.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,6 +1739,23 @@ public enum MCVanillaSound {
17391739
ITEM_BUNDLE_INSERT_FAIL(MCVersion.MC1_21_3),
17401740
UI_HUD_BUBBLE_POP(MCVersion.MC1_21_3),
17411741

1742+
// 1.21.4 additions
1743+
BLOCK_EYEBLOSSOM_CLOSE(MCVersion.MC1_21_4),
1744+
BLOCK_EYEBLOSSOM_CLOSE_LONG(MCVersion.MC1_21_4),
1745+
BLOCK_EYEBLOSSOM_IDLE(MCVersion.MC1_21_4),
1746+
BLOCK_EYEBLOSSOM_OPEN(MCVersion.MC1_21_4),
1747+
BLOCK_EYEBLOSSOM_OPEN_LONG(MCVersion.MC1_21_4),
1748+
BLOCK_RESIN_BREAK(MCVersion.MC1_21_4),
1749+
BLOCK_RESIN_BRICKS_BREAK(MCVersion.MC1_21_4),
1750+
BLOCK_RESIN_BRICKS_FALL(MCVersion.MC1_21_4),
1751+
BLOCK_RESIN_BRICKS_HIT(MCVersion.MC1_21_4),
1752+
BLOCK_RESIN_BRICKS_PLACE(MCVersion.MC1_21_4),
1753+
BLOCK_RESIN_BRICKS_STEP(MCVersion.MC1_21_4),
1754+
BLOCK_RESIN_FALL(MCVersion.MC1_21_4),
1755+
BLOCK_RESIN_PLACE(MCVersion.MC1_21_4),
1756+
BLOCK_RESIN_STEP(MCVersion.MC1_21_4),
1757+
ENTITY_CREAKING_TWITCH(MCVersion.MC1_21_4),
1758+
17421759
UNKNOWN(MCVersion.NEVER);
17431760

17441761
private final MCVersion since;

src/main/java/com/laytonsmith/abstraction/enums/MCTrimMaterial.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public enum MCVanillaTrimMaterial {
7171
NETHERITE,
7272
QUARTZ,
7373
REDSTONE,
74+
RESIN,
7475
UNKNOWN
7576
}
7677
}

src/main/java/com/laytonsmith/abstraction/enums/MCVersion.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public enum MCVersion implements Version {
7474
MC1_21,
7575
MC1_21_1,
7676
MC1_21_3,
77+
MC1_21_4,
7778
MC1_21_X,
7879
MC1_X,
7980
MC2_X,

src/main/java/com/laytonsmith/abstraction/enums/bukkit/BukkitMCParticle.java

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@
2020
import org.bukkit.entity.Entity;
2121
import org.bukkit.inventory.ItemStack;
2222

23+
import java.lang.reflect.Constructor;
24+
import java.lang.reflect.InvocationTargetException;
2325
import java.util.EnumMap;
2426
import java.util.Map;
27+
import java.util.Random;
2528

2629
public class BukkitMCParticle extends MCParticle<Particle> {
2730

@@ -147,11 +150,28 @@ public Object getParticleData(MCLocation l, Object data) {
147150
return 0;
148151
}
149152
case TRAIL:
150-
if(data instanceof MCParticleData.TargetColor target) {
151-
return new Particle.TargetColor((Location) target.location().getHandle(),
152-
BukkitMCColor.GetColor(target.color()));
153+
if(Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_21_4)) {
154+
try {
155+
Class clazz = Class.forName("org.bukkit.Particle$Trail");
156+
Constructor constructor = clazz.getConstructor(Location.class, Color.class, int.class);
157+
constructor.setAccessible(true);
158+
if(data instanceof MCParticleData.Trail trail) {
159+
return constructor.newInstance((Location) trail.location().getHandle(),
160+
BukkitMCColor.GetColor(trail.color()), trail.duration());
161+
} else {
162+
return constructor.newInstance((Location) l.getHandle(), Color.fromRGB(252, 120, 18),
163+
new Random().nextInt(40) + 10);
164+
}
165+
} catch (ClassNotFoundException | NoSuchMethodException | InstantiationException
166+
| IllegalAccessException | InvocationTargetException ignore) {}
153167
} else {
154-
return new Particle.TargetColor((Location) l.getHandle(), Color.fromRGB(252, 120, 18));
168+
// 1.21.3 only
169+
if(data instanceof MCParticleData.Trail trail) {
170+
return new Particle.TargetColor((Location) trail.location().getHandle(),
171+
BukkitMCColor.GetColor(trail.color()));
172+
} else {
173+
return new Particle.TargetColor((Location) l.getHandle(), Color.fromRGB(252, 120, 18));
174+
}
155175
}
156176
}
157177
return null;

src/main/java/com/laytonsmith/core/ObjectGenerator.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
import java.util.HashMap;
107107
import java.util.List;
108108
import java.util.Map;
109+
import java.util.Random;
109110
import java.util.Set;
110111
import java.util.UUID;
111112
import java.util.regex.MatchResult;
@@ -2652,9 +2653,18 @@ public Object particleData(MCParticle particleType, MCLocation l, CArray pa, Tar
26522653
color = StaticLayer.GetConvertor().GetColor(c.val(), t);
26532654
}
26542655
} else {
2656+
// Default colors are 0xFC,0x78,0x12 (orange) and 0x5F,0x5F,0x5F (gray)
2657+
// when moving towards or away from the Creaking, respectively.
26552658
color = StaticLayer.GetConvertor().GetColor(0xFC, 0x78, 0x12);
26562659
}
2657-
return new MCParticleData.TargetColor(target, color);
2660+
int duration;
2661+
if(pa.containsKey("duration")) {
2662+
duration = ArgumentValidation.getInt32(pa.get("duration", t), t);
2663+
} else {
2664+
// Default duration is a random value from 0.5 to 2.5 seconds
2665+
duration = new Random().nextInt(40) + 10;
2666+
}
2667+
return new MCParticleData.Trail(target, color, duration);
26582668
}
26592669
return null;
26602670
}

0 commit comments

Comments
 (0)