com.parzivail.util.blockentity.InventoryBlockEntity Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pswg Show documentation
Show all versions of pswg Show documentation
Explore the galaxy with Galaxies: Parzi's Star Wars Mod!
package com.parzivail.util.blockentity;
import com.parzivail.util.item.ItemUtil;
import net.minecraft.class_1262;
import net.minecraft.class_1263;
import net.minecraft.class_1657;
import net.minecraft.class_1799;
import net.minecraft.class_2338;
import net.minecraft.class_2371;
import net.minecraft.class_2487;
import net.minecraft.class_2586;
import net.minecraft.class_2591;
import net.minecraft.class_2680;
public abstract class InventoryBlockEntity extends class_2586 implements class_1263
{
protected final class_2371 inventory;
public InventoryBlockEntity(class_2591> type, class_2338 pos, class_2680 state, int inventorySize)
{
super(type, pos, state);
inventory = class_2371.method_10213(inventorySize, class_1799.field_8037);
}
@Override
public void method_11007(class_2487 tag)
{
class_1262.method_5426(tag, this.inventory);
super.method_11007(tag);
}
@Override
public void method_11014(class_2487 tag)
{
class_1262.method_5429(tag, inventory);
super.method_11014(tag);
}
@Override
public int method_5439()
{
return inventory.size();
}
@Override
public boolean method_5442()
{
return ItemUtil.isInventoryEmpty(inventory);
}
@Override
public class_1799 method_5438(int slot)
{
return inventory.get(slot);
}
@Override
public class_1799 method_5434(int slot, int amount)
{
var itemStack = class_1262.method_5430(inventory, slot, amount);
if (!itemStack.method_7960())
{
this.method_5431();
}
return itemStack;
}
@Override
public class_1799 method_5441(int slot)
{
var itemStack = inventory.get(slot);
if (itemStack.method_7960())
return class_1799.field_8037;
else
{
inventory.set(slot, class_1799.field_8037);
return itemStack;
}
}
@Override
public void method_5447(int slot, class_1799 stack)
{
inventory.set(slot, stack);
if (!stack.method_7960() && stack.method_7947() > this.method_5444())
{
stack.method_7939(this.method_5444());
}
this.method_5431();
}
@Override
public boolean method_5443(class_1657 player)
{
if (this.field_11863.method_8321(this.field_11867) != this)
return false;
else
return player.method_5649((double)this.field_11867.method_10263() + 0.5D, (double)this.field_11867.method_10264() + 0.5D, (double)this.field_11867.method_10260() + 0.5D) <= 64.0D;
}
@Override
public void method_5448()
{
inventory.clear();
this.method_5431();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy