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/BoatInventory.java

30 lines
930 B
Java

package com.thebrokenrail.twine.util;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.SimpleInventory;
import net.minecraft.sound.SoundEvents;
public class BoatInventory extends SimpleInventory {
private final Entity entity;
public BoatInventory(Entity entity, int size) {
super(size);
this.entity = entity;
}
@Override
public boolean canPlayerUse(PlayerEntity player) {
return BoatUtil.canReachEntity(player, entity) && entity.isAlive() && ((BoatUtil) entity).getChestMode() == BoatUtil.BoatChestMode.CHEST && super.canPlayerUse(player);
}
@Override
public void onOpen(PlayerEntity player) {
BoatUtil.playSound(entity, SoundEvents.BLOCK_CHEST_OPEN);
}
@Override
public void onClose(PlayerEntity player) {
BoatUtil.playSound(entity, SoundEvents.BLOCK_CHEST_CLOSE);
}
}