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

[1.8] Giving Texture


Recommended Posts

When I try to give texture to items, blocks or anything else, minecraft crashes. I don't understand why, and where I did mistake;

 

Pre Init:

@EventHandler
public void preInit(FMLPreInitializationEvent event) {

	configref.Settings(event);
	new blockref();
//	    blockref.registerRenders();
//		new itemref();
//		new armorref();
//		new foodref();
//		new reciperef();
        
        //Generation
        GameRegistry.registerWorldGenerator(new generation(), 1);
}

 

When cancel blockref.registerRenders(); it works without problem, but when I activate it it crashes.

package net.extend.mod;

import net.extend.mod.functions.addblock;
import net.extend.mod.functions.addore;
import net.extend.mod.functions.addramp;
import net.extend.mod.functions.addstair;
import net.minecraft.block.Block;
import net.minecraft.block.BlockStairs;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.extend.mod.itemref;

public class blockref {

//Blocks
public static Block acidBlock;
public static Block acidOre;
public static Block blackDiamondOre;
public static Block blackDiamondBlock;
public static Block nightOre;
public static Block nightBlock;
/*	public static Block owen;
public static Block owenActive; */

//Stairs
public static Block blackDiamondStair;
public static Block nightStair;

//Ramps
public static Block ironRamp;

public blockref() {
	//Add Block
	/*this.acidBlock = new addblock(configref.acidBlockID, "acidblock", Material.rock , Block.soundStoneFootstep, 2.0F);
	MinecraftForge.setBlockHarvestLevel(acidBlock, "pickaxe", 2);
	this.acidOre = new addore(configref.acidOreID, "acidore", Block.soundStoneFootstep, 2.0F);
	MinecraftForge.setBlockHarvestLevel(acidOre, "pickaxe", 3);*/
	this.blackDiamondBlock = new addblock("blackdiamondblock", Material.iron, Block.soundTypeStone, 2.0F, "pickaxe", 2);
//       	this.blackDiamondOre = new addore("blackdiamondore", Block.soundTypeStone, 4.0F, "pickaxe", 2);
//       	this.nightOre = new addore("nightore", Block.soundTypeStone, 4.0F, "pickaxe", 2);
//       	this.nightBlock = new addblock("nightblock", Material.iron, Block.soundTypeStone, 2.0F, "pickaxe", 2);

//		this.tomatoCrop = new tomatoCrop();

//      	this.nightStair = new addstair("nightstair", this.nightBlock);
//      	this.blackDiamondStair = new addstair("blackdiamondstair", this.blackDiamondBlock);

//		this.ironRamp = new addramp("ironramp", blockref.blackDiamondBlock);
}

public static void registerRenders() {
	registerRender(blackDiamondBlock);
}

public static void registerRender(Block block) {
	Item item = Item.getItemFromBlock(block);
	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(ref.uid + ":" + (block.getUnlocalizedName().substring(5)), "inventory"));
}
}

 

	this.blackDiamondBlock = new addblock("blackdiamondblock", Material.iron, Block.soundTypeStone, 2.0F, "pickaxe", 2);

 

this is the only activated line on blockref section.  I cant give any textures to them, how can I fix this?

 

This is addblock, maybe you need it.

package net.extend.mod.functions;

import net.extend.mod.ref;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class addblock extends Block {
public addblock(String name, Material material, SoundType sound, float hardness, String item, int level) {
	super(material);

	this.setHardness(hardness);
	this.setStepSound(sound);
        this.setCreativeTab(CreativeTabs.tabBlock);
        this.setUnlocalizedName(name);
        this.setHarvestLevel(item, level);
        GameRegistry.registerBlock(this, name);
}	

}

 

Link to post
Share on other sites

Might have something to do with calling code on the server, which does not have a Minecraft class.

 

But I don't know.

 

You didn't bother including the crash.

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 post
Share on other sites

There is no another mistake, because as I said before when I cancel blockref.registerRenders(); it works when I try to give texture to blocks it crashes. Crash reports doesn't have anything for help just error at preinit section

 

	at net.extend.mod.blockref.registerRender(blockref.java:62)
at net.extend.mod.blockref.registerRenders(blockref.java:57)
at net.extend.mod.extend.preInit(extend.java:101)

 

This is the error. If you need I can paste all file but you can see same things

 

---- Minecraft Crash Report ----
// This is a token for 1 free hug. Redeem at your nearest Mojangsta: [~~HUG~~]

Time: 07.04.2015 22:16
Description: Initializing game

java.lang.NullPointerException: Initializing game
at net.extend.mod.blockref.registerRender(blockref.java:62)
at net.extend.mod.blockref.registerRenders(blockref.java:57)
at net.extend.mod.extend.preInit(extend.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:518)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:208)
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:187)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118)
at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:514)
at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:243)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:446)
at net.minecraft.client.Minecraft.run(Minecraft.java:356)
at net.minecraft.client.main.Main.main(Main.java:117)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
at GradleStart.main(Unknown Source)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
at net.extend.mod.blockref.registerRender(blockref.java:62)
at net.extend.mod.blockref.registerRenders(blockref.java:57)
at net.extend.mod.extend.preInit(extend.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:518)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:208)
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:187)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118)
at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:514)
at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:243)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:446)

-- Initialization --
Details:
Stacktrace:
at net.minecraft.client.Minecraft.run(Minecraft.java:356)
at net.minecraft.client.main.Main.main(Main.java:117)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
at GradleStart.main(Unknown Source)

-- System Details --
Details:
Minecraft Version: 1.8
Operating System: Windows 7 (amd64) version 6.1
Java Version: 1.8.0_05, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 721074048 bytes (687 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v9.10 FML v8.0.69.1354 Minecraft Forge 11.14.1.1354 5 mods loaded, 5 mods active
mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized
FML{8.0.69.1354} [Forge Mod Loader] (forgeSrc-1.8-11.14.1.1354.jar) Unloaded->Constructed->Pre-initialized
Forge{11.14.1.1354} [Minecraft Forge] (forgeSrc-1.8-11.14.1.1354.jar) Unloaded->Constructed->Pre-initialized
examplemod{1.0} [Example Mod] (bin) Unloaded->Constructed->Pre-initialized
extend{0.0.1} [Extend] (bin) Unloaded->Constructed->Errored
Loaded coremods (and transformers): 
Launched Version: 1.8
LWJGL: 2.9.1
OpenGL: Intel(R) HD Graphics Family GL version 3.1.0 - Build 8.15.10.2476, Intel
GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.

Using VBOs: No
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Packs: []
Current Language: English (US)
Profiler Position: N/A (disabled)

Link to post
Share on other sites

Yeah, I realize it 5 mins before but now, json files isn't working, I am trying to give a texture but it isn't work. I have png file in textures/blocks, I have blackdiamondblock.json in models/block and blockstates folders. :( I have been working on that for 3 days, I am really tired to update from 1.7.10 to 1.8.0! I liked IIcon it was easy :S

Link to post
Share on other sites

The biggest stumbling block in updating to 1.8 for me was ensuring that the model .jsons had the correct name.

 

My advice is to break down your registerRender method and set a breakpoint at the end of it so that you can see exactly what name the mesher is expecting. The method adjusted for debug might look something like this:

 

public static void registerRender(Block block) {
     Item item = Item.getItemFromBlock(block);
     String modelName = ref.uid + ":" +  block.getUnlocalizedName().substring(5);
     ModelResourceLocation resLocation = new ModelResourceLocation(modelName, "inventory")
     Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, resLocation);

     /* Setting your breakpoint at the above line will allow you to easily see all the values of the variables within this method 
when debugging. You may find that the value of modelName differs from the name of your model file. */
}

 

The name registered to the mesher must match the name of the blockstates and model file precisely, including capitalization!

Link to post
Share on other sites

I didn't want to post new topic and up my topic because I have another question.

 

How can I update texture in game? How can I explain, for example diamond meter, when you go nearest, it's texture change, I want to know how can I update my texture in game. I tried this but it didn't work.

 

public void setRender(Item item, int level) {
	if (level < 1) {
		Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(ref.uid + ":" + (item.getUnlocalizedName().substring(5)), "inventory"));
	} else {
		Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(ref.uid + ":" + (item.getUnlocalizedName().substring(5)) + "_" + level, "inventory"));
	}
}

 

in onPlayerTick section;

setTexture(this, level);

Link to post
Share on other sites

You would create a property for the block that contains some info you want to check. Then in your block model you'd map different textures to the different values of that property. This is also how you can make different textures for different sides of an orientable block like a furnace.

 

You might want to check out my tutorial: http://jabelarminecraft.blogspot.com/p/minecraft-forge-18-block-modding.html

 

As well as this one from TheGreyGhost: http://greyminecraftcoder.blogspot.com/2014/12/block-models-18.html

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to post
Share on other sites

I add my favorites that sites but my question isn't this. Before your post I asked new question, maybe you didn't see :)

 

Actually I saw your question -- you want to change textures dynamically. But the answer is the same, you have to change the property so that the block states JSON looks up a different model JSON (which can have different texture).

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to post
Share on other sites

Ah ok, I will read it again, but it is about blocks I want to change texture of item, is it same? because items don't have face.

 

{
    "parent": "builtin/generated",
    "textures": {
        "layer0": "extend:items/block_checker"
    },
    "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 post
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.

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.



×
×
  • Create New...

Important Information

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