Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[Unsolved][1.12.2] Problem on spawning one-per-player-entity spawned by item


_Cruelar_
 Share

Recommended Posts

11 minutes ago, _Cruelar_ said:

else if (this.world.isRemote)

This line right here says is this a client 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

  • Replies 87
  • Created
  • Last Reply

Top Posters In This Topic

3 minutes ago, _Cruelar_ said:

Yes.

And then it does a few things with if it's in the ground and then sets itself to be dead, but only if the above is true. Which setDead are you having a problem with exactly?

Edited by Animefan8888

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

This is interesting. None of my Breakpoints responds.

Code:

package com.cruelar.cruelars_triforcemod.entities.projectiles;

import io.netty.buffer.ByteBuf;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.MoverType;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
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.ResourceLocation;
import net.minecraft.util.math.*;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import java.util.Iterator;
import java.util.List;
import java.util.UUID;

public class Clawshot_Head extends Entity implements IEntityAdditionalSpawnData{
    private UUID entityPlayer;
    public Entity caughtEntity;
    public Clawshot_Head.State currentState;
    private static final DataParameter<Integer> DATA_HOOKED_ENTITY;
    private boolean inGround;
    private int ticksInAir;
    private int ticksInGround;
    public static ResourceLocation RESOURCE_LOCATION=new ResourceLocation("cruelars_triforcemod:textures/entity/projectiles/clawshot_head.png");

    public Clawshot_Head(World world){
        super(world);
    }

    public Clawshot_Head(World world, EntityPlayer entityPlayer){
        super(world);
        this.init(entityPlayer);
        this.currentState = Clawshot_Head.State.FLYING;
        this.setPosition((double)entityPlayer.posX,(double)entityPlayer.posY+entityPlayer.getEyeHeight(),(double)entityPlayer.posZ);
        this.shoot(entityPlayer);
    }

    @SideOnly(Side.CLIENT)
    public Clawshot_Head(World world, EntityPlayer entityPlayer, double posX, double posY, double posZ) {
        super(world);
        this.init(entityPlayer);
        this.setPosition(posX,posY,posZ);
        this.prevPosX = this.posX;
        this.prevPosY = this.posY;
        this.prevPosZ = this.posZ;
    }

    public void notifyDataManagerChange(DataParameter<?> p_notifyDataManagerChange_1_) {
        if (DATA_HOOKED_ENTITY.equals(p_notifyDataManagerChange_1_)) {
            int i = (Integer)this.getDataManager().get(DATA_HOOKED_ENTITY);
            this.caughtEntity = i > 0 ? this.world.getEntityByID(i - 1) : null;
        }

        super.notifyDataManagerChange(p_notifyDataManagerChange_1_);
    }

    public void onUpdate()
    {
        super.onUpdate();
        if (this.entityPlayer == null)
        {
            this.setDead();
            System.out.println("ln:69 got called");
        }
        else if (this.world.isRemote)
        {
            if (this.inGround) {
                ++this.ticksInGround;
                motionX = 0;
                motionY = 0;
                motionZ = 0;
            }

            if(this.collidedHorizontally){
                motionX=0;
                motionY=0;
                motionZ=0;
                ++this.ticksInGround;
            }

            if(this.getDistance(getEntityByUUID(entityPlayer,world))>=64){
                this.setDead();
                System.out.println("ln:89 got called");
            }

            BlockPos blockpos = new BlockPos(this);
            IBlockState iblockstate = this.world.getBlockState(blockpos);
            if (this.currentState == Clawshot_Head.State.FLYING)
            {
                if (this.caughtEntity != null)
                {
                    this.motionX = 0.0D;
                    this.motionY = 0.0D;
                    this.motionZ = 0.0D;
                    this.currentState = Clawshot_Head.State.HOOKED_IN_ENTITY;
                    return;
                }

                if (!this.world.isRemote)
                {
                    this.checkCollision();
                }

                if (!this.inGround && !this.onGround && !this.collidedHorizontally)
                {
                    ++this.ticksInAir;
                }
                else
                {
                    this.ticksInAir = 0;
                    this.motionX = 0.0D;
                    this.motionY = 0.0D;
                    this.motionZ = 0.0D;
                }

            }
            else
            {
                if (this.currentState == Clawshot_Head.State.HOOKED_IN_ENTITY)
                {
                    if (this.caughtEntity != null)
                    {
                        if (this.caughtEntity.isDead)
                        {
                            this.caughtEntity = null;
                            this.currentState = Clawshot_Head.State.FLYING;
                        }
                        else
                        {
                            this.posX = this.caughtEntity.posX;
                            double d2 = (double)this.caughtEntity.height;
                            this.posY = this.caughtEntity.getEntityBoundingBox().minY + d2 * 0.8D;
                            this.posZ = this.caughtEntity.posZ;
                            this.setPosition(this.posX, this.posY, this.posZ);
                        }
                    }

                    return;
                }
            }

            this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ);
            this.updateRotation();
            this.setPosition(this.posX, this.posY, this.posZ);
        }
        if (this.ticksInGround >= 1200)
        {
            this.setDead();
            System.out.println("ln:155 got called");
        }
        if (ticksInAir>=200){
            this.setDead();
            System.out.println("ln:159 got called");
        }

    }

    private void updateRotation()
    {
        float f = MathHelper.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
        this.rotationYaw = (float)(MathHelper.atan2(this.motionX, this.motionZ) * (180D / Math.PI));

        for (this.rotationPitch = (float)(MathHelper.atan2(this.motionY, (double)f) * (180D / Math.PI)); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
        {

        }

        while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
        {
            this.prevRotationPitch += 360.0F;
        }

        while (this.rotationYaw - this.prevRotationYaw < -180.0F)
        {
            this.prevRotationYaw -= 360.0F;
        }

        while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
        {
            this.prevRotationYaw += 360.0F;
        }

        this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
        this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
    }

    public void shoot(Entity entity) {

        System.out.println(entity);
        this.motionX=0.6D*entity.getLookVec().x;
        this.motionY=0.6D*entity.getLookVec().y;
        this.motionZ=0.6D*entity.getLookVec().z;

    }

    public void shoot(double p_shoot_1_, double p_shoot_3_, double p_shoot_5_, float p_shoot_7_, float p_shoot_8_){}

    public int handleHookRetraction()
    {
        if (!this.world.isRemote && this.entityPlayer != null)
        {
            int i = 0;
            if (this.caughtEntity != null)
            {
                this.bringInHookedEntity();
                this.world.setEntityState(this, (byte)31);
                i = this.caughtEntity instanceof EntityItem ? 3 : 5;
            }
            else if (this.inGround)
            {
                i = 2;
            }

            this.setDead();
            return i;
        }
        else
        {
            return 0;
        }
    }

    protected void bringInHookedEntity()
    {
        if (this.getEntityByUUID(entityPlayer,world) != null)
        {
            double d0 = this.getEntityByUUID(entityPlayer,world).posX - this.posX;
            double d1 = this.getEntityByUUID(entityPlayer,world).posY - this.posY;
            double d2 = this.getEntityByUUID(entityPlayer,world).posZ - this.posZ;
            double d3 = 0.1D;
            this.caughtEntity.motionX += d0 * 0.1D;
            this.caughtEntity.motionY += d1 * 0.1D;
            this.caughtEntity.motionZ += d2 * 0.1D;
        }
    }

    public void setDead()
    {
        super.setDead();
    }

    public EntityPlayer getAngler()
    {
        return this.getEntityByUUID(entityPlayer,this.world);
    }

    private EntityPlayer getEntityByUUID(UUID entityUUID, World worldIn){
        int lenght =worldIn.getLoadedEntityList().size();
        List<Entity> loadedEntityList= worldIn.getLoadedEntityList();
        EntityPlayer foundEntity = null;
        for (int i = 0;i<lenght;i++){
            if (loadedEntityList.get(i).getUniqueID()==entityUUID){
                if (loadedEntityList.get(i) instanceof EntityPlayer) {
                    foundEntity = (EntityPlayer) loadedEntityList.get(i);
                }
            }
        }
        return foundEntity;
    }

    private void init(EntityPlayer p_init_1_) {
        this.setSize(0.25F, 0.25F);
        this.ignoreFrustumCheck = true;
        this.entityPlayer = p_init_1_.getUniqueID();
    }

    private void checkCollision() {
        Vec3d vec3d = new Vec3d(this.posX, this.posY, this.posZ);
        Vec3d vec3d1 = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
        RayTraceResult raytraceresult = this.world.rayTraceBlocks(vec3d, vec3d1, false, true, false);
        vec3d = new Vec3d(this.posX, this.posY, this.posZ);
        vec3d1 = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
        if (raytraceresult != null) {
            vec3d1 = new Vec3d(raytraceresult.hitVec.x, raytraceresult.hitVec.y, raytraceresult.hitVec.z);
            this.motionX=0;
            this.motionY=0;
            this.motionZ=0;
            getEntityByUUID(entityPlayer,this.world).posX=this.posX;
            getEntityByUUID(entityPlayer,this.world).posY=this.posY;
            getEntityByUUID(entityPlayer,this.world).posZ=this.posZ;
        }

        Entity entity = null;
        List<Entity> list = this.world.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().expand(this.motionX, this.motionY, this.motionZ).grow(1.0D));
        double d0 = 0.0D;
        Iterator var8 = list.iterator();

        while(true) {
            Entity entity1;
            double d1;
            do {
                RayTraceResult raytraceresult1;
                do {
                    do {
                        do {
                            if (!var8.hasNext()) {
                                if (entity != null) {
                                    raytraceresult = new RayTraceResult(entity);
                                }

                                if (raytraceresult != null && raytraceresult.typeOfHit != RayTraceResult.Type.MISS) {
                                    if (raytraceresult.typeOfHit == RayTraceResult.Type.ENTITY) {
                                        this.caughtEntity = raytraceresult.entityHit;
                                        this.setHookedEntity();
                                    } else {
                                        this.inGround = true;
                                    }
                                }

                                return;
                            }

                            entity1 = (Entity)var8.next();
                        } while(!this.canBeHooked(entity1));
                    } while(entity1 == this.getEntityByUUID(entityPlayer,this.world) && this.ticksInAir < 5);

                    AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().grow(0.30000001192092896D);
                    raytraceresult1 = axisalignedbb.calculateIntercept(vec3d, vec3d1);
                } while(raytraceresult1 == null);

                d1 = vec3d.squareDistanceTo(raytraceresult1.hitVec);
            } while(d1 >= d0 && d0 != 0.0D);

            entity = entity1;
            d0 = d1;
        }
    }

    private void setHookedEntity() {
        this.getDataManager().set(DATA_HOOKED_ENTITY, this.caughtEntity.getEntityId() + 1);
    }

    protected boolean canBeHooked(Entity p_canBeHooked_1_) {
        return p_canBeHooked_1_.canBeCollidedWith() || p_canBeHooked_1_ instanceof EntityItem;
    }

    protected void entityInit() {
        this.getDataManager().register(DATA_HOOKED_ENTITY, 0);
    }

    @Override
    protected void readEntityFromNBT(NBTTagCompound nbtTagCompound) {

    }

    @Override
    protected void writeEntityToNBT(NBTTagCompound nbtTagCompound) {

    }

    static {
        DATA_HOOKED_ENTITY = EntityDataManager.createKey(Clawshot_Head.class, DataSerializers.VARINT);
    }

    @Override
    public void writeSpawnData(ByteBuf buffer) {
        buffer.writeBoolean(getEntityByUUID(entityPlayer,this.world)==null);
        if (getEntityByUUID(entityPlayer,this.world)!=null) {
            buffer.writeInt(getEntityByUUID(entityPlayer,this.world).getEntityId());
        }
    }

    @Override
    public void readSpawnData(ByteBuf additionalData) {
        boolean nullPlayer = additionalData.readBoolean();
        if (!nullPlayer){
            EntityPlayer entityByID=(EntityPlayer) world.getEntityByID(additionalData.readInt());
            if (entityByID!=null){
                entityPlayer=entityByID.getUniqueID();
            }
            this.shoot(getEntityByUUID(entityPlayer,this.world));
        }
    }

    static enum State {
        FLYING,
        HOOKED_IN_ENTITY;

        private State() {
        }
    }
}

I changed the code to mainly use the UUID of the Player after thinking over Problematic code #9

Didn't solved the Problem though

My Projects:

Cruelars Triforcemod (1.12 release; 1.14 alpha soon coming)

 

Important:

As my mod is on at least 10 different third party sites without my permission, I want to warn you about that with a link to StopModReposts

Link to comment
Share on other sites

I made some changes to improve its behavior. But Still it dies after a certain amount  of time that static. Also it then still respawns with the same motion speed as the moment it died.

Updated code:

package com.cruelar.cruelars_triforcemod.entities.projectiles;

import io.netty.buffer.ByteBuf;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.MoverType;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
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.ResourceLocation;
import net.minecraft.util.math.*;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import java.util.Iterator;
import java.util.List;
import java.util.UUID;

public class Clawshot_Head extends Entity implements IEntityAdditionalSpawnData{
    private UUID entityPlayer;
    public Entity caughtEntity;
    public Clawshot_Head.State currentState;
    private static final DataParameter<Integer> DATA_HOOKED_ENTITY;
    private boolean inGround;
    private int ticksInAir;
    private int ticksInGround;
    public static ResourceLocation RESOURCE_LOCATION=new ResourceLocation("cruelars_triforcemod:textures/entity/projectiles/clawshot_head.png");

    public Clawshot_Head(World world){
        super(world);
    }

    public Clawshot_Head(World world, EntityPlayer entityPlayer){
        super(world);
        this.init(entityPlayer);
        this.currentState = Clawshot_Head.State.FLYING;
        this.setPosition((double)entityPlayer.posX,(double)entityPlayer.posY+entityPlayer.getEyeHeight(),(double)entityPlayer.posZ);
        this.shoot(entityPlayer);
        this.setNoGravity(true);
    }

    @SideOnly(Side.CLIENT)
    public Clawshot_Head(World world, EntityPlayer entityPlayer, double posX, double posY, double posZ) {
        super(world);
        this.init(entityPlayer);
        this.setPosition(posX,posY,posZ);
        this.prevPosX = this.posX;
        this.prevPosY = this.posY;
        this.prevPosZ = this.posZ;
    }

    public void notifyDataManagerChange(DataParameter<?> p_notifyDataManagerChange_1_) {
        if (DATA_HOOKED_ENTITY.equals(p_notifyDataManagerChange_1_)) {
            int i = (Integer)this.getDataManager().get(DATA_HOOKED_ENTITY);
            this.caughtEntity = i > 0 ? this.world.getEntityByID(i - 1) : null;
        }

        super.notifyDataManagerChange(p_notifyDataManagerChange_1_);
    }

    public void onUpdate()
    {
        super.onUpdate();
        if (this.entityPlayer == null)
        {
            System.out.println("ln:70 got called");
            this.setDead();

        }
        else if (this.world.isRemote)
        {
            if (this.inGround) {
                ++this.ticksInGround;
                motionX = 0;
                motionY = 0;
                motionZ = 0;
            }

            if(this.collidedHorizontally){
                motionX=0;
                motionY=0;
                motionZ=0;
                ++this.ticksInGround;
            }

            if(this.getDistance(getEntityByUUID(entityPlayer,world))>=64){
                System.out.println("ln:92 got called");
                this.setDead();
            }

            BlockPos blockpos = new BlockPos(this);
            IBlockState iblockstate = this.world.getBlockState(blockpos);
            if (this.currentState == Clawshot_Head.State.FLYING)
            {
                if (this.caughtEntity != null)
                {
                    this.motionX = 0.0D;
                    this.motionY = 0.0D;
                    this.motionZ = 0.0D;
                    this.currentState = Clawshot_Head.State.HOOKED_IN_ENTITY;
                    return;
                }

                if (!this.world.isRemote)
                {
                    this.checkCollision();
                }

                if (!this.inGround && !this.onGround && !this.collidedHorizontally)
                {
                    ++this.ticksInAir;
                }
                else
                {
                    this.ticksInAir = 0;
                    this.motionX = 0.0D;
                    this.motionY = 0.0D;
                    this.motionZ = 0.0D;
                }

            }
            else
            {
                if (this.currentState == Clawshot_Head.State.HOOKED_IN_ENTITY)
                {
                    if (this.caughtEntity != null)
                    {
                        if (this.caughtEntity.isDead)
                        {
                            this.caughtEntity = null;
                            this.currentState = Clawshot_Head.State.FLYING;
                        }
                        else
                        {
                            this.posX = this.caughtEntity.posX;
                            double d2 = (double)this.caughtEntity.height;
                            this.posY = this.caughtEntity.getEntityBoundingBox().minY + d2 * 0.8D;
                            this.posZ = this.caughtEntity.posZ;
                            this.setPosition(this.posX, this.posY, this.posZ);
                        }
                    }

                    return;
                }
            }

            this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ);
            this.updateRotation();
            this.setPosition(this.posX, this.posY, this.posZ);
        }
        if (this.ticksInGround >= 1200)
        {
            System.out.println("ln:157 got called");
            this.setDead();
        }
        if (ticksInAir>=200){
            System.out.println("ln:162 got called");
            this.setDead();
        }

    }

    private void updateRotation()
    {
        float f = MathHelper.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
        this.rotationYaw = (float)(MathHelper.atan2(this.motionX, this.motionZ) * (180D / Math.PI));

        for (this.rotationPitch = (float)(MathHelper.atan2(this.motionY, (double)f) * (180D / Math.PI)); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
        {

        }

        while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
        {
            this.prevRotationPitch += 360.0F;
        }

        while (this.rotationYaw - this.prevRotationYaw < -180.0F)
        {
            this.prevRotationYaw -= 360.0F;
        }

        while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
        {
            this.prevRotationYaw += 360.0F;
        }

        this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
        this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
    }

    public void shoot(Entity entity) {
        System.out.println(entity);
        this.motionX=0.6D*entity.getLookVec().x;
        this.motionY=0.6D*entity.getLookVec().y;
        this.motionZ=0.6D*entity.getLookVec().z;

    }

    public void shoot(double p_shoot_1_, double p_shoot_3_, double p_shoot_5_, float p_shoot_7_, float p_shoot_8_){}

    public int handleHookRetraction()
    {
        if (!this.world.isRemote && this.entityPlayer != null)
        {
            int i = 0;
            if (this.caughtEntity != null)
            {
                this.bringInHookedEntity();
                this.world.setEntityState(this, (byte)31);
                i = this.caughtEntity instanceof EntityItem ? 3 : 5;
            }
            else if (this.inGround)
            {
                i = 2;
            }

            this.setDead();
            return i;
        }
        else
        {
            return 0;
        }
    }

    protected void bringInHookedEntity()
    {
        if (this.getEntityByUUID(entityPlayer,world) != null)
        {
            double d0 = this.getEntityByUUID(entityPlayer,world).posX - this.posX;
            double d1 = this.getEntityByUUID(entityPlayer,world).posY - this.posY;
            double d2 = this.getEntityByUUID(entityPlayer,world).posZ - this.posZ;
            double d3 = 0.1D;
            this.caughtEntity.motionX += d0 * 0.1D;
            this.caughtEntity.motionY += d1 * 0.1D;
            this.caughtEntity.motionZ += d2 * 0.1D;
        }
    }

    public void setDead()
    {
        super.setDead();
    }

    public EntityPlayer getAngler()
    {
        return this.getEntityByUUID(entityPlayer,this.world);
    }

    private EntityPlayer getEntityByUUID(UUID entityUUID, World worldIn){
        int lenght =worldIn.getLoadedEntityList().size();
        List<Entity> loadedEntityList= worldIn.getLoadedEntityList();
        EntityPlayer foundEntity = null;
        for (int i = 0;i<lenght;i++){
            if (loadedEntityList.get(i).getUniqueID()==entityUUID){
                if (loadedEntityList.get(i) instanceof EntityPlayer) {
                    foundEntity = (EntityPlayer) loadedEntityList.get(i);
                }
            }
        }
        return foundEntity;
    }

    private void init(EntityPlayer p_init_1_) {
        this.setSize(0.25F, 0.25F);
        this.ignoreFrustumCheck = true;
        this.entityPlayer = p_init_1_.getUniqueID();
    }

    private void checkCollision() {
        Vec3d vec3d = new Vec3d(this.posX, this.posY, this.posZ);
        Vec3d vec3d1 = new Vec3d(this.posX + 0.2, this.posY + 0.2, this.posZ + 0.2);
        RayTraceResult raytraceresult = this.world.rayTraceBlocks(vec3d, vec3d1, false, true, false);
        vec3d = new Vec3d(this.posX, this.posY, this.posZ);
        vec3d1 = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
        if (raytraceresult != null) {
            vec3d1 = new Vec3d(raytraceresult.hitVec.x, raytraceresult.hitVec.y, raytraceresult.hitVec.z);
            this.inGround=true;
            this.motionX=0;
            this.motionY=0;
            this.motionZ=0;
            getEntityByUUID(entityPlayer,this.world).posX=this.posX;
            getEntityByUUID(entityPlayer,this.world).posY=this.posY;
            getEntityByUUID(entityPlayer,this.world).posZ=this.posZ;
        }

        Entity entity = null;
        List<Entity> list = this.world.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().expand(this.motionX, this.motionY, this.motionZ).grow(1.0D));
        double d0 = 0.0D;
        Iterator var8 = list.iterator();

        while(true) {
            Entity entity1;
            double d1;
            do {
                RayTraceResult raytraceresult1;
                do {
                    do {
                        do {
                            if (!var8.hasNext()) {
                                if (entity != null) {
                                    raytraceresult = new RayTraceResult(entity);
                                }

                                if (raytraceresult != null && raytraceresult.typeOfHit != RayTraceResult.Type.MISS) {
                                    if (raytraceresult.typeOfHit == RayTraceResult.Type.ENTITY) {
                                        this.caughtEntity = raytraceresult.entityHit;
                                        this.setHookedEntity();
                                    } else {
                                        this.inGround = true;
                                    }
                                }

                                return;
                            }

                            entity1 = (Entity)var8.next();
                        } while(!this.canBeHooked(entity1));
                    } while(entity1 == this.getEntityByUUID(entityPlayer,this.world) && this.ticksInAir < 5);

                    AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().grow(0.30000001192092896D);
                    raytraceresult1 = axisalignedbb.calculateIntercept(vec3d, vec3d1);
                } while(raytraceresult1 == null);

                d1 = vec3d.squareDistanceTo(raytraceresult1.hitVec);
            } while(d1 >= d0 && d0 != 0.0D);

            entity = entity1;
            d0 = d1;
        }
    }

    private void setHookedEntity() {
        this.getDataManager().set(DATA_HOOKED_ENTITY, this.caughtEntity.getEntityId() + 1);
    }

    protected boolean canBeHooked(Entity p_canBeHooked_1_) {
        return p_canBeHooked_1_.canBeCollidedWith() || p_canBeHooked_1_ instanceof EntityItem;
    }

    protected void entityInit() {
        this.getDataManager().register(DATA_HOOKED_ENTITY, 0);
    }

    @Override
    protected void readEntityFromNBT(NBTTagCompound nbtTagCompound) {

    }

    @Override
    protected void writeEntityToNBT(NBTTagCompound nbtTagCompound) {

    }

    static {
        DATA_HOOKED_ENTITY = EntityDataManager.createKey(Clawshot_Head.class, DataSerializers.VARINT);
    }

    @Override
    public void writeSpawnData(ByteBuf buffer) {
        buffer.writeBoolean(getEntityByUUID(entityPlayer,this.world)==null);
        if (getEntityByUUID(entityPlayer,this.world)!=null) {
            buffer.writeInt(getEntityByUUID(entityPlayer,this.world).getEntityId());
        }
    }

    @Override
    public void readSpawnData(ByteBuf additionalData) {
        boolean nullPlayer = additionalData.readBoolean();
        if (!nullPlayer){
            EntityPlayer entityByID=(EntityPlayer) world.getEntityByID(additionalData.readInt());
            if (entityByID!=null){
                entityPlayer=entityByID.getUniqueID();
            }
            this.shoot(getEntityByUUID(entityPlayer,this.world));
        }
    }

    static enum State {
        FLYING,
        HOOKED_IN_ENTITY;

        private State() {
        }
    }
}

 

My Projects:

Cruelars Triforcemod (1.12 release; 1.14 alpha soon coming)

 

Important:

As my mod is on at least 10 different third party sites without my permission, I want to warn you about that with a link to StopModReposts

Link to comment
Share on other sites

I found something that might give a hint to the core of the problem:

I'm calling shoot in the constructor and in the readSpawnData()

If I remove it in the constructor the Entity can't move.

If I remove it in readSpawnData() the behavior doesn't change

I noticed it by reading the output of shoot() when I Right click to shoot:

Spoiler

[12:24:02] [main/INFO] [STDOUT]: [com.cruelar.cruelars_triforcemod.entities.projectiles.Clawshot_Head:shoot:207]: EntityPlayerSP['Player200'/373, l='MpServer', x=224.65, y=93.19, z=279.93]
[12:24:02] [Server thread/INFO] [STDOUT]: [com.cruelar.cruelars_triforcemod.entities.projectiles.Clawshot_Head:shoot:207]: EntityPlayerMP['Player200'/373, l='Triforce Test', x=224.65, y=93.19, z=279.93]
[12:24:02] [main/INFO] [STDOUT]: [com.cruelar.cruelars_triforcemod.entities.projectiles.Clawshot_Head:shoot:207]: EntityPlayerSP['Player200'/373, l='MpServer', x=224.65, y=93.19, z=279.93]

A minor thing would be that I want to have a chain or at least a line between the entity and the item and don't know how to do that.

My Projects:

Cruelars Triforcemod (1.12 release; 1.14 alpha soon coming)

 

Important:

As my mod is on at least 10 different third party sites without my permission, I want to warn you about that with a link to StopModReposts

Link to comment
Share on other sites

@Animefan8888 and @diesieben07

I'm feeling we're close to the solution but I need your help as I don't know enough about this stuff yet.

My Projects:

Cruelars Triforcemod (1.12 release; 1.14 alpha soon coming)

 

Important:

As my mod is on at least 10 different third party sites without my permission, I want to warn you about that with a link to StopModReposts

Link to comment
Share on other sites

So I just managed to set up the breakpoints. Seems like I've done something wrong before.

But still The Entity is only set dead when I reload the world. All other conditions than entityplayer==null seem to be false all the time.

I'll appreciate any help. (Code is in my older posts)

Also the Entity starts after a short time at its startposition with its new movement speed.

My Projects:

Cruelars Triforcemod (1.12 release; 1.14 alpha soon coming)

 

Important:

As my mod is on at least 10 different third party sites without my permission, I want to warn you about that with a link to StopModReposts

Link to comment
Share on other sites

How can my Entity "die" without causing one of my Breakpoints? The only Output I get is on Loading a World cause off EntityPlayer being null

My Projects:

Cruelars Triforcemod (1.12 release; 1.14 alpha soon coming)

 

Important:

As my mod is on at least 10 different third party sites without my permission, I want to warn you about that with a link to StopModReposts

Link to comment
Share on other sites

9 hours ago, _Cruelar_ said:

How can my Entity "die" without causing one of my Breakpoints? The only Output I get is on Loading a World cause off EntityPlayer being null

Override set dead, return super & set a breakpoint there

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

On 7/28/2018 at 8:19 PM, _Cruelar_ said:

public void setDead() { super.setDead(); }

I did already. no results. that's why I used these ".

Edited by _Cruelar_

My Projects:

Cruelars Triforcemod (1.12 release; 1.14 alpha soon coming)

 

Important:

As my mod is on at least 10 different third party sites without my permission, I want to warn you about that with a link to StopModReposts

Link to comment
Share on other sites

I experimented a bit and now I have two one entity: One that behaves like before and one with the right size and almost the right behavior.

Here's my updated code:

Item:

package com.cruelar.cruelars_triforcemod.items;

import com.cruelar.cruelars_triforcemod.Cruelars_Triforcemod_Core;
import com.cruelar.cruelars_triforcemod.entities.projectiles.Clawshot_Head;
import com.cruelar.cruelars_triforcemod.inventory.cruelars_triforcemod;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.IItemPropertyGetter;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import javax.annotation.Nullable;
import java.util.List;
import java.util.Objects;
import java.util.UUID;

public class Clawshot_TP extends Item {
    public Entity entity;

    public Clawshot_TP(){
        this.setCreativeTab(cruelars_triforcemod.CRUELARS_TRIFORCEMOD);
        this.setRegistryName("clawshot_tp");
        this.setUnlocalizedName(Cruelars_Triforcemod_Core.MODID+".clawshot_tp");
        this.addPropertyOverride(new ResourceLocation("cast"), new IItemPropertyGetter() {
            @SideOnly(Side.CLIENT)
            public float apply(ItemStack p_apply_1_, @Nullable World p_apply_2_, @Nullable EntityLivingBase p_apply_3_) {
                if (p_apply_3_ == null) {
                    return 0.0F;
                } else {
                    boolean lvt_4_1_ = p_apply_3_.getHeldItemMainhand() == p_apply_1_;
                    boolean lvt_5_1_ = p_apply_3_.getHeldItemOffhand() == p_apply_1_;
                    if (p_apply_3_.getHeldItemMainhand().getItem() instanceof Clawshot_TP) {
                        lvt_5_1_ = false;
                    }

                    return (lvt_4_1_ || lvt_5_1_) && p_apply_3_ instanceof EntityPlayer && entity != null ? 1.0F : 0.0F;
                }
            }
        });
    }

    @Override
    public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer entityPlayer,EnumHand enumHand) {
        ItemStack itemStack = entityPlayer.getHeldItem(enumHand);
		if (world.isRemote){
            if (!this.getTagCompoundSafe(itemStack).hasKey("shot") || !this.getTagCompoundSafe(itemStack).getBoolean("shot") || this.getEntityByUUID(Objects.requireNonNull(this.getTagCompoundSafe(itemStack).getUniqueId("head")),world,itemStack)!=null && this.getEntityByUUID(Objects.requireNonNull(this.getTagCompoundSafe(itemStack).getUniqueId("head")),world,itemStack).isDead) {
                Clawshot_Head clawshot_head = new Clawshot_Head(world, entityPlayer);
                clawshot_head.shoot(entityPlayer);
                world.spawnEntity(clawshot_head);
                this.getTagCompoundSafe(itemStack).setBoolean("shot",true);
                this.getTagCompoundSafe(itemStack).setUniqueId("head",clawshot_head.getUniqueID());
            } else if (this.getEntityByUUID(this.getTagCompoundSafe(itemStack).getUniqueId("head"),world,itemStack)!=null){
                this.getEntityByUUID(this.getTagCompoundSafe(itemStack).getUniqueId("head"),world,itemStack).setDead();
                this.getTagCompoundSafe(itemStack).setBoolean("shot",false);
            }
        }
        return new ActionResult(EnumActionResult.SUCCESS,itemStack);
    }

    @SideOnly(Side.CLIENT)
    public void initModel(){
        ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation(Objects.requireNonNull(getRegistryName()), "inventory"));
    }

    private NBTTagCompound getTagCompoundSafe(ItemStack stack) {
        NBTTagCompound tagCompound = stack.getTagCompound();
        if (tagCompound == null) {
            tagCompound = new NBTTagCompound();
            stack.setTagCompound(tagCompound);
        }
        return tagCompound;
    }

    private Entity getEntityByUUID(UUID entityUUID, World worldIn, ItemStack itemStack){
        int lenght =worldIn.loadedEntityList.size();
        List<Entity> loadedEntityList= worldIn.loadedEntityList;
        Entity foundEntity = null;
        for (int i = 0;i<lenght;i++){
            if (loadedEntityList.get(i).getUniqueID()==entityUUID){
                foundEntity = loadedEntityList.get(i);
            }
        }
        entity=foundEntity;
        return foundEntity;
    }
}

Entity:

package com.cruelar.cruelars_triforcemod.entities.projectiles;

import io.netty.buffer.ByteBuf;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.MoverType;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
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.ResourceLocation;
import net.minecraft.util.math.*;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import java.util.Iterator;
import java.util.List;
import java.util.UUID;

public class Clawshot_Head extends Entity implements IEntityAdditionalSpawnData{
    private UUID entityPlayer;
    public Entity caughtEntity;
    public Clawshot_Head.State currentState;
    private static final DataParameter<Integer> DATA_HOOKED_ENTITY;
    private boolean inGround;
    private int ticksInAir;
    private int ticksInGround;
    public static final ResourceLocation RESOURCE_LOCATION=new ResourceLocation("cruelars_triforcemod:textures/entity/projectiles/clawshot_head.png");

    public Clawshot_Head(World world){
        super(world);
    }

    public Clawshot_Head(World world, EntityPlayer entityPlayer){
        super(world);
        this.init(entityPlayer);
        this.currentState = Clawshot_Head.State.FLYING;
        this.setPosition((double)entityPlayer.posX,(double)entityPlayer.posY+entityPlayer.getEyeHeight(),(double)entityPlayer.posZ);
        //this.shoot(entityPlayer); // Changed that as it is called before readSpawnData and writeSpawnData
        this.setNoGravity(true);
    }

    @SideOnly(Side.CLIENT)
    public Clawshot_Head(World world, EntityPlayer entityPlayer, double posX, double posY, double posZ) {
        super(world);
        this.init(entityPlayer);
        this.setPosition(posX,posY,posZ);
        this.prevPosX = this.posX;
        this.prevPosY = this.posY;
        this.prevPosZ = this.posZ;
    }

    public void notifyDataManagerChange(DataParameter<?> p_notifyDataManagerChange_1_) {
        if (DATA_HOOKED_ENTITY.equals(p_notifyDataManagerChange_1_)) {
            int i = (Integer)this.getDataManager().get(DATA_HOOKED_ENTITY);
            this.caughtEntity = i > 0 ? this.world.getEntityByID(i - 1) : null;
        }

        super.notifyDataManagerChange(p_notifyDataManagerChange_1_);
    }

    public void onUpdate()
    {
        super.onUpdate();
        if (this.entityPlayer == null)
        {
            System.out.println("ln:70 got called");
            this.setDead();

        }
        else if (this.world.isRemote)
        {
            if (this.inGround) {
                ++this.ticksInGround;
                motionX = 0;
                motionY = 0;
                motionZ = 0;
            }

            if(this.collidedHorizontally){
                motionX=0;
                motionY=0;
                motionZ=0;
                ++this.ticksInGround;
            }

            if(this.getDistance(getEntityByUUID(entityPlayer,world))>=64){
                System.out.println("ln:92 got called");
                this.setDead();
            }

            BlockPos blockpos = new BlockPos(this);
            IBlockState iblockstate = this.world.getBlockState(blockpos);
            if (this.currentState == Clawshot_Head.State.FLYING)
            {
                if (this.caughtEntity != null)
                {
                    this.motionX = 0.0D;
                    this.motionY = 0.0D;
                    this.motionZ = 0.0D;
                    this.currentState = Clawshot_Head.State.HOOKED_IN_ENTITY;
                    return;
                }

                if (!this.world.isRemote)
                {
                    this.checkCollision();
                }

            }
            else
            {
                if (this.currentState == Clawshot_Head.State.HOOKED_IN_ENTITY)
                {
                    if (this.caughtEntity != null)
                    {
                        if (this.caughtEntity.isDead)
                        {
                            this.caughtEntity = null;
                            this.currentState = Clawshot_Head.State.FLYING;
                        }
                        else
                        {
                            this.posX = this.caughtEntity.posX;
                            double d2 = (double)this.caughtEntity.height;
                            this.posY = this.caughtEntity.getEntityBoundingBox().minY + d2 * 0.8D;
                            this.posZ = this.caughtEntity.posZ;
                            this.setPosition(this.posX, this.posY, this.posZ);
                        }
                    }

                    return;
                }
            }

            this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ);
            this.updateRotation();
            this.setPosition(this.posX, this.posY, this.posZ);
        }
        if (this.ticksInAir>20){
            this.setDead();
        }
        if (this.ticksInGround >= 1200)
        {
            System.out.println("ln:147 got called");
            this.setDead();
        }

    }

    private void updateRotation()
    {
        float f = MathHelper.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
        this.rotationYaw = (float)(MathHelper.atan2(this.motionX, this.motionZ) * (180D / Math.PI));

        for (this.rotationPitch = (float)(MathHelper.atan2(this.motionY, (double)f) * (180D / Math.PI)); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
        {

        }

        while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
        {
            this.prevRotationPitch += 360.0F;
        }

        while (this.rotationYaw - this.prevRotationYaw < -180.0F)
        {
            this.prevRotationYaw -= 360.0F;
        }

        while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
        {
            this.prevRotationYaw += 360.0F;
        }

        this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
        this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
    }

    public void shoot(Entity entity) {
        System.out.println(entity);
        this.motionX=0.6D*entity.getLookVec().x;
        this.motionY=0.6D*entity.getLookVec().y;
        this.motionZ=0.6D*entity.getLookVec().z;

    }

    public void shoot(double p_shoot_1_, double p_shoot_3_, double p_shoot_5_, float p_shoot_7_, float p_shoot_8_){}

    public int handleHookRetraction()
    {
        if (!this.world.isRemote && this.entityPlayer != null)
        {
            int i = 0;
            if (this.caughtEntity != null)
            {
                this.bringInHookedEntity();
                this.world.setEntityState(this, (byte)31);
                i = this.caughtEntity instanceof EntityItem ? 3 : 5;
            }
            else if (this.inGround)
            {
                i = 2;
            }

            this.setDead();
            return i;
        }
        else
        {
            return 0;
        }
    }

    protected void bringInHookedEntity()
    {
        if (this.getEntityByUUID(entityPlayer,world) != null)
        {
            double d0 = this.getEntityByUUID(entityPlayer,world).posX - this.posX;
            double d1 = this.getEntityByUUID(entityPlayer,world).posY - this.posY;
            double d2 = this.getEntityByUUID(entityPlayer,world).posZ - this.posZ;
            double d3 = 0.1D;
            this.caughtEntity.motionX += d0 * d3;
            this.caughtEntity.motionY += d1 * d3;
            this.caughtEntity.motionZ += d2 * d3;
        }
    }

    public void setDead()
    {
        super.setDead();
    }

    public EntityPlayer getAngler()
    {
        return this.getEntityByUUID(entityPlayer,this.world);
    }


    private EntityPlayer getEntityByUUID(UUID entityUUID, World worldIn){
        int lenght =worldIn.loadedEntityList.size();
        List<Entity> loadedEntityList= worldIn.loadedEntityList;
        EntityPlayer foundEntity = null;
        for (int i = 0;i<lenght;i++){
            if (loadedEntityList.get(i).getUniqueID()==entityUUID){
                if (loadedEntityList.get(i) instanceof EntityPlayer) {
                    foundEntity = (EntityPlayer) loadedEntityList.get(i);
                }
            }
        }
        return foundEntity;
    }

    private void init(EntityPlayer p_init_1_) {
        this.setSize(0.25F, 0.25F);
        this.ignoreFrustumCheck = true;
        this.entityPlayer = p_init_1_.getUniqueID();
    }

    private void checkCollision() {
        Vec3d vec3d = new Vec3d(this.posX, this.posY, this.posZ);
        Vec3d vec3d1 = new Vec3d(this.posX + 0.2, this.posY + 0.2, this.posZ + 0.2);
        RayTraceResult raytraceresult = this.world.rayTraceBlocks(vec3d, vec3d1, false, true, false);
        vec3d = new Vec3d(this.posX, this.posY, this.posZ);
        vec3d1 = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
        if (raytraceresult != null) {
            vec3d1 = new Vec3d(raytraceresult.hitVec.x, raytraceresult.hitVec.y, raytraceresult.hitVec.z);
            this.inGround=true;
            this.motionX=0;
            this.motionY=0;
            this.motionZ=0;
            getEntityByUUID(entityPlayer,this.world).posX=this.posX;
            getEntityByUUID(entityPlayer,this.world).posY=this.posY;
            getEntityByUUID(entityPlayer,this.world).posZ=this.posZ;
        }

        Entity entity = null;
        List<Entity> list = this.world.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().expand(this.motionX, this.motionY, this.motionZ).grow(1.0D));
        double d0 = 0.0D;
        Iterator var8 = list.iterator();

        while(true) {
            Entity entity1;
            double d1;
            do {
                RayTraceResult raytraceresult1;
                do {
                    do {
                        do {
                            if (!var8.hasNext()) {
                                if (entity != null) {
                                    raytraceresult = new RayTraceResult(entity);
                                }

                                if (raytraceresult != null && raytraceresult.typeOfHit != RayTraceResult.Type.MISS) {
                                    if (raytraceresult.typeOfHit == RayTraceResult.Type.ENTITY) {
                                        this.caughtEntity = raytraceresult.entityHit;
                                        this.setHookedEntity();
                                    } else {
                                        this.inGround = true;
                                    }
                                }

                                return;
                            }

                            entity1 = (Entity)var8.next();
                        } while(!this.canBeHooked(entity1));
                    } while(entity1 == this.getEntityByUUID(entityPlayer,this.world) && this.ticksInAir < 5);

                    AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().grow(0.30000001192092896D);
                    raytraceresult1 = axisalignedbb.calculateIntercept(vec3d, vec3d1);
                } while(raytraceresult1 == null);

                d1 = vec3d.squareDistanceTo(raytraceresult1.hitVec);
            } while(d1 >= d0 && d0 != 0.0D);

            entity = entity1;
            d0 = d1;
        }
    }

    private void setHookedEntity() {
        this.getDataManager().set(DATA_HOOKED_ENTITY, this.caughtEntity.getEntityId() + 1);
    }

    protected boolean canBeHooked(Entity p_canBeHooked_1_) {
        return p_canBeHooked_1_.canBeCollidedWith() || p_canBeHooked_1_ instanceof EntityItem;
    }

    protected void entityInit() {
        this.getDataManager().register(DATA_HOOKED_ENTITY, 0);
    }

    @Override
    protected void readEntityFromNBT(NBTTagCompound nbtTagCompound) {

    }

    @Override
    protected void writeEntityToNBT(NBTTagCompound nbtTagCompound) {

    }

    static {
        DATA_HOOKED_ENTITY = EntityDataManager.createKey(Clawshot_Head.class, DataSerializers.VARINT);
    }

    @Override
    public void writeSpawnData(ByteBuf buffer) {
        buffer.writeBoolean(getEntityByUUID(entityPlayer,this.world)==null);
        if (getEntityByUUID(entityPlayer,this.world)!=null) {
            buffer.writeInt(getEntityByUUID(entityPlayer,this.world).getEntityId());
        }
    }

    @Override
    public void readSpawnData(ByteBuf additionalData) {
        boolean nullPlayer = additionalData.readBoolean();
        if (!nullPlayer){
            EntityPlayer entityByID=(EntityPlayer) world.getEntityByID(additionalData.readInt());
            if (entityByID!=null){
                entityPlayer=entityByID.getUniqueID();
            }
            //this.shoot(getEntityByUUID(entityPlayer,this.world)); //changed that because it is only called on one Side. Obviously the wrong side.
        }
    }

    static enum State {
        FLYING,
        HOOKED_IN_ENTITY;

        private State() {
        }
    }
}

New log output when shooting:

Spoiler

[11:13:43] [main/INFO] [STDOUT]: [com.cruelar.cruelars_triforcemod.entities.projectiles.Clawshot_Head:shoot:209]: EntityPlayerSP['Player636'/283, l='MpServer', x=250.85, y=72.79, z=261.42]
[11:15:01] [main/INFO] [STDOUT]: [com.cruelar.cruelars_triforcemod.entities.projectiles.Clawshot_Head:onUpdate:92]: ln:92 got called

It dies from me being to far away. Remaining Problems:

I can't retract it and can't use the Item more than one time.

I would like to have a line drawn between the Entity and me. Quite similar to the fishing hook.

Edited by _Cruelar_
More experimenting removed the 2nd entity, Updated code

My Projects:

Cruelars Triforcemod (1.12 release; 1.14 alpha soon coming)

 

Important:

As my mod is on at least 10 different third party sites without my permission, I want to warn you about that with a link to StopModReposts

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
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.

 Share




  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Yeah that's the correct Forum Experience (a lot since he join 2012) and knowledge from other threads with similar problems
    • I had tried using ContainerData before but I didn't notice addDataSlots in AbstractFurnaceMenu. After adding it to the constructor it worked. Thank you.
    • I'm assuming its in the wrong class because of this line ? Which would make it Client side ? @Mod.EventBusSubscriber(modid = MyMod.MODID, bus = Bus.MOD, value = Dist.CLIENT) Would removing this and setting up the MyMod.java like this be correct? I ask because I see other examples use the public static final RegistryObject<> in the same class that they setup the public static final DeferredRegister<>, and not for just particles. public MyMod() { // Register the setup method for modloading IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); ParticleRegistration.PARTICLES_TYPES.register(bus); } Or do I need to make further changes to the registration then? Such as moving the registerParticleFactory() to a ClientStartup/ClientProxy ?
    • For this branch, after I wrote the latest commit, it caused the loading percent to be stuck at 0% whenever I create a new world.  This is the latest log:  [19Jan2022 19:38:32.502] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--gameDir, ., --launchTarget, fmluserdevclient, --fml.mcpVersion, 20210115.111550, --fml.mcVersion, 1.16.5, --fml.forgeGroup, net.minecraftforge, --fml.forgeVersion, 36.2.20, --assetIndex, 1.16, --assetsDir, C:\Users\david\.gradle\caches\forge_gradle\assets, --version, MOD_DEV, --username, Dev, --accessToken, ❄❄❄❄❄❄❄❄, --userProperties, {}] [19Jan2022 19:38:32.509] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 8.0.9+86+master.3cf110c starting: java version 16.0.2 by Oracle Corporation [19Jan2022 19:38:33.121] [main/INFO] [net.minecraftforge.fml.loading.FixSSL/CORE]: Added Lets Encrypt root certificates as additional trust [19Jan2022 19:38:33.248] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.4 Source=file:/C:/Users/david/.gradle/caches/modules-2/files-2.1/org.spongepowered/mixin/0.8.4/4ec7d77d9ab32596ca0b78bb123956734767e3a/mixin-0.8.4.jar Service=ModLauncher Env=CLIENT [19Jan2022 19:38:38.129] [main/INFO] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Launching target 'fmluserdevclient' with arguments [--version, MOD_DEV, --gameDir, ., --assetsDir, C:\Users\david\.gradle\caches\forge_gradle\assets, --assetIndex, 1.16, --username, Dev, --accessToken, ❄❄❄❄❄❄❄❄, --userProperties, {}] [19Jan2022 19:38:56.600] [Render thread/INFO] [com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService/]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', servicesHost='https://api.minecraftservices.com', name='PROD' [19Jan2022 19:38:57.885] [Render thread/ERROR] [net.minecraft.client.Minecraft/]: Failed to verify authentication com.mojang.authlib.exceptions.AuthenticationUnavailableException: null at com.mojang.authlib.yggdrasil.YggdrasilSocialInteractionsService.checkPrivileges(YggdrasilSocialInteractionsService.java:97) ~[authlib-2.1.28.jar:?] at com.mojang.authlib.yggdrasil.YggdrasilSocialInteractionsService.<init>(YggdrasilSocialInteractionsService.java:40) ~[authlib-2.1.28.jar:?] at com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService.createSocialInteractionsService(YggdrasilAuthenticationService.java:152) ~[authlib-2.1.28.jar:?] at net.minecraft.client.Minecraft.createSocialInteractions(Minecraft.java:551) ~[forge-1.16.5-36.2.20_mapped_official_1.16.5.jar:?] at net.minecraft.client.Minecraft.<init>(Minecraft.java:383) ~[forge-1.16.5-36.2.20_mapped_official_1.16.5.jar:?] at net.minecraft.client.main.Main.main(Main.java:149) ~[forge-1.16.5-36.2.20_mapped_official_1.16.5.jar:?] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[?:?] at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?] at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:52) ~[forge-1.16.5-36.2.20_mapped_official_1.16.5.jar:?] at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.0.9.jar:?] at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.0.9.jar:?] at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.0.9.jar:?] at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.0.9.jar:?] at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.0.9.jar:?] at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:108) [forge-1.16.5-36.2.20_mapped_official_1.16.5.jar:?] [19Jan2022 19:38:57.903] [Render thread/INFO] [net.minecraft.client.Minecraft/]: Setting user: Dev [19Jan2022 19:38:58.300] [Render thread/INFO] [net.minecraft.client.Minecraft/]: Backend library: LWJGL version 3.2.2 build 10 [19Jan2022 19:39:00.295] [modloading-worker-2/INFO] [net.minecraftforge.common.ForgeMod/FORGEMOD]: Forge mod loading, version 36.2.20, for MC 1.16.5 with MCP 20210115.111550 [19Jan2022 19:39:00.302] [modloading-worker-2/INFO] [net.minecraftforge.common.MinecraftForge/FORGE]: MinecraftForge v36.2.20 Initialized [19Jan2022 19:39:05.738] [Render thread/INFO] [com.mojang.text2speech.NarratorWindows/]: Narrator library for x64 successfully loaded [19Jan2022 19:39:05.961] [Render thread/INFO] [net.minecraft.resources.SimpleReloadableResourceManager/]: Reloading ResourceManager: Default, Mod Resources [19Jan2022 19:39:06.499] [Forge Version Check/INFO] [net.minecraftforge.fml.VersionChecker/]: [forge] Starting version check at https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json [19Jan2022 19:39:07.319] [Forge Version Check/INFO] [net.minecraftforge.fml.VersionChecker/]: [forge] Found status: UP_TO_DATE Current: 36.2.20 Target: null [19Jan2022 19:39:23.497] [Worker-Main-11/WARN] [net.minecraft.client.renderer.model.ModelBakery/]: Unable to load model: 'multiverse:dimension_slasher#inventory' referenced from: multiverse:dimension_slasher#inventory: java.io.FileNotFoundException: multiverse:models/item/dimension_slasher.json [19Jan2022 19:39:29.402] [Render thread/INFO] [net.minecraft.client.audio.SoundSystem/]: OpenAL initialized. [19Jan2022 19:39:29.403] [Render thread/INFO] [net.minecraft.client.audio.SoundEngine/SOUNDS]: Sound engine started [19Jan2022 19:39:30.198] [Render thread/INFO] [net.minecraft.client.renderer.texture.AtlasTexture/]: Created: 1024x512x4 minecraft:textures/atlas/blocks.png-atlas [19Jan2022 19:39:30.419] [Render thread/INFO] [net.minecraft.client.renderer.texture.AtlasTexture/]: Created: 256x128x4 minecraft:textures/atlas/signs.png-atlas [19Jan2022 19:39:30.421] [Render thread/INFO] [net.minecraft.client.renderer.texture.AtlasTexture/]: Created: 512x512x4 minecraft:textures/atlas/banner_patterns.png-atlas [19Jan2022 19:39:30.431] [Render thread/INFO] [net.minecraft.client.renderer.texture.AtlasTexture/]: Created: 512x512x4 minecraft:textures/atlas/shield_patterns.png-atlas [19Jan2022 19:39:30.443] [Render thread/INFO] [net.minecraft.client.renderer.texture.AtlasTexture/]: Created: 256x256x4 minecraft:textures/atlas/chest.png-atlas [19Jan2022 19:39:30.446] [Render thread/INFO] [net.minecraft.client.renderer.texture.AtlasTexture/]: Created: 512x256x4 minecraft:textures/atlas/beds.png-atlas [19Jan2022 19:39:30.451] [Render thread/INFO] [net.minecraft.client.renderer.texture.AtlasTexture/]: Created: 512x256x4 minecraft:textures/atlas/shulker_boxes.png-atlas [19Jan2022 19:39:32.221] [Render thread/INFO] [net.minecraft.client.renderer.texture.AtlasTexture/]: Created: 256x256x0 minecraft:textures/atlas/particles.png-atlas [19Jan2022 19:39:32.274] [Render thread/INFO] [net.minecraft.client.renderer.texture.AtlasTexture/]: Created: 256x256x0 minecraft:textures/atlas/paintings.png-atlas [19Jan2022 19:39:32.279] [Render thread/INFO] [net.minecraft.client.renderer.texture.AtlasTexture/]: Created: 128x128x0 minecraft:textures/atlas/mob_effects.png-atlas [19Jan2022 19:39:33.070] [Realms Notification Availability checker #1/INFO] [com.mojang.realmsclient.client.RealmsClient/]: Could not authorize you against Realms server: Invalid session id [19Jan2022 19:54:25.061] [Render thread/INFO] [net.minecraft.world.storage.SaveFormat/]: Attempt 1... [19Jan2022 19:54:28.360] [Render thread/WARN] [net.minecraft.command.Commands/]: Ambiguity between arguments [teleport, destination] and [teleport, targets] with inputs: [Player, 0123, @e, dd12be42-52a9-4a91-a8a1-11c01849e498] [19Jan2022 19:54:28.361] [Render thread/WARN] [net.minecraft.command.Commands/]: Ambiguity between arguments [teleport, location] and [teleport, destination] with inputs: [0.1 -0.5 .9, 0 0 0] [19Jan2022 19:54:28.362] [Render thread/WARN] [net.minecraft.command.Commands/]: Ambiguity between arguments [teleport, location] and [teleport, targets] with inputs: [0.1 -0.5 .9, 0 0 0] [19Jan2022 19:54:28.363] [Render thread/WARN] [net.minecraft.command.Commands/]: Ambiguity between arguments [teleport, targets] and [teleport, destination] with inputs: [Player, 0123, dd12be42-52a9-4a91-a8a1-11c01849e498] [19Jan2022 19:54:28.364] [Render thread/WARN] [net.minecraft.command.Commands/]: Ambiguity between arguments [teleport, targets, location] and [teleport, targets, destination] with inputs: [0.1 -0.5 .9, 0 0 0] [19Jan2022 19:54:28.370] [Render thread/INFO] [net.minecraft.resources.SimpleReloadableResourceManager/]: Reloading ResourceManager: Default, main, forge-1.16.5-36.2.20_mapped_official_1.16.5.jar [19Jan2022 19:54:29.923] [Render thread/INFO] [net.minecraft.item.crafting.RecipeManager/]: Loaded 7 recipes [19Jan2022 19:54:30.966] [Render thread/INFO] [net.minecraft.advancements.AdvancementList/]: Loaded 927 advancements [19Jan2022 19:54:31.653] [Render thread/INFO] [com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService/]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', servicesHost='https://api.minecraftservices.com', name='PROD' [19Jan2022 19:54:31.725] [Server thread/INFO] [net.minecraft.server.integrated.IntegratedServer/]: Starting integrated minecraft server version 1.16.5 [19Jan2022 19:54:31.726] [Server thread/INFO] [net.minecraft.server.MinecraftServer/]: Generating keypair [19Jan2022 19:54:31.809] [Server thread/WARN] [net.minecraftforge.common.ForgeConfigSpec/CORE]: Configuration file .\saves\New World\serverconfig\multiverse-server.toml is not correct. Correcting [19Jan2022 19:54:31.812] [Server thread/WARN] [net.minecraftforge.common.ForgeConfigSpec/CORE]: Incorrect key Server config for Multiverse mod was corrected from null to its default, SimpleCommentedConfig:{}. [19Jan2022 19:54:31.813] [Server thread/WARN] [net.minecraftforge.common.ForgeConfigSpec/CORE]: Incorrect key Server config for Multiverse mod.maxDimensions was corrected from null to its default, 25. [19Jan2022 19:54:31.814] [Server thread/WARN] [net.minecraftforge.common.ForgeConfigSpec/CORE]: Incorrect key Server config for Multiverse mod.biomeTypeChance was corrected from null to its default, 0.1. [19Jan2022 19:54:31.815] [Server thread/WARN] [net.minecraftforge.common.ForgeConfigSpec/CORE]: Incorrect key Server config for Multiverse mod.fixedTimeChance was corrected from null to its default, 0.25. [19Jan2022 19:54:31.816] [Server thread/WARN] [net.minecraftforge.common.ForgeConfigSpec/CORE]: Incorrect key Server config for Multiverse mod.inverse was corrected from null to its default, false. [19Jan2022 19:54:31.816] [Server thread/WARN] [net.minecraftforge.common.ForgeConfigSpec/CORE]: Incorrect key Server config for Multiverse mod.riftChance was corrected from null to its default, 20. [19Jan2022 19:54:31.822] [Server thread/WARN] [net.minecraftforge.common.ForgeConfigSpec/CORE]: Configuration file .\saves\New World\serverconfig\forge-server.toml is not correct. Correcting [19Jan2022 19:54:31.823] [Server thread/WARN] [net.minecraftforge.common.ForgeConfigSpec/CORE]: Incorrect key server was corrected from null to its default, SimpleCommentedConfig:{}. [19Jan2022 19:54:31.823] [Server thread/WARN] [net.minecraftforge.common.ForgeConfigSpec/CORE]: Incorrect key server.removeErroringEntities was corrected from null to its default, false. [19Jan2022 19:54:31.823] [Server thread/WARN] [net.minecraftforge.common.ForgeConfigSpec/CORE]: Incorrect key server.removeErroringTileEntities was corrected from null to its default, false. [19Jan2022 19:54:31.824] [Server thread/WARN] [net.minecraftforge.common.ForgeConfigSpec/CORE]: Incorrect key server.fullBoundingBoxLadders was corrected from null to its default, false. [19Jan2022 19:54:31.824] [Server thread/WARN] [net.minecraftforge.common.ForgeConfigSpec/CORE]: Incorrect key server.zombieBaseSummonChance was corrected from null to its default, 0.1. [19Jan2022 19:54:31.825] [Server thread/WARN] [net.minecraftforge.common.ForgeConfigSpec/CORE]: Incorrect key server.zombieBabyChance was corrected from null to its default, 0.05. [19Jan2022 19:54:31.825] [Server thread/WARN] [net.minecraftforge.common.ForgeConfigSpec/CORE]: Incorrect key server.logCascadingWorldGeneration was corrected from null to its default, true. [19Jan2022 19:54:31.826] [Server thread/WARN] [net.minecraftforge.common.ForgeConfigSpec/CORE]: Incorrect key server.fixVanillaCascading was corrected from null to its default, false. [19Jan2022 19:54:31.828] [Server thread/WARN] [net.minecraftforge.common.ForgeConfigSpec/CORE]: Incorrect key server.dimensionUnloadQueueDelay was corrected from null to its default, 0. [19Jan2022 19:54:31.829] [Server thread/WARN] [net.minecraftforge.common.ForgeConfigSpec/CORE]: Incorrect key server.treatEmptyTagsAsAir was corrected from null to its default, false. [19Jan2022 19:54:31.830] [Server thread/WARN] [net.minecraftforge.common.ForgeConfigSpec/CORE]: Incorrect key server.fixAdvancementLoading was corrected from null to its default, true. [19Jan2022 19:54:35.808] [Server thread/INFO] [net.minecraft.server.MinecraftServer/]: Preparing start region for dimension minecraft:overworld [19Jan2022 19:54:36.159] [Render thread/INFO] [net.minecraft.world.chunk.listener.LoggingChunkStatusListener/]: Preparing spawn area: 0% [19Jan2022 19:54:36.359] [Render thread/INFO] [net.minecraft.world.chunk.listener.LoggingChunkStatusListener/]: Preparing spawn area: 0% [19Jan2022 19:54:36.858] [Render thread/INFO] [net.minecraft.world.chunk.listener.LoggingChunkStatusListener/]: Preparing spawn area: 0% [19Jan2022 19:54:37.341] [Render thread/INFO] [net.minecraft.world.chunk.listener.LoggingChunkStatusListener/]: Preparing spawn area: 0% I'm really confused as to what I changed to cause this. The versions before did not have this issue, but it appeared after the latest commit. 
    • thank you it worked, but 2 things, tell me where i have tu pubish my posts, i publish them in modder support isnt that right?   and Diesieben how do you quickly find how to solve modding errors, i can do it but if i create my own program or something but im minecraft modding, what goes through your mind to solve those problems? for example i still cant solve my problem with drawing correctly a glowing line even if i look the minecraft classes  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.