Jump to content

ChaoticSoul

Members
  • Posts

    28
  • Joined

  • Last visited

Everything posted by ChaoticSoul

  1. One of my mob's projectiles causes a crash but not every time it shoots. can someone tell me the cause and how to fix? https://pastebin.com/DNbHryF1 ^projectile https://pastebin.com/zsST527J ^error
  2. Thanks! Works perfectly now.
  3. Thanks, but the attacker now takes the damage and the mob does not take any damage. How do I change this? https://pastebin.com/jX8NZV0x ^code
  4. How would I go about making my mob deal damage back to the attacker when hit.
  5. is it not being called in the onUpdate method?
  6. Code: package com.ChaoticSoul.MoreArmor.entity; import java.util.List; import java.util.UUID; import javax.annotation.Nullable; import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.IProjectile; import net.minecraft.init.MobEffects; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.PotionEffect; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class EntityVenom extends Entity implements IProjectile { public EntityCobra owner; private NBTTagCompound ownerNbt; private EntityLivingBase living; public EntityVenom(World worldIn) { super(worldIn); } public EntityVenom(World worldIn, EntityCobra p_i47273_2_) { super(worldIn); this.owner = p_i47273_2_; this.setPosition(p_i47273_2_.posX - (double)(p_i47273_2_.width + 1.0F) * 0.5D * (double)MathHelper.sin(p_i47273_2_.renderYawOffset * 0.017453292F), p_i47273_2_.posY + (double)p_i47273_2_.getEyeHeight() - 0.10000000149011612D, p_i47273_2_.posZ + (double)(p_i47273_2_.width + 1.0F) * 0.5D * (double)MathHelper.cos(p_i47273_2_.renderYawOffset * 0.017453292F)); this.setSize(0.25F, 0.25F); } @SideOnly(Side.CLIENT) public EntityVenom(World worldIn, double x, double y, double z, double p_i47274_8_, double p_i47274_10_, double p_i47274_12_) { super(worldIn); this.setPosition(x, y, z); for (int i = 0; i < 7; ++i) { double d0 = 0.4D + 0.1D * (double)i; worldIn.spawnParticle(EnumParticleTypes.SPIT, x, y, z, p_i47274_8_ * d0, p_i47274_10_, p_i47274_12_ * d0); } this.motionX = p_i47274_8_; this.motionY = p_i47274_10_; this.motionZ = p_i47274_12_; } /** * Called to update the entity's position/logic. */ public void onUpdate() { super.onUpdate(); if (this.ownerNbt != null) { this.restoreOwnerFromSave(); } 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); 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 = this.getHitEntity(vec3d, vec3d1); if (entity != null) { raytraceresult = new RayTraceResult(entity); } if (raytraceresult != null && !net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, raytraceresult)) { this.onHit(raytraceresult, living); } this.posX += this.motionX; this.posY += this.motionY; this.posZ += this.motionZ; 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; float f1 = 0.99F; float f2 = 0.06F; if (!this.world.isMaterialInBB(this.getEntityBoundingBox(), Material.AIR)) { this.setDead(); } else if (this.isInWater()) { this.setDead(); } else { this.motionX *= 0.9900000095367432D; this.motionY *= 0.9900000095367432D; this.motionZ *= 0.9900000095367432D; if (!this.hasNoGravity()) { this.motionY -= 0.05999999865889549D; } this.setPosition(this.posX, this.posY, this.posZ); } } /** * Updates the entity motion clientside, called by packets from the server */ @SideOnly(Side.CLIENT) public void setVelocity(double x, double y, double z) { this.motionX = x; this.motionY = y; this.motionZ = z; if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { float f = MathHelper.sqrt(x * x + z * z); this.rotationPitch = (float)(MathHelper.atan2(y, (double)f) * (180D / Math.PI)); this.rotationYaw = (float)(MathHelper.atan2(x, z) * (180D / Math.PI)); this.prevRotationPitch = this.rotationPitch; this.prevRotationYaw = this.rotationYaw; this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch); } } @Nullable private Entity getHitEntity(Vec3d p_190538_1_, Vec3d p_190538_2_) { 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 (entity1 != this.owner) { AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().grow(0.30000001192092896D); RayTraceResult raytraceresult = axisalignedbb.calculateIntercept(p_190538_1_, p_190538_2_); if (raytraceresult != null) { double d1 = p_190538_1_.squareDistanceTo(raytraceresult.hitVec); if (d1 < d0 || d0 == 0.0D) { entity = entity1; d0 = d1; } } } } return entity; } /** * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction. */ public void shoot(double x, double y, double z, float velocity, float inaccuracy) { float f = MathHelper.sqrt(x * x + y * y + z * z); x = x / (double)f; y = y / (double)f; z = z / (double)f; x = x + this.rand.nextGaussian() * 0.007499999832361937D * (double)inaccuracy; y = y + this.rand.nextGaussian() * 0.007499999832361937D * (double)inaccuracy; z = z + this.rand.nextGaussian() * 0.007499999832361937D * (double)inaccuracy; x = x * (double)velocity; y = y * (double)velocity; z = z * (double)velocity; this.motionX = x; this.motionY = y; this.motionZ = z; float f1 = MathHelper.sqrt(x * x + z * z); this.rotationYaw = (float)(MathHelper.atan2(x, z) * (180D / Math.PI)); this.rotationPitch = (float)(MathHelper.atan2(y, (double)f1) * (180D / Math.PI)); this.prevRotationYaw = this.rotationYaw; this.prevRotationPitch = this.rotationPitch; } public void onHit(RayTraceResult p_190536_1_, EntityLivingBase living) { if (p_190536_1_.entityHit != null && this.owner != null) { p_190536_1_.entityHit.attackEntityFrom(DamageSource.causeIndirectDamage(this, this.owner).setProjectile(), 4.0F); PotionEffect potion = new PotionEffect(MobEffects.POISON, 100, 4); living.addPotionEffect(potion); } if (!this.world.isRemote) { this.setDead(); } } protected void entityInit() { } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ protected void readEntityFromNBT(NBTTagCompound compound) { if (compound.hasKey("Owner", 10)) { this.ownerNbt = compound.getCompoundTag("Owner"); } } /** * (abstract) Protected helper method to write subclass entity data to NBT. */ protected void writeEntityToNBT(NBTTagCompound compound) { if (this.owner != null) { NBTTagCompound nbttagcompound = new NBTTagCompound(); UUID uuid = this.owner.getUniqueID(); nbttagcompound.setUniqueId("OwnerUUID", uuid); compound.setTag("Owner", nbttagcompound); } } private void restoreOwnerFromSave() { if (this.ownerNbt != null && this.ownerNbt.hasUniqueId("OwnerUUID")) { UUID uuid = this.ownerNbt.getUniqueId("OwnerUUID"); for (EntityCobra entitycobra : this.world.getEntitiesWithinAABB(EntityCobra.class, this.getEntityBoundingBox().grow(15.0D))) { if (entitycobra.getUniqueID().equals(uuid)) { this.owner = entitycobra; break; } } } this.ownerNbt = null; } } When it shoots the game crashes, error: https://pastebin.com/gnbJppKL
  7. that did not help and I am new to programming mods so do not know how to do everything by myself so am using what is in Minecraft.
  8. https://pastebin.com/Yj00WMsH ^projectile code I just changed the code from EntityLlamaSpit (I have not attempted to add the potion effect here as I am unsure how to)
  9. I don't know how I would do this though.
  10. still does not work https://pastebin.com/iQwGRLdj
  11. I made my entity shoot projectiles and I want the projectile to give poison when it hits. https://pastebin.com/AN9qYw2w ^code
  12. error: https://pastebin.com/5G7Ez1Y9 no crash but it does not spawn
  13. the entity now does not spawn https://pastebin.com/VqNzdBeZ ^EntityPegasus https://pastebin.com/F3dZivKY ^EntityAIAttackRangedBow clone
  14. I get this error: "Bound mismatch: The type EntityPegasus is not a valid substitute for the bounded parameter <T extends EntityMob & IRangedAttackMob> of the type EntityAIAttackRangedBow<T>" https://pastebin.com/aRhGjMZ3 ^code
  15. How would I alter this for it to work with my mob?
  16. How do I call the AI that the skeleton has to stay away from the player for a mob that I am making?
  17. I have made it so I can mount on the mob but I am unable to control it when I do, package com.ChaoticSoul.MoreArmor.entity; import java.util.Set; import com.ChaoticSoul.MoreArmor.init.ModItems; import com.google.common.collect.Sets; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.IRangedAttackMob; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIAttackRanged; import net.minecraft.entity.ai.EntityAIFollow; import net.minecraft.entity.ai.EntityAIFollowOwnerFlying; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; import net.minecraft.entity.ai.EntityAISit; import net.minecraft.entity.ai.EntityAIWanderAvoidWater; import net.minecraft.entity.ai.EntityAIWatchClosest; import net.minecraft.entity.monster.IMob; import net.minecraft.entity.passive.EntityParrot; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityTippedArrow; import net.minecraft.init.Items; import net.minecraft.init.MobEffects; import net.minecraft.init.SoundEvents; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumHand; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; public class EntityPegasus extends EntityParrot implements IRangedAttackMob{ public EntityPegasus(World worldIn) { super(worldIn); } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(20.0D); this.getEntityAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(6); this.getEntityAttribute(SharedMonsterAttributes.FLYING_SPEED).setBaseValue(10.0D); this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.20000000298023224D); } protected void initEntityAI() { this.tasks.addTask(1, new EntityAIFollowOwnerFlying(this, 1.0D, 5.0F, 1.0F)); this.tasks.addTask(1, new EntityAISit(this)); this.tasks.addTask(1, new EntityAIAttackRanged(this, 1.25D, 10, 10.0F)); this.tasks.addTask(2, new EntityAIWanderAvoidWater(this, 1.0D, 1.0000001E-5F)); this.tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); this.tasks.addTask(4, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityLiving.class, 10, true, false, IMob.MOB_SELECTOR)); this.tasks.addTask(1, new EntityAIFollow(this, 1.0D, 3.0F, 7.0F)); } @Override public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) { EntityTippedArrow entitytippedarrow = new EntityTippedArrow(this.world, this); double d0 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D; double d1 = target.posX - this.posX; double d2 = d0 - entitytippedarrow.posY; double d3 = target.posZ - this.posZ; float f = MathHelper.sqrt(d1 * d1 + d3 * d3) * 0.2F; entitytippedarrow.shoot(d1, d2 + (double)f, d3, 1.6F, 12.0F); this.playSound(SoundEvents.ENTITY_SNOWMAN_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); this.world.spawnEntity(entitytippedarrow); PotionEffect potion = new PotionEffect(Potion.getPotionById(2), 100, 2); if(target.hitByEntity(entitytippedarrow)==true) { target.addPotionEffect(potion); } EntityTippedArrow entitytippedarrow2 = new EntityTippedArrow(this.world, this); double d4 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D; double d5 = target.posX - this.posX; double d6 = d4 - entitytippedarrow2.posY; double d7 = target.posZ - this.posZ; float f2 = MathHelper.sqrt(d1 * d1 + d3 * d3) * 0.2F; entitytippedarrow2.shoot(d1, d2 + (double)f, d3, 1.6F, 12.0F); this.playSound(SoundEvents.ENTITY_SNOWMAN_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); this.world.spawnEntity(entitytippedarrow2); PotionEffect potion2 = new PotionEffect(Potion.getPotionById(2), 100, 2); if(target.hitByEntity(entitytippedarrow2)==true) { target.addPotionEffect(potion2); } EntityTippedArrow entitytippedarrow3 = new EntityTippedArrow(this.world, this); double d8 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D; double d9 = target.posX - this.posX; double d10 = d4 - entitytippedarrow3.posY; double d11 = target.posZ - this.posZ; float f3 = MathHelper.sqrt(d1 * d1 + d3 * d3) * 0.2F; entitytippedarrow3.shoot(d1, d2 + (double)f, d3, 1.6F, 12.0F); this.playSound(SoundEvents.ENTITY_SNOWMAN_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); this.world.spawnEntity(entitytippedarrow3); PotionEffect potion3 = new PotionEffect(Potion.getPotionById(2), 100, 2); if(target.hitByEntity(entitytippedarrow3)==true) { target.addPotionEffect(potion3); } } @Override public void setSwingingArms(boolean swingingArms) { // TODO Auto-generated method stub } protected void mountTo(EntityPlayer player) { player.rotationYaw = this.rotationYaw; player.rotationPitch = this.rotationPitch; if (!this.world.isRemote) { player.startRiding(this); } } private static final Set<Item> TAME_ITEMS = Sets.newHashSet(ModItems.SAPPHIRE); private static final Item DEADLY_ITEM = ModItems.ANTI_PET_CHARM; @Override public boolean processInteract(EntityPlayer player, EnumHand hand) { { ItemStack itemstack = player.getHeldItem(hand); if (!this.isTamed() && TAME_ITEMS.contains(itemstack.getItem())) { if (!player.capabilities.isCreativeMode) { itemstack.shrink(1); } if (!this.isSilent()) { this.world.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_PARROT_EAT, this.getSoundCategory(), 1.0F, 1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F); } if (!this.world.isRemote) { if (this.rand.nextInt(10) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, player)) { this.setTamedBy(player); this.playTameEffect(true); this.world.setEntityState(this, (byte)7); } else { this.playTameEffect(false); this.world.setEntityState(this, (byte)6); } } return true; } else if (itemstack.getItem() == DEADLY_ITEM) { if (!player.capabilities.isCreativeMode) { itemstack.shrink(1); } this.addPotionEffect(new PotionEffect(MobEffects.POISON, 900)); if (player.isCreative() || !this.getIsInvulnerable()) { this.attackEntityFrom(DamageSource.causePlayerDamage(player), Float.MAX_VALUE); } return true; } else { if(this.isTamed()==true) { this.mountTo(player); return true; } else { return super.processInteract(player, hand); } } } }} PS: I also want the player to be able to fly when riding this mob.
  18. Oh, where am I meant to use it and how
  19. I made an entity that extends EntityParrot and am trying to set its tame items but when I do, It still has to be tamed using seeds. Can someone tell me what I am doing wrong? https://pastebin.com/cm53z8ke
  20. 1. the only tutorial I was able to find said to do it using getHeldItem 2. I am unsure how to use EntityEntryBuilder 3. can you tell me where each problematic code issue was
  21. I have made a bow tool class but I do not know how to make the damage that the bow does depend on the tool material.
  22. https://pastebin.com/wbMVRpPK ^renderer
  23. https://pastebin.com/5Es4TPzh ^Entity Class https://pastebin.com/5qF3Fua3 ^Entity Init https://pastebin.com/fVkBf1NR ^Render Handler https://pastebin.com/g8acqwuc ^Registry Handler Let me know if you need anything else
×
×
  • Create New...

Important Information

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