Jump to content

[SOLVED][1.10.2] EntityItem for custom item seems large and goes into floor


jabelar

Recommended Posts

I have multiple items in my mod, and only one of them seems to behave oddly when dropped (i.e. when it is an EntityItem). The item is a "golden egg" and the texture is exactly the same as vanilla egg except colored a golden yellow-orange. However, compared to the vanilla egg it is rendered much larger and this furthermore cause it to go into the floor when hovering.

 

Here is a picture of what is happening (my egg on left, vanilla in middle):

 

Now my item model JSON looks like this, which is almost identical to vanilla egg:

 

{

    "parent": "builtin/generated",

    "textures": {

        "layer0": "magicbeans:items/golden_egg"

    }

}

 

 

The item model is registered in my ClientProxy class init stage method like this:

 

@Override

public void fmlLifeCycleEvent(FMLInitializationEvent event)

{

// DEBUG

        System.out.println("on Client side");

 

        // do common stuff

super.fmlLifeCycleEvent(event);

 

// do client-specific stuff

// registerClientPacketHandler();

registerKeyBindings();

 

    // create sphere call list

    createSphereCallList();

   

        registerEntityRenderers();

    registerItemRenderers();

    registerBlockRenderers();

}

 

public void registerItemRenderers()

{

// DEBUG

System.out.println("Registering item renderers");

 

registerItemRenderer(MagicBeans.magicBeans);

registerItemRenderer(MagicBeans.bootsOfSafeFalling);

registerItemRenderer(MagicBeans.goldenGooseMeat);

registerItemRenderer(MagicBeans.itemGoldenEgg);

}

 

public void registerItemRenderer(Item parItem)

{

RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();

 

    renderItem.getItemModelMesher().register(parItem, 0, new ModelResourceLocation(MagicBeans.MODID + ":" + parItem.getUnlocalizedName().substring(5), "inventory"));

}

 

 

 

 

The item class is:

 

public class ItemGoldenEgg extends Item

{

    protected static final SoundEvent SOUND_EVENT_EQUIP = new SoundEvent(new ResourceLocation("random.bow"));

    protected EntityGoldenEggThrown entityEgg;

 

    public ItemGoldenEgg()

    {

        setUnlocalizedName("golden_egg");

    maxStackSize = 16; // same as regular egg

        setCreativeTab(CreativeTabs.MATERIALS);

    }

 

/**

    * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer

    */

    @Override

    public ActionResult<ItemStack> onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, EnumHand parHand)

    {

        if (!par3EntityPlayer.capabilities.isCreativeMode)

        {

            --par1ItemStack.stackSize;

        }

 

        par2World.playSound(par3EntityPlayer.posX,par3EntityPlayer.posY, par3EntityPlayer.posZ, SOUND_EVENT_EQUIP, SoundCategory.PLAYERS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F), true);

 

        if (!par2World.isRemote)

        {

            entityEgg = new EntityGoldenEggThrown(par2World, par3EntityPlayer);

            par2World.spawnEntityInWorld(entityEgg);

        }

 

        return new ActionResult(EnumActionResult.PASS, par1ItemStack);

    }

   

    @Override

    // Doing this override means that there is no localization for language

    // unless you specifically check for localization here and convert

public String getItemStackDisplayName(ItemStack par1ItemStack)

    {

    return Utilities.stringToGolden("Golden Egg", 4);

 

 

 

Don't know what else you might want to see code-wise but the whole thing is on my github (let me know if it is not publicly accessible) here: https://github.com/jabelar/MagicBeans-1.10.2

 

Note that I've seen where people add scaling and translation in the item model JSON. I tried the JSON like this, but still had same result:

 

{

    "parent": "builtin/generated",

    "textures": {

        "layer0": "magicbeans:items/golden_egg"

    },

    "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 ]

        }

    }

}

 

 

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

Link to comment
Share on other sites

1.9 added the

item/generated

model, which extends

builtin/generated

and defines the standard display transformations. Most vanilla item models extend this, yours should too. Only define display transformations in your models if they're different to the standard ones.

 

In addition to

item/generated

, there's now the

block/block

model that defines the standard display transformations for blocks. Most vanilla block models (including "abstract" models like

block/cube_all

) extend this.

 

1.9 also split the

firstperson

and

thirdperson

display transformations into separate left- and right-hand versions.

 

The first- and third-person display transformations only apply when an entity is holding the item. Item entities use the

ground

display transformation.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

  • 3 weeks later...

Had the same problem, managed to solve it with determined experimentation. It took a while as well, too bad I didn't see this sooner.

I still haven't published a mod because I can never get that in-dev version just right to warrant a public release. And yes, after two years of mod development I am still learning to speak Java.

 

Follow me on GitHub: https://github.com/yooksi

Contact me on Twitter: https://twitter.com/yooksi

Read my Minecraft blog: https://yooksidoesminecraft.blogspot.de/

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.