Jump to content

[1.10.2][UNSOLVED] Registering EntityItems with Forge


Recommended Posts

Posted

I've been trying to find an efficient way of registering my custom EntityItems with Forge for a while. The problem arises when I see how the items behave when tossed and dropped in the world. The motion is way off and there is a few second delay before the items is teleported to a new location a few blocks away from where it once was. If seems like quite a high price to pay just to have them conveniently saved and loaded in your world. Did someone else encounter these issues, and is there a known way to fix this? My main question though would be, what is the proper way of registering and handling an EntityItem?

 

When I do not register the entities and manually spawn them in the world by overriding some methods. everything works fine but as I said, they are not loaded or saved from the world.

 

My current registration method is this:

EntityRegistry.registerModEntity(MyEntityItem.class, "my_entity_item, 0, MyMod.instance, 40, 40, false);

The way I am handling entity creation when using the registration method:

@Override
public boolean hasCustomEntity(ItemStack stack)
{  
    return true;
}

@Override
public Entity createEntity(World world, Entity location, ItemStack itemstack)
{
    return new MyEntityItem(world, location.posX, location.posY, location.posZ, itemstack);		
}

I've been trying to solve this problem on many ways for some time now and I am slowly loosing patience.

Any help would really be appreciated. Thank you in advance guys.

 

EDIT: changed 'hasCustomEntity' return value from false to true, thanks to larsgerrits for spotting the mistake.

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/

Posted

If

Item#hasCustomEntity

returns

false

,

Item#createEntity

is not called. Also, show your

MyEntityItem

class.

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/

Posted

I beleive you want to copy the motion of the entity aswell as the positions.

I've tried this right now:

public Entity createEntity(World world, Entity location, ItemStack itemstack)
{
    return new MyEntityItem(world, location.posX, location.posY, location.posZ, itemstack, location.motionX, location.motionY, location.motionZ);		
}

public MyEntityItem(World worldObj, double posX, double d0, double posZ, ItemStack stack, double motionX, double motionY, double motionZ) 
{
    super(worldObj, posX, d0, posZ, stack);
}

It didn't seem to work at all. It also might be important to note that the when I register the EntityItem it requires a standard EntityItem constructor - MyEntityItem(World). Don't know if that is relevant or not but it looks like it's getting constructed twice, once with that constructor and once with my custom one. If I don't construct it with the custom one passing the location the entity just doesn't appear in the world.

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/

Posted

If

Item#hasCustomEntity

returns

false

,

Item#createEntity

is not called. Also, show your

MyEntityItem

class.

Thank you for spotting that, it was a mistake on my part when I was copy pasting. I didn't read it through enough. I've been experimenting a lot with it and I must have copied it in the stage when it said false. I am aware that it does not appear under this circumstances, the real problem appears when it does spawn. As I've said, the motion is way off and not to mention the weird teleportation effect (like some kind of lag).

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/

Posted

Yes, you need a standard constructor accepting a

World

as it's only argument, and pass it to it's super. This is for when the

Entity

is created from NBT e.g. loaded from a save file. If you want to spawn an

Entity

from code, use your own constructor.

 

For the motion, you never actually set the motion of the your

Entity

in your constructor.

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/

Posted

Yes, you need a standard constructor accepting a

World

as it's only argument, and pass it to it's super. This is for when the

Entity

is created from NBT e.g. loaded from a save file. If you want to spawn an

Entity

from code, use your own constructor.

 

For the motion, you never actually set the motion of the your

Entity

in your constructor.

Since I've tried setting the motion and all that in the constructor and it didn't work (or at least I don't know how to make it work), could you please explain to me how I would manually save and load the entity from NBT to and from the world (to achieve basically the same thing as the registration does, just without the whole 'setting up the motion and fixing the weird teleportation glitch' shenanigans). Also where and how would you set the basic motion to correct this? Because I've tried overriding the dropBlockAsItemWithChance and implementing my own version of spawnAsEntity where I only changed the entity construction invocation, and I also tried copying the motion formation code from several sources and placing it in createNewEntity in my custom item class and nothing worked.

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/

Posted

Yes, you need a standard constructor accepting a

World

as it's only argument, and pass it to it's super. This is for when the

Entity

is created from NBT e.g. loaded from a save file. If you want to spawn an

Entity

from code, use your own constructor.

 

For the motion, you never actually set the motion of the your

Entity

in your constructor.

Since I've tried setting the motion and all that in the constructor and it didn't work (or at least I don't know how to make it work), could you please explain to me how I would manually save and load the entity from NBT to and from the world (to achieve basically the same thing as the registration does, just without the whole 'setting up the motion and fixing the weird teleportation glitch' shenanigans). Also where and how would you set the basic motion to correct this? Because I've tried overriding the dropBlockAsItemWithChance and implementing my own version of spawnAsEntity where I only changed the entity construction invocation, and I also tried copying the motion formation code from several sources and placing it in createNewEntity in my custom item class and nothing worked.

Does your EntityItem extend EntityItem?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

Yes, you need a standard constructor accepting a

World

as it's only argument, and pass it to it's super. This is for when the

Entity

is created from NBT e.g. loaded from a save file. If you want to spawn an

Entity

from code, use your own constructor.

 

For the motion, you never actually set the motion of the your

Entity

in your constructor.

Since I've tried setting the motion and all that in the constructor and it didn't work (or at least I don't know how to make it work), could you please explain to me how I would manually save and load the entity from NBT to and from the world (to achieve basically the same thing as the registration does, just without the whole 'setting up the motion and fixing the weird teleportation glitch' shenanigans). Also where and how would you set the basic motion to correct this? Because I've tried overriding the dropBlockAsItemWithChance and implementing my own version of spawnAsEntity where I only changed the entity construction invocation, and I also tried copying the motion formation code from several sources and placing it in createNewEntity in my custom item class and nothing worked.

Does your EntityItem extend EntityItem?

Yes, it does.

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/

  • 3 weeks later...
Posted

Bumpy ol' bump!

 

Can anyone help me with this issue?

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/

Posted

Bumpy ol' bump!

 

Can anyone help me with this issue?

Can we see the updated whole class?

Let me know if you need me to provide more information.

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/

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Unlock an Instant $100 OFF with the Exclusive Temu Coupon Code ALF401700! Whether you're a first-time shopper or a loyal returning customer, this verified Temu promo code ALF401700 is your gateway to incredible savings on thousands of products. By applying code ALF401700 at checkout, you’ll receive a guaranteed $100 discount on your purchase, plus enjoy additional savings of up to 50% OFF on selected items. This special coupon is designed to maximize your discounts, making your shopping experience at Temu more affordable than ever. Why Choose Temu Coupon Code ALF401700 in 2025? First-Time Shoppers: Score a massive 50% off your first order plus a flat $100 OFF using promo code ALF401700. Returning Customers: Don’t miss out! Use ALF401700 to claim a generous $100 OFF on your next purchase. Massive Clearance Sales: With Temu’s ongoing 2025 clearance events, this code unlocks up to 90% OFF on select deals. Global Reach: Whether you shop from the USA, Canada, Europe, Asia, or beyond, Temu coupon ALF401700 works worldwide. 2025’s Top Temu Discounts Powered by ALF401700: Temu $100 OFF New User Promo — ALF401700 Temu Exclusive Discount for Returning Shoppers — ALF401700 Memorial Day Special: $100 OFF Using ALF401700 Country-Specific Offers: USA, Japan, Mexico, Chile, Colombia, Malaysia, Philippines, South Korea, Saudi Arabia, Qatar, Germany, France, Israel — all accept code ALF401700 Free Gift Unlocks — Apply ALF401700 Without Referrals Stackable Bundles: Combine ALF401700 for $100 OFF with up to 50% sitewide discounts 100% OFF Flash Deals during Temu Events with ALF401700 How to Redeem Your Temu Coupon Code ALF401700: Visit the official Temu website or open the Temu app. Select your favorite products and add them to your cart. Enter the promo code ALF401700 in the discount code field at checkout. Watch your total instantly drop by $100 and enjoy any additional percentage discounts automatically applied. Complete your order and enjoy huge savings! Key Benefits of Using ALF401700 Temu Promo Code: Verified and Tested: This code is active and guaranteed to work for 2025. Applicable for All Users: New or existing customers get to enjoy the perks. Works Across Multiple Countries: Perfect for international shoppers. No Minimum Purchase Required: Use it anytime to save $100. Perfect for Big and Small Orders: Whether buying essentials or splurging, save big with ALF401700. Temu Coupon Code ALF401700 by Region: 🇺🇸 United States — Save $100 OFF 🇨🇦 Canada — Instant $100 Discount 🇬🇧 United Kingdom — Exclusive $100 OFF 🇯🇵 Japan — Hot $100 OFF Deal 🇲🇽 Mexico — Get $100 OFF 🇨🇱 Chile — 2025 Special Discount 🇰🇷 South Korea — Massive Savings 🇵🇭 Philippines — Extra $100 OFF 🇸🇦 Saudi Arabia — Verified Promo 🇶🇦 Qatar — Top Discount 🇩🇪 Germany — Exclusive Savings 🇫🇷 France — Coupon Works 🇮🇱 Israel — Huge Discount Final Words: Make 2025 your year of unbeatable savings with the Temu coupon code ALF401700. Act now to claim your $100 OFF plus unlock additional discounts on thousands of products. Whether shopping for fashion, electronics, home essentials, or gifts, this is the best Temu promo code to maximize your budget. Download the Temu app today, enter ALF401700 at checkout, and watch the savings roll in!
    • Verified users can now unlock a $100 OFF Temu Coupon Code using the verified promo code [ALF401700]. This Temu $100 OFF code works for both new and existing customers and can be used to redeem up to 50% off your next order. Our exclusive Temu coupon code [ALF401700] delivers a flat $100 OFF on top of existing deals. First-time customers using code ALF401700 can save an extra 100% off select items. Returning users also qualify for an automatic $100 OFF discount just by applying this code at checkout. But wait—there’s more. With our Temu coupon codes for 2025, users can score up to 90% OFF on clearance items. Whether you’re shopping in the USA, Canada, UK, or elsewhere, Temu promo code ALF401700 unlocks extra discounts tailored to your account. Some users are saving 100% on items using this 2025 Temu promo code. 🔥 Temu Coupon Highlights Using Code [ALF401700]: Temu new user code – ALF401700: Save 50% off your first order + $100 OFF. Temu promo for existing customers – ALF401700: Enjoy flat $100 OFF instantly. Global availability: Works in the USA, UK, Canada, Germany, France, Japan, Chile, Colombia, Malaysia, Mexico, South Korea, Philippines, Saudi Arabia, Qatar, Pakistan, and more. Top 2025 Coupon Deal: Get $200 OFF plus 100% bonus discounts using code ALF401700. Top-Ranked Temu Deals for 2025 (Coupon Code: ALF401700): ✅ Temu $100 OFF Memorial Day Sale — Use ALF401700 ✅ Temu First Order Coupon — Use ALF401700 for 50% + $100 OFF ✅ Temu USA Coupon Code — Save $100 instantly with ALF401700 ✅ Temu Japan, Germany, Chile Codes — All support ALF401700 ✅ Temu Reddit Discount – $100 OFF: Valid for both new and old users ✅ Temu Coupon Bundle 2025 — $100 OFF + up to 50% slash ✅ 100% OFF Free Gift Code — Use ALF401700, no invite needed ✅ Temu Sign-Up Bonus Promo — Get a welcome $100 OFF instantly ✅ Free Temu Code for New Users — Use ALF401700, no referral required  Temu Clearance Codes 2025 — Use ALF401700 for 85–100% discounts Why ALF401700 is the Best Temu Code in 2025 Using Temu code ALF401700 is your ticket to massive savings, free shipping, first-order discounts, and stackable coupon bundles. Whether you're browsing electronics, fashion, home goods, or beauty products, this verified Temu discount code offers real savings—up to 90% OFF + $100 OFF on qualified orders. 💡 Pro Tip: Apply ALF401700 during checkout in the Temu app or website to activate your instant $100 discount, even if you’re not a new user. Temu $100 OFF Code by Country (All Use ALF401700): 🇺🇸 Temu USA – ALF401700 🇯🇵 Temu Japan – ALF401700 🇲🇽 Temu Mexico – ALF401700 🇨🇱 Temu Chile – ALF401700 🇨🇴 Temu Colombia – ALF401700 🇲🇾 Temu Malaysia – ALF401700 🇵🇭 Temu Philippines – ALF401700 🇰🇷 Temu Korea – ALF401700 🇵🇰 Temu Pakistan – ALF401700 🇫🇮 Temu Finland – ALF401700 🇸🇦 Temu Saudi Arabia – ALF401700 🇶🇦 Temu Qatar – ALF401700 🇫🇷 Temu France – ALF401700 🇩🇪 Temu Germany – ALF401700 🇮🇱 Temu Israel – ALF401700 Temu Coupon Code [ALF401700] Summary for SEO: Temu $100 OFF Code  Temu First Order Discount Code 2025  Temu Verified Promo Code ALF401700  Temu 50% OFF + $100 Bonus  Temu 100% OFF Code 2025  Temu App Promo ALF401700  Temu Working Discount Code 2025 
    • Hey there, nothing to do with the code, I am just suggesting you use Intelij IDEA. Trust me, it is the best.
    • Hey there, nothing to do with the code, I am just suggesting you use Intelij IDEA. Trust me, it is the best.
    • You can check the config of Geckolib and Mowzie's Mobs - maybe there is a way to disable some render features
  • Topics

×
×
  • Create New...

Important Information

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