Jump to content

Recommended Posts

Posted

When loading a world with my custom NetherItemEntity on the ground the game gets stuck at 100% loading world, The process is then unable to be terminated and requires restarting my computer before becoming bootable.

The issue only happens when reloading a world that has my custom ItemEntity on the ground.

At first I was cancelling the EntityJoinWorldEvent and replacing the itemEntity with my own if it was a NetherItem but when this issue started happening I moved to having my Item implement IForgeItem and have a customEntity. This did not fix my issue.

I don't know where to go from here as I don't know how to make my itemEntity invulnerable to fire & lava without this method.

The only similar forum post I found was this: 

 

This is my NetherItemEntity.class

Spoiler

 


public class NetherItemEntity extends ItemEntity {

    private int health = 5;

    public NetherItemEntity(World worldIn, double x, double y, double z, ItemStack stack) {
        super(worldIn, x, y, z, stack);
    }

    @Override
    public void dealFireDamage(int amount){ return; }

    @Override
    public boolean isInvulnerableTo(DamageSource source){
        if(source == DamageSource.IN_FIRE || source == DamageSource.LAVA || source == DamageSource.ON_FIRE)
            return true;
        return super.isInvulnerableTo(source);
    }

}

 

This is my NetheriteIngotItem.class

Spoiler

public class NetheriteIngotItem extends Item implements IForgeItem {
    public NetheriteIngotItem(Properties properties) {
        super(properties);
        setRegistryName("netherite_ingot");
    }

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

    @Override
    @Nullable
    public Entity createEntity(World world, Entity location, ItemStack itemstack) {
        NetherItemEntity entity = new NetherItemEntity(world, location.posX, location.posY, location.posZ, itemstack);
        entity.setPickupDelay(30);
        return entity;
    }


}

 

 

Posted
5 hours ago, kowagatte said:

When loading a world with my custom NetherItemEntity on the ground the game gets stuck at 100% loading world, The process is then unable to be terminated and requires restarting my computer before becoming bootable.

Post the debug.log file.

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 (edited)
5 hours ago, diesieben07 said:

You must use the ItemEntity constructor that takes an EntityType parameter and pass your EntityType.

You will also need to override createSpawnPacket in your entity class and return NetworkHooks.getEntitySpawningPacket.

I have not created an EntityType, would I just use the ItemEntity ItemType? Where will this constructor be called? my IDE says this is never used.

 

Edit: I tried doing what you suggested but the issue seems to keep persiting.
My NetherItemEntity.class

Spoiler

public class NetherItemEntity extends ItemEntity {

    private int health = 5;

    public NetherItemEntity(World worldIn, Entity location, ItemStack stack) {
        super(worldIn, location.posX, location.posY, location.posZ, stack);
    }

    @SuppressWarnings("unchecked")
    public NetherItemEntity(EntityType<Entity> entityEntityType, World world) {
        super((EntityType<? extends ItemEntity>) Patch116Entities.NETHER_ITEM_ENTITY, world);
    }

    @Override
    public void dealFireDamage(int amount){ return; }

    @Override
    public boolean isInvulnerableTo(DamageSource source){
        if(source == DamageSource.IN_FIRE || source == DamageSource.LAVA || source == DamageSource.ON_FIRE)
            return true;
        return super.isInvulnerableTo(source);
    }

    @Override
    public IPacket<?> createSpawnPacket() {
        return NetworkHooks.getEntitySpawningPacket(this);
    }
}

 

My Patch116Entities.class

Spoiler

public class Patch116Entities {

    public static EntityType<?> NETHER_ITEM_ENTITY = EntityType.Builder.create(NetherItemEntity::new, EntityClassification.MISC)
            .build(Patch116.MOD_ID+":nether_item_entity")
            .setRegistryName(new ResourceLocation(Patch116.MOD_ID, "nether_item_entity"));

    @Mod.EventBusSubscriber(modid = Patch116.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
    public static class Registration {
        @SubscribeEvent
        public static void registerEntities(final RegistryEvent.Register<EntityType<?>> event) {
            event.getRegistry().registerAll(NETHER_ITEM_ENTITY);
        }
    }
}

 

The issues still keeps happening, stuck loading at 100% when my custom ItemEntity is on the ground.

Edited by kowagatte
Posted
6 hours ago, Animefan8888 said:

Post the debug.log file.

I don't know how useful it's going to be since the client completely hangs and stops writing to the debug.log, there are no errors in the log.
Heres the last little bit before it hangs, I cant upload the entire thing since its too big.

Spoiler

[19Apr2020 17:34:12.906] [Server thread/DEBUG] [net.minecraftforge.registries.ObjectHolderRegistry/REGISTRIES]: Applying holder lookups
[19Apr2020 17:34:12.907] [Server thread/DEBUG] [net.minecraftforge.registries.ObjectHolderRegistry/REGISTRIES]: Holder lookups applied
[19Apr2020 17:34:12.907] [Server thread/DEBUG] [net.minecraftforge.fml.server.ServerLifecycleHooks/CORE]: Generating PackInfo named mod:forge for mod file /home/kowa/.gradle/caches/forge_gradle/minecraft_user_repo/net/minecraftforge/forge/1.14.4-28.2.0_mapped_snapshot_20190719-1.14.3/forge-1.14.4-28.2.0_mapped_snapshot_20190719-1.14.3-recomp.jar
[19Apr2020 17:34:12.907] [Server thread/DEBUG] [net.minecraftforge.fml.server.ServerLifecycleHooks/CORE]: Generating PackInfo named mod:patch116 for mod file /home/kowa/Desktop/netherrite_patch/build/resources/main
[19Apr2020 17:34:12.907] [Server thread/INFO] [net.minecraft.resources.SimpleReloadableResourceManager/]: Reloading ResourceManager: Default, forge-1.14.4-28.2.0_mapped_snapshot_20190719-1.14.3-recomp.jar, main
[19Apr2020 17:34:13.136] [Server thread/INFO] [net.minecraft.item.crafting.RecipeManager/]: Loaded 6 recipes
[19Apr2020 17:34:13.304] [Server thread/INFO] [net.minecraft.advancements.AdvancementList/]: Loaded 811 advancements
[19Apr2020 17:34:13.309] [Server thread/INFO] [net.minecraft.server.MinecraftServer/]: Preparing start region for dimension minecraft:overworld
[19Apr2020 17:34:13.726] [Client thread/INFO] [net.minecraft.world.chunk.listener.LoggingChunkStatusListener/]: Preparing spawn area: 0%
[19Apr2020 17:34:13.829] [Client thread/INFO] [net.minecraft.world.chunk.listener.LoggingChunkStatusListener/]: Preparing spawn area: 24%
[19Apr2020 17:34:14.338] [Client thread/INFO] [net.minecraft.world.chunk.listener.LoggingChunkStatusListener/]: Preparing spawn area: 83%
[19Apr2020 17:34:14.824] [Client thread/INFO] [net.minecraft.world.chunk.listener.LoggingChunkStatusListener/]: Preparing spawn area: 88%
[19Apr2020 17:34:15.330] [Client thread/INFO] [net.minecraft.world.chunk.listener.LoggingChunkStatusListener/]: Preparing spawn area: 94%

 

 

Posted
3 hours ago, diesieben07 said:

No, you must create your own one. Otherwise Minecraft cannot recognize your entity as its own type and properly spawn it. It will just spawn as a normal item entity on the client also be saved to the disk as such. When it then loads from disk that fails, because the custom item entity hook is not designed to work like that.

 

Why is there an "entityEntityType" parameter but you don't use it?

 

No. You can't have this constructor, as it would use the vanilla item entity type. All your constructors must pass your entity type to super.

Thanks a ton, fixing these issues solved my problem. Kindest regards.

  • 2 weeks later...
Posted

I am getting this problem with my custom item Entity, i've followed whats on this post but its still not working.
 

Main Class

 
 
 
 
Spoiler

@Mod("lavasmelting")
public class LavaSmelting {

    private static final Logger LOGGER = LogManager.getLogger();

    public static EntityType<?> ITEM_ENTITY = EntityType.Builder.create((entityType, world) -> new NewItemEntity(world), EntityClassification.MISC)
            .build("lavasmelting"+":item_entity")
            .setRegistryName(new ResourceLocation("lavasmelting", "item_entity"));



    public LavaSmelting() {
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);
        MinecraftForge.EVENT_BUS.register(this);
    }

    private void setup(final FMLCommonSetupEvent event) {
        LOGGER.info("Lava Smelting is setup!");
    }

    private void doClientStuff(final FMLClientSetupEvent event) {
        LOGGER.info("Lava Smelting client is setup!");
    }

    @SubscribeEvent
    public void itemJoinWorld(EntityJoinWorldEvent event) {
        if(event.getEntity() instanceof ItemEntity && !(event.getEntity() instanceof NewItemEntity)) {
            if(event.getWorld().getChunkProvider().chunkExists(event.getEntity().chunkCoordX, event.getEntity().chunkCoordZ)) {
                event.setCanceled(true);
                NewItemEntity item = new NewItemEntity(event.getWorld(), event.getEntity().getPosX(), event.getEntity().getPosY(), event.getEntity().getPosZ(), ((ItemEntity) event.getEntity()).getItem());
                System.out.println("made item noW!");
                item.setMotion(event.getEntity().getMotion());
                item.setDefaultPickupDelay();
                event.getWorld().addEntity(item);
                System.out.println("Added item");
            }
        }
    }

    @Mod.EventBusSubscriber(modid = "lavasmelting", bus = Mod.EventBusSubscriber.Bus.MOD)
    public static class Registration {
        @SubscribeEvent
        public static void registerEntities(final RegistryEvent.Register<EntityType<?>> event) {
            event.getRegistry().registerAll(ITEM_ENTITY);
            System.out.println("LOADED");
        }
    }
}

 

 

ItemEntity Class

 
 
 
 
Spoiler

public class NewItemEntity extends ItemEntity {

    public NewItemEntity(World world) {
        super((EntityType<? extends ItemEntity>) LavaSmelting.ITEM_ENTITY, world);
    }

    public NewItemEntity(World world, double posX, double posY, double posZ, ItemStack item) {
        super(world,posX,posY,posZ,item);
    }

    @Override
    public IPacket<?> createSpawnPacket() {
        return NetworkHooks.getEntitySpawningPacket(this);
    }
}

 

 I am getting stuck on 100%.

Posted

So this?
 

public ItemEntity(World worldIn, double x, double y, double z, ItemStack stack) {
      this(worldIn, x, y, z);
      this.setItem(stack);
      this.lifespan = (stack.getItem() == null ? 6000 : stack.getEntityLifespan(worldIn));
   }

 

Posted
55 minutes ago, Redstoneguy129 said:
On 4/19/2020 at 1:01 PM, diesieben07 said:

You must use the ItemEntity constructor that takes an EntityType parameter and pass your EntityType.

 

So this?
 


public ItemEntity(World worldIn, double x, double y, double z, ItemStack stack) {
      this(worldIn, x, y, z);
      this.setItem(stack);
      this.lifespan = (stack.getItem() == null ? 6000 : stack.getEntityLifespan(worldIn));
   }

 

Lets look at that constructor for a moment.

It has the following parameters:

  • World worldin
  • double x
  • double y
  • double z
  • ItemStack stack

Are any of these the type EntityType?

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.

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.