mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Fixed a Bug with Number Key Slot Swapping and the Drill being movable, added Armor Slots to the Energizer & Enervator
This commit is contained in:
parent
5de08fc41f
commit
adb64232e7
8 changed files with 78 additions and 11 deletions
|
@ -62,6 +62,14 @@ public class ContainerDrill extends Container{
|
||||||
super.onContainerClosed(player);
|
super.onContainerClosed(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack slotClick(int par1, int par2, int par3, EntityPlayer player){
|
||||||
|
//par3 appears to be the type of clicking
|
||||||
|
//par3 == 2 appears to be one of the number keys being hit
|
||||||
|
if(par3 == 2 && par2 == inventory.currentItem) return null;
|
||||||
|
else return super.slotClick(par1, par2, par3, player);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack transferStackInSlot(EntityPlayer player, int slot){
|
public ItemStack transferStackInSlot(EntityPlayer player, int slot){
|
||||||
final int inventoryStart = 5;
|
final int inventoryStart = 5;
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package ellpeck.actuallyadditions.inventory;
|
package ellpeck.actuallyadditions.inventory;
|
||||||
|
|
||||||
import cofh.api.energy.IEnergyContainerItem;
|
import cofh.api.energy.IEnergyContainerItem;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import ellpeck.actuallyadditions.inventory.slot.SlotOutput;
|
import ellpeck.actuallyadditions.inventory.slot.SlotOutput;
|
||||||
import ellpeck.actuallyadditions.tile.TileEntityBase;
|
import ellpeck.actuallyadditions.tile.TileEntityBase;
|
||||||
import ellpeck.actuallyadditions.tile.TileEntityEnergizer;
|
import ellpeck.actuallyadditions.tile.TileEntityEnergizer;
|
||||||
|
@ -9,15 +11,18 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
|
import net.minecraft.item.ItemArmor;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.IIcon;
|
||||||
|
|
||||||
@InventoryContainer
|
@InventoryContainer
|
||||||
public class ContainerEnergizer extends Container{
|
public class ContainerEnergizer extends Container{
|
||||||
|
|
||||||
private TileEntityEnergizer energizer;
|
private TileEntityEnergizer energizer;
|
||||||
|
|
||||||
public ContainerEnergizer(InventoryPlayer inventory, TileEntityBase tile){
|
public ContainerEnergizer(EntityPlayer player, TileEntityBase tile){
|
||||||
this.energizer = (TileEntityEnergizer)tile;
|
this.energizer = (TileEntityEnergizer)tile;
|
||||||
|
InventoryPlayer inventory = player.inventory;
|
||||||
|
|
||||||
this.addSlotToContainer(new Slot(this.energizer, 0, 76, 73));
|
this.addSlotToContainer(new Slot(this.energizer, 0, 76, 73));
|
||||||
this.addSlotToContainer(new SlotOutput(this.energizer, 1, 76, 42));
|
this.addSlotToContainer(new SlotOutput(this.energizer, 1, 76, 42));
|
||||||
|
@ -30,6 +35,25 @@ public class ContainerEnergizer extends Container{
|
||||||
for (int i = 0; i < 9; i++){
|
for (int i = 0; i < 9; i++){
|
||||||
this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155));
|
this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155));
|
||||||
}
|
}
|
||||||
|
final EntityPlayer finalPlayer = player;
|
||||||
|
for(int i = 0; i < 4; ++i){
|
||||||
|
final int finalI = i;
|
||||||
|
this.addSlotToContainer(new Slot(inventory, inventory.getSizeInventory()-1-i, 102, 19+i*18){
|
||||||
|
@Override
|
||||||
|
public int getSlotStackLimit(){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean isItemValid(ItemStack stack){
|
||||||
|
return stack != null && stack.getItem().isValidArmor(stack, finalI, finalPlayer);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public IIcon getBackgroundIconIndex(){
|
||||||
|
return ItemArmor.func_94602_b(finalI);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -37,6 +61,7 @@ public class ContainerEnergizer extends Container{
|
||||||
return this.energizer.isUseableByPlayer(player);
|
return this.energizer.isUseableByPlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO Armor Shift-Clicking
|
||||||
@Override
|
@Override
|
||||||
public ItemStack transferStackInSlot(EntityPlayer player, int slot){
|
public ItemStack transferStackInSlot(EntityPlayer player, int slot){
|
||||||
final int inventoryStart = 2;
|
final int inventoryStart = 2;
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package ellpeck.actuallyadditions.inventory;
|
package ellpeck.actuallyadditions.inventory;
|
||||||
|
|
||||||
import cofh.api.energy.IEnergyContainerItem;
|
import cofh.api.energy.IEnergyContainerItem;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import ellpeck.actuallyadditions.inventory.slot.SlotOutput;
|
import ellpeck.actuallyadditions.inventory.slot.SlotOutput;
|
||||||
import ellpeck.actuallyadditions.tile.TileEntityBase;
|
import ellpeck.actuallyadditions.tile.TileEntityBase;
|
||||||
import ellpeck.actuallyadditions.tile.TileEntityEnervator;
|
import ellpeck.actuallyadditions.tile.TileEntityEnervator;
|
||||||
|
@ -9,15 +11,18 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
|
import net.minecraft.item.ItemArmor;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.IIcon;
|
||||||
|
|
||||||
@InventoryContainer
|
@InventoryContainer
|
||||||
public class ContainerEnervator extends Container{
|
public class ContainerEnervator extends Container{
|
||||||
|
|
||||||
private TileEntityEnervator enervator;
|
private TileEntityEnervator enervator;
|
||||||
|
|
||||||
public ContainerEnervator(InventoryPlayer inventory, TileEntityBase tile){
|
public ContainerEnervator(EntityPlayer player, TileEntityBase tile){
|
||||||
this.enervator = (TileEntityEnervator)tile;
|
this.enervator = (TileEntityEnervator)tile;
|
||||||
|
InventoryPlayer inventory = player.inventory;
|
||||||
|
|
||||||
this.addSlotToContainer(new Slot(this.enervator, 0, 76, 73));
|
this.addSlotToContainer(new Slot(this.enervator, 0, 76, 73));
|
||||||
this.addSlotToContainer(new SlotOutput(this.enervator, 1, 76, 42));
|
this.addSlotToContainer(new SlotOutput(this.enervator, 1, 76, 42));
|
||||||
|
@ -30,6 +35,25 @@ public class ContainerEnervator extends Container{
|
||||||
for (int i = 0; i < 9; i++){
|
for (int i = 0; i < 9; i++){
|
||||||
this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155));
|
this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155));
|
||||||
}
|
}
|
||||||
|
final EntityPlayer finalPlayer = player;
|
||||||
|
for(int i = 0; i < 4; ++i){
|
||||||
|
final int finalI = i;
|
||||||
|
this.addSlotToContainer(new Slot(inventory, inventory.getSizeInventory()-1-i, 102, 19+i*18){
|
||||||
|
@Override
|
||||||
|
public int getSlotStackLimit(){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean isItemValid(ItemStack stack){
|
||||||
|
return stack != null && stack.getItem().isValidArmor(stack, finalI, finalPlayer);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public IIcon getBackgroundIconIndex(){
|
||||||
|
return ItemArmor.func_94602_b(finalI);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -37,6 +61,7 @@ public class ContainerEnervator extends Container{
|
||||||
return this.enervator.isUseableByPlayer(player);
|
return this.enervator.isUseableByPlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO Armor Shift-Clicking
|
||||||
@Override
|
@Override
|
||||||
public ItemStack transferStackInSlot(EntityPlayer player, int slot){
|
public ItemStack transferStackInSlot(EntityPlayer player, int slot){
|
||||||
final int inventoryStart = 2;
|
final int inventoryStart = 2;
|
||||||
|
|
|
@ -57,9 +57,9 @@ public class GuiHandler implements IGuiHandler{
|
||||||
case DRILL_ID:
|
case DRILL_ID:
|
||||||
return new ContainerDrill(entityPlayer.inventory);
|
return new ContainerDrill(entityPlayer.inventory);
|
||||||
case ENERGIZER_ID:
|
case ENERGIZER_ID:
|
||||||
return new ContainerEnergizer(entityPlayer.inventory, tile);
|
return new ContainerEnergizer(entityPlayer, tile);
|
||||||
case ENERVATOR_ID:
|
case ENERVATOR_ID:
|
||||||
return new ContainerEnervator(entityPlayer.inventory, tile);
|
return new ContainerEnervator(entityPlayer, tile);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -111,9 +111,9 @@ public class GuiHandler implements IGuiHandler{
|
||||||
case DRILL_ID:
|
case DRILL_ID:
|
||||||
return new GuiDrill(entityPlayer.inventory);
|
return new GuiDrill(entityPlayer.inventory);
|
||||||
case ENERGIZER_ID:
|
case ENERGIZER_ID:
|
||||||
return new GuiEnergizer(entityPlayer.inventory, tile);
|
return new GuiEnergizer(entityPlayer, tile);
|
||||||
case ENERVATOR_ID:
|
case ENERVATOR_ID:
|
||||||
return new GuiEnervator(entityPlayer.inventory, tile);
|
return new GuiEnervator(entityPlayer, tile);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import ellpeck.actuallyadditions.tile.TileEntityBase;
|
||||||
import ellpeck.actuallyadditions.tile.TileEntityEnergizer;
|
import ellpeck.actuallyadditions.tile.TileEntityEnergizer;
|
||||||
import ellpeck.actuallyadditions.util.AssetUtil;
|
import ellpeck.actuallyadditions.util.AssetUtil;
|
||||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ public class GuiEnergizer extends GuiContainer{
|
||||||
|
|
||||||
private static final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiEnergizer");
|
private static final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiEnergizer");
|
||||||
|
|
||||||
public GuiEnergizer(InventoryPlayer inventory, TileEntityBase tile){
|
public GuiEnergizer(EntityPlayer inventory, TileEntityBase tile){
|
||||||
super(new ContainerEnergizer(inventory, tile));
|
super(new ContainerEnergizer(inventory, tile));
|
||||||
this.energizer = (TileEntityEnergizer)tile;
|
this.energizer = (TileEntityEnergizer)tile;
|
||||||
this.xSize = 176;
|
this.xSize = 176;
|
||||||
|
|
|
@ -7,7 +7,7 @@ import ellpeck.actuallyadditions.tile.TileEntityBase;
|
||||||
import ellpeck.actuallyadditions.tile.TileEntityEnervator;
|
import ellpeck.actuallyadditions.tile.TileEntityEnervator;
|
||||||
import ellpeck.actuallyadditions.util.AssetUtil;
|
import ellpeck.actuallyadditions.util.AssetUtil;
|
||||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ public class GuiEnervator extends GuiContainer{
|
||||||
|
|
||||||
private static final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiEnergizer");
|
private static final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiEnergizer");
|
||||||
|
|
||||||
public GuiEnervator(InventoryPlayer inventory, TileEntityBase tile){
|
public GuiEnervator(EntityPlayer inventory, TileEntityBase tile){
|
||||||
super(new ContainerEnervator(inventory, tile));
|
super(new ContainerEnervator(inventory, tile));
|
||||||
this.enervator = (TileEntityEnervator)tile;
|
this.enervator = (TileEntityEnervator)tile;
|
||||||
this.xSize = 176;
|
this.xSize = 176;
|
||||||
|
|
|
@ -11,6 +11,16 @@ public class SlotImmovable extends Slot{
|
||||||
super(inventory, id, x, y);
|
super(inventory, id, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void putStack(ItemStack stack){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack decrStackSize(int i){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canTakeStack(EntityPlayer player){
|
public boolean canTakeStack(EntityPlayer player){
|
||||||
return false;
|
return false;
|
||||||
|
@ -20,5 +30,4 @@ public class SlotImmovable extends Slot{
|
||||||
public boolean isItemValid(ItemStack stack){
|
public boolean isItemValid(ItemStack stack){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Loading…
Reference in a new issue