diff --git a/common/src/main/java/io/github/flemmli97/flan/claim/Claim.java b/common/src/main/java/io/github/flemmli97/flan/claim/Claim.java index ab27094..6690a6d 100644 --- a/common/src/main/java/io/github/flemmli97/flan/claim/Claim.java +++ b/common/src/main/java/io/github/flemmli97/flan/claim/Claim.java @@ -21,8 +21,6 @@ import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.network.protocol.game.ClientboundSetSubtitleTextPacket; import net.minecraft.network.protocol.game.ClientboundSetTitleTextPacket; import net.minecraft.resources.ResourceLocation; @@ -98,9 +96,9 @@ public class Claim implements IPermissionContainer { } this.claimName = name; if (!ConfigHandler.config.defaultEnterMessage.isEmpty()) - this.enterTitle = new TextComponent(String.format(ConfigHandler.config.defaultEnterMessage, this.claimName)); + this.enterTitle = Component.literal(String.format(ConfigHandler.config.defaultEnterMessage, this.claimName)); if (!ConfigHandler.config.defaultLeaveMessage.isEmpty()) - this.leaveTitle = new TextComponent(String.format(ConfigHandler.config.defaultLeaveMessage, this.claimName)); + this.leaveTitle = Component.literal(String.format(ConfigHandler.config.defaultLeaveMessage, this.claimName)); } public Claim(BlockPos pos1, BlockPos pos2, UUID creator, ServerLevel world) { @@ -830,16 +828,16 @@ public class Claim implements IPermissionContainer { } private static Component fromPermissionMap(String lang, Map map) { - MutableComponent mapComp = new TextComponent("[").withStyle(ChatFormatting.GRAY); + MutableComponent mapComp = Component.literal("[").withStyle(ChatFormatting.GRAY); int i = 0; for (Map.Entry entry : map.entrySet()) { - MutableComponent pComp = new TextComponent((i != 0 ? ", " : "") + entry.getKey().id + "=").withStyle(ChatFormatting.GRAY); - pComp.append(new TextComponent(entry.getValue().toString()).withStyle(entry.getValue() ? ChatFormatting.GREEN : ChatFormatting.RED)); + MutableComponent pComp = Component.literal((i != 0 ? ", " : "") + entry.getKey().id + "=").withStyle(ChatFormatting.GRAY); + pComp.append(Component.literal(entry.getValue().toString()).withStyle(entry.getValue() ? ChatFormatting.GREEN : ChatFormatting.RED)); mapComp.append(pComp); i++; } mapComp.append("]"); - MutableComponent component = new TranslatableComponent(ConfigHandler.langManager.get(lang), mapComp).withStyle(ChatFormatting.DARK_BLUE); + MutableComponent component = Component.translatable(ConfigHandler.langManager.get(lang), mapComp).withStyle(ChatFormatting.DARK_BLUE); return component; } diff --git a/common/src/main/java/io/github/flemmli97/flan/claim/ClaimStorage.java b/common/src/main/java/io/github/flemmli97/flan/claim/ClaimStorage.java index b7ca756..342685b 100644 --- a/common/src/main/java/io/github/flemmli97/flan/claim/ClaimStorage.java +++ b/common/src/main/java/io/github/flemmli97/flan/claim/ClaimStorage.java @@ -28,9 +28,9 @@ import net.minecraft.commands.CommandSourceStack; import net.minecraft.core.BlockPos; import net.minecraft.core.SectionPos; import net.minecraft.network.chat.ClickEvent; +import net.minecraft.network.chat.Component; import net.minecraft.network.chat.HoverEvent; import net.minecraft.network.chat.MutableComponent; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.resources.ResourceKey; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; @@ -465,7 +465,7 @@ public class ClaimStorage implements IPermissionStorage { for (Claim claim : conflicts) { int[] dim = claim.getDimensions(); MutableComponent text = PermHelper.simpleColoredText(String.format("@[x=%d;z=%d]", dim[0], dim[2]), ChatFormatting.RED); - text.setStyle(text.getStyle().withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/tp @s " + dim[0] + " ~ " + dim[2])).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableComponent("chat.coordinates.tooltip")))); + text.setStyle(text.getStyle().withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/tp @s " + dim[0] + " ~ " + dim[2])).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.translatable("chat.coordinates.tooltip")))); src.sendSuccess(text, false); } } diff --git a/common/src/main/java/io/github/flemmli97/flan/claim/PermHelper.java b/common/src/main/java/io/github/flemmli97/flan/claim/PermHelper.java index d8af96b..11b01ff 100644 --- a/common/src/main/java/io/github/flemmli97/flan/claim/PermHelper.java +++ b/common/src/main/java/io/github/flemmli97/flan/claim/PermHelper.java @@ -4,9 +4,9 @@ import io.github.flemmli97.flan.api.permission.ClaimPermission; import io.github.flemmli97.flan.config.ConfigHandler; import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.Style; -import net.minecraft.network.chat.TextComponent; import net.minecraft.server.level.ServerPlayer; import java.util.Optional; @@ -31,7 +31,7 @@ public class PermHelper { } public static void noClaimMessage(ServerPlayer player) { - player.displayClientMessage(new TextComponent(ConfigHandler.langManager.get("noClaim")).setStyle(Style.EMPTY.applyFormat(ChatFormatting.DARK_RED)), false); + player.displayClientMessage(Component.literal(ConfigHandler.langManager.get("noClaim")).setStyle(Style.EMPTY.applyFormat(ChatFormatting.DARK_RED)), false); } public static Consumer> genericNoPermMessage(ServerPlayer player) { @@ -44,6 +44,6 @@ public class PermHelper { } public static MutableComponent simpleColoredText(String text, ChatFormatting... formatting) { - return new TextComponent(text).setStyle(formatting != null ? Style.EMPTY.applyFormats(formatting) : Style.EMPTY); + return Component.literal(text).setStyle(formatting != null ? Style.EMPTY.applyFormats(formatting) : Style.EMPTY); } } diff --git a/common/src/main/java/io/github/flemmli97/flan/commands/CommandClaim.java b/common/src/main/java/io/github/flemmli97/flan/commands/CommandClaim.java index 222d164..09b6537 100644 --- a/common/src/main/java/io/github/flemmli97/flan/commands/CommandClaim.java +++ b/common/src/main/java/io/github/flemmli97/flan/commands/CommandClaim.java @@ -35,8 +35,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.Style; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; @@ -640,7 +638,6 @@ public class CommandClaim { private static int editGlobalPerm(CommandContext context) throws CommandSyntaxException { int mode = switch (StringArgumentType.getString(context, "toggle")) { case "true" -> 1; - case "false" -> 0; case "default" -> -1; default -> 0; }; @@ -650,7 +647,6 @@ public class CommandClaim { private static int editGroupPerm(CommandContext context) throws CommandSyntaxException { int mode = switch (StringArgumentType.getString(context, "toggle")) { case "true" -> 1; - case "false" -> 0; case "default" -> -1; default -> 0; }; @@ -700,7 +696,6 @@ public class CommandClaim { String group = StringArgumentType.getString(context, "group"); int mode = switch (StringArgumentType.getString(context, "toggle")) { case "true" -> 1; - case "false" -> 0; case "default" -> -1; default -> 0; }; @@ -762,7 +757,7 @@ public class CommandClaim { } public static int editClaimMessages(CommandContext context) throws CommandSyntaxException { - return editClaimMessages(context, new TextComponent(StringArgumentType.getString(context, "message"))); + return editClaimMessages(context, Component.literal(StringArgumentType.getString(context, "message"))); } public static int editClaimMessages(CommandContext context, Component text) throws CommandSyntaxException { @@ -798,7 +793,7 @@ public class CommandClaim { feedback = ConfigHandler.langManager.get("setLeaveMessage"); } } - MutableComponent cmdFeed = new TranslatableComponent(feedback, text).withStyle(ChatFormatting.GOLD); + MutableComponent cmdFeed = Component.translatable(feedback, text).withStyle(ChatFormatting.GOLD); context.getSource().sendSuccess(cmdFeed, false); return Command.SINGLE_SUCCESS; } diff --git a/common/src/main/java/io/github/flemmli97/flan/config/BuySellHandler.java b/common/src/main/java/io/github/flemmli97/flan/config/BuySellHandler.java index bd13809..9124b93 100644 --- a/common/src/main/java/io/github/flemmli97/flan/config/BuySellHandler.java +++ b/common/src/main/java/io/github/flemmli97/flan/config/BuySellHandler.java @@ -8,7 +8,6 @@ import io.github.flemmli97.flan.player.PlayerClaimData; import net.minecraft.ChatFormatting; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.server.level.ServerPlayer; import net.minecraft.util.Mth; import net.minecraft.world.entity.item.ItemEntity; @@ -139,7 +138,7 @@ public class BuySellHandler { } } data.setAdditionalClaims(data.getAdditionalClaims() - blocks); - message.accept(new TranslatableComponent(ConfigHandler.langManager.get("sellSuccessItem"), blocks, amount, new TranslatableComponent(stack.getDescriptionId()).withStyle(ChatFormatting.AQUA))); + message.accept(Component.translatable(ConfigHandler.langManager.get("sellSuccessItem"), blocks, amount, Component.translatable(stack.getDescriptionId()).withStyle(ChatFormatting.AQUA))); return true; } case XP -> { diff --git a/common/src/main/java/io/github/flemmli97/flan/gui/ClaimTextHandler.java b/common/src/main/java/io/github/flemmli97/flan/gui/ClaimTextHandler.java index e01229d..5414e9b 100644 --- a/common/src/main/java/io/github/flemmli97/flan/gui/ClaimTextHandler.java +++ b/common/src/main/java/io/github/flemmli97/flan/gui/ClaimTextHandler.java @@ -9,8 +9,8 @@ import io.github.flemmli97.flan.gui.inv.SeparateInv; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.ClickEvent; import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.Style; -import net.minecraft.network.chat.TextComponent; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.MenuProvider; @@ -132,7 +132,7 @@ public class ClaimTextHandler extends ServerOnlyScreenHandler { if (clickType == 0) { player.getServer().execute(() -> StringResultScreenHandler.createNewStringResult(player, (s) -> { player.closeContainer(); - finalCons.accept(new TextComponent(s).withStyle(Style.EMPTY.withItalic(false).applyFormat(ChatFormatting.WHITE))); + finalCons.accept(Component.literal(s).withStyle(Style.EMPTY.withItalic(false).applyFormat(ChatFormatting.WHITE))); player.getServer().execute(() -> ClaimTextHandler.openClaimMenu(player, this.claim)); ServerScreenHelper.playSongToPlayer(player, SoundEvents.ANVIL_USE, 1, 1f); }, () -> { @@ -141,7 +141,7 @@ public class ClaimTextHandler extends ServerOnlyScreenHandler { ServerScreenHelper.playSongToPlayer(player, SoundEvents.VILLAGER_NO, 1, 1f); })); } else { - TextComponent text = new TextComponent(ConfigHandler.langManager.get("chatClaimTextEdit")); + MutableComponent text = Component.literal(ConfigHandler.langManager.get("chatClaimTextEdit")); String command = "/flan claimMessage" + (index == 2 || index == 3 ? " enter" : " leave") + (index == 2 || index == 4 ? " title" : " subtitle") + " text "; text.withStyle(Style.EMPTY.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command))); diff --git a/common/src/main/java/io/github/flemmli97/flan/gui/GroupScreenHandler.java b/common/src/main/java/io/github/flemmli97/flan/gui/GroupScreenHandler.java index 59d368b..55db3b1 100644 --- a/common/src/main/java/io/github/flemmli97/flan/gui/GroupScreenHandler.java +++ b/common/src/main/java/io/github/flemmli97/flan/gui/GroupScreenHandler.java @@ -113,7 +113,7 @@ public class GroupScreenHandler extends ServerOnlyScreenHandler { } ItemStack stack = slot.getItem(); if (!stack.isEmpty()) { - String name = stack.getHoverName().getContents(); + String name = stack.getHoverName().getString(); if (this.removeMode) { this.claim.removePermGroup(player, name); slot.set(ItemStack.EMPTY); diff --git a/common/src/main/java/io/github/flemmli97/flan/gui/PermissionScreenHandler.java b/common/src/main/java/io/github/flemmli97/flan/gui/PermissionScreenHandler.java index 5195dff..ce1247d 100644 --- a/common/src/main/java/io/github/flemmli97/flan/gui/PermissionScreenHandler.java +++ b/common/src/main/java/io/github/flemmli97/flan/gui/PermissionScreenHandler.java @@ -143,7 +143,7 @@ public class PermissionScreenHandler extends ServerOnlyScreenHandler ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f); } ItemStack stack = slot.getItem(); - String name = stack.getHoverName().getContents(); + String name = stack.getHoverName().getString(); ClaimPermission perm; try { perm = PermissionRegistry.get(name); diff --git a/common/src/main/java/io/github/flemmli97/flan/gui/PersonalGroupScreenHandler.java b/common/src/main/java/io/github/flemmli97/flan/gui/PersonalGroupScreenHandler.java index 1fa30c5..2f17535 100644 --- a/common/src/main/java/io/github/flemmli97/flan/gui/PersonalGroupScreenHandler.java +++ b/common/src/main/java/io/github/flemmli97/flan/gui/PersonalGroupScreenHandler.java @@ -113,7 +113,7 @@ public class PersonalGroupScreenHandler extends ServerOnlyScreenHandler } ItemStack stack = slot.getItem(); if (!stack.isEmpty()) { - String name = stack.getHoverName().getContents(); + String name = stack.getHoverName().getString(); if (this.removeMode) { PlayerClaimData.get(player).playerDefaultGroups().remove(name); slot.set(ItemStack.EMPTY); diff --git a/common/src/main/java/io/github/flemmli97/flan/gui/PersonalPermissionScreenHandler.java b/common/src/main/java/io/github/flemmli97/flan/gui/PersonalPermissionScreenHandler.java index d2cd4d1..b6cb2d3 100644 --- a/common/src/main/java/io/github/flemmli97/flan/gui/PersonalPermissionScreenHandler.java +++ b/common/src/main/java/io/github/flemmli97/flan/gui/PersonalPermissionScreenHandler.java @@ -141,7 +141,7 @@ public class PersonalPermissionScreenHandler extends ServerOnlyScreenHandler { if (id < potions.size()) { MobEffect effect = key.get(id); ItemStack effectStack = new ItemStack(Items.POTION); - TranslatableComponent txt = new TranslatableComponent(effect.getDescriptionId()); + MutableComponent txt = Component.translatable(effect.getDescriptionId()); Collection inst = Collections.singleton(new MobEffectInstance(effect, 0, potions.get(effect))); effectStack.getOrCreateTag().putString("FlanEffect", CrossPlatformStuff.INSTANCE.registryStatusEffects().getIDFrom(effect).toString()); effectStack.getTag().putInt("CustomPotionColor", PotionUtils.getColor(inst)); diff --git a/common/src/main/java/io/github/flemmli97/flan/gui/ServerScreenHelper.java b/common/src/main/java/io/github/flemmli97/flan/gui/ServerScreenHelper.java index 8476b11..62ee6d2 100644 --- a/common/src/main/java/io/github/flemmli97/flan/gui/ServerScreenHelper.java +++ b/common/src/main/java/io/github/flemmli97/flan/gui/ServerScreenHelper.java @@ -11,7 +11,6 @@ import net.minecraft.nbt.ListTag; import net.minecraft.nbt.StringTag; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Style; -import net.minecraft.network.chat.TextComponent; import net.minecraft.network.protocol.game.ClientboundSoundPacket; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; @@ -104,11 +103,11 @@ public class ServerScreenHelper { public static void playSongToPlayer(ServerPlayer player, SoundEvent event, float vol, float pitch) { player.connection.send( - new ClientboundSoundPacket(event, SoundSource.PLAYERS, player.position().x, player.position().y, player.position().z, vol, pitch)); + new ClientboundSoundPacket(event, SoundSource.PLAYERS, player.position().x, player.position().y, player.position().z, vol, pitch, player.level.getRandom().nextLong())); } public static Component coloredGuiText(String text, ChatFormatting... formattings) { - return new TextComponent(text).setStyle(Style.EMPTY.withItalic(false).applyFormats(formattings)); + return Component.literal(text).setStyle(Style.EMPTY.withItalic(false).applyFormats(formattings)); } public static void addLore(ItemStack stack, Component text) { diff --git a/common/src/main/java/io/github/flemmli97/flan/gui/StringResultScreenHandler.java b/common/src/main/java/io/github/flemmli97/flan/gui/StringResultScreenHandler.java index 1feeb85..c9712d2 100644 --- a/common/src/main/java/io/github/flemmli97/flan/gui/StringResultScreenHandler.java +++ b/common/src/main/java/io/github/flemmli97/flan/gui/StringResultScreenHandler.java @@ -79,7 +79,7 @@ public class StringResultScreenHandler extends AnvilMenu { if (i == 0) this.ret.run(); else if (i == 2) { - String s = slot.getItem().hasCustomHoverName() ? slot.getItem().getHoverName().getContents() : ""; + String s = slot.getItem().hasCustomHoverName() ? slot.getItem().getHoverName().getString() : ""; if (!s.isEmpty() && !s.equals(ConfigHandler.langManager.get("stringScreenReturn"))) { this.cons.accept(s); } @@ -96,7 +96,7 @@ public class StringResultScreenHandler extends AnvilMenu { this.ret.run(); else if (index == 2) { Slot slot = this.slots.get(index); - String s = slot.getItem().hasCustomHoverName() ? slot.getItem().getHoverName().getContents() : ""; + String s = slot.getItem().hasCustomHoverName() ? slot.getItem().getHoverName().getString() : ""; if (!s.isEmpty() && !s.equals(ConfigHandler.langManager.get("stringScreenReturn"))) this.cons.accept(s); ((ServerPlayer) player).connection.send(new ClientboundSetExperiencePacket(player.experienceProgress, player.totalExperience, player.experienceLevel)); diff --git a/common/src/main/java/io/github/flemmli97/flan/mixin/FireBlockMixin.java b/common/src/main/java/io/github/flemmli97/flan/mixin/FireBlockMixin.java index 26e35e7..6586d62 100644 --- a/common/src/main/java/io/github/flemmli97/flan/mixin/FireBlockMixin.java +++ b/common/src/main/java/io/github/flemmli97/flan/mixin/FireBlockMixin.java @@ -3,6 +3,7 @@ package io.github.flemmli97.flan.mixin; import io.github.flemmli97.flan.event.WorldEvents; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.RandomSource; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.FireBlock; import net.minecraft.world.level.block.state.BlockState; @@ -12,8 +13,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import java.util.Random; - @Mixin(FireBlock.class) public abstract class FireBlockMixin { @@ -21,7 +20,7 @@ public abstract class FireBlockMixin { * Stop ticking overall if fire is in claim */ @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;getGameRules()Lnet/minecraft/world/level/GameRules;"), cancellable = true) - private void tick(BlockState state, ServerLevel world, BlockPos pos, Random random, CallbackInfo info) { + private void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random, CallbackInfo info) { if (!WorldEvents.canFireSpread(world, pos)) { info.cancel(); } @@ -30,7 +29,7 @@ public abstract class FireBlockMixin { /** * Check if fire can spread to this block */ - @Inject(method = "getFireOdds", at = @At(value = "HEAD"), cancellable = true) + @Inject(method = "getIgniteOdds(Lnet/minecraft/world/level/LevelReader;Lnet/minecraft/core/BlockPos;)I", at = @At(value = "HEAD"), cancellable = true) private void burn(LevelReader worldView, BlockPos pos, CallbackInfoReturnable info) { if (worldView instanceof ServerLevel && !WorldEvents.canFireSpread((ServerLevel) worldView, pos)) { info.setReturnValue(0); diff --git a/fabric/src/main/java/io/github/flemmli97/flan/fabric/FlanFabric.java b/fabric/src/main/java/io/github/flemmli97/flan/fabric/FlanFabric.java index 0dc31bb..e1f1a13 100644 --- a/fabric/src/main/java/io/github/flemmli97/flan/fabric/FlanFabric.java +++ b/fabric/src/main/java/io/github/flemmli97/flan/fabric/FlanFabric.java @@ -13,7 +13,7 @@ import io.github.flemmli97.flan.platform.integration.dynmap.DynmapIntegration; import io.github.flemmli97.flan.player.PlayerDataHandler; import io.github.flemmli97.flan.scoreboard.ClaimCriterias; import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback; +import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; import net.fabricmc.fabric.api.event.Event; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; @@ -25,6 +25,7 @@ import net.fabricmc.fabric.api.event.player.UseEntityCallback; import net.fabricmc.fabric.api.event.player.UseItemCallback; import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.commands.Commands; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; @@ -52,7 +53,7 @@ public class FlanFabric implements ModInitializer { ServerLifecycleEvents.SERVER_STARTED.register(FlanFabric::serverFinishLoad); ServerTickEvents.START_SERVER_TICK.register(WorldEvents::serverTick); ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> PlayerEvents.onLogout(handler.player)); - CommandRegistrationCallback.EVENT.register(CommandClaim::register); + CommandRegistrationCallback.EVENT.register((dispatcher, reg, env) -> CommandClaim.register(dispatcher, env == Commands.CommandSelection.DEDICATED)); Flan.permissionAPI = FabricLoader.getInstance().isModLoaded("fabric-permissions-api-v0"); Flan.gunpowder = FabricLoader.getInstance().isModLoaded("gunpowder-currency"); diff --git a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/FabricFireMixin.java b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/FabricFireMixin.java index 015a34e..535ec14 100644 --- a/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/FabricFireMixin.java +++ b/fabric/src/main/java/io/github/flemmli97/flan/fabric/mixin/FabricFireMixin.java @@ -3,6 +3,7 @@ package io.github.flemmli97.flan.fabric.mixin; import io.github.flemmli97.flan.event.WorldEvents; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.RandomSource; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.FireBlock; import org.spongepowered.asm.mixin.Mixin; @@ -10,8 +11,6 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.Random; - @Mixin(FireBlock.class) public abstract class FabricFireMixin { @@ -19,7 +18,7 @@ public abstract class FabricFireMixin { * Check for blocks reacting to fire (e.g. tnt) */ @Inject(method = "checkBurnOut", at = @At(value = "HEAD"), cancellable = true) - private void spread(Level world, BlockPos pos, int spreadFactor, Random rand, int currentAge, CallbackInfo info) { + private void spread(Level world, BlockPos pos, int spreadFactor, RandomSource rand, int currentAge, CallbackInfo info) { if (!world.isClientSide && !WorldEvents.canFireSpread((ServerLevel) world, pos)) { info.cancel(); } diff --git a/fabric/src/main/java/io/github/flemmli97/flan/fabric/platform/integration/currency/CommandCurrencyImpl.java b/fabric/src/main/java/io/github/flemmli97/flan/fabric/platform/integration/currency/CommandCurrencyImpl.java index 54eb18a..547ef03 100644 --- a/fabric/src/main/java/io/github/flemmli97/flan/fabric/platform/integration/currency/CommandCurrencyImpl.java +++ b/fabric/src/main/java/io/github/flemmli97/flan/fabric/platform/integration/currency/CommandCurrencyImpl.java @@ -8,14 +8,11 @@ import io.github.flemmli97.flan.claim.PermHelper; import io.github.flemmli97.flan.config.ConfigHandler; import io.github.flemmli97.flan.platform.integration.currency.CommandCurrency; import io.github.flemmli97.flan.player.PlayerClaimData; -import io.github.gunpowder.entities.StoredBalance; -import io.github.gunpowder.modelhandlers.BalanceHandler; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; -import java.math.BigDecimal; import java.util.function.Consumer; public class CommandCurrencyImpl implements CommandCurrency { @@ -29,7 +26,7 @@ public class CommandCurrencyImpl implements CommandCurrency { return false; } if (Flan.gunpowder) { - PlayerClaimData data = PlayerClaimData.get(player); + /*PlayerClaimData data = PlayerClaimData.get(player); if (data.getAdditionalClaims() - Math.max(0, data.usedClaimBlocks() - data.getClaimBlocks()) < blocks) { message.accept(PermHelper.simpleColoredText(ConfigHandler.langManager.get("sellFail"), ChatFormatting.DARK_RED)); return false; @@ -40,7 +37,8 @@ public class CommandCurrencyImpl implements CommandCurrency { BalanceHandler.INSTANCE.updateUser(bal); data.setAdditionalClaims(data.getAdditionalClaims() - blocks); message.accept(PermHelper.simpleColoredText(String.format(ConfigHandler.langManager.get("sellSuccess"), blocks, price), ChatFormatting.GOLD)); - return true; + return true;*/ + return false; } if (Flan.octoEconomy) { PlayerClaimData data = PlayerClaimData.get(player); @@ -71,7 +69,7 @@ public class CommandCurrencyImpl implements CommandCurrency { return false; } if (Flan.gunpowder) { - StoredBalance bal = BalanceHandler.INSTANCE.getUser(player.getUUID()); + /*StoredBalance bal = BalanceHandler.INSTANCE.getUser(player.getUUID()); BigDecimal price = BigDecimal.valueOf(Math.max(0, blocks * value)); if (bal.getBalance().compareTo(price) >= 0) { PlayerClaimData data = PlayerClaimData.get(player); @@ -81,7 +79,7 @@ public class CommandCurrencyImpl implements CommandCurrency { message.accept(PermHelper.simpleColoredText(String.format(ConfigHandler.langManager.get("buySuccess"), blocks, price), ChatFormatting.GOLD)); return true; } - message.accept(PermHelper.simpleColoredText(ConfigHandler.langManager.get("buyFail"), ChatFormatting.DARK_RED)); + message.accept(PermHelper.simpleColoredText(ConfigHandler.langManager.get("buyFail"), ChatFormatting.DARK_RED));*/ return false; } if (Flan.octoEconomy) { diff --git a/forge/src/main/java/io/github/flemmli97/flan/forge/ForgeRegistryWrapper.java b/forge/src/main/java/io/github/flemmli97/flan/forge/ForgeRegistryWrapper.java index bf2780d..adc21e3 100644 --- a/forge/src/main/java/io/github/flemmli97/flan/forge/ForgeRegistryWrapper.java +++ b/forge/src/main/java/io/github/flemmli97/flan/forge/ForgeRegistryWrapper.java @@ -3,9 +3,8 @@ package io.github.flemmli97.flan.forge; import io.github.flemmli97.flan.SimpleRegistryWrapper; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.registries.IForgeRegistry; -import net.minecraftforge.registries.IForgeRegistryEntry; -public record ForgeRegistryWrapper>( +public record ForgeRegistryWrapper( IForgeRegistry registry) implements SimpleRegistryWrapper { @Override @@ -15,7 +14,7 @@ public record ForgeRegistryWrapper>( @Override public ResourceLocation getIDFrom(T entry) { - return entry.getRegistryName(); + return this.registry.getKey(entry); } @Override diff --git a/forge/src/main/java/io/github/flemmli97/flan/forge/mixin/ForgeFireMixin.java b/forge/src/main/java/io/github/flemmli97/flan/forge/mixin/ForgeFireMixin.java index a8d7fd6..2ca9fbb 100644 --- a/forge/src/main/java/io/github/flemmli97/flan/forge/mixin/ForgeFireMixin.java +++ b/forge/src/main/java/io/github/flemmli97/flan/forge/mixin/ForgeFireMixin.java @@ -4,6 +4,7 @@ import io.github.flemmli97.flan.event.WorldEvents; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.RandomSource; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.FireBlock; import org.spongepowered.asm.mixin.Mixin; @@ -11,8 +12,6 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.Random; - @Mixin(FireBlock.class) public abstract class ForgeFireMixin { @@ -20,7 +19,7 @@ public abstract class ForgeFireMixin { * Check for blocks reacting to fire (e.g. tnt) */ @Inject(method = "tryCatchFire", at = @At(value = "HEAD"), cancellable = true, remap = false) - private void spread(Level world, BlockPos pos, int spreadFactor, Random rand, int currentAge, Direction dir, CallbackInfo info) { + private void spread(Level world, BlockPos pos, int spreadFactor, RandomSource rand, int currentAge, Direction dir, CallbackInfo info) { if (!world.isClientSide && !WorldEvents.canFireSpread((ServerLevel) world, pos)) { info.cancel(); }