Skip to content

Commit d8abbb3

Browse files
Update to 1.21.6 (#62)
1 parent d148ac6 commit d8abbb3

File tree

9 files changed

+77
-56
lines changed

9 files changed

+77
-56
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ dependencies {
5151
// modImplementation "dev.emi:trinkets:${project.trinkets_version}"
5252
// modImplementation "com.github.apace100:apoli:${project.apoli_version}"
5353

54-
modImplementation "me.lucko:fabric-permissions-api:0.2-SNAPSHOT"
55-
include "me.lucko:fabric-permissions-api:0.2-SNAPSHOT"
54+
modImplementation "me.lucko:fabric-permissions-api:0.4.0"
55+
include "me.lucko:fabric-permissions-api:0.4.0"
5656

5757
// Dev Mods - These can be commented/uncommented to test compatibility
5858
//modLocalRuntime "maven.modrinth:cloth-config:9.0.94+fabric"

gradle.properties

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
org.gradle.jvmargs=-Xmx1G
33
# Fabric Properties
44
# check these on https://fabricmc.net/develop/
5-
minecraft_version=1.21.5
6-
yarn_mappings=1.21.5+build.1
7-
loader_version=0.16.11
5+
minecraft_version=1.21.6
6+
yarn_mappings=1.21.6+build.1
7+
loader_version=0.16.14
88
# Mod Properties
9-
mod_version=1.4.16
9+
mod_version=1.4.17
1010
maven_group=us.potatoboy
1111
archives_base_name=InvView
1212
# Dependencies
1313
# check this on https://fabricmc.net/develop/
14-
fabric_version=0.119.6+1.21.5
15-
trinkets_version=3.10.0
16-
apoli_version=2.11.11
17-
sgui_version=1.9.0+1.21.5
14+
fabric_version=0.127.1+1.21.6
15+
# trinkets_version=3.10.0
16+
# apoli_version=2.12.0
17+
sgui_version=1.10.0+1.21.6

gradle/wrapper/gradle-wrapper.jar

302 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.13-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -55,7 +57,7 @@
5557
# Darwin, MinGW, and NonStop.
5658
#
5759
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
60+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5961
# within the Gradle project.
6062
#
6163
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,7 @@ done
8486
# shellcheck disable=SC2034
8587
APP_BASE_NAME=${0##*/}
8688
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87-
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
8890

8991
# Use the maximum available, or set MAX_FD != -1 to use that value.
9092
MAX_FD=maximum
@@ -112,7 +114,7 @@ case "$( uname )" in #(
112114
NONSTOP* ) nonstop=true ;;
113115
esac
114116

115-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
117+
CLASSPATH="\\\"\\\""
116118

117119

118120
# Determine the Java command to use to start the JVM.
@@ -203,15 +205,15 @@ fi
203205
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204206

205207
# Collect all arguments for the java command:
206-
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
208+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207209
# and any embedded shellness will be escaped.
208210
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209211
# treated as '${Hostname}' itself on the command line.
210212

211213
set -- \
212214
"-Dorg.gradle.appname=$APP_BASE_NAME" \
213215
-classpath "$CLASSPATH" \
214-
org.gradle.wrapper.GradleWrapperMain \
216+
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
215217
"$@"
216218

217219
# Stop when "xargs" is not available.

gradlew.bat

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
@rem See the License for the specific language governing permissions and
1414
@rem limitations under the License.
1515
@rem
16+
@rem SPDX-License-Identifier: Apache-2.0
17+
@rem
1618

1719
@if "%DEBUG%"=="" @echo off
1820
@rem ##########################################################################
@@ -68,11 +70,11 @@ goto fail
6870
:execute
6971
@rem Setup the command line
7072

71-
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73+
set CLASSPATH=
7274

7375

7476
@rem Execute Gradle
75-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
77+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
7678

7779
:end
7880
@rem End local scope for the variables with windows NT shell

src/main/java/us/potatoboy/invview/InvView.java

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package us.potatoboy.invview;
22

33
import com.mojang.brigadier.tree.LiteralCommandNode;
4+
import com.mojang.logging.LogUtils;
5+
46
import me.lucko.fabric.api.permissions.v0.Permissions;
57
import net.fabricmc.api.ModInitializer;
68
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
@@ -13,12 +15,14 @@
1315
import net.minecraft.server.command.CommandManager;
1416
import net.minecraft.server.command.ServerCommandSource;
1517
import net.minecraft.server.network.ServerPlayerEntity;
18+
import net.minecraft.storage.NbtWriteView;
19+
import net.minecraft.util.ErrorReporter;
1620
import net.minecraft.util.Util;
1721
import net.minecraft.util.WorldSavePath;
18-
import org.apache.logging.log4j.LogManager;
1922

2023
import java.io.File;
21-
import java.io.FileOutputStream;
24+
import java.nio.file.Files;
25+
import java.nio.file.Path;
2226

2327
public class InvView implements ModInitializer {
2428
private static MinecraftServer minecraftServer;
@@ -90,18 +94,21 @@ public static MinecraftServer getMinecraftServer() {
9094
return minecraftServer;
9195
}
9296

97+
// Taken from net.minecraft.world.PlayerSaveHandler.savePlayerData(), which is a protected method
9398
public static void savePlayerData(ServerPlayerEntity player) {
94-
File playerDataDir = minecraftServer.getSavePath(WorldSavePath.PLAYERDATA).toFile();
95-
try {
96-
NbtCompound compoundTag = player.writeNbt(new NbtCompound());
97-
File file = File.createTempFile(player.getUuidAsString() + "-", ".dat", playerDataDir);
98-
final FileOutputStream fos = new FileOutputStream(file);
99-
NbtIo.writeCompressed(compoundTag, fos);
100-
File file2 = new File(playerDataDir, player.getUuidAsString() + ".dat");
101-
File file3 = new File(playerDataDir, player.getUuidAsString() + ".dat_old");
102-
Util.backupAndReplace(file2.toPath(), file.toPath(), file3.toPath());
103-
} catch (Exception var6) {
104-
LogManager.getLogger().warn("Failed to save player data for {}", player.getName().getString());
105-
}
106-
}
99+
File playerDataDir = minecraftServer.getSavePath(WorldSavePath.PLAYERDATA).toFile();
100+
try (ErrorReporter.Logging logging = new ErrorReporter.Logging(player.getErrorReporterContext(), LogUtils.getLogger())) {
101+
NbtWriteView nbtWriteView = NbtWriteView.create(logging, player.getRegistryManager());
102+
player.writeData(nbtWriteView);
103+
Path path = playerDataDir.toPath();
104+
Path path2 = Files.createTempFile(path, player.getUuidAsString() + "-", ".dat");
105+
NbtCompound nbtCompound = nbtWriteView.getNbt();
106+
NbtIo.writeCompressed(nbtCompound, path2);
107+
Path path3 = path.resolve(player.getUuidAsString() + ".dat");
108+
Path path4 = path.resolve(player.getUuidAsString() + ".dat_old");
109+
Util.backupAndReplace(path3, path2, path4);
110+
} catch (Exception var11) {
111+
LogUtils.getLogger().warn("Failed to save player data for {}", player.getName().getString());
112+
}
113+
}
107114
}

src/main/java/us/potatoboy/invview/ViewCommand.java

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,26 @@
33
import com.mojang.authlib.GameProfile;
44
import com.mojang.brigadier.context.CommandContext;
55
import com.mojang.brigadier.exceptions.CommandSyntaxException;
6-
import com.mojang.serialization.Dynamic;
6+
import com.mojang.logging.LogUtils;
77
import eu.pb4.sgui.api.elements.GuiElementBuilder;
88
import eu.pb4.sgui.api.gui.SimpleGui;
99
import me.lucko.fabric.api.permissions.v0.Permissions;
1010
import net.minecraft.command.argument.GameProfileArgumentType;
1111
import net.minecraft.inventory.EnderChestInventory;
1212
import net.minecraft.item.Items;
13-
import net.minecraft.nbt.NbtCompound;
14-
import net.minecraft.nbt.NbtOps;
1513
import net.minecraft.network.packet.c2s.common.SyncedClientOptions;
14+
import net.minecraft.registry.RegistryKey;
15+
import net.minecraft.registry.RegistryKeys;
1616
import net.minecraft.screen.ScreenHandlerType;
1717
import net.minecraft.screen.slot.Slot;
1818
import net.minecraft.server.MinecraftServer;
1919
import net.minecraft.server.command.ServerCommandSource;
2020
import net.minecraft.server.network.ServerPlayerEntity;
2121
import net.minecraft.server.world.ServerWorld;
22+
import net.minecraft.storage.ReadView;
2223
import net.minecraft.text.Text;
23-
import net.minecraft.world.dimension.DimensionType;
24+
import net.minecraft.util.ErrorReporter;
25+
import net.minecraft.util.Identifier;
2426
import us.potatoboy.invview.gui.SavingPlayerDataGui;
2527
import us.potatoboy.invview.gui.UnmodifiableSlot;
2628
import us.potatoboy.invview.mixin.EntityAccessor;
@@ -48,7 +50,8 @@ public static int inv(CommandContext<ServerCommandSource> context) throws Comman
4850
gui.setTitle(requestedPlayer.getName());
4951
addBackground(gui);
5052
for (int i = 0; i < requestedPlayer.getInventory().size(); i++) {
51-
gui.setSlotRedirect(i, canModify ? new Slot(requestedPlayer.getInventory(), i, 0, 0) : new UnmodifiableSlot(requestedPlayer.getInventory(), i));
53+
gui.setSlotRedirect(i, canModify ? new Slot(requestedPlayer.getInventory(), i, 0, 0)
54+
: new UnmodifiableSlot(requestedPlayer.getInventory(), i));
5255
}
5356

5457
gui.open();
@@ -69,19 +72,20 @@ public static int eChest(CommandContext<ServerCommandSource> context) throws Com
6972
if (isProtected) {
7073
context.getSource().sendError(Text.literal(msgProtected));
7174
} else {
72-
ScreenHandlerType<?> screenHandlerType = switch (requestedEchest.size()) {
73-
case 9 -> ScreenHandlerType.GENERIC_9X1;
74-
case 18 -> ScreenHandlerType.GENERIC_9X2;
75-
case 36 -> ScreenHandlerType.GENERIC_9X4;
76-
case 45 -> ScreenHandlerType.GENERIC_9X5;
77-
case 54 -> ScreenHandlerType.GENERIC_9X6;
78-
default -> ScreenHandlerType.GENERIC_9X3;
79-
};
75+
ScreenHandlerType<?> screenHandlerType = switch (requestedEchest.size()) {
76+
case 9 -> ScreenHandlerType.GENERIC_9X1;
77+
case 18 -> ScreenHandlerType.GENERIC_9X2;
78+
case 36 -> ScreenHandlerType.GENERIC_9X4;
79+
case 45 -> ScreenHandlerType.GENERIC_9X5;
80+
case 54 -> ScreenHandlerType.GENERIC_9X6;
81+
default -> ScreenHandlerType.GENERIC_9X3;
82+
};
8083
SimpleGui gui = new SavingPlayerDataGui(screenHandlerType, player, requestedPlayer);
8184
gui.setTitle(requestedPlayer.getName());
8285
addBackground(gui);
8386
for (int i = 0; i < requestedEchest.size(); i++) {
84-
gui.setSlotRedirect(i, canModify ? new Slot(requestedEchest, i, 0, 0) : new UnmodifiableSlot(requestedEchest, i));
87+
gui.setSlotRedirect(i,
88+
canModify ? new Slot(requestedEchest, i, 0, 0) : new UnmodifiableSlot(requestedEchest, i));
8589
}
8690

8791
gui.open();
@@ -161,15 +165,21 @@ private static ServerPlayerEntity getRequestedPlayer(CommandContext<ServerComman
161165
GameProfile requestedProfile = GameProfileArgumentType.getProfileArgument(context, "target").iterator().next();
162166
ServerPlayerEntity requestedPlayer = minecraftServer.getPlayerManager().getPlayer(requestedProfile.getName());
163167

168+
// If player is not currently online
164169
if (requestedPlayer == null) {
165-
requestedPlayer = minecraftServer.getPlayerManager().createPlayer(requestedProfile, SyncedClientOptions.createDefault());
166-
Optional<NbtCompound> compoundOpt = minecraftServer.getPlayerManager().loadPlayerData(requestedPlayer);
167-
if (compoundOpt.isPresent()) {
168-
NbtCompound compound = compoundOpt.get();
169-
if (compound.contains("Dimension")) {
170+
requestedPlayer = new ServerPlayerEntity(minecraftServer, minecraftServer.getOverworld(), requestedProfile,
171+
SyncedClientOptions.createDefault());
172+
Optional<ReadView> readViewOpt = minecraftServer.getPlayerManager()
173+
.loadPlayerData(requestedPlayer, new ErrorReporter.Logging(LogUtils.getLogger()));
174+
175+
// Avoids player's dimension being reset to the overworld
176+
if (readViewOpt.isPresent()) {
177+
ReadView readView = readViewOpt.get();
178+
Optional<String> dimension = readView.getOptionalString("Dimension");
179+
180+
if (dimension.isPresent()) {
170181
ServerWorld world = minecraftServer.getWorld(
171-
DimensionType.worldFromDimensionNbt(new Dynamic<>(NbtOps.INSTANCE, compound.get("Dimension")))
172-
.result().get());
182+
RegistryKey.of(RegistryKeys.WORLD, Identifier.tryParse(dimension.get())));
173183

174184
if (world != null) {
175185
((EntityAccessor) requestedPlayer).callSetWorld(world);

src/main/resources/fabric.mod.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@
3434
"depends": {
3535
"fabricloader": ">=0.15.10",
3636
"fabric": "*",
37-
"minecraft": ">=1.21.5"
37+
"minecraft": ">=1.21.6"
3838
}
39-
}
39+
}

0 commit comments

Comments
 (0)