Lots more moved
This commit is contained in:
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.recipe.RecipeType;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
|
||||
import appeng.util.helpers.ItemHandlerUtil;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class AppEngCraftingSlot extends AppEngSlot {
|
||||
|
||||
/**
|
||||
* The craft matrix inventory linked to this result slot.
|
||||
*/
|
||||
private final FixedItemInv craftMatrix;
|
||||
|
||||
/**
|
||||
* The player that is using the GUI where this slot resides.
|
||||
*/
|
||||
private final PlayerEntity thePlayer;
|
||||
|
||||
/**
|
||||
* The number of items that have been crafted so far. Gets passed to
|
||||
* ItemStack.onCrafted before being reset.
|
||||
*/
|
||||
private int amountCrafted;
|
||||
|
||||
public AppEngCraftingSlot(final PlayerEntity par1PlayerEntity, final FixedItemInv par2IInventory,
|
||||
final FixedItemInv par3IInventory, final int par4, final int par5, final int par6) {
|
||||
super(par3IInventory, par4, par5, par6);
|
||||
this.thePlayer = par1PlayerEntity;
|
||||
this.craftMatrix = par2IInventory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the stack is a valid item for this slot. Always true beside for the
|
||||
* armor slots.
|
||||
*/
|
||||
@Override
|
||||
public boolean canInsert(final ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not
|
||||
* ore and wood. Typically increases an internal count then calls
|
||||
* onCrafted(item).
|
||||
*/
|
||||
@Override
|
||||
protected void onCrafted(final ItemStack par1ItemStack, final int par2) {
|
||||
this.amountCrafted += par2;
|
||||
this.onCrafted(par1ItemStack);
|
||||
}
|
||||
|
||||
/**
|
||||
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not
|
||||
* ore and wood.
|
||||
*/
|
||||
@Override
|
||||
protected void onCrafted(final ItemStack par1ItemStack) {
|
||||
par1ItemStack.onCraft(this.thePlayer.world, this.thePlayer, this.amountCrafted);
|
||||
this.amountCrafted = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onTakeItem(final PlayerEntity playerIn, final ItemStack stack) {
|
||||
// FIXME FABRIC BasicEventHooks.firePlayerCraftingEvent(playerIn, stack, new WrapperInvItemHandler(this.craftMatrix));
|
||||
this.onCrafted(stack);
|
||||
// FIXME FABRIC: net.minecraftforge.common.ForgeHooks.setCraftingPlayer(playerIn);
|
||||
final CraftingInventory ic = new CraftingInventory(this.getContainer(), 3, 3);
|
||||
|
||||
for (int x = 0; x < this.craftMatrix.getSlotCount(); x++) {
|
||||
ic.setStack(x, this.craftMatrix.getInvStack(x));
|
||||
}
|
||||
|
||||
final DefaultedList<ItemStack> remainingItems = getRemainingItems(ic, playerIn.world);
|
||||
|
||||
ItemHandlerUtil.copy(ic, this.craftMatrix, false);
|
||||
|
||||
// FIXME FABRIC: net.minecraftforge.common.ForgeHooks.setCraftingPlayer(null);
|
||||
|
||||
for (int i = 0; i < remainingItems.size(); ++i) {
|
||||
final ItemStack itemstack1 = this.craftMatrix.getInvStack(i);
|
||||
final ItemStack itemstack2 = remainingItems.get(i);
|
||||
|
||||
if (!itemstack1.isEmpty()) {
|
||||
this.craftMatrix.getSlot(i).extract(1);
|
||||
}
|
||||
|
||||
if (!itemstack2.isEmpty()) {
|
||||
if (this.craftMatrix.getInvStack(i).isEmpty()) {
|
||||
ItemHandlerUtil.setStackInSlot(this.craftMatrix, i, itemstack2);
|
||||
} else if (!this.thePlayer.inventory.insertStack(itemstack2)) {
|
||||
this.thePlayer.dropItem(itemstack2, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrease the size of the stack in slot (first int arg) by the amount of the
|
||||
* second int arg. Returns the new stack.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack takeStack(final int par1) {
|
||||
if (this.hasStack()) {
|
||||
this.amountCrafted += Math.min(par1, this.getStack().getCount());
|
||||
}
|
||||
|
||||
return super.takeStack(par1);
|
||||
}
|
||||
|
||||
// TODO: This is really hacky and NEEDS to be solved with a full container/gui
|
||||
// refactoring.
|
||||
protected DefaultedList<ItemStack> getRemainingItems(CraftingInventory ic, World world) {
|
||||
return world.getRecipeManager().getRemainingStacks(RecipeType.CRAFTING, ic, world);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import alexiil.mc.lib.attributes.item.SingleItemSlot;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.inventory.SimpleInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class AppEngSlot extends Slot {
|
||||
private static Inventory emptyInventory = new SimpleInventory(0);
|
||||
private final FixedItemInv itemHandler;
|
||||
private final SingleItemSlot backingSlot;
|
||||
private final int index;
|
||||
|
||||
private final int defX;
|
||||
private final int defY;
|
||||
private boolean isDraggable = true;
|
||||
private boolean isPlayerSide = false;
|
||||
private AEBaseContainer myContainer = null;
|
||||
private int IIcon = -1;
|
||||
private CalculatedValidity isValid;
|
||||
private boolean isDisplay = false;
|
||||
|
||||
public AppEngSlot(final FixedItemInv inv, final int idx, final int x, final int y) {
|
||||
super(emptyInventory, idx, x, y);
|
||||
this.itemHandler = inv;
|
||||
this.index = idx;
|
||||
this.backingSlot = inv.getSlot(idx);
|
||||
|
||||
this.defX = x;
|
||||
this.defY = y;
|
||||
this.setIsValid(CalculatedValidity.NotAvailable);
|
||||
}
|
||||
|
||||
public Slot setNotDraggable() {
|
||||
this.setDraggable(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Slot setPlayerSide() {
|
||||
this.isPlayerSide = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTooltip() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void clearStack() {
|
||||
backingSlot.set(ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsert(@Nonnull final ItemStack stack) {
|
||||
if (this.isSlotEnabled()) {
|
||||
return this.backingSlot.isValid(stack);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getStack() {
|
||||
if (!this.isSlotEnabled()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (this.index >= this.itemHandler.getSlotCount()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (this.isDisplay()) {
|
||||
this.setDisplay(false);
|
||||
return this.getDisplayStack();
|
||||
}
|
||||
|
||||
return this.backingSlot.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStack(final ItemStack stack) {
|
||||
if (this.isSlotEnabled()) {
|
||||
this.backingSlot.set(stack);
|
||||
this.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyContainerSlotChanged() {
|
||||
if (this.getContainer() != null) {
|
||||
this.getContainer().onSlotChange(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
super.markDirty();
|
||||
this.setIsValid(CalculatedValidity.NotAvailable);
|
||||
notifyContainerSlotChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxStackAmount() {
|
||||
return this.backingSlot.getMaxAmount(ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxStackAmount(@Nonnull ItemStack stack) {
|
||||
return Math.min(this.getMaxStackAmount(), stack.getMaxCount());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeItems(final PlayerEntity par1PlayerEntity) {
|
||||
if (this.isSlotEnabled()) {
|
||||
return this.backingSlot.couldExtractAnything();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack takeStack(int amount) {
|
||||
return this.backingSlot.extract(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasStack() {
|
||||
return !backingSlot.get().isEmpty();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@Environment(EnvType.CLIENT)
|
||||
public boolean doDrawHoveringEffect() {
|
||||
return this.isSlotEnabled();
|
||||
}
|
||||
|
||||
public boolean isSlotEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public ItemStack getDisplayStack() {
|
||||
return this.backingSlot.get();
|
||||
}
|
||||
|
||||
public float getOpacityOfIcon() {
|
||||
return 0.4f;
|
||||
}
|
||||
|
||||
public boolean renderIconWithItem() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getIcon() {
|
||||
return this.getIIcon();
|
||||
}
|
||||
|
||||
public boolean isPlayerSide() {
|
||||
return this.isPlayerSide;
|
||||
}
|
||||
|
||||
public boolean shouldDisplay() {
|
||||
return this.isSlotEnabled();
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return this.defX;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return this.defY;
|
||||
}
|
||||
|
||||
private int getIIcon() {
|
||||
return this.IIcon;
|
||||
}
|
||||
|
||||
public void setIIcon(final int iIcon) {
|
||||
this.IIcon = iIcon;
|
||||
}
|
||||
|
||||
private boolean isDisplay() {
|
||||
return this.isDisplay;
|
||||
}
|
||||
|
||||
public void setDisplay(final boolean isDisplay) {
|
||||
this.isDisplay = isDisplay;
|
||||
}
|
||||
|
||||
public boolean isDraggable() {
|
||||
return this.isDraggable;
|
||||
}
|
||||
|
||||
private void setDraggable(final boolean isDraggable) {
|
||||
this.isDraggable = isDraggable;
|
||||
}
|
||||
|
||||
void setPlayerSide(final boolean isPlayerSide) {
|
||||
this.isPlayerSide = isPlayerSide;
|
||||
}
|
||||
|
||||
public CalculatedValidity getIsValid() {
|
||||
return this.isValid;
|
||||
}
|
||||
|
||||
public void setIsValid(final CalculatedValidity isValid) {
|
||||
this.isValid = isValid;
|
||||
}
|
||||
|
||||
protected AEBaseContainer getContainer() {
|
||||
return this.myContainer;
|
||||
}
|
||||
|
||||
public void setContainer(final AEBaseContainer myContainer) {
|
||||
this.myContainer = myContainer;
|
||||
}
|
||||
|
||||
public enum CalculatedValidity {
|
||||
NotAvailable, Valid, Invalid
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.util.inv.WrapperInvItemHandler;
|
||||
|
||||
public class CraftingMatrixSlot extends AppEngSlot {
|
||||
private final AEBaseContainer c;
|
||||
private final Inventory wrappedInventory;
|
||||
|
||||
public CraftingMatrixSlot(final AEBaseContainer c, final FixedItemInv par1iInventory, final int par2,
|
||||
final int par3, final int par4) {
|
||||
super(par1iInventory, par2, par3, par4);
|
||||
this.c = c;
|
||||
this.wrappedInventory = new WrapperInvItemHandler(par1iInventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearStack() {
|
||||
super.clearStack();
|
||||
this.c.onContentChanged(this.wrappedInventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStack(final ItemStack par1ItemStack) {
|
||||
super.setStack(par1ItemStack);
|
||||
this.c.onContentChanged(this.wrappedInventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerSide() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack takeStack(final int par1) {
|
||||
final ItemStack is = super.takeStack(par1);
|
||||
this.c.onContentChanged(this.wrappedInventory);
|
||||
return is;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,292 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.recipe.RecipeType;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IStorageMonitorable;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.ContainerNull;
|
||||
import appeng.container.implementations.CraftingTermContainer;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.items.storage.ViewCellItem;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.helpers.ItemHandlerUtil;
|
||||
import appeng.util.inv.AdaptorFixedInv;
|
||||
import appeng.util.inv.WrapperCursorItemHandler;
|
||||
import appeng.util.inv.WrapperInvItemHandler;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class CraftingTermSlot extends AppEngCraftingSlot {
|
||||
|
||||
private final FixedItemInv craftInv;
|
||||
private final FixedItemInv pattern;
|
||||
|
||||
private final IActionSource mySrc;
|
||||
private final IEnergySource energySrc;
|
||||
private final IStorageMonitorable storage;
|
||||
private final IContainerCraftingPacket container;
|
||||
|
||||
public CraftingTermSlot(final PlayerEntity player, final IActionSource mySrc, final IEnergySource energySrc,
|
||||
final IStorageMonitorable storage, final FixedItemInv cMatrix, final FixedItemInv secondMatrix,
|
||||
final FixedItemInv output, final int x, final int y, final IContainerCraftingPacket ccp) {
|
||||
super(player, cMatrix, output, 0, x, y);
|
||||
this.energySrc = energySrc;
|
||||
this.storage = storage;
|
||||
this.mySrc = mySrc;
|
||||
this.pattern = cMatrix;
|
||||
this.craftInv = secondMatrix;
|
||||
this.container = ccp;
|
||||
}
|
||||
|
||||
public FixedItemInv getCraftingMatrix() {
|
||||
return this.craftInv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeItems(final PlayerEntity par1PlayerEntity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onTakeItem(final PlayerEntity p, final ItemStack is) {
|
||||
return is;
|
||||
}
|
||||
|
||||
public void doClick(final InventoryAction action, final PlayerEntity who) {
|
||||
if (this.getStack().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (Platform.isClient()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final IMEMonitor<IAEItemStack> inv = this.storage
|
||||
.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||
final int howManyPerCraft = this.getStack().getCount();
|
||||
int maxTimesToCraft = 0;
|
||||
|
||||
InventoryAdaptor ia = null;
|
||||
if (action == InventoryAction.CRAFT_SHIFT) // craft into player inventory...
|
||||
{
|
||||
ia = InventoryAdaptor.getAdaptor(who);
|
||||
maxTimesToCraft = (int) Math.floor((double) this.getStack().getMaxCount() / (double) howManyPerCraft);
|
||||
} else if (action == InventoryAction.CRAFT_STACK) // craft into hand, full stack
|
||||
{
|
||||
ia = new AdaptorFixedInv(new WrapperCursorItemHandler(who.inventory));
|
||||
maxTimesToCraft = (int) Math.floor((double) this.getStack().getMaxCount() / (double) howManyPerCraft);
|
||||
} else
|
||||
// pick up what was crafted...
|
||||
{
|
||||
ia = new AdaptorFixedInv(new WrapperCursorItemHandler(who.inventory));
|
||||
maxTimesToCraft = 1;
|
||||
}
|
||||
|
||||
maxTimesToCraft = this.capCraftingAttempts(maxTimesToCraft);
|
||||
|
||||
if (ia == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ItemStack rs = this.getStack().copy();
|
||||
if (rs.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int x = 0; x < maxTimesToCraft; x++) {
|
||||
if (ia.simulateAdd(rs).isEmpty()) {
|
||||
final IItemList<IAEItemStack> all = inv.getStorageList();
|
||||
final ItemStack extra = ia.addItems(this.craftItem(who, rs, inv, all));
|
||||
if (!extra.isEmpty()) {
|
||||
final List<ItemStack> drops = new ArrayList<>();
|
||||
drops.add(extra);
|
||||
Platform.spawnDrops(who.world,
|
||||
new BlockPos((int) who.getX(), (int) who.getY(), (int) who.getZ()), drops);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: This is really hacky and NEEDS to be solved with a full container/gui
|
||||
// refactoring.
|
||||
protected Recipe<CraftingInventory> findRecipe(CraftingInventory ic, World world) {
|
||||
if (this.container instanceof CraftingTermContainer) {
|
||||
final CraftingTermContainer containerTerminal = (CraftingTermContainer) this.container;
|
||||
final Recipe<CraftingInventory> recipe = containerTerminal.getCurrentRecipe();
|
||||
|
||||
if (recipe != null && recipe.matches(ic, world)) {
|
||||
return containerTerminal.getCurrentRecipe();
|
||||
}
|
||||
}
|
||||
|
||||
return world.getRecipeManager().getFirstMatch(RecipeType.CRAFTING, ic, world).orElse(null);
|
||||
}
|
||||
|
||||
// TODO: This is really hacky and NEEDS to be solved with a full container/gui
|
||||
// refactoring.
|
||||
protected DefaultedList<ItemStack> getRemainingItems(CraftingInventory ic, World world) {
|
||||
if (this.container instanceof CraftingTermContainer) {
|
||||
final CraftingTermContainer containerTerminal = (CraftingTermContainer) this.container;
|
||||
final Recipe<CraftingInventory> recipe = containerTerminal.getCurrentRecipe();
|
||||
|
||||
if (recipe != null && recipe.matches(ic, world)) {
|
||||
return recipe.getRemainingStacks(ic);
|
||||
}
|
||||
}
|
||||
|
||||
return super.getRemainingItems(ic, world);
|
||||
}
|
||||
|
||||
private int capCraftingAttempts(final int maxTimesToCraft) {
|
||||
return maxTimesToCraft;
|
||||
}
|
||||
|
||||
private ItemStack craftItem(final PlayerEntity p, final ItemStack request, final IMEMonitor<IAEItemStack> inv,
|
||||
final IItemList all) {
|
||||
// update crafting matrix...
|
||||
ItemStack is = this.getStack();
|
||||
|
||||
if (!is.isEmpty() && ItemStack.areItemsEqual(request, is)) {
|
||||
final ItemStack[] set = new ItemStack[this.getPattern().getSlotCount()];
|
||||
// Safeguard for empty slots in the inventory for now
|
||||
Arrays.fill(set, ItemStack.EMPTY);
|
||||
|
||||
// add one of each item to the items on the board...
|
||||
if (Platform.isServer()) {
|
||||
final CraftingInventory ic = new CraftingInventory(new ContainerNull(), 3, 3);
|
||||
for (int x = 0; x < 9; x++) {
|
||||
ic.setStack(x, this.getPattern().getInvStack(x));
|
||||
}
|
||||
|
||||
final Recipe<CraftingInventory> r = this.findRecipe(ic, p.world);
|
||||
|
||||
if (r == null) {
|
||||
final Item target = request.getItem();
|
||||
// FIXME FABRIC: This entire code-path may be pointless because RepairItemRecipe is of type CRAFTING
|
||||
if (target.isDamageable() /* FIXME FABRIC && target.isRepairable(request) */) {
|
||||
boolean isBad = false;
|
||||
for (int x = 0; x < ic.size(); x++) {
|
||||
final ItemStack pis = ic.getStack(x);
|
||||
if (pis.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
if (pis.getItem() != target) {
|
||||
isBad = true;
|
||||
}
|
||||
}
|
||||
if (!isBad) {
|
||||
super.onTakeItem(p, is);
|
||||
// actually necessary to cleanup this case...
|
||||
p.currentScreenHandler.onContentChanged(new WrapperInvItemHandler(this.craftInv));
|
||||
return request;
|
||||
}
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
is = r.craft(ic);
|
||||
|
||||
if (inv != null) {
|
||||
for (int x = 0; x < this.getPattern().getSlotCount(); x++) {
|
||||
if (!this.getPattern().getInvStack(x).isEmpty()) {
|
||||
set[x] = Platform.extractItemsByRecipe(this.energySrc, this.mySrc, inv, p.world, r, is, ic,
|
||||
this.getPattern().getInvStack(x), x, all, Actionable.MODULATE,
|
||||
ViewCellItem.createFilter(this.container.getViewCells()));
|
||||
ic.setStack(x, set[x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.preCraft(p, inv, set, is)) {
|
||||
this.makeItem(p, is);
|
||||
|
||||
this.postCraft(p, inv, set, is);
|
||||
}
|
||||
|
||||
p.currentScreenHandler.onContentChanged(new WrapperInvItemHandler(this.craftInv));
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
private boolean preCraft(final PlayerEntity p, final IMEMonitor<IAEItemStack> inv, final ItemStack[] set,
|
||||
final ItemStack result) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void makeItem(final PlayerEntity p, final ItemStack is) {
|
||||
super.onTakeItem(p, is);
|
||||
}
|
||||
|
||||
private void postCraft(final PlayerEntity p, final IMEMonitor<IAEItemStack> inv, final ItemStack[] set,
|
||||
final ItemStack result) {
|
||||
final List<ItemStack> drops = new ArrayList<>();
|
||||
|
||||
// add one of each item to the items on the board...
|
||||
if (Platform.isServer()) {
|
||||
// set new items onto the crafting table...
|
||||
for (int x = 0; x < this.craftInv.getSlotCount(); x++) {
|
||||
if (this.craftInv.getInvStack(x).isEmpty()) {
|
||||
ItemHandlerUtil.setStackInSlot(this.craftInv, x, set[x]);
|
||||
} else if (!set[x].isEmpty()) {
|
||||
// eek! put it back!
|
||||
final IAEItemStack fail = inv.injectItems(AEItemStack.fromItemStack(set[x]), Actionable.MODULATE,
|
||||
this.mySrc);
|
||||
if (fail != null) {
|
||||
drops.add(fail.createItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (drops.size() > 0) {
|
||||
Platform.spawnDrops(p.world, new BlockPos((int) p.getX(), (int) p.getY(), (int) p.getZ()), drops);
|
||||
}
|
||||
}
|
||||
|
||||
FixedItemInv getPattern() {
|
||||
return this.pattern;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
public class DisabledSlot extends AppEngSlot {
|
||||
|
||||
public DisabledSlot(final FixedItemInv par1iInventory, final int slotIndex, final int x, final int y) {
|
||||
super(par1iInventory, slotIndex, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsert(final ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeItems(final PlayerEntity par1PlayerEntity) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
public class FakeBlacklistSlot extends FakeTypeOnlySlot {
|
||||
|
||||
public FakeBlacklistSlot(final FixedItemInv inv, final int idx, final int x, final int y) {
|
||||
super(inv, idx, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getOpacityOfIcon() {
|
||||
return 0.8f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderIconWithItem() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIcon() {
|
||||
if (this.hasStack()) {
|
||||
return this.getStack().getCount() > 0 ? 16 + 14 : 14;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
public class FakeCraftingMatrixSlot extends FakeSlot {
|
||||
|
||||
public FakeCraftingMatrixSlot(final FixedItemInv inv, final int idx, final int x, final int y) {
|
||||
super(inv, idx, x, y);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class FakeSlot extends AppEngSlot {
|
||||
|
||||
public FakeSlot(final FixedItemInv inv, final int idx, final int x, final int y) {
|
||||
super(inv, idx, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onTakeItem(final PlayerEntity par1PlayerEntity, final ItemStack par2ItemStack) {
|
||||
return par2ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack takeStack(final int par1) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsert(final ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStack(ItemStack is) {
|
||||
if (!is.isEmpty()) {
|
||||
is = is.copy();
|
||||
}
|
||||
|
||||
super.setStack(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeItems(final PlayerEntity par1PlayerEntity) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class FakeTypeOnlySlot extends FakeSlot {
|
||||
|
||||
public FakeTypeOnlySlot(final FixedItemInv inv, final int idx, final int x, final int y) {
|
||||
super(inv, idx, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStack(ItemStack is) {
|
||||
if (!is.isEmpty()) {
|
||||
is = is.copy();
|
||||
if (is.getCount() > 1) {
|
||||
is.setCount(1);
|
||||
} else if (is.getCount() < -1) {
|
||||
is.setCount(-1);
|
||||
}
|
||||
}
|
||||
|
||||
super.setStack(is);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2018, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
/**
|
||||
* @author BrockWS
|
||||
* @version rv6 - 2/05/2018
|
||||
* @since rv6 2/05/2018
|
||||
*/
|
||||
public interface IOptionalSlot {
|
||||
default boolean isRenderDisabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
int getSourceX();
|
||||
|
||||
int getSourceY();
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
public interface IOptionalSlotHost {
|
||||
|
||||
boolean isSlotEnabled(int idx);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
public class InaccessibleSlot extends AppEngSlot {
|
||||
|
||||
private ItemStack dspStack = ItemStack.EMPTY;
|
||||
|
||||
public InaccessibleSlot(final FixedItemInv i, final int slotIdx, final int x, final int y) {
|
||||
super(i, slotIdx, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsert(final ItemStack i) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
super.markDirty();
|
||||
this.dspStack = ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeItems(final PlayerEntity par1PlayerEntity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDisplayStack() {
|
||||
if (this.dspStack.isEmpty()) {
|
||||
final ItemStack dsp = super.getDisplayStack();
|
||||
if (!dsp.isEmpty()) {
|
||||
this.dspStack = dsp.copy();
|
||||
}
|
||||
}
|
||||
return this.dspStack;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
import appeng.container.implementations.MolecularAssemblerContainer;
|
||||
|
||||
public class MolecularAssemblerPatternSlot extends AppEngSlot {
|
||||
|
||||
private final MolecularAssemblerContainer mac;
|
||||
|
||||
private final int slotIdx;
|
||||
|
||||
public MolecularAssemblerPatternSlot(final MolecularAssemblerContainer mac, final FixedItemInv i, final int slotIdx,
|
||||
final int x, final int y) {
|
||||
super(i, slotIdx, x, y);
|
||||
this.mac = mac;
|
||||
this.slotIdx = slotIdx;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsert(final ItemStack i) {
|
||||
return this.mac.isValidItemForSlot(slotIdx, i);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
public class NormalSlot extends AppEngSlot {
|
||||
|
||||
public NormalSlot(final FixedItemInv inv, final int slot, final int xPos, final int yPos) {
|
||||
super(inv, slot, xPos, yPos);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
public class OptionalFakeSlot extends FakeSlot implements IOptionalSlot {
|
||||
|
||||
private final int srcX;
|
||||
private final int srcY;
|
||||
private final int groupNum;
|
||||
private final IOptionalSlotHost host;
|
||||
private boolean renderDisabled = true;
|
||||
|
||||
public OptionalFakeSlot(final FixedItemInv inv, final IOptionalSlotHost containerBus, final int idx, final int x,
|
||||
final int y, final int offX, final int offY, final int groupNum) {
|
||||
super(inv, idx, x + offX * 18, y + offY * 18);
|
||||
this.srcX = x;
|
||||
this.srcY = y;
|
||||
this.groupNum = groupNum;
|
||||
this.host = containerBus;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getStack() {
|
||||
if (!this.isSlotEnabled()) {
|
||||
if (!this.getDisplayStack().isEmpty()) {
|
||||
this.clearStack();
|
||||
}
|
||||
}
|
||||
|
||||
return super.getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled() {
|
||||
if (this.host == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.host.isSlotEnabled(this.groupNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRenderDisabled() {
|
||||
return this.renderDisabled;
|
||||
}
|
||||
|
||||
public void setRenderDisabled(final boolean renderDisabled) {
|
||||
this.renderDisabled = renderDisabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSourceX() {
|
||||
return this.srcX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSourceY() {
|
||||
return this.srcY;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
public class OptionalNormalSlot extends AppEngSlot implements IOptionalSlot {
|
||||
|
||||
private final int groupNum;
|
||||
private final IOptionalSlotHost host;
|
||||
|
||||
public OptionalNormalSlot(final FixedItemInv inv, final IOptionalSlotHost containerBus, final int slot,
|
||||
final int xPos, final int yPos, final int groupNum) {
|
||||
super(inv, slot, xPos, yPos);
|
||||
this.groupNum = groupNum;
|
||||
this.host = containerBus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled() {
|
||||
if (this.host == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.host.isSlotEnabled(this.groupNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSourceX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSourceY() {
|
||||
return this.y;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
public class OptionalRestrictedInputSlot extends RestrictedInputSlot {
|
||||
|
||||
private final int groupNum;
|
||||
private final IOptionalSlotHost host;
|
||||
|
||||
public OptionalRestrictedInputSlot(final PlacableItemType valid, final FixedItemInv i, final IOptionalSlotHost host,
|
||||
final int slotIndex, final int x, final int y, final int grpNum, final PlayerInventory invPlayer) {
|
||||
super(valid, i, slotIndex, x, y, invPlayer);
|
||||
this.groupNum = grpNum;
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled() {
|
||||
if (this.host == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.host.isSlotEnabled(this.groupNum);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
public class OptionalTypeOnlyFakeSlot extends OptionalFakeSlot {
|
||||
|
||||
public OptionalTypeOnlyFakeSlot(final FixedItemInv inv, final IOptionalSlotHost containerBus, final int idx,
|
||||
final int x, final int y, final int offX, final int offY, final int groupNum) {
|
||||
super(inv, containerBus, idx, x, y, offX, offY, groupNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStack(ItemStack is) {
|
||||
if (!is.isEmpty()) {
|
||||
is = is.copy();
|
||||
if (is.getCount() > 1) {
|
||||
is.setCount(1);
|
||||
} else if (is.getCount() < -1) {
|
||||
is.setCount(-1);
|
||||
}
|
||||
}
|
||||
|
||||
super.setStack(is);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
public class OutputSlot extends AppEngSlot {
|
||||
|
||||
public OutputSlot(final FixedItemInv a, final int b, final int c, final int d, final int i) {
|
||||
super(a, b, c, d);
|
||||
this.setIIcon(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsert(final ItemStack i) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
public class PatternOutputsSlot extends OptionalFakeSlot {
|
||||
|
||||
public PatternOutputsSlot(final FixedItemInv inv, final IOptionalSlotHost containerBus, final int idx, final int x,
|
||||
final int y, final int offX, final int offY, final int groupNum) {
|
||||
super(inv, containerBus, idx, x, y, offX, offY, groupNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldDisplay() {
|
||||
return super.isSlotEnabled();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.storage.IStorageMonitorable;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.core.sync.BasePacket;
|
||||
import appeng.core.sync.packets.PatternSlotPacket;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
|
||||
public class PatternTermSlot extends CraftingTermSlot {
|
||||
|
||||
private final int groupNum;
|
||||
private final IOptionalSlotHost host;
|
||||
|
||||
public PatternTermSlot(final PlayerEntity player, final IActionSource mySrc, final IEnergySource energySrc,
|
||||
final IStorageMonitorable storage, final FixedItemInv cMatrix, final FixedItemInv secondMatrix,
|
||||
final FixedItemInv output, final int x, final int y, final IOptionalSlotHost h, final int groupNumber,
|
||||
final IContainerCraftingPacket c) {
|
||||
super(player, mySrc, energySrc, storage, cMatrix, secondMatrix, output, x, y, c);
|
||||
|
||||
this.host = h;
|
||||
this.groupNum = groupNumber;
|
||||
}
|
||||
|
||||
public BasePacket getRequest(final boolean shift) {
|
||||
return new PatternSlotPacket(this.getPattern(),
|
||||
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(this.getStack()),
|
||||
shift);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
if (!this.isSlotEnabled()) {
|
||||
if (!this.getDisplayStack().isEmpty()) {
|
||||
this.clearStack();
|
||||
}
|
||||
}
|
||||
|
||||
return super.getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled() {
|
||||
if (this.host == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.host.isSlotEnabled(this.groupNum);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
public class PlayerHotBarSlot extends AppEngSlot {
|
||||
|
||||
public PlayerHotBarSlot(final FixedItemInv par1iInventory, final int par2, final int par3, final int par4) {
|
||||
super(par1iInventory, par2, par3, par4);
|
||||
this.setPlayerSide(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
// there is nothing special about this slot, its simply used to represent the players inventory, vs a container slot.
|
||||
|
||||
public class PlayerInvSlot extends AppEngSlot {
|
||||
|
||||
public PlayerInvSlot(final FixedItemInv par1iInventory, final int idx, final int x, final int y) {
|
||||
super(par1iInventory, idx, x, y);
|
||||
|
||||
this.setPlayerSide(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,294 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container.slot;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.fabricmc.fabric.api.registry.FuelRegistry;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.tag.ItemTags;
|
||||
import net.minecraft.tag.Tag;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IItems;
|
||||
import appeng.api.definitions.IMaterials;
|
||||
import appeng.api.features.INetworkEncodable;
|
||||
import appeng.api.implementations.ICraftingPatternItem;
|
||||
import appeng.api.implementations.items.IBiometricCard;
|
||||
import appeng.api.implementations.items.ISpatialStorageCell;
|
||||
import appeng.api.implementations.items.IStorageComponent;
|
||||
import appeng.api.implementations.items.IUpgradeModule;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.storage.cells.ICellWorkbenchItem;
|
||||
import appeng.items.misc.EncodedPatternItem;
|
||||
import appeng.recipes.handlers.GrinderRecipes;
|
||||
import appeng.tile.misc.InscriberRecipes;
|
||||
import appeng.util.Platform;
|
||||
|
||||
/**
|
||||
* @author AlgorithmX2
|
||||
* @author thatsIch
|
||||
* @version rv2
|
||||
* @since rv0
|
||||
*/
|
||||
public class RestrictedInputSlot extends AppEngSlot {
|
||||
|
||||
private static final List<Identifier> METAL_INGOT_TAGS = ImmutableList.of(
|
||||
new Identifier("forge:ingots/copper"), new Identifier("forge:ingots/tin"),
|
||||
new Identifier("forge:ingots/iron"), new Identifier("forge:ingots/gold"),
|
||||
new Identifier("forge:ingots/lead"), new Identifier("forge:ingots/bronze"),
|
||||
new Identifier("forge:ingots/brass"), new Identifier("forge:ingots/nickel"),
|
||||
new Identifier("forge:ingots/aluminium"));
|
||||
|
||||
private final PlacableItemType which;
|
||||
private final PlayerInventory p;
|
||||
private boolean allowEdit = true;
|
||||
private int stackLimit = -1;
|
||||
|
||||
public RestrictedInputSlot(final PlacableItemType valid, final FixedItemInv i, final int slotIndex, final int x,
|
||||
final int y, final PlayerInventory p) {
|
||||
super(i, slotIndex, x, y);
|
||||
this.which = valid;
|
||||
this.setIIcon(valid.IIcon);
|
||||
this.p = p;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxStackAmount() {
|
||||
if (this.stackLimit != -1) {
|
||||
return this.stackLimit;
|
||||
}
|
||||
return super.getMaxStackAmount();
|
||||
}
|
||||
|
||||
public boolean isValid(final ItemStack is, final World theWorld) {
|
||||
if (this.which == PlacableItemType.VALID_ENCODED_PATTERN_W_OUTPUT) {
|
||||
final ICraftingPatternDetails ap = is.getItem() instanceof ICraftingPatternItem
|
||||
? ((ICraftingPatternItem) is.getItem()).getPatternForItem(is, theWorld)
|
||||
: null;
|
||||
return ap != null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Slot setStackLimit(final int i) {
|
||||
this.stackLimit = i;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsert(final ItemStack i) {
|
||||
if (!this.getContainer().isValidForSlot(this, i)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (i.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (i.getItem() == Items.AIR) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!super.canInsert(i)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.isAllowEdit()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IMaterials materials = definitions.materials();
|
||||
final IItems items = definitions.items();
|
||||
|
||||
switch (this.which) {
|
||||
case ENCODED_CRAFTING_PATTERN:
|
||||
if (i.getItem() instanceof ICraftingPatternItem) {
|
||||
final ICraftingPatternItem b = (ICraftingPatternItem) i.getItem();
|
||||
final ICraftingPatternDetails de = b.getPatternForItem(i, this.p.player.world);
|
||||
if (de != null) {
|
||||
return de.isCraftable();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
case VALID_ENCODED_PATTERN_W_OUTPUT:
|
||||
case ENCODED_PATTERN_W_OUTPUT:
|
||||
case ENCODED_PATTERN: {
|
||||
if (i.getItem() instanceof ICraftingPatternItem) {
|
||||
return true;
|
||||
}
|
||||
// ICraftingPatternDetails pattern = i.getItem() instanceof ICraftingPatternItem
|
||||
// ?
|
||||
// ((ICraftingPatternItem)
|
||||
// i.getItem()).getPatternForItem( i ) : null;
|
||||
return false;// pattern != null;
|
||||
}
|
||||
case BLANK_PATTERN:
|
||||
return materials.blankPattern().isSameAs(i);
|
||||
|
||||
case PATTERN:
|
||||
|
||||
if (i.getItem() instanceof ICraftingPatternItem) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return materials.blankPattern().isSameAs(i);
|
||||
|
||||
case INSCRIBER_PLATE:
|
||||
if (materials.namePress().isSameAs(i)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return InscriberRecipes.isValidOptionalIngredient(p.player.world, i);
|
||||
|
||||
case INSCRIBER_INPUT:
|
||||
return true;/*
|
||||
* for (ItemStack is : Inscribe.inputs) if ( Platform.isSameItemPrecise( is, i )
|
||||
* ) return true; return false;
|
||||
*/
|
||||
|
||||
case METAL_INGOTS:
|
||||
|
||||
return isMetalIngot(i);
|
||||
|
||||
case VIEW_CELL:
|
||||
return items.viewCell().isSameAs(i);
|
||||
case ORE:
|
||||
return GrinderRecipes.isValidIngredient(p.player.world, i);
|
||||
case FUEL:
|
||||
return FuelRegistry.INSTANCE.get(i.getItem()) > 0;
|
||||
case POWERED_TOOL:
|
||||
return Platform.isChargeable(i);
|
||||
case QE_SINGULARITY:
|
||||
return materials.qESingularity().isSameAs(i);
|
||||
|
||||
case RANGE_BOOSTER:
|
||||
return materials.wirelessBooster().isSameAs(i);
|
||||
|
||||
case SPATIAL_STORAGE_CELLS:
|
||||
return i.getItem() instanceof ISpatialStorageCell
|
||||
&& ((ISpatialStorageCell) i.getItem()).isSpatialStorage(i);
|
||||
case STORAGE_CELLS:
|
||||
return AEApi.instance().registries().cell().isCellHandled(i);
|
||||
case WORKBENCH_CELL:
|
||||
return i.getItem() instanceof ICellWorkbenchItem && ((ICellWorkbenchItem) i.getItem()).isEditable(i);
|
||||
case STORAGE_COMPONENT:
|
||||
return i.getItem() instanceof IStorageComponent
|
||||
&& ((IStorageComponent) i.getItem()).isStorageComponent(i);
|
||||
case TRASH:
|
||||
if (AEApi.instance().registries().cell().isCellHandled(i)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !(i.getItem() instanceof IStorageComponent
|
||||
&& ((IStorageComponent) i.getItem()).isStorageComponent(i));
|
||||
case ENCODABLE_ITEM:
|
||||
return i.getItem() instanceof INetworkEncodable
|
||||
|| AEApi.instance().registries().wireless().isWirelessTerminal(i);
|
||||
case BIOMETRIC_CARD:
|
||||
return i.getItem() instanceof IBiometricCard;
|
||||
case UPGRADES:
|
||||
return i.getItem() instanceof IUpgradeModule && ((IUpgradeModule) i.getItem()).getType(i) != null;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeItems(final PlayerEntity par1PlayerEntity) {
|
||||
return this.isAllowEdit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDisplayStack() {
|
||||
if (Platform.isClient() && (this.which == PlacableItemType.ENCODED_PATTERN)) {
|
||||
final ItemStack is = super.getStack();
|
||||
if (!is.isEmpty() && is.getItem() instanceof EncodedPatternItem) {
|
||||
final EncodedPatternItem iep = (EncodedPatternItem) is.getItem();
|
||||
final ItemStack out = iep.getOutput(p.player.world, is);
|
||||
if (!out.isEmpty()) {
|
||||
return out;
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.getStack();
|
||||
}
|
||||
|
||||
public static boolean isMetalIngot(final ItemStack i) {
|
||||
if (Platform.itemComparisons().isSameItem(i, new ItemStack(Items.IRON_INGOT))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: Can be optimized by somehow caching the Tag's
|
||||
Item item = i.getItem();
|
||||
for (Identifier tagName : METAL_INGOT_TAGS) {
|
||||
Tag<Item> ingotTag = ItemTags.getContainer().get(tagName);
|
||||
if (ingotTag != null && item.isIn(ingotTag)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isAllowEdit() {
|
||||
return this.allowEdit;
|
||||
}
|
||||
|
||||
public void setAllowEdit(final boolean allowEdit) {
|
||||
this.allowEdit = allowEdit;
|
||||
}
|
||||
|
||||
public enum PlacableItemType {
|
||||
STORAGE_CELLS(15), ORE(16 + 15), STORAGE_COMPONENT(3 * 16 + 15),
|
||||
|
||||
ENCODABLE_ITEM(4 * 16 + 15), TRASH(5 * 16 + 15), VALID_ENCODED_PATTERN_W_OUTPUT(7 * 16 + 15),
|
||||
ENCODED_PATTERN_W_OUTPUT(7 * 16 + 15),
|
||||
|
||||
ENCODED_CRAFTING_PATTERN(7 * 16 + 15), ENCODED_PATTERN(7 * 16 + 15), PATTERN(8 * 16 + 15),
|
||||
BLANK_PATTERN(8 * 16 + 15), POWERED_TOOL(9 * 16 + 15),
|
||||
|
||||
RANGE_BOOSTER(6 * 16 + 15), QE_SINGULARITY(10 * 16 + 15), SPATIAL_STORAGE_CELLS(11 * 16 + 15),
|
||||
|
||||
FUEL(12 * 16 + 15), UPGRADES(13 * 16 + 15), WORKBENCH_CELL(15), BIOMETRIC_CARD(14 * 16 + 15),
|
||||
VIEW_CELL(4 * 16 + 14),
|
||||
|
||||
INSCRIBER_PLATE(2 * 16 + 14), INSCRIBER_INPUT(3 * 16 + 14), METAL_INGOTS(3 * 16 + 14);
|
||||
|
||||
public final int IIcon;
|
||||
|
||||
PlacableItemType(final int o) {
|
||||
this.IIcon = o;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user