102 lines
3.4 KiB
Java
102 lines
3.4 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/PrinterBlockEntity.class */
|
|
public class PrinterBlockEntity extends BlockEntity implements Container {
|
|
public static final BlockEntityType<PrinterBlockEntity> PRINTER = BlockEntityType.Builder.of(PrinterBlockEntity::new, new Block[]{(Block) CustomBlocks.BLOCK_PRINTER.get()}).build((Type) null);
|
|
private static final Logger LOGGER = LogManager.getLogger();
|
|
public static final int PRINTER_CONTAINER_SIZE = 27;
|
|
private NonNullList<ItemStack> items;
|
|
|
|
public NonNullList<ItemStack> getItems() {
|
|
return this.items;
|
|
}
|
|
|
|
public PrinterBlockEntity(BlockPos pos, BlockState state) {
|
|
super(PRINTER, pos, state);
|
|
this.items = NonNullList.withSize(27, 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 27;
|
|
}
|
|
|
|
public boolean isEmpty() {
|
|
for (int i = 0; i < this.items.size(); i++) {
|
|
if (!((ItemStack) this.items.get(i)).isEmpty()) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public int freeSlotCount() {
|
|
int freeSlots = 0;
|
|
for (int i = 0; i < this.items.size(); i++) {
|
|
if (((ItemStack) this.items.get(i)).isEmpty()) {
|
|
freeSlots++;
|
|
}
|
|
}
|
|
return freeSlots;
|
|
}
|
|
|
|
public int getFirstFreeSlot() {
|
|
for (int i = 0; i < this.items.size(); i++) {
|
|
if (((ItemStack) this.items.get(i)).isEmpty()) {
|
|
return i;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|