Skip to content

Commit 3bd5723

Browse files
committed
Update to 1.21.5-rc1
`/cglow block` kinda works but is a little broken. Need to investigate whether being underwater is still a banned action for player RNG.
1 parent 206301d commit 3bd5723

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+389
-281
lines changed

gradle.properties

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

44
# Fabric Properties
55
# check these on https://fabricmc.net/develop/
6-
minecraft_version=1.21.4
7-
minecraft_version_dependency=1.21.4
8-
minecraft_version_list=1.21.4
9-
minecraft_version_list_presentable=1.21.4
6+
minecraft_version=1.21.5-rc1
7+
minecraft_version_dependency=1.21.5-rc.1
8+
minecraft_version_list=1.21.5
9+
minecraft_version_list_presentable=1.21.5
1010
loader_version=0.16.10
1111

12-
parchment_mcversion=1.21
13-
parchment_version=2024.11.10
12+
parchment_mcversion=1.21.4
13+
parchment_version=2025.03.16
1414

1515
# Mod Properties
1616
mod_version=2.9.11
@@ -19,8 +19,8 @@ org.gradle.jvmargs=-Xmx2G
1919

2020
# Dependencies
2121
# also check this on https://fabricmc.net/develop/
22-
fabric_version=0.110.5+1.21.4
23-
clientarguments_version=1.10.1
22+
fabric_version=0.119.2+1.21.5
23+
clientarguments_version=1.11.1
2424
betterconfig_version=2.3.0
2525
seedfinding_core_version=1.200.1
2626
seedfinding_biome_version=1.171.1

regressionTests/playerRandomHierarchy.regressiontest

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
net/minecraft/server/level/ServerPlayer.createItemStackToDrop (Lnet/minecraft/world/item/ItemStack;ZZ)Lnet/minecraft/world/entity/item/ItemEntity; <- net/minecraft/world/entity/Entity.random
2-
net/minecraft/server/level/ServerPlayer.createItemStackToDrop (Lnet/minecraft/world/item/ItemStack;ZZ)Lnet/minecraft/world/entity/item/ItemEntity; <- net/minecraft/world/entity/Entity.random
3-
net/minecraft/server/level/ServerPlayer.createItemStackToDrop (Lnet/minecraft/world/item/ItemStack;ZZ)Lnet/minecraft/world/entity/item/ItemEntity; <- net/minecraft/world/entity/Entity.random
4-
net/minecraft/server/level/ServerPlayer.createItemStackToDrop (Lnet/minecraft/world/item/ItemStack;ZZ)Lnet/minecraft/world/entity/item/ItemEntity; <- net/minecraft/world/entity/Entity.random
5-
net/minecraft/server/level/ServerPlayer.createItemStackToDrop (Lnet/minecraft/world/item/ItemStack;ZZ)Lnet/minecraft/world/entity/item/ItemEntity; <- net/minecraft/world/entity/Entity.random
6-
net/minecraft/server/level/ServerPlayer.createItemStackToDrop (Lnet/minecraft/world/item/ItemStack;ZZ)Lnet/minecraft/world/entity/item/ItemEntity; <- net/minecraft/world/entity/Entity.random
71
net/minecraft/world/level/block/entity/BaseContainerBlockEntity.canUnlock (Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/LockCode;Lnet/minecraft/network/chat/Component;)Z <- net/minecraft/server/level/ServerPlayer.playNotifySound <- net/minecraft/world/entity/Entity.random
82
net/minecraft/world/entity/Entity.<init> (Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/world/level/Level;)V <- net/minecraft/world/entity/Entity.random
93
net/minecraft/world/entity/Entity.<init> (Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/world/level/Level;)V <- net/minecraft/world/entity/Entity.random
@@ -63,12 +57,12 @@ net/minecraft/world/entity/Entity.playSwimSound (F)V <- net/minecraft/world/enti
6357
net/minecraft/world/entity/Entity.playSwimSound (F)V <- net/minecraft/world/entity/Entity.random
6458
net/minecraft/world/entity/Entity.spawnSprintParticle ()V <- net/minecraft/world/entity/Entity.random
6559
net/minecraft/world/entity/Entity.spawnSprintParticle ()V <- net/minecraft/world/entity/Entity.random
66-
net/minecraft/world/entity/LivingEntity.baseTick ()V <- net/minecraft/world/entity/Entity.random
67-
net/minecraft/world/entity/LivingEntity.baseTick ()V <- net/minecraft/world/entity/Entity.random
68-
net/minecraft/world/entity/LivingEntity.baseTick ()V <- net/minecraft/world/entity/Entity.random
69-
net/minecraft/world/entity/LivingEntity.baseTick ()V <- net/minecraft/world/entity/Entity.random
70-
net/minecraft/world/entity/LivingEntity.baseTick ()V <- net/minecraft/world/entity/Entity.random
71-
net/minecraft/world/entity/LivingEntity.baseTick ()V <- net/minecraft/world/entity/Entity.random
60+
net/minecraft/world/entity/LivingEntity.createItemStackToDrop (Lnet/minecraft/world/item/ItemStack;ZZ)Lnet/minecraft/world/entity/item/ItemEntity; <- net/minecraft/world/entity/Entity.random
61+
net/minecraft/world/entity/LivingEntity.createItemStackToDrop (Lnet/minecraft/world/item/ItemStack;ZZ)Lnet/minecraft/world/entity/item/ItemEntity; <- net/minecraft/world/entity/Entity.random
62+
net/minecraft/world/entity/LivingEntity.createItemStackToDrop (Lnet/minecraft/world/item/ItemStack;ZZ)Lnet/minecraft/world/entity/item/ItemEntity; <- net/minecraft/world/entity/Entity.random
63+
net/minecraft/world/entity/LivingEntity.createItemStackToDrop (Lnet/minecraft/world/item/ItemStack;ZZ)Lnet/minecraft/world/entity/item/ItemEntity; <- net/minecraft/world/entity/Entity.random
64+
net/minecraft/world/entity/LivingEntity.createItemStackToDrop (Lnet/minecraft/world/item/ItemStack;ZZ)Lnet/minecraft/world/entity/item/ItemEntity; <- net/minecraft/world/entity/Entity.random
65+
net/minecraft/world/entity/LivingEntity.createItemStackToDrop (Lnet/minecraft/world/item/ItemStack;ZZ)Lnet/minecraft/world/entity/item/ItemEntity; <- net/minecraft/world/entity/Entity.random
7266
net/minecraft/world/entity/LivingEntity.decreaseAirSupply (I)I <- net/minecraft/world/entity/Entity.random
7367
net/minecraft/world/entity/LivingEntity.getVoicePitch ()F <- net/minecraft/world/entity/Entity.random
7468
net/minecraft/world/entity/LivingEntity.getVoicePitch ()F <- net/minecraft/world/entity/Entity.random
@@ -84,6 +78,9 @@ net/minecraft/world/entity/LivingEntity.handleEntityEvent (B)V <- net/minecraft/
8478
net/minecraft/world/entity/LivingEntity.handleEntityEvent (B)V <- net/minecraft/world/entity/Entity.random
8579
net/minecraft/world/entity/LivingEntity.handleEntityEvent (B)V <- net/minecraft/world/entity/Entity.random
8680
net/minecraft/world/entity/LivingEntity.handleEntityEvent (B)V <- net/minecraft/world/entity/Entity.random
81+
net/minecraft/world/entity/LivingEntity.makeDrownParticles ()V <- net/minecraft/world/entity/Entity.random
82+
net/minecraft/world/entity/LivingEntity.makeDrownParticles ()V <- net/minecraft/world/entity/Entity.random
83+
net/minecraft/world/entity/LivingEntity.makeDrownParticles ()V <- net/minecraft/world/entity/Entity.random
8784
net/minecraft/world/entity/LivingEntity.makePoofParticles ()V <- net/minecraft/world/entity/Entity.random
8885
net/minecraft/world/entity/LivingEntity.makePoofParticles ()V <- net/minecraft/world/entity/Entity.random
8986
net/minecraft/world/entity/LivingEntity.makePoofParticles ()V <- net/minecraft/world/entity/Entity.random

src/main/java/net/earthcomputer/clientcommands/ClientCommands.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import net.earthcomputer.clientcommands.features.PlayerRandCracker;
1515
import net.earthcomputer.clientcommands.features.Relogger;
1616
import net.earthcomputer.clientcommands.features.ServerBrandManager;
17+
import net.earthcomputer.clientcommands.render.RenderQueue;
1718
import net.earthcomputer.clientcommands.util.MappingsHelper;
1819
import net.fabricmc.api.ClientModInitializer;
1920
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
@@ -50,6 +51,8 @@ public class ClientCommands implements ClientModInitializer {
5051

5152
@Override
5253
public void onInitializeClient() {
54+
RenderQueue.register();
55+
5356
setupScrambleWindowTitle();
5457

5558
// Config
@@ -126,6 +129,7 @@ public static void registerCommands(CommandDispatcher<FabricClientCommandSource>
126129
BuildInfoCommand.register(dispatcher);
127130
CalcCommand.register(dispatcher);
128131
CalcStackCommand.register(dispatcher, context);
132+
CallbackCommand.register(dispatcher);
129133
CDebugCommand.register(dispatcher);
130134
CEnchantCommand.register(dispatcher, context);
131135
CFunctionCommand.register(dispatcher);

src/main/java/net/earthcomputer/clientcommands/command/BookCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private static int fillBook(FabricClientCommandSource source, IntStream characte
8282
throw NO_BOOK.create();
8383
}
8484
}
85-
int slot = hand == InteractionHand.MAIN_HAND ? player.getInventory().selected : Inventory.SLOT_OFFHAND;
85+
int slot = hand == InteractionHand.MAIN_HAND ? player.getInventory().getSelectedSlot() : Inventory.SLOT_OFFHAND;
8686

8787
String joinedPages = characterGenerator.limit((long) getMaxLimit() * 210).mapToObj(i -> String.valueOf((char) i)).collect(Collectors.joining());
8888

src/main/java/net/earthcomputer/clientcommands/command/CEnchantCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private static int cenchant(FabricClientCommandSource source, ItemAndEnchantment
103103
List<EnchantmentInstance> enchantments = new ArrayList<>(result.enchantments());
104104
EnchantmentCracker.sortIntoTooltipOrder(level.registryAccess().lookupOrThrow(Registries.ENCHANTMENT), enchantments);
105105
for (EnchantmentInstance ench : enchantments) {
106-
source.sendFeedback(Component.literal("- ").append(Enchantment.getFullname(ench.enchantment, ench.level)));
106+
source.sendFeedback(Component.literal("- ").append(Enchantment.getFullname(ench.enchantment(), ench.level())));
107107
}
108108
}
109109
}

src/main/java/net/earthcomputer/clientcommands/command/CGiveCommand.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ private static int give(FabricClientCommandSource source, ItemInput itemInput, i
7878
}
7979

8080
private static int getSlotWithRemainingSpace(Inventory inventory, ItemStack stack, IntList fullSlots) {
81-
if (inventory.hasRemainingSpaceForItem(inventory.getItem(inventory.selected), stack) && !fullSlots.contains(inventory.selected)) {
82-
return inventory.selected;
81+
if (inventory.hasRemainingSpaceForItem(inventory.getItem(inventory.getSelectedSlot()), stack) && !fullSlots.contains(inventory.getSelectedSlot())) {
82+
return inventory.getSelectedSlot();
8383
} else if (inventory.hasRemainingSpaceForItem(inventory.getItem(Inventory.SLOT_OFFHAND), stack) && !fullSlots.contains(Inventory.SLOT_OFFHAND)) {
84-
return inventory.selected;
84+
return inventory.getSelectedSlot();
8585
} else {
8686
for (int slot = 0; slot < Inventory.INVENTORY_SIZE; slot++) {
8787
if (inventory.hasRemainingSpaceForItem(inventory.getItem(slot), stack) && !fullSlots.contains(slot)) {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package net.earthcomputer.clientcommands.command;
2+
3+
import com.mojang.brigadier.Command;
4+
import com.mojang.brigadier.CommandDispatcher;
5+
import com.mojang.brigadier.exceptions.CommandSyntaxException;
6+
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
7+
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
8+
import net.minecraft.network.chat.Component;
9+
10+
import java.util.UUID;
11+
12+
import static dev.xpple.clientarguments.arguments.CUuidArgument.*;
13+
import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.*;
14+
15+
public class CallbackCommand {
16+
private static final SimpleCommandExceptionType NO_SUCH_CALLBACK_EXCEPTION = new SimpleCommandExceptionType(Component.translatable("commands.ccallback.failed"));
17+
18+
public static void register(CommandDispatcher<FabricClientCommandSource> dispatcher) {
19+
dispatcher.register(literal("ccallback")
20+
.then(argument("id", uuid())
21+
.executes(ctx -> runCallback(getUuid(ctx, "id")))));
22+
}
23+
24+
private static int runCallback(UUID uuid) throws CommandSyntaxException {
25+
if (!ClientCommandHelper.runCallback(uuid)) {
26+
throw NO_SUCH_CALLBACK_EXCEPTION.create();
27+
}
28+
29+
return Command.SINGLE_SUCCESS;
30+
}
31+
}

src/main/java/net/earthcomputer/clientcommands/command/ClientCommandHelper.java

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
import net.minecraft.network.chat.MutableComponent;
1515
import net.minecraft.world.entity.Entity;
1616

17-
import java.util.HashMap;
1817
import java.util.Map;
19-
import java.util.Random;
18+
import java.util.UUID;
19+
import java.util.concurrent.ConcurrentHashMap;
2020

2121
public class ClientCommandHelper {
2222

@@ -86,19 +86,46 @@ public static Component getCommandTextComponent(@Translatable String translation
8686

8787
public static Component getCommandTextComponent(MutableComponent component, String command) {
8888
return component.withStyle(style -> style.applyFormat(ChatFormatting.UNDERLINE)
89-
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command))
90-
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal(command))));
91-
}
92-
93-
public static final Map<String, Runnable> runnables = new HashMap<>();
94-
95-
public static String registerCode(Runnable code) {
96-
String randomString = new Random().ints('0', 'z' + 1)
97-
.filter(i -> (i <= '9' || i >= 'A') && (i <= 'Z' || i >= 'a'))
98-
.limit(10)
99-
.collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append)
100-
.toString();
101-
runnables.put(randomString, code);
102-
return randomString;
89+
.withClickEvent(new ClickEvent.RunCommand(command))
90+
.withHoverEvent(new HoverEvent.ShowText(Component.literal(command))));
91+
}
92+
93+
private static final Map<UUID, Callback> callbacks = new ConcurrentHashMap<>();
94+
95+
public static ClickEvent callbackClickEvent(Runnable runnable) {
96+
return callbackClickEvent(runnable, 60_000_000_000L); // 1 minute timeout
97+
}
98+
99+
public static ClickEvent callbackClickEvent(Runnable callback, long timeoutNanos) {
100+
UUID callbackId = UUID.randomUUID();
101+
callbacks.put(callbackId, new Callback(callback, System.nanoTime() + timeoutNanos));
102+
return new ClickEvent.RunCommand("/ccallback " + callbackId);
103+
}
104+
105+
public static boolean runCallback(UUID callbackId) {
106+
Callback callback = callbacks.get(callbackId);
107+
if (callback == null) {
108+
return false;
109+
}
110+
callback.callback.run();
111+
return true;
112+
}
113+
114+
private record Callback(Runnable callback, long timeout) {
115+
static {
116+
Thread.ofVirtual().name("Clientcommands callback cleanup").start(() -> {
117+
while (true) {
118+
try {
119+
// This isn't really "busy-waiting" since the wait time is so long
120+
//noinspection BusyWait
121+
Thread.sleep(1000);
122+
} catch (InterruptedException e) {
123+
break;
124+
}
125+
long now = System.nanoTime();
126+
callbacks.values().removeIf(callback -> now - callback.timeout <= 0);
127+
}
128+
});
129+
}
103130
}
104131
}

src/main/java/net/earthcomputer/clientcommands/command/CreativeTabCommand.java

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ private static int changeIcon(FabricClientCommandSource source, String name, Ite
209209

210210
Tab tab = tabs.get(name);
211211
ListTag items = tab.items();
212-
ItemStack old = ItemStack.parseOptional(source.registryAccess(), tab.icon());
212+
ItemStack old = ItemStack.parse(source.registryAccess(), tab.icon()).orElse(ItemStack.EMPTY);
213213

214214
tabs.put(name, new Tab((CompoundTag) icon.save(source.registryAccess()), items));
215215

@@ -262,62 +262,64 @@ private static void saveFile() throws CommandSyntaxException {
262262

263263
private static void loadFile() throws IOException {
264264
tabs.clear();
265-
CompoundTag rootTag = NbtIo.read(configPath.resolve("creative_tabs.dat"));
266-
if (rootTag == null) {
265+
CompoundTag rootTagTmp = NbtIo.read(configPath.resolve("creative_tabs.dat"));
266+
if (rootTagTmp == null) {
267267
try {
268268
Files.move(configPath.resolve("groups.dat"), configPath.resolve("creative_tabs.dat"));
269269
} catch (NoSuchFileException e) {
270270
return;
271271
}
272-
rootTag = NbtIo.read(configPath.resolve("creative_tabs.dat"));
273-
if (rootTag == null) {
272+
rootTagTmp = NbtIo.read(configPath.resolve("creative_tabs.dat"));
273+
if (rootTagTmp == null) {
274274
return;
275275
}
276276
}
277+
CompoundTag rootTag = rootTagTmp;
277278
final int currentVersion = SharedConstants.getCurrentVersion().getDataVersion().getVersion();
278-
final int fileVersion = rootTag.getInt("DataVersion");
279-
CompoundTag compoundTag = rootTag.getCompound("CreativeTabs");
280-
if (compoundTag.isEmpty()) {
281-
compoundTag = rootTag.getCompound("Groups");
282-
}
279+
final int fileVersion = rootTag.getIntOr("DataVersion", 99);
280+
CompoundTag compoundTag = rootTag.getCompound("CreativeTabs").orElseGet(() -> rootTag.getCompoundOrEmpty("Groups"));
283281
DataFixer dataFixer = Minecraft.getInstance().getFixerUpper();
284282
if (fileVersion >= currentVersion) {
285-
for (String key : compoundTag.getAllKeys()) {
286-
if (ResourceLocation.tryParse("clientcommands:" + key) == null) {
287-
LOGGER.warn("Skipping creative tab with invalid name {}", key);
283+
for (var entry : compoundTag.entrySet()) {
284+
if (ResourceLocation.tryParse("clientcommands:" + entry.getKey()) == null) {
285+
LOGGER.warn("Skipping creative tab with invalid name {}", entry.getKey());
288286
return;
289287
}
290288

291-
CompoundTag tab = compoundTag.getCompound(key);
292-
CompoundTag icon = tab.getCompound("icon");
293-
ListTag items = tab.getList("items", Tag.TAG_COMPOUND);
294-
tabs.put(key, new Tab(icon, items));
289+
if (!(entry.getValue() instanceof CompoundTag tab)) {
290+
continue;
291+
}
292+
CompoundTag icon = tab.getCompoundOrEmpty("icon");
293+
ListTag items = tab.getListOrEmpty("items");
294+
tabs.put(entry.getKey(), new Tab(icon, items));
295295
}
296296
} else {
297-
for (String key : compoundTag.getAllKeys()) {
298-
if (ResourceLocation.tryParse("clientcommands:" + key) == null) {
299-
LOGGER.warn("Skipping creative tab with invalid name {}", key);
297+
for (var entry : compoundTag.entrySet()) {
298+
if (ResourceLocation.tryParse("clientcommands:" + entry.getKey()) == null) {
299+
LOGGER.warn("Skipping creative tab with invalid name {}", entry.getKey());
300300
return;
301301
}
302302

303-
CompoundTag tab = compoundTag.getCompound(key);
304-
Dynamic<Tag> oldStackDynamic = new Dynamic<>(NbtOps.INSTANCE, tab.getCompound("icon"));
303+
if (!(entry.getValue() instanceof CompoundTag tab)) {
304+
continue;
305+
}
306+
Dynamic<Tag> oldStackDynamic = new Dynamic<>(NbtOps.INSTANCE, tab.getCompoundOrEmpty("icon"));
305307
Dynamic<Tag> newStackDynamic = dataFixer.update(References.ITEM_STACK, oldStackDynamic, fileVersion, currentVersion);
306308
CompoundTag icon = (CompoundTag) newStackDynamic.getValue();
307309

308310
ListTag updatedListTag = new ListTag();
309-
tab.getList("items", Tag.TAG_COMPOUND).forEach(tag -> {
311+
tab.getListOrEmpty("items").forEach(tag -> {
310312
Dynamic<Tag> oldTagDynamic = new Dynamic<>(NbtOps.INSTANCE, tag);
311313
Dynamic<Tag> newTagDynamic = dataFixer.update(References.ITEM_STACK, oldTagDynamic, fileVersion, currentVersion);
312314
updatedListTag.add(newTagDynamic.getValue());
313315
});
314-
tabs.put(key, new Tab(icon, updatedListTag));
316+
tabs.put(entry.getKey(), new Tab(icon, updatedListTag));
315317
}
316318
}
317319
}
318320

319321
private static ItemStack singleItemFromNbt(HolderLookup.Provider holderLookupProvider, CompoundTag nbt) {
320-
ItemStack stack = ItemStack.parseOptional(holderLookupProvider, nbt);
322+
ItemStack stack = ItemStack.parse(holderLookupProvider, nbt).orElse(ItemStack.EMPTY);
321323
if (!stack.isEmpty()) {
322324
stack.setCount(1);
323325
}
@@ -332,7 +334,7 @@ void registerCreativeTab(HolderLookup.Provider builtinLookupProvider, String key
332334
.displayItems((displayContext, entries) -> {
333335
Set<ItemStack> existingStacks = ItemStackLinkedSet.createTypeAndComponentsSet();
334336
for (int i = 0; i < items.size(); i++) {
335-
ItemStack stack = singleItemFromNbt(displayContext.holders(), items.getCompound(i));
337+
ItemStack stack = singleItemFromNbt(displayContext.holders(), items.getCompoundOrEmpty(i));
336338
if (stack.isEmpty()) {
337339
continue;
338340
}

0 commit comments

Comments
 (0)