Skip to content

Commit

Permalink
Add support for Minecraft 1.21.4
Browse files Browse the repository at this point in the history
  • Loading branch information
PseudoKnight committed Dec 5, 2024
1 parent cbc9263 commit df53022
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 11 deletions.
10 changes: 8 additions & 2 deletions src/main/java/com/laytonsmith/abstraction/MCParticleData.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ public MCColor to() {
}
}

public static class TargetColor {
public static class Trail {
MCLocation location;
MCColor color;
int duration;

public TargetColor(MCLocation location, MCColor color) {
public Trail(MCLocation location, MCColor color, int duration) {
this.location = location;
this.color = color;
this.duration = duration;
}

public MCLocation location() {
Expand All @@ -36,6 +38,10 @@ public MCLocation location() {
public MCColor color() {
return this.color;
}

public int duration() {
return this.duration;
}
}

public static class VibrationBlockDestination {
Expand Down
16 changes: 15 additions & 1 deletion src/main/java/com/laytonsmith/abstraction/blocks/MCMaterial.java
Original file line number Diff line number Diff line change
Expand Up @@ -1721,7 +1721,21 @@ public enum MCVanillaMaterial {
PALE_OAK_WOOD(MCVersion.MC1_21_3),
POTTED_PALE_OAK_SAPLING(MCVersion.MC1_21_3),
STRIPPED_PALE_OAK_LOG(MCVersion.MC1_21_3),
STRIPPED_PALE_OAK_WOOD(MCVersion.MC1_21_3);
STRIPPED_PALE_OAK_WOOD(MCVersion.MC1_21_3),

// 1.21.4 additions
CLOSED_EYEBLOSSOM(MCVersion.MC1_21_4),
OPEN_EYEBLOSSOM(MCVersion.MC1_21_4),
POTTED_CLOSED_EYEBLOSSOM(MCVersion.MC1_21_4),
POTTED_OPEN_EYEBLOSSOM(MCVersion.MC1_21_4),
RESIN_BLOCK(MCVersion.MC1_21_4),
RESIN_BRICK(MCVersion.MC1_21_4),
RESIN_BRICKS(MCVersion.MC1_21_4),
RESIN_BRICK_SLAB(MCVersion.MC1_21_4),
RESIN_BRICK_STAIRS(MCVersion.MC1_21_4),
RESIN_BRICK_WALL(MCVersion.MC1_21_4),
RESIN_CLUMP(MCVersion.MC1_21_4),
CHISELED_RESIN_BRICKS(MCVersion.MC1_21_4);

private final MCVersion since;
private final MCVersion until;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ public boolean teleport(MCLocation location, MCTeleportCause cause) {
isPaperTeleportFlag = BukkitMCEntity.isPaperTeleportFlag;
if(isPaperTeleportFlag == null) {
try {
// 1.19.3
Class.forName("io.papermc.paper.entity.TeleportFlag$EntityState");
BukkitMCEntity.isPaperTeleportFlag = isPaperTeleportFlag = true;
} catch(ClassNotFoundException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ public enum MCVanillaEntityType {
COD,
COW,
CREAKING(true, MCVersion.MC1_21_3),
CREAKING_TRANSIENT(true, MCVersion.MC1_21_3),
CREEPER,
DOLPHIN,
DRAGON_FIREBALL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ public enum MCVanillaParticle {
TRIAL_OMEN(MCVersion.MC1_20_6),
BLOCK_CRUMBLE(MCVersion.MC1_21_3),
TRAIL(MCVersion.MC1_21_3),
PALE_OAK_LEAVES(MCVersion.MC1_21_4),
UNKNOWN(MCVersion.NEVER);

private final MCVersion since;
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/laytonsmith/abstraction/enums/MCSound.java
Original file line number Diff line number Diff line change
Expand Up @@ -1739,6 +1739,23 @@ public enum MCVanillaSound {
ITEM_BUNDLE_INSERT_FAIL(MCVersion.MC1_21_3),
UI_HUD_BUBBLE_POP(MCVersion.MC1_21_3),

// 1.21.4 additions
BLOCK_EYEBLOSSOM_CLOSE(MCVersion.MC1_21_4),
BLOCK_EYEBLOSSOM_CLOSE_LONG(MCVersion.MC1_21_4),
BLOCK_EYEBLOSSOM_IDLE(MCVersion.MC1_21_4),
BLOCK_EYEBLOSSOM_OPEN(MCVersion.MC1_21_4),
BLOCK_EYEBLOSSOM_OPEN_LONG(MCVersion.MC1_21_4),
BLOCK_RESIN_BREAK(MCVersion.MC1_21_4),
BLOCK_RESIN_BRICKS_BREAK(MCVersion.MC1_21_4),
BLOCK_RESIN_BRICKS_FALL(MCVersion.MC1_21_4),
BLOCK_RESIN_BRICKS_HIT(MCVersion.MC1_21_4),
BLOCK_RESIN_BRICKS_PLACE(MCVersion.MC1_21_4),
BLOCK_RESIN_BRICKS_STEP(MCVersion.MC1_21_4),
BLOCK_RESIN_FALL(MCVersion.MC1_21_4),
BLOCK_RESIN_PLACE(MCVersion.MC1_21_4),
BLOCK_RESIN_STEP(MCVersion.MC1_21_4),
ENTITY_CREAKING_TWITCH(MCVersion.MC1_21_4),

UNKNOWN(MCVersion.NEVER);

private final MCVersion since;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public enum MCVanillaTrimMaterial {
NETHERITE,
QUARTZ,
REDSTONE,
RESIN,
UNKNOWN
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public enum MCVersion implements Version {
MC1_21,
MC1_21_1,
MC1_21_3,
MC1_21_4,
MC1_21_X,
MC1_X,
MC2_X,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
import org.bukkit.entity.Entity;
import org.bukkit.inventory.ItemStack;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.EnumMap;
import java.util.Map;
import java.util.Random;

public class BukkitMCParticle extends MCParticle<Particle> {

Expand Down Expand Up @@ -147,11 +150,28 @@ public Object getParticleData(MCLocation l, Object data) {
return 0;
}
case TRAIL:
if(data instanceof MCParticleData.TargetColor target) {
return new Particle.TargetColor((Location) target.location().getHandle(),
BukkitMCColor.GetColor(target.color()));
if(Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_21_4)) {
try {
Class clazz = Class.forName("org.bukkit.Particle$Trail");
Constructor constructor = clazz.getConstructor(Location.class, Color.class, int.class);
constructor.setAccessible(true);
if(data instanceof MCParticleData.Trail trail) {
return constructor.newInstance((Location) trail.location().getHandle(),
BukkitMCColor.GetColor(trail.color()), trail.duration());
} else {
return constructor.newInstance((Location) l.getHandle(), Color.fromRGB(252, 120, 18),
new Random().nextInt(40) + 10);
}
} catch (ClassNotFoundException | NoSuchMethodException | InstantiationException
| IllegalAccessException | InvocationTargetException ignore) {}
} else {
return new Particle.TargetColor((Location) l.getHandle(), Color.fromRGB(252, 120, 18));
// 1.21.3 only
if(data instanceof MCParticleData.Trail trail) {
return new Particle.TargetColor((Location) trail.location().getHandle(),
BukkitMCColor.GetColor(trail.color()));
} else {
return new Particle.TargetColor((Location) l.getHandle(), Color.fromRGB(252, 120, 18));
}
}
}
return null;
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/com/laytonsmith/core/ObjectGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.UUID;
import java.util.regex.MatchResult;
Expand Down Expand Up @@ -2652,9 +2653,18 @@ public Object particleData(MCParticle particleType, MCLocation l, CArray pa, Tar
color = StaticLayer.GetConvertor().GetColor(c.val(), t);
}
} else {
// Default colors are 0xFC,0x78,0x12 (orange) and 0x5F,0x5F,0x5F (gray)
// when moving towards or away from the Creaking, respectively.
color = StaticLayer.GetConvertor().GetColor(0xFC, 0x78, 0x12);
}
return new MCParticleData.TargetColor(target, color);
int duration;
if(pa.containsKey("duration")) {
duration = ArgumentValidation.getInt32(pa.get("duration", t), t);
} else {
// Default duration is a random value from 0.5 to 2.5 seconds
duration = new Random().nextInt(40) + 10;
}
return new MCParticleData.Trail(target, color, duration);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,7 @@ public String docs() {
+ " <br>VIBRATION particles take a \"destination\" location array or entity UUID."
+ " <br>SCULK_CHARGE particles take an \"angle\" in radians. (defaults to 0.0)"
+ " <br>SHRIEK particles take an integer \"delay\" in ticks before playing. (defaults to 0)"
+ " <br>TRAIL particles take a \"target\" location array and a \"color\".";
+ " <br>TRAIL particles take a \"target\" location array, a \"color\", and a \"duration\" integer in ticks.";
}

@Override
Expand Down
7 changes: 6 additions & 1 deletion src/main/resources/docs/Compatibility
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ In general, the compatibility requirements, if not listed, are the same as the p
The minimum requirements for the current builds are:

* Java 16
* Spigot or Paper 1.16.5 - 1.21.3 (when used as a plugin)
* Spigot or Paper 1.16.5 - 1.21.4 (when used as a plugin)

CommandHelper may still be backwards and forward compatible to a large degree. Many of the advanced features that
normally have hard dependencies on certain versions of external dependencies have been configured to "soft" fail.
Expand All @@ -20,6 +20,11 @@ Regardless, only the most current builds are officially supported.
|-
|
|
| Added support for Spigot 1.21.4
| Spigot 1.16.5 - 1.21.4
|-
| 3.3.5 build-500
| [https://github.com/EngineHub/CommandHelper/commit/62e47f3912789598ca41578e263b03207bccda49 62e47f3]
| Added support for Spigot 1.21.3
| Spigot 1.16.5 - 1.21.3
|-
Expand Down

0 comments on commit df53022

Please sign in to comment.