Jump to content

Recommended Posts

Posted

I have created a custom ItemEntity, however, no matter what's put into it (100% just vanilla code switched to be mine) Whenever I throw the item it doesn't drop it will pop out of my inventory for not even a millisecond and place back into the spot it was in.

 

  Reveal hidden contents
  Reveal hidden contents

 

Posted
  On 3/21/2022 at 9:13 PM, diesieben07 said:

Why did you both extend and copy ItemEntity? This does not make any sense.

Expand  

I extended it originally, but when I added in the code needed, it still didn't function correctly, so I copied it. I will extend Entity instead and see how that pans out

Posted
  On 3/21/2022 at 9:46 PM, tal124 said:

I extended it originally, but when I added in the code needed, it still didn't function correctly, so I copied it. I will extend Entity instead and see how that pans out

Expand  

There were a few things I couldn't port over to the copied over code, So I went back to the extending, I'm not sure what code I'm putting in/not putting in thats messing with the ItemEntity and not allowing it to drop.

Posted
  On 3/22/2022 at 8:07 AM, diesieben07 said:

Show updated code. And yes, you should extend it and only override what you need to change.

Expand  
public class CoalSwordEntity extends ItemEntity {

    public CoalSwordEntity(EntityType<? extends ItemEntity> entityType, Level level) {
        super(entityType, level);
    }

    public CoalSwordEntity(Level level, double x, double y, double z, ItemStack stack) {
        super(level, x, y, z, stack);
    }

    public CoalSwordEntity(Level level, double x, double y, double z, ItemStack stack, double deltaX, double deltaY, double deltaZ) {
        super(level, x, y, z, stack, deltaX, deltaY, deltaZ);
    }

}

I have reverted to what I had originally to try and figure out what the issue was, It not even dropping the item at all, doing the same thing as before, I'm starting to believe my actual issue is somewhere in my ItemClass and not the ItemEntity class

 

  Reveal hidden contents

Somewhere around here? maybe?

Posted (edited)

you have to create a custom EntityType and you need to register a EntityRenderer for your Entity.

You also can not super the constructor from ItemEntity, since they use the vanilla EntityType 

Edited by Luis_ST
Posted
  On 3/23/2022 at 5:41 AM, Luis_ST said:

you have to create a custom EntityType and you need to register a EntityRenderer for your Entity.

You also can not super the constructor from ItemEntity, since they use the vanilla EntityType 

Expand  

How do I go about registering the EntityRenderer to the eventbus? I'm a bit stuck on that part as well.

Posted
  On 3/23/2022 at 9:04 PM, tal124 said:

How do I go about registering the EntityRenderer to the eventbus? I'm a bit stuck on that part as well.

Expand  
  Reveal hidden contents
  Reveal hidden contents

I'm unsure how to actually register it since I can't actually register the ItemEntity as an Entity since that won't accept ItemEntities.

  Reveal hidden contents

 

Posted

Whenever I do try and register it, it won't let me 

 

  Reveal hidden contents

This throws an error of

"no instance(s) of type variable(s) exist so that EntityType<Entity> conforms to EntityType<CoalSwordEntity> inference variable I has incompatible bounds: equality constraints: EntityType<CoalSwordEntity> lower bounds: EntityType<Entity>

Posted

@tal124  what is it that you are trying to do? because it it's something that can be done in tick handler (update handler), you need none of that above. none.

 

Posted
  On 3/24/2022 at 1:08 PM, MFMods said:

@tal124  what is it that you are trying to do? because it it's something that can be done in tick handler (update handler), you need none of that above. none.

 

Expand  

I figured that out when I was working on my ArmorCustomItems, onEntityItemUpdate works fine for it, But now It pops 3 out at once when I drop them in some fire.
 

  Reveal hidden contents

I've gotten it fixed now, this will set the remove the item and spawn the other item that I'm trying to get. I basically discarded the CustomItemEntity because nothing I did with it would work. Once I found the ArmorTick I thought there might be an Entity modifier for it.

Posted (edited)
  On 3/27/2022 at 1:12 AM, tal124 said:

But now It pops 3 out at once when I drop them in some fire

Expand  

yeah.

look - let's say you and me are playing minecraft together now. there are three game instances running: client game on my machine, client game (window with blocky world) on your machine and a server game (doesn't matter on which machine).  and in all three game "programs", there is a sword in fire; you ask  if (entity.isOnFire())  and entity.spawnAtLocation executes three times (although two out of three fire swords are ghosts and you can't pick them up).  you need to ask ( not event.getWorld().isClientSide() and entity.isOnFire() ).

also, if you are handling entity update, ask whether the entity is removed already. if it is, do nothing. i'm not sure if that's still an issue.

Edited by MFMods
Posted
  On 3/27/2022 at 8:28 AM, MFMods said:

yeah.

look - let's say you and me are playing minecraft together now. there are three game instances running: client game on my machine, client game (window with blocky world) on your machine and a server game (doesn't matter on which machine).  and in all three game "programs", there is a sword in fire; you ask  if (entity.isOnFire())  and entity.spawnAtLocation executes three times (although two out of three fire swords are ghosts and you can't pick them up).  you need to ask ( not event.getWorld().isClientSide() and entity.isOnFire() ).

also, if you are handling entity update, ask whether the entity is removed already. if it is, do nothing. i'm not sure if that's still an issue.

Expand  

Its fixed, I created an Entity.removalReason for the Item and it removes the item before popping out the one Item asked for. The code up there is the current and working version of it. I may go through later and add && level.isClientSide() just for precautions

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.