Skip to content

Commit 895240d

Browse files
committed
Port to 1.21.9-pre1
1 parent 20a3519 commit 895240d

11 files changed

Lines changed: 57 additions & 42 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'fabric-loom' version '1.10.+'
2+
id 'fabric-loom' version '1.11.+'
33
id 'maven-publish'
44
id "com.modrinth.minotaur" version "2.+"
55
id 'com.matthewprenger.cursegradle' version '1.4.0'

gradle.properties

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ org.gradle.jvmargs=-Xmx1G
33

44
# Fabric Properties
55
# check these on https://fabricmc.net/use
6-
minecraft_version=1.21.8
7-
yarn_mappings=1.21.8+build.1
8-
loader_version=0.16.14
6+
minecraft_version=1.21.9-pre1
7+
yarn_mappings=1.21.9-pre1+build.2
8+
loader_version=0.17.2
99

1010
#Fabric api
11-
fabric_version=0.130.0+1.21.8
11+
fabric_version=0.133.7+1.21.9
1212

1313
# Mod Properties
14-
mod_version = 2.7.2+1.21.8
14+
mod_version = 2.8.0-pre1+1.21.9
1515
maven_group = eu.pb4
1616
archives_base_name = placeholder-api

gradle/wrapper/gradle-wrapper.jar

181 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gradlew.bat

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/eu/pb4/placeholders/api/PlaceholderContext.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package eu.pb4.placeholders.api;
22

33
import com.mojang.authlib.GameProfile;
4+
import com.mojang.authlib.yggdrasil.ProfileResult;
45
import eu.pb4.placeholders.impl.placeholder.ViewObjectImpl;
56
import net.minecraft.entity.Entity;
67
import net.minecraft.server.MinecraftServer;
8+
import net.minecraft.server.PlayerConfigEntry;
79
import net.minecraft.server.command.CommandOutput;
810
import net.minecraft.server.command.ServerCommandSource;
911
import net.minecraft.server.network.ServerPlayerEntity;
@@ -15,6 +17,7 @@
1517
import org.jetbrains.annotations.Contract;
1618
import org.jetbrains.annotations.Nullable;
1719

20+
import java.util.Objects;
1821
import java.util.function.Supplier;
1922

2023

@@ -92,21 +95,32 @@ public static PlaceholderContext of(MinecraftServer server, ViewObject view) {
9295
return new PlaceholderContext(server, server::getCommandSource, null, null, null, null, view);
9396
}
9497

98+
public static PlaceholderContext of(PlayerConfigEntry profile, MinecraftServer server) {
99+
return of(profile, server, ViewObject.DEFAULT);
100+
}
101+
102+
public static PlaceholderContext of(PlayerConfigEntry entry, MinecraftServer server, ViewObject view) {
103+
var name = entry.name() != null ? entry.name() : entry.id().toString();
104+
ProfileResult result = server.getApiServices().sessionService().fetchProfile(entry.id(), true); // Try to Fetch Secure GameProfile for textures, if this code requires it.
105+
GameProfile profile = result != null ? result.profile() : new GameProfile(entry.id(), name);
106+
return new PlaceholderContext(server, () -> new ServerCommandSource(CommandOutput.DUMMY, Vec3d.ZERO, Vec2f.ZERO, server.getOverworld(), server.getPermissionLevel(entry), name, Text.literal(name), server, null), null, null, null, profile, view);
107+
}
108+
95109
public static PlaceholderContext of(GameProfile profile, MinecraftServer server) {
96110
return of(profile, server, ViewObject.DEFAULT);
97111
}
98112

99113
public static PlaceholderContext of(GameProfile profile, MinecraftServer server, ViewObject view) {
100-
var name = profile.getName() != null ? profile.getName() : profile.getId().toString();
101-
return new PlaceholderContext(server, () -> new ServerCommandSource(CommandOutput.DUMMY, Vec3d.ZERO, Vec2f.ZERO, server.getOverworld(), server.getPermissionLevel(profile), name, Text.literal(name), server, null), null, null, null, profile, view);
114+
var name = profile.name() != null ? profile.name() : profile.id().toString();
115+
return new PlaceholderContext(server, () -> new ServerCommandSource(CommandOutput.DUMMY, Vec3d.ZERO, Vec2f.ZERO, server.getOverworld(), server.getPermissionLevel(new PlayerConfigEntry(profile)), name, Text.literal(name), server, null), null, null, null, profile, view);
102116
}
103117

104118
public static PlaceholderContext of(ServerPlayerEntity player) {
105119
return of(player, ViewObject.DEFAULT);
106120
}
107121

108122
public static PlaceholderContext of(ServerPlayerEntity player, ViewObject view) {
109-
return new PlaceholderContext(player.getServer(), player::getCommandSource, player.getWorld(), player, player, player.getGameProfile(), view);
123+
return new PlaceholderContext(player.getCommandSource().getServer(), player::getCommandSource, player.getEntityWorld(), player, player, player.getGameProfile(), view);
110124
}
111125

112126
public static PlaceholderContext of(ServerCommandSource source) {
@@ -125,8 +139,8 @@ public static PlaceholderContext of(Entity entity, ViewObject view) {
125139
if (entity instanceof ServerPlayerEntity player) {
126140
return of(player, view);
127141
} else {
128-
var world = (ServerWorld) entity.getWorld();
129-
return new PlaceholderContext(entity.getServer(), () -> entity.getCommandSource(world), world, null, entity, null, view);
142+
var world = (ServerWorld) entity.getEntityWorld();
143+
return new PlaceholderContext(entity.getCommandSource(world).getServer(), () -> entity.getCommandSource(world), world, null, entity, null, view);
130144
}
131145
}
132146

src/main/java/eu/pb4/placeholders/api/node/parent/FontNode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import eu.pb4.placeholders.api.ParserContext;
44
import eu.pb4.placeholders.api.node.TextNode;
55
import net.minecraft.text.Style;
6+
import net.minecraft.text.StyleSpriteSource;
67
import net.minecraft.util.Identifier;
78

89
import java.util.Arrays;
@@ -17,7 +18,7 @@ public FontNode(TextNode[] children, Identifier font) {
1718

1819
@Override
1920
protected Style style(ParserContext context) {
20-
return Style.EMPTY.withFont(font);
21+
return Style.EMPTY.withFont(new StyleSpriteSource.Font(this.font));
2122
}
2223

2324
@Override

src/main/java/eu/pb4/placeholders/impl/placeholder/builtin/PlayerPlaceholders.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static void register() {
3131
if (ctx.hasEntity()) {
3232
return PlaceholderResult.value(ctx.entity().getName());
3333
} else if (ctx.hasGameProfile()) {
34-
return PlaceholderResult.value(Text.of(ctx.gameProfile().getName()));
34+
return PlaceholderResult.value(Text.of(ctx.gameProfile().name()));
3535
} else {
3636
return PlaceholderResult.invalid("No player!");
3737
}
@@ -41,7 +41,7 @@ public static void register() {
4141
if (ctx.hasEntity()) {
4242
return PlaceholderResult.value(GeneralUtils.removeHoverAndClick(ctx.entity().getName()));
4343
} else if (ctx.hasGameProfile()) {
44-
return PlaceholderResult.value(Text.of(ctx.gameProfile().getName()));
44+
return PlaceholderResult.value(Text.of(ctx.gameProfile().name()));
4545
} else {
4646
return PlaceholderResult.invalid("No player!");
4747
}
@@ -51,7 +51,7 @@ public static void register() {
5151
if (ctx.hasEntity()) {
5252
return PlaceholderResult.value(ctx.entity().getName().getString());
5353
} else if (ctx.hasGameProfile()) {
54-
return PlaceholderResult.value(Text.of(ctx.gameProfile().getName()));
54+
return PlaceholderResult.value(Text.of(ctx.gameProfile().name()));
5555
} else {
5656
return PlaceholderResult.invalid("No player!");
5757
}
@@ -78,7 +78,7 @@ public static void register() {
7878
if (ctx.hasEntity()) {
7979
return PlaceholderResult.value(ctx.entity().getDisplayName());
8080
} else if (ctx.hasGameProfile()) {
81-
return PlaceholderResult.value(Text.of(ctx.gameProfile().getName()));
81+
return PlaceholderResult.value(Text.of(ctx.gameProfile().name()));
8282
} else {
8383
return PlaceholderResult.invalid("No player!");
8484
}
@@ -90,7 +90,7 @@ public static void register() {
9090
if (ctx.hasEntity()) {
9191
return PlaceholderResult.value(GeneralUtils.removeHoverAndClick(ctx.entity().getDisplayName()));
9292
} else if (ctx.hasGameProfile()) {
93-
return PlaceholderResult.value(Text.of(ctx.gameProfile().getName()));
93+
return PlaceholderResult.value(Text.of(ctx.gameProfile().name()));
9494
} else {
9595
return PlaceholderResult.invalid("No player!");
9696
}
@@ -102,7 +102,7 @@ public static void register() {
102102
if (ctx.hasEntity()) {
103103
return PlaceholderResult.value(Text.literal(ctx.entity().getDisplayName().getString()));
104104
} else if (ctx.hasGameProfile()) {
105-
return PlaceholderResult.value(Text.of(ctx.gameProfile().getName()));
105+
return PlaceholderResult.value(Text.of(ctx.gameProfile().name()));
106106
} else {
107107
return PlaceholderResult.invalid("No player!");
108108
}
@@ -401,7 +401,7 @@ public static void register() {
401401
otherWorld = ctx.server().getOverworld();
402402
}
403403

404-
double value = ctx.entity().getX() * DimensionType.getCoordinateScaleFactor(ctx.entity().getWorld().getDimension(), otherWorld.getDimension()); String format = "%.2f";
404+
double value = ctx.entity().getX() * DimensionType.getCoordinateScaleFactor(ctx.entity().getEntityWorld().getDimension(), otherWorld.getDimension()); String format = "%.2f";
405405

406406
if (arg != null) {
407407
try {
@@ -433,7 +433,7 @@ public static void register() {
433433
otherWorld = ctx.server().getOverworld();
434434
}
435435

436-
double value = ctx.entity().getY() * DimensionType.getCoordinateScaleFactor(ctx.entity().getWorld().getDimension(), otherWorld.getDimension()); String format = "%.2f";
436+
double value = ctx.entity().getY() * DimensionType.getCoordinateScaleFactor(ctx.entity().getEntityWorld().getDimension(), otherWorld.getDimension()); String format = "%.2f";
437437

438438
if (arg != null) {
439439
try {
@@ -465,7 +465,7 @@ public static void register() {
465465
otherWorld = ctx.server().getOverworld();
466466
}
467467

468-
double value = ctx.entity().getZ() * DimensionType.getCoordinateScaleFactor(ctx.entity().getWorld().getDimension(), otherWorld.getDimension());
468+
double value = ctx.entity().getZ() * DimensionType.getCoordinateScaleFactor(ctx.entity().getEntityWorld().getDimension(), otherWorld.getDimension());
469469
String format = "%.2f";
470470

471471
if (arg != null) {
@@ -487,7 +487,7 @@ public static void register() {
487487
if (ctx.hasPlayer()) {
488488
return PlaceholderResult.value(ctx.player().getUuidAsString());
489489
} else if (ctx.hasGameProfile()) {
490-
return PlaceholderResult.value(Text.of("" + ctx.gameProfile().getId()));
490+
return PlaceholderResult.value(Text.of("" + ctx.gameProfile().id()));
491491
} else {
492492
return PlaceholderResult.invalid("No player!");
493493
}
@@ -553,7 +553,7 @@ public static void register() {
553553
});
554554

555555
Placeholders.register(Identifier.of("player", "biome"), (ctx, arg) -> {
556-
var world = ctx.entity() != null ? ctx.entity().getWorld() : ctx.source().getWorld();
556+
var world = ctx.entity() != null ? ctx.entity().getEntityWorld() : ctx.source().getWorld();
557557
var pos = ctx.entity() != null ? ctx.entity().getBlockPos() : BlockPos.ofFloored(ctx.source().getPosition());
558558

559559

@@ -566,7 +566,7 @@ public static void register() {
566566
});
567567

568568
Placeholders.register(Identifier.of("player", "biome_raw"), (ctx, arg) -> {
569-
var world = ctx.entity() != null ? ctx.entity().getWorld() : ctx.source().getWorld();
569+
var world = ctx.entity() != null ? ctx.entity().getEntityWorld() : ctx.source().getWorld();
570570
var pos = ctx.entity() != null ? ctx.entity().getBlockPos() : BlockPos.ofFloored(ctx.source().getPosition());
571571

572572

src/main/java/eu/pb4/placeholders/impl/placeholder/builtin/WorldPlaceholders.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static void register() {
2121
Placeholders.register(Identifier.of("world", "time"), (ctx, arg) -> {
2222
ServerWorld world;
2323
if (ctx.player() != null) {
24-
world = ctx.player().getWorld();
24+
world = ctx.player().getEntityWorld();
2525
} else {
2626
world = ctx.server().getOverworld();
2727
}
@@ -34,7 +34,7 @@ public static void register() {
3434
Placeholders.register(Identifier.of("world", "time_alt"), (ctx, arg) -> {
3535
ServerWorld world;
3636
if (ctx.player() != null) {
37-
world = ctx.player().getWorld();
37+
world = ctx.player().getEntityWorld();
3838
} else {
3939
world = ctx.server().getOverworld();
4040
}
@@ -51,7 +51,7 @@ public static void register() {
5151
Placeholders.register(Identifier.of("world", "day"), (ctx, arg) -> {
5252
ServerWorld world;
5353
if (ctx.player() != null) {
54-
world = ctx.player().getWorld();
54+
world = ctx.player().getEntityWorld();
5555
} else {
5656
world = ctx.server().getOverworld();
5757
}
@@ -62,7 +62,7 @@ public static void register() {
6262
Placeholders.register(Identifier.of("world", "id"), (ctx, arg) -> {
6363
ServerWorld world;
6464
if (ctx.player() != null) {
65-
world = ctx.player().getWorld();
65+
world = ctx.player().getEntityWorld();
6666
} else {
6767
world = ctx.server().getOverworld();
6868
}
@@ -73,7 +73,7 @@ public static void register() {
7373
Placeholders.register(Identifier.of("world", "name"), (ctx, arg) -> {
7474
ServerWorld world;
7575
if (ctx.player() != null) {
76-
world = ctx.player().getWorld();
76+
world = ctx.player().getEntityWorld();
7777
} else {
7878
world = ctx.server().getOverworld();
7979
}
@@ -94,7 +94,7 @@ public static void register() {
9494
Placeholders.register(Identifier.of("world", "player_count"), (ctx, arg) -> {
9595
ServerWorld world;
9696
if (ctx.player() != null) {
97-
world = ctx.player().getWorld();
97+
world = ctx.player().getEntityWorld();
9898
} else {
9999
world = ctx.server().getOverworld();
100100
}
@@ -105,7 +105,7 @@ public static void register() {
105105
Placeholders.register(Identifier.of("world", "mob_count_colored"), (ctx, arg) -> {
106106
ServerWorld world;
107107
if (ctx.player() != null) {
108-
world = ctx.player().getWorld();
108+
world = ctx.player().getEntityWorld();
109109
} else {
110110
world = ctx.server().getOverworld();
111111
}
@@ -142,7 +142,7 @@ public static void register() {
142142
Placeholders.register(Identifier.of("world", "mob_count"), (ctx, arg) -> {
143143
ServerWorld world;
144144
if (ctx.player() != null) {
145-
world = ctx.player().getWorld();
145+
world = ctx.player().getEntityWorld();
146146
} else {
147147
world = ctx.server().getOverworld();
148148
}
@@ -169,7 +169,7 @@ public static void register() {
169169
Placeholders.register(Identifier.of("world", "mob_cap"), (ctx, arg) -> {
170170
ServerWorld world;
171171
if (ctx.player() != null) {
172-
world = ctx.player().getWorld();
172+
world = ctx.player().getEntityWorld();
173173
} else {
174174
world = ctx.server().getOverworld();
175175
}
@@ -196,7 +196,7 @@ public static void register() {
196196
Placeholders.register(Identifier.of("world", "weather"), (ctx, arg) -> {
197197
World world;
198198
if (ctx.entity() != null) {
199-
world = ctx.entity().getWorld();
199+
world = ctx.entity().getEntityWorld();
200200
} else {
201201
world = ctx.source().getWorld();
202202
}

0 commit comments

Comments
 (0)