diff --git a/build.gradle b/build.gradle index 783d07c..d55b489 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { id 'idea' id 'maven-publish' id 'java-library' - id 'net.minecraftforge.gradle' version '[6.0,6.2)' + id 'net.minecraftforge.gradle' version '5.1.+' id 'org.parchmentmc.librarian.forgegradle' version '1.+' } @@ -53,7 +53,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 + //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. @@ -187,7 +187,7 @@ dependencies { // 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 { +/*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, @@ -200,7 +200,7 @@ tasks.named('processResources', ProcessResources).configure { 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 50bba12..84387da 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,25 +4,25 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -parchment_version=2023.09.03 +parchment_version=2022.11.06 # luckperms_api_version=5.4 -libac=1.4.18 +libac=1.4.19 eventsbus=1.0.31 ## Environment Properties # The Minecraft version must agree with the Forge version to get a valid artifact -minecraft_version=1.20.1 +minecraft_version=1.18.2 # 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.20.1,1.21) +minecraft_version_range=[1.18.2,1.19) # The Forge version must agree with the Minecraft version to get a valid artifact -forge_version=47.2.0 +forge_version=40.2.17 # The Forge version range can use any version of Forge as bounds or match the loader version range -forge_version_range=[47,) +forge_version_range=[40,) # The loader version range can only use the major version of Forge/FML as bounds -loader_version_range=[47,) +loader_version_range=[40,) # 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. @@ -40,7 +40,7 @@ loader_version_range=[47,) mapping_channel=parchment # The mapping version to query from the mapping channel. # This must match the format required by the mapping channel. -mapping_version=2023.09.03-1.20.1 +mapping_version=2022.11.06-1.18.2 ## Mod Properties @@ -53,7 +53,7 @@ mod_name=Zontreck Library Mod # 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.10.011524.0045 +mod_version=1.10.012124.1709 # 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 fae0804..ae04661 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle index 8a72e7b..7f4682f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,8 +3,4 @@ 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/libzontreck/LibZontreck.java b/src/main/java/dev/zontreck/libzontreck/LibZontreck.java index eafd174..bc5fe5e 100644 --- a/src/main/java/dev/zontreck/libzontreck/LibZontreck.java +++ b/src/main/java/dev/zontreck/libzontreck/LibZontreck.java @@ -13,13 +13,11 @@ import dev.zontreck.eventsbus.Bus; import dev.zontreck.libzontreck.chestgui.ChestGUIRegistry; import dev.zontreck.libzontreck.currency.Bank; import dev.zontreck.libzontreck.currency.CurrencyHelper; -import dev.zontreck.libzontreck.items.CreativeModeTabs; import dev.zontreck.libzontreck.items.ModItems; import dev.zontreck.libzontreck.menus.ChestGUIScreen; import dev.zontreck.libzontreck.types.ModMenuTypes; import dev.zontreck.libzontreck.networking.NetworkEvents; import net.minecraft.client.gui.screens.MenuScreens; -import net.minecraftforge.registries.RegisterEvent; import org.slf4j.Logger; import com.mojang.logging.LogUtils; diff --git a/src/main/java/dev/zontreck/libzontreck/blocks/BlockImitation.java b/src/main/java/dev/zontreck/libzontreck/blocks/BlockImitation.java deleted file mode 100644 index ab23bd1..0000000 --- a/src/main/java/dev/zontreck/libzontreck/blocks/BlockImitation.java +++ /dev/null @@ -1,95 +0,0 @@ -package dev.zontreck.libzontreck.blocks; - -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.entity.Entity; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.biome.Biome; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; - -/** - * Code partially taken from HT's TreeChop - *

- * Source Material - */ -public abstract class BlockImitation extends Block -{ - public BlockImitation(Properties pProperties) { - super(pProperties); - } - - - public abstract BlockState getImitatedBlockState(BlockGetter level, BlockPos pos); - - public abstract void updateImitation(BlockState newState, BlockGetter level, BlockPos pos); - - @Override - public void animateTick(BlockState blockState, Level level, BlockPos pos, RandomSource random) { - BlockState imitatedBlockState = getImitatedBlockState(level, pos); - imitatedBlockState.getBlock().animateTick(imitatedBlockState, level, pos, random); - } - - @Override - public void stepOn(Level level, BlockPos pos, BlockState blockState, Entity entity) { - BlockState imitatedBlockState = getImitatedBlockState(level, pos); - imitatedBlockState.getBlock().stepOn(level, pos, imitatedBlockState, entity); - } - - @Override - public void fallOn(Level level, BlockState blockState, BlockPos pos, Entity entity, float speed) { - BlockState imitatedBlockState = getImitatedBlockState(level, pos); - imitatedBlockState.getBlock().fallOn(level, imitatedBlockState, pos, entity, speed); - } - - @Override - public ItemStack getCloneItemStack(BlockGetter level, BlockPos pos, BlockState blockState) { - BlockState imitatedBlockState = getImitatedBlockState(level, pos); - return imitatedBlockState.getBlock().getCloneItemStack(level, pos, imitatedBlockState); - } - - @Override - public void handlePrecipitation(BlockState blockState, Level level, BlockPos pos, Biome.Precipitation precipitation) { - BlockState imitatedBlockState = getImitatedBlockState(level, pos); - imitatedBlockState.getBlock().handlePrecipitation(imitatedBlockState, level, pos, precipitation); - } - - @Override - public int getLightBlock(BlockState blockState, BlockGetter level, BlockPos pos) { - return super.getLightBlock(blockState, level, pos); - } - - @Override - public float getShadeBrightness(BlockState blockState, BlockGetter level, BlockPos pos) { - return super.getShadeBrightness(blockState, level, pos); - } - - @Override - public int getAnalogOutputSignal(BlockState blockState, Level level, BlockPos pos) { - return getImitatedBlockState(level, pos).getAnalogOutputSignal(level, pos); - } - - @Override - public void randomTick(BlockState blockState, ServerLevel level, BlockPos pos, RandomSource random) { - getImitatedBlockState(level, pos).randomTick(level, pos, random); - } - - @Override - public void tick(BlockState blockState, ServerLevel level, BlockPos pos, RandomSource random) { - getImitatedBlockState(level, pos).tick(level, pos, random); - } - - @Override - public int getSignal(BlockState blockState, BlockGetter level, BlockPos pos, Direction direction) { - return getImitatedBlockState(level, pos).getSignal(level, pos, direction); - } - - @Override - public int getDirectSignal(BlockState blockState, BlockGetter level, BlockPos pos, Direction direction) { - return getImitatedBlockState(level, pos).getDirectSignal(level, pos, direction); - } -} diff --git a/src/main/java/dev/zontreck/libzontreck/chat/HoverTip.java b/src/main/java/dev/zontreck/libzontreck/chat/HoverTip.java index 2eafb13..083d974 100644 --- a/src/main/java/dev/zontreck/libzontreck/chat/HoverTip.java +++ b/src/main/java/dev/zontreck/libzontreck/chat/HoverTip.java @@ -1,5 +1,6 @@ package dev.zontreck.libzontreck.chat; +import dev.zontreck.libzontreck.util.ChatHelpers; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.HoverEvent; import net.minecraft.network.chat.HoverEvent.Action; @@ -17,7 +18,7 @@ public class HoverTip { */ public static HoverEvent get(String text) { - return new HoverEvent(Action.SHOW_TEXT, Component.literal(text)); + return new HoverEvent(Action.SHOW_TEXT, ChatHelpers.macro(text)); } /** diff --git a/src/main/java/dev/zontreck/libzontreck/chestgui/ChestGUI.java b/src/main/java/dev/zontreck/libzontreck/chestgui/ChestGUI.java index ae829ec..445281c 100644 --- a/src/main/java/dev/zontreck/libzontreck/chestgui/ChestGUI.java +++ b/src/main/java/dev/zontreck/libzontreck/chestgui/ChestGUI.java @@ -7,6 +7,7 @@ import dev.zontreck.libzontreck.items.ModItems; import dev.zontreck.libzontreck.menus.ChestGUIMenu; import dev.zontreck.libzontreck.networking.ModMessages; import dev.zontreck.libzontreck.networking.packets.S2CCloseChestGUI; +import dev.zontreck.libzontreck.util.ChatHelpers; import dev.zontreck.libzontreck.util.ServerUtilities; import dev.zontreck.libzontreck.vectors.Vector2; import dev.zontreck.libzontreck.vectors.Vector2i; @@ -198,7 +199,7 @@ public class ChestGUI { updateUtilityButtons(); MinecraftForge.EVENT_BUS.post(new OpenGUIEvent(id, player, this)); - NetworkHooks.openScreen(ServerUtilities.getPlayerByID(player.toString()), new SimpleMenuProvider(ChestGUIMenu.getServerMenu(this), Component.literal((MenuTitle != "") ? MenuTitle : "No Title"))); + NetworkHooks.openGui(ServerUtilities.getPlayerByID(player.toString()), new SimpleMenuProvider(ChestGUIMenu.getServerMenu(this), ChatHelpers.macro(((MenuTitle != "") ? MenuTitle : "No Title")))); } } diff --git a/src/main/java/dev/zontreck/libzontreck/currency/Account.java b/src/main/java/dev/zontreck/libzontreck/currency/Account.java index e0b81f8..bef02ff 100644 --- a/src/main/java/dev/zontreck/libzontreck/currency/Account.java +++ b/src/main/java/dev/zontreck/libzontreck/currency/Account.java @@ -6,7 +6,6 @@ import dev.zontreck.libzontreck.chat.ChatColor; import dev.zontreck.libzontreck.currency.events.TransactionHistoryFlushEvent; import dev.zontreck.libzontreck.profiles.Profile; import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException; -import net.minecraft.core.UUIDUtil; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.NbtUtils; diff --git a/src/main/java/dev/zontreck/libzontreck/events/ForgeEventHandlers.java b/src/main/java/dev/zontreck/libzontreck/events/ForgeEventHandlers.java index c2813ec..22895f2 100644 --- a/src/main/java/dev/zontreck/libzontreck/events/ForgeEventHandlers.java +++ b/src/main/java/dev/zontreck/libzontreck/events/ForgeEventHandlers.java @@ -23,9 +23,9 @@ import net.minecraftforge.fml.common.Mod; public class ForgeEventHandlers { @SubscribeEvent - public void onPlayerTick(LivingEvent.LivingTickEvent ev) + public void onPlayerTick(LivingEvent.LivingUpdateEvent ev) { - if(ev.getEntity().level().isClientSide) return; + if(ServerUtilities.isClient()) return; if(ev.getEntity() instanceof ServerPlayer player) { @@ -44,11 +44,11 @@ public class ForgeEventHandlers { @SubscribeEvent public void onPlayerJoin(final PlayerEvent.PlayerLoggedInEvent ev) { - if(ev.getEntity().level().isClientSide)return; + if(ServerUtilities.isClient())return; ServerPlayer player = (ServerPlayer)ev.getEntity(); Profile prof = Profile.factory(player); - ServerLevel level = player.serverLevel(); + ServerLevel level = player.getLevel(); MinecraftForge.EVENT_BUS.post(new ProfileLoadedEvent(prof, player, level)); @@ -68,7 +68,7 @@ public class ForgeEventHandlers { public void onLeave(final PlayerEvent.PlayerLoggedOutEvent ev) { LibZontreck.LIBZONTRECK_SERVER_AVAILABLE=false; // Yes do this even on the client! - if(ev.getEntity().level().isClientSide)return; + if(ServerUtilities.isClient()) return; // Get player profile, send disconnect alert, then commit profile and remove it from memory try { diff --git a/src/main/java/dev/zontreck/libzontreck/items/CreativeModeTabs.java b/src/main/java/dev/zontreck/libzontreck/items/CreativeModeTabs.java deleted file mode 100644 index 5a24937..0000000 --- a/src/main/java/dev/zontreck/libzontreck/items/CreativeModeTabs.java +++ /dev/null @@ -1,46 +0,0 @@ -package dev.zontreck.libzontreck.items; - -import dev.zontreck.libzontreck.LibZontreck; -import net.minecraft.core.registries.Registries; -import net.minecraft.network.chat.Component; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.Items; -import net.minecraft.world.level.ItemLike; -import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.RegistryObject; - -import java.util.ArrayList; -import java.util.List; -import java.util.function.Supplier; - -//@Mod.EventBusSubscriber(modid = LibZontreck.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) -public class CreativeModeTabs -{ - public static final DeferredRegister REGISTRY = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, LibZontreck.MOD_ID); - - public static final List> LZ_MOD_ITEMS = new ArrayList<>(); - - public static final RegistryObject LIBZONTRECK_TAB = REGISTRY.register("libzontreck", ()->CreativeModeTab.builder() - .title(Component.translatable("itemGroup.tabs.libzontreck")) - .icon(Items.BARRIER::getDefaultInstance) - .displayItems((display,output)->LZ_MOD_ITEMS.forEach(it->output.accept(it.get()))) - .build() - ); - - public static RegistryObject addToLZTab(RegistryObject item) - { - LZ_MOD_ITEMS.add(item); - return item; - } - - - public static void register(IEventBus bus) - { - REGISTRY.register(bus); - } - -} diff --git a/src/main/java/dev/zontreck/libzontreck/menus/ChestGUIScreen.java b/src/main/java/dev/zontreck/libzontreck/menus/ChestGUIScreen.java index 9ae9ee4..c736c76 100644 --- a/src/main/java/dev/zontreck/libzontreck/menus/ChestGUIScreen.java +++ b/src/main/java/dev/zontreck/libzontreck/menus/ChestGUIScreen.java @@ -1,9 +1,9 @@ package dev.zontreck.libzontreck.menus; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import dev.zontreck.libzontreck.LibZontreck; import dev.zontreck.libzontreck.chestgui.ChestGUI; -import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.network.chat.Component; @@ -35,7 +35,7 @@ public class ChestGUIScreen extends AbstractContainerScreen { } @Override - public void render(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) { + public void render(PoseStack pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) { this.renderBackground(pGuiGraphics); super.render(pGuiGraphics, pMouseX, pMouseY, pPartialTick); this.renderTooltip(pGuiGraphics, pMouseX, pMouseY); @@ -50,17 +50,18 @@ public class ChestGUIScreen extends AbstractContainerScreen { } @Override - protected void renderBg(GuiGraphics guiGraphics, float v, int i, int i1) { + protected void renderBg(PoseStack guiGraphics, float v, int i, int i1) { renderBackground(guiGraphics); RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShaderColor(1,1,1,1); RenderSystem.setShaderTexture(0, TEXTURE); - guiGraphics.blit(TEXTURE, this.leftPos, this.topPos, 0, 0, imageWidth, imageHeight); + blit(guiGraphics, this.leftPos, this.topPos, 0, 0, imageWidth, imageHeight); } @Override - protected void renderLabels(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY) { - pGuiGraphics.drawString(this.font, this.title, this.titleLabelX, this.titleLabelY, 4210752, false); + protected void renderLabels(PoseStack pGuiGraphics, int pMouseX, int pMouseY) { + + drawString(pGuiGraphics, this.font, this.title, this.titleLabelX, this.titleLabelY, 4210752); } } diff --git a/src/main/java/dev/zontreck/libzontreck/networking/ModMessages.java b/src/main/java/dev/zontreck/libzontreck/networking/ModMessages.java index 002a9ac..5345c37 100644 --- a/src/main/java/dev/zontreck/libzontreck/networking/ModMessages.java +++ b/src/main/java/dev/zontreck/libzontreck/networking/ModMessages.java @@ -49,21 +49,21 @@ public class ModMessages { net.messageBuilder(S2CPlaySoundPacket.class, PACKET_ID.getAndIncrement(), NetworkDirection.PLAY_TO_CLIENT) .decoder(S2CPlaySoundPacket::new) - .encoder(S2CPlaySoundPacket::toBytes) - .consumerMainThread(S2CPlaySoundPacket::handle) - .add(); + .encoder(S2CPlaySoundPacket::toBytes) + .consumer(S2CPlaySoundPacket::handle) + .add(); net.messageBuilder(S2CCloseChestGUI.class, PACKET_ID.getAndIncrement(), NetworkDirection.PLAY_TO_CLIENT) .decoder(S2CCloseChestGUI::new) .encoder(S2CCloseChestGUI::toBytes) - .consumerMainThread(S2CCloseChestGUI::handle) + .consumer(S2CCloseChestGUI::handle) .add(); net.messageBuilder(S2CServerAvailable.class, PACKET_ID.getAndIncrement(), NetworkDirection.PLAY_TO_CLIENT) .decoder(S2CServerAvailable::new) .encoder(S2CServerAvailable::toBytes) - .consumerMainThread(S2CServerAvailable::handle) + .consumer(S2CServerAvailable::handle) .add(); } diff --git a/src/main/java/dev/zontreck/libzontreck/networking/packets/S2CPlaySoundPacket.java b/src/main/java/dev/zontreck/libzontreck/networking/packets/S2CPlaySoundPacket.java index 4d79616..da1732b 100644 --- a/src/main/java/dev/zontreck/libzontreck/networking/packets/S2CPlaySoundPacket.java +++ b/src/main/java/dev/zontreck/libzontreck/networking/packets/S2CPlaySoundPacket.java @@ -48,7 +48,8 @@ public class S2CPlaySoundPacket implements IPacket ctx.enqueueWork(()->{ // We are on the client now, enqueue the sound! - SoundEvent ev = SoundEvent.createFixedRangeEvent(sound, 2.0f); + SoundEvent ev = new SoundEvent(sound); + // Play sound for player! Minecraft.getInstance().player.playSound(ev, 1, BinUtil.getARandomInstance().nextFloat(0, 1)); }); diff --git a/src/main/java/dev/zontreck/libzontreck/types/ModMenuTypes.java b/src/main/java/dev/zontreck/libzontreck/types/ModMenuTypes.java index cfecba4..0e8d0e8 100644 --- a/src/main/java/dev/zontreck/libzontreck/types/ModMenuTypes.java +++ b/src/main/java/dev/zontreck/libzontreck/types/ModMenuTypes.java @@ -13,7 +13,7 @@ import net.minecraftforge.registries.RegistryObject; public class ModMenuTypes { - public static DeferredRegister> REGISTRY = DeferredRegister.create(ForgeRegistries.MENU_TYPES, LibZontreck.MOD_ID); + public static DeferredRegister> REGISTRY = DeferredRegister.create(ForgeRegistries.CONTAINERS, LibZontreck.MOD_ID); public static RegistryObject> CHEST_GUI_MENU = registerMenuType(ChestGUIMenu::new, "chestgui"); diff --git a/src/main/java/dev/zontreck/libzontreck/util/ChatHelpers.java b/src/main/java/dev/zontreck/libzontreck/util/ChatHelpers.java index fb6dc04..02f6f56 100644 --- a/src/main/java/dev/zontreck/libzontreck/util/ChatHelpers.java +++ b/src/main/java/dev/zontreck/libzontreck/util/ChatHelpers.java @@ -111,7 +111,7 @@ public class ChatHelpers { */ public static MutableComponent macro(String input, String... inputs) { - return Component.literal(macroize(input,inputs)); + return new TextComponent(macroize(input,inputs)); } /** * Returns the output with colors applied, and chat entries replaced using [number] as the format diff --git a/src/main/java/dev/zontreck/libzontreck/util/SNbtIo.java b/src/main/java/dev/zontreck/libzontreck/util/SNbtIo.java new file mode 100644 index 0000000..40fcbb6 --- /dev/null +++ b/src/main/java/dev/zontreck/libzontreck/util/SNbtIo.java @@ -0,0 +1,46 @@ +package dev.zontreck.libzontreck.util; + +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import dev.zontreck.ariaslib.util.FileIO; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtIo; +import net.minecraft.nbt.NbtUtils; + +import java.io.File; +import java.nio.file.Path; + +/** + * Provides helpers for reading and writing snbt to file + */ +public class SNbtIo +{ + /** + * Read the file at the path, and deserialize from snbt + * @param path The file to load + * @return The deserialized compound tag, or a blank tag + */ + public static CompoundTag loadSnbt(Path path) + { + if(!path.toFile().exists()) + return new CompoundTag(); + else { + File fi = path.toFile(); + try { + return NbtUtils.snbtToStructure(FileIO.readFile(fi.getAbsolutePath())); + } catch (CommandSyntaxException e) { + return new CompoundTag(); + } + } + } + + /** + * Writes the tag to the file specified + * @param path The file to write + * @param tag The tag to serialize + */ + public static void writeSnbt(Path path, CompoundTag tag) + { + String snbt = NbtUtils.structureToSnbt(tag); + FileIO.writeFile(path.toFile().getAbsolutePath(), snbt); + } +} diff --git a/src/main/java/dev/zontreck/libzontreck/util/ServerUtilities.java b/src/main/java/dev/zontreck/libzontreck/util/ServerUtilities.java index abd8d57..d1b753b 100644 --- a/src/main/java/dev/zontreck/libzontreck/util/ServerUtilities.java +++ b/src/main/java/dev/zontreck/libzontreck/util/ServerUtilities.java @@ -40,7 +40,7 @@ public class ServerUtilities channel.messageBuilder(type, ModMessages.id(), packet.getDirection()) .decoder(decoder) .encoder(X::toBytes) - .consumerMainThread(X::handle) + .consumer(X::handle) .add(); } diff --git a/src/main/java/dev/zontreck/libzontreck/util/heads/CreditsEntry.java b/src/main/java/dev/zontreck/libzontreck/util/heads/CreditsEntry.java index 67a92a0..2c228bf 100644 --- a/src/main/java/dev/zontreck/libzontreck/util/heads/CreditsEntry.java +++ b/src/main/java/dev/zontreck/libzontreck/util/heads/CreditsEntry.java @@ -4,6 +4,7 @@ import dev.zontreck.libzontreck.chat.ChatColor; import dev.zontreck.libzontreck.lore.ExtraLore; import dev.zontreck.libzontreck.lore.LoreContainer; import dev.zontreck.libzontreck.lore.LoreEntry; +import dev.zontreck.libzontreck.util.ChatHelpers; import dev.zontreck.libzontreck.util.heads.HeadCache.HeadCacheItem; import net.minecraft.network.chat.Component; import net.minecraft.world.item.ItemStack; @@ -28,7 +29,7 @@ public class CreditsEntry { public ItemStack compile() { ItemStack stack = player.getAsItem(""); - stack.setHoverName(Component.literal(name)); + stack.setHoverName(ChatHelpers.macro(name)); LoreContainer contain = new LoreContainer(stack); contain.clear(); LoreEntry.Builder builder = new LoreEntry.Builder(); diff --git a/src/main/java/dev/zontreck/libzontreck/vectors/WorldPosition.java b/src/main/java/dev/zontreck/libzontreck/vectors/WorldPosition.java index fa69b61..2a2afad 100644 --- a/src/main/java/dev/zontreck/libzontreck/vectors/WorldPosition.java +++ b/src/main/java/dev/zontreck/libzontreck/vectors/WorldPosition.java @@ -35,7 +35,7 @@ public class WorldPosition { } public WorldPosition(ServerPlayer player) { - this(new Vector3(player.position()), player.serverLevel()); + this(new Vector3(player.position()), player.getLevel()); } public WorldPosition(Vector3 pos, ServerLevel lvl) { diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index a1b1cbb..a69184f 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -6,30 +6,32 @@ # 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="${loader_version_range}" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. +loaderVersion="[40,)" #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="${mod_license}" +license="GPLv2" # A URL to refer people to when problems occur with this mod -issueTrackerURL="https://github.com/zontreck/LibZontreckMod/issues" #optional +issueTrackerURL="https://github.com/zontreck/LibZontreckMod/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="${mod_id}" #mandatory -# The version number of the mod -version="${mod_version}" #mandatory +modId="libzontreck" #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 # A display name for the mod -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/ +displayName="LibZontreck" #mandatory +# A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/ #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="examplemod.png" #optional # A text field displayed in the mod UI -#credits="" #optional +credits="Zontreck" #optional # A text field displayed in the mod UI -authors="${mod_authors}" #optional +authors="zontreck" #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. @@ -39,32 +41,26 @@ authors="${mod_authors}" #optional #displayTest="MATCH_VERSION" # MATCH_VERSION is the default if nothing is specified (#optional) # The description text for the mod (multi line!) (#mandatory) -description='''${mod_description}''' +description=''' +This is a library mod for common code for all zontreck's mods. +''' # A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional. -[[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" +[[dependencies.libzontreck]] #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" # Here's another dependency -[[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" - -# 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 +[[dependencies.libzontreck]] +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" \ No newline at end of file diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta index eca79ae..954af3c 100644 --- a/src/main/resources/pack.mcmeta +++ b/src/main/resources/pack.mcmeta @@ -1,8 +1,8 @@ { "pack": { - "description": { - "text": "${mod_id} resources" - }, - "pack_format": 15 + "description": "LibZontreck resources", + "pack_format": 9, + "forge:resource_pack_format": 8, + "forge:data_pack_format": 9 } } \ No newline at end of file