Jump to content

Missing Texture without error


_Dommi_

Recommended Posts

I have a Problem with my crops, they have the missing-texture texture and i cant find my mistake.

 

Main:

package io.github.dommihd.blazecraft;

import io.github.dommihd.blazecraft.blocks.BlazeBlocks;
import io.github.dommihd.blazecraft.items.BlazeItems;
import io.github.dommihd.blazecraft.proxy.CommonProxy;
import io.github.dommihd.blazecraft.recepies.BlazeCrafting;
import io.github.dommihd.blazecraft.recepies.BlazeSmelting;
import net.minecraft.init.Blocks;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

@Mod(modid = Blazecraft.MODID, version = Blazecraft.VERSION, name = Blazecraft.NAME)
public class Blazecraft
{
    public static final String MODID = "blazecraft";
    public static final String VERSION = "0.1";
    public static final String NAME = "Blazecraft";
  
    @Instance(MODID)
public static Blazecraft instance = new Blazecraft();
    
@SidedProxy(modId = MODID, serverSide = "io.github.dommihd.blazecraft.proxy.CommonProxy", clientSide = "io.github.dommihd.blazecraft.proxy.ClientProxy")
public static CommonProxy proxy = new CommonProxy();

public BlazeItems items;
public BlazeBlocks blocks;
public BlazeTab tab;
public BlazeCrafting craft;
public BlazeSmelting smelt;

@EventHandler
public void preInit(FMLPreInitializationEvent event){
	tab = new BlazeTab();

	items = new BlazeItems();
	items.init();
	items.register();

	blocks = new BlazeBlocks();
	blocks.init();
	blocks.register();
}
@EventHandler
public void load(FMLInitializationEvent event){
	craft = new BlazeCrafting();
	craft.register();

	smelt = new BlazeSmelting();
	smelt.register();
}
@EventHandler
public void postInit(FMLPostInitializationEvent event){
	proxy.registerModels();
}
}

 

Client Proxy:

package io.github.dommihd.blazecraft.proxy;

import io.github.dommihd.blazecraft.Blazecraft;
import io.github.dommihd.blazecraft.blocks.BlazeBlocks;
import io.github.dommihd.blazecraft.items.BlazeItems;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemSeeds;

public class ClientProxy extends CommonProxy {


public void registerModels() {
	//items
	registerModel(BlazeItems.testitem, 0, new ModelResourceLocation(BlazeItems.testitem.getRegistryName(),"inventory"));
	registerModel(BlazeItems.emberorchidSeeds, 0, new ModelResourceLocation(BlazeItems.emberorchidSeeds.getRegistryName(),"inventory"));
	//blocks
	registerModel(BlazeBlocks.testblock, 0, new ModelResourceLocation(BlazeBlocks.testblock.getRegistryName(),"inventory"));
	registerModel(BlazeBlocks.emberorchid, 0, new ModelResourceLocation(BlazeBlocks.emberorchid.getRegistryName(),"inventory"));
}

private void registerModel(Object obj, int meta, ModelResourceLocation loc){
	Item item = null;
	if (obj instanceof Item){
		item = (Item) obj;
	}else if (obj instanceof ItemSeeds){
		item = (ItemSeeds) obj;

	} else if (obj instanceof Block){
		item = Item.getItemFromBlock((Block) obj);

	}else{
		throw new IllegalArgumentException();
	} 
	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, meta, loc);
}

}

Name Utils:

package io.github.dommihd.blazecraft;

import net.minecraft.block.Block;
import net.minecraft.item.Item;

public class NameUtils {

public static void setNames(Object obj,String name){
	if(obj instanceof Item){
		((Item)obj).setRegistryName(name).setUnlocalizedName(name);
	} else if(obj instanceof Block){
		((Block)obj).setRegistryName(name).setUnlocalizedName(name);
	}else{
		throw new IllegalArgumentException();
	}
}

}

Blocks Class:

package io.github.dommihd.blazecraft.blocks;

import io.github.dommihd.blazecraft.Blazecraft;
import io.github.dommihd.blazecraft.NameUtils;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class BlazeBlocks {

public static Block testblock;
public static Block emberorchid;

public void init(){
	testblock = new BlockTest().setCreativeTab(Blazecraft.instance.tab);
	NameUtils.setNames(testblock, "testblock");
	emberorchid = new EmberOrchid();
	NameUtils.setNames(emberorchid, "emberorchid");
}

public void register(){
	registerBlock(testblock);
	registeremberBlock(emberorchid);
}

private void registerBlock(Block block){
	GameRegistry.register(block);
	ItemBlock itemblock = new ItemBlock(block);
	itemblock.setUnlocalizedName(block.getUnlocalizedName()).setRegistryName(block.getRegistryName());
	GameRegistry.register(itemblock);
}
private void registeremberBlock(Block block){
	GameRegistry.register(block);
}
}

Block Crops

package io.github.dommihd.blazecraft.blocks;

import io.github.dommihd.blazecraft.items.BlazeItems;
import net.minecraft.block.BlockCrops;
import net.minecraft.init.Items;
import net.minecraft.item.Item;

public class EmberOrchid extends BlockCrops{

@Override
protected Item getSeed(){

	return BlazeItems.emberorchidSeeds;

}

@Override
protected Item getCrop() {

	return Items.BLAZE_POWDER;
}

}

blockstates:

{
    "variants": {
        "age=0": { "model": "blazecraft:eo_stage0" },
        "age=1": { "model": "blazecraft:eo_stage1" },
        "age=2": { "model": "blazecraft:eo_stage2" },
        "age=3": { "model": "blazecraft:eo_stage3" },
        "age=4": { "model": "blazecraft:eo_stage4" },
        "age=5": { "model": "blazecraft:eo_stage5" },
        "age=6": { "model": "blazecraft:eo_stage6" },
        "age=7": { "model": "blazecraft:eo_stage7" }
    }
}

block models exaple:

{
    "parent": "block/crop",
    "textures": {
        "crop": "blazecraft:blocks/eo_stage0"
    }
}

texture names: eo_stage0.png, eo_stage1.png, ...

Link to comment
Share on other sites

Your blockstate is wrong.  You're telling Minecraft to look for a model that doesn't exist.

You should instead override the texture, like so:

 

https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/resources/assets/harderores/blockstates/hardiron.json

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

I have the same problem : No texture and no error for my item:

 

the main class:

 

@Mod (modid = References.MOD_ID, name = References.NAME, version = References.VERSION,
      acceptedMinecraftVersions = References.ACCEPTED_VERSIONS)

public class Tem {

@SidedProxy(serverSide= References.CLIENT_PROXY_CLASS, clientSide = References.SERVER_PROXY_CLASS)
public static CommonProxy proxy;


@Instance
public static Tem instance;

@EventHandler
public void preInit (FMLPreInitializationEvent event) {

	ModItems.init();
	ModItems.register();


}
@EventHandler
public void init (FMLInitializationEvent event){



}
@EventHandler
public void postInit(FMLPostInitializationEvent event){

	proxy.init();

}

}

 

 

the references class:

 

public class References {
public static final String MOD_ID = "tem";
public static final String NAME = "Tim's Expansion Mod";
public static final String VERSION = "1.0.0";
public static final String ACCEPTED_VERSIONS = "[1.10]";

public static final String CLIENT_PROXY_CLASS = "winnetrie.tem.proxy.ClientProxy";
public static final String SERVER_PROXY_CLASS = "winnetrie.tem.proxy.ServerProxy";

public static enum temItems {
	CHEESE("cheese", "ItemCheese");

	private String unlocalizedName;
	private String registryName;

	temItems(String unlocalizedName, String registryName){
		this.unlocalizedName = unlocalizedName;
		this.registryName = registryName;

	}
	public String getUnlocalizedName(){
		return unlocalizedName;
	}
	public String getRegistryName(){
		return registryName;
	}
}

}

 

 

the ModItems class:

 

 

public class ModItems {

public static Item cheese;

public static void init(){

	cheese = new ItemCheese();

}

public static void register(){
	GameRegistry.register(cheese);

}

public static void registerRenders(){
	registerRender(cheese);

}

private static void registerRender(Item item){
	ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(),"inventory"));

}

}

 

 

the ItemCheese class:

 

public class ItemCheese extends Item {

public ItemCheese(){
	setUnlocalizedName(References.temItems.CHEESE.getUnlocalizedName());
	setRegistryName(References.temItems.CHEESE.getRegistryName());
}

}

 

the item model ItemCheese.json:

 

{
   "parent": "item/generated",
   "textures": {
      "layer0": "tem:items/ItemCheese"
   }
}

 

 

and the texture is called ItemCheese.png

Link to comment
Share on other sites

When dealing with resources do not use capital letters.

 

I watched a video tutorial where the person use capital letters in his resources.

The example worked fine.

But hey i tried it out and changed everything lower case and guess what?

No errors and still no textures.

 

I also saw a little mistake done by me.

I did put proxy.init(); in the postinit instead of the init method.

That didn't fixed it either, so must be something else...

Link to comment
Share on other sites

@_Dommi_

Show your ItemSeed class. If the crop-block is placed just fine, then something is likely wrong with your seed.

I have a working ItemSeed implementation here that you can take a look at.

 

 

@winnetrie

1) Mojang will be enforcing lowercase soon for resources, I've heard. It's good practice to follow what will come, and not having to redo all work when updating etc.

2) (Depending on your OS (Windows falls under here)) The dev-environment will ignore lower/uppercase mismatches, and show you the resource for supermod:SuPeRbLoCk == supermod:superblock. This means that if your resources are typed with different cases, they will still show as expected. However, when compiled into a .jar (really just a .zip file with different name) it cannot do this anymore, leading to SuPeRbLoCk =! superblock. It's a pain in the proverbial behind to find all these issues with the naked eye.

3) I don't see you calling ModItems.registerRenders. This has to be done in preInit, in the clientproxy.

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Link to comment
Share on other sites

i changed it, but still no textures and no error:

@Mod (modid = References.MOD_ID, name = References.NAME, version = References.VERSION,
      acceptedMinecraftVersions = References.ACCEPTED_VERSIONS)

public class Tem {

@SidedProxy(serverSide= References.CLIENT_PROXY_CLASS, clientSide = References.SERVER_PROXY_CLASS)
public static CommonProxy proxy;


@Instance
public static Tem instance;

@EventHandler
public void preInit (FMLPreInitializationEvent event) {
	proxy.init();
	ModItems.init();
	ModItems.register();



}
@EventHandler
public void init (FMLInitializationEvent event){




}
@EventHandler
public void postInit(FMLPostInitializationEvent event){



}

}

 

I also did it exactly as in the tutorial. In the tutorial they do it in the Init and not preInit

Link to comment
Share on other sites

@_Dommi_

You need to override

onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)

in your seed class.

You can see how my itemseeds do so in my previous post.

 

 

@Winnetrie

You... What are.... how...

What?

You are calling your proxy's init, from preInit... That is not what I told you to do.

In your main's preInit, call proxy.preInit().

In your clientProxy's preInit, call ModItems.registerRenders

 

i changed it, but still no textures and no error:

 

I also did it exactly as in the tutorial. In the tutorial they do it in the Init and not preInit

ModelLoader HAS to be registered in preInit. If you use Minecraft::getItemModelMesher, then yes, you register in init, but that is buggy as heck, which is why Forge had to add ModelLoader as a better alternative.

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Link to comment
Share on other sites

What is it with this trend to put everything inside the proxy classes? That defeats their purpose...

 

Not to mention that your client proxy then calls ModItems, which is common code, further defeating the purpose of proxies.

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

now the game crashed ^^ : http://pastebin.com/yE0Nw1jB

 

Seeds:

package io.github.dommihd.blazecraft.items;

import io.github.dommihd.blazecraft.Blazecraft;
import io.github.dommihd.blazecraft.blocks.BlazeBlocks;
import io.github.dommihd.blazecraft.blocks.EmberOrchid;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class EmberOrchidSeeds extends ItemSeeds{

    private static EmberOrchid crops;
    private static Block soilBlockID;

public EmberOrchidSeeds(){
	super(BlazeBlocks.eo, Blocks.DIRT);
	this.setCreativeTab(Blazecraft.instance.tab);
	this.soilBlockID = Blocks.DIRT;
}


@Override
    public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
    {
        net.minecraft.block.state.IBlockState state = worldIn.getBlockState(pos);
        if (facing == EnumFacing.UP && playerIn.canPlayerEdit(pos.offset(facing), facing, stack) && worldIn.isAirBlock(pos.up()) && this.crops.canSustainBush(state))
        {
            worldIn.setBlockState(pos.up(), this.crops.getDefaultState());
            --stack.stackSize;
            return EnumActionResult.SUCCESS;
        }
        else
        {
            return EnumActionResult.FAIL;
        }
}

}

 

package io.github.dommihd.blazecraft.blocks;

import java.util.Random;

import io.github.dommihd.blazecraft.items.BlazeItems;
import net.minecraft.block.BlockCrops;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class EmberOrchid extends BlockCrops{




@Override
protected Item getSeed(){

	return BlazeItems.emberorchidSeeds;

}

@Override
protected Item getCrop() {

	return Items.BLAZE_POWDER;
}	
  @Override
    public boolean canSustainBush(IBlockState state){
    	if(state.getBlock() == Blocks.DIRT ||state.getBlock() == Blocks.GRASS || state.getBlock() == Blocks.SAND)
    		return true;
    	
        return false;
}
}

Link to comment
Share on other sites

@Winnetrie

You... What are.... how...

What?

You are calling your proxy's init, from preInit... That is not what I told you to do.

In your main's preInit, call proxy.preInit().

In your clientProxy's preInit, call ModItems.registerRenders

 

I'm really confused now. I don't understand what you mean!

Maybe take a look at this tutorial:

 

I did exactly like this and it works for him, why not for me?

Link to comment
Share on other sites

net.minecraft.block.state.IBlockState state

?  Really?

Couldn't be arsed to import that?

 

As for the crash...

Caused by: java.lang.NullPointerException
    at io.github.dommihd.blazecraft.items.EmberOrchidSeeds.onItemUse(EmberOrchidSeeds.java:33) ~[EmberOrchidSeeds.class:?]

 

Go to EmberOrchidSeeds line 33.  Find the thing that is null, it is very easy.

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

I checked something and it appears that this is never been called:

 

public class ClientProxy implements CommonProxy{

@Override
public void init() {

	ModItems.registerRenders();
	System.out.println("renders have been registered");

}	

}

I added the System.out.println("renders have been registered"); to check, but i can't see the message.

So i guess it isn't called but why?

 

Also if i name the method init or preInit or whatever name you can imagine, it's just a name. Does it really matter how i name it?

Like i said before i watch the tutorial video (wich is a working example) and checked every step again and again.

Link to comment
Share on other sites

So i guess it isn't called but why?

Because you never call the method...

 

Also if i name the method init or preInit or whatever name you can imagine, it's just a name. Does it really matter how i name it?

Like i said before i watch the tutorial video (wich is a working example) and checked every step again and again.

You can name your methods whatever you want, just be sure to name them something logical.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

@_Dommi_

I didn't mean for you to copy/paste directly from my github.

 

Your crop creates blaze-powder, no? Then I assume you want it to only grow on soulsand. Use that instead of grass|dirt|sand.

 

The nullpointer occurs here:

if (facing == EnumFacing.UP && playerIn.canPlayerEdit(pos.offset(facing), facing, stack) && worldIn.isAirBlock(pos.up()) && this.crops.canSustainBush(state))

Something here, is called, when it does not exist.

You could just simply have if-checks before hand and check if they are null, System.out.print(variable + " is null") and return the method. Then you know what is wrong.

 

net.minecraft.block.state.IBlockState state

?  Really?

Couldn't be arsed to import that?

=_= That's on me, actually. Copied from the github. Lesson learnt: don't code stuff when sick.

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Link to comment
Share on other sites

Because you never call the method...

 

Am i not doing that here?:

 

@Mod (modid = References.MOD_ID, name = References.NAME, version = References.VERSION,
      acceptedMinecraftVersions = References.ACCEPTED_VERSIONS)

public class Tem {

@SidedProxy(serverSide= References.CLIENT_PROXY_CLASS, clientSide = References.SERVER_PROXY_CLASS)
public static CommonProxy proxy;


@Instance
public static Tem instance;

@EventHandler
public void preInit (FMLPreInitializationEvent event) {
	proxy.init();
	ModItems.init();
	ModItems.register();



}
@EventHandler
public void init (FMLInitializationEvent event){




}
@EventHandler
public void postInit(FMLPostInitializationEvent event){



}

}

 

 

the proxy.init() ?

 

Link to comment
Share on other sites

ok private static EmberOrchid crops; was null and i fixed it and the seeds can now only placed on soul sand, but theres no sound and no texture  :-\ :'(

 

package io.github.dommihd.blazecraft.items;

import io.github.dommihd.blazecraft.Blazecraft;
import io.github.dommihd.blazecraft.blocks.BlazeBlocks;
import io.github.dommihd.blazecraft.blocks.EmberOrchid;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class EmberOrchidSeeds extends ItemSeeds{

    private static EmberOrchid crops= new EmberOrchid();
    private static Block soilBlockID;

public EmberOrchidSeeds(){
	super(BlazeBlocks.eo, Blocks.SOUL_SAND);
	this.setCreativeTab(Blazecraft.instance.tab);
	this.soilBlockID = Blocks.SOUL_SAND;
}


@Override
    public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
    {
        net.minecraft.block.state.IBlockState state = worldIn.getBlockState(pos);
        if(state!=null&&facing!=null&&pos!=null&&stack!=null&&worldIn!=null&&playerIn!=null&&crops!=null){
        	System.out.println("hi");
        if (facing == EnumFacing.UP && playerIn.canPlayerEdit(pos.offset(facing), facing, stack) && worldIn.isAirBlock(pos.up())&& this.crops.canSustainBush(state))
        {
        	System.out.println("hi2");
            worldIn.setBlockState(pos.up(),this.crops.getDefaultState());
            --stack.stackSize;
            return EnumActionResult.SUCCESS;
        }
        else
        {
            return EnumActionResult.FAIL;
        }
        }else  return EnumActionResult.FAIL;
}

}

Link to comment
Share on other sites

So i tested something else.

I did call the rendering right in the main class just to test it, i know it should not be done!

That seems to work. So that means everything is good and something is wrong with the proxy.

I really don't know why i do call it but it doesn't fire for some reason

Link to comment
Share on other sites

Itemseeds class:

package io.github.dommihd.blazecraft.items;

import io.github.dommihd.blazecraft.Blazecraft;
import io.github.dommihd.blazecraft.blocks.BlazeBlocks;
import io.github.dommihd.blazecraft.blocks.EmberOrchid;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class EmberOrchidSeeds extends ItemSeeds{

    private static EmberOrchid crops= new EmberOrchid();
    private static Block soilBlockID;

public EmberOrchidSeeds(){
	super(BlazeBlocks.eo, Blocks.SOUL_SAND);
	this.setCreativeTab(Blazecraft.instance.tab);
	this.soilBlockID = Blocks.SOUL_SAND;
}


@Override
    public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
    {
        net.minecraft.block.state.IBlockState state = worldIn.getBlockState(pos);
        if(state!=null&&facing!=null&&pos!=null&&stack!=null&&worldIn!=null&&playerIn!=null&&crops!=null){
        if (facing == EnumFacing.UP && playerIn.canPlayerEdit(pos.offset(facing), facing, stack) && worldIn.isAirBlock(pos.up())&& this.crops.canSustainBush(state))
        {
            worldIn.setBlockState(pos.up(),this.crops.getDefaultState());
            --stack.stackSize;
            return EnumActionResult.SUCCESS;
        }
        else
        {
            return EnumActionResult.FAIL;
        }
        }else  return EnumActionResult.FAIL;
}

}

Block crops:

package io.github.dommihd.blazecraft.blocks;

import java.util.Random;

import io.github.dommihd.blazecraft.items.BlazeItems;
import net.minecraft.block.BlockCrops;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class EmberOrchid extends BlockCrops{




@Override
protected Item getSeed(){

	return BlazeItems.emberorchidSeeds;

}

@Override
protected Item getCrop() {

	return Items.BLAZE_POWDER;
}	
  @Override
    public boolean canSustainBush(IBlockState state){
    	if(state.getBlock() == Blocks.SOUL_SAND){
    		return true;
    	}else{
        return false;
    	}
}
}

 

package io.github.dommihd.blazecraft.items;

import io.github.dommihd.blazecraft.Blazecraft;
import io.github.dommihd.blazecraft.NameUtils;
import io.github.dommihd.blazecraft.blocks.BlazeBlocks;
import io.github.dommihd.blazecraft.blocks.EmberOrchid;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemSeeds;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class BlazeItems {

public static Item testitem;
public static EmberOrchidSeeds emberorchidSeeds =new EmberOrchidSeeds();

public void init(){
	testitem = new ItemTest().setCreativeTab(Blazecraft.instance.tab);
	NameUtils.setNames(testitem, "testitem");
	emberorchidSeeds = new EmberOrchidSeeds();
	NameUtils.setNames(emberorchidSeeds, "emberorchidSeeds");
}

public void register(){
	registerItem(testitem);
	registerItemSeeds(emberorchidSeeds);
}

private void registerItem(Item item){
	GameRegistry.register(item);
}

private void registerItemSeeds(ItemSeeds item){
	GameRegistry.register(item);
}
}

package io.github.dommihd.blazecraft.blocks;

import io.github.dommihd.blazecraft.Blazecraft;
import io.github.dommihd.blazecraft.NameUtils;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class BlazeBlocks {

public static Block testblock;
public static EmberOrchid eo = new EmberOrchid();

public void init(){
	testblock = new BlockTest().setCreativeTab(Blazecraft.instance.tab);
	NameUtils.setNames(testblock, "testblock");
	eo = new EmberOrchid();
	NameUtils.setNames(eo, "eo");
}

public void register(){
	registerBlock(testblock);
	registerBlock(eo);
}

private void registerBlock(Block block){
	GameRegistry.register(block);
	ItemBlock itemblock = new ItemBlock(block);
	itemblock.setUnlocalizedName(block.getUnlocalizedName()).setRegistryName(block.getRegistryName());
	GameRegistry.register(itemblock);
}
private void registeremberBlock(Block block){
	GameRegistry.register(block);
	//Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block),0, new ModelResourceLocation("blazecraft:eo","inventory"));
}
}

Client Proxy:

package io.github.dommihd.blazecraft.proxy;

import io.github.dommihd.blazecraft.Blazecraft;
import io.github.dommihd.blazecraft.blocks.BlazeBlocks;
import io.github.dommihd.blazecraft.items.BlazeItems;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemSeeds;

public class ClientProxy extends CommonProxy {


public void registerModels() {
	//items
	registerModel(BlazeItems.testitem, 0, new ModelResourceLocation(BlazeItems.testitem.getRegistryName(),"inventory"));
	registerModel(BlazeItems.emberorchidSeeds, 0, new ModelResourceLocation(BlazeItems.emberorchidSeeds.getRegistryName(),"inventory"));
	//blocks
	registerModel(BlazeBlocks.testblock, 0, new ModelResourceLocation(BlazeBlocks.testblock.getRegistryName(),"inventory"));
	registerModel(BlazeBlocks.eo, 0, new ModelResourceLocation(BlazeBlocks.eo.getRegistryName(),"inventory"));
}

private void registerModel(Object obj, int meta, ModelResourceLocation loc){
	Item item = null;
	System.out.println(obj);
	if (obj instanceof Item){
		item = (Item) obj;
		System.out.println(item);
	}else if (obj instanceof ItemSeeds){
		item = (ItemSeeds) obj;
		System.out.println(item);
	} else if (obj instanceof Block){
		item = Item.getItemFromBlock((Block) obj);
		System.out.println(item);
	}else{
		throw new IllegalArgumentException();

	} 
	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, meta, loc);
}

}

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



×
×
  • Create New...

Important Information

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