diff --git a/src/main/java/api/hbm/redstoneoverradio/IRORInteractive.java b/src/main/java/api/hbm/redstoneoverradio/IRORInteractive.java index 86e5bb59f..518b23c87 100644 --- a/src/main/java/api/hbm/redstoneoverradio/IRORInteractive.java +++ b/src/main/java/api/hbm/redstoneoverradio/IRORInteractive.java @@ -9,7 +9,7 @@ public interface IRORInteractive extends IRORInfo { public static String EX_NAME = "Exception: Multiple Name Separators"; public static String EX_FORMAT = "Exception: Parameter in Invalid Format"; - /** Runs a function on the ROR component, usually causing the component to change or do something. Returns are optional. */ + /** Runs a function on the ROR component, usually causing the component to change or do something. Returns are unused for now. */ public String runRORFunction(String name, String[] params); /** Extracts the command name from a full command string */ diff --git a/src/main/java/com/hbm/inventory/SlotPattern.java b/src/main/java/com/hbm/inventory/SlotPattern.java index a6957c7ac..a1bdc6c67 100644 --- a/src/main/java/com/hbm/inventory/SlotPattern.java +++ b/src/main/java/com/hbm/inventory/SlotPattern.java @@ -29,7 +29,7 @@ public class SlotPattern extends Slot { @Override public int getSlotStackLimit() { - return 1; + return allowStackSize ? 64 : 1; } @Override @@ -37,7 +37,7 @@ public class SlotPattern extends Slot { if (stack != null) { stack = stack.copy(); - if (!allowStackSize) + if(!allowStackSize) stack.stackSize = 1; } super.putStack(stack); diff --git a/src/main/java/com/hbm/inventory/container/ContainerPneumoStorageExporter.java b/src/main/java/com/hbm/inventory/container/ContainerPneumoStorageExporter.java new file mode 100644 index 000000000..95776aa6d --- /dev/null +++ b/src/main/java/com/hbm/inventory/container/ContainerPneumoStorageExporter.java @@ -0,0 +1,44 @@ +package com.hbm.inventory.container; + +import com.hbm.inventory.SlotPattern; +import com.hbm.tileentity.network.pneumatic.TileEntityPneumoStorageExporter; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class ContainerPneumoStorageExporter extends ContainerBase { + + public ContainerPneumoStorageExporter(InventoryPlayer invPlayer, TileEntityPneumoStorageExporter exporter) { + super(invPlayer, exporter); + + for(int i = 0; i < 9; i++) { + this.addSlotToContainer(new SlotPattern(exporter, i, 17 + (i % 3) * 18, 17 + (i / 3) * 18, true)); + } + + addSlots(exporter, 9, 80, 17, 3, 3); + playerInv(invPlayer, 103); + } + + @Override + public ItemStack slotClick(int index, int button, int mode, EntityPlayer player) { + + //L/R: 0 + //M3: 3 + //SHIFT: 1 + //DRAG: 5 + + if(index < 0 || index >= 9) { + return super.slotClick(index, button, mode, player); + } + + Slot slot = this.getSlot(index); + ItemStack ret = null; + ItemStack held = player.inventory.getItemStack(); + + if(slot.getHasStack()) ret = slot.getStack().copy(); + slot.putStack(held); + return ret; + } +} diff --git a/src/main/java/com/hbm/inventory/gui/GUIPneumoStorageExporter.java b/src/main/java/com/hbm/inventory/gui/GUIPneumoStorageExporter.java new file mode 100644 index 000000000..2f7001c41 --- /dev/null +++ b/src/main/java/com/hbm/inventory/gui/GUIPneumoStorageExporter.java @@ -0,0 +1,60 @@ +package com.hbm.inventory.gui; + +import org.lwjgl.opengl.GL11; + +import com.hbm.inventory.container.ContainerPneumoStorageExporter; +import com.hbm.lib.RefStrings; +import com.hbm.tileentity.network.pneumatic.TileEntityPneumoStorageExporter; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; + +public class GUIPneumoStorageExporter extends GuiInfoContainer { + + private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/storage/gui_pneumatic_exporter.png"); + private TileEntityPneumoStorageExporter importer; + + public GUIPneumoStorageExporter(InventoryPlayer invPlayer, TileEntityPneumoStorageExporter importer) { + super(new ContainerPneumoStorageExporter(invPlayer, importer)); + this.importer = importer; + + this.xSize = 176; + this.ySize = 185; + } + + @Override + public void drawScreen(int x, int y, float interp) { + super.drawScreen(x, y, interp); + } + + @Override + protected void mouseClicked(int x, int y, int i) { + super.mouseClicked(x, y, i); + + clickSendFlag(importer, x, y, 142, 16, 18, 18, "continuous"); + clickSendFlag(importer, x, y, 142, 34, 18, 18, "request"); + clickSendFlag(importer, x, y, 142, 52, 18, 18, "ror"); + } + + @Override + protected void drawGuiContainerForegroundLayer(int i, int j) { + String name = this.importer.hasCustomInventoryName() ? this.importer.getInventoryName() : I18n.format(this.importer.getInventoryName()); + + this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 5, 4210752); + this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + Minecraft.getMinecraft().getTextureManager().bindTexture(texture); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + + if(!this.importer.continuousRequest) drawTexturedModalRect(guiLeft + 142, guiTop + 16, xSize, 0, 18, 18); + if(!this.importer.rorConfiguredMode) drawTexturedModalRect(guiLeft + 142, guiTop + 52, xSize, 18, 18, 18); + if(this.importer.requestMode == importer.MODE_FULL_STACK) drawTexturedModalRect(guiLeft + 142, guiTop + 34, xSize + 18, 0, 18, 18); + if(this.importer.requestMode == importer.MODE_FULL_REQUEST) drawTexturedModalRect(guiLeft + 142, guiTop + 34, xSize + 18, 18, 18, 18); + } +} diff --git a/src/main/java/com/hbm/inventory/gui/GUIPneumoStorageImporter.java b/src/main/java/com/hbm/inventory/gui/GUIPneumoStorageImporter.java index b55b30e4f..79f7fbcc1 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIPneumoStorageImporter.java +++ b/src/main/java/com/hbm/inventory/gui/GUIPneumoStorageImporter.java @@ -22,7 +22,7 @@ public class GUIPneumoStorageImporter extends GuiContainer { this.importer = importer; this.xSize = 176; - this.ySize = 186; + this.ySize = 185; } @Override diff --git a/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumoStorageExporter.java b/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumoStorageExporter.java index 0bd594d5f..2c01aff94 100644 --- a/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumoStorageExporter.java +++ b/src/main/java/com/hbm/tileentity/network/pneumatic/TileEntityPneumoStorageExporter.java @@ -1,12 +1,18 @@ package com.hbm.tileentity.network.pneumatic; +import com.hbm.interfaces.IControlReceiver; +import com.hbm.inventory.container.ContainerPneumoStorageExporter; +import com.hbm.inventory.gui.GUIPneumoStorageExporter; + import api.hbm.redstoneoverradio.IRORInteractive; +import io.netty.buffer.ByteBuf; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineBase implements IRORInteractive { +public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineBase implements IRORInteractive, IControlReceiver { /** If requests should be pulled repeatedly every tick */ public boolean continuousRequest = false; @@ -14,6 +20,8 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB public boolean rorConfiguredMode = false; /** What strategy to use for handling request filters */ public int requestMode = 0; + /** Item ID and meta pairs for RoR controlled filters */ + public short[][] rorFilters = new short[9][2]; /** Each slot individually tries to pull as much as it can of the configured item */ public static final int MODE_AS_MUCH_AS_POSSIBLE = 0; @@ -34,10 +42,55 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB @Override public void updateEntity() { super.updateEntity(); + + if(!worldObj.isRemote) { + this.networkPackNT(15); + } } - @Override public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { return null; } - @Override public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { return null; } + @Override + public void serialize(ByteBuf buf) { + super.serialize(buf); + buf.writeBoolean(continuousRequest); + buf.writeBoolean(rorConfiguredMode); + buf.writeByte((byte) requestMode); + for(int i = 0; i < 9; i++) { + buf.writeShort(rorFilters[i][0]); + buf.writeShort(rorFilters[i][1]); + } + } + + @Override + public void deserialize(ByteBuf buf) { + super.deserialize(buf); + this.continuousRequest = buf.readBoolean(); + this.rorConfiguredMode = buf.readBoolean(); + this.requestMode = buf.readByte(); + for(int i = 0; i < 9; i++) { + rorFilters[i][0] = buf.readShort(); + rorFilters[i][1] = buf.readShort(); + } + } + + @Override public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { return new ContainerPneumoStorageExporter(player.inventory, this); } + @Override public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { return new GUIPneumoStorageExporter(player.inventory, this); } + + @Override public boolean hasPermission(EntityPlayer player) { return this.isUseableByPlayer(player); } + + @Override + public void receiveControl(NBTTagCompound data) { + if(data.hasKey("continuous")) { + this.continuousRequest = !this.continuousRequest; + } + if(data.hasKey("request")) { + this.requestMode++; + if(this.requestMode >= 3) this.requestMode = 0; + } + if(data.hasKey("ror")) { + this.rorConfiguredMode = !this.rorConfiguredMode; + } + this.markChanged(); + } @Override public String[] getFunctionInfo() { diff --git a/src/main/resources/assets/hbm/textures/blocks/hopper_turbo_side.png b/src/main/resources/assets/hbm/textures/blocks/hopper_turbo_side.png new file mode 100644 index 000000000..0704d875b Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/hopper_turbo_side.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/pneumatic_storage_exporter.png b/src/main/resources/assets/hbm/textures/blocks/pneumatic_storage_exporter.png new file mode 100644 index 000000000..90013ac56 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/pneumatic_storage_exporter.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/pneumatic_storage_importer.png b/src/main/resources/assets/hbm/textures/blocks/pneumatic_storage_importer.png index d9c89f323..f6ce9b8c2 100644 Binary files a/src/main/resources/assets/hbm/textures/blocks/pneumatic_storage_importer.png and b/src/main/resources/assets/hbm/textures/blocks/pneumatic_storage_importer.png differ