Jump to content

captaincleric

Members
  • Posts

    57
  • Joined

  • Last visited

Everything posted by captaincleric

  1. Woops. Looks like I'm doing this wrong, too, though it works just fine when I use it. I'll change it to use addWeatherEffect.
  2. Sorry for the double post, but I'm going to use this thread to log my adventures in case anyone else has the same problem. It seems the entity is taking damage from an "inWall" source, even when they are standing in the middle of an open field. I'm not sure why.
  3. So I've written a custom Entity; nothing special, it just extends EntityTameable, follows the player around and attacks stuff for them. The only difference is that it's summoned from an item, rather than tamed in the traditional way. However, when the user quits, then comes back in, the entity takes damage until it dies. Here's the class in case it's needed: package com.nosrick.masterofmagic.entities; import java.util.UUID; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityAgeable; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.IEntityOwnable; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIAttackOnCollide; import net.minecraft.entity.ai.EntityAIFollowOwner; import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAIOwnerHurtByTarget; import net.minecraft.entity.ai.EntityAIOwnerHurtTarget; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; import net.minecraft.entity.passive.EntityTameable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; public class EntityGuardianSpirit extends EntityTameable implements IEntityOwnable { public EntityGuardianSpirit(World worldIn) { super(worldIn); this.tasks.addTask(1, new EntityAIAttackOnCollide(this, 1.0D, true)); this.tasks.addTask(2, new EntityAIFollowOwner(this, 0.4D, 10.0F, 2.0F)); this.tasks.addTask(3, new EntityAIWander(this, 0.2D)); this.tasks.addTask(4, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(4, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this)); this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this)); this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true, new Class[0])); } @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); // standard attributes registered to EntityLivingBase getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D); getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.80D); getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(0.8D); getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(16.0D); // need to register any additional attributes getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage); getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(6.0D); } @Override public String getOwnerId() { return this.dataWatcher.getWatchableObjectString(17); } @Override public EntityLivingBase getOwner() { UUID uuid = UUID.fromString(this.getOwnerId()); EntityPlayer owner = this.worldObj.getPlayerEntityByUUID(uuid); return owner; } public void setOwnerId(String owner) { this.dataWatcher.updateObject(17, owner); } @Override public EntityAgeable createChild(EntityAgeable ageable) { return null; } }
  4. Fixed it, finally. For those hoping to achieve similar results, try the following: A simple function to find a target: protected MovingObjectPosition FindTarget(EntityPlayer player, World world) { Vec3 playerPosition = new Vec3(player.posX, player.posY + player.getEyeHeight(), player.posZ); Vec3 normalisedLook = player.getLookVec().normalize(); Vec3 targetPosition = new Vec3(playerPosition.xCoord + (normalisedLook.xCoord * DISTANCE), playerPosition.yCoord + player.eyeHeight + (normalisedLook.yCoord * DISTANCE), playerPosition.zCoord + (normalisedLook.zCoord * DISTANCE)); MovingObjectPosition position = world.rayTraceBlocks(playerPosition, targetPosition, true, true, false); return position; } If you want to find all entities within an area, simply use the World.getEntitiesWithinAABBExcludingEntity(player, box) (I used player as I had no other entity available), where 'box' is a bounding box assembled from the data you get from your FindTarget call. Hope this helps!
  5. It's just personal preference, and something drilled into me by my work. Variables start with lowercase, functions start with a capital. Thanks! Very helpful. There's a problem there; using an axis aligned bounding box needs an Entity. I only have an Item. I'd need to create or get (I don't know from where) an Entity to use that. Could I use the player?
  6. You might have to get a bit low-level for this one, since it's a hardware related issue. What I'd perhaps do is look at how InventoryTweaks does it. Here's a link to the class:
  7. So I'm trying to make an anti-Undead spell that deals direct damage to the Undead, but I'm having a problem actually dealing damage. attackEntityFrom() seems to fail on the worldObj.isRemote check, indicating that the world is indeed, remote. When I put in a check for it, it fails it and attackEntityFrom() never gets called. What can I do about this? Code posted below. @Override public ItemStack onItemUseFinish(ItemStack itemStack, World world, EntityPlayer player) { int mana = 0; ItemStack wand = FindWand(player); if(wand != null) { if(wand.getTagCompound() != null) { mana = wand.getTagCompound().getInteger("mana"); } if(mana >= COST) { int distance = 64; //MovingObjectPosition position = Minecraft.getMinecraft().getRenderViewEntity().rayTrace(distance, 1.0f); Entity target = Minecraft.getMinecraft().objectMouseOver.entityHit; if(target != null) { if(target instanceof EntityLiving) { EntityLiving livingTarget = (EntityLiving)target; if(livingTarget.getCreatureAttribute() == EnumCreatureAttribute.UNDEAD) { ItemBaseWand castWand = (ItemBaseWand)wand.getItem(); livingTarget.attackEntityFrom(DamageSource.inFire, DAMAGE); livingTarget.setFire(10); if(!world.isRemote) { castWand.ModMana(wand, -COST); } } } } } } return itemStack; }
×
×
  • Create New...

Important Information

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