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

35 lines
1.0 KiB
Java

package com.thebrokenrail.twine.util;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.sound.SoundEvent;
public class BoatInventory extends ItemInventory {
private final Entity entity;
private final SoundEvent openSound;
private final SoundEvent closeSound;
public BoatInventory(Entity entity, int size, ItemStack stack, SoundEvent openSound, SoundEvent closeSound) {
super(size, stack);
this.entity = entity;
this.openSound = openSound;
this.closeSound = closeSound;
}
@Override
public boolean canPlayerUse(PlayerEntity player) {
return BoatUtil.canReachEntity(player, entity) && entity.isAlive() && ((BoatUtil) entity).getChestMode().hasItems();
}
@Override
public void onOpen(PlayerEntity player) {
BoatUtil.playSound(entity, openSound);
}
@Override
public void onClose(PlayerEntity player) {
BoatUtil.playSound(entity, closeSound);
}
}