83 lines
2.9 KiB
Java
83 lines
2.9 KiB
Java
package com.dairymoose.modernlife.tileentities;
|
|
|
|
import com.dairymoose.modernlife.core.CustomBlocks;
|
|
import com.mojang.datafixers.types.Type;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.core.NonNullList;
|
|
import net.minecraft.nbt.CompoundTag;
|
|
import net.minecraft.world.Container;
|
|
import net.minecraft.world.ContainerHelper;
|
|
import net.minecraft.world.entity.player.Player;
|
|
import net.minecraft.world.item.ItemStack;
|
|
import net.minecraft.world.level.block.Block;
|
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
/* loaded from: outputsrg.jar:com/dairymoose/modernlife/tileentities/TrashCanBlockEntity.class */
|
|
public class TrashCanBlockEntity extends BlockEntity implements Container {
|
|
public static final BlockEntityType<TrashCanBlockEntity> TRASH_CAN = BlockEntityType.Builder.of(TrashCanBlockEntity::new, new Block[]{(Block) CustomBlocks.BLOCK_TRASH_CAN.get()}).build((Type) null);
|
|
private static final Logger LOGGER = LogManager.getLogger();
|
|
public static final int TRASH_CAN_CONTAINER_SIZE = 8;
|
|
private NonNullList<ItemStack> items;
|
|
|
|
public NonNullList<ItemStack> getItems() {
|
|
return this.items;
|
|
}
|
|
|
|
public TrashCanBlockEntity(BlockPos pos, BlockState state) {
|
|
super(TRASH_CAN, pos, state);
|
|
this.items = NonNullList.withSize(8, ItemStack.EMPTY);
|
|
}
|
|
|
|
public void load(CompoundTag p_230337_2_) {
|
|
super.load(p_230337_2_);
|
|
ContainerHelper.loadAllItems(p_230337_2_, this.items);
|
|
}
|
|
|
|
protected void saveAdditional(CompoundTag p_189515_1_) {
|
|
ContainerHelper.saveAllItems(p_189515_1_, this.items);
|
|
}
|
|
|
|
public void m_6211_() {
|
|
for (int i = 0; i < this.items.size(); i++) {
|
|
this.items.set(i, ItemStack.EMPTY);
|
|
}
|
|
}
|
|
|
|
public int getContainerSize() {
|
|
return 8;
|
|
}
|
|
|
|
public boolean isEmpty() {
|
|
for (int i = 0; i < this.items.size(); i++) {
|
|
if (this.items.get(i) != ItemStack.EMPTY) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public ItemStack getItem(int var1) {
|
|
return (ItemStack) this.items.get(var1);
|
|
}
|
|
|
|
public ItemStack removeItem(int var1, int var2) {
|
|
return ContainerHelper.removeItem(this.items, var1, var2);
|
|
}
|
|
|
|
public ItemStack removeItemNoUpdate(int var1) {
|
|
return ContainerHelper.takeItem(this.items, var1);
|
|
}
|
|
|
|
public void setItem(int var1, ItemStack var2) {
|
|
this.items.set(var1, var2);
|
|
}
|
|
|
|
public boolean stillValid(Player p_70300_1_) {
|
|
return this.level.getBlockEntity(this.worldPosition) == this && p_70300_1_.distanceToSqr(((double) this.worldPosition.getX()) + 0.5d, ((double) this.worldPosition.getY()) + 0.5d, ((double) this.worldPosition.getZ()) + 0.5d) <= 64.0d;
|
|
}
|
|
}
|