Merge pull request #1748 from tambry/architectshiftclickfix

Fix shift-clicking in architect table, fix #1740
This commit is contained in:
SpaceToad 2014-05-08 18:20:48 +02:00
commit f344a4aed2
4 changed files with 48 additions and 21 deletions

View file

@ -43,7 +43,7 @@ public class GuiHandler implements IGuiHandler {
if (!(tile instanceof TileArchitect)) {
return null;
}
return new GuiArchitect(player.inventory, (TileArchitect) tile);
return new GuiArchitect(player, (TileArchitect) tile);
case GuiIds.BLUEPRINT_LIBRARY:
if (!(tile instanceof TileBlueprintLibrary)) {
@ -91,7 +91,7 @@ public class GuiHandler implements IGuiHandler {
if (!(tile instanceof TileArchitect)) {
return null;
}
return new ContainerArchitect(player.inventory, (TileArchitect) tile);
return new ContainerArchitect(player, (TileArchitect) tile);
case GuiIds.BLUEPRINT_LIBRARY:
if (!(tile instanceof TileBlueprintLibrary)) {

View file

@ -12,9 +12,10 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import buildcraft.builders.TileArchitect;
import buildcraft.core.gui.BuildCraftContainer;
import buildcraft.core.gui.slots.SlotArchitect;
import buildcraft.core.gui.slots.SlotOutput;
public class ContainerArchitect extends BuildCraftContainer {
@ -23,23 +24,23 @@ public class ContainerArchitect extends BuildCraftContainer {
protected TileArchitect architect;
protected int computingTime = 0;
public ContainerArchitect(IInventory playerInventory, TileArchitect template) {
public ContainerArchitect(EntityPlayer player, TileArchitect template) {
super(template.getSizeInventory());
this.playerIInventory = playerInventory;
this.playerIInventory = player.inventory;
this.architect = template;
addSlotToContainer(new Slot(template, 0, 135, 35));
addSlotToContainer(new SlotArchitect(template, player, 0, 135, 35));
addSlotToContainer(new SlotOutput(template, 1, 194, 35));
for (int l = 0; l < 3; l++) {
for (int k1 = 0; k1 < 9; k1++) {
addSlotToContainer(new Slot(playerInventory, k1 + l * 9 + 9, 88 + k1 * 18, 84 + l * 18));
addSlotToContainer(new Slot(player.inventory, k1 + l * 9 + 9, 88 + k1 * 18, 84 + l * 18));
}
}
for (int i1 = 0; i1 < 9; i1++) {
addSlotToContainer(new Slot(playerInventory, i1, 88 + i1 * 18, 142));
addSlotToContainer(new Slot(player.inventory, i1, 88 + i1 * 18, 142));
}
}
@ -77,14 +78,4 @@ public class ContainerArchitect extends BuildCraftContainer {
public boolean canInteractWith(EntityPlayer entityplayer) {
return architect.isUseableByPlayer(entityplayer);
}
@Override
public ItemStack slotClick(int slotNum, int mouseButton, int modifier, EntityPlayer player) {
if (slotNum == 0) {
architect.currentAuthorName = player.getDisplayName();
}
return super.slotClick(slotNum, mouseButton, modifier, player);
}
}

View file

@ -13,6 +13,7 @@ import org.lwjgl.opengl.GL11;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.ResourceLocation;
@ -45,9 +46,9 @@ public class GuiArchitect extends GuiBuildCraft {
private GuiTextField textField;
public GuiArchitect(IInventory playerInventory, TileArchitect architect) {
super(new ContainerArchitect(playerInventory, architect), architect, TEXTURE);
this.playerInventory = playerInventory;
public GuiArchitect(EntityPlayer player, TileArchitect architect) {
super(new ContainerArchitect(player, architect), architect, TEXTURE);
this.playerInventory = player.inventory;
this.architect = architect;
xSize = 256;
ySize = 166;

View file

@ -0,0 +1,35 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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.core.gui.slots;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import buildcraft.builders.TileArchitect;
public class SlotArchitect extends SlotBase {
private TileArchitect architect;
private EntityPlayer player;
private int slot;
public SlotArchitect(IInventory iinventory, EntityPlayer player, int slotIndex, int posX, int posY) {
super(iinventory, slotIndex, posX, posY);
this.architect = (TileArchitect) iinventory;
this.slot = slotIndex;
this.player = player;
}
@Override
public void onSlotChanged() {
if (slot == 0) {
architect.currentAuthorName = player.getDisplayName();
}
this.inventory.markDirty();
}
}