Jump to content

Recommended Posts

Posted

Hello.

I am still new in putting together a mod for the game and a little bit stuck now, I have been using suppergerrie2's practice mod tutorial as a reference for my own mod.

I have several questions:

1) How do I add my custom item to one of the game's already existing tabs?

2) I fail to realize something, how exactly the model and texture for a custom item are referred to in the code, as in how the code tells the game which .json and texture to load for the item?

3) Is it possible to edit vanilla block properties through Forge? as in defining new values for harvest speeds, harvest output and so on... ,if so, how?

 

Thanks.

Posted
2 hours ago, diesieben07 said:

 Use one of the constants in the CreativeTabs class instead of your own CreativeTabs instance.

 

Thank you very much! That was just too simple that it makes me feel a bit stupid...

 

 

2 hours ago, diesieben07 said:

You call ModelLoader.setCustomModelResourceLocation during ModelRegistryEvent to set this. If the variant of the ModelResourceLocation is inventory, then the game will look in models/items for a model. If the variant is something else, the game will first look in blockstates for a blockstate json (yes, even for items, this is a forge change) and then find the specified variant in that blockstate json. It will then use the model (now from models/blocks) referenced by the blockstate json for that variant.

Thank you once again, went over the code a couple of more times and I think I finally got the hang of it.

However, I am having an issue at the moment - after a lot of troubleshoot attempts I am getting quite helpless...

I simply copied the .json and texture of the Clay Ball(clay_ball) and edited them accordingly to be a Dirt Ball.

I just can't get the item to appear the way I intend to, it shows up as a 2D square with a missing texture...

I hope you could help me out on this one as well:

 

 

@Mod.EventBusSubscriber(modid=Reference.MODID)
public class ModItems {
	
	static Item dirthandfulItem;
	
	public static void init() {
		dirthandfulItem = new ItemDirtHandful("dirt_ball");
	}
	
	@SubscribeEvent
	public static void registerItems(RegistryEvent.Register<Item> event) {
		event.getRegistry().registerAll(dirthandfulItem);
	}
	
	@SubscribeEvent
	public static void registerRenders(ModelRegistryEvent event) {
		registerRender(dirthandfulItem);
	}
	
	private static void registerRender(Item item) {
		ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation( item.getRegistryName(), "inventory"));
	}
	
}

 

MODID is hc , the relevant .json and .png files are labled dirt_ball

Packaging:         assets.hc.models.item

                           assets.hc.textures.item

{
    "parent": "item/generated",
    "textures": {
        "layer0": "hc:items/dirt_ball"
    }
}

 

Posted
8 minutes ago, diesieben07 said:

It is intended to be globally unique. "hc" is not unique.

...and you have 64 characters of length to play with.

  • Like 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
30 minutes ago, diesieben07 said:

Before you do anything else, change your Mod ID. It is intended to be globally unique. "hc" is not unique.

 

Location for item textures must be assets/[domain]/textures/items.

Oopsie, I overlooked the s...

I want to try to make Minecraft a bit more challenging, supposedly more 'Hardcore' hence the abbreviation 'hc'. To be honest, I did not put much thought to this bit and did not know that using hc as my mod's ID could be troublesome.

Thank you very much for your help!

 

I will be using hcmod temporarily as the mod's ID until I come up with a better name for the mod, I have corrected the relevant lines of code but the issues still persists, though in a different manner...

It still appears to have its texture missing but with the inscription hcmod:dirt_ball#inventory fixed to it.

So what am I doing wrong now?

 

Posted
3 hours ago, Armadelix said:

So what am I doing wrong now?

Two things you didnt change assets/modid/models/item to items did you?

And post your log file for this the error will tell us where the problem is.

  • Thanks 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
5 hours ago, Armadelix said:

I will be using hcmod temporarily as the mod's ID until I come up with a better name for the mod

Note that the more items and blocks you create the more model and blockstate JSON files you'll have to update to reflect the change.

  • Thanks 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)
On 9/17/2019 at 3:43 AM, Animefan8888 said:

Two things you didnt change assets/modid/models/item to items did you?

And post your log file for this the error will tell us where the problem is.

I did change item to items in the packages' label so that I have:

Quote

assets.hcmod.textures.items

assets.hcmod.models.items

Also made sure to check that these paths are actually that way, and they are.

Normally, will the game actually log texture issues like this one into somewhere? (When running just fine without crashes)

On 9/17/2019 at 6:08 AM, Draco18s said:

Note that the more items and blocks you create the more model and blockstate JSON files you'll have to update to reflect the change.

I have already acknowledged this, still thanks for the heads up!

Edited by Armadelix
typo fix
Posted
22 hours ago, diesieben07 said:

It should...

Please post a Git repository of your mod.

I am not too familiar with Github, can I just post sections of the code?

 

This is from the debug log:

[20:11:12] [main/ERROR] [FML]: Exception loading model for variant hcmod:dirt_ball#inventory for item "hcmod:dirt_ball", normal location exception: 
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model hcmod:item/dirt_ball with loader VanillaLoader.INSTANCE, skipping
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:161) ~[ModelLoaderRegistry.class:?]
	at net.minecraftforge.client.model.ModelLoader.loadItemModels(ModelLoader.java:302) ~[ModelLoader.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.loadVariantItemModels(ModelBakery.java:175) ~[ModelBakery.class:?]
	at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:151) ~[ModelLoader.class:?]
	at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?]
	at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:121) [SimpleReloadableResourceManager.class:?]
	at net.minecraft.client.Minecraft.init(Minecraft.java:559) [Minecraft.class:?]
	at net.minecraft.client.Minecraft.run(Minecraft.java:421) [Minecraft.class:?]
	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_201]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_201]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_201]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_201]
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_201]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_201]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_201]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_201]
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
	at GradleStart.main(GradleStart.java:25) [start/:?]
Caused by: java.io.FileNotFoundException: hcmod:models/item/dirt_ball.json
	at net.minecraft.client.resources.FallbackResourceManager.getResource(FallbackResourceManager.java:69) ~[FallbackResourceManager.class:?]
	at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:65) ~[SimpleReloadableResourceManager.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.loadModel(ModelBakery.java:334) ~[ModelBakery.class:?]
	at net.minecraftforge.client.model.ModelLoader.access$1400(ModelLoader.java:115) ~[ModelLoader.class:?]
	at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:861) ~[ModelLoader$VanillaLoader.class:?]
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:157) ~[ModelLoaderRegistry.class:?]
	... 20 more
[20:11:12] [main/ERROR] [FML]: Exception loading model for variant hcmod:dirt_ball#inventory for item "hcmod:dirt_ball", blockstate location exception: 
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model hcmod:dirt_ball#inventory with loader VariantLoader.INSTANCE, skipping
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:161) ~[ModelLoaderRegistry.class:?]
	at net.minecraftforge.client.model.ModelLoader.loadItemModels(ModelLoader.java:296) ~[ModelLoader.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.loadVariantItemModels(ModelBakery.java:175) ~[ModelBakery.class:?]
	at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:151) ~[ModelLoader.class:?]
	at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?]
	at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:121) [SimpleReloadableResourceManager.class:?]
	at net.minecraft.client.Minecraft.init(Minecraft.java:559) [Minecraft.class:?]
	at net.minecraft.client.Minecraft.run(Minecraft.java:421) [Minecraft.class:?]
	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_201]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_201]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_201]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_201]
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_201]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_201]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_201]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_201]
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
	at GradleStart.main(GradleStart.java:25) [start/:?]
Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException
	at net.minecraft.client.renderer.block.model.ModelBlockDefinition.getVariant(ModelBlockDefinition.java:83) ~[ModelBlockDefinition.class:?]
	at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1175) ~[ModelLoader$VariantLoader.class:?]
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:157) ~[ModelLoaderRegistry.class:?]

 

Posted
19 minutes ago, Armadelix said:

Caused by: java.io.FileNotFoundException: hcmod:models/item/dirt_ball.json

This here is your problem. 

  • Thanks 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
12 minutes ago, diesieben07 said:

That would not help me test this locally.

However, the log pretty clearly tells you what's wrong.

 

7 minutes ago, Animefan8888 said:

This here is your problem. 

I did go over that log, but I couldn't understand what exactly the culprit is. Tbh, kind of losing my mind as the said .json file exists, the path/packaging is:

src/main/resources/assets/hcmod/models/items/dirt_ball.json

What I find weird is that the log message reads item and not items as part of the file path, I also tried to change items to item and the outcome is the same.

Could it be that the .json file itself is not accessible by the game for some reason? 

Posted
1 minute ago, diesieben07 said:

Emphasis added.

 

15 minutes ago, Armadelix said:

What I find weird is that the log message reads item and not items as part of the file path, I also tried to change items to item and the outcome is the same.

Isn't it also meant to be items?? you have corrected me on that already.

Posted
10 minutes ago, Armadelix said:

 

Isn't it also meant to be items?? you have corrected me on that already.

Mojang changed it after 1.12

  • Thanks 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

I have changed the "models" package from:

assets.hcmod.models.items

to

assets.hcmod.models.item

 

There still is the same type of mode/texture (visual) error of the item, however the log indicates on a different issue:

[21:22:11] [main/ERROR] [FML]: Exception loading model for variant hcmod:dirt_ball#inventory for item "hcmod:dirt_ball", normal location exception: 
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model hcmod:item/dirt_ball with loader VanillaLoader.INSTANCE, skipping
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:161) ~[ModelLoaderRegistry.class:?]
	at net.minecraftforge.client.model.ModelLoader.loadItemModels(ModelLoader.java:302) ~[ModelLoader.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.loadVariantItemModels(ModelBakery.java:175) ~[ModelBakery.class:?]
	at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:151) ~[ModelLoader.class:?]
	at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?]
	at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:121) [SimpleReloadableResourceManager.class:?]
	at net.minecraft.client.Minecraft.init(Minecraft.java:559) [Minecraft.class:?]
	at net.minecraft.client.Minecraft.run(Minecraft.java:421) [Minecraft.class:?]
	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_201]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_201]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_201]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_201]
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_201]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_201]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_201]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_201]
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
	at GradleStart.main(GradleStart.java:25) [start/:?]
Caused by: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated object at line 5 column 10 path $.textures.texture
	at com.google.gson.internal.Streams.parse(Streams.java:60) ~[Streams.class:?]
	at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:65) ~[TreeTypeAdapter.class:?]
	at net.minecraft.util.JsonUtils.gsonDeserialize(JsonUtils.java:435) ~[JsonUtils.class:?]
	at net.minecraft.client.renderer.block.model.ModelBlock.deserialize(ModelBlock.java:51) ~[ModelBlock.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.loadModel(ModelBakery.java:338) ~[ModelBakery.class:?]
	at net.minecraftforge.client.model.ModelLoader.access$1400(ModelLoader.java:115) ~[ModelLoader.class:?]
	at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:861) ~[ModelLoader$VanillaLoader.class:?]
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:157) ~[ModelLoaderRegistry.class:?]
	... 20 more
Caused by: com.google.gson.stream.MalformedJsonException: Unterminated object at line 5 column 10 path $.textures.texture
	at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1559) ~[JsonReader.class:?]
	at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:491) ~[JsonReader.class:?]
	at com.google.gson.stream.JsonReader.hasNext(JsonReader.java:414) ~[JsonReader.class:?]
	at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:738) ~[TypeAdapters$29.class:?]
	at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:739) ~[TypeAdapters$29.class:?]
	at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:714) ~[TypeAdapters$29.class:?]
	at com.google.gson.internal.Streams.parse(Streams.java:48) ~[Streams.class:?]
	at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:65) ~[TreeTypeAdapter.class:?]
	at net.minecraft.util.JsonUtils.gsonDeserialize(JsonUtils.java:435) ~[JsonUtils.class:?]
	at net.minecraft.client.renderer.block.model.ModelBlock.deserialize(ModelBlock.java:51) ~[ModelBlock.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.loadModel(ModelBakery.java:338) ~[ModelBakery.class:?]
	at net.minecraftforge.client.model.ModelLoader.access$1400(ModelLoader.java:115) ~[ModelLoader.class:?]
	at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:861) ~[ModelLoader$VanillaLoader.class:?]
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:157) ~[ModelLoaderRegistry.class:?]
	... 20 more
[21:22:11] [main/ERROR] [FML]: Exception loading model for variant hcmod:dirt_ball#inventory for item "hcmod:dirt_ball", blockstate location exception: 
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model hcmod:dirt_ball#inventory with loader VariantLoader.INSTANCE, skipping
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:161) ~[ModelLoaderRegistry.class:?]
	at net.minecraftforge.client.model.ModelLoader.loadItemModels(ModelLoader.java:296) ~[ModelLoader.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.loadVariantItemModels(ModelBakery.java:175) ~[ModelBakery.class:?]
	at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:151) ~[ModelLoader.class:?]
	at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?]
	at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:121) [SimpleReloadableResourceManager.class:?]
	at net.minecraft.client.Minecraft.init(Minecraft.java:559) [Minecraft.class:?]
	at net.minecraft.client.Minecraft.run(Minecraft.java:421) [Minecraft.class:?]
	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_201]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_201]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_201]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_201]
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_201]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_201]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_201]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_201]
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
	at GradleStart.main(GradleStart.java:25) [start/:?]
Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException
	at net.minecraft.client.renderer.block.model.ModelBlockDefinition.getVariant(ModelBlockDefinition.java:83) ~[ModelBlockDefinition.class:?]
	at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1175) ~[ModelLoader$VariantLoader.class:?]
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:157) ~[ModelLoaderRegistry.class:?]

Aren't variants are supposed to defined? because I did not define for the item to have variants..

Same for the blockstates, this is quite weird...

Posted
4 minutes ago, Armadelix said:

log indicates on a different issue:

Some of your jsons are syntactically wrong. Specifically your dirt_ball model.

  • Thanks 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
4 minutes ago, Animefan8888 said:

Some of your jsons are syntactically wrong. Specifically your dirt_ball model.

As of now, only a single .json is used for this mod. This .json is a direct copy of the 'Clay Ball' item in the game with some editing in its text values via Eclipse.

This is the content of it:

{
    "parent": "item/generated",
    "textures": {
        "texture": "hcmod:items/dirt_ball"
        "layer0": "hcmod:items/dirt_ball"
    }

I saw in several tutorials that only layer0 is used, but today I also added texture as an attempt to troubleshoot this problem.

Any idea what I could be doing wrong?

 

Posted
17 minutes ago, Animefan8888 said:

You're missing a "}"at the end of your file.

Ah *facepalm*, curly brackets and semicolons are the programming beginner's nightmare.

 

13 minutes ago, diesieben07 said:

There is also a comma missing after the "texture" entry. Get an editor that can properly highlight JSON.

 

This is it, this is the final thing that has been missing - the item now appears properly in-game. For some reason while editing the JSON file

 I expected Eclipse to point out my errors just like when working on regular code, I'll keep that in mind now!!

 

Thank you very much for the help!!!

 

Posted
1 minute ago, Armadelix said:

For some reason while editing the JSON file

 I expected Eclipse to point out my errors just like when working on regular code,

It can if you get the JSON Editor plugin for eclipse from the Market Place. Help -> Eclipse Marketplace. Then search Json.

  • Thanks 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
On 9/16/2019 at 7:31 PM, diesieben07 said:

Harvest output: BlockEvent.HarvestDropsEvent.

As I have already said, I am new to all this and not too sure of "what and how".

I would like to make the dirt block yield exclusively dirt ball(s), so I did the following:

package com.hcmod.hardcoremod.init;

import com.hcmod.hardcoremod.Reference;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;

public class HCHarvest {
	
	@SubscribeEvent
    public void onHarvestDirt(HarvestDropsEvent event)
    {
			if (event.getState().getBlock() == Blocks.DIRT) //Note to self - Probably does not apply for all conditions of attaining a dirt block
				
			{
				event.getDrops().clear(); //Note to self - check if its the proper method to clear out default harvest drop
				event.getDrops().add(new ItemStack(ModItems.dirthandfulItem, 1)); //Note to self - check how to make the quantity randomize
			}
    }
}

 

Several questions...

1) How do I get this to initialize? I tried adding to this class file the following:

public static void init()
{
  
}

and to call it under preInit using "HCHarvest.init();" in the main class file but it didn't work.

 

2) Is this the proper way of doing what I want to achieve?

 

3) What are the different types of events in which a block breaks and drops something(excluding HarvestDropsEvent)?

 

Thanks.

Posted
On 9/19/2019 at 1:32 PM, Armadelix said:

com.google.gson.stream.MalformedJsonException

 

You have to register your event handler. Your init method, by the way, does nothing, so I'm not sure why you tried that.

 

https://mcforge.readthedocs.io/en/latest/events/intro/

  • Thanks 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
37 minutes ago, Draco18s said:

 

You have to register your event handler. Your init method, by the way, does nothing, so I'm not sure why you tried that.

 

https://mcforge.readthedocs.io/en/latest/events/intro/

 

Fantastic! I did not understand it that well at first, but after you've referred me there again, I understood how to do that and it now works!

Also added a guaranteed check for harvesting,randomizing amount up to 9 and another instance for the block check, so it covers the grass block as well.

package com.hcmod.hardcoremod.init;

import java.util.Random;
import com.hcmod.hardcoremod.Reference;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;

@Mod.EventBusSubscriber(modid=Reference.MODID)
public class HCHarvest {
	
	@SubscribeEvent
    public void onHarvestDirt(HarvestDropsEvent event)
    {
		Random rnd = new Random();
		int qty = 0;
		if (event.getHarvester() != null) //Checks if the player is performing harvest 
		{
			if (event.getState().getBlock() == Blocks.DIRT || event.getState().getBlock() == Blocks.GRASS) //Note to self - Probably does not apply for all conditions of attaining a dirt block	
			{	
				qty = rnd.nextInt(9);
				event.getDrops().clear(); //Note to self - check if its the proper method to clear out default harvest drop
				event.getDrops().add(new ItemStack(ModItems.dirthandfulItem, qty)); //Note to self - check how to make the quantity randomize
			}
		}
    }
}

To actually register it I have added this line under Init:

MinecraftForge.EVENT_BUS.register(new HCHarvest());

(I am writing my steps/results for those who are also willing to learn, I try to learn more through posts like these but I rarely find what I am looking for)

 

 

I would like to know, is it possible to handle the event which drops the block on explosion?

Posted
6 hours ago, diesieben07 said:

There is no way to detect if the harvest event was fired by an explosion (which happens if Block#canDropFromExplosion is true). 

Can I somehow write into this boolean? make it false somehow?

Posted
24 minutes ago, Armadelix said:

Can I somehow write into this boolean? make it false somehow?

Not with any method that is good practice.

 

There does exist one way that would do that, but if you don't already know what it's called and how to use it without causing problems, you're not going to learn it here.

  • Thanks 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
16 hours ago, Draco18s said:

Not with any method that is good practice.

 

There does exist one way that would do that, but if you don't already know what it's called and how to use it without causing problems, you're not going to learn it here.

 

The only practice I see viable as of now is subscribing to ExplosionEvent.Detonate and using :

List<BlockPos> affectedBlocks = event.getAffectedBlocks();

 

A little struggling to understand how I can use it at the moment, as I am still learning.

Posted
5 hours ago, diesieben07 said:

Or... Update to 1.14.4 where this is handled via data packs and you can just override the loot tables.

Not really a desired option as I want to work with Forge and that's not quite possible at the moment.

 

5 hours ago, diesieben07 said:

You could remove blocks from this list, but that would mean they would just never be exploded.

You could add to this list, but that just means they are exploded using vanilla logic.

 

You need to completely replace the explosion logic if you want custom drops.

 

I thought of a different approach, instead of messing with explosion logic directly.

 

Explosion occurs(to its fullest and a block "pickup" is dropped) -> Get explosion coords -> Perform proximity check on its coords -> Find which block "pickups" are in that proximity -> Clear them out and have desired item(s) "pickup" placed there instead

 

So a couple of questions:

1) Is it possible to get coordinates of an explosion?

2) Is it possible to perform a "proximity check" that gets which block "pickup" entities are in it?

 

Thanks!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.