Adding Logemerald pipe
This is an action sensitive extraction pipe. The pipe can be configured with 4 different items and actions will decide which one to extract from the connected inventory.
After Width: | Height: | Size: 325 B |
After Width: | Height: | Size: 215 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 169 B |
After Width: | Height: | Size: 183 B |
After Width: | Height: | Size: 159 B |
After Width: | Height: | Size: 192 B |
|
@ -33,6 +33,7 @@ gui.pipes.emerald.blocking=Blocking
|
|||
gui.pipes.emerald.blocking.tip=Extraction is blocked if one element in filter is missing
|
||||
gui.pipes.emerald.nonblocking=Non Blocking
|
||||
gui.pipes.emerald.nonblocking.tip=Extraction continues with the next element in filter if one element is missing
|
||||
gui.pipes.logemerald.title=Extraction presets
|
||||
item.bucketFuel=Fuel Bucket
|
||||
item.bucketOil=Oil Bucket
|
||||
item.woodenGearItem=Wood Gear
|
||||
|
@ -78,6 +79,7 @@ item.PipeItemsObsidian=Obsidian Transport Pipe
|
|||
item.PipeItemsEmerald=Emerald Transport Pipe
|
||||
item.PipeItemsLapis=Lapis Transport Pipe
|
||||
item.PipeItemsDaizuli=Daizuli Transport Pipe
|
||||
item.PipeItemsLogemerald=Logemerald Transport Pipe
|
||||
item.PipeFluidsWood=Wooden Fluid Pipe
|
||||
item.PipeFluidsCobblestone=Cobblestone Fluid Pipe
|
||||
item.PipeFluidsStone=Stone Fluid Pipe
|
||||
|
@ -152,6 +154,7 @@ tip.PipeItemsSandstone=Only connects to other pipes
|
|||
tip.PipeItemsStone=Basic pipe, medium drag\nWon't connect to Cobblestone or Quartz
|
||||
tip.PipeItemsVoid=Destroys items
|
||||
tip.PipeItemsWood=Extraction pipe
|
||||
tip.PipeItemsLogemerald=Action controlled extraction pipe
|
||||
tip.PipePowerWood=Power Input Pipe
|
||||
tip.PipePowerIron=Selectable Limiter Pipe
|
||||
tip.PipeStructureCobblestone=Support pipe
|
||||
|
|
|
@ -54,6 +54,7 @@ import buildcraft.transport.pipes.PipeItemsDiamond;
|
|||
import buildcraft.transport.pipes.PipeItemsEmerald;
|
||||
import buildcraft.transport.pipes.PipeItemsGold;
|
||||
import buildcraft.transport.pipes.PipeItemsIron;
|
||||
import buildcraft.transport.pipes.PipeItemsLogemerald;
|
||||
import buildcraft.transport.pipes.PipeItemsLapis;
|
||||
import buildcraft.transport.pipes.PipeItemsObsidian;
|
||||
import buildcraft.transport.pipes.PipeItemsQuartz;
|
||||
|
@ -71,6 +72,7 @@ import buildcraft.transport.pipes.PipePowerStone;
|
|||
import buildcraft.transport.pipes.PipePowerWood;
|
||||
import buildcraft.transport.pipes.PipeStructureCobblestone;
|
||||
import buildcraft.transport.triggers.ActionEnergyPulser;
|
||||
import buildcraft.transport.triggers.ActionExtractionPreset;
|
||||
import buildcraft.transport.triggers.ActionPipeColor;
|
||||
import buildcraft.transport.triggers.ActionPipeDirection;
|
||||
import buildcraft.transport.triggers.ActionPowerLimiter;
|
||||
|
@ -126,6 +128,7 @@ public class BuildCraftTransport {
|
|||
public static Item pipeItemsDaizuli;
|
||||
public static Item pipeItemsVoid;
|
||||
public static Item pipeItemsSandstone;
|
||||
public static Item pipeItemsLogemerald;
|
||||
public static Item pipeFluidsWood;
|
||||
public static Item pipeFluidsCobblestone;
|
||||
public static Item pipeFluidsStone;
|
||||
|
@ -170,11 +173,17 @@ public class BuildCraftTransport {
|
|||
public static BCAction[] actionPipeColor = new BCAction[16];
|
||||
public static BCAction[] actionPipeDirection = new BCAction[16];
|
||||
public static BCAction[] actionPowerLimiter = new BCAction[7];
|
||||
@Instance("BuildCraft|Transport")
|
||||
public static BuildCraftTransport instance;
|
||||
public static BCAction actionExtractionPresetRed = new ActionExtractionPreset(-1, EnumColor.RED);
|
||||
public static BCAction actionExtractionPresetBlue = new ActionExtractionPreset(-1, EnumColor.BLUE);
|
||||
public static BCAction actionExtractionPresetGreen = new ActionExtractionPreset(-1, EnumColor.GREEN);
|
||||
public static BCAction actionExtractionPresetYellow = new ActionExtractionPreset(-1, EnumColor.YELLOW);
|
||||
|
||||
public IIconProvider pipeIconProvider = new PipeIconProvider();
|
||||
public IIconProvider gateIconProvider = new GateIconProvider();
|
||||
public IIconProvider wireIconProvider = new WireIconProvider();
|
||||
|
||||
@Instance("BuildCraft|Transport")
|
||||
public static BuildCraftTransport instance;
|
||||
|
||||
private static class PipeRecipe {
|
||||
|
||||
|
@ -270,7 +279,6 @@ public class BuildCraftTransport {
|
|||
genericPipeBlock = new BlockGenericPipe(genericPipeId.getInt());
|
||||
CoreProxy.proxy.registerBlock(genericPipeBlock.setUnlocalizedName("pipeBlock"), ItemBlock.class);
|
||||
|
||||
// Fixing retro-compatiblity
|
||||
pipeItemsWood = buildPipe(DefaultProps.PIPE_ITEMS_WOOD_ID, PipeItemsWood.class, "Wooden Transport Pipe", "plankWood", Block.glass, "plankWood");
|
||||
pipeItemsEmerald = buildPipe(DefaultProps.PIPE_ITEMS_EMERALD_ID, PipeItemsEmerald.class, "Emerald Transport Pipe", Item.emerald, Block.glass, Item.emerald);
|
||||
pipeItemsCobblestone = buildPipe(DefaultProps.PIPE_ITEMS_COBBLESTONE_ID, PipeItemsCobblestone.class, "Cobblestone Transport Pipe", "cobblestone", Block.glass, "cobblestone");
|
||||
|
@ -284,7 +292,8 @@ public class BuildCraftTransport {
|
|||
pipeItemsDaizuli = buildPipe(DefaultProps.PIPE_ITEMS_DAIZULI_ID, PipeItemsDaizuli.class, "Daizuli Transport Pipe", Block.blockLapis, Block.glass, Item.diamond);
|
||||
pipeItemsSandstone = buildPipe(DefaultProps.PIPE_ITEMS_SANDSTONE_ID, PipeItemsSandstone.class, "Sandstone Transport Pipe", Block.sandStone, Block.glass, Block.sandStone);
|
||||
pipeItemsVoid = buildPipe(DefaultProps.PIPE_ITEMS_VOID_ID, PipeItemsVoid.class, "Void Transport Pipe", "dyeBlack", Block.glass, Item.redstone);
|
||||
|
||||
pipeItemsLogemerald = buildPipe(DefaultProps.PIPE_ITEMS_LOGEMERALD_ID, PipeItemsLogemerald.class, "Logemerald Transport Pipe", "logWood", Block.glass, Item.emerald);
|
||||
|
||||
pipeFluidsWood = buildPipe(DefaultProps.PIPE_LIQUIDS_WOOD_ID, PipeFluidsWood.class, "Wooden Waterproof Pipe", pipeWaterproof, pipeItemsWood);
|
||||
pipeFluidsCobblestone = buildPipe(DefaultProps.PIPE_LIQUIDS_COBBLESTONE_ID, PipeFluidsCobblestone.class, "Cobblestone Waterproof Pipe", pipeWaterproof, pipeItemsCobblestone);
|
||||
pipeFluidsStone = buildPipe(DefaultProps.PIPE_LIQUIDS_STONE_ID, PipeFluidsStone.class, "Stone Waterproof Pipe", pipeWaterproof, pipeItemsStone);
|
||||
|
@ -367,7 +376,7 @@ public class BuildCraftTransport {
|
|||
// Register connection handler
|
||||
// MinecraftForge.registerConnectionHandler(new ConnectionHandler());
|
||||
|
||||
// Register gui handler
|
||||
// Register GUI handler
|
||||
// MinecraftForge.setGuiHandler(mod_BuildCraftTransport.instance, new GuiHandler());
|
||||
|
||||
TransportProxy.proxy.registerTileEntities();
|
||||
|
|
|
@ -63,6 +63,7 @@ public class DefaultProps {
|
|||
public static int PIPE_ITEMS_QUARTZ_ID = 19168;
|
||||
public static int PIPE_ITEMS_LAPIS_ID = 19169;
|
||||
public static int PIPE_ITEMS_DAIZULI_ID = 19170;
|
||||
public static int PIPE_ITEMS_LOGEMERALD_ID = 19171;
|
||||
|
||||
public static int PIPE_LIQUIDS_WOOD_ID = 19180;
|
||||
public static int PIPE_LIQUIDS_COBBLESTONE_ID = 19181;
|
||||
|
|
|
@ -19,6 +19,7 @@ public class GuiIds {
|
|||
public static final int PIPE_DIAMOND = 50;
|
||||
public static final int GATES = 51;
|
||||
public static final int PIPE_EMERALD_ITEM = 52;
|
||||
public static final int PIPE_LOGEMERALD_ITEM = 53;
|
||||
|
||||
public static final int FILTERED_BUFFER = 60;
|
||||
}
|
||||
|
|
|
@ -6,12 +6,15 @@ import buildcraft.transport.gui.ContainerDiamondPipe;
|
|||
import buildcraft.transport.gui.ContainerEmeraldPipe;
|
||||
import buildcraft.transport.gui.ContainerFilteredBuffer;
|
||||
import buildcraft.transport.gui.ContainerGateInterface;
|
||||
import buildcraft.transport.gui.ContainerLogemeraldPipe;
|
||||
import buildcraft.transport.gui.GuiDiamondPipe;
|
||||
import buildcraft.transport.gui.GuiEmeraldPipe;
|
||||
import buildcraft.transport.gui.GuiFilteredBuffer;
|
||||
import buildcraft.transport.gui.GuiGateInterface;
|
||||
import buildcraft.transport.gui.GuiLogemeraldPipe;
|
||||
import buildcraft.transport.pipes.PipeItemsDiamond;
|
||||
import buildcraft.transport.pipes.PipeItemsEmerald;
|
||||
import buildcraft.transport.pipes.PipeItemsLogemerald;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import java.util.logging.Level;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -48,6 +51,9 @@ public class GuiHandler implements IGuiHandler {
|
|||
case GuiIds.PIPE_EMERALD_ITEM:
|
||||
return new ContainerEmeraldPipe(player.inventory, (PipeItemsEmerald) pipe.pipe);
|
||||
|
||||
case GuiIds.PIPE_LOGEMERALD_ITEM:
|
||||
return new ContainerLogemeraldPipe(player.inventory, (PipeItemsLogemerald) pipe.pipe);
|
||||
|
||||
case GuiIds.GATES:
|
||||
if (pipe.pipe.hasGate())
|
||||
return new ContainerGateInterface(player.inventory, pipe.pipe);
|
||||
|
@ -89,6 +95,9 @@ public class GuiHandler implements IGuiHandler {
|
|||
case GuiIds.PIPE_EMERALD_ITEM:
|
||||
return new GuiEmeraldPipe(player.inventory, (PipeItemsEmerald) pipe.pipe);
|
||||
|
||||
case GuiIds.PIPE_LOGEMERALD_ITEM:
|
||||
return new GuiLogemeraldPipe(player.inventory, (PipeItemsLogemerald) pipe.pipe);
|
||||
|
||||
case GuiIds.GATES:
|
||||
if (pipe.pipe.hasGate())
|
||||
return new GuiGateInterface(player.inventory, pipe.pipe);
|
||||
|
|
|
@ -12,6 +12,7 @@ import buildcraft.transport.pipes.PipeFluidsCobblestone;
|
|||
import buildcraft.transport.pipes.PipeFluidsStone;
|
||||
import buildcraft.transport.pipes.PipeFluidsWood;
|
||||
import buildcraft.transport.pipes.PipeItemsCobblestone;
|
||||
import buildcraft.transport.pipes.PipeItemsLogemerald;
|
||||
import buildcraft.transport.pipes.PipeItemsObsidian;
|
||||
import buildcraft.transport.pipes.PipeItemsQuartz;
|
||||
import buildcraft.transport.pipes.PipeItemsStone;
|
||||
|
@ -41,6 +42,8 @@ public class PipeConnectionBans {
|
|||
banConnection(PipeItemsWood.class);
|
||||
|
||||
banConnection(PipeItemsObsidian.class);
|
||||
|
||||
banConnection(PipeItemsLogemerald.class);
|
||||
|
||||
// Power Pipes
|
||||
banConnection(PipePowerWood.class);
|
||||
|
|
|
@ -64,6 +64,9 @@ public class PipeIconProvider implements IIconProvider {
|
|||
PipeItemsEmerald_Standard("pipeItemsEmerald_standard"),
|
||||
PipeAllEmerald_Solid("pipeAllEmerald_solid"),
|
||||
//
|
||||
PipeItemsLogemerald_Standard("pipeItemsLogemerald_standard"),
|
||||
PipeAllLogemerald_Solid("pipeAllLogemerald_solid"),
|
||||
//
|
||||
PipeItemsGold("pipeItemsGold"),
|
||||
//
|
||||
PipeItemsIron_Standard("pipeItemsIron_standard"),
|
||||
|
|
|
@ -39,6 +39,7 @@ public class TransportProxyClient extends TransportProxy {
|
|||
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsEmerald.itemID, pipeItemRenderer);
|
||||
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsLapis.itemID, pipeItemRenderer);
|
||||
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsDaizuli.itemID, pipeItemRenderer);
|
||||
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsLogemerald.itemID, pipeItemRenderer);
|
||||
|
||||
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeFluidsWood.itemID, pipeItemRenderer);
|
||||
MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeFluidsCobblestone.itemID, pipeItemRenderer);
|
||||
|
|
49
common/buildcraft/transport/gui/ContainerLogemeraldPipe.java
Normal file
|
@ -0,0 +1,49 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
|
||||
* 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.transport.gui;
|
||||
|
||||
import buildcraft.core.gui.BuildCraftContainer;
|
||||
import buildcraft.core.gui.slots.SlotPhantom;
|
||||
import buildcraft.transport.pipes.PipeItemsLogemerald;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
public class ContainerLogemeraldPipe extends BuildCraftContainer {
|
||||
|
||||
private final PipeItemsLogemerald logemeraldPipe;
|
||||
|
||||
private final IInventory filterInv;
|
||||
|
||||
public ContainerLogemeraldPipe(IInventory playerInventory, PipeItemsLogemerald pipe) {
|
||||
super(pipe.getFilters().getSizeInventory());
|
||||
|
||||
logemeraldPipe = pipe;
|
||||
filterInv = logemeraldPipe.getFilters();
|
||||
|
||||
addSlotToContainer(new SlotPhantom(filterInv, 0, 44, 21));
|
||||
addSlotToContainer(new SlotPhantom(filterInv, 1, 116, 21));
|
||||
addSlotToContainer(new SlotPhantom(filterInv, 2, 44, 49));
|
||||
addSlotToContainer(new SlotPhantom(filterInv, 3, 116, 49));
|
||||
|
||||
for (int l = 0; l < 3; l++) {
|
||||
for (int k1 = 0; k1 < 9; k1++) {
|
||||
addSlotToContainer(new Slot(playerInventory, k1 + l * 9 + 9, 8 + k1 * 18, 84 + l * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i1 = 0; i1 < 9; i1++) {
|
||||
addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return logemeraldPipe.container.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
}
|
52
common/buildcraft/transport/gui/GuiLogemeraldPipe.java
Normal file
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
|
||||
* 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.transport.gui;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.gui.GuiBuildCraft;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
import buildcraft.transport.pipes.PipeItemsLogemerald;
|
||||
|
||||
public class GuiLogemeraldPipe extends GuiBuildCraft {
|
||||
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/logemerald_pipe_gui.png");
|
||||
|
||||
IInventory filterInventory;
|
||||
PipeItemsLogemerald logemeraldPipe;
|
||||
|
||||
public GuiLogemeraldPipe(IInventory playerInventory, PipeItemsLogemerald pipe) {
|
||||
super(new ContainerLogemeraldPipe(playerInventory, pipe), pipe.getFilters());
|
||||
|
||||
logemeraldPipe = pipe;
|
||||
filterInventory = pipe.getFilters();
|
||||
|
||||
xSize = 175;
|
||||
ySize = 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
String title = StringUtils.localize("gui.pipes.logemerald.title");
|
||||
fontRenderer.drawString(title, (xSize - fontRenderer.getStringWidth(title)) / 2, 6, 0x404040);
|
||||
fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 93, 0x404040);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
mc.renderEngine.bindTexture(TEXTURE);
|
||||
int j = (width - xSize) / 2;
|
||||
int k = (height - ySize) / 2;
|
||||
drawTexturedModalRect(j, k, 0, 0, xSize, ySize);
|
||||
}
|
||||
}
|
246
common/buildcraft/transport/pipes/PipeItemsLogemerald.java
Normal file
|
@ -0,0 +1,246 @@
|
|||
/*
|
||||
* Copyright (c) SpaceToad, 2011-2012
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.transport.pipes;
|
||||
|
||||
import java.util.BitSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.api.inventory.ISelectiveInventory;
|
||||
import buildcraft.api.inventory.ISpecialInventory;
|
||||
import buildcraft.core.GuiIds;
|
||||
import buildcraft.core.inventory.SimpleInventory;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.EnumColor;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import buildcraft.transport.BlockGenericPipe;
|
||||
import buildcraft.transport.PipeIconProvider;
|
||||
import buildcraft.transport.pipes.PipeItemsEmerald.ButtonState;
|
||||
import buildcraft.transport.triggers.ActionExtractionPreset;
|
||||
|
||||
public class PipeItemsLogemerald extends PipeItemsWood {
|
||||
|
||||
private final SimpleInventory filters = new SimpleInventory(4, "Filters", 1);
|
||||
|
||||
private BitSet activeFlags = new BitSet(4);
|
||||
private int filterCount = filters.getSizeInventory();
|
||||
private int currentFilter = 0;
|
||||
|
||||
public PipeItemsLogemerald(int itemID) {
|
||||
super(itemID);
|
||||
|
||||
standardIconIndex = PipeIconProvider.TYPE.PipeItemsLogemerald_Standard.ordinal();
|
||||
solidIconIndex = PipeIconProvider.TYPE.PipeAllLogemerald_Solid.ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean blockActivated(EntityPlayer entityplayer) {
|
||||
if (entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().itemID < Block.blocksList.length) {
|
||||
if (Block.blocksList[entityplayer.getCurrentEquippedItem().itemID] instanceof BlockGenericPipe) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (super.blockActivated(entityplayer)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!CoreProxy.proxy.isRenderWorld(container.worldObj)) {
|
||||
entityplayer.openGui(BuildCraftTransport.instance, GuiIds.PIPE_LOGEMERALD_ITEM, container.worldObj, container.xCoord, container.yCoord, container.zCoord);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the itemstack that can be if something can be extracted from this
|
||||
* inventory, null if none. On certain cases, the extractable slot depends
|
||||
* on the position of the pipe.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack[] checkExtract(IInventory inventory, boolean doRemove, ForgeDirection from) {
|
||||
|
||||
if (activeFlags.isEmpty()){
|
||||
return null;
|
||||
}
|
||||
|
||||
incrementFilter();
|
||||
|
||||
if (filters.getStackInSlot(currentFilter % filterCount) == null || !activeFlags.get(currentFilter % filterCount)){
|
||||
return null;
|
||||
}
|
||||
|
||||
/* ISELECTIVEINVENTORY */
|
||||
if (inventory instanceof ISelectiveInventory) {
|
||||
ItemStack[] stacks = ((ISelectiveInventory) inventory).extractItem(new ItemStack[] { getCurrentFilter() }, false, doRemove, from, (int) powerHandler.getEnergyStored());
|
||||
if (doRemove) {
|
||||
for (ItemStack stack : stacks) {
|
||||
if (stack != null) {
|
||||
powerHandler.useEnergy(stack.stackSize, stack.stackSize, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return stacks;
|
||||
|
||||
/* ISPECIALINVENTORY */
|
||||
} else if (inventory instanceof ISpecialInventory) {
|
||||
ItemStack[] stacks = ((ISpecialInventory) inventory).extractItem(false, from, (int) powerHandler.getEnergyStored());
|
||||
if (stacks != null) {
|
||||
for (ItemStack stack : stacks) {
|
||||
if (stack == null)
|
||||
continue;
|
||||
|
||||
boolean matches = false;
|
||||
for (int i = 0; i < filters.getSizeInventory(); i++) {
|
||||
ItemStack filter = filters.getStackInSlot(i);
|
||||
if (filter != null && filter.isItemEqual(stack)) {
|
||||
matches = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!matches) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (doRemove) {
|
||||
stacks = ((ISpecialInventory) inventory).extractItem(true, from, (int) powerHandler.getEnergyStored());
|
||||
for (ItemStack stack : stacks) {
|
||||
if (stack != null) {
|
||||
powerHandler.useEnergy(stack.stackSize, stack.stackSize, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return stacks;
|
||||
|
||||
} else {
|
||||
|
||||
// This is a generic inventory
|
||||
IInventory inv = Utils.getInventory(inventory);
|
||||
ItemStack result = checkExtractGeneric(inv, doRemove, from);
|
||||
|
||||
if (result != null) {
|
||||
return new ItemStack[] { result };
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack checkExtractGeneric(net.minecraft.inventory.ISidedInventory inventory, boolean doRemove, ForgeDirection from) {
|
||||
for (int i : inventory.getAccessibleSlotsFromSide(from.ordinal())) {
|
||||
ItemStack stack = inventory.getStackInSlot(i);
|
||||
if (stack != null && stack.stackSize > 0) {
|
||||
ItemStack filter = getCurrentFilter();
|
||||
if (filter == null) {
|
||||
return null;
|
||||
}
|
||||
if (!filter.isItemEqual(stack)) {
|
||||
continue;
|
||||
}
|
||||
if (!inventory.canExtractItem(i, stack, from.ordinal())) {
|
||||
continue;
|
||||
}
|
||||
if (doRemove) {
|
||||
return inventory.decrStackSize(i, (int) powerHandler.useEnergy(1, stack.stackSize, true));
|
||||
} else {
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public IInventory getFilters() {
|
||||
return filters;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionsActivated(Map<IAction, Boolean> actions) {
|
||||
super.actionsActivated(actions);
|
||||
|
||||
activeFlags.clear();
|
||||
|
||||
for (Entry<IAction, Boolean> action : actions.entrySet()) {
|
||||
if (action.getKey() instanceof ActionExtractionPreset && action.getValue() != null && action.getValue()) {
|
||||
setActivePreset(((ActionExtractionPreset) action.getKey()).color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setActivePreset(EnumColor color) {
|
||||
switch (color){
|
||||
case RED:
|
||||
activeFlags.set(0);
|
||||
break;
|
||||
case BLUE:
|
||||
activeFlags.set(1);
|
||||
break;
|
||||
case GREEN:
|
||||
activeFlags.set(2);
|
||||
break;
|
||||
case YELLOW:
|
||||
activeFlags.set(3);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinkedList<IAction> getActions() {
|
||||
LinkedList<IAction> result = super.getActions();
|
||||
|
||||
result.add(BuildCraftTransport.actionExtractionPresetRed);
|
||||
result.add(BuildCraftTransport.actionExtractionPresetBlue);
|
||||
result.add(BuildCraftTransport.actionExtractionPresetGreen);
|
||||
result.add(BuildCraftTransport.actionExtractionPresetYellow);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
filters.readFromNBT(nbt);
|
||||
currentFilter = nbt.getInteger("currentFilter");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
filters.writeToNBT(nbt);
|
||||
nbt.setInteger("currentFilter", currentFilter);
|
||||
}
|
||||
|
||||
private void incrementFilter() {
|
||||
int count = 0;
|
||||
currentFilter++;
|
||||
|
||||
while (!(filters.getStackInSlot(currentFilter % filterCount) != null && activeFlags.get(currentFilter % filterCount)) && count < filterCount) {
|
||||
currentFilter++;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
private ItemStack getCurrentFilter() {
|
||||
return filters.getStackInSlot(currentFilter % filters.getSizeInventory());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
|
||||
* 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.transport.triggers;
|
||||
|
||||
import buildcraft.core.triggers.BCAction;
|
||||
import buildcraft.core.utils.EnumColor;
|
||||
import java.util.Locale;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.util.Icon;
|
||||
|
||||
public class ActionExtractionPreset extends BCAction {
|
||||
|
||||
private Icon icon;
|
||||
public final EnumColor color;
|
||||
|
||||
public ActionExtractionPreset(int id, EnumColor color) {
|
||||
super(id, "buildcraft.extraction.preset." + color.getTag());
|
||||
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return color.getName() + " Extraction Preset";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IconRegister iconRegister) {
|
||||
icon = iconRegister.registerIcon("buildcraft:triggers/extraction_preset_" + color.name().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
}
|