Skip to content

Commit cc4c164

Browse files
committed
Update to 1.19.3
1 parent 204f7b6 commit cc4c164

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

+288
-204
lines changed

build.gradle

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,9 @@ dependencies {
2929
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
3030
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
3131
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
32-
modImplementation('net.earthcomputer.multiconnect:multiconnect-api:1.5.10') {
33-
transitive = false
34-
}
35-
include('net.earthcomputer.multiconnect:multiconnect-api:1.5.10') {
36-
transitive = false
37-
}
3832

39-
modImplementation 'dev.xpple:clientarguments:1.4.1'
40-
include 'dev.xpple:clientarguments:1.4.1'
33+
modImplementation 'dev.xpple:clientarguments:1.4.2'
34+
include 'dev.xpple:clientarguments:1.4.2'
4135

4236
modRuntimeOnly 'me.djtheredstoner:DevAuth-fabric:1.1.0'
4337
}

gradle.properties

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

44
# Fabric Properties
55
# check these on https://modmuss50.me/fabric.html
6-
minecraft_version=1.19.2
7-
minecraft_version_dependency=1.19.2
8-
yarn_mappings=1.19.2+build.28
9-
loader_version=0.14.10
6+
minecraft_version=1.19.3
7+
minecraft_version_dependency=1.19.3
8+
yarn_mappings=1.19.3+build.1
9+
loader_version=0.14.11
1010

1111
# Mod Properties
1212
mod_version = 2.7.5
@@ -15,4 +15,4 @@ org.gradle.jvmargs=-Xmx2G
1515

1616
# Dependencies
1717
# also check this on https://modmuss50.me/fabric.html
18-
fabric_version=0.64.0+1.19.2
18+
fabric_version=0.68.1+1.19.3

src/main/java/net/cortex/clientAddon/cracker/SeedCracker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private static void doCrack(OnCrack Callback){
105105
}
106106

107107
public static void onEntityCreation(EntitySpawnS2CPacket packet) {
108-
if (packet.getEntityTypeId() == EntityType.ITEM && SeedCracker.expectedItems>0) {
108+
if (packet.getEntityType() == EntityType.ITEM && SeedCracker.expectedItems>0) {
109109

110110
long rand_val = (long) ((Math.atan2(packet.getVelocityZ(), packet.getVelocityX()) + Math.PI) / (Math.PI * 2) * ((float) (1 << 24)));
111111
long top_bits = rand_val;
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package net.earthcomputer.clientcommands;
2+
3+
import net.minecraft.SharedConstants;
4+
import net.minecraft.registry.Registry;
5+
import net.minecraft.util.Util;
6+
import org.jetbrains.annotations.Nullable;
7+
8+
import java.lang.reflect.Method;
9+
10+
public final class MulticonnectCompat {
11+
public static final int V1_13_2 = 404;
12+
public static final int V1_14 = 477;
13+
public static final int V1_14_2 = 485;
14+
public static final int V1_15 = 573;
15+
public static final int V1_15_2 = 578;
16+
public static final int V1_17 = 755;
17+
public static final int V1_18 = 757;
18+
19+
private MulticonnectCompat() {
20+
}
21+
22+
@Nullable
23+
private static final Object api = Util.make(() -> {
24+
Class<?> clazz;
25+
try {
26+
clazz = Class.forName("net.earthcomputer.multiconnect.api.MultiConnectAPI");
27+
} catch (ClassNotFoundException e) {
28+
return null;
29+
}
30+
try {
31+
return clazz.getMethod("getInstance").invoke(null);
32+
} catch (ReflectiveOperationException e) {
33+
throw new RuntimeException(e);
34+
}
35+
});
36+
private static final Method getProtocolVersion = Util.make(() -> {
37+
if (api == null) {
38+
return null;
39+
}
40+
try {
41+
return api.getClass().getMethod("getProtocolVersion");
42+
} catch (ReflectiveOperationException e) {
43+
throw new RuntimeException(e);
44+
}
45+
});
46+
private static final Method doesServerKnow = Util.make(() -> {
47+
if (api == null) {
48+
return null;
49+
}
50+
try {
51+
return api.getClass().getMethod("doesServerKnow", Registry.class, Object.class);
52+
} catch (ReflectiveOperationException e) {
53+
throw new RuntimeException(e);
54+
}
55+
});
56+
57+
public static int getProtocolVersion() {
58+
if (api == null) {
59+
return SharedConstants.getProtocolVersion();
60+
} else {
61+
try {
62+
return (Integer) getProtocolVersion.invoke(api);
63+
} catch (ReflectiveOperationException e) {
64+
throw new RuntimeException(e);
65+
}
66+
}
67+
}
68+
69+
public static <T> boolean doesServerKnow(Registry<T> registry, T value) {
70+
if (api == null) {
71+
return true;
72+
} else {
73+
try {
74+
return (Boolean) doesServerKnow.invoke(api, registry, value);
75+
} catch (ReflectiveOperationException e) {
76+
throw new RuntimeException(e);
77+
}
78+
}
79+
}
80+
}

src/main/java/net/earthcomputer/clientcommands/c2c/CCNetworkHandler.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import net.minecraft.client.MinecraftClient;
88
import net.minecraft.client.network.PlayerListEntry;
99
import net.minecraft.network.encryption.PlayerPublicKey;
10+
import net.minecraft.network.encryption.PublicPlayerSession;
1011
import net.minecraft.text.MutableText;
1112
import net.minecraft.text.Text;
1213
import net.minecraft.util.Formatting;
@@ -37,7 +38,11 @@ public void sendPacket(C2CPacket packet, PlayerListEntry recipient) throws Comma
3738
LOGGER.warn("Could not send the packet because the id was not recognised");
3839
return;
3940
}
40-
PlayerPublicKey ppk = recipient.getPublicKeyData();
41+
PublicPlayerSession session = recipient.getSession();
42+
if (session == null) {
43+
throw PUBLIC_KEY_NOT_FOUND_EXCEPTION.create();
44+
}
45+
PlayerPublicKey ppk = session.publicKeyData();
4146
if (ppk == null) {
4247
throw PUBLIC_KEY_NOT_FOUND_EXCEPTION.create();
4348
}
@@ -58,7 +63,7 @@ public void sendPacket(C2CPacket packet, PlayerListEntry recipient) throws Comma
5863
if (commandString.length() >= 256) {
5964
throw MESSAGE_TOO_LONG_EXCEPTION.create();
6065
}
61-
MinecraftClient.getInstance().player.sendCommand(commandString, null);
66+
MinecraftClient.getInstance().getNetworkHandler().sendChatCommand(commandString);
6267
OutgoingPacketFilter.addPacket(packetString);
6368
}
6469

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import net.fabricmc.fabric.impl.command.client.ClientCommandInternals;
1616
import net.fabricmc.loader.api.FabricLoader;
1717
import net.minecraft.client.MinecraftClient;
18+
import net.minecraft.client.network.ClientPlayNetworkHandler;
1819
import net.minecraft.text.Text;
1920
import net.minecraft.util.Formatting;
2021
import org.slf4j.Logger;
@@ -95,11 +96,15 @@ private static int executeAliasCommand(FabricClientCommandSource source, String
9596
} else if (arguments != null){
9697
cmd += " " + arguments;
9798
}
99+
ClientPlayNetworkHandler networkHandler = MinecraftClient.getInstance().getNetworkHandler();
100+
if (networkHandler == null) {
101+
return Command.SINGLE_SUCCESS;
102+
}
98103
if (cmd.startsWith("/")) {
99104
cmd = cmd.substring(1);
100-
source.getPlayer().sendCommand(cmd);
105+
networkHandler.sendChatCommand(cmd);
101106
} else {
102-
source.getPlayer().sendChatMessage(cmd, null);
107+
networkHandler.sendChatMessage(cmd);
103108
}
104109

105110
return Command.SINGLE_SUCCESS;

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
import com.mojang.brigadier.CommandDispatcher;
55
import com.mojang.brigadier.exceptions.CommandSyntaxException;
66
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
7-
import net.earthcomputer.multiconnect.api.MultiConnectAPI;
8-
import net.earthcomputer.multiconnect.api.Protocols;
7+
import net.earthcomputer.clientcommands.MulticonnectCompat;
98
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
109
import net.minecraft.client.network.ClientPlayerEntity;
1110
import net.minecraft.entity.player.PlayerInventory;
@@ -36,7 +35,7 @@ public class BookCommand {
3635
private static final int DEFAULT_LIMIT = 50;
3736

3837
public static void register(CommandDispatcher<FabricClientCommandSource> dispatcher) {
39-
if (MultiConnectAPI.instance().getProtocolVersion() >= Protocols.V1_15) {
38+
if (MulticonnectCompat.getProtocolVersion() >= MulticonnectCompat.V1_15) {
4039
return; // chunk savestate fixed in 1.15
4140
}
4241

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
88
import net.minecraft.particle.ParticleEffect;
99
import net.minecraft.particle.ParticleTypes;
10+
import net.minecraft.registry.Registries;
1011
import net.minecraft.text.Text;
1112
import net.minecraft.util.math.Vec3d;
1213
import net.minecraft.util.math.random.Random;
13-
import net.minecraft.util.registry.Registry;
1414

1515
import static com.mojang.brigadier.arguments.FloatArgumentType.*;
1616
import static com.mojang.brigadier.arguments.IntegerArgumentType.*;
@@ -60,7 +60,7 @@ private static int spawnParticle(FabricClientCommandSource source, ParticleEffec
6060
}
6161
}
6262
source.sendFeedback(Text.translatable("commands.cparticle.success",
63-
Registry.PARTICLE_TYPE.getId(parameters.getType()).toString()));
63+
Registries.PARTICLE_TYPE.getId(parameters.getType()).toString()));
6464
return Command.SINGLE_SUCCESS;
6565
}
6666
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import net.minecraft.client.MinecraftClient;
44
import net.minecraft.client.network.ClientPlayerEntity;
5+
import net.minecraft.registry.DynamicRegistryManager;
56
import net.minecraft.server.command.ServerCommandSource;
6-
import net.minecraft.util.registry.DynamicRegistryManager;
77

88
import java.util.Collection;
99
import java.util.stream.Collectors;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public boolean canUse(PlayerEntity var1) {
217217
}
218218

219219
@Override
220-
public ItemStack transferSlot(PlayerEntity player, int index) {
220+
public ItemStack quickMove(PlayerEntity player, int index) {
221221
return ItemStack.EMPTY;
222222
}
223223

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

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,19 @@
88
import com.mojang.datafixers.DataFixer;
99
import com.mojang.logging.LogUtils;
1010
import com.mojang.serialization.Dynamic;
11-
import net.earthcomputer.clientcommands.interfaces.IItemGroup;
1211
import net.earthcomputer.clientcommands.mixin.CreativeInventoryScreenAccessor;
12+
import net.earthcomputer.clientcommands.mixin.ItemGroupsAccessor;
1313
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
14-
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
14+
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
15+
import net.fabricmc.fabric.impl.itemgroup.ItemGroupHelper;
1516
import net.fabricmc.loader.api.FabricLoader;
1617
import net.minecraft.SharedConstants;
1718
import net.minecraft.client.MinecraftClient;
1819
import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
1920
import net.minecraft.command.CommandRegistryAccess;
2021
import net.minecraft.datafixer.TypeReferences;
2122
import net.minecraft.item.ItemGroup;
23+
import net.minecraft.item.ItemGroups;
2224
import net.minecraft.item.ItemStack;
2325
import net.minecraft.nbt.*;
2426
import net.minecraft.text.Text;
@@ -31,6 +33,7 @@
3133
import java.lang.reflect.Field;
3234
import java.nio.file.Path;
3335
import java.util.HashMap;
36+
import java.util.List;
3437
import java.util.Map;
3538

3639
import static com.mojang.brigadier.arguments.IntegerArgumentType.*;
@@ -106,9 +109,10 @@ private static int addGroup(FabricClientCommandSource source, String name, ItemS
106109
if (identifier == null) {
107110
throw ILLEGAL_CHARACTER_EXCEPTION.create(name);
108111
}
109-
ItemGroup itemGroup = FabricItemGroupBuilder.create(identifier)
110-
.icon(() -> icon)
111-
.build();
112+
ItemGroup itemGroup = FabricItemGroup.builder(identifier)
113+
.displayName(Text.literal(name))
114+
.icon(() -> icon)
115+
.build();
112116

113117
groups.put(name, new Group(itemGroup, icon, new NbtList()));
114118
saveFile();
@@ -143,7 +147,7 @@ private static int removeGroup(FabricClientCommandSource source, String name) th
143147
groups.remove(name);
144148

145149
reloadGroups();
146-
CreativeInventoryScreenAccessor.setSelectedTab(0);
150+
CreativeInventoryScreenAccessor.setSelectedTab(ItemGroups.getDefaultTab());
147151
try {
148152
CURRENT_PAGE_FIELD.set(null, 0);
149153
} catch (ReflectiveOperationException e) {
@@ -214,8 +218,9 @@ private static int changeIcon(FabricClientCommandSource source, String name, Ite
214218
ItemGroup itemGroup = group.getItemGroup();
215219
NbtList items = group.getItems();
216220
ItemStack old = itemGroup.getIcon();
217-
itemGroup = FabricItemGroupBuilder.create(
221+
itemGroup = FabricItemGroup.builder(
218222
new Identifier("clientcommands", name))
223+
.displayName(Text.literal(name))
219224
.icon(() -> icon)
220225
.build();
221226

@@ -240,9 +245,10 @@ private static int renameGroup(FabricClientCommandSource source, String name, St
240245
ItemGroup itemGroup = group.getItemGroup();
241246
NbtList items = group.getItems();
242247
ItemStack icon = itemGroup.getIcon();
243-
itemGroup = FabricItemGroupBuilder.create(identifier)
244-
.icon(() -> icon)
245-
.build();
248+
itemGroup = FabricItemGroup.builder(identifier)
249+
.displayName(Text.literal(name))
250+
.icon(() -> icon)
251+
.build();
246252
groups.put(_new, new Group(itemGroup, icon, items));
247253

248254
reloadGroups();
@@ -289,12 +295,13 @@ private static void loadFile() throws IOException {
289295
NbtCompound group = compoundTag.getCompound(key);
290296
ItemStack icon = ItemStack.fromNbt(group.getCompound("icon"));
291297
NbtList items = group.getList("items", NbtElement.COMPOUND_TYPE);
292-
ItemGroup itemGroup = FabricItemGroupBuilder.create(
298+
ItemGroup itemGroup = FabricItemGroup.builder(
293299
new Identifier("clientcommands", key))
300+
.displayName(Text.literal(key))
294301
.icon(() -> icon)
295-
.appendItems(stacks -> {
302+
.entries((enabledFeatures, entries, operatorEnabled) -> {
296303
for (int i = 0; i < items.size(); i++) {
297-
stacks.add(ItemStack.fromNbt(items.getCompound(i)));
304+
entries.add(ItemStack.fromNbt(items.getCompound(i)));
298305
}
299306
})
300307
.build();
@@ -313,12 +320,13 @@ private static void loadFile() throws IOException {
313320
Dynamic<NbtElement> newTagDynamic = dataFixer.update(TypeReferences.ITEM_STACK, oldTagDynamic, fileVersion, currentVersion);
314321
updatedListTag.add(newTagDynamic.getValue());
315322
});
316-
ItemGroup itemGroup = FabricItemGroupBuilder.create(
323+
ItemGroup itemGroup = FabricItemGroup.builder(
317324
new Identifier("clientcommands", key))
325+
.displayName(Text.literal(key))
318326
.icon(() -> icon)
319-
.appendItems(stacks -> {
327+
.entries((enabledFeatures, entries, operatorEnabled) -> {
320328
for (int i = 0; i < updatedListTag.size(); i++) {
321-
stacks.add(ItemStack.fromNbt(updatedListTag.getCompound(i)));
329+
entries.add(ItemStack.fromNbt(updatedListTag.getCompound(i)));
322330
}
323331
})
324332
.build();
@@ -328,16 +336,31 @@ private static void loadFile() throws IOException {
328336
}
329337

330338
private static void reloadGroups() {
331-
((IItemGroup) ItemGroup.BUILDING_BLOCKS).shrink();
339+
ItemGroupsAccessor.setGroups(
340+
ItemGroups.getGroups().stream()
341+
.filter(group -> !group.getId().getNamespace().equals("clientcommands"))
342+
.toList()
343+
);
344+
345+
if (groups.isEmpty()) {
346+
// refresh the item groups list by remove and readding the last item group
347+
List<ItemGroup> list = ItemGroups.getGroups();
348+
ItemGroupsAccessor.setGroups(list.subList(0, list.size() - 1));
349+
//noinspection UnstableApiUsage
350+
ItemGroupHelper.appendItemGroup(list.get(list.size() - 1));
351+
return;
352+
}
353+
// otherwise adding the groups will refresh the item groups list
332354

333355
for (String key : groups.keySet()) {
334356
Group group = groups.get(key);
335-
group.setItemGroup(FabricItemGroupBuilder.create(
357+
group.setItemGroup(FabricItemGroup.builder(
336358
new Identifier("clientcommands", key))
359+
.displayName(Text.literal(key))
337360
.icon(group::getIcon)
338-
.appendItems(stacks -> {
361+
.entries((enabledFeatures, entries, operatorEnabled) -> {
339362
for (int i = 0; i < group.getItems().size(); i++) {
340-
stacks.add(ItemStack.fromNbt(group.getItems().getCompound(i)));
363+
entries.add(ItemStack.fromNbt(group.getItems().getCompound(i)));
341364
}
342365
})
343366
.build());

0 commit comments

Comments
 (0)