Jump to content

[1.9.4]custom logs help


SuperLuke
 Share

Recommended Posts

I can't seem to figure out how to make my log display a texture

here's an error message:

 

Exception loading blockstate for the variant mymod:modlogs#axis=z,variant=corwood:

java.lang.Exception: Could not load model definition for variant mymod:modlogs

 

and here are the classes for my custom log:

 

Logs

package mymod.blocks;

import java.util.List;

import javax.annotation.Nullable;

import net.minecraft.block.BlockLog;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import com.google.common.base.Predicate;

public class ModdedLogs extends BlockLog implements IMetaBlockName
{
    public static final PropertyEnum<ModdedPlanks.EnumType> VARIANT = PropertyEnum.<ModdedPlanks.EnumType>create("variant", ModdedPlanks.EnumType.class, new Predicate<ModdedPlanks.EnumType>()
    {
        public boolean apply(@Nullable ModdedPlanks.EnumType p_apply_1_)
        {
            return p_apply_1_.getMetadata() < 4;
        }
    });

    public ModdedLogs()
    {
        this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, ModdedPlanks.EnumType.Dark).withProperty(LOG_AXIS, BlockLog.EnumAxis.Y));
        
    }

    /**
     * Get the MapColor for this Block and the given BlockState
     */
    public MapColor getMapColor(IBlockState state)
    {
        ModdedPlanks.EnumType blockplanks$enumtype = (ModdedPlanks.EnumType)state.getValue(VARIANT);

        switch ((BlockLog.EnumAxis)state.getValue(LOG_AXIS))
        {
            case X:
            case Z:
            case NONE:
            default:

                switch (blockplanks$enumtype)
                {
                    case Dark:
                    default:
                        return ModdedPlanks.EnumType.Dark.getMapColor();
                    case Corrupted:
                        return ModdedPlanks.EnumType.Corrupted.getMapColor();
                }

            case Y:
                return blockplanks$enumtype.getMapColor();
        }
    }

    /**
     * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
     */
    @SideOnly(Side.CLIENT)
    public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
    {
        list.add(new ItemStack(itemIn, 1, ModdedPlanks.EnumType.Dark.getMetadata()));
        list.add(new ItemStack(itemIn, 1, ModdedPlanks.EnumType.Corrupted.getMetadata()));

    }

    /**
     * Convert the given metadata into a BlockState for this Block
     */
    public IBlockState getStateFromMeta(int meta)
    {
        IBlockState iblockstate = this.getDefaultState().withProperty(VARIANT, ModdedPlanks.EnumType.byMetadata((meta & 3) + 4));

        switch (meta & 12)
        {
            case 0:
                iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y);
                break;
            case 4:
                iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X);
                break;
            case 8:
                iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z);
                break;
            default:
                iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE);
        }

        return iblockstate;
    }

    /**
     * Convert the BlockState into the correct metadata value
     */
    @SuppressWarnings("incomplete-switch")
    public int getMetaFromState(IBlockState state)
    {
        int i = 0;
        i = i | ((ModdedPlanks.EnumType)state.getValue(VARIANT)).getMetadata();

        switch ((BlockLog.EnumAxis)state.getValue(LOG_AXIS))
        {
            case X:
                i |= 4;
                break;
            case Z:
                i |= 8;
                break;
            case NONE:
                i |= 12;
        }

        return i;
    }

    protected BlockStateContainer createBlockState()
    {
        return new BlockStateContainer(this, new IProperty[] {VARIANT, LOG_AXIS});
    }

    protected ItemStack createStackedBlock(IBlockState state)
    {
        return new ItemStack(Item.getItemFromBlock(this), 1, ((ModdedPlanks.EnumType)state.getValue(VARIANT)).getMetadata());
    }

    /**
     * Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
     * returns the metadata of the dropped item based on the old metadata of the block.
     */
    public int damageDropped(IBlockState state)
    {
        return ((ModdedPlanks.EnumType)state.getValue(VARIANT)).getMetadata();
    }

@Override
public String getSpecialName(ItemStack stack) {
	// TODO Auto-generated method stub
	return stack.getItemDamage() == 0 ? "white" : "black";
}
}

 

Planks

package mymod.blocks;

import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IStringSerializable;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class ModdedPlanks extends Block implements IMetaBlockName
{
    public static final PropertyEnum<ModdedPlanks.EnumType> VARIANT = PropertyEnum.<ModdedPlanks.EnumType>create("variant", ModdedPlanks.EnumType.class);

    public ModdedPlanks()
    {
        super(Material.WOOD);
        this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, ModdedPlanks.EnumType.Dark));
        this.setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
    }

    /**
     * Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
     * returns the metadata of the dropped item based on the old metadata of the block.
     */
    public int damageDropped(IBlockState state)
    {
        return ((ModdedPlanks.EnumType)state.getValue(VARIANT)).getMetadata();
    }

    /**
     * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
     */
    @SideOnly(Side.CLIENT)
    public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
    {
        for (ModdedPlanks.EnumType blockplanks$enumtype : ModdedPlanks.EnumType.values())
        {
            list.add(new ItemStack(itemIn, 1, blockplanks$enumtype.getMetadata()));
        }
    }

    /**
     * Convert the given metadata into a BlockState for this Block
     */
    @Override
    public IBlockState getStateFromMeta(int meta)
    {
        return this.getDefaultState().withProperty(VARIANT, ModdedPlanks.EnumType.byMetadata(meta));
    }

    /**
     * Get the MapColor for this Block and the given BlockState
     */
    public MapColor getMapColor(IBlockState state)
    {
        return ((ModdedPlanks.EnumType)state.getValue(VARIANT)).getMapColor();
    }

    /**
     * Convert the BlockState into the correct metadata value
     */
    @Override
    public int getMetaFromState(IBlockState state)
    {
        return ((ModdedPlanks.EnumType)state.getValue(VARIANT)).getMetadata();
    }

    protected BlockStateContainer createBlockState()
    {
        return new BlockStateContainer(this, new IProperty[] {VARIANT});
    }

    public static enum EnumType implements IStringSerializable
    {
        Dark(0, "darkwood", MapColor.WOOD),
        Corrupted(1, "corwood", MapColor.OBSIDIAN);
        

        private static final ModdedPlanks.EnumType[] META_LOOKUP = new ModdedPlanks.EnumType[values().length];
        private final int meta;
        private final String name;
        private final String unlocalizedName;
        /** The color that represents this entry on a map. */
        private final MapColor mapColor;

        private EnumType(int metaIn, String nameIn, MapColor mapColorIn)
        {
            this(metaIn, nameIn, nameIn, mapColorIn);
        }

        private EnumType(int metaIn, String nameIn, String unlocalizedNameIn, MapColor mapColorIn)
        {
            this.meta = metaIn;
            this.name = nameIn;
            this.unlocalizedName = unlocalizedNameIn;
            this.mapColor = mapColorIn;
            System.out.println(nameIn);
        }
        
        public int getMetadata()
        {
            return this.meta;
        }

        /**
         * The color which represents this entry on a map.
         */
        public MapColor getMapColor()
        {
            return this.mapColor;
        }

        public String toString()
        {
            return this.name;
        }

        public static ModdedPlanks.EnumType byMetadata(int meta)
        {
            if (meta < 0 || meta >= META_LOOKUP.length)
            {
                meta = 0;
            }

            return META_LOOKUP[meta];
        }
        
        @Override
        public String getName()
        {
            return this.name;
        }

        public String getUnlocalizedName()
        {
            return this.unlocalizedName;
        }

        static
        {
            for (ModdedPlanks.EnumType blockplanks$enumtype : values())
            {
                META_LOOKUP[blockplanks$enumtype.getMetadata()] = blockplanks$enumtype;
            }
        }
    }

    @Override
    public String getSpecialName(ItemStack stack) {
    	
        return stack.getItemDamage() == 0 ? "white" : "black";
    }
}

 

it's most likely i have something named wrong, but i can't find what that would be.

 

 

Link to comment
Share on other sites

Where do you register the render for these? (main or proxies?)

When do you register them? (preInit, init, postInit)

How do you render them? Minecraft::getItemModelMesher() (think that's the method name) or with ModelLoader?

Post your classes that deals with these.

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

Do you have a json blockstate file?

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've been doing a lot of testing and i actually have multiple blockstate files i don't know which one is being called

 

so here they are

 

darkwood.json

{
    "variants": {
        "normal": { "model": "mymod:DarkStone" }
    }
}

 

darkwood_modlogs.json

{
    "variants": {
        "axis=y":  { "model": "acacia_log" },
        "axis=z":   { "model": "acacia_log", "x": 90 },
        "axis=x":   { "model": "acacia_log", "x": 90, "y": 90 },
        "axis=none": { "model": "acacia_bark" }
        
    }
}

 

modlogs.json

{
    "variants": {
       "variant=darkwood": {
        "axis=y":  { "model": "acacia_log" },
        "axis=z":   { "model": "acacia_log", "x": 90 },
        "axis=x":   { "model": "acacia_log", "x": 90, "y": 90 },
        "axis=none": { "model": "acacia_bark" }
        }
    }
}

Link to comment
Share on other sites

this is in my main file in preinit

 

ModBlocks.inti();
    	ModBlocks.register();

 

modblocks file info

 

public static void register()
  {
GameRegistry.registerBlock(l = new ModdedLogs(), ItemBlockMeta.class,"modlogs").setUnlocalizedName("modlogs");
}

reg(ModBlocks.l, 0, "darkwood");
    reg(ModBlocks.l, 1, "corwood");



public static void reg(Block block, int meta, String file) {
    Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
    .register(Item.getItemFromBlock(block), meta, new ModelResourceLocation("mymod:" + file, "inventory"));
}

 

 

proxy

public class ClientProxy extends CommonProxy
{
   @Override
public  void preInit( FMLPreInitializationEvent event ) 
{
  super.preInit(event);
  ModEntities.RegisterEntity();
}

   @Override
public  void init( FMLInitializationEvent event ) 
{


	ModBlocks.registerRenders();



}
   @Override
public  void postInit( FMLPostInitializationEvent event ) 
{
	super.postInit(event);
}
   
   
}

Link to comment
Share on other sites

You can't use client side code in common code.  You must move that stuff to your client proxy.

 

Also, you must use ModelLoader.setCustomModelResourceLocation

https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/java/com/draco18s/ores/client/ClientProxy.java

 

Also don't use GameRegistry.registerBlock, it's deprecated for a reason.

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

Just use

GameRegistry#register(Object)

to register your blocks and items.

 

ModelLoader also has to be called in preInit, after your registration of the blocks.

 

Also, for the

ModelResourceLocation

, do not manually prefix the name. Simply call

block.getRegistryName

, and it will prefix it for you.

If I have a block that I call "superblock", in a mod called "supermod",

getRegistryName

will return "supermod:superblock" for me.

This also means that the files for which the blockstate & models will try to look for, have to have the same name as what was used for the

setRegistryName

, which here would be "superblock".

 

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 have other blocks that work just fine l have multiple versions of sand and planks it's just the logs that don't work.

 

It's deprecated because it's slated for removal. Not deprecated because it doesn't function.

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

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

    • I'm researching the how to create biomes in json. There is a great tool for creating the jsons online. Using the vanilla `river` biome, I want to essentially create a custom disk feature that mixes 3 blocks instead of a single-block provider. Any ideas on where to start with that?
    • I figured out what was wrong ... you can spot it pretty quick most likely: { "type": "minecraft:smelting", "ingredient": { "item": "minecraft:gold_nugget_ore" }, "result": "minecraft:gold_nugget", "experience": 0.25, "cookingtime": 150 }   ... so, after changing `minecraft` to `foundations` for all the custom items and all the recipes work. Well that's what copy/paste will get you. One last question about recipes, though. What does the following json key/value do in the game? "group": "copper_ingot"  
    • # Copyright (c) 1993-2009 Microsoft Corp. # # This is a sample HOSTS file used by Microsoft TCP/IP for Windows. # # This file contains the mappings of IP addresses to host names. Each # entry should be kept on an individual line. The IP address should # be placed in the first column followed by the corresponding host name. # The IP address and the host name should be separated by at least one # space. # # Additionally, comments (such as these) may be inserted on individual # lines or following the machine name denoted by a '#' symbol. # # For example: # #      102.54.94.97     rhino.acme.com          # source server #       38.25.63.10     x.acme.com              # x client host # localhost name resolution is handled within DNS itself. #    127.0.0.1       localhost #    ::1             localhost ###0.0.0.0 apps.corel.com ###0.0.0.0 mc.corel.com 0.0.0.0 origin-mc.corel.com ###0.0.0.0 iws.corel.com
    • Is there a way to create a custom map marker for a custom structure/biome (same as a vanilla mansion)?
    • I’ve scrounged the Internet for solutions and found absolutely nothing that has worked for me I have posted my code in a GitHub Repository. I bet the culprit is somewhere in the Container or TileEntity classes (Furnace packages are in blocks/coke_furnace or blocks/foundry) PS I know I’m on 1.12.2 and that it’s not supported I don’t want to update my game or my code. Lol It’s my favorite version and the most widely modded. I don’t plan to release the mod, I’m just customizing my game to my will. I’ll send it to friends but that’s it.
  • Topics

×
×
  • Create New...

Important Information

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