Posted April 10, 20205 yr The onKillEntity method seems to work with any entity, but it doesn't seem to be activated when a player dies. I figure I can get over this issue by using the LivingDeathEvent and checking whether the entity in question is a player, but i just want to know if this is an error or an intended feature (or, if there is another method I could use besides the event).
April 10, 20205 yr 3 hours ago, SSilvamc said: onKillEntity method onKillEntity method in what class? 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.
April 10, 20205 yr Author 5 hours ago, Animefan8888 said: onKillEntity method in what class? I was using it with FallingBlockEntity. Then again, that class does not override onKillEntity, it just takes it from the Entity class. This was my code: Spoiler public class BeheadingBladeEntity extends FallingBlockEntity { public BeheadingBladeEntity(World worldIn, double x, double y, double z, BlockState fallingBlockState) { super(worldIn, x, y, z, fallingBlockState); } public boolean onLivingFall(float distance, float damageMultiplier) { int i = MathHelper.ceil(distance - 1.0F); if (i > 0) { List<Entity> list = Lists.newArrayList(this.world.getEntitiesWithinAABBExcludingEntity(this, this.getBoundingBox())); for(Entity entity : list) { Random rand = new Random(); int val = rand.nextInt(5); IndirectEntityDamageSource source = new IndirectEntityDamageSource("guillotine" + Integer.toString(val), this, this); entity.attackEntityFrom(source, Float.MAX_VALUE); } } return false; } @Override public void onKillEntity(LivingEntity entityLivingIn) { System.out.println("Entity killed: " + entityLivingIn); } } This gets called whenever any entity is killed, but not when the player is killed. I'm using an IndirectEntityDamageSource because the onDeath method in LivingEntity (which is where the onKillEntity method is triggered; it's the only reference to such method in the code, apart from the one in ZombieEntity which turns villagers to zombie villagers) gets the entity causing the damage with getTrueSource(), and if I use a simple DamageSource, this is set to null (and the onKillEntity method is never called)
April 10, 20205 yr Author Just now, diesieben07 said: You'll have to use LivingDeathEvent. onKillEntity is not called by ServerPlayerEntity#onDeath, which is where it would normally be called from. Great! Thanks.
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.