Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

ChaoticSoul

Members
  • Joined

  • Last visited

  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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.