This repository has been archived on 2023-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
Twine/src/main/java/com/thebrokenrail/twine/util/boat/BoatUtil.java

30 lines
1.1 KiB
Java

package com.thebrokenrail.twine.util.boat;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventory;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.math.Vec3d;
public interface BoatUtil {
BoatChestMode getChestMode();
Inventory getChestInventory();
void openInventory(PlayerEntity player);
static boolean canReachEntity(PlayerEntity player, Entity entity) {
return player.squaredDistanceTo(entity.getPos().getX(), entity.getPos().getY(), entity.getPos().getZ()) <= 64d;
}
static boolean canPlayerUse(PlayerEntity player, Entity entity, BoatChestMode mode) {
return BoatUtil.canReachEntity(player, entity) && entity.isAlive() && ((BoatUtil) entity).getChestMode() == mode;
}
static void playSound(Entity vehicle, SoundEvent sound) {
Vec3d pos = vehicle.getPos();
vehicle.getEntityWorld().playSound(null, pos.getX(), pos.getY(), pos.getZ(), sound, SoundCategory.BLOCKS, 0.5F, vehicle.getEntityWorld().random.nextFloat() * 0.1F + 0.9F);
}
}