From 63f491cea764084ff2e4cd49f2e2b95b6bf06fd8 Mon Sep 17 00:00:00 2001 From: MisterJulsen Date: Wed, 18 Oct 2023 11:58:42 +0200 Subject: [PATCH] Updated to 1.19.3 --- build.gradle | 6 ++-- .../de/mrjulsen/mineify/blocks/ModBlocks.java | 8 +++-- .../client/screen/ErrorMessageScreen.java | 7 ++-- .../client/screen/FFMPEGMissingScreen.java | 30 ++++++++-------- .../screen/PlaybackAreaConfigScreen.java | 8 ++--- .../mineify/client/screen/PlaylistScreen.java | 18 +++++----- .../client/screen/SoundBoardScreen.java | 18 +++++----- .../client/screen/SoundConfigScreen.java | 8 ++--- .../SoundPlayerConfigurationScreen.java | 20 +++++------ .../client/screen/UploadSoundScreen.java | 10 +++--- .../mineify/commands/ModCommandArguments.java | 4 +-- .../mineify/events/ModCreativeTabs.java | 34 +++++++++++++++++++ .../mineify/items/SoundBoardItem.java | 6 ++-- src/main/resources/META-INF/mods.toml | 8 ++--- src/main/resources/pack.mcmeta | 4 +-- update.json | 4 +-- 16 files changed, 114 insertions(+), 79 deletions(-) create mode 100644 src/main/java/de/mrjulsen/mineify/events/ModCreativeTabs.java diff --git a/build.gradle b/build.gradle index bf1c0b7..8dba8bd 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.parchmentmc.librarian.forgegradle' -version = '1.0.0-1.19.2' +version = '1.0.0-1.19.3' group = 'de.mrjulsen.mineify' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'mineify' @@ -47,7 +47,7 @@ minecraft { // // Use non-default mappings at your own risk. They may not always work. // Simply re-run your setup task after changing the mappings to update your workspace. - mappings channel: 'parchment', version: '1.19.2-2022.11.27-1.19.2' + mappings channel: 'parchment', version: '1.19.3-2023.06.25-1.19.3' // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default. @@ -158,7 +158,7 @@ dependencies { // Specify the version of Minecraft to use. If this is any group other than 'net.minecraft', it is assumed // that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied. // The userdev artifact is a special name and will get all sorts of transformations applied to it. - minecraft 'net.minecraftforge:forge:1.19.2-43.3.0' + minecraft 'net.minecraftforge:forge:1.19.3-44.1.0' // https://mavenlibs.com/maven/dependency/org.jcraft/jorbis // minecraftLibrary ("org.jcraft:jorbis:0.0.17") diff --git a/src/main/java/de/mrjulsen/mineify/blocks/ModBlocks.java b/src/main/java/de/mrjulsen/mineify/blocks/ModBlocks.java index 8a568c7..a3829b0 100644 --- a/src/main/java/de/mrjulsen/mineify/blocks/ModBlocks.java +++ b/src/main/java/de/mrjulsen/mineify/blocks/ModBlocks.java @@ -3,9 +3,11 @@ import java.util.function.Supplier; import de.mrjulsen.mineify.ModMain; +import de.mrjulsen.mineify.events.ModCreativeTabs; import de.mrjulsen.mineify.items.ModItems; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraftforge.eventbus.api.IEventBus; @@ -17,7 +19,7 @@ public class ModBlocks { public static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, ModMain.MOD_ID); - public static final RegistryObject SOUND_PLAYER = registerBlock("sound_player", () -> new SoundPlayer(), CreativeModeTab.TAB_REDSTONE); + public static final RegistryObject SOUND_PLAYER = registerBlock("sound_player", () -> new SoundPlayer(), CreativeModeTabs.REDSTONE_BLOCKS); private static RegistryObject registerBlock(String name, Supplier block, CreativeModeTab tab) { @@ -28,7 +30,9 @@ private static RegistryObject registerBlock(String name, Sup private static RegistryObject registerBlockItem(String name, RegistryObject block, CreativeModeTab tab) { return ModItems.ITEMS.register(name, () -> { - return new BlockItem(block.get(), new Item.Properties().tab(tab)); + BlockItem item = new BlockItem(block.get(), new Item.Properties()); + ModCreativeTabs.setCreativeTab(item, tab); + return item; }); } diff --git a/src/main/java/de/mrjulsen/mineify/client/screen/ErrorMessageScreen.java b/src/main/java/de/mrjulsen/mineify/client/screen/ErrorMessageScreen.java index d97b167..0732853 100644 --- a/src/main/java/de/mrjulsen/mineify/client/screen/ErrorMessageScreen.java +++ b/src/main/java/de/mrjulsen/mineify/client/screen/ErrorMessageScreen.java @@ -25,11 +25,10 @@ public ErrorMessageScreen(Screen last, Component title, Component message) { protected void init() { super.init(); - this.addRenderableWidget( - new Button(this.width / 2 - 50, height - 40, 100, 20, CommonComponents.GUI_BACK, (p_96057_) -> { + this.addRenderableWidget(Button.builder(CommonComponents.GUI_BACK, (p_96057_) -> { this.minecraft.setScreen(lastScreen); - })); - + }).pos(this.width / 2 - 50, height - 40).size(100, 20).build()); + this.messageLabel = MultiLineLabel.create(this.font, message, 256, 20); } diff --git a/src/main/java/de/mrjulsen/mineify/client/screen/FFMPEGMissingScreen.java b/src/main/java/de/mrjulsen/mineify/client/screen/FFMPEGMissingScreen.java index 29bbc47..eaa7c4f 100644 --- a/src/main/java/de/mrjulsen/mineify/client/screen/FFMPEGMissingScreen.java +++ b/src/main/java/de/mrjulsen/mineify/client/screen/FFMPEGMissingScreen.java @@ -9,6 +9,7 @@ import net.minecraft.Util; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.MultiLineLabel; +import net.minecraft.client.gui.components.Tooltip; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.CommonComponents; import net.minecraft.network.chat.Component; @@ -29,26 +30,20 @@ public FFMPEGMissingScreen(Screen last) { @Override protected void init() { super.init(); - this.addRenderableWidget( - new Button(this.width / 2 - 100, 150, 200, 20, Component.translatable("gui.mineify.soundselection.upload.ffmpeg_missing.ffmpeg_web"), (p_96057_) -> { + + this.addRenderableWidget(Button.builder(Component.translatable("gui.mineify.soundselection.upload.ffmpeg_missing.ffmpeg_web"), (p_96057_) -> { Util.getPlatform().openUri(Constants.FFMPEG_WEB); - }, new Button.OnTooltip() { - @Override - public void onTooltip(Button pButton, PoseStack pPoseStack, int pMouseX, int pMouseY) { - FFMPEGMissingScreen.this.renderTooltip(pPoseStack, Component.literal(Constants.FFMPEG_WEB), pMouseX, pMouseY); - } - })); + }).pos(this.width / 2 - 100, 150).size(200, 20).tooltip(Tooltip.create(Component.literal(Constants.FFMPEG_WEB))).build()); - this.addRenderableWidget( - new Button(this.width / 2 - 100, 175, 200, 20, Component.translatable("gui.mineify.soundselection.upload.ffmpeg_missing.show_folder"), (p_96057_) -> { + this.addRenderableWidget(Button.builder(Component.translatable("gui.mineify.soundselection.upload.ffmpeg_missing.show_folder"), (p_96057_) -> { IOUtils.createDirectory(Constants.FFMPEG_HOME); Util.getPlatform().openFile(new File(Constants.FFMPEG_HOME)); - })); + }).pos(this.width / 2 - 100, 175).size(200, 20).build()); - this.addRenderableWidget( - new Button(this.width / 2 - 50, 210, 100, 20, CommonComponents.GUI_BACK, (p_96057_) -> { - this.minecraft.setScreen(lastScreen); - })); + this.addRenderableWidget(Button.builder(CommonComponents.GUI_BACK, (p_96057_) -> { + IOUtils.createDirectory(Constants.FFMPEG_HOME); + Util.getPlatform().openFile(new File(Constants.FFMPEG_HOME)); + }).pos(this.width / 2 - 50, 21).size(100, 20).build()); this.messageLabel = MultiLineLabel.create(this.font, message, 256, 10); } @@ -65,4 +60,9 @@ public void render(PoseStack pPoseStack, int pMouseX, int pMouseY, float pPartia public boolean shouldCloseOnEsc() { return true; } + + @Override + public void onClose() { + this.minecraft.setScreen(lastScreen); + } } diff --git a/src/main/java/de/mrjulsen/mineify/client/screen/PlaybackAreaConfigScreen.java b/src/main/java/de/mrjulsen/mineify/client/screen/PlaybackAreaConfigScreen.java index bf7bbc8..850d322 100644 --- a/src/main/java/de/mrjulsen/mineify/client/screen/PlaybackAreaConfigScreen.java +++ b/src/main/java/de/mrjulsen/mineify/client/screen/PlaybackAreaConfigScreen.java @@ -93,13 +93,13 @@ public void init() { guiTop = this.height / 2 - HEIGHT / 2; - this.addRenderableWidget(new Button(this.width / 2 - 100, guiTop + 210, 97, 20, btnDoneTxt, (p) -> { + this.addRenderableWidget(Button.builder(btnDoneTxt, (p) -> { this.onDone(); - })); + }).pos(this.width / 2 - 100, guiTop + 210).size(97, 20).build()); - this.addRenderableWidget(new Button(this.width / 2 + 4, guiTop + 210, 97, 20, btnCancelTxt, (p) -> { + this.addRenderableWidget(Button.builder(btnCancelTxt, (p) -> { this.onCancel(); - })); + }).pos(this.width / 2 + 4, guiTop + 210).size(97, 20).build()); /* Controls */ diff --git a/src/main/java/de/mrjulsen/mineify/client/screen/PlaylistScreen.java b/src/main/java/de/mrjulsen/mineify/client/screen/PlaylistScreen.java index 430bf9a..5cacd98 100644 --- a/src/main/java/de/mrjulsen/mineify/client/screen/PlaylistScreen.java +++ b/src/main/java/de/mrjulsen/mineify/client/screen/PlaylistScreen.java @@ -86,30 +86,28 @@ protected void init() { this.defaultControls.components.clear(); this.loadingScreenControls.components.clear(); - cancelButton = this.loadingScreenControls.add(new Button(this.width / 2 - 50, this.height - 50, 100, 20, - CommonComponents.GUI_CANCEL, (p_100004_) -> { + cancelButton = this.loadingScreenControls.add(Button.builder(CommonComponents.GUI_CANCEL, (p_100004_) -> { this.onClose(); - })); + }).pos(this.width / 2 - 50, this.height - 50).size(100, 20).build()); - this.defaultControls.add(new Button(this.width / 2 + 4 + (b ? 50 : 0), this.height - 30, 100 + (b ? 0 : 50), 20, CommonComponents.GUI_DONE, (p_100036_) -> { + this.defaultControls.add(Button.builder(CommonComponents.GUI_DONE, (p_100036_) -> { this.onDone(); - })); + }).pos(this.width / 2 + 4 + (b ? 50 : 0), this.height - 30).size(100 + (b ? 0 : 50), 20).build()); if (b) { - this.defaultControls.add(new Button(this.width / 2 - 50, this.height - 30, 100, 20, - textOpenFolder, (p_100004_) -> { + this.defaultControls.add(Button.builder(textOpenFolder, (p_100004_) -> { Util.getPlatform().openFile(this.soundsDir); - })); + }).pos(this.width / 2 - 50, this.height - 30).size(100, 20).build()); } - this.defaultControls.add(new Button(this.width / 2 - 154, this.height - 30, 100 + (b ? 0 : 50), 20, textUpload, (p_100036_) -> { + this.defaultControls.add(Button.builder(textUpload, (p_100036_) -> { ClientApi.showUploadDialog((path) -> { if (path == null) return; onFilesDrop(new ArrayList(List.of(path))); }); - })); + }).pos(this.width / 2 - 154, this.height - 30).size(100 + (b ? 0 : 50), 20).build()); this.defaultControls.add(CycleButton.onOffBuilder(this.loop) .withInitialValue(this.loop) diff --git a/src/main/java/de/mrjulsen/mineify/client/screen/SoundBoardScreen.java b/src/main/java/de/mrjulsen/mineify/client/screen/SoundBoardScreen.java index bb62070..de13ca3 100644 --- a/src/main/java/de/mrjulsen/mineify/client/screen/SoundBoardScreen.java +++ b/src/main/java/de/mrjulsen/mineify/client/screen/SoundBoardScreen.java @@ -92,30 +92,28 @@ protected void init() { this.defaultControls.components.clear(); this.loadingScreenControls.components.clear(); - cancelButton = this.loadingScreenControls.add(new Button(this.width / 2 - 50, this.height - 50, 100, 20, - CommonComponents.GUI_CANCEL, (p_100004_) -> { + cancelButton = this.loadingScreenControls.add(Button.builder(CommonComponents.GUI_CANCEL, (p_100004_) -> { this.onClose(); - })); + }).pos(this.width / 2 - 50, this.height - 50).size(100, 20).build()); - this.defaultControls.add(new Button(this.width / 2 + 4 + (b ? 50 : 0), this.height - 30, 100 + (b ? 0 : 50), 20, textClose, (p_100036_) -> { + this.defaultControls.add(Button.builder(textClose, (p_100036_) -> { this.onClose(); - })); + }).pos(this.width / 2 + 4 + (b ? 50 : 0), this.height - 30).size(100 + (b ? 0 : 50), 20).build()); if (b) { - this.defaultControls.add(new Button(this.width / 2 - 50, this.height - 30, 100, 20, - textOpenFolder, (p_100004_) -> { + this.defaultControls.add(Button.builder(textOpenFolder, (p_100004_) -> { Util.getPlatform().openFile(this.soundsDir); - })); + }).pos(this.width / 2 - 50, this.height - 30).size(100, 20).build()); } - this.defaultControls.add(new Button(this.width / 2 - 154, this.height - 30, 100 + (b ? 0 : 50), 20, textUpload, (p_100036_) -> { + this.defaultControls.add(Button.builder(textUpload, (p_100036_) -> { ClientApi.showUploadDialog((path) -> { if (path == null) return; onFilesDrop(new ArrayList(List.of(path))); }); - })); + }).pos(this.width / 2 - 154, this.height - 30).size(100 + (b ? 0 : 50), 20).build()); this.distanceSlider = this.addRenderableWidget(new ForgeSlider(this.width / 2 - 154, this.height - 55, 150, 20, textDistance, Component.literal(""), 1, ModCommonConfig.SOUND_BOARD_MAX_DISTANCE.get(), this.distance, 1, 1, true)); this.pitchSlider = this.addRenderableWidget(new ForgeSlider(this.width / 2 + 4, this.height - 55, 150, 20, textPitch, Component.literal(""), Constants.PITCH_MIN, Constants.PITCH_MAX, this.pitch, 0.01D, 4, true)); diff --git a/src/main/java/de/mrjulsen/mineify/client/screen/SoundConfigScreen.java b/src/main/java/de/mrjulsen/mineify/client/screen/SoundConfigScreen.java index 5a527e8..a1ba4a0 100644 --- a/src/main/java/de/mrjulsen/mineify/client/screen/SoundConfigScreen.java +++ b/src/main/java/de/mrjulsen/mineify/client/screen/SoundConfigScreen.java @@ -56,13 +56,13 @@ public void init() { guiTop = this.height / 2 - HEIGHT / 2; - this.addRenderableWidget(new Button(this.width / 2 - 100, guiTop + 100, 97, 20, CommonComponents.GUI_DONE, (p) -> { + this.addRenderableWidget(Button.builder(CommonComponents.GUI_DONE, (p) -> { this.onDone(); - })); + }).pos(this.width / 2 - 100, guiTop + 100).size(97, 20).build()); - this.addRenderableWidget(new Button(this.width / 2 + 4, guiTop + 100, 97, 20, CommonComponents.GUI_CANCEL, (p) -> { + this.addRenderableWidget(Button.builder(CommonComponents.GUI_CANCEL, (p) -> { this.onCancel(); - })); + }).pos(this.width / 2 + 4, guiTop + 100).size(97, 20).build()); this.volumeSlider = this.addRenderableWidget(new CustomMessageSlider(this.width / 2 - 100, guiTop + 25, 200, 20, Component.literal(""), Component.literal(""), Constants.VOLUME_MIN, Constants.VOLUME_MAX, this.volume, 0.01D, 1, true, (slider) -> { slider.setMessage(Component.literal(Component.translatable("gui.mineify.sound_config.volume").getString() + ": " + (int)(slider.getValue() * 100.0D) + "%")); diff --git a/src/main/java/de/mrjulsen/mineify/client/screen/SoundPlayerConfigurationScreen.java b/src/main/java/de/mrjulsen/mineify/client/screen/SoundPlayerConfigurationScreen.java index 93e868b..3b789d8 100644 --- a/src/main/java/de/mrjulsen/mineify/client/screen/SoundPlayerConfigurationScreen.java +++ b/src/main/java/de/mrjulsen/mineify/client/screen/SoundPlayerConfigurationScreen.java @@ -80,21 +80,21 @@ public void init() { guiTop = this.height / 2 - HEIGHT / 2; - this.addRenderableWidget(new Button(this.width / 2 - 100, guiTop + 160, 97, 20, btnDoneTxt, (p) -> { + this.addRenderableWidget(Button.builder(btnDoneTxt, (p) -> { this.onDone(); - })); + }).pos(this.width / 2 - 100, guiTop + 160).size(97, 20).build()); - this.addRenderableWidget(new Button(this.width / 2 + 4, guiTop + 160, 97, 20, btnCancelTxt, (p) -> { + this.addRenderableWidget(Button.builder(btnCancelTxt, (p) -> { this.onCancel(); - })); + }).pos(this.width / 2 + 4, guiTop + 160).size(97, 20).build()); /* Controls */ - this.addRenderableWidget(new Button(this.width / 2 - 100, guiTop + 25, 200, 20, textPlaylist, (p) -> { + this.addRenderableWidget(Button.builder(textPlaylist, (p) -> { Minecraft.getInstance().setScreen(new PlaylistScreen(this, this.playlist, (data) -> { this.playlist = data; })); - })); + }).pos(this.width / 2 - 100, guiTop + 25).size(200, 20).build()); lockButton = new LockIconButton(this.width / 2 + 104, guiTop + 25, (button) -> { this.locked = !locked; @@ -107,21 +107,21 @@ public void init() { //60, 85, 110 - this.addRenderableWidget(new Button(this.width / 2 - 100, guiTop + 50, 200, 20, textZone, (p) -> { + this.addRenderableWidget(Button.builder(textZone, (p) -> { Minecraft.getInstance().setScreen(new PlaybackAreaConfigScreen(this, new PlaybackArea(this.playbackArea), (success, data) -> { if (success) { this.playbackArea = data; } })); - })); + }).pos(this.width / 2 - 100, guiTop + 50).size(200, 20).build()); - this.addRenderableWidget(new Button(this.width / 2 - 100, guiTop + 75, 200, 20, textSoundConfig, (p) -> { + this.addRenderableWidget(Button.builder(textSoundConfig, (p) -> { Minecraft.getInstance().setScreen(new SoundConfigScreen(this, volume, pitch, (value) -> { this.volume = value; }, (value) -> { this.pitch = value; })); - })); + }).pos(this.width / 2 - 100, guiTop + 75).size(200, 20).build()); this.triggerButton = this.addRenderableWidget(CycleButton.builder((p) -> { return Component.translatable(p.getTranslationKey()); diff --git a/src/main/java/de/mrjulsen/mineify/client/screen/UploadSoundScreen.java b/src/main/java/de/mrjulsen/mineify/client/screen/UploadSoundScreen.java index 4fe657e..e4af7f3 100644 --- a/src/main/java/de/mrjulsen/mineify/client/screen/UploadSoundScreen.java +++ b/src/main/java/de/mrjulsen/mineify/client/screen/UploadSoundScreen.java @@ -97,13 +97,13 @@ public void init() { guiTop = this.height / 2 - HEIGHT / 2; - this.doneButton = this.addRenderableWidget(new Button(this.width / 2 - 100, guiTop + 160, 97, 20, btnDoneTxt, (p) -> { + this.doneButton = this.addRenderableWidget(Button.builder(btnDoneTxt, (p) -> { this.onDone(); - })); + }).pos(this.width / 2 - 100, guiTop + 160).size(97, 20).build()); - this.addRenderableWidget(new Button(this.width / 2 + 4, guiTop + 160, 97, 20, btnCancelTxt, (p) -> { + this.addRenderableWidget(Button.builder(btnCancelTxt, (p) -> { this.onCancel(); - })); + }).pos(this.width / 2 + 4, guiTop + 160).size(97, 20).build()); this.filenameBox = new EditBox(this.font, this.width / 2 - 100, guiTop + 40, 200, 20, Component.translatable("gui.mineify.upload.filename")); this.filenameBox.setMaxLength(ModCommonConfig.MAX_FILENAME_LENGTH.get()); @@ -193,7 +193,7 @@ public void render(PoseStack stack, int mouseX, int mouseY, float partialTicks) Utils.renderTooltip(this, this.channelsButton, () -> { return Utils.getEnumTooltipData(this, ESoundChannels.class, width / 3); }, stack, mouseX, mouseY); Utils.renderTooltip(this, this.qualitySlider, () -> { return Utils.getTooltipData(this, Component.translatable("gui.mineify.quality.description"), width / 3); }, stack, mouseX, mouseY); - if (!this.doneButton.active && mouseX >= this.doneButton.x && mouseX <= this.doneButton.x + this.doneButton.getWidth() && mouseY >= this.doneButton.y && mouseY <= this.doneButton.y + this.doneButton.getHeight()) { + if (!this.doneButton.active && mouseX >= this.doneButton.getX() && mouseX <= this.doneButton.getX() + this.doneButton.getWidth() && mouseY >= this.doneButton.getY() && mouseY <= this.doneButton.getY() + this.doneButton.getHeight()) { this.renderTooltip(stack, Utils.getTooltipData(this, Component.translatable("gui.mineify.upload.file_duplicate"), width / 3), mouseX, mouseY, this.getMinecraft().font); } } diff --git a/src/main/java/de/mrjulsen/mineify/commands/ModCommandArguments.java b/src/main/java/de/mrjulsen/mineify/commands/ModCommandArguments.java index 38ba40f..f58a951 100644 --- a/src/main/java/de/mrjulsen/mineify/commands/ModCommandArguments.java +++ b/src/main/java/de/mrjulsen/mineify/commands/ModCommandArguments.java @@ -4,14 +4,14 @@ import net.minecraft.commands.synchronization.ArgumentTypeInfo; import net.minecraft.commands.synchronization.ArgumentTypeInfos; import net.minecraft.commands.synchronization.SingletonArgumentInfo; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.RegistryObject; public class ModCommandArguments { - public static final DeferredRegister> COMMAND_ARGUMENTS = DeferredRegister.create(Registry.COMMAND_ARGUMENT_TYPE_REGISTRY, ModMain.MOD_ID); + public static final DeferredRegister> COMMAND_ARGUMENTS = DeferredRegister.create(Registries.COMMAND_ARGUMENT_TYPE, ModMain.MOD_ID); public static final RegistryObject> SOUNDS = COMMAND_ARGUMENTS.register("sounds", () -> ArgumentTypeInfos.registerByClass(SoundsArgument.class, new SoundArgumentInfo())); diff --git a/src/main/java/de/mrjulsen/mineify/events/ModCreativeTabs.java b/src/main/java/de/mrjulsen/mineify/events/ModCreativeTabs.java new file mode 100644 index 0000000..fc45227 --- /dev/null +++ b/src/main/java/de/mrjulsen/mineify/events/ModCreativeTabs.java @@ -0,0 +1,34 @@ +package de.mrjulsen.mineify.events; + +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; + +import de.mrjulsen.mineify.ModMain; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.ItemLike; +import net.minecraftforge.event.CreativeModeTabEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.Mod.EventBusSubscriber; + +@EventBusSubscriber(modid = ModMain.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) +public class ModCreativeTabs { + + protected static Multimap itemsPerCreativeTab = HashMultimap.create(); + + @SubscribeEvent + public static void buildContents(CreativeModeTabEvent.BuildContents event) { + CreativeModeTab tab = event.getTab(); + if (itemsPerCreativeTab.containsKey(tab)) + for (ItemLike il : itemsPerCreativeTab.get(tab)) { + Item item = il.asItem(); + event.accept(item); + } + } + + public static void setCreativeTab(ItemLike itemlike, CreativeModeTab group) { + ModCreativeTabs.itemsPerCreativeTab.put(group, itemlike); + } + +} diff --git a/src/main/java/de/mrjulsen/mineify/items/SoundBoardItem.java b/src/main/java/de/mrjulsen/mineify/items/SoundBoardItem.java index 209d007..c9f35cc 100644 --- a/src/main/java/de/mrjulsen/mineify/items/SoundBoardItem.java +++ b/src/main/java/de/mrjulsen/mineify/items/SoundBoardItem.java @@ -1,10 +1,11 @@ package de.mrjulsen.mineify.items; import de.mrjulsen.mineify.client.ClientWrapper; +import de.mrjulsen.mineify.events.ModCreativeTabs; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; @@ -12,7 +13,8 @@ public class SoundBoardItem extends Item { public SoundBoardItem() { - super(new Properties().tab(CreativeModeTab.TAB_MISC).stacksTo(1)); + super(new Properties().stacksTo(1)); + ModCreativeTabs.setCreativeTab(this, CreativeModeTabs.TOOLS_AND_UTILITIES); } @Override diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 31df4e2..50d9ada 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -6,7 +6,7 @@ # 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="[44,)" #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="All rights reserved" @@ -23,7 +23,7 @@ version="${file.jarVersion}" #mandatory # A display name for the mod displayName="Mineify" #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://raw.githubusercontent.com/MisterJulsen/Mineify/1.19.2/update.json" #optional +updateJSONURL="https://raw.githubusercontent.com/MisterJulsen/Mineify/1.19.3/update.json" #optional # A URL for the "homepage" for this mod, displayed in the mod UI displayURL="https://www.curseforge.com/minecraft/mc-mods/mineify" #optional # A file name (in the root of the mod JAR) containing a logo for display @@ -43,7 +43,7 @@ With Mineify, each player can upload their own sounds or music to the server and # Does this dependency have to exist - if not, ordering below must be specified mandatory=true #mandatory # The version range of the dependency - versionRange="[43,)" #mandatory + versionRange="[44,)" #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 @@ -53,6 +53,6 @@ With Mineify, each player can upload their own sounds or music to the server and 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.19.2,1.20)" + versionRange="[1.19.3,1.20)" ordering="NONE" side="BOTH" diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta index a9ccb4b..7d491f0 100644 --- a/src/main/resources/pack.mcmeta +++ b/src/main/resources/pack.mcmeta @@ -1,8 +1,8 @@ { "pack": { "description": "mineify resources", - "pack_format": 9, - "forge:resource_pack_format": 9, + "pack_format": 12, + "forge:resource_pack_format": 12, "forge:data_pack_format": 10 } } diff --git a/update.json b/update.json index eb317db..c0caf11 100644 --- a/update.json +++ b/update.json @@ -1,7 +1,7 @@ { "promos": { - "1.19.2-latest": "1.0.0-1.19.2", - "1.19.2-recommended": "1.0.0-1.19.2" + "1.19.3-latest": "1.0.0-1.19.3", + "1.19.3-recommended": "1.0.0-1.19.3" }, "homepage": "https://www.curseforge.com/minecraft/mc-mods/mineify" } \ No newline at end of file