75 lines
1.9 KiB
Java
75 lines
1.9 KiB
Java
package com.thebrokenrail.twine.util;
|
|
|
|
import net.minecraft.block.Blocks;
|
|
import net.minecraft.entity.Entity;
|
|
import net.minecraft.entity.player.PlayerEntity;
|
|
import net.minecraft.inventory.EnderChestInventory;
|
|
import net.minecraft.inventory.Inventory;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.sound.SoundEvents;
|
|
|
|
public class EnderChestInventoryWrapper implements Inventory {
|
|
private final EnderChestInventory inventory;
|
|
private final Entity entity;
|
|
|
|
public EnderChestInventoryWrapper(Entity entity, EnderChestInventory inventory) {
|
|
this.entity = entity;
|
|
this.inventory = inventory;
|
|
}
|
|
|
|
@Override
|
|
public int size() {
|
|
return inventory.size();
|
|
}
|
|
|
|
@Override
|
|
public boolean isEmpty() {
|
|
return inventory.isEmpty();
|
|
}
|
|
|
|
@Override
|
|
public ItemStack getStack(int slot) {
|
|
return inventory.getStack(slot);
|
|
}
|
|
|
|
@Override
|
|
public ItemStack removeStack(int slot, int amount) {
|
|
return inventory.removeStack(slot, amount);
|
|
}
|
|
|
|
@Override
|
|
public ItemStack removeStack(int slot) {
|
|
return inventory.removeStack(slot);
|
|
}
|
|
|
|
@Override
|
|
public void setStack(int slot, ItemStack stack) {
|
|
inventory.setStack(slot, stack);
|
|
}
|
|
|
|
@Override
|
|
public void markDirty() {
|
|
inventory.markDirty();
|
|
}
|
|
|
|
@Override
|
|
public boolean canPlayerUse(PlayerEntity player) {
|
|
return BoatUtil.canReachEntity(player, entity) && entity.isAlive() && ((BoatUtil) entity).getChestMode().getBlock() == Blocks.ENDER_CHEST;
|
|
}
|
|
|
|
@Override
|
|
public void onOpen(PlayerEntity player) {
|
|
BoatUtil.playSound(entity, SoundEvents.BLOCK_ENDER_CHEST_OPEN);
|
|
}
|
|
|
|
@Override
|
|
public void onClose(PlayerEntity player) {
|
|
BoatUtil.playSound(entity, SoundEvents.BLOCK_ENDER_CHEST_CLOSE);
|
|
}
|
|
|
|
@Override
|
|
public void clear() {
|
|
inventory.clear();
|
|
}
|
|
}
|