MinecraftScripterAI
Discord ↗
Link Copied to Clipboard
×
"I have an entity that bounces off of blocks, but it bounces through the ground "
This issue might be caused by the bounce logic not correctly handling the case when the entity hits a block from below. You can fix this by checking the collision normal in your bounce logic and reversing the vertical motion if the entity is moving downwards when it hits a block. Here is a basic example: /* This entity bounces off of blocks, including the ground. */ public class BouncingEntity extends Entity { public BouncingEntity(EntityType<?> type, World worldIn) { super(type, worldIn); } @Override public void tick() { super.tick(); /* If the entity is moving downwards and is on the ground, reverse the vertical motion */ if (this.getDeltaMovement().y < 0 && this.onGround) { this.setDeltaMovement(this.getDeltaMovement().x, -this.getDeltaMovement().y, this.getDeltaMovement().z); } /* If the entity hits a block from the side, reverse the horizontal motion */ if (this.horizontalCollision) { this.setDeltaMovement(-this.getDeltaMovement().x, this.getDeltaMovement().y, -this.getDeltaMovement().z); } } /* Other necessary methods like registerAttributes, createSpawnPacket, etc. */ }