Posted November 27, 20168 yr 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; } }
November 27, 20168 yr This is what looking at your class hierarchy is good for. protected void arrowHit(EntityLivingBase living) Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
November 27, 20168 yr Author This is what looking at your class hierarchy is good for. protected void arrowHit(EntityLivingBase living) 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; } }
November 27, 20168 yr @SideOnly(Side.CLIENT) Why is this here? Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
November 27, 20168 yr Author @SideOnly(Side.CLIENT) Why is this here? wops , well i tried it without and with, dont work
November 27, 20168 yr And why is this here? protected void arrowHit(EntityLivingBase living,RayTraceResult result) Seriously, use @Override and don't go dickering with things that you souldn't dicker with. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
November 27, 20168 yr Author And why is this here? protected void arrowHit(EntityLivingBase living,RayTraceResult result) Seriously, use @Override and don't go dickering with things that you souldn't dicker with. 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"
November 27, 20168 yr I have this: public class EntityCheeseArrow extends EntityArrow { private int duration = 200; public EntityCheeseArrow(World worldIn) { super(worldIn); } public EntityCheeseArrow(World worldIn, EntityLivingBase shooter) { super(worldIn, shooter); } public EntityCheeseArrow(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(CheeseItems.CHEESE_ARROW); } @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); } } } That works for me... Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
November 27, 20168 yr Author I have this: public class EntityCheeseArrow extends EntityArrow { private int duration = 200; public EntityCheeseArrow(World worldIn) { super(worldIn); } public EntityCheeseArrow(World worldIn, EntityLivingBase shooter) { super(worldIn, shooter); } public EntityCheeseArrow(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(CheeseItems.CHEESE_ARROW); } @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); } } } That works for me... sure that it is for 1.10? it shows up a bunch of errors
November 27, 20168 yr 1. Make sure to import the right things 2. CheeseItems.CHEESE_ARROW is just my arrow item, you need to put your own there 3. Can you post the errors? Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
November 27, 20168 yr Author 1. Make sure to import the right things 2. CheeseItems.CHEESE_ARROW is just my arrow item, you need to put your own there 3. Can you post the errors? 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); } } }
November 27, 20168 yr Don't call your arrow class EntityArrow, it makes things pretty confusing, and extends EntityArrow, not EntityTippedArrow Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
November 27, 20168 yr Author Don't call your arrow class EntityArrow, it makes things pretty confusing, and extends EntityArrow, not EntityTippedArrow 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); } } }
November 27, 20168 yr I don't know why either, sorry Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
November 27, 20168 yr Author I don't know why either, sorry still thank you x) i will search for it !
November 27, 20168 yr BTW search hycrafthd on youtube, he has a 1.9 tutorial on arrows and makes them explose, it's German but I don't speak German but still just copied the code and understood the minimum Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
November 27, 20168 yr Author BTW search hycrafthd on youtube, he has a 1.9 tutorial on arrows and makes them explose, it's German but I don't speak German but still just copied the code and understood the minimum ok i will do, i am german so i might understand more
November 27, 20168 yr Oh lol Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.