Jump to content

[1.8] Custom Stair Error (FIXED)


KansasToYou

Recommended Posts

EDIT: I fixed this by moving everything having to do with rendering the stair block in BlockStonebrickLightStairs to RandomBlocks.

 

I made a custom stair and I don't know why it's not working properly. I can see the block in game, fully rendered and textured, it's just in the inventory slot it's a no textured block. It also is a full-sized block in my hand while looking in third-person.

 

RandomBlocks:

package com.kansastoyou.mod.init;

import com.kansastoyou.mod.RandomMod;
import com.kansastoyou.mod.Reference;
import com.kansastoyou.mod.blocks.BlockCheese;
import com.kansastoyou.mod.blocks.BlockStonebrickLight;
import com.kansastoyou.mod.blocks.BlockStonebrickLightStairs;
import com.kansastoyou.mod.blocks.BlockStonebrickDark;

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.item.Item;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class RandomBlocks {

//Cheese Block
public static Block cheese_block;

//Light Stonebrick
public static Block stonebrick_light;

//Dark Stonebrick
public static Block stonebrick_dark;

//Light Stonebrick Stairs

public static BlockStairs stonebrick_light_stairs;


public static void init()
{
	cheese_block = new BlockCheese(Material.sponge).setUnlocalizedName("cheese_block").setCreativeTab(RandomMod.tabRandom);
	stonebrick_light = new BlockStonebrickLight(Material.rock).setUnlocalizedName("stonebrick_light").setCreativeTab(RandomMod.tabRandom);;
	stonebrick_dark = new BlockStonebrickDark(Material.rock).setUnlocalizedName("stonebrick_dark").setCreativeTab(RandomMod.tabRandom);;	
	stonebrick_light_stairs = new BlockStonebrickLightStairs(Material.rock, "stonebrick_light_stairs", 3.0F, 5.0F, RandomMod.tabRandom, BlockStonebrickLightStairs.HarvestToolEnum.PICKAXE, BlockStonebrickLightStairs.HarvestLevelEnum.STONE);

}

public static void register()
{
	GameRegistry.registerBlock(cheese_block, cheese_block.getUnlocalizedName().substring(5));
	GameRegistry.registerBlock(stonebrick_light, stonebrick_light.getUnlocalizedName().substring(5));
	GameRegistry.registerBlock(stonebrick_dark, stonebrick_dark.getUnlocalizedName().substring(5));		

}	

public static void registerRenders()
{
	registerRender(cheese_block);
	registerRender(stonebrick_light);
	registerRender(stonebrick_dark);

}

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

 

BlockStonebrickLightStairs

package com.kansastoyou.mod.blocks;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.BlockStairs;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry;

import com.kansastoyou.mod.RandomMod;
import com.kansastoyou.mod.Reference;

public class BlockStonebrickLightStairs extends BlockStairs {

        
      private Item dropsOnHarvest;
      private int dropamountmax = 1;
      private int maxharvestEXP = 0;

       
      
       public BlockStonebrickLightStairs(Material material, String name, float hardness, float resistance, CreativeTabs creativetab, HarvestToolEnum harvesttool, HarvestLevelEnum harvestlevel)
       {
           super(Blocks.stone_brick_stairs.getStateFromMeta(0));
                        
            this.setUnlocalizedName(name);
            this.setHardness(hardness);
            this.setResistance(resistance);
            this.setStepSound(soundTypePiston);
            this.setCreativeTab(RandomMod.tabRandom);      
            this.setHarvestLevel(harvesttool, harvestlevel);
            this.useNeighborBrightness = true;
            
            GameRegistry.registerBlock(this, name);
            
            this.dropsOnHarvest = Item.getItemFromBlock(this);
           }
       public void RegisterRenderer(String modelName)
      {         
         Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(this), 0, new ModelResourceLocation(Reference.MOD_ID +":"+modelName, "inventory"));
      }      
       private void setHarvestLevel(HarvestToolEnum harvesttool,
            HarvestLevelEnum harvestlevel) {
          int level;
         String tool;
         
         switch(harvesttool)
         {
            case PICKAXE:
               tool = "pickaxe";
               break;
            case SHOVEL:
               tool = "shovel";
               break;
            case AXE:
               tool = "axe";
               break;
            default:
               tool = "pickaxe";
         }
         switch(harvestlevel)
         {
            case WOOD:
               level = 0;
               break;
            case STONE:
               level = 1;
               break;
            case IRON:
               level = 2;
               break;
            case DIAMOND:
               level = 3;
               break;
            case GOLD:
               level = 0;
               break;
            default:
               level = 0;
         }
         super.setHarvestLevel(tool, level);
       }   
      
      public static enum HarvestToolEnum
      {
         PICKAXE,
         SHOVEL,
         AXE;      
      }   
      public static enum HarvestLevelEnum
      {
         WOOD,
         STONE,
         IRON,
         DIAMOND,
         GOLD;
      }
      
      
      public void setMaxHarvestEXP(int expAmount)
      {
         maxharvestEXP = expAmount;
      }
      
      public void setDrops(Item drops)
      {
         this.dropsOnHarvest = drops;
      }
      public void setDrops(Block drops)
      {
         this.dropsOnHarvest = Item.getItemFromBlock(drops);
      }
      
      public void setDropMaxAmount(int dropamount)
      {
         this.dropamountmax = dropamount;
      }
      
      public Item getItemDropped(IBlockState state, Random rand, int fortune)
       {
          return this.dropsOnHarvest;
       }
      
      public int quantityDropped(Random random)
       {      
         int amount = random.nextInt(this.dropamountmax)+1;
           return amount;
       }
      
      public int getExpDrop(IBlockAccess world, BlockPos pos, int fortune)
       {
           IBlockState state = world.getBlockState(pos);
           Random rand = world instanceof World ? ((World)world).rand : new Random();
           if (this.getItemDropped(state, rand, fortune) != Item.getItemFromBlock(this))
           {
              return MathHelper.getRandomIntegerInRange(rand, 0, maxharvestEXP);
           }
           return 0;
       }
   }

 

I'm not sure if these classes have anything to do with the problem, but here they are anyway.

 

ClientProxy

package com.kansastoyou.mod.proxy;

import com.kansastoyou.mod.init.RandomBlocks;
import com.kansastoyou.mod.init.RandomItems;

public class ClientProxy extends CommonProxy{
@Override
public void registerRenders() {
	RandomBlocks.registerRenders();
	RandomItems.registerRenders();
}
}

 

CommonProxy

package com.kansastoyou.mod.proxy;

public class CommonProxy {
public void registerRenders() {

}
}

 

Screenshots of Problem:

 

w08TRGR.png

 

s3LObcH.png

 

I'm not that experienced in Forge modding, or modding in general, but any help is appreciated.

Link to comment
Share on other sites

RandomMod

package com.kansastoyou.mod;

import com.kansastoyou.mod.init.RandomBlocks;
import com.kansastoyou.mod.init.RandomItems;
import com.kansastoyou.mod.proxy.CommonProxy;

import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
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;
import net.minecraftforge.fml.common.registry.GameRegistry;

@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION)
public class RandomMod {

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

public static final RandomTab tabRandom = new RandomTab("tabRandom");

@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
	RandomBlocks.init();
	RandomBlocks.register();
	RandomItems.init();
	RandomItems.register();
}

@EventHandler
public void init(FMLInitializationEvent event)
{
	proxy.registerRenders();

	//Cheese Item Crafting/Smelting Recipe
	GameRegistry.addShapelessRecipe(new ItemStack(RandomItems.cheese_item, 9), new Object[]{RandomBlocks.cheese_block});
	GameRegistry.addSmelting(new ItemStack(Items.milk_bucket), new ItemStack(RandomItems.cheese_item, 9), 0.5F);

	//Cheese Block Crafting Recipe
	GameRegistry.addRecipe(new ItemStack(RandomBlocks.cheese_block), new Object[]{"XXX", "XXX", "XXX", 'X', RandomItems.cheese_item});

	//Light Stone Bricks Crafting Recipe
	GameRegistry.addShapelessRecipe(new ItemStack(RandomBlocks.stonebrick_light, 1), new Object[]{new ItemStack(Items.dye, 1, 15), Blocks.stonebrick});

	//Dark Stone Bricks Crafting Recipe
	GameRegistry.addShapelessRecipe(new ItemStack(RandomBlocks.stonebrick_dark, 1), new Object[]{new ItemStack(Items.coal, 1, 1), Blocks.stonebrick});
	GameRegistry.addShapelessRecipe(new ItemStack(RandomBlocks.stonebrick_dark, 1), new Object[]{new ItemStack(Items.coal), Blocks.stonebrick});

	//Light Stone Brick Stairs Crafting Recipe
	GameRegistry.addRecipe(new ItemStack(RandomBlocks.stonebrick_light_stairs), new Object[]{"X  ", "XX ", "XXX", 'X', RandomBlocks.stonebrick_light});
	GameRegistry.addRecipe(new ItemStack(RandomBlocks.stonebrick_light_stairs), new Object[]{"XXX", " XX", "  X", 'X', RandomBlocks.stonebrick_light});

}

@EventHandler
public void postInit(FMLPostInitializationEvent event)
{

}
}

Link to comment
Share on other sites

stonebrick_light_stairs.json

{
    "parent": "rm:block/stonebrick_light_stairs",
    "display": {
        "thirdperson": {
            "rotation": [ 10, -45, 170 ],
            "translation": [ 0, 1.5, -2.75 ],
            "scale": [ 0.375, 0.375, 0.375 ]
        },
        "gui": {
            "rotation": [ 0, 180, 0 ]
        }
    }
}

Link to comment
Share on other sites

I think the problem is that in

 

RandomBlocks

package com.kansastoyou.mod.init;

import com.kansastoyou.mod.RandomMod;
import com.kansastoyou.mod.Reference;
import com.kansastoyou.mod.blocks.BlockCheese;
import com.kansastoyou.mod.blocks.BlockStonebrickLight;
import com.kansastoyou.mod.blocks.BlockStonebrickLightStairs;
import com.kansastoyou.mod.blocks.BlockStonebrickDark;

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.item.Item;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class RandomBlocks {

//Cheese Block
public static Block cheese_block;

//Light Stonebrick
public static Block stonebrick_light;

//Dark Stonebrick
public static Block stonebrick_dark;

//Light Stonebrick Stairs

public static BlockStairs stonebrick_light_stairs;


public static void init()
{
	cheese_block = new BlockCheese(Material.sponge).setUnlocalizedName("cheese_block").setCreativeTab(RandomMod.tabRandom);
	stonebrick_light = new BlockStonebrickLight(Material.rock).setUnlocalizedName("stonebrick_light").setCreativeTab(RandomMod.tabRandom);;
	stonebrick_dark = new BlockStonebrickDark(Material.rock).setUnlocalizedName("stonebrick_dark").setCreativeTab(RandomMod.tabRandom);;	
	stonebrick_light_stairs = new BlockStonebrickLightStairs(Material.rock, "stonebrick_light_stairs", 3.0F, 5.0F, RandomMod.tabRandom, BlockStonebrickLightStairs.HarvestToolEnum.PICKAXE, BlockStonebrickLightStairs.HarvestLevelEnum.STONE);

}

public static void register()
{
	GameRegistry.registerBlock(cheese_block, cheese_block.getUnlocalizedName().substring(5));
	GameRegistry.registerBlock(stonebrick_light, stonebrick_light.getUnlocalizedName().substring(5));
	GameRegistry.registerBlock(stonebrick_dark, stonebrick_dark.getUnlocalizedName().substring(5));		

}	

public static void registerRenders()
{
	registerRender(cheese_block);
	registerRender(stonebrick_light);
	registerRender(stonebrick_dark);

}

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

 

I didn't register the stairs in public static void register() or public static void registerRenders(), but every time I try to, my game crashes.

Here's what It looks like when I add it to those two locations.

 

package com.kansastoyou.mod.init;

import com.kansastoyou.mod.RandomMod;
import com.kansastoyou.mod.Reference;
import com.kansastoyou.mod.blocks.BlockCheese;
import com.kansastoyou.mod.blocks.BlockStonebrickLight;
import com.kansastoyou.mod.blocks.BlockStonebrickLightStairs;
import com.kansastoyou.mod.blocks.BlockStonebrickDark;

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.item.Item;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class RandomBlocks {

//Cheese Block
public static Block cheese_block;

//Light Stonebrick
public static Block stonebrick_light;

//Dark Stonebrick
public static Block stonebrick_dark;

//Light Stonebrick Stairs

public static BlockStairs stonebrick_light_stairs;


public static void init()
{
	cheese_block = new BlockCheese(Material.sponge).setUnlocalizedName("cheese_block").setCreativeTab(RandomMod.tabRandom);
	stonebrick_light = new BlockStonebrickLight(Material.rock).setUnlocalizedName("stonebrick_light").setCreativeTab(RandomMod.tabRandom);;
	stonebrick_dark = new BlockStonebrickDark(Material.rock).setUnlocalizedName("stonebrick_dark").setCreativeTab(RandomMod.tabRandom);;	
	stonebrick_light_stairs = new BlockStonebrickLightStairs(Material.rock, "stonebrick_light_stairs", 3.0F, 5.0F, RandomMod.tabRandom, BlockStonebrickLightStairs.HarvestToolEnum.PICKAXE, BlockStonebrickLightStairs.HarvestLevelEnum.STONE);

}

public static void register()
{
	GameRegistry.registerBlock(cheese_block, cheese_block.getUnlocalizedName().substring(5));
	GameRegistry.registerBlock(stonebrick_light, stonebrick_light.getUnlocalizedName().substring(5));
	GameRegistry.registerBlock(stonebrick_dark, stonebrick_dark.getUnlocalizedName().substring(5));	
                GameRegistry.registerBlock(stonebrick_light_stairs, stonebrick_light_stairs.getUnlocalizedName().substring(5));	

}	

public static void registerRenders()
{
	registerRender(cheese_block);
	registerRender(stonebrick_light);
	registerRender(stonebrick_dark);
                registerRender(stonebrick_light_stairs);

}

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

 

And here's the crash report:

 

---- Minecraft Crash Report ----
// I'm sorry, Dave.

Time: 7/13/15 9:03 PM
Description: There was a severe problem during mod loading that has caused the game to fail

net.minecraftforge.fml.common.LoaderException: java.lang.IllegalStateException: Can't free registry slot 198 occupied by net.minecraft.item.ItemBlock@43945480
at net.minecraftforge.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:231)
at net.minecraftforge.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:188)
at net.minecraftforge.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:177)
at com.kansastoyou.mod.init.RandomBlocks.register(RandomBlocks.java:48)
at com.kansastoyou.mod.RandomMod.preInit(RandomMod.java:30)
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:537)
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:212)
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190)
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:119)
at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:550)
at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:249)
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)
Caused by: java.lang.IllegalStateException: Can't free registry slot 198 occupied by net.minecraft.item.ItemBlock@43945480
at net.minecraftforge.fml.common.registry.GameData.freeSlot(GameData.java:876)
at net.minecraftforge.fml.common.registry.GameData.registerItem(GameData.java:776)
at net.minecraftforge.fml.common.registry.GameData.registerItem(GameData.java:745)
at net.minecraftforge.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:223)
... 43 more


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

-- System Details --
Details:
Minecraft Version: 1.8
Operating System: Windows 8.1 (amd64) version 6.3
Java Version: 1.8.0_05, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 877193408 bytes (836 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.99.99 Minecraft Forge 11.14.3.1487 4 mods loaded, 4 mods active
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
UCH	mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) 
UCH	FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8-11.14.3.1487.jar) 
UCH	Forge{11.14.3.1487} [Minecraft Forge] (forgeSrc-1.8-11.14.3.1487.jar) 
UCE	rm{1.0} [Random Mod] (bin) 
Loaded coremods (and transformers): 
GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.3.12618 Compatibility Profile Context 13.251.9001.1001' Renderer: 'AMD Radeon HD 7400M Series'

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.

Announcements



×
×
  • Create New...

Important Information

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