Merge branch 'tambry-librarygetnamewhenshift' into 6.0.x

This commit is contained in:
SpaceToad 2014-05-07 19:58:41 +02:00
commit f895948f41
2 changed files with 47 additions and 20 deletions

View file

@ -12,10 +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.TileBlueprintLibrary;
import buildcraft.core.gui.BuildCraftContainer;
import buildcraft.core.gui.slots.SlotBlueprintLibrary;
import buildcraft.core.gui.slots.SlotOutput;
public class ContainerBlueprintLibrary extends BuildCraftContainer {
@ -30,10 +30,10 @@ public class ContainerBlueprintLibrary extends BuildCraftContainer {
this.playerInventory = player.inventory;
this.library = library;
addSlotToContainer(new Slot(library, 0, 211, 61));
addSlotToContainer(new SlotBlueprintLibrary(library, player, 0, 211, 61));
addSlotToContainer(new SlotOutput(library, 1, 167, 61));
addSlotToContainer(new Slot(library, 2, 167, 79));
addSlotToContainer(new SlotBlueprintLibrary(library, player, 2, 167, 79));
addSlotToContainer(new SlotOutput(library, 3, 211, 79));
// Player inventory
@ -48,23 +48,6 @@ public class ContainerBlueprintLibrary extends BuildCraftContainer {
}
}
@Override
public ItemStack slotClick(int slotNum, int mouseButton, int modifier, EntityPlayer player) {
// When downloading or uploading a blueprint, the server needs to know
// who requested it. The way to do it so far is by recording the last
// player that clicks on the slots. To be improved if the method is
// not robust enough (e.g. what if the player is not logged anymore?
// is that robust against race conditions? etc.)
if (slotNum == 0) {
library.uploadingPlayer = player;
} else if (slotNum == 2) {
library.downloadingPlayer = player;
}
return super.slotClick(slotNum, mouseButton, modifier, player);
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();

View file

@ -0,0 +1,44 @@
/**
* 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.TileBlueprintLibrary;
public class SlotBlueprintLibrary extends SlotBase {
private TileBlueprintLibrary library;
private EntityPlayer player;
private int slot;
public SlotBlueprintLibrary(IInventory iinventory, EntityPlayer player, int slotIndex, int posX, int posY) {
super(iinventory, slotIndex, posX, posY);
this.library = (TileBlueprintLibrary) iinventory;
this.slot = slotIndex;
this.player = player;
}
@Override
public void onSlotChanged() {
// When downloading or uploading a blueprint, the server needs to know
// who requested it. The way to do it so far is by recording the last
// player that clicks on the slots. To be improved if the method is
// not robust enough (e.g. what if the player is not logged anymore?
// is that robust against race conditions? etc.)
if (slot == 0) {
library.uploadingPlayer = player;
} else if (slot == 2) {
library.downloadingPlayer = player;
}
this.inventory.markDirty();
}
}