package com.thebrokenrail.twine.util; import net.minecraft.entity.Entity; import net.minecraft.entity.data.DataTracker; import net.minecraft.entity.data.TrackedData; import net.minecraft.entity.data.TrackedDataHandlerRegistry; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.vehicle.BoatEntity; import net.minecraft.inventory.Inventory; import net.minecraft.item.Item; import net.minecraft.item.Items; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvent; import net.minecraft.util.math.Vec3d; public interface BoatUtil { TrackedData HAS_CHEST = DataTracker.registerData(BoatEntity.class, TrackedDataHandlerRegistry.STRING); 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; } enum BoatChestMode { ENDER_CHEST(Items.ENDER_CHEST, false), CHEST(Items.CHEST, true), TRAPPED_CHEST(Items.TRAPPED_CHEST, true), NONE(Items.AIR, false); private final Item item; private final boolean hasItems; BoatChestMode(Item item, boolean hasItems) { this.item = item; this.hasItems = hasItems; } public Item getItem() { return item; } public boolean hasItems() { return hasItems; } public static BoatChestMode valueOF(Item item) { for (BoatChestMode mode : values()) { if (mode.getItem() == item) { return mode; } } return NONE; } } 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); } }