Add support for injecting colored items in pipes
This commit is contained in:
parent
b71fe3cce8
commit
7a941c1279
13 changed files with 33 additions and 18 deletions
|
@ -6,9 +6,12 @@
|
|||
* 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.core.utils;
|
||||
package buildcraft.api.core;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public enum EnumColor {
|
||||
|
||||
|
@ -132,7 +135,7 @@ public enum EnumColor {
|
|||
}
|
||||
|
||||
public static EnumColor getRand() {
|
||||
return VALUES[Utils.RANDOM.nextInt(VALUES.length)];
|
||||
return VALUES[new Random().nextInt(VALUES.length)];
|
||||
}
|
||||
|
||||
public EnumColor getNext() {
|
||||
|
@ -162,7 +165,7 @@ public enum EnumColor {
|
|||
}
|
||||
|
||||
public String getLocalizedName() {
|
||||
return StringUtils.localize(getTag());
|
||||
return StatCollector.translateToLocal(getTag());
|
||||
}
|
||||
|
||||
public String getDye() {
|
|
@ -9,8 +9,8 @@
|
|||
package buildcraft.api.transport;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.core.EnumColor;
|
||||
|
||||
public interface IPipeTile {
|
||||
|
||||
|
@ -29,8 +29,16 @@ public interface IPipeTile {
|
|||
* @param doAdd If false no actual addition should take place. Implementors
|
||||
* should simulate.
|
||||
* @param from Orientation the ItemStack is offered from.
|
||||
* @param color The color of the item to be added to the pipe, or null for no color.
|
||||
* @return Amount of items used from the passed stack.
|
||||
*/
|
||||
int injectItem(ItemStack stack, boolean doAdd, ForgeDirection from, EnumColor color);
|
||||
|
||||
/**
|
||||
* Same as
|
||||
* {@link #injectItem(ItemStack, boolean, ForgeDirection, EnumColor)}
|
||||
* but with no color attribute.
|
||||
*/
|
||||
int injectItem(ItemStack stack, boolean doAdd, ForgeDirection from);
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,6 +33,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||
import net.minecraftforge.oredict.RecipeSorter;
|
||||
|
||||
import buildcraft.api.blueprints.SchematicRegistry;
|
||||
import buildcraft.api.core.EnumColor;
|
||||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.core.JavaTools;
|
||||
import buildcraft.api.gates.GateExpansions;
|
||||
|
@ -51,7 +52,6 @@ import buildcraft.core.Version;
|
|||
import buildcraft.core.network.BuildCraftChannelHandler;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.triggers.ActionPipeClose;
|
||||
import buildcraft.core.utils.EnumColor;
|
||||
import buildcraft.transport.BlockFilteredBuffer;
|
||||
import buildcraft.transport.BlockGenericPipe;
|
||||
import buildcraft.transport.GuiHandler;
|
||||
|
|
|
@ -37,6 +37,7 @@ import net.minecraftforge.fluids.IFluidHandler;
|
|||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.BCLog;
|
||||
import buildcraft.api.core.EnumColor;
|
||||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.core.Position;
|
||||
import buildcraft.api.gates.IGateExpansion;
|
||||
|
@ -579,7 +580,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
|
|||
|
||||
/* IPIPEENTRY */
|
||||
@Override
|
||||
public int injectItem(ItemStack payload, boolean doAdd, ForgeDirection from) {
|
||||
public int injectItem(ItemStack payload, boolean doAdd, ForgeDirection from, EnumColor color) {
|
||||
if (pipe.isClosed()) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -590,6 +591,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
|
|||
itemPos.moveBackwards(0.4);
|
||||
|
||||
TravelingItem pipedItem = TravelingItem.make(itemPos.x, itemPos.y, itemPos.z, payload);
|
||||
pipedItem.color = color;
|
||||
((PipeTransportItems) pipe.transport).injectItem(pipedItem, itemPos.orientation);
|
||||
}
|
||||
return payload.stackSize;
|
||||
|
@ -598,6 +600,11 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
|
|||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int injectItem(ItemStack payload, boolean doAdd, ForgeDirection from) {
|
||||
return injectItem(payload, doAdd, from, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PipeType getPipeType() {
|
||||
if (BlockGenericPipe.isValid(pipe)) {
|
||||
|
|
|
@ -26,9 +26,9 @@ import cpw.mods.fml.relauncher.Side;
|
|||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.api.core.EnumColor;
|
||||
import buildcraft.api.core.Position;
|
||||
import buildcraft.core.inventory.StackHelper;
|
||||
import buildcraft.core.utils.EnumColor;
|
||||
|
||||
public class TravelingItem {
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import cpw.mods.fml.relauncher.Side;
|
|||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.EnumColor;
|
||||
import buildcraft.core.gui.BuildCraftContainer;
|
||||
import buildcraft.core.gui.GuiBuildCraft;
|
||||
import buildcraft.core.gui.slots.SlotPhantom;
|
||||
|
@ -30,7 +31,6 @@ import buildcraft.core.gui.tooltips.ToolTip;
|
|||
import buildcraft.core.gui.tooltips.ToolTipLine;
|
||||
import buildcraft.core.gui.widgets.ButtonWidget;
|
||||
import buildcraft.core.network.PacketGuiReturn;
|
||||
import buildcraft.core.utils.EnumColor;
|
||||
import buildcraft.core.utils.RevolvingList;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
import buildcraft.transport.pipes.PipeItemsEmzuli;
|
||||
|
|
|
@ -13,10 +13,9 @@ import io.netty.buffer.ByteBuf;
|
|||
import net.minecraft.util.MathHelper;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.api.core.EnumColor;
|
||||
import buildcraft.core.network.BuildCraftPacket;
|
||||
import buildcraft.core.network.PacketIds;
|
||||
import buildcraft.core.utils.EnumColor;
|
||||
import buildcraft.transport.TravelingItem;
|
||||
|
||||
public class PacketPipeTransportTraveler extends BuildCraftPacket {
|
||||
|
|
|
@ -24,11 +24,11 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.EnumColor;
|
||||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import buildcraft.core.utils.EnumColor;
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.PipeIconProvider;
|
||||
import buildcraft.transport.PipeTransportItems;
|
||||
|
|
|
@ -24,12 +24,12 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.EnumColor;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.core.GuiIds;
|
||||
import buildcraft.core.inventory.InvUtils;
|
||||
import buildcraft.core.inventory.SimpleInventory;
|
||||
import buildcraft.core.network.IGuiReturnHandler;
|
||||
import buildcraft.core.utils.EnumColor;
|
||||
import buildcraft.transport.BlockGenericPipe;
|
||||
import buildcraft.transport.PipeIconProvider;
|
||||
import buildcraft.transport.TravelingItem;
|
||||
|
|
|
@ -21,10 +21,10 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.EnumColor;
|
||||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import buildcraft.core.utils.EnumColor;
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.PipeIconProvider;
|
||||
import buildcraft.transport.PipeTransportItems;
|
||||
|
|
|
@ -38,6 +38,7 @@ import net.minecraftforge.fluids.FluidStack;
|
|||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.BuildCraftCore.RenderMode;
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.EnumColor;
|
||||
import buildcraft.api.gates.IGateExpansion;
|
||||
import buildcraft.api.transport.IPipeTile.PipeType;
|
||||
import buildcraft.api.transport.PipeWire;
|
||||
|
@ -46,7 +47,6 @@ import buildcraft.core.DefaultProps;
|
|||
import buildcraft.core.render.RenderEntityBlock;
|
||||
import buildcraft.core.render.RenderEntityBlock.RenderInfo;
|
||||
import buildcraft.core.render.RenderUtils;
|
||||
import buildcraft.core.utils.EnumColor;
|
||||
import buildcraft.core.utils.MatrixTranformations;
|
||||
import buildcraft.transport.Gate;
|
||||
import buildcraft.transport.Pipe;
|
||||
|
|
|
@ -11,9 +11,8 @@ package buildcraft.transport.triggers;
|
|||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
||||
import buildcraft.api.core.EnumColor;
|
||||
import buildcraft.core.triggers.BCActionPassive;
|
||||
import buildcraft.core.utils.EnumColor;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
|
||||
public class ActionExtractionPreset extends BCActionPassive {
|
||||
|
|
|
@ -11,9 +11,8 @@ package buildcraft.transport.triggers;
|
|||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
||||
import buildcraft.api.core.EnumColor;
|
||||
import buildcraft.core.triggers.BCActionPassive;
|
||||
import buildcraft.core.utils.EnumColor;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
|
||||
public class ActionPipeColor extends BCActionPassive {
|
||||
|
|
Loading…
Reference in a new issue