本文整理汇总了Java中net.minecraft.inventory.ISidedInventory类的典型用法代码示例。如果您正苦于以下问题:Java ISidedInventory类的具体用法?Java ISidedInventory怎么用?Java ISidedInventory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISidedInventory类属于net.minecraft.inventory包,在下文中一共展示了ISidedInventory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ContainerTileCustomMachine
import net.minecraft.inventory.ISidedInventory; //导入依赖的package包/类
public ContainerTileCustomMachine(IInventory playerInv, TileCustomMachine tileEntity)
{
super(0,3, 4,40);
setTileEntity(tileEntity);
CustomMachineSlot slotFirst = new CustomMachineSlot((ISidedInventory) tileEntity, 0, 52, 16);
CustomMachineSlot slotSecond = new CustomMachineSlot((ISidedInventory) tileEntity, 1, 80, 16);
CustomMachineSlot slotThird = new CustomMachineSlot((ISidedInventory) tileEntity, 2, 107, 16);
CustomMachineSlot slotOut = new CustomMachineSlot((ISidedInventory) tileEntity, 3, 80, 46);
// Tile Entity, Slot 0-3, Slot IDs 0-3
this.addSlotToContainer(slotFirst);
this.addSlotToContainer(slotSecond);
this.addSlotToContainer(slotThird);
this.addSlotToContainer(slotOut);
// Player Inventory, Slot 4-35, Slot IDs 4-35
for (int y = 0; y < 3; ++y)
for (int x = 0; x < 9; ++x)
this.addSlotToContainer(new Slot(playerInv, x + y * 9 + 9, 8 + x * 18, 84 + y * 18));
// Player Inventory, Slot 0-8, Slot IDs 36-44
for (int x = 0; x < 9; ++x)
this.addSlotToContainer(new Slot(playerInv, x, 8 + x * 18, 142));
}
示例2: collectItems
import net.minecraft.inventory.ISidedInventory; //导入依赖的package包/类
private void collectItems() {
applyGravity(attract, true);
IItemHandler handler = to.getKey();
ISidedInventory sidedInv = to.getValue();
getItemsFiltered(absorptionRange).forEach(e -> {
e.setNoGravity(true);
for(int slot = 0; slot < handler.getSlots(); slot++) {
ItemStack inSlot = handler.getStackInSlot(slot);
ItemStack in = e.getItem();
if(sidedInv == null || sidedInv.canInsertItem(slot, in, getFacingLazy())) {
if(inSlot.isEmpty() || (ItemHandlerHelper.canItemStacksStack(inSlot, in)
&& (inSlot.getCount() < inSlot.getMaxStackSize()
&& inSlot.getCount() < handler.getSlotLimit(slot)))) {
ItemStack out = handler.insertItem(slot, in, false);
if(out != in) {
e.setItem(out);
break;
}
}
}
}
});
}
示例3: dropItems
import net.minecraft.inventory.ISidedInventory; //导入依赖的package包/类
private void dropItems() {
if(world.getTotalWorldTime() % 10 != 0) return;
applyGravity(repulse, false);
IItemHandler handler = from.getKey();
ISidedInventory sidedInv = from.getValue();
Vector3 spawn = Vector3.create(getPos()).add(0.5D).offset(getFacingLazy(), 1);
for(int slot = 0; slot < handler.getSlots(); slot++) {
ItemStack inSlot = handler.getStackInSlot(slot);
if(!inSlot.isEmpty()
&& (lookup.isEmpty() || ItemHandlerHelper.canItemStacksStack(lookup, inSlot))
&& (sidedInv == null || sidedInv.canExtractItem(slot, inSlot, getFacingLazy()))) {
ItemStack out = handler.extractItem(slot, Integer.MAX_VALUE, false);
EntityTemporalItem entity = new EntityTemporalItem(world, spawn.x, spawn.y, spawn.z, out);
impulseEntityItem(spawn, entity);
world.spawnEntity(entity);
break;
}
}
}
示例4: transferOut
import net.minecraft.inventory.ISidedInventory; //导入依赖的package包/类
private ItemStack transferOut(BlockPos pos, boolean test) {
EnumFacing facing = getFacing().getOpposite();
Pair<IItemHandler, ISidedInventory> inv = getInventory(pos, facing);
if(inv.getKey() != null) {
IItemHandler handler = inv.getKey();
ISidedInventory tile = inv.getValue();
for(int slot = 0; slot < handler.getSlots(); slot++) {
ItemStack in = handler.getStackInSlot(slot);
if(!in.isEmpty() && (tile == null || tile.canExtractItem(slot, in, facing))) {
return handler.extractItem(slot, Integer.MAX_VALUE, test);
}
}
}
return ItemStack.EMPTY;
}
示例5: transferIn
import net.minecraft.inventory.ISidedInventory; //导入依赖的package包/类
private boolean transferIn(BlockPos pos, ItemStack inserted, boolean test) {
EnumFacing facing = getFacing();
Pair<IItemHandler, ISidedInventory> inv = getInventory(pos, facing);
if(inv.getKey() != null) {
IItemHandler handler = inv.getKey();
ISidedInventory tile = inv.getValue();
for(int slot = 0; slot < handler.getSlots(); slot++) {
ItemStack inSlot = handler.getStackInSlot(slot);
if(tile != null && !tile.canInsertItem(slot, inserted, facing)) return false;
if(inSlot.isEmpty() || (ItemHandlerHelper.canItemStacksStack(inSlot, inserted) && (inSlot.getCount() < inSlot.getMaxStackSize() && inSlot.getCount() < handler.getSlotLimit(slot)))) {
return handler.insertItem(slot, inserted, test) != inserted;
}
}
}
return false;
}
示例6: putStackInInventoryAllSlots
import net.minecraft.inventory.ISidedInventory; //导入依赖的package包/类
/**
* Attempts to place the passed stack in the inventory, using as many slots as required. Returns leftover items
*/
public static ItemStack putStackInInventoryAllSlots(IInventory inventoryIn, IInventory stack, ItemStack side, @Nullable EnumFacing p_174918_3_)
{
if (stack instanceof ISidedInventory && p_174918_3_ != null)
{
ISidedInventory isidedinventory = (ISidedInventory)stack;
int[] aint = isidedinventory.getSlotsForFace(p_174918_3_);
for (int k = 0; k < aint.length && !side.func_190926_b(); ++k)
{
side = insertStack(inventoryIn, stack, side, aint[k], p_174918_3_);
}
}
else
{
int i = stack.getSizeInventory();
for (int j = 0; j < i && !side.func_190926_b(); ++j)
{
side = insertStack(inventoryIn, stack, side, j, p_174918_3_);
}
}
return side;
}
示例7: WidgetSlot
import net.minecraft.inventory.ISidedInventory; //导入依赖的package包/类
public WidgetSlot(final IInventory inv, final int slot, final int x, final int y) {
super(inv, slot, x + 1, y + 1);
this.isISided = (inv instanceof ISidedInventory);
this.side = 0;
if (this.isISided) {
this.side = 0;
while (this.side < 6) {
final int[] arr$;
final int[] slots = arr$ = ((ISidedInventory)inv).getAccessibleSlotsFromSide(this.side);
for (final int s : arr$) {
if (s == slot) {
return;
}
}
++this.side;
}
}
}
示例8: getFirstExtractableItemStackSlot
import net.minecraft.inventory.ISidedInventory; //导入依赖的package包/类
private static int getFirstExtractableItemStackSlot(final IInventory inv, final int side) {
for (final int i : XUHelper.getInventorySideSlots(inv, side)) {
final ItemStack item = inv.getStackInSlot(i);
if (item != null && item.stackSize > 0 && (!(inv instanceof ISidedInventory) || ((ISidedInventory)inv).canExtractItem(i, item, side))) {
if (!item.getItem().hasContainerItem(item)) {
return i;
}
final ItemStack t = item.getItem().getContainerItem(item);
for (final int j : XUHelper.getInventorySideSlots(inv, side)) {
if (((j != i && inv.getStackInSlot(j) == null) || (j == i && item.stackSize == 1)) && inv.isItemValidForSlot(j, t) && (!(inv instanceof ISidedInventory) || ((ISidedInventory)inv).canInsertItem(i, t, side))) {
return i;
}
}
}
}
return -1;
}
示例9: isValidTileEntity
import net.minecraft.inventory.ISidedInventory; //导入依赖的package包/类
public static boolean isValidTileEntity(final TileEntity inv, final int side) {
if (inv == null) {
return false;
}
final ForgeDirection forgeSide = ForgeDirection.getOrientation(side);
final String classname = inv.getClass().toString();
if (classname.contains("thermalexpansion") && classname.contains("conduit")) {
return false;
}
if (inv instanceof IFluidHandler) {
final FluidTankInfo[] t = ((IFluidHandler)inv).getTankInfo(forgeSide);
if (t != null && t.length != 0) {
return true;
}
}
if (inv instanceof IInventory && ((IInventory)inv).getSizeInventory() > 0) {
if (!(inv instanceof ISidedInventory)) {
return true;
}
final int[] t2 = ((ISidedInventory)inv).getAccessibleSlotsFromSide(side);
if (t2 != null && t2.length != 0) {
return true;
}
}
return isRFEnergy(inv, forgeSide);
}
示例10: InventoryRange
import net.minecraft.inventory.ISidedInventory; //导入依赖的package包/类
public InventoryRange(IInventory inv, int side)
{
this.inv = inv;
this.side = side;
if(inv instanceof ISidedInventory)
{
sidedInv = (ISidedInventory)inv;
slots = sidedInv.getAccessibleSlotsFromSide(side);
}
else
{
slots = new int[inv.getSizeInventory()];
for(int i = 0; i < slots.length; i++)
slots[i] = i;
}
}
示例11: doInsertItem
import net.minecraft.inventory.ISidedInventory; //导入依赖的package包/类
public static int doInsertItem(Object into, ItemStack item, EnumFacing side, boolean insert) {
if (into == null || ItemStackTools.isNullStack(item)) {
return 0;
}
if (into instanceof ISidedInventory) {
return ItemUtil.doInsertItemInv((ISidedInventory) into, item, side, insert);
} else if (into instanceof IInventory) {
return ItemUtil.doInsertItemInv(getInventory((IInventory) into), item, side, insert);
} else if (into instanceof IItemHandler){
IItemHandler handler = (IItemHandler)into;
int startSize = ItemStackTools.getStackSize(item);
ItemStack res = ItemHandlerHelper.insertItemStacked(handler, item.copy(), !insert);
int val = ItemStackTools.isNullStack(res) ? startSize : startSize - ItemStackTools.getStackSize(res);
return val;
}
return 0;
}
示例12: getItemHandler
import net.minecraft.inventory.ISidedInventory; //导入依赖的package包/类
public static IItemHandler getItemHandler(World world, BlockPos pos, EnumFacing side, boolean includeEntities) {
TileEntity te = world.getTileEntity(pos);
if (te instanceof IDrawer) {
return new DrawerWrapper((IDrawer) te);
} else if (te instanceof IDrawerGroup) {
return new DrawerGroupWrapper((IDrawerGroup) te);
} else if (te == null || !te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)) {
IInventory inv = includeEntities ? TileEntityHopper.getInventoryAtPosition(world, pos.getX(), pos.getY(), pos.getZ()) : (te instanceof IInventory ? (IInventory) te : null);
if (inv != null) {
if (inv instanceof ISidedInventory) {
return new SidedInvWrapper((ISidedInventory) inv, side);
} else {
return new InvWrapper(inv);
}
} else
return null;
} else {
return te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side);
}
}
示例13: canInsertItem
import net.minecraft.inventory.ISidedInventory; //导入依赖的package包/类
@Override
public boolean canInsertItem(int slot, ItemStack itemstack, EnumFacing direction) {
if (slot < filters.length) {
return true;
}
try {
IInventory target = getRecursiveTarget();
if (target == null) {
return true;
}
if (target instanceof ISidedInventory) {
return ((ISidedInventory) target).canInsertItem(slot - filters.length, itemstack, facing_direction) && itemPassesFilter(itemstack);
}
return itemPassesFilter(itemstack);
} finally {
endRecursion();
}
}
示例14: canExtractItem
import net.minecraft.inventory.ISidedInventory; //导入依赖的package包/类
@Override
public boolean canExtractItem(int index, ItemStack itemstack, EnumFacing direction) {
if (index < filters.length) {
return true;
}
try {
IInventory target = getRecursiveTarget();
if (target == null) {
return true;
}
if (target instanceof ISidedInventory) {
return ((ISidedInventory) target).canExtractItem(index - filters.length, itemstack, facing_direction) && itemPassesFilter(itemstack);
}
return itemPassesFilter(itemstack);
} finally {
endRecursion();
}
}
示例15: canAccessSlot
import net.minecraft.inventory.ISidedInventory; //导入依赖的package包/类
public static boolean canAccessSlot(IInventory inv, int slot) {
if (inv instanceof ISidedInventory) {
ISidedInventory isi = (ISidedInventory) inv;
//O(n). Ugh.
for (EnumFacing face : EnumFacing.VALUES) {
int[] slots = isi.getSlotsForFace(face);
for (int j = 0; j < slots.length; j++) {
if (slots[j] == slot) {
return true;
}
}
}
} else {
return true;
}
return false;
}