- 117
- 7
Создал новый entity (сильно порезанный FishHook). При запуске игры вылетает такая ошибка в крашлоге:
Could not find constructor 'EntitySmokersTongue(net.minecraft.world.World)' in class ru.mark0wka.left4zombies.entity.EntitySmokersTongue
Но в классе же есть этот конструктор. Или я опять что-то не понял?
Could not find constructor 'EntitySmokersTongue(net.minecraft.world.World)' in class ru.mark0wka.left4zombies.entity.EntitySmokersTongue
Но в классе же есть этот конструктор. Или я опять что-то не понял?
Код:
public class EntitySmokersTongue extends Entity
{
private static final DataParameter<Integer> DATA_HOOKED_ENTITY = EntityDataManager.<Integer>createKey(EntitySmokersTongue.class, DataSerializers.VARINT);
private boolean inGround;
private int ticksInGround;
private EntitySmoker angler;
private int ticksInAir;
private int ticksCatchable;
private int ticksCaughtDelay;
private int ticksCatchableDelay;
private float fishApproachAngle;
public Entity caughtEntity;
private EntitySmokersTongue.State currentState = EntitySmokersTongue.State.FLYING;
private int luck;
private int lureSpeed;
@SideOnly(Side.CLIENT)
public EntitySmokersTongue(World worldIn, EntitySmoker smoker, double x, double y, double z)
{
super(worldIn);
this.init(smoker);
this.setPosition(x, y, z);
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
}
public EntitySmokersTongue(World worldIn, EntitySmoker fishingPlayer)
{
super(worldIn);
this.init(fishingPlayer);
this.shoot();
}
private void init(EntitySmoker smoker)
{
this.setSize(0.25F, 0.25F);
this.ignoreFrustumCheck = true;
this.angler = smoker;
//this.angler.fishEntity = this;
}
public void setLureSpeed(int p_191516_1_)
{
this.lureSpeed = p_191516_1_;
}
public void setLuck(int p_191517_1_)
{
this.luck = p_191517_1_;
}
public void shoot()
{
float f = this.angler.prevRotationPitch + (this.angler.rotationPitch - this.angler.prevRotationPitch);
float f1 = this.angler.prevRotationYaw + (this.angler.rotationYaw - this.angler.prevRotationYaw);
float f2 = MathHelper.cos(-f1 * 0.017453292F - (float)Math.PI);
float f3 = MathHelper.sin(-f1 * 0.017453292F - (float)Math.PI);
float f4 = -MathHelper.cos(-f * 0.017453292F);
float f5 = MathHelper.sin(-f * 0.017453292F);
double d0 = this.angler.prevPosX + (this.angler.posX - this.angler.prevPosX) - (double)f3 * 0.3D;
double d1 = this.angler.prevPosY + (this.angler.posY - this.angler.prevPosY) + (double)this.angler.getEyeHeight();
double d2 = this.angler.prevPosZ + (this.angler.posZ - this.angler.prevPosZ) - (double)f2 * 0.3D;
this.setLocationAndAngles(d0, d1, d2, f1, f);
this.motionX = (double)(-f3);
this.motionY = (double)MathHelper.clamp(-(f5 / f4), -5.0F, 5.0F);
this.motionZ = (double)(-f2);
float f6 = MathHelper.sqrt(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
this.motionX *= 0.6D / (double)f6 + 0.5D + this.rand.nextGaussian() * 0.0045D;
this.motionY *= 0.6D / (double)f6 + 0.5D + this.rand.nextGaussian() * 0.0045D;
this.motionZ *= 0.6D / (double)f6 + 0.5D + this.rand.nextGaussian() * 0.0045D;
float f7 = MathHelper.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationYaw = (float)(MathHelper.atan2(this.motionX, this.motionZ) * (180D / Math.PI));
this.rotationPitch = (float)(MathHelper.atan2(this.motionY, (double)f7) * (180D / Math.PI));
this.prevRotationYaw = this.rotationYaw;
this.prevRotationPitch = this.rotationPitch;
}
protected void entityInit()
{
this.getDataManager().register(DATA_HOOKED_ENTITY, Integer.valueOf(0));
}
public void notifyDataManagerChange(DataParameter<?> key)
{
if (DATA_HOOKED_ENTITY.equals(key))
{
int i = ((Integer)this.getDataManager().get(DATA_HOOKED_ENTITY)).intValue();
this.caughtEntity = i > 0 ? this.world.getEntityByID(i - 1) : null;
}
super.notifyDataManagerChange(key);
}
/**
* Checks if the entity is in range to render.
*/
@SideOnly(Side.CLIENT)
public boolean isInRangeToRenderDist(double distance)
{
double d0 = 64.0D;
return distance < 4096.0D;
}
/**
* Set the position and rotation values directly without any clamping.
*/
@SideOnly(Side.CLIENT)
public void setPositionAndRotationDirect(double x, double y, double z, float yaw, float pitch, int posRotationIncrements, boolean teleport)
{
}
public void onUpdate()
{
super.onUpdate();
if (this.angler == null)
{
this.setDead();
}
else if (this.world.isRemote || !this.shouldStopFishing())
{
if (this.inGround)
{
++this.ticksInGround;
if (this.ticksInGround >= 1200)
{
this.setDead();
return;
}
}
float f = 0.0F;
BlockPos blockpos = new BlockPos(this);
IBlockState iblockstate = this.world.getBlockState(blockpos);
if (iblockstate.getMaterial() == Material.WATER)
{
f = BlockLiquid.getBlockLiquidHeight(iblockstate, this.world, blockpos);
}
if (this.currentState == EntitySmokersTongue.State.FLYING)
{
if (this.caughtEntity != null)
{
this.motionX = 0.0D;
this.motionY = 0.0D;
this.motionZ = 0.0D;
this.currentState = EntitySmokersTongue.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 == EntitySmokersTongue.State.HOOKED_IN_ENTITY)
{
if (this.caughtEntity != null)
{
if (this.caughtEntity.isDead)
{
this.caughtEntity = null;
this.currentState = EntitySmokersTongue.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;
}
}
if (iblockstate.getMaterial() != Material.WATER)
{
this.motionY -= 0.03D;
}
this.move(MoverType.SELF, this.motionX, this.motionY, this.motionZ);
this.updateRotation();
double d1 = 0.92D;
this.motionX *= 0.92D;
this.motionY *= 0.92D;
this.motionZ *= 0.92D;
this.setPosition(this.posX, this.posY, this.posZ);
}
}
private boolean shouldStopFishing()
{
ItemStack itemstack = this.angler.getHeldItemMainhand();
ItemStack itemstack1 = this.angler.getHeldItemOffhand();
boolean flag = itemstack.getItem() instanceof net.minecraft.item.ItemFishingRod;
boolean flag1 = itemstack1.getItem() instanceof net.minecraft.item.ItemFishingRod;
if (!this.angler.isDead && this.angler.isEntityAlive() && (flag || flag1) && this.getDistanceSq(this.angler) <= 1024.0D)
{
return false;
}
else
{
this.setDead();
return true;
}
}
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;
}
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);
}
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;
for (Entity entity1 : list)
{
if (this.canBeHooked(entity1) && (entity1 != this.angler || this.ticksInAir >= 5))
{
AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().grow(0.30000001192092896D);
RayTraceResult raytraceresult1 = axisalignedbb.calculateIntercept(vec3d, vec3d1);
if (raytraceresult1 != null)
{
double d1 = vec3d.squareDistanceTo(raytraceresult1.hitVec);
if (d1 < d0 || d0 == 0.0D)
{
entity = entity1;
d0 = d1;
}
}
}
}
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;
}
}
}
private void setHookedEntity()
{
this.getDataManager().set(DATA_HOOKED_ENTITY, Integer.valueOf(this.caughtEntity.getEntityId() + 1));
}
protected boolean canBeHooked(Entity p_189739_1_)
{
return p_189739_1_.canBeCollidedWith() || p_189739_1_ instanceof EntityItem;
}
public void writeEntityToNBT(NBTTagCompound compound)
{
}
public void readEntityFromNBT(NBTTagCompound compound)
{
}
public int handleHookRetraction()
{
if (!this.world.isRemote && this.angler != null)
{
int i = 0;
net.minecraftforge.event.entity.player.ItemFishedEvent event = null;
if (this.caughtEntity != null)
{
this.bringInHookedEntity();
this.world.setEntityState(this, (byte)31);
i = this.caughtEntity instanceof EntityItem ? 3 : 5;
}
if (this.inGround)
{
i = 2;
}
this.setDead();
return event == null ? i : event.getRodDamage();
}
else
{
return 0;
}
}
@SideOnly(Side.CLIENT)
public void handleStatusUpdate(byte id)
{
if (id == 31 && this.world.isRemote && this.caughtEntity instanceof EntityPlayer && ((EntityPlayer)this.caughtEntity).isUser())
{
this.bringInHookedEntity();
}
super.handleStatusUpdate(id);
}
protected void bringInHookedEntity()
{
if (this.angler != null)
{
double d0 = this.angler.posX - this.posX;
double d1 = this.angler.posY - this.posY;
double d2 = this.angler.posZ - this.posZ;
double d3 = 0.1D;
this.caughtEntity.motionX += d0 * 0.5D;
this.caughtEntity.motionY += d1 * 0.5D;
this.caughtEntity.motionZ += d2 * 0.5D;
}
}
protected boolean canTriggerWalking()
{
return false;
}
public void setDead()
{
super.setDead();
if (this.angler != null)
{
//this.angler.fishEntity = null;
}
}
public EntitySmoker getAngler()
{
return this.angler;
}
static enum State
{
FLYING,
HOOKED_IN_ENTITY,
}
}