ошибка на сервере

Версия Minecraft
1.12.2
API
Forge
31
1
1
При попадании Entity по игроку вылетает сервер(логический) и сервер (сервер) ,не могу разобраться (

Rocket_Launcher:
public class Rocket_Launcher extends ItemBase {
    public Rocket_Launcher(String name){
        super(name);
        this.setMaxStackSize(1);
    }

    @Override
    public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
    {
        ItemStack item = playerIn.getHeldItem(handIn);
        Vec3d aim = playerIn.getLookVec();

        EntityRocket rocket = new EntityRocket(worldIn,playerIn,1,1,1);

        rocket.setPosition(playerIn.posX + aim.x * 1.50, playerIn.posY  + aim.y * 1.50, playerIn.posZ + aim.z * 1.50);
        rocket.accelerationX = aim.x * 0.1;rocket.accelerationY = aim.y * 0.1;rocket.accelerationZ = aim.z * 0.1;
        worldIn.spawnEntity(rocket);

        item.damageItem(1,playerIn);



        return  new ActionResult<ItemStack>(EnumActionResult.SUCCESS, item);

    }

    }

Код EntityRocket(Энтити ракеты - вылетающее)
EntityRocket:
public class EntityRocket extends EntityRocketSmall
    {
        public int explosionPower = 6;

        public EntityRocket(World worldIn)
        {
            super(worldIn);

        }

        @SideOnly(Side.CLIENT)
        public EntityRocket(World worldIn, double x, double y, double z, double accelX, double accelY, double accelZ)
        {
            super(worldIn, x, y, z, accelX, accelY, accelZ);
        }

        public EntityRocket(World worldIn, EntityLivingBase shooter, double accelX, double accelY, double accelZ)
        {
            super(worldIn, shooter, accelX, accelY, accelZ);
        }

        /**
         * Called when this EntityFireball hits a block or entity.
         */
        protected void onImpact(RayTraceResult result)
        {
            if (!this.world.isRemote)
            {
                if (result.entityHit != null)
                {
                    result.entityHit.attackEntityFrom(DamageSources.causeRocketDamage(this, this.shootingEntity), 6.0F);
                    this.applyEnchantments(this.shootingEntity, result.entityHit);
                }

                boolean flag = this.world.getGameRules().getBoolean("mobGriefing");
                this.world.newExplosion((Entity)null, this.posX, this.posY, this.posZ, (float)this.explosionPower, flag, flag);
                this.setDead();
            }
        }

        public static void registerFixesRocket(DataFixer fixer)
        {
           EntityRocketSmall.registerFixesRocket(fixer, "Rocket");
        }

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

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

            if (compound.hasKey("ExplosionPower", 99))
            {
                this.explosionPower = compound.getInteger("ExplosionPower");
            }
        }
    }

Код EntityRocketSmall ( по-идее тут находится логика для ракеты)
EntityRocketSmall:
public abstract class EntityRocketSmall extends Entity
    {
        public EntityLivingBase shootingEntity;
        private int ticksAlive;
        private int ticksInAir;
        public double accelerationX;
        public double accelerationY;
        public double accelerationZ;

        public EntityRocketSmall(World worldIn)
        {
            super(worldIn);
            this.setSize(1.0F, 1.0F);
        }

        protected void entityInit()
        {
        }

        /**
         * Checks if the entity is in range to render.
         */
        @SideOnly(Side.CLIENT)
        public boolean isInRangeToRenderDist(double distance)
        {
            double d0 = this.getEntityBoundingBox().getAverageEdgeLength() * 4.0D;

            if (Double.isNaN(d0))
            {
                d0 = 4.0D;
            }

            d0 = d0 * 64.0D;
            return distance < d0 * d0;
        }

        public EntityRocketSmall(World worldIn, double x, double y, double z, double accelX, double accelY, double accelZ)
        {
            super(worldIn);
            this.setSize(1.0F, 1.0F);
            this.setLocationAndAngles(x, y, z, this.rotationYaw, this.rotationPitch);
            this.setPosition(x, y, z);
            double d0 = (double) MathHelper.sqrt(accelX * accelX + accelY * accelY + accelZ * accelZ);
            this.accelerationX = accelX / d0 * 0.1D;
            this.accelerationY = accelY / d0 * 0.1D;
            this.accelerationZ = accelZ / d0 * 0.1D;
        }

        public EntityRocketSmall(World worldIn, EntityLivingBase shooter, double accelX, double accelY, double accelZ)
        {
            super(worldIn);
            this.shootingEntity = shooter;
            this.setSize(1.0F, 1.0F);
            this.setLocationAndAngles(shooter.posX, shooter.posY, shooter.posZ, shooter.rotationYaw, shooter.rotationPitch);
            this.setPosition(this.posX, this.posY, this.posZ);
            this.motionX = 0.0D;
            this.motionY = 0.0D;
            this.motionZ = 0.0D;
            accelX = accelX + this.rand.nextGaussian() * 0.4D;
            accelY = accelY + this.rand.nextGaussian() * 0.4D;
            accelZ = accelZ + this.rand.nextGaussian() * 0.4D;
            double d0 = (double)MathHelper.sqrt(accelX * accelX + accelY * accelY + accelZ * accelZ);
            this.accelerationX = accelX / d0 * 0.1D;
            this.accelerationY = accelY / d0 * 0.1D;
            this.accelerationZ = accelZ / d0 * 0.1D;
        }

        /**
         * Called to update the entity's position/logic.
         */
        public void onUpdate()
        {
            if (this.world.isRemote || (this.shootingEntity == null || !this.shootingEntity.isDead) && this.world.isBlockLoaded(new BlockPos(this)))
            {
                super.onUpdate();

                if (this.isRocketFiery())
                {

                }

                ++this.ticksInAir;
                RayTraceResult raytraceresult = ProjectileHelper.forwardsRaycast(this, true, this.ticksInAir >= 25, this.shootingEntity);

                if (raytraceresult != null)
                {
                    this.onImpact(raytraceresult);
                }

                this.posX += this.motionX;
                this.posY += this.motionY;
                this.posZ += this.motionZ;
                ProjectileHelper.rotateTowardsMovement(this, 0.2F);
                float f = this.getMotionFactor();

                if (this.isInWater())
                {
                    for (int i = 0; i < 4; ++i)
                    {
                        float f1 = 0.25F;
                        this.world.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX - this.motionX * 0.25D, this.posY - this.motionY * 0.25D, this.posZ - this.motionZ * 0.25D, this.motionX, this.motionY, this.motionZ);
                    }

                    f = 0.8F;
                }

                this.motionX += this.accelerationX;
                this.motionY += this.accelerationY;
                this.motionZ += this.accelerationZ;
                this.motionX *= (double)f;
                this.motionY *= (double)f;
                this.motionZ *= (double)f;
                this.world.spawnParticle(this.getParticleType(), this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D);
                this.setPosition(this.posX, this.posY, this.posZ);
            }
            else
            {
                this.setDead();
            }
        }

        protected boolean isRocketFiery()
        {
            return true;
        }

        protected EnumParticleTypes getParticleType()
        {
            return EnumParticleTypes.SMOKE_NORMAL;
        }

        /**
         * Return the motion factor for this projectile. The factor is multiplied by the original motion.
         */
        protected float getMotionFactor()
        {
            return 0.95F;
        }

        /**
         * Called when this EntityFireball hits a block or entity.
         */
        protected abstract void onImpact(RayTraceResult result);

        public static void registerFixesRocket(DataFixer fixer, String name)
        {
        }

        /**
         * (abstract) Protected helper method to write subclass entity data to NBT.
         */
        public void writeEntityToNBT(NBTTagCompound compound)
        {
            compound.setTag("direction", this.newDoubleNBTList(new double[] {this.motionX, this.motionY, this.motionZ}));
            compound.setTag("power", this.newDoubleNBTList(new double[] {this.accelerationX, this.accelerationY, this.accelerationZ}));
            compound.setInteger("life", this.ticksAlive);
        }

        /**
         * (abstract) Protected helper method to read subclass entity data from NBT.
         */
        public void readEntityFromNBT(NBTTagCompound compound)
        {
            if (compound.hasKey("power", 9))
            {
                NBTTagList nbttaglist = compound.getTagList("power", 6);

                if (nbttaglist.tagCount() == 3)
                {
                    this.accelerationX = nbttaglist.getDoubleAt(0);
                    this.accelerationY = nbttaglist.getDoubleAt(1);
                    this.accelerationZ = nbttaglist.getDoubleAt(2);
                }
            }

            this.ticksAlive = compound.getInteger("life");

            if (compound.hasKey("direction", 9) && compound.getTagList("direction", 6).tagCount() == 3)
            {
                NBTTagList nbttaglist1 = compound.getTagList("direction", 6);
                this.motionX = nbttaglist1.getDoubleAt(0);
                this.motionY = nbttaglist1.getDoubleAt(1);
                this.motionZ = nbttaglist1.getDoubleAt(2);
            }
            else
            {
                this.setDead();
            }
        }

        /**
         * Returns true if other Entities should be prevented from moving through this Entity.
         */
        public boolean canBeCollidedWith()
        {
            return true;
        }

        public float getCollisionBorderSize()
        {
            return 1.0F;
        }

        /**
         * Called when the entity is attacked.
         */
        public boolean attackEntityFrom(DamageSource source, float amount)
        {
            if (this.isEntityInvulnerable(source))
            {
                return false;
            }
            else
            {
                this.markVelocityChanged();

                if (source.getTrueSource() != null)
                {
                    Vec3d vec3d = source.getTrueSource().getLookVec();

                    if (vec3d != null)
                    {
                        this.motionX = vec3d.x;
                        this.motionY = vec3d.y;
                        this.motionZ = vec3d.z;
                        this.accelerationX = this.motionX * 0.1D;
                        this.accelerationY = this.motionY * 0.1D;
                        this.accelerationZ = this.motionZ * 0.1D;
                    }

                    if (source.getTrueSource() instanceof EntityLivingBase)
                    {
                        this.shootingEntity = (EntityLivingBase)source.getTrueSource();
                    }

                    return true;
                }
                else
                {
                    return false;
                }
            }
        }

        /**
         * Gets how bright this entity is.
         */
        public float getBrightness()
        {
            return 1.0F;
        }

        @SideOnly(Side.CLIENT)
        public int getBrightnessForRender()
        {
            return 15728880;
        }
    }

Код прокси:
Client:

ClientProxy:
public class ClientProxy extends CommonProxy{



    public void registerItemRenderer(Item item , int meta, String id){
           ModelLoader.setCustomModelResourceLocation(item,meta, new ModelResourceLocation(item.getRegistryName(),id));

       }

    @Override
    public void preInit(FMLPreInitializationEvent event) {
        super.preInit(event);

        RenderingRegistry.registerEntityRenderingHandler(EntityRocket.class, new SnowballRenderFactory(initItems.Rocket));
        RenderingRegistry.registerEntityRenderingHandler(EntityBulletak.class,new SnowballRenderFactory(initItems.Bulletak));
        RenderingRegistry.registerEntityRenderingHandler(EntityBulletPistol.class,new SnowballRenderFactory(initItems.BulletPistol));
        RenderingRegistry.registerEntityRenderingHandler(EntityBulletShotgun.class,new SnowballRenderFactory(initItems.BulletShotgun));
    }
}


Common:
CommonProxy:
public class CommonProxy {
   public void registerItemRenderer(Item item, int meta, String id){}

   public void preInit(FMLPreInitializationEvent event) {
      EntityRegistry.registerModEntity(new ResourceLocation("rustmod", "RocketSmall"), EntityRocketSmall.class, "rustmod:RocketSmall", 0, rustmod.instance, 64, 20, true);


      EntityRegistry.registerModEntity(new ResourceLocation("rustmod","Bulletak"), EntityBulletak.class, "rustmod.Bulletak",1, rustmod.instance, 64, 20,true );
      EntityRegistry.registerModEntity(new ResourceLocation("rustmod","BulletPistol"), EntityBulletPistol.class, "rustmod.Bulletak",2, rustmod.instance, 64, 20,true );
      EntityRegistry.registerModEntity(new ResourceLocation("rustmod","BulletShotgun"), EntityBulletShotgun.class, "rustmod.Bulletak",3, rustmod.instance, 64, 20,true );


   }


   public void init(FMLInitializationEvent event) {
   }

   public void postInit(FMLPostInitializationEvent event) {
   }

}


Рендер снежка (нужен для рендера модели)
SnowballRenderFactory:
public class SnowballRenderFactory implements IRenderFactory {
    public final Item item;


    public SnowballRenderFactory(Item item) {
        this.item = item;
    }

    @Override
    public Render createRenderFor(RenderManager manager) {
       
        return new RenderSnowball(manager, item, Minecraft.getMinecraft().getRenderItem());
    }
}
 
Краш-лог
---- Minecraft Crash Report ----
// Who set us up the TNT?

Time: 5/1/21 10:50 PM
Description: Exception in server tick loop

java.lang.IllegalArgumentException: Don't know how to add class com.endienasg.rustmod.Items.bullets.explosive.EntityRocket!
at net.minecraft.entity.EntityTrackerEntry.createSpawnPacket(EntityTrackerEntry.java:681)
at net.minecraft.entity.EntityTrackerEntry.updatePlayerEntity(EntityTrackerEntry.java:399)
at net.minecraft.entity.EntityTrackerEntry.updatePlayerEntities(EntityTrackerEntry.java:509)
at net.minecraft.entity.EntityTrackerEntry.updatePlayerList(EntityTrackerEntry.java:155)
at net.minecraft.entity.EntityTracker.tick(EntityTracker.java:297)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:854)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592)
at java.lang.Thread.run(Thread.java:748)
Краш-лог:
---- Minecraft Crash Report ----
// Who set us up the TNT?

Time: 5/1/21 10:50 PM
Description: Exception in server tick loop

java.lang.IllegalArgumentException: Don't know how to add class com.endienasg.rustmod.Items.bullets.explosive.EntityRocket!
	at net.minecraft.entity.EntityTrackerEntry.createSpawnPacket(EntityTrackerEntry.java:681)
	at net.minecraft.entity.EntityTrackerEntry.updatePlayerEntity(EntityTrackerEntry.java:399)
	at net.minecraft.entity.EntityTrackerEntry.updatePlayerEntities(EntityTrackerEntry.java:509)
	at net.minecraft.entity.EntityTrackerEntry.updatePlayerList(EntityTrackerEntry.java:155)
	at net.minecraft.entity.EntityTracker.tick(EntityTracker.java:297)
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:854)
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743)
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192)
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592)
	at java.lang.Thread.run(Thread.java:748)
Последнее редактирование:
Сверху