mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
boring ahh GUI crap
This commit is contained in:
parent
1a318e2867
commit
6918974095
@ -1,5 +1,6 @@
|
||||
package com.hbm.inventory.container;
|
||||
|
||||
import com.hbm.inventory.SlotPattern;
|
||||
import com.hbm.inventory.SlotUpgrade;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.tileentity.network.TileEntityCraneExtractor;
|
||||
@ -20,7 +21,7 @@ public class ContainerCraneExtractor extends Container {
|
||||
//filter
|
||||
for(int i = 0; i < 3; i++) {
|
||||
for(int j = 0; j < 3; j++) {
|
||||
this.addSlotToContainer(new Slot(extractor, j + i * 3, 71 + j * 18, 17 + i * 18));
|
||||
this.addSlotToContainer(new SlotPattern(extractor, j + i * 3, 71 + j * 18, 17 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ public class ContainerDroneDock extends ContainerCrateBase {
|
||||
public ContainerDroneDock(InventoryPlayer invPlayer, TileEntityDroneDock tedf) {
|
||||
super(tedf);
|
||||
|
||||
for(int i = 0; i < 34; i++) {
|
||||
for(int i = 0; i < 3; i++) {
|
||||
for(int j = 0; j < 3; j++) {
|
||||
this.addSlotToContainer(new Slot(tedf, j + i * 3, 62 + j * 18, 17 + i * 18));
|
||||
}
|
||||
|
||||
@ -2,15 +2,17 @@ package com.hbm.inventory.container;
|
||||
|
||||
import com.hbm.tileentity.network.TileEntityDroneProvider;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerDroneProvider extends ContainerCrateBase {
|
||||
|
||||
public ContainerDroneProvider(InventoryPlayer invPlayer, TileEntityDroneProvider tedf) {
|
||||
super(tedf);
|
||||
|
||||
for(int i = 0; i < 34; i++) {
|
||||
for(int i = 0; i < 3; i++) {
|
||||
for(int j = 0; j < 3; j++) {
|
||||
this.addSlotToContainer(new Slot(tedf, j + i * 3, 62 + j * 18, 17 + i * 18));
|
||||
}
|
||||
@ -26,4 +28,35 @@ public class ContainerDroneProvider extends ContainerCrateBase {
|
||||
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 161));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int par2) {
|
||||
ItemStack var3 = null;
|
||||
Slot var4 = (Slot) this.inventorySlots.get(par2);
|
||||
|
||||
if(var4 != null && var4.getHasStack()) {
|
||||
ItemStack var5 = var4.getStack();
|
||||
var3 = var5.copy();
|
||||
|
||||
if(par2 < 9) return null; //ignore filters
|
||||
|
||||
if(par2 <= crate.getSizeInventory() - 1) {
|
||||
if(!this.mergeItemStack(var5, crate.getSizeInventory(), this.inventorySlots.size(), true)) {
|
||||
return null;
|
||||
}
|
||||
} else if(!this.mergeItemStack(var5, 9, crate.getSizeInventory(), false)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(var5.stackSize == 0) {
|
||||
var4.putStack((ItemStack) null);
|
||||
} else {
|
||||
var4.onSlotChanged();
|
||||
}
|
||||
|
||||
var4.onPickupFromSlot(p_82846_1_, var5);
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,77 @@
|
||||
package com.hbm.inventory.container;
|
||||
|
||||
import com.hbm.inventory.SlotPattern;
|
||||
import com.hbm.tileentity.network.TileEntityDroneRequester;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerDroneRequester extends ContainerCrateBase {
|
||||
|
||||
public ContainerDroneRequester(InventoryPlayer invPlayer, TileEntityDroneRequester tedf) {
|
||||
super(tedf);
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
for(int j = 0; j < 3; j++) {
|
||||
this.addSlotToContainer(new SlotPattern(tedf, j + i * 3, 98 + j * 18, 17 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
for(int j = 0; j < 3; j++) {
|
||||
this.addSlotToContainer(new Slot(tedf, j + i * 3 + 9, 26 + j * 18, 17 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
for(int j = 0; j < 9; j++) {
|
||||
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 103 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < 9; i++) {
|
||||
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 161));
|
||||
}
|
||||
}
|
||||
|
||||
@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 > 8) {
|
||||
return super.slotClick(index, button, mode, player);
|
||||
}
|
||||
|
||||
Slot slot = this.getSlot(index);
|
||||
|
||||
ItemStack ret = null;
|
||||
ItemStack held = player.inventory.getItemStack();
|
||||
TileEntityDroneRequester requester = (TileEntityDroneRequester) crate;
|
||||
|
||||
if(slot.getHasStack())
|
||||
ret = slot.getStack().copy();
|
||||
|
||||
if(button == 1 && mode == 0 && slot.getHasStack()) {
|
||||
requester.nextMode(index);
|
||||
return ret;
|
||||
|
||||
} else {
|
||||
slot.putStack(held != null ? held.copy() : null);
|
||||
|
||||
if(slot.getHasStack()) {
|
||||
slot.getStack().stackSize = 1;
|
||||
}
|
||||
|
||||
slot.onSlotChanged();
|
||||
requester.matcher.initPatternStandard(requester.getWorldObj(), slot.getStack(), index);
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
69
src/main/java/com/hbm/inventory/gui/GUIDroneRequester.java
Normal file
69
src/main/java/com/hbm/inventory/gui/GUIDroneRequester.java
Normal file
@ -0,0 +1,69 @@
|
||||
package com.hbm.inventory.gui;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.inventory.container.ContainerDroneRequester;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.network.TileEntityDroneRequester;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GUIDroneRequester extends GuiInfoContainer {
|
||||
|
||||
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/storage/gui_drone_requester.png");
|
||||
private TileEntityDroneRequester diFurnace;
|
||||
|
||||
public GUIDroneRequester(InventoryPlayer invPlayer, TileEntityDroneRequester tedf) {
|
||||
super(new ContainerDroneRequester(invPlayer, tedf));
|
||||
diFurnace = tedf;
|
||||
|
||||
this.xSize = 176;
|
||||
this.ySize = 186;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int x, int y, float interp) {
|
||||
super.drawScreen(x, y, interp);
|
||||
|
||||
if(this.mc.thePlayer.inventory.getItemStack() == null) {
|
||||
for(int i = 0; i < 9; ++i) {
|
||||
Slot slot = (Slot) this.inventorySlots.inventorySlots.get(i);
|
||||
|
||||
if(this.isMouseOverSlot(slot, x, y) && diFurnace.matcher.modes[i] != null) {
|
||||
|
||||
String label = EnumChatFormatting.YELLOW + "";
|
||||
|
||||
switch(diFurnace.matcher.modes[i]) {
|
||||
case "exact": label += "Item and meta match"; break;
|
||||
case "wildcard": label += "Item matches"; break;
|
||||
default: label += "Ore dict key matches: " + diFurnace.matcher.modes[i]; break;
|
||||
}
|
||||
|
||||
this.func_146283_a(Arrays.asList(new String[] { EnumChatFormatting.RED + "Right click to change", label }), x, y - 30);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int i, int j) {
|
||||
String name = this.diFurnace.hasCustomInventoryName() ? this.diFurnace.getInventoryName() : I18n.format(this.diFurnace.getInventoryName());
|
||||
|
||||
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 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);
|
||||
}
|
||||
}
|
||||
@ -1,10 +1,19 @@
|
||||
package com.hbm.tileentity.network;
|
||||
|
||||
import com.hbm.inventory.container.ContainerDroneRequester;
|
||||
import com.hbm.inventory.gui.GUIDroneRequester;
|
||||
import com.hbm.module.ModulePatternMatcher;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TileEntityDroneRequester extends TileEntityRequestNetworkContainer {
|
||||
public class TileEntityDroneRequester extends TileEntityRequestNetworkContainer implements IGUIProvider {
|
||||
|
||||
public ModulePatternMatcher matcher;
|
||||
|
||||
@ -49,4 +58,15 @@ public class TileEntityDroneRequester extends TileEntityRequestNetworkContainer
|
||||
public boolean canExtractItem(int i, ItemStack stack, int j) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return new ContainerDroneRequester(player.inventory, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return new GUIDroneRequester(player.inventory, this);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user