terraya
Members-
Posts
161 -
Joined
-
Last visited
Everything posted by terraya
-
still thank you x) i will search for it !
-
ok i did a new class but it still doesnt work ... id ont understand why it doesnt work ... here we go: public static Item TestArrow; TestArrow = new CustomArrow().setUnlocalizedName("TestArrow"); GameRegistry.registerItem(TestArrow, "TestArrow"); registerRender(TestArrow); the customarrow.class public class CustomArrow extends ItemArrow{ public EntityArrow createArrow(World worldIn, ItemStack stack, EntityLivingBase shooter) { EntityTippedArrow entitytippedarrow = new EntityTippedArrow(worldIn, shooter); entitytippedarrow.setPotionEffect(stack); return entitytippedarrow; } } EntityRegistry.registerModEntity(ExplosionArrow.class, "TestArrow", 14, this, 80, 3, true); public class ExplosionArrow extends EntityTippedArrow { private int duration = 200; public ExplosionArrow(World worldIn) { super(worldIn); } public ExplosionArrow(World worldIn, EntityLivingBase shooter) { super(worldIn, shooter); } public ExplosionArrow(World worldIn, double x, double y, double z) { super(worldIn, x, y, z); } @Override public void onUpdate() { super.onUpdate(); if (this.worldObj.isRemote && !this.inGround) { this.worldObj.spawnParticle(EnumParticleTypes.END_ROD, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, new int[0]); } else if (!this.worldObj.isRemote && this.inGround) { worldObj.createExplosion(shootingEntity, this.posX, this.posY, this.posZ, 1.0F, true); this.setDead(); } } @Override public ItemStack getArrowStack() { return new ItemStack(ItemsUpdate.TestArrow); } @Override public void arrowHit(EntityLivingBase living) { super.arrowHit(living); World world = living.getEntityWorld(); if(living != shootingEntity) { world.createExplosion(shootingEntity, living.posX, living.posY, living.posZ, 1.0F, true); } } }
-
ok i got all i think, but somehow the problem is , that he is using my arrow (yes) but i dont know why (or is it normal?) that the customarrow (without textures etc) has automaticaly the form/texture of the vanila arrow? and ye it work without errors , it just dont want to explode ... idk what am i doing wrong public class EntityArrow extends EntityTippedArrow { private int duration = 200; public EntityArrow(World worldIn) { super(worldIn); } public EntityArrow(World worldIn, EntityLivingBase shooter) { super(worldIn, shooter); } public EntityArrow(World worldIn, double x, double y, double z) { super(worldIn, x, y, z); } @Override public void onUpdate() { super.onUpdate(); if (this.worldObj.isRemote && !this.inGround) { this.worldObj.spawnParticle(EnumParticleTypes.END_ROD, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, new int[0]); } else if (!this.worldObj.isRemote && this.inGround) { worldObj.createExplosion(shootingEntity, this.posX, this.posY, this.posZ, 1.0F, true); this.setDead(); } } @Override public ItemStack getArrowStack() { return new ItemStack(ItemsUpdate.TestArrow); } @Override public void arrowHit(EntityLivingBase living) { super.arrowHit(living); World world = living.getEntityWorld(); if(living != shootingEntity) { world.createExplosion(shootingEntity, living.posX, living.posY, living.posZ, 1.0F, true); } } }
-
sure that it is for 1.10? it shows up a bunch of errors
-
becouse if i do it like this: protected void arrowHit(EntityLivingBase living) { super.arrowHit(living); { if (living.entityHit != null) { int i = 0; if (living.entityHit instanceof EntityLivingBase) { i = 150; } living.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)i); worldObj.playSound((EntityPlayer)null, posX, posY, posZ, SoundEvents.BLOCK_GRASS_BREAK, SoundCategory.NEUTRAL, 0.8F, 1.5F / (worldObj.rand.nextFloat() * 0.4F + 0.8F)); this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, this.HitExplosionRadius, true); } for (int j = 0; j < 1; ++j) { this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, this.explosionRadius, true); } if (!this.worldObj.isRemote) { this.setDead(); worldObj.playSound((EntityPlayer)null, posX, posY, posZ, SoundEvents.BLOCK_GRASS_BREAK, SoundCategory.NEUTRAL, 0.7F, 1.5F / (worldObj.rand.nextFloat() * 0.4F + 0.8F)); } } } it says "entityHit cannot be resolved or is not a field"
-
Why is this here? wops , well i tried it without and with, dont work
-
tried it out now , somehow the arrow still doesnt make the "explosion" thats my class: public class EntityArrow extends EntityTippedArrow implements IThrowableEntity { public EntityArrow(World worldIn) { super(worldIn); } public EntityArrow(World worldIn, double x, double y, double z) { super(worldIn, x, y, z); } public EntityArrow(World worldIn, EntityLivingBase shooter) { super(worldIn, shooter); } public void onEntityUpdate() { if (this.ticks <= 0) { this.ticks = 200; setDead(); } else { this.ticks -= 1; } } public int ticks = 200; public int HitExplosionRadius = 10; public int explosionRadius = 5; @SideOnly(Side.CLIENT) protected void arrowHit(EntityLivingBase living,RayTraceResult result) { super.arrowHit(living); { if (result.entityHit != null) { int i = 0; if (result.entityHit instanceof EntityLivingBase) { i = 150; } result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)i); worldObj.playSound((EntityPlayer)null, posX, posY, posZ, SoundEvents.BLOCK_GRASS_BREAK, SoundCategory.NEUTRAL, 0.8F, 1.5F / (worldObj.rand.nextFloat() * 0.4F + 0.8F)); this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, this.HitExplosionRadius, true); } for (int j = 0; j < 1; ++j) { this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, this.explosionRadius, true); } if (!this.worldObj.isRemote) { this.setDead(); worldObj.playSound((EntityPlayer)null, posX, posY, posZ, SoundEvents.BLOCK_GRASS_BREAK, SoundCategory.NEUTRAL, 0.7F, 1.5F / (worldObj.rand.nextFloat() * 0.4F + 0.8F)); } } } @Override public void setPotionEffect(ItemStack stack) { super.setPotionEffect(new ItemStack(ItemsUpdate.TestArrow)); } @Override protected ItemStack getArrowStack() { return new ItemStack(ItemsUpdate.TestArrow); } @Override public Entity getThrower() { return shootingEntity; } @Override public void setThrower(Entity entity) { shootingEntity = entity; } protected float getGravityVelocity() { return 0F; } }
-
Hello@All , i got my normal class from my Arrow, but how can i add a explosion? i mean, i cannot use like on a "throwableEntity" , "OnImpact". public class EntityArrow extends EntityTippedArrow implements IThrowableEntity { public EntityArrow(World worldIn) { super(worldIn); } public EntityArrow(World worldIn, double x, double y, double z) { super(worldIn, x, y, z); } public EntityArrow(World worldIn, EntityLivingBase shooter) { super(worldIn, shooter); } @Override public void setPotionEffect(ItemStack stack) { super.setPotionEffect(new ItemStack(ItemsUpdate.TestArrow)); } @Override protected ItemStack getArrowStack() { return new ItemStack(ItemsUpdate.TestArrow); } @Override public Entity getThrower() { return shootingEntity; } @Override public void setThrower(Entity entity) { shootingEntity = entity; } protected float getGravityVelocity() { return 0F; } }
-
" cz.grossik.farmcraft2.tractor.EntityTractor" post this class here please. and your "main class" / "proxy"
-
use my code, it work on me public class FireBallItem extends Item { public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) { if (!playerIn.capabilities.isCreativeMode) { --itemStackIn.stackSize; } worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.4F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!worldIn.isRemote) { FireBall entitythrowable = new FireBall(worldIn, playerIn); entitythrowable.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F); worldIn.spawnEntityInWorld(entitythrowable); } playerIn.addStat(StatList.getObjectUseStats(this)); return new ActionResult(EnumActionResult.SUCCESS, itemStackIn); } } EDIT: ofc you have to configure it for yourself , but it should work out
-
EntityAIAttackMelee is a vanilla class and wont call you private method of tryAbility. hmm so how could i do it, i did a class "OnUpdate" and he doesnt use it, or do i need to use it in a class? (Please know that its my first entityclass with abilitys that i ever code, so for any help im very thankfull) public boolean onUpdate(EntityLivingBase mob) { if ((getAttackTarget() != null) && ((getAttackTarget() instanceof EntityPlayer))) { tryAbility(mob, getAttackTarget()); } return onUpdate(mob); } private long nextAbilityUse = 0L; private void tryAbility(EntityLivingBase mob, EntityLivingBase target) { if ((target == null) || (target.getRidingEntity() != null) || (!mob.canEntityBeSeen(target))) { return; } long time = System.currentTimeMillis(); if ((time > this.nextAbilityUse) && (mob.getDistanceToEntity(target) > 0.0F)); //(target.worldObj.canBlockSeeSky(new BlockPos(MathHelper.floor_double(target.posX), MathHelper.floor_double(target.posY), MathHelper.floor_double(target.posZ))))) { this.nextAbilityUse = (time + 0L); mob.worldObj.addWeatherEffect(new EntityLightningBolt(mob.worldObj, target.posX, target.posY - 1.0D, target.posZ, false)); } }
-
EDIT
-
EDIT: i want to try it with "EntityAIAttackMelee" , so my entity is attacking me now .. but hes not using "tryability" ... idk why .. hers the code: public class EntityModelTest extends EntityMob{ public EntityModelTest(World worldIn) { super(worldIn); //AI Components this.tasks.addTask(1, new EntityAISwimming(this)); this.tasks.addTask(2, new EntityAIAttackMelee(this, 1.0D, false)); this.tasks.addTask(3, new EntityAIMoveTowardsRestriction(this, 1.0D)); this.tasks.addTask(4, new EntityAIWander(this, 1.0D)); this.tasks.addTask(5, new EntityAIWatchClosest(this, EntityPlayer.class, 20F)); this.tasks.addTask(6, new EntityAILookIdle(this)); this.targetTasks.addTask(0, new EntityAINearestAttackableTarget(this, EntityPlayer.class , true)); this.setSize(0.6f, 1.5f); } @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(35.0D); this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.23000000417232513D); this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(4.0D); this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(1000.0D); } protected void addRandomArmor() { this.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, new ItemStack(Items.SHIELD)); } protected boolean isAIEnabled() { return true; } public boolean onUpdate(EntityLivingBase mob) { if ((getAttackTarget() != null) && ((getAttackTarget() instanceof EntityPlayer))) { tryAbility(mob, getAttackTarget()); } return onUpdate(mob); } private long nextAbilityUse = 0L; private void tryAbility(EntityLivingBase mob, EntityLivingBase target) { if ((target == null) || (target.getRidingEntity() != null) || (!mob.canEntityBeSeen(target))) { return; } long time = System.currentTimeMillis(); if ((time > this.nextAbilityUse) && (mob.getDistanceToEntity(target) > 3.0F) && (target.worldObj.canBlockSeeSky(new BlockPos(MathHelper.floor_double(target.posX), MathHelper.floor_double(target.posY), MathHelper.floor_double(target.posZ))))) { this.nextAbilityUse = (time + 15000L); mob.worldObj.addWeatherEffect(new EntityLightningBolt(mob.worldObj, target.posX, target.posY - 1.0D, target.posZ, false)); } } protected boolean canDropLoot() { return false; } protected SoundEvent getAmbientSound() { return null; } protected SoundEvent getHurtSound() { return null; } protected SoundEvent getDeathSound() { return null; } @Override public void readEntityFromNBT(NBTTagCompound nbt) { super.readEntityFromNBT(nbt); } @Override public void writeEntityToNBT(NBTTagCompound nbt) { super.writeEntityToNBT(nbt); } } if someone could help me
-
im using in my tasks "EntityAIAttackMelee" but hes not attacking me back if i hit him
-
Hello@All , so i got only 1 problem, my entity dont want to attack me , but i know whats missing, in 1.7.10 there was a function like :" AIAttackOnColide" i cant find it for 1.10 heres my entity class: public class EntityModelTest extends EntityMob{ public EntityModelTest(World worldIn) { super(worldIn); //AI Components this.tasks.addTask(1, new EntityAISwimming(this)); this.tasks.addTask(2, new EntityAIAttackMelee(this, 1.0D, false)); this.tasks.addTask(3, new EntityAIMoveTowardsRestriction(this, 1.0D)); this.tasks.addTask(4, new EntityAIWander(this, 1.0D)); this.tasks.addTask(5, new EntityAIWatchClosest(this, EntityPlayer.class, 20F)); this.tasks.addTask(6, new EntityAILookIdle(this)); this.setSize(0.6f, 1.5f); } @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(35.0D); this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.23000000417232513D); this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(4.0D); this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(1000.0D); } @Override public void readEntityFromNBT(NBTTagCompound nbt) { super.readEntityFromNBT(nbt); } @Override public void writeEntityToNBT(NBTTagCompound nbt) { super.writeEntityToNBT(nbt); } @Override public boolean attackEntityAsMob(Entity entity){ super.attackEntityAsMob(entity); return entity.attackEntityFrom(DamageSource.causeMobDamage(this), 1); } protected boolean isAIEnabled() { return true; } public boolean onUpdate(EntityLivingBase mob) { if ((getAttackTarget() != null) && ((getAttackTarget() instanceof EntityPlayer))) { tryAbility(mob, getAttackTarget()); } return onUpdate(mob); } private long nextAbilityUse = 0L; private void tryAbility(EntityLivingBase mob, EntityLivingBase target) { if ((target == null) || (target.getRidingEntity() != null) || (!mob.canEntityBeSeen(target))) { return; } long time = System.currentTimeMillis(); if ((time > this.nextAbilityUse) && (mob.getDistanceToEntity(target) > 3.0F) && (target.worldObj.canBlockSeeSky(new BlockPos(MathHelper.floor_double(target.posX), MathHelper.floor_double(target.posY), MathHelper.floor_double(target.posZ))))) { this.nextAbilityUse = (time + 15000L); mob.worldObj.addWeatherEffect(new EntityLightningBolt(mob.worldObj, target.posX, target.posY - 1.0D, target.posZ, false)); } } protected boolean canDropLoot() { return false; } }
-
[1.10] CustomEntity transform automaticaly into pig? o.O
terraya replied to terraya's topic in Modder Support
as written above, its not the register. well the error are my attribute tasks: this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(1, new EntityAITempt(this, 1.0D, Items.APPLE, false)); this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D)); this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false)); this.tasks.addTask(7, new EntityAIWander(this, 1.0D)); this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(8, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true)); one of them makes my entity to an pig X) Then remove the ones you added to make sure. If so remove them one by one, if that doesn't work try removing multiple to see which ones are causing it then come back and tell us which ones are causing the problem. yep did that , and worked out perfectly! thanks -
[1.10] CustomEntity transform automaticaly into pig? o.O
terraya replied to terraya's topic in Modder Support
as written above, its not the register. well the error are my attribute tasks: this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(1, new EntityAITempt(this, 1.0D, Items.APPLE, false)); this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D)); this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false)); this.tasks.addTask(7, new EntityAIWander(this, 1.0D)); this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(8, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true)); one of them makes my entity to an pig X) -
[1.10] CustomEntity transform automaticaly into pig? o.O
terraya replied to terraya's topic in Modder Support
as i said, "it is not in the registry" becouse the pig came out after changing the entityclass itself ^^ well , im gonna search a bit more and tell you what it is -
Hello@All, im trying to play around a bit with my TestEntity. somehow , i addet a attribute or something that makes my Entity.class take the model of a pig becouse when i try to spawn it, it spawns a pig ... public class EntityModelTest extends EntityMob{ public EntityModelTest(World worldIn) { super(worldIn); } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(10.0D); this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.3F); this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(1, new EntityAITempt(this, 1.0D, Items.APPLE, false)); this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D)); this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false)); this.tasks.addTask(7, new EntityAIWander(this, 1.0D)); this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(8, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true)); } @Override public void readEntityFromNBT(NBTTagCompound nbt) { super.readEntityFromNBT(nbt); } @Override public void writeEntityToNBT(NBTTagCompound nbt) { super.writeEntityToNBT(nbt); } @Override public boolean attackEntityAsMob(Entity entity){ super.attackEntityAsMob(entity); return entity.attackEntityFrom(DamageSource.causeMobDamage(this), 1); } public boolean attackEntityFrom(DamageSource ds, float damage) { if(ds.getEntity() != null && ds.getEntity() instanceof EntityPlayer) { return super.attackEntityFrom(ds, this.getMaxHealth()); } return super.attackEntityFrom(ds, damage); } protected boolean isAIEnabled() { return true; } public boolean onUpdate(EntityLivingBase mob) { if ((getAttackTarget() != null) && ((getAttackTarget() instanceof EntityPlayer))) { tryAbility(mob, getAttackTarget()); } return onUpdate(mob); } private long nextAbilityUse = 0L; private void tryAbility(EntityLivingBase mob, EntityLivingBase target) { if ((target == null) || (target.getRidingEntity() != null) || (!mob.canEntityBeSeen(target))) { return; } long time = System.currentTimeMillis(); if ((time > this.nextAbilityUse) && (mob.getDistanceToEntity(target) > 3.0F) && (target.worldObj.canBlockSeeSky(new BlockPos(MathHelper.floor_double(target.posX), MathHelper.floor_double(target.posY), MathHelper.floor_double(target.posZ))))) { this.nextAbilityUse = (time + 15000L); mob.worldObj.addWeatherEffect(new EntityLightningBolt(mob.worldObj, target.posX, target.posY - 1.0D, target.posZ, false)); } } protected boolean canDropLoot() { return false; } } IT IS NOT the "Handler" or the "render" etc ... it has to be in this class bcuz "before" it worked pretty well , now it just doent work becouse i add something weird
-
I would use the LivingAttackEvent to check if the entity attacking from the source is an instanceof EntityLiving and specifically EntityPlayer and then grab the inventory object to see if the item used was yours then apply the effect. got some problem on starting my mod, but i got the function writting with big hope that this test thing here will work: private void tryAbility(EntityLivingBase mob, EntityLivingBase target) { if ((target == null) || (target.getRidingEntity() != null) || (!mob.canEntityBeSeen(target))) { return; } long time = System.currentTimeMillis(); if ((time > this.nextAbilityUse) && (mob.getDistanceToEntity(target) > 3.0F) && (target.worldObj.canBlockSeeSky(new BlockPos(MathHelper.floor_double(target.posX), MathHelper.floor_double(target.posY), MathHelper.floor_double(target.posZ))))) { this.nextAbilityUse = (time + 15000L); mob.worldObj.addWeatherEffect(new EntityLightningBolt(mob.worldObj, target.posX, target.posY - 1.0D, target.posZ, false)); } } }
-
I was being sarcastic at gurujive, not you. I was telling him he was being dumb because he was suggesting Solution-A which won't work for Problem-B (he can't even get his own entities working properly, so he's really got no experience helping other people with entities). ye i understand that but anyway , i codet a small function: public boolean attackEntityAsMob(Entity entity) { boolean success = super.attackEntityAsMob(entity); if (entity instanceof EntityLiving) { ((EntityLiving)entity).addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 200)); success = true; } return success; } so now , next mission is to mix that with "attackentityasmob" , but how can i use "OnImpact" , i mean , is there a function like : "OnEntityHit" or something?
-
hmm dont looked onto it, any idea how to mix it with the function written above?
-
Yeah, that's totally going to work for a sword. sarcasm? i mean well first i have to search "entity.projectile" , never used it before, snowball is to throw so .. well i want to make the effect on "hit" not on "throw and hit"
-
hello@All so as i hear that an Entity cant use the Abilitys of a Sword so i have to make a custom Entity with a sword in hes hand. the problem which i have on it is, "When he hits an enemy" : protected void onImpact(RayTraceResult result) { if (result.entityHit != null) { int i = 0; if (result.entityHit instanceof EntityLivingBase) { i = 150; } result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)i); worldObj.playSound((EntityPlayer)null, posX, posY, posZ, SoundEvents.BLOCK_GRASS_BREAK, SoundCategory.NEUTRAL, 0.8F, 1.5F / (worldObj.rand.nextFloat() * 0.4F + 0.8F)); this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, this.HitExplosionRadius, true); } for (int j = 0; j < 1; ++j) { this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, this.explosionRadius, true); } if (!this.worldObj.isRemote) { this.setDead(); worldObj.playSound((EntityPlayer)null, posX, posY, posZ, SoundEvents.BLOCK_GRASS_BREAK, SoundCategory.NEUTRAL, 0.7F, 1.5F / (worldObj.rand.nextFloat() * 0.4F + 0.8F)); } } the problem here is "OnImpact" is for "EntityThrowable" , so i am searching for a function which works like: "if entity hits the enemy then ... ... ... "
-
btw. is there a function like "If EntityHit target" ?