gurujive Posted August 13, 2016 Share Posted August 13, 2016 So I'm messin' around with this spell I'm working on. It does, this.doBlockCollisions(); when OnImpact EntityLivingBase to pierce through entities, but when it goes through the first one, it disappears. It still exists and continues through the first entity to hit the ones behind it. It just doesn't render for some odd reason. I can instead OnImpact do this seperately And it will travel through blocks and entities and not disappear at all: if (!this.worldObj.isRemote) { this.doBlockCollisions(); } The thing is it doesn't need to travel through blocks it only needs to travel through entities. This should work darn it. Here is the one where it travels through blocks and entities and doesn't disappear: public class EntityEarthOrb extends EntityOrb2 { public EntityEarthOrb(World worldIn) { super(worldIn); } public EntityEarthOrb(World worldIn, EntityLivingBase throwerIn) { super(worldIn, throwerIn); } public void onUpdate() { super.onUpdate(); this.worldObj.spawnParticle(EnumParticleTypes.BLOCK_CRACK, posX + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) / 2, posY + (worldObj.rand.nextFloat() / -2 - worldObj.rand.nextFloat()) / -1.3, posZ + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) / 2, 0, 0, 0, new int[] {Block.getIdFromBlock(Blocks.DIRT)}); ++ticksExisted; if (this.ticksExisted >= 54) { this.setDead(); } } public EntityEarthOrb(World worldIn, double x, double y, double z) { super(worldIn, x, y, z); } protected void onImpact(RayTraceResult result) { if (result.entityHit != null) { int i = 0; if (result.entityHit instanceof EntityLivingBase) { i = 4; } 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)); } for (int j = 0; j < 8; ++j) { this.worldObj.spawnParticle(EnumParticleTypes.BLOCK_CRACK, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, new int[] {Block.getIdFromBlock(Blocks.DIRT)}); } if (!this.worldObj.isRemote) { this.doBlockCollisions(); } } } Here is the one that will die when it hits blocks but disappear after going through the first entity it hits: public class EntityEarthOrb extends EntityOrb2 { public EntityEarthOrb(World worldIn) { super(worldIn); } public EntityEarthOrb(World worldIn, EntityLivingBase throwerIn) { super(worldIn, throwerIn); } public void onUpdate() { super.onUpdate(); this.worldObj.spawnParticle(EnumParticleTypes.BLOCK_CRACK, posX + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) / 2, posY + (worldObj.rand.nextFloat() / -2 - worldObj.rand.nextFloat()) / -1.3, posZ + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) / 2, 0, 0, 0, new int[] {Block.getIdFromBlock(Blocks.DIRT)}); ++ticksExisted; if (this.ticksExisted >= 54) { this.setDead(); } } public EntityEarthOrb(World worldIn, double x, double y, double z) { super(worldIn, x, y, z); } protected void onImpact(RayTraceResult result) { if (result.entityHit != null) { int i = 0; if (result.entityHit instanceof EntityLivingBase) { i = 4; } 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.doBlockCollisions(); } for (int j = 0; j < 8; ++j) { this.worldObj.spawnParticle(EnumParticleTypes.BLOCK_CRACK, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, new int[] {Block.getIdFromBlock(Blocks.DIRT)}); } if (this.worldObj.isRemote) { this.setDead(); } } } any ideas? Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 13, 2016 Share Posted August 13, 2016 Override doCollisions and remove the code stopping/killing the entity when it collides. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
gurujive Posted August 13, 2016 Author Share Posted August 13, 2016 This is doing the same thing: I'm really disappointed. The entity disappears after going through the first entity it hits, to travel through and hit whats behind it. import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.SoundEvents; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; public class EntityEarthOrb extends EntityOrb2 { public EntityEarthOrb(World worldIn) { super(worldIn); } public EntityEarthOrb(World worldIn, EntityLivingBase throwerIn) { super(worldIn, throwerIn); } public void onUpdate() { super.onUpdate(); this.worldObj.spawnParticle(EnumParticleTypes.BLOCK_CRACK, posX + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) / 2, posY + (worldObj.rand.nextFloat() / -2 - worldObj.rand.nextFloat()) / -1.3, posZ + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) / 2, 0, 0, 0, new int[] {Block.getIdFromBlock(Blocks.DIRT)}); ++ticksExisted; if (this.ticksExisted >= 54) { this.setDead(); } } public EntityEarthOrb(World worldIn, double x, double y, double z) { super(worldIn, x, y, z); } protected void onImpact(RayTraceResult result) { if (result.entityHit != null) { int i = 0; if (result.entityHit instanceof EntityLivingBase) { i = 4; } 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.canBeCollidedWith(); { boolean o; o = true; } } for (int j = 0; j < 8; ++j) { this.worldObj.spawnParticle(EnumParticleTypes.BLOCK_CRACK, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, new int[] {Block.getIdFromBlock(Blocks.DIRT)}); } if (this.worldObj.isRemote) { this.setDead(); } } } Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 13, 2016 Share Posted August 13, 2016 Why do you do this? if (this.worldObj.isRemote) { this.setDead(); } What you are doing is killing the Entity client side. Therefore it doesn't render. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
gurujive Posted August 14, 2016 Author Share Posted August 14, 2016 it makes it so when it hits a block it dies, but when it hits an entity it pierces through it. Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted August 14, 2016 Share Posted August 14, 2016 You are only killing it client side though because world.isRemote you should be using !world.isRemote. You are killing the entity anyways it is at the end of the method and always gets called. Try adding return; at the end of the if entityHit != null if statement. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
gurujive Posted August 15, 2016 Author Share Posted August 15, 2016 Yeah, I'm going to change this to solved. I got it goin' Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.