Jump to content

[Solved][1.10] Client crashes on spawnEntity


Zerahi

Recommended Posts

whenever i spawn the entity it crashes the client, then when i restart it entity is in world where it should be like nothing happened, any idea why its crashing?

 

if(!worldObj.isRemote) {

		            Entity spawn = null;

	                spawn = Ref.altarlisttier1(this.display);
	                spawn.setWorld(worldObj);

	                EntityLiving entityliving = spawn instanceof EntityLiving ? (EntityLiving)spawn : null;
                    spawn.setLocationAndAngles(pos.getX(), pos.getY()+1.25f, pos.getZ(), worldObj.rand.nextFloat() * 360.0F, 0.0F);


                        AnvilChunkLoader.spawnEntity(spawn, worldObj);
                        worldObj.playEvent(2004, pos, 0);

                        if (entityliving != null)
                        {
                            entityliving.spawnExplosionParticle();
                        }
		        }

 

Description: Ticking entity

java.lang.NullPointerException: Ticking entity
at net.minecraft.entity.ai.EntityAITasks.onUpdateTasks(EntityAITasks.java:64)
at net.minecraft.entity.EntityLiving.updateEntityActionState(EntityLiving.java:846)
at net.minecraft.entity.EntityLivingBase.onLivingUpdate(EntityLivingBase.java:2392)
at net.minecraft.entity.EntityLiving.onLivingUpdate(EntityLiving.java:643)
at net.minecraft.entity.EntityAgeable.onLivingUpdate(EntityAgeable.java:178)
at net.minecraft.entity.passive.EntityAnimal.onLivingUpdate(EntityAnimal.java:47)
at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:2218)
at net.minecraft.entity.EntityLiving.onUpdate(EntityLiving.java:342)
at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2106)
at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:872)
at net.minecraft.world.World.updateEntity(World.java:2073)
at net.minecraft.world.World.updateEntities(World.java:1886)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:644)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:783)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536)
at java.lang.Thread.run(Unknown Source)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Client thread
Stacktrace:
at net.minecraft.entity.ai.EntityAITasks.onUpdateTasks(EntityAITasks.java:64)
at net.minecraft.entity.EntityLiving.updateEntityActionState(EntityLiving.java:846)
at net.minecraft.entity.EntityLivingBase.onLivingUpdate(EntityLivingBase.java:2392)
at net.minecraft.entity.EntityLiving.onLivingUpdate(EntityLiving.java:643)
at net.minecraft.entity.EntityAgeable.onLivingUpdate(EntityAgeable.java:178)
at net.minecraft.entity.passive.EntityAnimal.onLivingUpdate(EntityAnimal.java:47)
at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:2218)
at net.minecraft.entity.EntityLiving.onUpdate(EntityLiving.java:342)
at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2106)
at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:872)
at net.minecraft.world.World.updateEntity(World.java:2073)

-- Entity being ticked --
Details:
Entity Type: rv.voidbeast (com.ravvoid.entity.mob.EntityVoidBeast)
Entity ID: 0
Entity Name: Void Beast
Entity's Exact location: 237.00, 70.25, 303.00
Entity's Block location: World: (237,70,303), Chunk: (at 13,4,15 in 14,18; contains blocks 224,0,288 to 239,255,303), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Entity's Momentum: 0.00, 0.00, 0.00
Entity's Passengers: []
Entity's Vehicle: ~~ERROR~~ NullPointerException: null
Stacktrace:
at net.minecraft.world.World.updateEntities(World.java:1886)
at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:644)

-- Affected level --
Details:
Level name: New World
All players: 1 total; [EntityPlayerMP['Player368'/314, l='New World', x=231.35, y=69.00, z=301.42]]
Chunk stats: ServerChunkCache: 639 Drop: 0
Level seed: 9049979599259575510
Level generator: ID 00 - default, ver 1. Features enabled: true
Level generator options: 
Level spawn location: World: (256,64,256), Chunk: (at 0,4,0 in 16,16; contains blocks 256,0,256 to 271,255,271), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Level time: 12466 game time, 12466 day time
Level dimension: 0
Level storage version: 0x04ABD - Anvil
Level weather: Rain time: 87931 (now: false), thunder time: 115727 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true
Stacktrace:
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:783)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536)
at java.lang.Thread.run(Unknown Source)

-- System Details --
Details:
Minecraft Version: 1.10.2
Operating System: Windows 10 (amd64) version 10.0
Java Version: 1.8.0_91, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 456852240 bytes (435 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94
FML: MCP 9.32 Powered by Forge 12.18.1.2011 4 mods loaded, 4 mods active
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
UCHIJAAAA	mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) 
UCHIJAAAA	FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.10.2-12.18.1.2011.jar) 
UCHIJAAAA	Forge{12.18.1.2011} [Minecraft Forge] (forgeSrc-1.10.2-12.18.1.2011.jar) 
UCHIJAAAA	rv{1.10.2} [Ravenous Void] (bin) 
Loaded coremods (and transformers): 
GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.
Profiler Position: N/A (disabled)
Player Count: 1 / 8; [EntityPlayerMP['Player368'/314, l='New World', x=231.35, y=69.00, z=301.42]]
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to 'fml,forge'

 

https://github.com/Zerahi/RavenousVoid/blob/master/src/main/java/com/ravvoid/tileentity/TileEntityAltar.java

Link to comment
Share on other sites

For one you are spawning the entity even if it is null.

 

	                EntityLiving entityliving = spawn instanceof EntityLiving ? (EntityLiving)spawn : null;
                    spawn.setLocationAndAngles(pos.getX(), pos.getY()+1.25f, pos.getZ(), worldObj.rand.nextFloat() * 360.0F, 0.0F);


                        AnvilChunkLoader.spawnEntity(spawn, worldObj);

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.

Link to comment
Share on other sites

its not null ever its only triggered if the Ref.altarlisttier1(this.display) != null;

and mob spawns fine from a spawn egg no crash

 

package com.ravvoid.entity.mob;

import com.google.common.base.Predicate;
import com.ravvoid.Ref;

import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackMelee;
import net.minecraft.entity.ai.EntityAIFollowParent;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAIPanic;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.util.DamageSource;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.World;
import net.minecraft.world.storage.loot.LootTableList;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class EntityVoidBeast extends EntityAnimal
{

    public EntityVoidBeast(World world)
    {
        super(world);
        this.setSize(0.9F, 1.1F);
    }

    /**
     * Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
     * the animal type)
     */
    public boolean isBreedingItem(ItemStack stack)
    {
        return false;
    }

    protected void initEntityAI()
    {
        super.initEntityAI();
        this.tasks.addTask(0, new EntityAISwimming(this));
        this.tasks.addTask(1, new EntityAIAttackMelee(this, 1.0D, false));
        this.tasks.addTask(2, new EntityAIWander(this, 1.0D));
        this.tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
        this.tasks.addTask(4, new EntityAILookIdle(this));
        this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
    }

    protected void applyEntityAttributes()
    {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(15.0D);
        this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(20.0D);
        this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.25D);
        this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE);
        this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(3.0D);
    }

    protected SoundEvent getAmbientSound()
    {
        return SoundEvents.field_190026_er;
    }

    protected SoundEvent getHurtSound()
    {
        return SoundEvents.field_190029_eu;
    }

    protected SoundEvent getDeathSound()
    {
        return SoundEvents.field_190028_et;
    }

    protected void playStepSound(BlockPos pos, Block blockIn)
    {
        this.playSound(SoundEvents.field_190030_ev, 0.15F, 1.0F);
    }


    @Nullable
    protected ResourceLocation getLootTable()
    {
        return Ref.VOIDBEAST;
    }

    /**
     * (abstract) Protected helper method to read subclass entity data from NBT.
     */
    public void readEntityFromNBT(NBTTagCompound compound)
    {
        super.readEntityFromNBT(compound);
    }

    /**
     * (abstract) Protected helper method to write subclass entity data to NBT.
     */
    public void writeEntityToNBT(NBTTagCompound compound)
    {
        super.writeEntityToNBT(compound);
    }


    public boolean attackEntityAsMob(Entity entityIn)
    {
        boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), (float)((int)this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue()));

        if (flag)
        {
            this.applyEnchantments(this, entityIn);
        }

        return flag;
    }



@Override
public EntityAgeable createChild(EntityAgeable ageable) {
	// TODO Auto-generated method stub
	return null;
}
}

Link to comment
Share on other sites

Is your Void Beast a hostile entity, if so you might be better to extend something that doesn't extend EntityAgeable

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.

Link to comment
Share on other sites

Entities aren't singletons, you can't just store a single instance and reuse it. You need to create a new instance every time you want to spawn one.

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

Also it seems when you create that single instance, thank you for pointing that out Choonster, you are passing in a null parameter for world.

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.

Link to comment
Share on other sites

All entities need to be registered with the EntityRegistry, but no instead of

 

public static Entity altarlisttier1(ItemStack item) {

	for (Entry<ItemStack, Entity> entry : altarlisttier1.entrySet())
        {
            if (ItemStack.areItemsEqual(item, (ItemStack)entry.getKey()))
            {
            	return entry.getValue();
            }
            else {
            	return null;
            }
        }
	return null;
}

 

Some thing like

public static Entity getEntityFromItemStackInAltar(World world, ItemStack stack) {
     // Only needs either instanceof or ==
     if (stack != null && (stack.getItem() instanceof ItemClass || stack.getItem() == Items.diamond)) {
          return new Entity(world);
     }
}

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.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
  • Topics

×
×
  • Create New...

Important Information

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