| 13 | import java.util.function.Function; |
| 14 | |
| 15 | public class Tools { |
| 16 | |
| 17 | public static void spawnInWorld(Level level, BlockPos pos, ItemStack remaining) { |
| 18 | if (!remaining.isEmpty()) { |
| 19 | ItemEntity entityitem = new ItemEntity(level, pos.getX() + .5, pos.getY() + .5, pos.getZ() + .5, remaining); |
| 20 | entityitem.setPickUpDelay(40); |
| 21 | entityitem.setDeltaMovement(entityitem.getDeltaMovement().multiply(0, 1, 0)); |
| 22 | level.addFreshEntity(entityitem); |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | public static void teleport(ServerPlayer entity, ServerLevel destination, BlockPos pos, boolean findTop) { |
| 27 | entity.changeDimension(destination, new ITeleporter() { |
| 28 | @Override |
| 29 | public Entity placeEntity(Entity entity, ServerLevel currentWorld, ServerLevel destWorld, float yaw, Function<Boolean, Entity> repositionEntity) { |
| 30 | entity = repositionEntity.apply(false); |
| 31 | int y = pos.getY(); |
| 32 | if (findTop) { |
| 33 | y = destination.getHeight(Heightmap.Types.WORLD_SURFACE_WG, pos.getX(), pos.getZ()); |
| 34 | } |
| 35 | entity.teleportTo(pos.getX(), y, pos.getZ()); |
| 36 | return entity; |
| 37 | } |
| 38 | }); |
| 39 | } |
| 40 | |
| 41 | } |
nothing calls this directly
no outgoing calls
no test coverage detected