Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.8] My First Modding Experience


statphantom
 Share

Recommended Posts

From within the constructor inside your item class, type "this." And it should give you a list of things that you can mess around with.  I believe stack size is in there.

 

Another thing that you can do, at least if you're in eclipse, is hold control and click on the class you are extending, or any class for that matter, and it will open and you can see many of the methods they use and override them in your own class.

Link to comment
Share on other sites

  • Replies 71
  • Created
  • Last Reply

Top Posters In This Topic

I still can't figure out this item spawning thing. I have added maxStackSize(64). however it still wont stack, maybe it's because I am creating a new ItemStack() and a new Item(). however I can get it to work without recalling the constructors, any help on what I am doing wrong? my code is on my previous post, thanks.

Link to comment
Share on other sites

Never ever ever create new Items outside of preInit! Creating a new Item means you are creating a new type of Item. You must re-use the static Item instance you create in preInit.

 

THANK YOU! Light bulb moment, I am such an idiot I completely forget it is a static variable in the mod class. I knew there was something wrong with my calling my item constructor but had no idea how to get around it, it is working now :D thanks!!!!

Link to comment
Share on other sites

I am trying to register a texture but keep getting a nullpointer exception.

 

Maybe it's because I'm using the forge eclipse environment it is not registering it in the right place? help anyone? :)

 

I am using this....

 

    public static void regTexture(Item item) {
        Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(MODID + ":" + item.getUnlocalizedName().substring(5), "inventory"));
    }

Link to comment
Share on other sites

If you haven't found it yet:

https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample

 

I don't know why I didn't post it earlier...

 

Should resolve all your basic problems.

 

More info:

http://greyminecraftcoder.blogspot.co.at/p/list-of-topics.html

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

If you haven't found it yet:

https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample

 

I don't know why I didn't post it earlier...

 

Should resolve all your basic problems.

 

More info:

http://greyminecraftcoder.blogspot.co.at/p/list-of-topics.html

 

I have checked greyminecraftcoder and been looking at those examples but still cant figure out where to put my textures.

 

I register my item here....

 

    @EventHandler
    public void preInit (FMLPreInitializationEvent event) {
    	
    	System.out.println("Loading " + MODNAME + "!");
    	System.out.println("Version " + VERSION + "!");
    	
    	sharpstick = new SharpStick();
    	
    	MinecraftForge.EVENT_BUS.register(new LevelEventHandler());
    	
    	if (event.getSide() == Side.CLIENT) {
    		regTexture(sharpstick);                                <------ calling here
    	}
    	
    	GameRegistry.addRecipe(new ItemStack(sharpstick),
    	"A ",
    	" A",
    	'A', Items.stick);
    }

 

I have tried various places to put the texture files but I have put it in src/main/resources/assets/ModName/textures/items

and my .json files in src/main/resources/assets/ModName/models/item

Link to comment
Share on other sites

What do I use to get the itemStack of a custom item? Items class only contains vanilla items, do I need to do a search for name?

 

Of you didn't figure it out:

New ItemStack (MainModClass.yourItem)

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.

Link to comment
Share on other sites

 

Main Mod Class

 

package tutorial.generic;

import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;

@Mod(modid = Level.MODID, name = Level.MODNAME, version = Level.VERSION)
public class Level {
    public static final String MODID = "StatsLevelMod";
    public static final String MODNAME = "Level";
    public static final String VERSION = "1.0.1";
}

 

Oooops!  Make your mod ID all lower case.  That's probably part, if not all of your problem with the texture

 

Link to comment
Share on other sites

 

Main Mod Class

 

package tutorial.generic;

import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;

@Mod(modid = Level.MODID, name = Level.MODNAME, version = Level.VERSION)
public class Level {
    public static final String MODID = "StatsLevelMod";
    public static final String MODNAME = "Level";
    public static final String VERSION = "1.0.1";
}

 

Oooops!  Make your mod ID all lower case.  That's probably part, if not all of your problem with the texture

 

thanks, fixed this but still not working, I think it might be a problem with my path but I can't find any forge eclipse environment path example to help iron out the problem

my current path is.

 

src/main/resources/assets/statslevelmod/textures/items/sharpStick.png

NOT eclipse/src but have tried it in their also.

 

PS: I really am grateful of everyone's help and I hope I'm not becoming annoying :P

Link to comment
Share on other sites

Post your json file for the texture.

 

path is:

src/main/resources/assets/statslevelmod/models/item/sharpStrick.json

{
    "parent":"builtin/generated",
    "textures": {
        "layer0":"statslevelmod:items/sharpStick"
    },
    "display": {
        "thirdperson": {
            "rotation": [ -90, 0, 0 ],
            "translation": [ 0, 1, -3 ],
            "scale": [ 0.55, 0.55, 0.55 ]
        },
        "firstperson": {
            "rotation": [ 0, -135, 25 ],
            "translation": [ 0, 4, 2 ],
            "scale": [ 1.7, 1.7, 1.7 ]
        }
    }
}

Link to comment
Share on other sites

I'm unsure if this is it l, because json stuff...  But try renaming the json file from sharpStick to SharpStick.

I haven't messed with textures lately, but I vaguely remember doing something similar to that and it fixed it.

I'm also on my phone, so if that doesn't work, I'll check back in a little bit when I get back home.

Link to comment
Share on other sites

I'm unsure if this is it l, because json stuff...  But try renaming the json file from sharpStick to SharpStick.

I haven't messed with textures lately, but I vaguely remember doing something similar to that and it fixed it.

I'm also on my phone, so if that doesn't work, I'll check back in a little bit when I get back home.

 

Nop :( no change, still getting nullpointer exception

Link to comment
Share on other sites

Fixed my texture problem! it was both a wrong path but the crash was due to me calling it during preInit, not Init.

 

new idea: I want sharp sticks to only be gathered when under leaves, I am thinking of doing a loop check, checking the block two above the block clicked, then +1 Z axis untill either it hits a leaf block then it passes true, up to..... I am tihnking 20 blocks high at which point it will return false. Is this a good way to do this or is there a better way?

Link to comment
Share on other sites

Show your entityItem class.

 

is this what you mean?

package statslevelmod;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class SharpStick extends Item {

private final String name = "sharpStick";

public SharpStick() {
	super();

	GameRegistry.registerItem(this, name);
	setCreativeTab(CreativeTabs.tabMisc);
	setUnlocalizedName(name);
	setMaxStackSize(64);
}
}

Link to comment
Share on other sites

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
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.

 Share




  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • thats exactly what i did, didnt work
    • performance problems?, i saw that the pumpkin overlay's size is 256x256, then how it draws in full screen?
    • ---- Minecraft Crash Report ---- // I bet Cylons wouldn't have this problem. Time: 1/25/22 3:30 PM Description: Rendering overlay net.minecraftforge.fml.config.ConfigFileTypeHandler$ConfigLoadingException: Failed loading config file forge-common.toml of type COMMON for modid forge     at net.minecraftforge.fml.config.ConfigFileTypeHandler.lambda$reader$1(ConfigFileTypeHandler.java:61) ~[?:?] {re:classloading}     at net.minecraftforge.fml.config.ConfigFileTypeHandler$$Lambda$4733/78604773.apply(Unknown Source) ~[?:?] {}     at net.minecraftforge.fml.config.ConfigTracker.openConfig(ConfigTracker.java:104) ~[?:?] {re:classloading}     at net.minecraftforge.fml.config.ConfigTracker.lambda$loadConfigs$1(ConfigTracker.java:83) ~[?:?] {re:classloading}     at net.minecraftforge.fml.config.ConfigTracker$$Lambda$4732/324662817.accept(Unknown Source) ~[?:?] {}     at java.lang.Iterable.forEach(Iterable.java:75) ~[?:1.8.0_51] {}     at java.util.Collections$SynchronizedCollection.forEach(Collections.java:2062) ~[?:1.8.0_51] {}     at net.minecraftforge.fml.config.ConfigTracker.loadConfigs(ConfigTracker.java:83) ~[?:?] {re:classloading}     at net.minecraftforge.fml.ModLoader.loadMods(ModLoader.java:209) ~[?:?] {re:classloading}     at net.minecraftforge.fml.client.ClientModLoader.lambda$startModLoading$7(ClientModLoader.java:132) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}     at net.minecraftforge.fml.client.ClientModLoader$$Lambda$4722/1128558020.run(Unknown Source) ~[?:?] {}     at net.minecraftforge.fml.client.ClientModLoader.lambda$createRunnableWithCatch$4(ClientModLoader.java:123) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}     at net.minecraftforge.fml.client.ClientModLoader$$Lambda$2917/1825071442.run(Unknown Source) ~[?:?] {}     at net.minecraftforge.fml.client.ClientModLoader.startModLoading(ClientModLoader.java:132) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}     at net.minecraftforge.fml.client.ClientModLoader.lambda$onResourceReload$2(ClientModLoader.java:114) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}     at net.minecraftforge.fml.client.ClientModLoader$$Lambda$4719/1991615833.run(Unknown Source) ~[?:?] {}     at net.minecraftforge.fml.client.ClientModLoader.lambda$createRunnableWithCatch$4(ClientModLoader.java:123) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}     at net.minecraftforge.fml.client.ClientModLoader$$Lambda$2917/1825071442.run(Unknown Source) ~[?:?] {}     at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1618) ~[?:1.8.0_51] {}     at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1610) ~[?:1.8.0_51] {}     at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) ~[?:1.8.0_51] {}     at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) ~[?:1.8.0_51] {}     at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1689) ~[?:1.8.0_51] {}     at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) ~[?:1.8.0_51] {} Caused by: com.electronwill.nightconfig.core.io.ParsingException: Not enough data available     at com.electronwill.nightconfig.core.io.ParsingException.notEnoughData(ParsingException.java:22) ~[core-3.6.3.jar:?] {}     at com.electronwill.nightconfig.core.io.ReaderInput.directReadChar(ReaderInput.java:36) ~[core-3.6.3.jar:?] {}     at com.electronwill.nightconfig.core.io.AbstractInput.readChar(AbstractInput.java:49) ~[core-3.6.3.jar:?] {}     at com.electronwill.nightconfig.core.io.AbstractInput.readCharsUntil(AbstractInput.java:123) ~[core-3.6.3.jar:?] {}     at com.electronwill.nightconfig.toml.TableParser.parseKey(TableParser.java:166) ~[toml-3.6.3.jar:?] {}     at com.electronwill.nightconfig.toml.TableParser.parseDottedKey(TableParser.java:145) ~[toml-3.6.3.jar:?] {}     at com.electronwill.nightconfig.toml.TableParser.parseNormal(TableParser.java:55) ~[toml-3.6.3.jar:?] {}     at com.electronwill.nightconfig.toml.TomlParser.parse(TomlParser.java:44) ~[toml-3.6.3.jar:?] {}     at com.electronwill.nightconfig.toml.TomlParser.parse(TomlParser.java:37) ~[toml-3.6.3.jar:?] {}     at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:113) ~[core-3.6.3.jar:?] {}     at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:219) ~[core-3.6.3.jar:?] {}     at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:202) ~[core-3.6.3.jar:?] {}     at com.electronwill.nightconfig.core.file.WriteSyncFileConfig.load(WriteSyncFileConfig.java:73) ~[core-3.6.3.jar:?] {}     at com.electronwill.nightconfig.core.file.AutosaveCommentedFileConfig.load(AutosaveCommentedFileConfig.java:85) ~[core-3.6.3.jar:?] {}     at net.minecraftforge.fml.config.ConfigFileTypeHandler.lambda$reader$1(ConfigFileTypeHandler.java:57) ~[?:?] {re:classloading}     ... 23 more A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Render thread Stacktrace:     at net.minecraftforge.fml.config.ConfigFileTypeHandler.lambda$reader$1(ConfigFileTypeHandler.java:61) ~[?:?] {re:classloading}     at net.minecraftforge.fml.config.ConfigFileTypeHandler$$Lambda$4733/78604773.apply(Unknown Source) ~[?:?] {}     at net.minecraftforge.fml.config.ConfigTracker.openConfig(ConfigTracker.java:104) ~[?:?] {re:classloading}     at net.minecraftforge.fml.config.ConfigTracker.lambda$loadConfigs$1(ConfigTracker.java:83) ~[?:?] {re:classloading}     at net.minecraftforge.fml.config.ConfigTracker$$Lambda$4732/324662817.accept(Unknown Source) ~[?:?] {}     at java.lang.Iterable.forEach(Iterable.java:75) ~[?:1.8.0_51] {}     at java.util.Collections$SynchronizedCollection.forEach(Collections.java:2062) ~[?:1.8.0_51] {}     at net.minecraftforge.fml.config.ConfigTracker.loadConfigs(ConfigTracker.java:83) ~[?:?] {re:classloading}     at net.minecraftforge.fml.ModLoader.loadMods(ModLoader.java:209) ~[?:?] {re:classloading} -- Overlay render details -- Details:     Overlay name: net.minecraft.client.gui.ResourceLoadProgressGui Stacktrace:     at net.minecraft.client.renderer.GameRenderer.func_195458_a(GameRenderer.java:484) ~[?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.func_195542_b(Minecraft.java:977) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:607) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.main.Main.main(Main.java:184) [?:?] {re:classloading,pl:runtimedistcleaner:A}     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51] {}     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_51] {}     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_51] {}     at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_51] {}     at net.minecraftforge.fml.loading.FMLClientLaunchProvider.lambda$launchService$0(FMLClientLaunchProvider.java:51) [forge-1.16.5-36.2.22.jar:36.2] {}     at net.minecraftforge.fml.loading.FMLClientLaunchProvider$$Lambda$459/1573125303.call(Unknown Source) [forge-1.16.5-36.2.22.jar:36.2] {}     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.0.9.jar:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.0.9.jar:?] {}     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.0.9.jar:?] {}     at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.0.9.jar:?] {}     at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.0.9.jar:?] {}  
    • "Required" in the sense that it's the correct way to do things to maintain mod compatibility. But loot tables are still loot tables and can still be overridden with data packs. Forge won't stop you from doing it.
    • Hi all, First post here. I have tried to solve this myself but I can't identify the problem. I used to use version 1.16.3 and in the console I was able to press up and down to access commands in the history and tab for auto completion of the command. Now I upgraded to version 1.17.1 and I these keys don't work anymore. How can I enable auto complete? Thanks. System info: MinecraftForge version 37.1.1 Minecraft 1.17.1 with MCP 20210706. OS: Ubuntu 20.04.3 openjdk 17.0.1 2021-10-19 OpenJDK Runtime Environment (build 17.0.1+12-Ubuntu-120.04)
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.