Skip to content
This repository was archived by the owner on Oct 20, 2024. It is now read-only.

Commit 880d1ff

Browse files
committed
1.20.6
1 parent b3d0d4a commit 880d1ff

File tree

6 files changed

+12
-71
lines changed

6 files changed

+12
-71
lines changed

build.gradle

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,25 +144,18 @@ publishMods {
144144

145145
displayName = "${project.mod_version} (${project.minecraft_version})"
146146

147-
["1.19.2", "1.19.3", "1.19.4", "1.20", "1.20.1", "1.20.2", "1.20.3", "1.20.4"].each {
148-
modrinth {
149-
minecraftVersions.add(it)
150-
}
151-
curseforge {
152-
minecraftVersions.add(it)
153-
}
154-
}
155-
156147
modrinth {
157148
projectId = "sc4Mu9Zu"
158149
accessToken = providers.environmentVariable("MODRINTH_TOKEN")
150+
minecraftVersions.add("${project.minecraft_version}")
159151

160152
requires("fabric-api")
161153
embeds("dark-matter")
162154
}
163155
curseforge {
164156
projectId = "622736"
165157
accessToken = providers.environmentVariable("CURSEFORGE_TOKEN")
158+
minecraftVersions.add("${project.minecraft_version}")
166159

167160
requires("fabric-api")
168161
embeds("dark-matter")

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
org.gradle.jvmargs=-Xmx1G
33
# Fabric Properties
44
# check these on https://fabricmc.net/versions.html
5-
minecraft_version=1.20.2
6-
yarn_mappings=1.20.2+build.4
5+
minecraft_version=1.20.6
6+
yarn_mappings=1.20.6+build.3
77
# Mod Properties
88
mod_version=5.4.4
99
maven_group=com.github.vini2003.linkart

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ dark-matter = "4.0.0-1.20.1-build.481"
33

44
[libraries]
55
fabric-loader = { group = "net.fabricmc", name = "fabric-loader", version = "0.15.11" }
6-
fabric-api = { group = "net.fabricmc.fabric-api", name = "fabric-api", version = "0.90.0+1.20.2" }
6+
fabric-api = { group = "net.fabricmc.fabric-api", name = "fabric-api", version = "0.99.4+1.20.6" }
77

88
dark-matter-base = { group = "me.melontini", name = "dark-matter-base", version.ref = "dark-matter" }
99

src/main/java/com/github/vini2003/linkart/mixin/AbstractMinecartEntityMixin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,14 @@ void onPushAway(Entity entity, CallbackInfo ci) {
157157
private void linkart$write(NbtCompound nbt, CallbackInfo ci) {
158158
if (linkart$followingUUID != null) nbt.putUuid("LK-Following", linkart$followingUUID);
159159
if (linkart$followerUUID != null) nbt.putUuid("LK-Follower", linkart$followerUUID);
160-
if (linkart$itemStack != null) nbt.put("LK-ItemStack", linkart$itemStack.writeNbt(new NbtCompound()));
160+
if (linkart$itemStack != null) nbt.put("LK-ItemStack", linkart$itemStack.encodeAllowEmpty(this.getRegistryManager()));
161161
}
162162

163163
@Inject(at = @At("RETURN"), method = "readCustomDataFromNbt")
164164
private void linkart$read(NbtCompound nbt, CallbackInfo ci) {
165165
if (nbt.contains("LK-Following")) linkart$followingUUID = nbt.getUuid("LK-Following");
166166
if (nbt.contains("LK-Follower")) linkart$followerUUID = nbt.getUuid("LK-Follower");
167-
if (nbt.contains("LK-ItemStack")) linkart$itemStack = ItemStack.fromNbt(nbt.getCompound("LK-ItemStack"));
167+
if (nbt.contains("LK-ItemStack")) linkart$itemStack = ItemStack.fromNbtOrEmpty(this.getRegistryManager(), nbt.getCompound("LK-ItemStack"));
168168
}
169169

170170
@Override

src/main/java/com/github/vini2003/linkart/utility/LinkartCommand.java

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,24 @@
22

33
import com.github.vini2003.linkart.Linkart;
44
import com.mojang.brigadier.CommandDispatcher;
5-
import me.melontini.dark_matter.api.base.util.Exceptions;
6-
import me.melontini.dark_matter.api.base.util.Mapper;
75
import net.minecraft.server.command.CommandManager;
86
import net.minecraft.server.command.ServerCommandSource;
97
import net.minecraft.text.Text;
10-
import org.apache.logging.log4j.LogManager;
11-
import org.apache.logging.log4j.Logger;
128

13-
import java.lang.invoke.MethodHandle;
14-
import java.lang.invoke.MethodHandles;
15-
import java.lang.invoke.MethodType;
169
import java.util.function.Supplier;
1710

1811
public class LinkartCommand {
19-
private static final Logger LOGGER = LogManager.getLogger();
2012

2113
private static final Supplier<Text> RELOADED = () -> TextUtil.literal("reloaded linkart config");
22-
private static final MethodHandle cachedHandle = Exceptions.supply(() -> {
23-
try {
24-
String mthd = Mapper.mapMethod(ServerCommandSource.class, "method_9226", MethodType.methodType(void.class, Supplier.class, boolean.class));
25-
return MethodHandles.insertArguments(MethodHandles.lookup().findVirtual(ServerCommandSource.class, mthd, MethodType.methodType(void.class, Supplier.class, boolean.class)),
26-
1, RELOADED, true);
27-
} catch (Throwable e) {
28-
String mthd = Mapper.mapMethod(ServerCommandSource.class, "method_9226", MethodType.methodType(void.class, Text.class, boolean.class));
29-
return MethodHandles.insertArguments(MethodHandles.lookup().findVirtual(ServerCommandSource.class, mthd, MethodType.methodType(void.class, Text.class, boolean.class)),
30-
1, RELOADED.get(), true);
31-
}
32-
});
3314

3415
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
3516
dispatcher.register(CommandManager.literal("linkart")
3617
.then(CommandManager.literal("config")
3718
.then(CommandManager.literal("reload")
3819
.executes(context -> {
3920
Linkart.loadConfig();
40-
invoke(context.getSource());
21+
context.getSource().sendFeedback(RELOADED, true);
4122
return 1;
4223
}))));
4324
}
44-
45-
private static void invoke(Object... args) {
46-
try {
47-
LinkartCommand.cachedHandle.invokeWithArguments(args);
48-
} catch (Throwable e) {
49-
LOGGER.error(e);
50-
throw new RuntimeException(e);
51-
}
52-
}
5325
}

src/main/java/com/github/vini2003/linkart/utility/LoadingCarts.java

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,33 @@
11
package com.github.vini2003.linkart.utility;
22

3-
import me.melontini.dark_matter.api.base.util.Exceptions;
4-
import me.melontini.dark_matter.api.base.util.Mapper;
5-
import me.melontini.dark_matter.api.base.util.Utilities;
63
import net.minecraft.entity.vehicle.AbstractMinecartEntity;
74
import net.minecraft.nbt.NbtCompound;
85
import net.minecraft.nbt.NbtElement;
96
import net.minecraft.nbt.NbtList;
107
import net.minecraft.nbt.NbtLong;
8+
import net.minecraft.registry.RegistryWrapper;
119
import net.minecraft.server.world.ChunkTicketType;
1210
import net.minecraft.server.world.ServerWorld;
1311
import net.minecraft.util.math.BlockPos;
1412
import net.minecraft.util.math.ChunkPos;
1513
import net.minecraft.world.PersistentState;
16-
import net.minecraft.world.PersistentStateManager;
1714

18-
import java.lang.invoke.*;
1915
import java.util.HashSet;
2016
import java.util.Set;
21-
import java.util.function.Function;
22-
import java.util.function.Supplier;
2317

2418
public class LoadingCarts extends PersistentState {
2519

26-
private static final Function<PersistentStateManager, LoadingCarts> GETTER = Exceptions.supply(() -> {
27-
Supplier<LoadingCarts> supplier = LoadingCarts::new;
28-
Function<NbtCompound, LoadingCarts> function = nbt -> new LoadingCarts().readNbt(nbt);
29-
try {
30-
Type<LoadingCarts> type = new Type<>(supplier, function, null);//thanks, FAPI
31-
return manager -> manager.getOrCreate(type, "linkart_loading_carts");
32-
} catch (Throwable e) {
33-
String mth = Mapper.mapMethod(PersistentStateManager.class, "method_17924", MethodType.methodType(PersistentState.class, Function.class, Supplier.class, String.class));
34-
MethodHandle h = Exceptions.supply(() -> MethodHandles.lookup().findVirtual(PersistentStateManager.class, mth, MethodType.methodType(PersistentState.class, Function.class, Supplier.class, String.class)));
35-
36-
//Not pretty, but is faster than reflection and handles.
37-
interface Invoker {
38-
PersistentState invoke(PersistentStateManager manager, Function<?,?> f, Supplier<?> s, String name);
39-
}
40-
41-
Invoker invoker = Utilities.makeLambda(MethodHandles.lookup(), Invoker.class, h);
42-
return manager -> (LoadingCarts) invoker.invoke(manager, function, supplier, "linkart_loading_carts");
43-
}
44-
});
20+
private static final Type<LoadingCarts> TYPE = new Type<>(LoadingCarts::new, (compound, lookup) -> new LoadingCarts().readNbt(compound), null);//thanks, FAPI
4521

4622
public static LoadingCarts getOrCreate(ServerWorld world) {
47-
return GETTER.apply(world.getPersistentStateManager());
23+
return world.getPersistentStateManager().getOrCreate(TYPE, "linkart_loading_carts");
4824
}
4925

5026
private final Set<BlockPos> chunksToReload = new HashSet<>();
5127
private final Set<AbstractMinecartEntity> cartsToBlockPos = new HashSet<>();
5228

5329
@Override
54-
public NbtCompound writeNbt(NbtCompound nbt) {
30+
public NbtCompound writeNbt(NbtCompound nbt, RegistryWrapper.WrapperLookup registryLookup) {
5531
NbtList list = new NbtList();
5632
for (AbstractMinecartEntity minecart : cartsToBlockPos) {
5733
if (!minecart.isRemoved()) list.add(NbtLong.of(minecart.getBlockPos().asLong()));

0 commit comments

Comments
 (0)