mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-10-26 14:24:23 +00:00
ec2 style output rule and oc integration
This commit is contained in:
1 parent
19f9dee682
commit
e38869f07d
20 files changed
+503
-25
No files matched your search
+5
-4
@@ -5,14 +5,15 @@ dependencies {
|
||||
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-75-GTNH:dev')
|
||||
compile('curse.maven:cofh-core-69162:2388751')
|
||||
compile('com.github.GTNewHorizons:ExtraCells2:2.5.9:dev') {transitive = false}
|
||||
compile("com.github.GTNewHorizons:ForestryMC:4.4.4:dev")
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:ForestryMC:4.4.4:dev")
|
||||
compileOnly("com.github.GTNewHorizons:EnderIO:2.3.1.27:dev")
|
||||
compileOnly("com.github.GTNewHorizons:EnderCore:0.2.6:dev")
|
||||
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.40.41:dev')
|
||||
compileOnly('com.github.GTNewHorizons:StructureLib:1.0.15:dev')
|
||||
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
|
||||
compile('com.github.GTNewHorizons:GT5-Unofficial:5.09.40.41:dev')
|
||||
compile('com.github.GTNewHorizons:StructureLib:1.0.15:dev')
|
||||
compile('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
|
||||
compileOnly('com.github.GTNewHorizons:AppleCore:3.1.9:dev') {transitive = false}
|
||||
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.27:dev') {transitive = false}
|
||||
compileOnly("com.gregoriust.gregtech:gregtech_1.7.10:6.14.23:dev") {transitive = false}
|
||||
compile('com.github.GTNewHorizons:OpenComputers:1.7.5.23-GTNH:dev') {transitive = false}
|
||||
}
|
||||
@@ -72,12 +72,19 @@ public class GuiFluidInterface extends AEBaseGui {
|
||||
|
||||
mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
|
||||
for (int i = 0; i < 6; i++) {
|
||||
if (!isPart()) {
|
||||
fontRendererObj.drawString(dirName(i), TANK_X + i * TANK_X_OFF + 5, 22, 0x404040);
|
||||
}
|
||||
renderFluidIntoGui(TANK_X + i * TANK_X_OFF, TANK_Y, TANK_WIDTH, TANK_HEIGHT,
|
||||
fluidInv.getFluidInSlot(i), fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity);
|
||||
}
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
}
|
||||
|
||||
public String dirName(int face) {
|
||||
return I18n.format(NameConst.GUI_FLUID_INTERFACE + "." + face);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
mc.getTextureManager().bindTexture(TEX_BG);
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.glodblock.github.client.gui;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.core.localization.GuiText;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.ContainerOCPatternEditor;
|
||||
import com.glodblock.github.common.tile.TileOCPatternEditor;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GuiOCPatternEditor extends AEBaseGui {
|
||||
|
||||
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/oc_pattern_editor.png");
|
||||
|
||||
public GuiOCPatternEditor(InventoryPlayer ipl, TileOCPatternEditor tile) {
|
||||
super(new ContainerOCPatternEditor(ipl, tile));
|
||||
this.ySize = 186;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
mc.getTextureManager().bindTexture(TEX_BG);
|
||||
drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
fontRendererObj.drawString(getGuiDisplayName(I18n.format(NameConst.GUI_OC_PATTERN_EDITOR)), 8, 6, 0x404040);
|
||||
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import com.glodblock.github.common.tile.TileOCPatternEditor;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
public class ContainerOCPatternEditor extends AEBaseContainer {
|
||||
|
||||
public ContainerOCPatternEditor(InventoryPlayer ipl, TileOCPatternEditor tile) {
|
||||
super(ipl, tile);
|
||||
for (int i = 0; i < 4; i ++) {
|
||||
for (int j = 0; j < 4; j ++) {
|
||||
addSlotToContainer(new SlotRestrictedInput(
|
||||
SlotRestrictedInput.PlacableItemType.PATTERN, tile.getInternalInventory(),
|
||||
j * 4 + i, 55 + i * 18, 17 + j * 18, ipl
|
||||
));
|
||||
}
|
||||
}
|
||||
bindPlayerInventory(ipl, 0, 104);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.glodblock.github.common.block;
|
||||
|
||||
import appeng.block.AEBaseItemBlock;
|
||||
import com.glodblock.github.common.tile.TileOCPatternEditor;
|
||||
import com.glodblock.github.crossmod.opencomputers.OCDriverInit;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockOCPatternEditor extends FCBaseBlock {
|
||||
|
||||
public BlockOCPatternEditor() {
|
||||
super(Material.iron, NameConst.BLOCK_OC_PATTERN_EDITOR);
|
||||
setTileEntity(TileOCPatternEditor.class);
|
||||
setFullBlock(true);
|
||||
setOpaque(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivated(World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) {
|
||||
if (player.isSneaking()) {
|
||||
return false;
|
||||
}
|
||||
TileOCPatternEditor tile = getTileEntity(world, x, y, z);
|
||||
if (tile != null) {
|
||||
if (!world.isRemote) {
|
||||
InventoryHandler.openGui(player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.OC_PATTERN_EDITOR);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public BlockOCPatternEditor register() {
|
||||
if (ModAndClassUtil.OC) {
|
||||
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_OC_PATTERN_EDITOR);
|
||||
GameRegistry.registerTileEntity(TileOCPatternEditor.class, NameConst.BLOCK_OC_PATTERN_EDITOR);
|
||||
OCDriverInit.run();
|
||||
return this;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,8 +16,6 @@ import appeng.client.texture.CableBusTextures;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.misc.PartInterface;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
@@ -108,7 +106,7 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
|
||||
return config;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
@Override
|
||||
public void writeToStream(ByteBuf data) throws IOException {
|
||||
super.writeToStream( data );
|
||||
for (int i = 0; i < config.getSizeInventory(); i++) {
|
||||
|
||||
@@ -168,7 +168,7 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler,
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
return invFluids.drain(from, maxDrain, doDrain);
|
||||
return invFluids.drain(from.ordinal(), maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -43,10 +43,6 @@ public class TileFluidPatternEncoder extends AEBaseTile implements IAEAppEngInve
|
||||
|
||||
@Override
|
||||
public void getDrops(final World w, final int x, final int y, final int z, final List<ItemStack> drops ) {
|
||||
getDrops(w, new BlockPos(x, y, z), drops);
|
||||
}
|
||||
|
||||
public void getDrops(World world, BlockPos pos, List<ItemStack> drops) {
|
||||
for (ItemStack stack : patternInv) {
|
||||
if (stack != null) {
|
||||
drops.add(stack);
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.glodblock.github.common.tile;
|
||||
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.tile.AEBaseInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileOCPatternEditor extends AEBaseInvTile {
|
||||
|
||||
private final AppEngInternalInventory invItems = new AppEngInternalInventory(this, 16);
|
||||
|
||||
@Override
|
||||
public IInventory getInternalInventory() {
|
||||
return invItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added) {
|
||||
markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsBySide(ForgeDirection whichSide) {
|
||||
return new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot( final int i, final ItemStack itemstack ) {
|
||||
return itemstack == null || itemstack.getItem() instanceof ItemEncodedPattern;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,275 @@
|
||||
package com.glodblock.github.crossmod.opencomputers;
|
||||
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
|
||||
import com.glodblock.github.common.tile.TileOCPatternEditor;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import com.glodblock.github.util.Util;
|
||||
import li.cil.oc.api.driver.EnvironmentProvider;
|
||||
import li.cil.oc.api.driver.NamedBlock;
|
||||
import li.cil.oc.api.internal.Database;
|
||||
import li.cil.oc.api.machine.Arguments;
|
||||
import li.cil.oc.api.machine.Callback;
|
||||
import li.cil.oc.api.machine.Context;
|
||||
import li.cil.oc.api.network.Component;
|
||||
import li.cil.oc.api.network.ManagedEnvironment;
|
||||
import li.cil.oc.api.network.Node;
|
||||
import li.cil.oc.api.prefab.DriverSidedTileEntity;
|
||||
import li.cil.oc.integration.ManagedTileEntityEnvironment;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class DriverOCPatternEditor extends DriverSidedTileEntity {
|
||||
|
||||
public DriverOCPatternEditor() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getTileEntityClass() {
|
||||
return TileOCPatternEditor.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManagedEnvironment createEnvironment(World world, int x, int y, int z, ForgeDirection forgeDirection) {
|
||||
return new DriverOCPatternEditor.Environment((TileOCPatternEditor) world.getTileEntity(x, y, z));
|
||||
}
|
||||
|
||||
public static class Environment extends ManagedTileEntityEnvironment<TileOCPatternEditor>
|
||||
implements NamedBlock {
|
||||
|
||||
public Environment(TileOCPatternEditor tileEntity) {
|
||||
super(tileEntity, NameConst.BLOCK_OC_PATTERN_EDITOR);
|
||||
}
|
||||
|
||||
private int optSlot(Arguments args, IInventory inv, int index, int def) {
|
||||
if (index >= 0 && index < args.count()) {
|
||||
int slot = args.checkInteger(index) - 1;
|
||||
if (slot < 0 || slot >= inv.getSizeInventory()) {
|
||||
throw new IllegalArgumentException("invalid slot");
|
||||
}
|
||||
return slot;
|
||||
}
|
||||
else {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
private int checkSlot(Arguments args, IInventory inv, int index) {
|
||||
if (index >= 0 && index < args.count()) {
|
||||
int slot = args.checkInteger(index) - 1;
|
||||
if (slot < 0 || slot >= inv.getSizeInventory()) {
|
||||
throw new IllegalArgumentException("invalid slot");
|
||||
}
|
||||
return slot;
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("invalid slot");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean validPattern(ItemStack pattern) {
|
||||
if (pattern == null) {
|
||||
throw new IllegalArgumentException("No pattern here!");
|
||||
}
|
||||
if (pattern.getItem() instanceof ItemEncodedPattern && !(pattern.getItem() instanceof ItemFluidEncodedPattern)) {
|
||||
ItemEncodedPattern iep = (ItemEncodedPattern) pattern.getItem();
|
||||
return iep.getOutput(pattern) == null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private ItemStack getStack(Arguments args) {
|
||||
if (args.count() > 1) {
|
||||
String address;
|
||||
int entry;
|
||||
int size;
|
||||
if (args.isString(0)) {
|
||||
address = args.checkString(0);
|
||||
entry = args.checkInteger(1);
|
||||
size = args.optInteger(2, 1);
|
||||
}
|
||||
else {
|
||||
address = args.checkString(1);
|
||||
entry = args.checkInteger(2);
|
||||
size = args.optInteger(3, 1);
|
||||
}
|
||||
Node node = node().network().node(address);
|
||||
if (node instanceof Component) {
|
||||
if (node.host() instanceof Database) {
|
||||
ItemStack dbStack = ((Database) node.host()).getStackInSlot(entry - 1);
|
||||
if (dbStack == null || size < 1) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
dbStack.stackSize = Math.min(size, dbStack.getMaxStackSize());
|
||||
return dbStack;
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("not a database");
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("no such component");
|
||||
}
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Object[] clearInterfacePattern(Context context, Arguments args, String tag) {
|
||||
IInventory inv = tileEntity.getInternalInventory();
|
||||
ItemStack pattern = inv.getStackInSlot(checkSlot(args, inv, 0));
|
||||
if (validPattern(pattern)) {
|
||||
NBTTagCompound encodedValue = pattern.getTagCompound();
|
||||
int slot = checkSlot(args, inv, 0);
|
||||
if (encodedValue == null)
|
||||
throw new IllegalArgumentException("No pattern here!");
|
||||
NBTTagList nbt = encodedValue.getTagList(tag, 10);
|
||||
int index = args.checkInteger(1) - 1;
|
||||
if (index < 0)
|
||||
throw new IllegalArgumentException("Invalid index!");
|
||||
nbt.removeTag(index);
|
||||
encodedValue.setTag(tag, nbt);
|
||||
pattern.setTagCompound(encodedValue);
|
||||
inv.setInventorySlotContents(slot, null);
|
||||
inv.setInventorySlotContents(slot, pattern);
|
||||
context.pause(0.1);
|
||||
return new Object[] {true};
|
||||
} else {
|
||||
throw new IllegalArgumentException("Not Fluid Encoded pattern!");
|
||||
}
|
||||
}
|
||||
|
||||
private Object[] setPatternSlot(Context context, Arguments args, String tag, boolean fluid) {
|
||||
IInventory inv = tileEntity.getInternalInventory();
|
||||
int slot = args.isString(0) ? 0 : optSlot(args, inv, 0, 0);
|
||||
ItemStack stack = getStack(args);
|
||||
if (fluid) {
|
||||
FluidStack fluids = Util.getFluidFromItem(stack);
|
||||
stack = ItemFluidDrop.newStack(fluids);
|
||||
}
|
||||
int index = args.checkInteger(4) - 1;
|
||||
if (index < 0 || index > 511)
|
||||
throw new IllegalArgumentException("Invalid index!");
|
||||
ItemStack pattern = inv.getStackInSlot(slot);
|
||||
if (validPattern(pattern)) {
|
||||
NBTTagCompound encodedValue = pattern.getTagCompound();
|
||||
if (encodedValue == null)
|
||||
throw new IllegalArgumentException("No pattern here!");
|
||||
|
||||
NBTTagList inTag = encodedValue.getTagList(tag, 10);
|
||||
while (inTag.tagCount() <= index)
|
||||
inTag.appendTag(new NBTTagCompound());
|
||||
if (stack != null) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
AEItemStack aeStack = AEItemStack.create(stack);
|
||||
aeStack.writeToNBT(nbt);
|
||||
inTag.func_150304_a(index, nbt);
|
||||
}
|
||||
else {
|
||||
inTag.removeTag(index);
|
||||
}
|
||||
encodedValue.setTag(tag, inTag);
|
||||
pattern.setTagCompound(encodedValue);
|
||||
inv.setInventorySlotContents(slot, null);
|
||||
inv.setInventorySlotContents(slot, pattern);
|
||||
context.pause(0.1);
|
||||
return new Object[] {true};
|
||||
} else {
|
||||
throw new IllegalArgumentException("Not Fluid Encoded pattern!");
|
||||
}
|
||||
}
|
||||
|
||||
@Callback(doc = "function([slot:number]):table -- Get the configuration of the interface.")
|
||||
public Object[] getInterfaceConfiguration(Context context, Arguments args) {
|
||||
IInventory config = tileEntity.getInternalInventory();
|
||||
int slot = optSlot(args, config, 0, 0);
|
||||
ItemStack stack = config.getStackInSlot(slot);
|
||||
if (!validPattern(stack )) {
|
||||
throw new IllegalArgumentException("Not Fluid Encoded pattern!");
|
||||
}
|
||||
return new Object[]{stack};
|
||||
}
|
||||
|
||||
@Callback(doc = "function([slot:number][, database:address, entry:number[, size:number]]):boolean -- Configure the interface.")
|
||||
public Object[] setInterfaceConfiguration(Context context, Arguments args) {
|
||||
IInventory config = tileEntity.getInternalInventory();
|
||||
int slot = args.isString(0) ? 0 : optSlot(args, config, 0, 0);
|
||||
config.setInventorySlotContents(slot, getStack(args));
|
||||
context.pause(0.5);
|
||||
return new Object[] {true};
|
||||
}
|
||||
|
||||
@Callback(doc = "function([slot:number]):table -- Get the given pattern in the interface.")
|
||||
public Object[] getInterfacePattern(Context context, Arguments args) {
|
||||
IInventory inv = tileEntity.getInternalInventory();
|
||||
int slot = optSlot(args, inv, 0, 0);
|
||||
ItemStack stack = inv.getStackInSlot(slot);
|
||||
return new Object[] {stack};
|
||||
}
|
||||
|
||||
@Callback(doc = "function(slot:number, database:address, entry:number, size:number, index:number):boolean -- Set the pattern item input at the given index.")
|
||||
public Object[] setInterfacePatternItemInput(Context context, Arguments args) {
|
||||
return setPatternSlot(context, args, "in", false);
|
||||
}
|
||||
|
||||
@Callback(doc = "function(slot:number, database:address, entry:number, size:number, index:number):boolean -- Set the pattern item output at the given index.")
|
||||
public Object[] setInterfacePatternItemOutput(Context context, Arguments args) {
|
||||
return setPatternSlot(context, args, "out", false);
|
||||
}
|
||||
|
||||
@Callback(doc = "function(slot:number, database:address, entry:number, size:number, index:number):boolean -- Set the pattern fluid input at the given index.")
|
||||
public Object[] setInterfacePatternFluidInput(Context context, Arguments args) {
|
||||
return setPatternSlot(context, args, "in", true);
|
||||
}
|
||||
|
||||
@Callback(doc = "function(slot:number, database:address, entry:number, size:number, index:number):boolean -- Set the pattern fluid output at the given index.")
|
||||
public Object[] setInterfacePatternFluidOutput(Context context, Arguments args) {
|
||||
return setPatternSlot(context, args, "out", true);
|
||||
}
|
||||
|
||||
@Callback(doc = "function(slot:number, index:number):boolean -- Clear pattern input at the given index.")
|
||||
public Object[] clearInterfacePatternInput(Context context, Arguments args) {
|
||||
return clearInterfacePattern(context, args, "in");
|
||||
}
|
||||
|
||||
@Callback(doc = "function(slot:number, index:number):boolean -- Clear pattern output at the given index.")
|
||||
public Object[] clearInterfacePatternOutput(Context context, Arguments args) {
|
||||
return clearInterfacePattern(context, args, "out");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String preferredName() {
|
||||
return NameConst.BLOCK_OC_PATTERN_EDITOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int priority() {
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Provider implements EnvironmentProvider {
|
||||
Provider() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getEnvironment(ItemStack itemStack) {
|
||||
if (itemStack != null && itemStack.isItemEqual(ItemAndBlockHolder.OC_EDITOR.stack())) {
|
||||
return DriverOCPatternEditor.Environment.class;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.glodblock.github.crossmod.opencomputers;
|
||||
|
||||
import li.cil.oc.api.Driver;
|
||||
|
||||
public class OCDriverInit {
|
||||
|
||||
public static void run() {
|
||||
Driver.add(new DriverOCPatternEditor());
|
||||
Driver.add(new DriverOCPatternEditor.Provider());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -39,9 +39,9 @@ public class AEFluidInventory implements IAEFluidTank
|
||||
{
|
||||
if( slot >= 0 && slot < this.getSlots() )
|
||||
{
|
||||
if( Objects.equals( this.fluids[slot], fluid ) )
|
||||
if( fluid != null && this.fluids[slot] != null && fluid.getFluidStack().isFluidEqual(this.fluids[slot].getFluidStack()) )
|
||||
{
|
||||
if( fluid != null && fluid.getStackSize() != this.fluids[slot].getStackSize() )
|
||||
if(fluid.getStackSize() != this.fluids[slot].getStackSize())
|
||||
{
|
||||
this.fluids[slot].setStackSize( Math.min( fluid.getStackSize(), this.capacity ) );
|
||||
this.onContentChanged( slot );
|
||||
@@ -82,6 +82,15 @@ public class AEFluidInventory implements IAEFluidTank
|
||||
return null;
|
||||
}
|
||||
|
||||
public FluidStack getFluidStackInSlot( final int slot )
|
||||
{
|
||||
if( getFluidInSlot(slot) != null )
|
||||
{
|
||||
return getFluidInSlot(slot).getFluidStack();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlots()
|
||||
{
|
||||
@@ -141,7 +150,7 @@ public class AEFluidInventory implements IAEFluidTank
|
||||
public FluidStack drain( final int slot, final FluidStack resource, final boolean doDrain )
|
||||
{
|
||||
final IAEFluidStack fluid = this.fluids[slot];
|
||||
if(fluid == null || !fluid.getFluidStack().equals(resource))
|
||||
if(fluid == null || !fluid.getFluidStack().isFluidEqual(resource))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -212,6 +221,9 @@ public class AEFluidInventory implements IAEFluidTank
|
||||
FluidStack totalDrained = null;
|
||||
for( int slot = 0; slot < this.getSlots(); ++slot )
|
||||
{
|
||||
if (!fluid.isFluidEqual(getFluidStackInSlot(slot))) {
|
||||
continue;
|
||||
}
|
||||
FluidStack drain = this.drain( slot, resource, doDrain );
|
||||
if( drain != null )
|
||||
{
|
||||
@@ -247,6 +259,10 @@ public class AEFluidInventory implements IAEFluidTank
|
||||
|
||||
for( int slot = 0; slot < this.getSlots(); ++slot )
|
||||
{
|
||||
if (this.getFluidInSlot(slot) == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if( totalDrained == null )
|
||||
{
|
||||
totalDrained = this.drain( slot, toDrain, doDrain );
|
||||
@@ -375,7 +391,7 @@ public class AEFluidInventory implements IAEFluidTank
|
||||
|
||||
@Override
|
||||
public int fill(FluidStack resource, boolean doFill) {
|
||||
if (resource == null || (getFluid() != null && !resource.equals(getFluid()))) return 0;
|
||||
if (resource == null || (getFluid() != null && !resource.isFluidEqual(getFluid()))) return 0;
|
||||
int acc = 0;
|
||||
if (getFluid() == null) {
|
||||
acc = Math.min(resource.amount, getCapacity());
|
||||
|
||||
@@ -11,10 +11,7 @@ import com.glodblock.github.client.gui.container.*;
|
||||
import com.glodblock.github.common.parts.FCBasePart;
|
||||
import com.glodblock.github.common.parts.PartFluidInterface;
|
||||
import com.glodblock.github.common.parts.PartSharedFluidBus;
|
||||
import com.glodblock.github.common.tile.TileFluidInterface;
|
||||
import com.glodblock.github.common.tile.TileFluidPacketDecoder;
|
||||
import com.glodblock.github.common.tile.TileFluidPatternEncoder;
|
||||
import com.glodblock.github.common.tile.TileIngredientBuffer;
|
||||
import com.glodblock.github.common.tile.*;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
@@ -23,6 +20,18 @@ import java.util.List;
|
||||
|
||||
public enum GuiType {
|
||||
|
||||
OC_PATTERN_EDITOR(new TileGuiFactory<TileOCPatternEditor>(TileOCPatternEditor.class) {
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, TileOCPatternEditor inv) {
|
||||
return new ContainerOCPatternEditor(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, TileOCPatternEditor inv) {
|
||||
return new GuiOCPatternEditor(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
|
||||
DUAL_INTERFACE_PART(new PartGuiFactory<PartFluidInterface>(PartFluidInterface.class) {
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, PartFluidInterface inv) {
|
||||
|
||||
@@ -29,6 +29,7 @@ public class ItemAndBlockHolder {
|
||||
public static BlockFluidPacketDecoder DECODER = new BlockFluidPacketDecoder().register();
|
||||
public static BlockFluidInterface INTERFACE = new BlockFluidInterface().register();
|
||||
public static BlockIngredientBuffer BUFFER = new BlockIngredientBuffer().register();
|
||||
public static BlockOCPatternEditor OC_EDITOR = new BlockOCPatternEditor().register();
|
||||
|
||||
public static void loadSetting() {
|
||||
if (!Config.fluidCells) return;
|
||||
|
||||
@@ -176,13 +176,13 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable<
|
||||
NBTTagCompound tag = Objects.requireNonNull(patternStack.getTagCompound());
|
||||
// may be possible to enter a partially-correct state if setInputs succeeds but setOutputs failed
|
||||
// but outside code should treat it as completely incorrect and not attempt to make calls
|
||||
return setInputs(readStackArray(tag.getTagList("in", Constants.NBT.TAG_COMPOUND), 16))
|
||||
&& setOutputs(readStackArray(tag.getTagList("out", Constants.NBT.TAG_COMPOUND), 4));
|
||||
return setInputs(readStackArray(tag.getTagList("in", Constants.NBT.TAG_COMPOUND)))
|
||||
&& setOutputs(readStackArray(tag.getTagList("out", Constants.NBT.TAG_COMPOUND)));
|
||||
}
|
||||
|
||||
public static IAEItemStack[] readStackArray(NBTTagList listTag, int maxCount) {
|
||||
public static IAEItemStack[] readStackArray(NBTTagList listTag) {
|
||||
// see note at top of class
|
||||
IAEItemStack[] stacks = new IAEItemStack[Math.min(listTag.tagCount(), maxCount)];
|
||||
IAEItemStack[] stacks = new IAEItemStack[listTag.tagCount()];
|
||||
for (int i = 0; i < stacks.length; i++) {
|
||||
stacks[i] = AEItemStack.loadItemStackFromNBT(listTag.getCompoundTagAt(i));
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ public final class ModAndClassUtil {
|
||||
public static boolean EC2 = false;
|
||||
public static boolean EIO = false;
|
||||
public static boolean FTR = false;
|
||||
public static boolean OC = false;
|
||||
|
||||
public static boolean isDoubleButton;
|
||||
public static boolean isSaveText;
|
||||
@@ -95,7 +96,8 @@ public final class ModAndClassUtil {
|
||||
EIO = true;
|
||||
if (Loader.isModLoaded("Forestry"))
|
||||
FTR = true;
|
||||
|
||||
if (Loader.isModLoaded("OpenComputers"))
|
||||
OC = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ public class NameConst {
|
||||
public static final String BLOCK_FLUID_PACKET_DECODER = "fluid_packet_decoder";
|
||||
public static final String BLOCK_FLUID_INTERFACE = "fluid_interface";
|
||||
public static final String BLOCK_INGREDIENT_BUFFER = "ingredient_buffer";
|
||||
public static final String BLOCK_OC_PATTERN_EDITOR = "oc_pattern_editor";
|
||||
|
||||
public static final String ITEM_FLUID_DROP = "fluid_drop";
|
||||
public static final String ITEM_FLUID_ENCODED_PATTERN = "fluid_encoded_pattern";
|
||||
@@ -37,5 +38,6 @@ public class NameConst {
|
||||
public static final String GUI_FLUID_PACKET_DECODER = GUI_KEY + BLOCK_FLUID_PACKET_DECODER;
|
||||
public static final String GUI_INGREDIENT_BUFFER = GUI_KEY + BLOCK_INGREDIENT_BUFFER;
|
||||
public static final String GUI_FLUID_INTERFACE = GUI_KEY + BLOCK_FLUID_INTERFACE;
|
||||
public static final String GUI_OC_PATTERN_EDITOR = GUI_KEY + BLOCK_OC_PATTERN_EDITOR;
|
||||
|
||||
}
|
||||
@@ -26,6 +26,7 @@ tile.fluid_pattern_encoder.name=Fluid Pattern Encoder
|
||||
tile.fluid_packet_decoder.name=ME Fluid Packet Decoder
|
||||
tile.fluid_interface.name=ME Dual Interface
|
||||
tile.ingredient_buffer.name=Ingredient Buffer
|
||||
tile.oc_pattern_editor.name=OC Pattern Editor
|
||||
|
||||
ae2fc.tooltip.invalid_fluid=Invalid fluid!
|
||||
ae2fc.tooltip.encode_pattern=Encode Patter
|
||||
@@ -40,3 +41,10 @@ ae2fc.gui.fluid_pattern_encoder=Fluid Pattern Encoder
|
||||
ae2fc.gui.fluid_packet_decoder=ME Fluid Packet Decoder
|
||||
ae2fc.gui.ingredient_buffer=Ingredient Buffer
|
||||
ae2fc.gui.fluid_interface=ME Dual Interface
|
||||
ae2fc.gui.fluid_interface.0=D
|
||||
ae2fc.gui.fluid_interface.1=U
|
||||
ae2fc.gui.fluid_interface.2=N
|
||||
ae2fc.gui.fluid_interface.3=S
|
||||
ae2fc.gui.fluid_interface.4=W
|
||||
ae2fc.gui.fluid_interface.5=E
|
||||
ae2fc.gui.oc_pattern_editor=OC Pattern Editor
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 320 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Reference in new issue
Block a user