Java Code Examples for net.minecraft.entity.Entity#slowMovement()

The following examples show how to use net.minecraft.entity.Entity#slowMovement() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MoonBerryBushBlock.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
@Override
public void onEntityCollision(BlockState blockState, World world, BlockPos blockPos, Entity entity) {
    entity.slowMovement(blockState, new Vec3d(0.800000011920929D, 0.75D, 0.800000011920929D));
}
 
Example 2
Source File: BramblesBlock.java    From the-hallow with MIT License 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
	if (entity instanceof LivingEntity && entity.getType() != HallowedEntities.CROW && entity.getType() != HallowedEntities.PUMPCOWN) {
		entity.slowMovement(state, new Vec3d(0.800000011920929D, 0.75D, 0.800000011920929D));
		if (!world.isClient && (entity.lastRenderX != entity.getX() || entity.lastRenderZ != entity.getZ())) {
			double entityX = Math.abs(entity.getX() - entity.lastRenderX);
			double entityZ = Math.abs(entity.getZ() - entity.lastRenderZ);
			if (entityX >= 0.003000000026077032D || entityZ >= 0.003000000026077032D) {
				entity.damage(DAMAGE_SOURCE, 1.0F);
			}
		}
	}
}