30 lines
926 B
Java
30 lines
926 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).hasChest() == 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);
|
|
}
|
|
} |