Skip to content

Commit

Permalink
migrate: v1.1.8 -> 1.20.3~1.20.4
Browse files Browse the repository at this point in the history
  • Loading branch information
sakurawald committed Dec 24, 2023
1 parent 56b0963 commit 464dc8a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fabric_version=0.91.3+1.20.4
carpet_core_version=1.20.3-1.4.128+v231205
sgui_version=1.4.0+1.20.4
adventure_api_version=4.15.0
adventure_platform_fabric_version=5.10.1
adventure_platform_fabric_version=5.11.0-SNAPSHOT

# common deps
fabric_permissions_version=0.2-SNAPSHOT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void registerCommand(CommandDispatcher<CommandSourceStack> dispatcher, Co

File file = STORAGE_PATH.resolve(getStorageFileName(from)).toFile();
CompoundTag rootTag;
rootTag = NbtIo.read(file);
rootTag = NbtIo.read(file.toPath());
if (rootTag == null) {
source.sendMessage(Component.text("No deathlog found."));
return 0;
Expand Down Expand Up @@ -139,7 +139,7 @@ private String getStorageFileName(String playerName) {

File file = STORAGE_PATH.resolve(getStorageFileName(from)).toFile();
CompoundTag rootTag;
rootTag = NbtIo.read(file);
rootTag = NbtIo.read(file.toPath());

if (rootTag == null) {
ctx.getSource().sendMessage(Component.text("No deathlog found."));
Expand Down Expand Up @@ -185,9 +185,9 @@ public void store(ServerPlayer player) {

CompoundTag rootTag;
if (!file.exists()) {
NbtIo.write(new CompoundTag(), file);
NbtIo.write(new CompoundTag(), file.toPath());
}
rootTag = NbtIo.read(file);
rootTag = NbtIo.read(file.toPath());
if (rootTag == null) return;

ListTag deathsTag;
Expand All @@ -201,7 +201,7 @@ public void store(ServerPlayer player) {
writeRemarkTag(deathTag, player);
deathsTag.add(deathTag);

NbtIo.write(rootTag, file);
NbtIo.write(rootTag, file.toPath());
}

private void writeRemarkTag(CompoundTag deathTag, ServerPlayer player) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftProfileTextures;
import com.mojang.authlib.minecraft.MinecraftSessionService;
import com.mojang.authlib.yggdrasil.ProfileResult;
import eu.pb4.sgui.api.elements.GuiElementBuilder;
Expand Down Expand Up @@ -66,13 +67,14 @@ public void onTick() {
}

GameProfile profile = profileResult.profile();
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> textures = sessionService.getTextures(profile, false);
if (textures.isEmpty()) {

MinecraftProfileTextures textures = sessionService.getTextures(profile);
if (textures == MinecraftProfileTextures.EMPTY) {
outputStack.removeTagKey("SkullOwner");
return;
}

MinecraftProfileTexture texture = textures.get(MinecraftProfileTexture.Type.SKIN);
MinecraftProfileTexture texture = textures.skin();
CompoundTag ownerTag = outputStack.getOrCreateTagElement("SkullOwner");
ownerTag.putUUID("Id", profile.getId());
ownerTag.putString("Name", profile.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(Commands.class)
Expand All @@ -22,14 +23,14 @@ public class CommandsMixin {

// If you issue "///abcdefg", then commandLine = "//abcdefg"
@Inject(method = "performCommand", at = @At("HEAD"), cancellable = true)
public void $performCommand(ParseResults<CommandSourceStack> parseResults, String commandLine, CallbackInfoReturnable<Integer> cir) {
public void $performCommand(ParseResults<CommandSourceStack> parseResults, String string, CallbackInfo ci) {
ServerPlayer player = parseResults.getContext().getSource().getPlayer();
if (player == null) return;

long cooldown = module.calculateCommandCooldown(player, commandLine);
long cooldown = module.calculateCommandCooldown(player, string);
if (cooldown > 0) {
MessageUtil.sendActionBar(player, "command_cooldown.cooldown", cooldown / 1000);
cir.setReturnValue(0);
ci.cancel();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(Commands.class)
Expand All @@ -16,11 +17,11 @@ public class CommandsMixin {

// If you issue "///abcdefg", then commandLine = "//abcdefg"
@Inject(method = "performCommand", at = @At("HEAD"))
public void $performCommand(ParseResults<CommandSourceStack> parseResults, String commandLine, CallbackInfoReturnable<Integer> cir) {
public void $performCommand(ParseResults<CommandSourceStack> parseResults, String string, CallbackInfo ci) {
ServerPlayer player = parseResults.getContext().getSource().getPlayer();
if (player == null) return;

// fix: fabric console will not log the command issue
Fuji.LOGGER.info("{} issued server command: {}", player.getGameProfile().getName(), commandLine);
Fuji.LOGGER.info("{} issued server command: {}", player.getGameProfile().getName(), string);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io.github.sakurawald.module.initializer.resource_world.interfaces.SimpleRegistryMixinInterface;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.ObjectList;
import it.unimi.dsi.fastutil.objects.Reference2IntMap;
import net.minecraft.core.Holder;
import net.minecraft.core.MappedRegistry;
import net.minecraft.resources.ResourceKey;
Expand Down Expand Up @@ -45,7 +46,8 @@ public abstract class SimpleRegistryMixin<T> implements SimpleRegistryMixinInter

@Shadow
@Final
private Object2IntMap<T> toId;
private Reference2IntMap<T> toId;

@Shadow
private boolean frozen;
@Shadow
Expand Down

0 comments on commit 464dc8a

Please sign in to comment.