diff --git a/src/generated/resources/assets/justdirethings/models/item/blazegold_pickaxe.json b/src/generated/resources/assets/justdirethings/models/item/blazegold_pickaxe.json index 1ce19e70..fda9f2d4 100644 --- a/src/generated/resources/assets/justdirethings/models/item/blazegold_pickaxe.json +++ b/src/generated/resources/assets/justdirethings/models/item/blazegold_pickaxe.json @@ -1,5 +1,13 @@ { "parent": "minecraft:item/handheld", + "overrides": [ + { + "model": "justdirethings:item/blazegold_pickaxe_active", + "predicate": { + "justdirethings:enabled": 1.0 + } + } + ], "textures": { "layer0": "justdirethings:item/blazegold_pickaxe" } diff --git a/src/generated/resources/assets/justdirethings/models/item/blazegold_pickaxe_active.json b/src/generated/resources/assets/justdirethings/models/item/blazegold_pickaxe_active.json new file mode 100644 index 00000000..2a6c6d96 --- /dev/null +++ b/src/generated/resources/assets/justdirethings/models/item/blazegold_pickaxe_active.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/handheld", + "textures": { + "layer0": "justdirethings:item/blazegold_pickaxe_active" + } +} \ No newline at end of file diff --git a/src/main/java/com/direwolf20/justdirethings/datagen/JustDireItemModels.java b/src/main/java/com/direwolf20/justdirethings/datagen/JustDireItemModels.java index 12b81851..6cc36293 100644 --- a/src/main/java/com/direwolf20/justdirethings/datagen/JustDireItemModels.java +++ b/src/main/java/com/direwolf20/justdirethings/datagen/JustDireItemModels.java @@ -3,6 +3,7 @@ import com.direwolf20.justdirethings.JustDireThings; import com.direwolf20.justdirethings.setup.Registration; import net.minecraft.data.PackOutput; +import net.minecraft.resources.ResourceLocation; import net.neoforged.neoforge.client.model.generators.ItemModelProvider; import net.neoforged.neoforge.common.data.ExistingFileHelper; @@ -38,7 +39,22 @@ protected void registerModels() { public void registerTools() { for (var tool : Registration.TOOLS.getEntries()) { - singleTexture(tool.getId().getPath(), mcLoc("item/handheld"), "layer0", modLoc("item/" + tool.getId().getPath())); + if (!tool.is(Registration.BlazegoldPickaxe.getId())) + singleTexture(tool.getId().getPath(), mcLoc("item/handheld"), "layer0", modLoc("item/" + tool.getId().getPath())); + else { + ResourceLocation enabledModelPath = modLoc("item/" + tool.getId().getPath() + "_active"); // Path to your enabled model + ResourceLocation defaultModelPath = modLoc("item/" + tool.getId().getPath()); // Path to your default model + + // Start building your item model + getBuilder(tool.getId().getPath()) // This should match your item's registry name + .parent(getExistingFile(mcLoc("item/handheld"))) + .texture("layer0", defaultModelPath) + .override() + .predicate(new ResourceLocation("justdirethings", "enabled"), 1.0F) // Using custom property + .model(singleTexture(tool.getId().getPath() + "_active", mcLoc("item/handheld"), "layer0", modLoc("item/" + tool.getId().getPath() + "_active"))) + .end(); + + } } } } diff --git a/src/main/java/com/direwolf20/justdirethings/setup/ClientSetup.java b/src/main/java/com/direwolf20/justdirethings/setup/ClientSetup.java index 2c77aad8..59cb8dee 100644 --- a/src/main/java/com/direwolf20/justdirethings/setup/ClientSetup.java +++ b/src/main/java/com/direwolf20/justdirethings/setup/ClientSetup.java @@ -11,6 +11,9 @@ import com.direwolf20.justdirethings.client.screens.FuelCanisterScreen; import com.direwolf20.justdirethings.client.screens.PocketGeneratorScreen; import com.direwolf20.justdirethings.client.screens.ToolSettingScreen; +import com.direwolf20.justdirethings.common.items.tools.utils.ToggleableTool; +import net.minecraft.client.renderer.item.ItemProperties; +import net.minecraft.resources.ResourceLocation; import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.common.Mod; @@ -29,10 +32,14 @@ public static void init(final FMLClientSetupEvent event) { NeoForge.EVENT_BUS.register(EventKeyInput.class); NeoForge.EVENT_BUS.register(RenderHighlight.class); - //Screens - /*event.enqueueWork(() -> { - MenuScreens.register(Registration.FuelCanister_Container.get(), FuelCanisterScreen::new); // Attach our container to the screen - });*/ + //Item Properties + event.enqueueWork(() -> { + ItemProperties.register(Registration.BlazegoldPickaxe.get(), + new ResourceLocation(JustDireThings.MODID, "enabled"), (stack, level, living, id) -> { + return ToggleableTool.getEnabled(stack) ? 1.0f : 0.0f; + }); + }); + } @SubscribeEvent diff --git a/src/main/resources/assets/justdirethings/textures/item/blazegold_pickaxe_active.png b/src/main/resources/assets/justdirethings/textures/item/blazegold_pickaxe_active.png new file mode 100644 index 00000000..ae978a2e Binary files /dev/null and b/src/main/resources/assets/justdirethings/textures/item/blazegold_pickaxe_active.png differ diff --git a/src/main/resources/assets/justdirethings/textures/item/blazegold_pickaxe_active.png.mcmeta b/src/main/resources/assets/justdirethings/textures/item/blazegold_pickaxe_active.png.mcmeta new file mode 100644 index 00000000..0709ed95 --- /dev/null +++ b/src/main/resources/assets/justdirethings/textures/item/blazegold_pickaxe_active.png.mcmeta @@ -0,0 +1,6 @@ +{ + "animation": { + "frametime": 80, + "interpolate": true + } +}