diff --git a/build.gradle b/build.gradle index 0abcb44..0305be8 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ plugins { id 'eclipse' id 'idea' id 'maven-publish' - id 'net.minecraftforge.gradle' version '5.1+' + id 'net.minecraftforge.gradle' version '[6.0,6.2)' id 'org.parchmentmc.librarian.forgegradle' version '1.+' } @@ -41,6 +41,7 @@ minecraft { // This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game. // It is REQUIRED to be set to true for this template to function. // See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html + copyIdeResources = true // When true, this property will add the folder name of all declared run configurations to generated IDE run configurations. // The folder name can be set on a run configuration using the "folderName" property. @@ -168,6 +169,24 @@ dependencies { // http://www.gradle.org/docs/current/userguide/dependency_management.html } +// This block of code expands all declared replace properties in the specified resource targets. +// A missing property will result in an error. Properties are expanded using ${} Groovy notation. +// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments. +// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html +tasks.named('processResources', ProcessResources).configure { + var replaceProperties = [ + minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range, + forge_version: forge_version, forge_version_range: forge_version_range, + loader_version_range: loader_version_range, + mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version, + mod_authors: mod_authors, mod_description: mod_description, + ] + inputs.properties replaceProperties + + filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) { + expand replaceProperties + [project: project] + } +} // Example for how to get properties into the manifest for reading at runtime. tasks.named('jar', Jar).configure { diff --git a/gradle.properties b/gradle.properties index f249bd8..440d6f1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,22 +3,22 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -libzontreck=1.10.012124.1709 +libzontreck=1.10.011524.0045 ## Environment Properties # The Minecraft version must agree with the Forge version to get a valid artifact -minecraft_version=1.18.2 +minecraft_version=1.20.1 # The Minecraft version range can use any release version of Minecraft as bounds. # Snapshots, pre-releases, and release candidates are not guaranteed to sort properly # as they do not follow standard versioning conventions. -minecraft_version_range=[1.18.2,1.19) +minecraft_version_range=[1.20.1,1.21) # The Forge version must agree with the Minecraft version to get a valid artifact -forge_version=40.2.1 +forge_version=47.2.0 # The Forge version range can use any version of Forge as bounds or match the loader version range -forge_version_range=[40,) +forge_version_range=[47,) # The loader version range can only use the major version of Forge/FML as bounds -loader_version_range=[40,) +loader_version_range=[47,) # The mapping channel to use for mappings. # The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"]. # Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin. @@ -36,7 +36,7 @@ loader_version_range=[40,) mapping_channel=parchment # The mapping version to query from the mapping channel. # This must match the format required by the mapping channel. -mapping_version=2022.11.06-1.18.2 +mapping_version=2023.09.03-1.20.1 ## Mod Properties @@ -49,7 +49,7 @@ mod_name=Aria's Essentials # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=GPLv3 # The mod version. See https://semver.org/ -mod_version=1.2.012124.2356 +mod_version=1.2.011524.2039 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 81b8f92..37aef8d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle index 7f4682f..4e8d059 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,4 +3,8 @@ pluginManagement { gradlePluginPortal() maven { url = "https://maven.zontreck.com/repository/internal" } } +} + +plugins { + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0' } \ No newline at end of file diff --git a/src/main/java/dev/zontreck/essentials/AriasEssentials.java b/src/main/java/dev/zontreck/essentials/AriasEssentials.java index dd077aa..93825ec 100644 --- a/src/main/java/dev/zontreck/essentials/AriasEssentials.java +++ b/src/main/java/dev/zontreck/essentials/AriasEssentials.java @@ -25,6 +25,7 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.client.event.RegisterKeyMappingsEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; @@ -144,6 +145,13 @@ public class AriasEssentials { MinecraftForge.EVENT_BUS.register(new HeartsRenderer()); } + @OnlyIn(Dist.CLIENT) + @SubscribeEvent + public static void onRegisterKeyBinds(RegisterKeyMappingsEvent ev) + { + ev.register(Keybindings.AUTOWALK); + } + } } diff --git a/src/main/java/dev/zontreck/essentials/client/AutoWalk.java b/src/main/java/dev/zontreck/essentials/client/AutoWalk.java index 1774472..616feca 100644 --- a/src/main/java/dev/zontreck/essentials/client/AutoWalk.java +++ b/src/main/java/dev/zontreck/essentials/client/AutoWalk.java @@ -11,7 +11,6 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import java.time.Instant; -import java.util.UUID; @OnlyIn(Dist.CLIENT) @Mod.EventBusSubscriber(modid = AriasEssentials.MODID, value = Dist.CLIENT) @@ -22,7 +21,7 @@ public class AutoWalk { static long lastPress; @SubscribeEvent - public static void onKeyPress(InputEvent.KeyInputEvent event) { + public static void onKeyPress(InputEvent.Key event) { if(Keybindings.AUTOWALK.matches(event.getKey(), event.getScanCode()) && Minecraft.getInstance().screen == null && Keybindings.AUTOWALK.isDown()) { lastPress = Instant.now().getEpochSecond(); @@ -36,10 +35,10 @@ public class AutoWalk { private static void startWalking() { isWalking=true; - autoJump = Minecraft.getInstance().options.autoJump; - Minecraft.getInstance().options.autoJump = true; + autoJump = Minecraft.getInstance().options.autoJump().get(); + Minecraft.getInstance().options.autoJump().set(true); - Minecraft.getInstance().player.sendMessage(ChatHelpers.macro(Messages.ESSENTIALS_PREFIX + "!Dark_Green!AutoWalking started"), new UUID(0,0)); + Minecraft.getInstance().player.sendSystemMessage(ChatHelpers.macro(Messages.ESSENTIALS_PREFIX + "!Dark_Green!AutoWalking started")); runner = new Thread(()->{ while(AutoWalk.isWalking) @@ -55,10 +54,10 @@ public class AutoWalk { isWalking=false; runner.interrupt(); runner=null; - Minecraft.getInstance().options.autoJump = autoJump; + Minecraft.getInstance().options.autoJump().set(autoJump); Minecraft.getInstance().options.keyUp.setDown(false); - Minecraft.getInstance().player.sendMessage(ChatHelpers.macro(Messages.ESSENTIALS_PREFIX + "!Dark_Green!AutoWalking stopped"), new UUID(0,0)); + Minecraft.getInstance().player.sendSystemMessage(ChatHelpers.macro(Messages.ESSENTIALS_PREFIX + "!Dark_Green!AutoWalking stopped")); } } diff --git a/src/main/java/dev/zontreck/essentials/client/Keybindings.java b/src/main/java/dev/zontreck/essentials/client/Keybindings.java index cad9a55..612567f 100644 --- a/src/main/java/dev/zontreck/essentials/client/Keybindings.java +++ b/src/main/java/dev/zontreck/essentials/client/Keybindings.java @@ -5,9 +5,8 @@ import com.mojang.blaze3d.platform.InputConstants; import net.minecraft.client.KeyMapping; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.client.event.RegisterKeyMappingsEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; @OnlyIn(Dist.CLIENT) public class Keybindings { @@ -20,5 +19,11 @@ public class Keybindings { final KeyMapping key = new KeyMapping(name, keycode, category); return key; } + + @SubscribeEvent + public static void registerKeyMappings(RegisterKeyMappingsEvent event) + { + event.register(AUTOWALK); + } } diff --git a/src/main/java/dev/zontreck/essentials/commands/gui/HeartsCommand.java b/src/main/java/dev/zontreck/essentials/commands/gui/HeartsCommand.java index cbd8e60..9850a6e 100644 --- a/src/main/java/dev/zontreck/essentials/commands/gui/HeartsCommand.java +++ b/src/main/java/dev/zontreck/essentials/commands/gui/HeartsCommand.java @@ -2,7 +2,6 @@ package dev.zontreck.essentials.commands.gui; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.BoolArgumentType; -import com.mojang.brigadier.exceptions.CommandSyntaxException; import dev.zontreck.essentials.Messages; import dev.zontreck.essentials.events.CommandExecutionEvent; import dev.zontreck.essentials.networking.ModMessages; @@ -10,7 +9,6 @@ import dev.zontreck.essentials.networking.packets.s2c.S2CUpdateHearts; import dev.zontreck.libzontreck.util.ChatHelpers; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; -import net.minecraft.server.level.ServerPlayer; import net.minecraftforge.common.MinecraftForge; public class HeartsCommand @@ -22,31 +20,24 @@ public class HeartsCommand private static int hearts(CommandSourceStack stack, boolean compressHearts) { - - ServerPlayer player = null; - try { - player = stack.getPlayerOrException(); - } catch (CommandSyntaxException e) { - throw new RuntimeException(e); - } - var exec = new CommandExecutionEvent(player, "hearts"); + var exec = new CommandExecutionEvent(stack.getPlayer(), "hearts"); if(MinecraftForge.EVENT_BUS.post(exec)) { return 0; } // Send the state to the client, then update the config // Send feedback to the user - ChatHelpers.broadcastTo(player.getUUID(), ChatHelpers.macro(Messages.HEARTS_UPDATED), stack.getServer()); + ChatHelpers.broadcastTo(stack.getPlayer().getUUID(), ChatHelpers.macro(Messages.HEARTS_UPDATED), stack.getServer()); S2CUpdateHearts update = new S2CUpdateHearts(compressHearts); - ModMessages.sendToPlayer(update, player); + ModMessages.sendToPlayer(update, stack.getPlayer()); return 0; } private static int usage(CommandSourceStack stack) { - ChatHelpers.broadcastTo(stack.getEntity().getUUID(), ChatHelpers.macro(Messages.HEARTS_USAGE), stack.getServer()); + ChatHelpers.broadcastTo(stack.getPlayer().getUUID(), ChatHelpers.macro(Messages.HEARTS_USAGE), stack.getServer()); return 0; diff --git a/src/main/java/dev/zontreck/essentials/commands/homes/DelHomeCommand.java b/src/main/java/dev/zontreck/essentials/commands/homes/DelHomeCommand.java index 8e24648..41ba7fa 100644 --- a/src/main/java/dev/zontreck/essentials/commands/homes/DelHomeCommand.java +++ b/src/main/java/dev/zontreck/essentials/commands/homes/DelHomeCommand.java @@ -3,7 +3,6 @@ package dev.zontreck.essentials.commands.homes; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.StringArgumentType; -import com.mojang.brigadier.exceptions.CommandSyntaxException; import dev.zontreck.essentials.AriasEssentials; import dev.zontreck.essentials.Messages; import dev.zontreck.essentials.events.CommandExecutionEvent; @@ -37,12 +36,7 @@ public class DelHomeCommand { private static int rmHome(CommandSourceStack ctx, String homeName) { - CommandExecutionEvent exec = null; - try { - exec = new CommandExecutionEvent(ctx.getPlayerOrException(), "delhome"); - } catch (CommandSyntaxException e) { - throw new RuntimeException(e); - } + var exec = new CommandExecutionEvent(ctx.getPlayer(), "delhome"); if(MinecraftForge.EVENT_BUS.post(exec)) { return 0; diff --git a/src/main/java/dev/zontreck/essentials/commands/homes/HomeCommand.java b/src/main/java/dev/zontreck/essentials/commands/homes/HomeCommand.java index da9b6cc..7ef3328 100644 --- a/src/main/java/dev/zontreck/essentials/commands/homes/HomeCommand.java +++ b/src/main/java/dev/zontreck/essentials/commands/homes/HomeCommand.java @@ -33,12 +33,7 @@ public class HomeCommand { private static int home(CommandSourceStack ctx, String homeName) { - CommandExecutionEvent exec = null; - try { - exec = new CommandExecutionEvent(ctx.getPlayerOrException(), "home"); - } catch (CommandSyntaxException e) { - throw new RuntimeException(e); - } + var exec = new CommandExecutionEvent(ctx.getPlayer(), "home"); if(MinecraftForge.EVENT_BUS.post(exec)) { return 0; diff --git a/src/main/java/dev/zontreck/essentials/commands/homes/HomesCommand.java b/src/main/java/dev/zontreck/essentials/commands/homes/HomesCommand.java index b87baa8..36dbf9a 100644 --- a/src/main/java/dev/zontreck/essentials/commands/homes/HomesCommand.java +++ b/src/main/java/dev/zontreck/essentials/commands/homes/HomesCommand.java @@ -60,7 +60,7 @@ public class HomesCommand { { stack = new ItemStack(Items.GRASS_BLOCK, 1); } - stack.setHoverName(ChatHelpers.macro(string.homeName)); + stack.setHoverName(Component.literal(string.homeName)); ChestGUIButton button = new ChestGUIButton(stack, (stackx, container, lore)-> { diff --git a/src/main/java/dev/zontreck/essentials/commands/homes/SetHomeCommand.java b/src/main/java/dev/zontreck/essentials/commands/homes/SetHomeCommand.java index cafb06a..47f6ca5 100644 --- a/src/main/java/dev/zontreck/essentials/commands/homes/SetHomeCommand.java +++ b/src/main/java/dev/zontreck/essentials/commands/homes/SetHomeCommand.java @@ -24,7 +24,6 @@ import net.minecraft.commands.Commands; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec2; import net.minecraft.world.phys.Vec3; import net.minecraftforge.common.MinecraftForge; @@ -43,12 +42,7 @@ public class SetHomeCommand { private static int setHome(CommandSourceStack ctx, String homeName) { - CommandExecutionEvent exec = null; - try { - exec = new CommandExecutionEvent(ctx.getPlayerOrException(), "sethome"); - } catch (CommandSyntaxException e) { - throw new RuntimeException(e); - } + var exec = new CommandExecutionEvent(ctx.getPlayer(), "sethome"); if(MinecraftForge.EVENT_BUS.post(exec)) { return 0; @@ -64,7 +58,7 @@ public class SetHomeCommand { p = ctx.getPlayerOrException(); - if(TeleportActioner.isBlacklistedDimension(p.getLevel())) + if(TeleportActioner.isBlacklistedDimension(p.serverLevel())) { ChatHelpers.broadcastTo(p, ChatHelpers.macro(Messages.ESSENTIALS_PREFIX + AEServerConfig.getInstance().messages.BlacklistedDimensionError), p.server); @@ -74,11 +68,9 @@ public class SetHomeCommand { Vec3 position = p.position(); Vec2 rot = p.getRotationVector(); - TeleportDestination dest = new TeleportDestination(new Vector3(position), new Vector2(rot), p.getLevel()); - - BlockState bs = p.getLevel().getBlockState(dest.Position.moveDown().asBlockPos()); + TeleportDestination dest = new TeleportDestination(new Vector3(position), new Vector2(rot), p.serverLevel()); - Home newhome = new Home(p, homeName, dest, new ItemStack(bs.getBlock().asItem())); + Home newhome = new Home(p, homeName, dest, new ItemStack(p.getBlockStateOn().getBlock().asItem())); AriasEssentials.player_homes.get(p.getUUID()).add(newhome); diff --git a/src/main/java/dev/zontreck/essentials/commands/teleport/BackCommand.java b/src/main/java/dev/zontreck/essentials/commands/teleport/BackCommand.java index c5185ac..c513f5a 100644 --- a/src/main/java/dev/zontreck/essentials/commands/teleport/BackCommand.java +++ b/src/main/java/dev/zontreck/essentials/commands/teleport/BackCommand.java @@ -1,7 +1,6 @@ package dev.zontreck.essentials.commands.teleport; import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.exceptions.CommandSyntaxException; import dev.zontreck.essentials.Messages; import dev.zontreck.essentials.configs.server.AEServerConfig; import dev.zontreck.essentials.events.CommandExecutionEvent; @@ -21,12 +20,7 @@ public class BackCommand public static int back(CommandSourceStack ctx) { - CommandExecutionEvent exec = null; - try { - exec = new CommandExecutionEvent(ctx.getPlayerOrException(), "back"); - } catch (CommandSyntaxException e) { - throw new RuntimeException(e); - } + var exec = new CommandExecutionEvent(ctx.getPlayer(), "back"); if(MinecraftForge.EVENT_BUS.post(exec)) { return 0; @@ -34,20 +28,20 @@ public class BackCommand try { if(!AEServerConfig.getInstance().back.Enabled && !ctx.hasPermission(ctx.getServer().getOperatorUserPermissionLevel())) { - ChatHelpers.broadcastTo(ctx.getPlayerOrException(), ChatHelpers.macro(Messages.TELEPORT_BACK_DISABLED), ctx.getServer()); + ChatHelpers.broadcastTo(ctx.getPlayer(), ChatHelpers.macro(Messages.TELEPORT_BACK_DISABLED), ctx.getServer()); return 0; } - WorldPosition wp = BackPositionCaches.Pop(ctx.getPlayerOrException().getUUID()); + WorldPosition wp = BackPositionCaches.Pop(ctx.getPlayer().getUUID()); - ChatHelpers.broadcastTo(ctx.getPlayerOrException(), ChatHelpers.macro(Messages.TELEPORT_BACK), ctx.getServer()); + ChatHelpers.broadcastTo(ctx.getPlayer(), ChatHelpers.macro(Messages.TELEPORT_BACK), ctx.getServer()); - TeleportContainer cont = new TeleportContainer(ctx.getPlayerOrException(), wp.Position.asMinecraftVector(), ctx.getRotation(), wp.getActualDimension()); + TeleportContainer cont = new TeleportContainer(ctx.getPlayer(), wp.Position.asMinecraftVector(), ctx.getRotation(), wp.getActualDimension()); - TeleportActioner.ApplyTeleportEffect(ctx.getPlayerOrException()); + TeleportActioner.ApplyTeleportEffect(ctx.getPlayer()); TeleportActioner.PerformTeleport(cont, true); } catch (Exception e) { - ChatHelpers.broadcastTo(ctx.getEntity().getUUID(), ChatHelpers.macro(Messages.NO_BACK), ctx.getServer()); + ChatHelpers.broadcastTo(ctx.getPlayer(), ChatHelpers.macro(Messages.NO_BACK), ctx.getServer()); } return 0; } diff --git a/src/main/java/dev/zontreck/essentials/commands/teleport/RTPCommand.java b/src/main/java/dev/zontreck/essentials/commands/teleport/RTPCommand.java index d27174b..bbaeee0 100644 --- a/src/main/java/dev/zontreck/essentials/commands/teleport/RTPCommand.java +++ b/src/main/java/dev/zontreck/essentials/commands/teleport/RTPCommand.java @@ -2,7 +2,6 @@ package dev.zontreck.essentials.commands.teleport; import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.exceptions.CommandSyntaxException; import dev.zontreck.essentials.events.CommandExecutionEvent; import dev.zontreck.essentials.rtp.RandomPositionFactory; import net.minecraft.commands.CommandSourceStack; @@ -28,12 +27,7 @@ public class RTPCommand { private static int rtp(CommandSourceStack source) { - CommandExecutionEvent exec = null; - try { - exec = new CommandExecutionEvent(source.getPlayerOrException(), "rtp"); - } catch (CommandSyntaxException e) { - throw new RuntimeException(e); - } + var exec = new CommandExecutionEvent(source.getPlayer(), "rtp"); if(MinecraftForge.EVENT_BUS.post(exec)) { return 0; @@ -64,7 +58,7 @@ public class RTPCommand { Vec3 pos = pla.position(); //boolean found_place= false; - RandomPositionFactory.beginRTP(pla, pla.getLevel()); + RandomPositionFactory.beginRTP(pla, pla.serverLevel()); } diff --git a/src/main/java/dev/zontreck/essentials/commands/teleport/SpawnCommand.java b/src/main/java/dev/zontreck/essentials/commands/teleport/SpawnCommand.java index a17f712..009a381 100644 --- a/src/main/java/dev/zontreck/essentials/commands/teleport/SpawnCommand.java +++ b/src/main/java/dev/zontreck/essentials/commands/teleport/SpawnCommand.java @@ -2,7 +2,6 @@ package dev.zontreck.essentials.commands.teleport; import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.exceptions.CommandSyntaxException; import dev.zontreck.essentials.Messages; import dev.zontreck.essentials.events.CommandExecutionEvent; import dev.zontreck.libzontreck.util.ChatHelpers; @@ -28,12 +27,7 @@ public class SpawnCommand { private static int respawn(CommandSourceStack source) { - CommandExecutionEvent exec = null; - try { - exec = new CommandExecutionEvent(source.getPlayerOrException(), "spawn"); - } catch (CommandSyntaxException e) { - throw new RuntimeException(e); - } + var exec = new CommandExecutionEvent(source.getPlayer(), "spawn"); if(MinecraftForge.EVENT_BUS.post(exec)) { return 0; @@ -42,10 +36,10 @@ public class SpawnCommand { ChatHelpers.broadcastTo(p.getUUID(), ChatHelpers.macro(Messages.RESPAWNING), p.server); - BlockPos spawn = p.getLevel().getSharedSpawnPos(); + BlockPos spawn = p.serverLevel().getSharedSpawnPos(); TeleportActioner.ApplyTeleportEffect(p); - TeleportContainer cont = new TeleportContainer(p, new Vec3(spawn.getX(), spawn.getY(), spawn.getZ()), Vec2.ZERO, p.getLevel()); + TeleportContainer cont = new TeleportContainer(p, new Vec3(spawn.getX(), spawn.getY(), spawn.getZ()), Vec2.ZERO, p.serverLevel()); TeleportActioner.PerformTeleport(cont, false); diff --git a/src/main/java/dev/zontreck/essentials/commands/teleport/TPACommand.java b/src/main/java/dev/zontreck/essentials/commands/teleport/TPACommand.java index ebe30fe..e2bf5d4 100644 --- a/src/main/java/dev/zontreck/essentials/commands/teleport/TPACommand.java +++ b/src/main/java/dev/zontreck/essentials/commands/teleport/TPACommand.java @@ -2,7 +2,6 @@ package dev.zontreck.essentials.commands.teleport; import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.exceptions.CommandSyntaxException; import dev.zontreck.ariaslib.terminal.Task; import dev.zontreck.ariaslib.util.DelayedExecutorService; import dev.zontreck.essentials.Messages; @@ -38,12 +37,7 @@ public class TPACommand { private static int tpa(CommandSourceStack source, ServerPlayer serverPlayer) { - CommandExecutionEvent exec = null; - try { - exec = new CommandExecutionEvent(source.getPlayerOrException(), "tpa"); - } catch (CommandSyntaxException e) { - throw new RuntimeException(e); - } + var exec = new CommandExecutionEvent(source.getPlayer(), "tpa"); if(MinecraftForge.EVENT_BUS.post(exec)) { return 0; @@ -124,7 +118,7 @@ public class TPACommand { private static int usage(CommandSourceStack source) { - ChatHelpers.broadcastTo(source.getEntity().getUUID(), ChatHelpers.macro("/tpa USAGE\n\n "+ChatColor.BOLD + ChatColor.DARK_GRAY+"/tpa "+ChatColor.DARK_RED+"target_player\n"), source.getServer()); + source.sendSystemMessage(ChatHelpers.macro("/tpa USAGE\n\n "+ChatColor.BOLD + ChatColor.DARK_GRAY+"/tpa "+ChatColor.DARK_RED+"target_player\n")); return 0; } } diff --git a/src/main/java/dev/zontreck/essentials/commands/teleport/TPAHereCommand.java b/src/main/java/dev/zontreck/essentials/commands/teleport/TPAHereCommand.java index 0305739..0c95e0b 100644 --- a/src/main/java/dev/zontreck/essentials/commands/teleport/TPAHereCommand.java +++ b/src/main/java/dev/zontreck/essentials/commands/teleport/TPAHereCommand.java @@ -2,7 +2,6 @@ package dev.zontreck.essentials.commands.teleport; import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.exceptions.CommandSyntaxException; import dev.zontreck.ariaslib.terminal.Task; import dev.zontreck.ariaslib.util.DelayedExecutorService; import dev.zontreck.essentials.Messages; @@ -34,12 +33,7 @@ public class TPAHereCommand { private static int tpa(CommandSourceStack source, ServerPlayer serverPlayer) { - CommandExecutionEvent exec = null; - try { - exec = new CommandExecutionEvent(source.getPlayerOrException(), "tpahere"); - } catch (CommandSyntaxException e) { - throw new RuntimeException(e); - } + var exec = new CommandExecutionEvent(source.getPlayer(), "tpahere"); if(MinecraftForge.EVENT_BUS.post(exec)) { return 0; @@ -120,7 +114,7 @@ public class TPAHereCommand { } private static int usage(CommandSourceStack source) { - ChatHelpers.broadcastTo(source.getEntity().getUUID(), ChatHelpers.macro("/tpahere USAGE\n\n !Bold!!Dark_Gray!/tpahere !Dark_Red!target_player\n"), source.getServer()); + source.sendSystemMessage(ChatHelpers.macro("/tpahere USAGE\n\n !Bold!!Dark_Gray!/tpahere !Dark_Red!target_player\n")); return 0; } } diff --git a/src/main/java/dev/zontreck/essentials/commands/teleport/TPAcceptCommand.java b/src/main/java/dev/zontreck/essentials/commands/teleport/TPAcceptCommand.java index 685d320..1748496 100644 --- a/src/main/java/dev/zontreck/essentials/commands/teleport/TPAcceptCommand.java +++ b/src/main/java/dev/zontreck/essentials/commands/teleport/TPAcceptCommand.java @@ -6,7 +6,6 @@ import java.util.UUID; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.StringArgumentType; -import com.mojang.brigadier.exceptions.CommandSyntaxException; import dev.zontreck.essentials.Messages; import dev.zontreck.essentials.events.CommandExecutionEvent; import dev.zontreck.libzontreck.chat.ChatColor; @@ -26,12 +25,7 @@ public class TPAcceptCommand { private static int doAccept(CommandSourceStack source, String TPID) { - CommandExecutionEvent exec = null; - try { - exec = new CommandExecutionEvent(source.getPlayerOrException(), "tpaccept"); - } catch (CommandSyntaxException e) { - throw new RuntimeException(e); - } + var exec = new CommandExecutionEvent(source.getPlayer(), "tpaccept"); if(MinecraftForge.EVENT_BUS.post(exec)) { return 0; @@ -60,7 +54,7 @@ public class TPAcceptCommand { cont.PlayerInst = from; cont.Position = to.position(); cont.Rotation = to.getRotationVector(); - cont.Dimension = to.getLevel(); + cont.Dimension = to.serverLevel(); TeleportActioner.ApplyTeleportEffect(from); TeleportActioner.PerformTeleport(cont, false); diff --git a/src/main/java/dev/zontreck/essentials/commands/teleport/TPEffectsCommand.java b/src/main/java/dev/zontreck/essentials/commands/teleport/TPEffectsCommand.java index 4aec495..a5b9651 100644 --- a/src/main/java/dev/zontreck/essentials/commands/teleport/TPEffectsCommand.java +++ b/src/main/java/dev/zontreck/essentials/commands/teleport/TPEffectsCommand.java @@ -2,14 +2,11 @@ package dev.zontreck.essentials.commands.teleport; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.BoolArgumentType; -import com.mojang.brigadier.exceptions.CommandSyntaxException; -import dev.zontreck.essentials.Messages; import dev.zontreck.libzontreck.chestgui.ChestGUI; import dev.zontreck.libzontreck.chestgui.ChestGUIButton; import dev.zontreck.libzontreck.chestgui.ChestGUIIdentifier; import dev.zontreck.libzontreck.profiles.Profile; import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException; -import dev.zontreck.libzontreck.util.ChatHelpers; import dev.zontreck.libzontreck.util.ServerUtilities; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; @@ -23,23 +20,16 @@ public class TPEffectsCommand { public static void register(CommandDispatcher dispatcher) { - dispatcher.register(Commands.literal("tpeffects_disable").then(Commands.argument("disabled", BoolArgumentType.bool()).executes(x->tpeffects(x.getSource(), BoolArgumentType.getBool(x, "disabled"))))); + dispatcher.register(Commands.literal("tpeffects").then(Commands.argument("enable", BoolArgumentType.bool()).executes(x->tpeffects(x.getSource(), BoolArgumentType.getBool(x, "enable"))))); } - public static int tpeffects(CommandSourceStack source, boolean disabled) + public static int tpeffects(CommandSourceStack source, boolean enabled) { - ServerPlayer player = null; - try { - player = source.getPlayerOrException(); - } catch (CommandSyntaxException e) { - throw new RuntimeException(e); - } + ServerPlayer player = source.getPlayer(); try { Profile prof = Profile.get_profile_of(player.getStringUUID()); - prof.NBT.putBoolean("tpeffects", disabled); - - ChatHelpers.broadcastTo(player.getUUID(), ChatHelpers.macro(Messages.TP_EFFECTS_TOGGLED, disabled ? "disabled" : "enabled"), player.server); + prof.NBT.putBoolean("tpeffects", enabled); return 0; } catch (UserProfileNotYetExistsException e) { diff --git a/src/main/java/dev/zontreck/essentials/commands/teleport/TeleportActioner.java b/src/main/java/dev/zontreck/essentials/commands/teleport/TeleportActioner.java index a09d710..e4a0546 100644 --- a/src/main/java/dev/zontreck/essentials/commands/teleport/TeleportActioner.java +++ b/src/main/java/dev/zontreck/essentials/commands/teleport/TeleportActioner.java @@ -3,10 +3,9 @@ package dev.zontreck.essentials.commands.teleport; import dev.zontreck.ariaslib.util.DelayedExecutorService; import dev.zontreck.essentials.AriasEssentials; import dev.zontreck.essentials.configs.server.AEServerConfig; -import dev.zontreck.libzontreck.profiles.Profile; -import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException; import dev.zontreck.libzontreck.vectors.Vector3; import dev.zontreck.libzontreck.vectors.WorldPosition; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.commands.EffectCommands; import net.minecraft.server.level.ServerLevel; @@ -31,16 +30,7 @@ public class TeleportActioner } public static void ApplyTeleportEffect(ServerPlayer player){ - try { - Profile prof = Profile.get_profile_of(player.getStringUUID()); - if(prof.NBT.getBoolean("tpeffects")) - { - return; - } - } catch (UserProfileNotYetExistsException e) { - throw new RuntimeException(e); - } - if(isBlacklistedDimension(player.getLevel())){ + if(isBlacklistedDimension(player.serverLevel())){ return; } // 10/05/2022 - Thinking ahead here to future proof it so i can do things in threads safely @@ -53,7 +43,7 @@ public class TeleportActioner for(int i = 0; i < effects.size(); i++) { RegistryObject effect = RegistryObject.create(new ResourceLocation(effects.get(i)), ForgeRegistries.MOB_EFFECTS); - int duration = AriasEssentials.random.nextInt(2, 5) * 20; + int duration = AriasEssentials.random.nextInt(5, 10) * 20; int amplifier = AriasEssentials.random.nextInt(1, 3); if (effects.get(i).equals("minecraft:slow_falling")) diff --git a/src/main/java/dev/zontreck/essentials/commands/warps/DelWarpCommand.java b/src/main/java/dev/zontreck/essentials/commands/warps/DelWarpCommand.java index 7a4abab..f5a6b56 100644 --- a/src/main/java/dev/zontreck/essentials/commands/warps/DelWarpCommand.java +++ b/src/main/java/dev/zontreck/essentials/commands/warps/DelWarpCommand.java @@ -3,7 +3,6 @@ package dev.zontreck.essentials.commands.warps; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.StringArgumentType; -import com.mojang.brigadier.exceptions.CommandSyntaxException; import dev.zontreck.essentials.Messages; import dev.zontreck.essentials.events.CommandExecutionEvent; import dev.zontreck.essentials.warps.NoSuchWarpException; @@ -30,12 +29,7 @@ public class DelWarpCommand { private static int setWarp(CommandSourceStack source, String string) { - CommandExecutionEvent exec = null; - try { - exec = new CommandExecutionEvent(source.getPlayerOrException(), "delwarp"); - } catch (CommandSyntaxException e) { - throw new RuntimeException(e); - } + var exec = new CommandExecutionEvent(source.getPlayer(), "delwarp"); if(MinecraftForge.EVENT_BUS.post(exec)) { return 0; diff --git a/src/main/java/dev/zontreck/essentials/commands/warps/RTPWarpCommand.java b/src/main/java/dev/zontreck/essentials/commands/warps/RTPWarpCommand.java index b314014..56ca832 100644 --- a/src/main/java/dev/zontreck/essentials/commands/warps/RTPWarpCommand.java +++ b/src/main/java/dev/zontreck/essentials/commands/warps/RTPWarpCommand.java @@ -7,7 +7,6 @@ import java.sql.SQLException; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.StringArgumentType; -import com.mojang.brigadier.exceptions.CommandSyntaxException; import dev.zontreck.essentials.Messages; import dev.zontreck.essentials.commands.teleport.TeleportDestination; import dev.zontreck.essentials.events.CommandExecutionEvent; @@ -41,12 +40,7 @@ public class RTPWarpCommand { private static int setWarp(CommandSourceStack source, String string) { - CommandExecutionEvent exec = null; - try { - exec = new CommandExecutionEvent(source.getPlayerOrException(), "setwarp"); - } catch (CommandSyntaxException e) { - throw new RuntimeException(e); - } + var exec = new CommandExecutionEvent(source.getPlayer(), "setwarp"); if(MinecraftForge.EVENT_BUS.post(exec)) { return 0; @@ -56,8 +50,8 @@ public class RTPWarpCommand { Vec3 position = p.position(); Vec2 rot = p.getRotationVector(); - TeleportDestination dest = new TeleportDestination(new Vector3(position), new Vector2(rot), p.getLevel()); - Warp warp = new Warp(p.getUUID(), string, true, true, dest, new ItemStack(p.getFeetBlockState().getBlock().asItem())); + TeleportDestination dest = new TeleportDestination(new Vector3(position), new Vector2(rot), p.serverLevel()); + Warp warp = new Warp(p.getUUID(), string, true, true, dest, new ItemStack(p.getBlockStateOn().getBlock().asItem())); WarpCreatedEvent event = new WarpCreatedEvent(warp); if(MinecraftForge.EVENT_BUS.post(event)) { diff --git a/src/main/java/dev/zontreck/essentials/commands/warps/SetWarpCommand.java b/src/main/java/dev/zontreck/essentials/commands/warps/SetWarpCommand.java index ba59fb8..c6efdac 100644 --- a/src/main/java/dev/zontreck/essentials/commands/warps/SetWarpCommand.java +++ b/src/main/java/dev/zontreck/essentials/commands/warps/SetWarpCommand.java @@ -7,7 +7,6 @@ import java.sql.SQLException; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.StringArgumentType; -import com.mojang.brigadier.exceptions.CommandSyntaxException; import dev.zontreck.essentials.Messages; import dev.zontreck.essentials.commands.teleport.TeleportDestination; import dev.zontreck.essentials.events.CommandExecutionEvent; @@ -23,7 +22,6 @@ import net.minecraft.commands.Commands; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec2; import net.minecraft.world.phys.Vec3; import net.minecraftforge.common.MinecraftForge; @@ -42,12 +40,7 @@ public class SetWarpCommand { private static int setWarp(CommandSourceStack source, String string) { - CommandExecutionEvent exec = null; - try { - exec = new CommandExecutionEvent(source.getPlayerOrException(), "setwarp"); - } catch (CommandSyntaxException e) { - throw new RuntimeException(e); - } + var exec = new CommandExecutionEvent(source.getPlayer(), "setwarp"); if(MinecraftForge.EVENT_BUS.post(exec)) { return 0; @@ -58,11 +51,8 @@ public class SetWarpCommand { Vec3 position = p.position(); Vec2 rot = p.getRotationVector(); - TeleportDestination dest = new TeleportDestination(new Vector3(position), new Vector2(rot), p.getLevel()); - - BlockState bs = p.getLevel().getBlockState(dest.Position.moveDown().asBlockPos()); - - Warp w = new Warp(p.getUUID(), string, false, true, dest, new ItemStack(bs.getBlock().asItem())); + TeleportDestination dest = new TeleportDestination(new Vector3(position), new Vector2(rot), p.serverLevel()); + Warp w = new Warp(p.getUUID(), string, false, true, dest, new ItemStack(p.getBlockStateOn().getBlock().asItem())); WarpCreatedEvent event = new WarpCreatedEvent(w); if(MinecraftForge.EVENT_BUS.post(event)){ ChatHelpers.broadcastTo(p.getUUID(), ChatHelpers.macro(Messages.WARP_CREATE_ERROR, event.denyReason), p.server); diff --git a/src/main/java/dev/zontreck/essentials/commands/warps/WarpCommand.java b/src/main/java/dev/zontreck/essentials/commands/warps/WarpCommand.java index 604bf83..ffc3d39 100644 --- a/src/main/java/dev/zontreck/essentials/commands/warps/WarpCommand.java +++ b/src/main/java/dev/zontreck/essentials/commands/warps/WarpCommand.java @@ -64,7 +64,7 @@ public class WarpCommand { if(type==1){ try { - var exec = new CommandExecutionEvent(source.getPlayerOrException(), "rtp"); + var exec = new CommandExecutionEvent(source.getPlayer(), "rtp"); if(MinecraftForge.EVENT_BUS.post(exec)) { return; @@ -78,12 +78,7 @@ public class WarpCommand { } } - CommandExecutionEvent exec = null; - try { - exec = new CommandExecutionEvent(source.getPlayerOrException(), "warp"); - } catch (CommandSyntaxException e) { - throw new RuntimeException(e); - } + var exec = new CommandExecutionEvent(source.getPlayer(), "warp"); if(MinecraftForge.EVENT_BUS.post(exec)) { return; diff --git a/src/main/java/dev/zontreck/essentials/commands/warps/WarpsCommand.java b/src/main/java/dev/zontreck/essentials/commands/warps/WarpsCommand.java index 4d8a020..425253f 100644 --- a/src/main/java/dev/zontreck/essentials/commands/warps/WarpsCommand.java +++ b/src/main/java/dev/zontreck/essentials/commands/warps/WarpsCommand.java @@ -140,8 +140,11 @@ public class WarpsCommand { ) .withInfo(new LoreEntry.Builder().text(ChatHelpers.macro(appendType, warp.destination.Dimension).getString()).build()); - ChatHelpers.broadcastTo(p, warpMsg, p.server); - if(!(warps.size() > (2*9))) + if(warps.size() > (2*9)) + { + // Say to person + ChatHelpers.broadcastTo(p, warpMsg, p.server); + }else chestGui.withButton(button); iconY++; diff --git a/src/main/java/dev/zontreck/essentials/configs/client/AEClientConfig.java b/src/main/java/dev/zontreck/essentials/configs/client/AEClientConfig.java index 00d3782..f8a5ef6 100644 --- a/src/main/java/dev/zontreck/essentials/configs/client/AEClientConfig.java +++ b/src/main/java/dev/zontreck/essentials/configs/client/AEClientConfig.java @@ -1,9 +1,8 @@ package dev.zontreck.essentials.configs.client; import com.mojang.brigadier.exceptions.CommandSyntaxException; -import dev.zontreck.ariaslib.util.FileIO; import dev.zontreck.essentials.util.EssentialsDatastore; -import dev.zontreck.libzontreck.util.SNbtIo; +import dev.zontreck.essentials.util.FileHandler; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtUtils; @@ -31,7 +30,16 @@ public class AEClientConfig Path serverConfig = EssentialsDatastore.of("client.snbt"); if(serverConfig.toFile().exists()) { - inst = deserialize(SNbtIo.loadSnbt(serverConfig)); + + try { + String snbt = FileHandler.readFile(serverConfig.toFile().getAbsolutePath()); + + inst = deserialize(NbtUtils.snbtToStructure(snbt)); + + + } catch (CommandSyntaxException e) { + throw new RuntimeException(e); + } }else { initNewConfig(); } @@ -60,8 +68,9 @@ public class AEClientConfig CompoundTag tag = inst.serialize(); + var snbt = NbtUtils.structureToSnbt(tag); - SNbtIo.writeSnbt(serverConfig, tag); + FileHandler.writeFile(serverConfig.toFile().getAbsolutePath(), snbt); } public CompoundTag serialize() diff --git a/src/main/java/dev/zontreck/essentials/configs/server/AEServerConfig.java b/src/main/java/dev/zontreck/essentials/configs/server/AEServerConfig.java index e5e1637..eccbca5 100644 --- a/src/main/java/dev/zontreck/essentials/configs/server/AEServerConfig.java +++ b/src/main/java/dev/zontreck/essentials/configs/server/AEServerConfig.java @@ -1,14 +1,17 @@ package dev.zontreck.essentials.configs.server; +import com.mojang.brigadier.exceptions.CommandSyntaxException; import dev.zontreck.ariaslib.util.Lists; import dev.zontreck.essentials.configs.server.sections.*; import dev.zontreck.essentials.util.EssentialsDatastore; +import dev.zontreck.essentials.util.FileHandler; import dev.zontreck.essentials.util.Maps; -import dev.zontreck.libzontreck.util.SNbtIo; import net.minecraft.nbt.*; +import java.io.*; import java.nio.file.Path; import java.util.HashMap; +import java.util.List; import java.util.Map; public class AEServerConfig @@ -49,7 +52,15 @@ public class AEServerConfig if(serverConfig.toFile().exists()) { - inst = deserialize(SNbtIo.loadSnbt(serverConfig)); + try { + String snbt = FileHandler.readFile(serverConfig.toFile().getAbsolutePath()); + + inst = deserialize(NbtUtils.snbtToStructure(snbt)); + + + } catch (CommandSyntaxException e) { + throw new RuntimeException(e); + } }else { initNewConfig(); } @@ -76,7 +87,7 @@ public class AEServerConfig back = new Back(); teleport = new Teleportation(); teleport.Effects = Lists.of( - "minecraft:blindness", + "minecraft:darkness", "minecraft:levitation", "minecraft:slow_falling", "minecraft:hunger" @@ -101,7 +112,9 @@ public class AEServerConfig CompoundTag tag = inst.serialize(); - SNbtIo.writeSnbt(serverConfig, tag); + var snbt = NbtUtils.structureToSnbt(tag); + + FileHandler.writeFile(serverConfig.toFile().getAbsolutePath(), snbt); } public CompoundTag serialize() diff --git a/src/main/java/dev/zontreck/essentials/gui/HeartsRenderer.java b/src/main/java/dev/zontreck/essentials/gui/HeartsRenderer.java index 9854b7d..d8df687 100644 --- a/src/main/java/dev/zontreck/essentials/gui/HeartsRenderer.java +++ b/src/main/java/dev/zontreck/essentials/gui/HeartsRenderer.java @@ -17,7 +17,7 @@ import dev.zontreck.essentials.configs.client.AEClientConfig; import net.minecraft.Util; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; import net.minecraft.world.effect.MobEffectInstance; @@ -28,8 +28,10 @@ import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.player.Player; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.event.RenderGameOverlayEvent; -import net.minecraftforge.client.gui.ForgeIngameGui; +import net.minecraftforge.client.event.RenderGuiOverlayEvent; +import net.minecraftforge.client.gui.overlay.ForgeGui; +import net.minecraftforge.client.gui.overlay.GuiOverlayManager; +import net.minecraftforge.client.gui.overlay.NamedGuiOverlay; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -42,7 +44,7 @@ public class HeartsRenderer { "textures/gui/hearts.png"); private static final ResourceLocation ICON_ABSORB = new ResourceLocation(AriasEssentials.MODID, "textures/gui/absorb.png"); - private static final ResourceLocation ICON_VANILLA = GuiComponent.GUI_ICONS_LOCATION; + private static final ResourceLocation ICON_VANILLA = Gui.GUI_ICONS_LOCATION; private final Minecraft mc = Minecraft.getInstance(); @@ -65,8 +67,8 @@ public class HeartsRenderer { * @param width Width to draw * @param height Height to draw */ - private void blit(PoseStack matrixStack, int x, int y, int textureX, int textureY, int width, int height) { - Minecraft.getInstance().gui.blit(matrixStack, x, y, textureX, textureY, width, height); + private void blit(GuiGraphics matrixStack, int x, int y, int textureX, int textureY, int width, int height, ResourceLocation resource) { + matrixStack.blit(resource, x, y, textureX, textureY, width, height); } /* HUD */ @@ -77,12 +79,28 @@ public class HeartsRenderer { * @param event Event instance */ @SubscribeEvent(priority = EventPriority.LOW) - public void renderHealthbar(RenderGameOverlayEvent.PreLayer event) { - if (event.isCanceled() || !AEClientConfig.getInstance().EnableHearts || event.getOverlay() != ForgeIngameGui.PLAYER_HEALTH_ELEMENT) { + public void renderHealthbar(RenderGuiOverlayEvent.Pre event) { + NamedGuiOverlay ActualOverlay = GuiOverlayManager.findOverlay(new ResourceLocation("minecraft:player_health")); + + if (ActualOverlay == null) { + if (GuiOverlayManager.getOverlays() == null) { + AriasEssentials.LOGGER.info("Overlays non existent?!"); + } + for (NamedGuiOverlay overlay : GuiOverlayManager.getOverlays()) { + // Next print + // LibZontreck.LOGGER.info("GUI OVERLAY: "+overlay.id().getPath()); + + if (overlay.id().getPath().equals("player_health")) { + ActualOverlay = overlay; + break; + } + } + } + if (event.isCanceled() || !AEClientConfig.getInstance().EnableHearts || event.getOverlay() != ActualOverlay) { return; } // ensure its visible - if (!(mc.gui instanceof ForgeIngameGui gui) || mc.options.hideGui || !gui.shouldDrawSurvivalElements()) { + if (!(mc.gui instanceof ForgeGui gui) || mc.options.hideGui || !gui.shouldDrawSurvivalElements()) { return; } Entity renderViewEnity = this.mc.getCameraEntity(); @@ -94,7 +112,7 @@ public class HeartsRenderer { this.mc.getProfiler().push("health"); // extra setup stuff from us - int left_height = gui.left_height; + int left_height = gui.leftHeight; int width = this.mc.getWindow().getGuiScaledWidth(); int height = this.mc.getWindow().getGuiScaledHeight(); int updateCounter = this.mc.gui.getGuiTicks(); @@ -103,13 +121,13 @@ public class HeartsRenderer { // changes are indicated by comment int health = Mth.ceil(player.getHealth()); - boolean highlight = this.healthUpdateCounter > (long) updateCounter && (this.healthUpdateCounter - (long) updateCounter) / 3L % 2L == 1L; + boolean highlight = this.healthUpdateCounter > (long) updateCounter + && (this.healthUpdateCounter - (long) updateCounter) / 3L % 2L == 1L; if (health < this.playerHealth && player.invulnerableTime > 0) { this.lastSystemTime = Util.getMillis(); this.healthUpdateCounter = (updateCounter + 20); - } - else if (health > this.playerHealth && player.invulnerableTime > 0) { + } else if (health > this.playerHealth && player.invulnerableTime > 0) { this.lastSystemTime = Util.getMillis(); this.healthUpdateCounter = (updateCounter + 10); } @@ -127,7 +145,8 @@ public class HeartsRenderer { float healthMax = attrMaxHealth == null ? 0 : (float) attrMaxHealth.getValue(); float absorb = Mth.ceil(player.getAbsorptionAmount()); - // CHANGE: simulate 10 hearts max if there's more, so vanilla only renders one row max + // CHANGE: simulate 10 hearts max if there's more, so vanilla only renders one + // row max healthMax = Math.min(healthMax, 20f); health = Math.min(health, 20); absorb = Math.min(absorb, 20); @@ -139,9 +158,10 @@ public class HeartsRenderer { int left = width / 2 - 91; int top = height - left_height; - // change: these are unused below, unneeded? should these adjust the Forge variable? - //left_height += (healthRows * rowHeight); - //if (rowHeight != 10) left_height += 10 - rowHeight; + // change: these are unused below, unneeded? should these adjust the Forge + // variable? + // left_height += (healthRows * rowHeight); + // if (rowHeight != 10) left_height += 10 - rowHeight; this.regen = -1; if (player.hasEffect(MobEffects.REGENERATION)) { @@ -152,46 +172,46 @@ public class HeartsRenderer { final int TOP = 9 * (this.mc.level.getLevelData().isHardcore() ? 5 : 0); final int BACKGROUND = (highlight ? 25 : 16); int MARGIN = 16; - if (player.hasEffect(MobEffects.POISON)) MARGIN += 36; - else if (player.hasEffect(MobEffects.WITHER)) MARGIN += 72; + if (player.hasEffect(MobEffects.POISON)) + MARGIN += 36; + else if (player.hasEffect(MobEffects.WITHER)) + MARGIN += 72; float absorbRemaining = absorb; - PoseStack matrixStack = event.getMatrixStack(); + GuiGraphics matrixStack = event.getGuiGraphics(); for (int i = Mth.ceil((healthMax + absorb) / 2.0F) - 1; i >= 0; --i) { int row = Mth.ceil((float) (i + 1) / 10.0F) - 1; int x = left + i % 10 * 8; int y = top - row * rowHeight; - if (health <= 4) y += this.rand.nextInt(2); - if (i == this.regen) y -= 2; + if (health <= 4) + y += this.rand.nextInt(2); + if (i == this.regen) + y -= 2; - this.blit(matrixStack, x, y, BACKGROUND, TOP, 9, 9); + this.blit(matrixStack, x, y, BACKGROUND, TOP, 9, 9, ICON_VANILLA); if (highlight) { if (i * 2 + 1 < healthLast) { - this.blit(matrixStack, x, y, MARGIN + 54, TOP, 9, 9); //6 - } - else if (i * 2 + 1 == healthLast) { - this.blit(matrixStack, x, y, MARGIN + 63, TOP, 9, 9); //7 + this.blit(matrixStack, x, y, MARGIN + 54, TOP, 9, 9, ICON_VANILLA); // 6 + } else if (i * 2 + 1 == healthLast) { + this.blit(matrixStack, x, y, MARGIN + 63, TOP, 9, 9, ICON_VANILLA); // 7 } } if (absorbRemaining > 0.0F) { if (absorbRemaining == absorb && absorb % 2.0F == 1.0F) { - this.blit(matrixStack, x, y, MARGIN + 153, TOP, 9, 9); //17 + this.blit(matrixStack, x, y, MARGIN + 153, TOP, 9, 9, ICON_VANILLA); // 17 absorbRemaining -= 1.0F; - } - else { - this.blit(matrixStack, x, y, MARGIN + 144, TOP, 9, 9); //16 + } else { + this.blit(matrixStack, x, y, MARGIN + 144, TOP, 9, 9, ICON_VANILLA); // 16 absorbRemaining -= 2.0F; } - } - else { + } else { if (i * 2 + 1 < health) { - this.blit(matrixStack, x, y, MARGIN + 36, TOP, 9, 9); //4 - } - else if (i * 2 + 1 == health) { - this.blit(matrixStack, x, y, MARGIN + 45, TOP, 9, 9); //5 + this.blit(matrixStack, x, y, MARGIN + 36, TOP, 9, 9, ICON_VANILLA); // 4 + } else if (i * 2 + 1 == health) { + this.blit(matrixStack, x, y, MARGIN + 45, TOP, 9, 9, ICON_VANILLA); // 5 } } } @@ -200,22 +220,23 @@ public class HeartsRenderer { this.renderExtraAbsorption(matrixStack, left, top - rowHeight, player); RenderSystem.setShaderTexture(0, ICON_VANILLA); - gui.left_height += 10; + gui.leftHeight += 10; if (absorb > 0) { - gui.left_height += 10; + gui.leftHeight += 10; } event.setCanceled(true); RenderSystem.disableBlend(); this.mc.getProfiler().pop(); - MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.PostLayer(matrixStack, event, ForgeIngameGui.PLAYER_HEALTH_ELEMENT)); + MinecraftForge.EVENT_BUS + .post(new RenderGuiOverlayEvent.Post(mc.getWindow(), event.getGuiGraphics(), event.getPartialTick(), ActualOverlay)); } - /** * Gets the texture from potion effects - * @param player Player instance - * @return Texture offset for potion effects + * + * @param player Player instance + * @return Texture offset for potion effects */ private int getPotionOffset(Player player) { int potionOffset = 0; @@ -236,12 +257,13 @@ public class HeartsRenderer { /** * Renders the health above 10 hearts - * @param matrixStack Matrix stack instance - * @param xBasePos Health bar top corner - * @param yBasePos Health bar top corner - * @param player Player instance + * + * @param matrixStack Matrix stack instance + * @param xBasePos Health bar top corner + * @param yBasePos Health bar top corner + * @param player Player instance */ - private void renderExtraHearts(PoseStack matrixStack, int xBasePos, int yBasePos, Player player) { + private void renderExtraHearts(GuiGraphics matrixStack, int xBasePos, int yBasePos, Player player) { int potionOffset = this.getPotionOffset(player); // Extra hearts @@ -250,15 +272,15 @@ public class HeartsRenderer { this.renderCustomHearts(matrixStack, xBasePos, yBasePos, potionOffset, hp, false); } - /** * Renders the absorption health above 10 hearts - * @param matrixStack Matrix stack instance - * @param xBasePos Health bar top corner - * @param yBasePos Health bar top corner - * @param player Player instance + * + * @param matrixStack Matrix stack instance + * @param xBasePos Health bar top corner + * @param yBasePos Health bar top corner + * @param player Player instance */ - private void renderExtraAbsorption(PoseStack matrixStack, int xBasePos, int yBasePos, Player player) { + private void renderExtraAbsorption(GuiGraphics matrixStack, int xBasePos, int yBasePos, Player player) { int potionOffset = this.getPotionOffset(player); // Extra hearts @@ -269,8 +291,9 @@ public class HeartsRenderer { /** * Gets the texture offset from the regen effect - * @param i Heart index - * @param offset Current offset + * + * @param i Heart index + * @param offset Current offset */ private int getYRegenOffset(int i, int offset) { return i + offset == this.regen ? -2 : 0; @@ -278,6 +301,7 @@ public class HeartsRenderer { /** * Shared logic to render custom hearts + * * @param matrixStack Matrix stack instance * @param xBasePos Health bar top corner * @param yBasePos Health bar top corner @@ -285,7 +309,8 @@ public class HeartsRenderer { * @param count Number to render * @param absorb If true, render absorption hearts */ - private void renderCustomHearts(PoseStack matrixStack, int xBasePos, int yBasePos, int potionOffset, int count, boolean absorb) { + private void renderCustomHearts(GuiGraphics matrixStack, int xBasePos, int yBasePos, int potionOffset, int count, + boolean absorb) { int regenOffset = absorb ? 10 : 0; for (int iter = 0; iter < count / 20; iter++) { int renderHearts = (count - 20 * (iter + 1)) / 2; @@ -296,16 +321,16 @@ public class HeartsRenderer { for (int i = 0; i < renderHearts; i++) { int y = this.getYRegenOffset(i, regenOffset); if (absorb) { - this.blit(matrixStack, xBasePos + 8 * i, yBasePos + y, 0, 54, 9, 9); + this.blit(matrixStack, xBasePos + 8 * i, yBasePos + y, 0, 54, 9, 9, ICON_ABSORB); } - this.blit(matrixStack, xBasePos + 8 * i, yBasePos + y, 18 * heartIndex, potionOffset, 9, 9); + this.blit(matrixStack, xBasePos + 8 * i, yBasePos + y, 18 * heartIndex, potionOffset, 9, 9, ICON_HEARTS); } if (count % 2 == 1 && renderHearts < 10) { int y = this.getYRegenOffset(renderHearts, regenOffset); if (absorb) { - this.blit(matrixStack, xBasePos + 8 * renderHearts, yBasePos + y, 0, 54, 9, 9); + this.blit(matrixStack, xBasePos + 8 * renderHearts, yBasePos + y, 0, 54, 9, 9, ICON_ABSORB); } - this.blit(matrixStack, xBasePos + 8 * renderHearts, yBasePos + y, 9 + 18 * heartIndex, potionOffset, 9, 9); + this.blit(matrixStack, xBasePos + 8 * renderHearts, yBasePos + y, 9 + 18 * heartIndex, potionOffset, 9, 9, ICON_HEARTS); } } } diff --git a/src/main/java/dev/zontreck/essentials/homes/HomesSuggestionProvider.java b/src/main/java/dev/zontreck/essentials/homes/HomesSuggestionProvider.java index e7f098a..63629d9 100644 --- a/src/main/java/dev/zontreck/essentials/homes/HomesSuggestionProvider.java +++ b/src/main/java/dev/zontreck/essentials/homes/HomesSuggestionProvider.java @@ -16,7 +16,7 @@ import java.util.concurrent.CompletableFuture; public class HomesSuggestionProvider { public static SuggestionProvider PROVIDER = (ctx,suggestionsBuilder)->{ - Homes homes = HomesProvider.getHomesForPlayer(ctx.getSource().getPlayerOrException().getUUID().toString()); + Homes homes = HomesProvider.getHomesForPlayer(ctx.getSource().getPlayer().getUUID().toString()); List homesList = new ArrayList<>(); diff --git a/src/main/java/dev/zontreck/essentials/networking/ModMessages.java b/src/main/java/dev/zontreck/essentials/networking/ModMessages.java index dd3a5ef..410904f 100644 --- a/src/main/java/dev/zontreck/essentials/networking/ModMessages.java +++ b/src/main/java/dev/zontreck/essentials/networking/ModMessages.java @@ -30,10 +30,10 @@ public class ModMessages { net.messageBuilder(S2CUpdateHearts.class, id(), NetworkDirection.PLAY_TO_CLIENT) - .decoder(S2CUpdateHearts::new) - .encoder(S2CUpdateHearts::toBytes) - .consumer(S2CUpdateHearts::handle) - .add(); + .decoder(S2CUpdateHearts::new) + .encoder(S2CUpdateHearts::toBytes) + .consumerMainThread(S2CUpdateHearts::handle) + .add(); } diff --git a/src/main/java/dev/zontreck/essentials/rtp/RTP.java b/src/main/java/dev/zontreck/essentials/rtp/RTP.java index 8311708..186a81b 100644 --- a/src/main/java/dev/zontreck/essentials/rtp/RTP.java +++ b/src/main/java/dev/zontreck/essentials/rtp/RTP.java @@ -8,7 +8,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Vec3i; import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; @@ -21,87 +20,124 @@ import java.util.Iterator; import java.util.List; import java.util.Random; -public class RTP { - private static final List BLACKLIST = Lists.of(Blocks.LAVA, Blocks.WATER, Blocks.BEDROCK); - private final int SEARCH_DIRECTION; - private final Heightmap.Types heightMapType; - public WorldPosition position; - private final ServerLevel dimension; - private int tries; +/** + * As of v1.1.121823.x, this is now used for RTP + *

+ * This ensures that RTP is only scanned once every so often. This is because RTP lags the server when it is having to check block positions. + *

+ * If the RTP system scans each dimension (Not blacklisted), then it can build a list of safe locations that will be rotated out every 2 hours. + *

+ * Every 10 minutes, a new RTP location is scanned. This ensures sufficiently semi-random locations. Eventually old locations will be removed from the list. + *

+ * At server start, it will scan 10 RTP locations per dimension while there are no players. + */ +public class RTP +{ + public RTP(ServerLevel level) + { + position = new WorldPosition(new Vector3(0,500,0), WorldPosition.getDim(level)); - public RTP(ServerLevel level) { - position = new WorldPosition(new Vector3(0, -60, 0), WorldPosition.getDim(level)); - dimension = position.getActualDimension(); - - if (position.getActualDimension().dimensionType().hasCeiling()) { + if(position.getActualDimension().dimensionType().hasCeiling()) + { heightMapType = Heightmap.Types.MOTION_BLOCKING_NO_LEAVES; - SEARCH_DIRECTION = -1; - } else { + SearchDirection=-1; + }else { heightMapType = Heightmap.Types.MOTION_BLOCKING_NO_LEAVES; - SEARCH_DIRECTION = 1; + SearchDirection=1; } } + private final int SearchDirection; + private Thread containingThread; + private final Heightmap.Types heightMapType; + public WorldPosition position; + private final List BLACKLIST = Lists.of(Blocks.LAVA, Blocks.WATER, Blocks.BEDROCK); + protected int tries; + protected int lastThreadDelay = 15; - public boolean isDimension(ServerLevel level) { + protected RTP withThreadDelay(int delay) + { + lastThreadDelay=delay; + if(lastThreadDelay >= 60) lastThreadDelay = 60; + return this; + } + + public boolean isDimension(ServerLevel level) + { String dim = WorldPosition.getDim(level); return dim.equals(position.Dimension); } - public BlockPos findSafeLandingLocation() { - BlockPos targetPos = position.Position.asBlockPos(); - - // Search upward for a safe landing location - while (!isSafe(targetPos) || !isSafe(targetPos.above())) { - targetPos = targetPos.above(); - } - - return targetPos; + /** + * Searches for, and finds, a valid RTP location + * @param level The level to scan + * @return RTP data + */ + public static void find(ServerLevel level) + { + RandomPositionFactory.beginRTPSearch(level); } - private boolean isSafe(BlockPos blockPos) { - BlockState blockState = dimension.getBlockState(blockPos); - BlockState blockStateAbove = dimension.getBlockState(blockPos.above()); - BlockState blockStateBelow = dimension.getBlockState(blockPos.below()); + public static List slicedByDimension(ServerLevel lvl) + { + List slice = new ArrayList<>(); - if (blockState.isAir() && blockStateAbove.isAir()) { - if (!blockStateBelow.isAir()) { - return !BLACKLIST.contains(blockStateBelow.getBlock()); - } else { - return false; + Iterator it = RTPCaches.Locations.iterator(); + while(it.hasNext()) + { + RTP nxt = it.next(); + if(nxt.isDimension(lvl)) + { + slice.add(nxt); } - } else { - return false; } + + return slice; } - public static RTP getRTP(ServerLevel level) { + public static RTP getRTP(ServerLevel level) + { List slice = slicedByDimension(level); - if (!slice.isEmpty()) { - RTP ret = slice.get(AriasEssentials.random.nextInt(slice.size())); + if(slice.size()>0) + { + RTP ret = slice.get(AriasEssentials.random.nextInt(0, slice.size())); RTPCaches.Locations.remove(ret); RandomPositionFactory.beginRTPSearch(ret.position.getActualDimension()); return ret; - } else { - return null; + } else return null; + } + + + public void moveDown() { + position.Position = position.Position.moveDown(); + } + + public void moveUp() { + position.Position = position.Position.moveUp(); + } + + public void move() + { + if(SearchDirection==1){ + moveUp(); + }else if(SearchDirection==0) + { + moveDown(); } } - - public void move() { - if (SEARCH_DIRECTION == 1) { - position.Position = position.Position.moveUp(); - } else if (SEARCH_DIRECTION == -1) { - position.Position = position.Position.moveDown(); + public void moveOpposite() + { + if(SearchDirection==1){ + moveDown(); + }else if(SearchDirection==0) + { + moveUp(); } } - - public void moveOpposite() { - move(); - } - public void newPosition() { - if (!AriasEssentials.ALIVE || tries >= 5) return; + if (!AriasEssentials.ALIVE || tries >= 25) return; - AriasEssentials.LOGGER.info("RTP starts looking for a new position"); + containingThread = Thread.currentThread(); + AriasEssentials.LOGGER.info("RTP starts looking for new position"); Random rng = new Random(Instant.now().getEpochSecond()); @@ -109,27 +145,37 @@ public class RTP { BlockPos bpos; do { - pos = new Vector3(rng.nextDouble(0xFFFF), -60, rng.nextDouble(0xFFFF)); + pos = new Vector3(rng.nextDouble(0xFFFF), 150, rng.nextDouble(0xFFFF)); pos = spiralPositions(pos); position.Position = pos; bpos = pos.asBlockPos(); } while (!isValidPosition(bpos)); + + if (pos.y < -30 || pos.y >= position.getActualDimension().getLogicalHeight()) { + newPosition(); + return; + } + tries++; - AriasEssentials.LOGGER.info("RTP returns a new position"); + AriasEssentials.LOGGER.info("RTP returns new position"); } private boolean isValidPosition(BlockPos bpos) { + ServerLevel dimension = position.getActualDimension(); ChunkStatus status = ChunkStatus.SPAWN; + dimension.getChunk(bpos.getX() >> 4, bpos.getZ() >> 4, status); Vector3 pos = new Vector3(dimension.getHeightmapPos(heightMapType, bpos)); return dimension.getWorldBorder().isWithinBounds(pos.asBlockPos()); } + private Vector3 spiralPositions(Vector3 position) { Vec3i posi = position.asMinecraftVec3i(); + ServerLevel dimension = this.position.getActualDimension(); BlockPos startBlockPos = new BlockPos(posi.getX(), dimension.getSeaLevel(), posi.getZ()); for (BlockPos pos : BlockPos.spiralAround(startBlockPos, 16, Direction.WEST, Direction.NORTH)) { @@ -142,17 +188,32 @@ public class RTP { return position; } - public static List slicedByDimension(ServerLevel lvl) { - List slice = new ArrayList<>(); - Iterator it = RTPCaches.Locations.iterator(); - while (it.hasNext()) { - RTP nxt = it.next(); - if (nxt.isDimension(lvl)) { - slice.add(nxt); - } - } + private boolean safe(BlockPos blockPos) + { + containingThread=Thread.currentThread(); + BlockState b = position.getActualDimension().getBlockState(blockPos); + BlockState b2 = position.getActualDimension().getBlockState(blockPos.above()); + BlockState b3 = position.getActualDimension().getBlockState(blockPos.below()); - return slice; + if (b.isAir() && b2.isAir()) { + if (!b3.isAir()) { + return !BLACKLIST.contains(b3.getBlock()); + } else + return false; + } else + return false; + + } + public boolean isSafe(BlockPos blockPos) { + return safe(blockPos); + /* + boolean s = safe(blockPos); + if(s) + { + AriasEssentials.LOGGER.info("/!\\ SAFE /!\\"); + }else AriasEssentials.LOGGER.info("/!\\ NOT SAFE /!\\"); + + return s;*/ } } diff --git a/src/main/java/dev/zontreck/essentials/rtp/RTPCachesEventHandlers.java b/src/main/java/dev/zontreck/essentials/rtp/RTPCachesEventHandlers.java index a837ebd..68a5260 100644 --- a/src/main/java/dev/zontreck/essentials/rtp/RTPCachesEventHandlers.java +++ b/src/main/java/dev/zontreck/essentials/rtp/RTPCachesEventHandlers.java @@ -4,9 +4,7 @@ import dev.zontreck.essentials.AriasEssentials; import dev.zontreck.essentials.Messages; import dev.zontreck.essentials.commands.teleport.TeleportActioner; import dev.zontreck.essentials.events.RTPFoundEvent; -import dev.zontreck.libzontreck.LibZontreck; import dev.zontreck.libzontreck.util.ChatHelpers; -import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.TickEvent; @@ -21,7 +19,6 @@ public class RTPCachesEventHandlers { if(!AriasEssentials.ALIVE) return; lastTick++; - MinecraftServer server = LibZontreck.THE_SERVER; if(lastTick>=400) { lastTick=0; @@ -34,7 +31,7 @@ public class RTPCachesEventHandlers firstRun=false; AriasEssentials.LOGGER.info("Aria's Essentials startup is running. Scanning for initial RTP locations"); - for(ServerLevel level : server.getAllLevels()) + for(ServerLevel level : event.getServer().getAllLevels()) { if(AriasEssentials.DEBUG) { diff --git a/src/main/java/dev/zontreck/essentials/util/FileHandler.java b/src/main/java/dev/zontreck/essentials/util/FileHandler.java new file mode 100644 index 0000000..abc95b2 --- /dev/null +++ b/src/main/java/dev/zontreck/essentials/util/FileHandler.java @@ -0,0 +1,24 @@ +package dev.zontreck.essentials.util; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; + +public class FileHandler +{ + + public static String readFile(String filePath) { + try { + byte[] fileBytes = Files.readAllBytes(Paths.get(filePath)); + return new String(fileBytes); + } catch (IOException e) { + return "An error occurred: " + e.getMessage(); + } + } + public static void writeFile(String filePath, String newContent) { + try { + Files.write(Paths.get(filePath), newContent.getBytes()); + } catch (IOException e) { + } + } +} diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index e69de29..b4796c8 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -0,0 +1,5 @@ +public net.minecraft.client.gui.Gui +public net.minecraft.client.gui.Gui f_279580_ # GUI_ICONS_LOCATION +public net.minecraft.client.gui.Gui f_92974_ # displayHealth +public net.minecraft.client.gui.Gui f_92973_ # lastHealth +public net.minecraft.client.gui.Gui f_92976_ # healthBlinkTime \ No newline at end of file diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index f71a626..fd59e36 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -6,67 +6,71 @@ # The name of the mod loader type to load - for regular FML @Mod mods it should be javafml modLoader="javafml" #mandatory # A version range to match for said mod loader - for regular FML @Mod it will be the forge version -loaderVersion="[40,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. +loaderVersion="${loader_version_range}" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. # The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties. # Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here. -license="GPLv3" +license="${mod_license}" # A URL to refer people to when problems occur with this mod -#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional +issueTrackerURL="https://github.com/zontreck/Arias-Essentials/issues/" #optional # A list of mods - how many allowed here is determined by the individual mod loader [[mods]] #mandatory # The modid of the mod -modId="ariasessentials" #mandatory -# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it -# ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata -# see the associated build.gradle script for how to populate this completely automatically during a build -version="${file.jarVersion}" #mandatory +modId="${mod_id}" #mandatory +# The version number of the mod +version="${mod_version}" #mandatory # A display name for the mod -displayName="Aria's Essentials" #mandatory -# A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/ +displayName="${mod_name}" #mandatory +# A URL to query for updates for this mod. See the JSON update specification https://docs.minecraftforge.net/en/latest/misc/updatechecker/ #updateJSONURL="https://change.me.example.invalid/updates.json" #optional # A URL for the "homepage" for this mod, displayed in the mod UI #displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional # A file name (in the root of the mod JAR) containing a logo for display logoFile="ariasessentials.png" #optional # A text field displayed in the mod UI -credits="Thanks for this example mod goes to Java" #optional +#credits="" #optional # A text field displayed in the mod UI -authors="Love, Cheese and small house plants" #optional +authors="${mod_authors}" #optional # Display Test controls the display for your mod in the server connection screen # MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod. # IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod. # IGNORE_ALL_VERSION means that your mod will not cause a red X if it's present on the client or the server. This is a special case and should only be used if your mod has no server component. # NONE means that no display test is set on your mod. You need to do this yourself, see IExtensionPoint.DisplayTest for more information. You can define any scheme you wish with this value. # IMPORTANT NOTE: this is NOT an instruction as to which environments (CLIENT or DEDICATED SERVER) your mod loads on. Your mod should load (and maybe do nothing!) whereever it finds itself. -displayTest="MATCH_VERSION" # MATCH_VERSION is the default if nothing is specified (#optional) +#displayTest="MATCH_VERSION" # MATCH_VERSION is the default if nothing is specified (#optional) # The description text for the mod (multi line!) (#mandatory) -description=''' -Aria's Essentials mod. This provides a bunch of essential functions and commands -''' +description='''${mod_description}''' # A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional. -[[dependencies.ariasessentials]] #optional -# the modid of the dependency -modId="forge" #mandatory -# Does this dependency have to exist - if not, ordering below must be specified -mandatory=true #mandatory -# The version range of the dependency -versionRange="[40,)" #mandatory -# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory -ordering="NONE" -# Side this dependency is applied on - BOTH, CLIENT or SERVER -side="BOTH" +[[dependencies.${mod_id}]] #optional + # the modid of the dependency + modId="forge" #mandatory + # Does this dependency have to exist - if not, ordering below must be specified + mandatory=true #mandatory + # The version range of the dependency + versionRange="${forge_version_range}" #mandatory + # An ordering relationship for the dependency - BEFORE or AFTER required if the dependency is not mandatory + # BEFORE - This mod is loaded BEFORE the dependency + # AFTER - This mod is loaded AFTER the dependency + ordering="NONE" + # Side this dependency is applied on - BOTH, CLIENT, or SERVER + side="BOTH" # Here's another dependency -[[dependencies.ariasessentials]] -modId="minecraft" -mandatory=true -# This version range declares a minimum of the current minecraft version up to but not including the next major version -versionRange="[1.18.2,1.19)" -ordering="NONE" -side="BOTH" -[[dependencies.libzontreck]] -modId="libzontreck" -mandatory=true -versionRange="[1.10,1.11)" -ordering="NONE" -side="BOTH" \ No newline at end of file +[[dependencies.${mod_id}]] + modId="minecraft" + mandatory=true + # This version range declares a minimum of the current minecraft version up to but not including the next major version + versionRange="${minecraft_version_range}" + ordering="NONE" + side="BOTH" +[[dependencies.${mod_id}]] + modId="libzontreck" + mandatory=true + versionRange="[1.10,1.11)" + ordering="NONE" + side="BOTH" + +# Features are specific properties of the game environment, that you may want to declare you require. This example declares +# that your mod requires GL version 3.2 or higher. Other features will be added. They are side aware so declaring this won't +# stop your mod loading on the server for example. +#[features.${mod_id}] +#openGLVersion="[3.2,)" \ No newline at end of file diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta index d60a22f..eca79ae 100644 --- a/src/main/resources/pack.mcmeta +++ b/src/main/resources/pack.mcmeta @@ -1,8 +1,8 @@ { "pack": { - "description": "Aria's Essentials resources", - "pack_format": 9, - "forge:resource_pack_format": 8, - "forge:data_pack_format": 9 + "description": { + "text": "${mod_id} resources" + }, + "pack_format": 15 } } \ No newline at end of file