-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
55 changed files
with
1,610 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
src/main/java/com/windanesz/ancientspellcraft/client/gui/ContainerInventoryInItemStack.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package com.windanesz.ancientspellcraft.client.gui; | ||
|
||
import com.windanesz.ancientspellcraft.item.ItemGlyphArtefact; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.inventory.Container; | ||
import net.minecraft.inventory.IInventory; | ||
import net.minecraft.inventory.Slot; | ||
import net.minecraft.item.ItemStack; | ||
|
||
public class ContainerInventoryInItemStack extends Container { | ||
private final IInventory itemInventory; | ||
|
||
public ContainerInventoryInItemStack(IInventory playerInventory, IInventory itemInventory, EntityPlayer player) { | ||
this.itemInventory = itemInventory; | ||
itemInventory.openInventory(player); | ||
|
||
if (itemInventory instanceof InventoryInItemStack) { | ||
|
||
int rowCount = ((InventoryInItemStack) itemInventory).getRowCount(); | ||
int columnCount = ((InventoryInItemStack) itemInventory).getColumnCount(); | ||
int index = 0; | ||
|
||
int offsetX = itemInventory.getSizeInventory() == 9 ? 0 : -54; | ||
|
||
this.addSlotToContainer(new Slot(itemInventory, index, 80, 36) { | ||
@Override | ||
public boolean isItemValid(ItemStack stack) { | ||
return stack.getItem() instanceof ItemGlyphArtefact; | ||
} | ||
}); | ||
index++; | ||
this.addSlotToContainer(new Slot(itemInventory, index, 60, 76) { | ||
@Override | ||
public boolean isItemValid(ItemStack stack) { | ||
return stack.getItem() instanceof ItemGlyphArtefact; | ||
} | ||
}); | ||
index++; | ||
this.addSlotToContainer(new Slot(itemInventory, index, 100, 76) { | ||
@Override | ||
public boolean isItemValid(ItemStack stack) { | ||
return stack.getItem() instanceof ItemGlyphArtefact; | ||
} | ||
}); | ||
|
||
// player's inventory | ||
for (int i1 = 0; i1 < 3; ++i1) { | ||
for (int k1 = 0; k1 < 9; ++k1) { | ||
this.addSlotToContainer(new Slot(playerInventory, k1 + i1 * 9 + 9, 8 + k1 * 18, 134 + i1 * 18)); | ||
} | ||
} | ||
|
||
// player's inventory hotbar | ||
for (int j1 = 0; j1 < 9; ++j1) { | ||
this.addSlotToContainer(new Slot(playerInventory, j1, 8 + j1 * 18, 192)); | ||
} | ||
} | ||
} | ||
|
||
public boolean canInteractWith(EntityPlayer playerIn) { | ||
return this.itemInventory.isUsableByPlayer(playerIn); | ||
} | ||
|
||
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { | ||
ItemStack itemstack = ItemStack.EMPTY; | ||
Slot slot = this.inventorySlots.get(index); | ||
|
||
if (slot != null && slot.getHasStack()) { | ||
ItemStack itemstack1 = slot.getStack(); | ||
itemstack = itemstack1.copy(); | ||
|
||
if (index < this.itemInventory.getSizeInventory()) { | ||
if (!this.mergeItemStack(itemstack1, this.itemInventory.getSizeInventory(), this.inventorySlots.size(), true)) { | ||
return ItemStack.EMPTY; | ||
} | ||
} else if (this.getSlot(1).isItemValid(itemstack1) && !this.getSlot(1).getHasStack()) { | ||
if (!this.mergeItemStack(itemstack1, 1, 2, false)) { | ||
return ItemStack.EMPTY; | ||
} | ||
} else if (this.getSlot(0).isItemValid(itemstack1)) { | ||
if (!this.mergeItemStack(itemstack1, 0, 1, false)) { | ||
return ItemStack.EMPTY; | ||
} | ||
} else if (this.itemInventory.getSizeInventory() <= 2 || !this.mergeItemStack(itemstack1, 2, this.itemInventory.getSizeInventory(), false)) { | ||
return ItemStack.EMPTY; | ||
} | ||
|
||
if (itemstack1.isEmpty()) { | ||
slot.putStack(ItemStack.EMPTY); | ||
} else { | ||
slot.onSlotChanged(); | ||
} | ||
|
||
} | ||
|
||
return itemstack; | ||
} | ||
|
||
public void onContainerClosed(EntityPlayer playerIn) { | ||
super.onContainerClosed(playerIn); | ||
this.itemInventory.closeInventory(playerIn); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/com/windanesz/ancientspellcraft/client/gui/GuiScreenInventoryInItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.windanesz.ancientspellcraft.client.gui; | ||
|
||
import com.windanesz.ancientspellcraft.AncientSpellcraft; | ||
import net.minecraft.client.gui.inventory.GuiContainer; | ||
import net.minecraft.client.renderer.GlStateManager; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.inventory.IInventory; | ||
import net.minecraft.util.ResourceLocation; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
import net.minecraftforge.fml.relauncher.SideOnly; | ||
|
||
@SideOnly(Side.CLIENT) | ||
public class GuiScreenInventoryInItem extends GuiContainer { | ||
|
||
private final ResourceLocation GUI_BACKGROUND; | ||
|
||
public GuiScreenInventoryInItem(IInventory inventory, EntityPlayer player, String texture) { | ||
super(new ContainerInventoryInItemStack(player.inventory, inventory, player)); | ||
this.xSize = 176; | ||
this.ySize = 223; | ||
this.GUI_BACKGROUND = new ResourceLocation(AncientSpellcraft.MODID, "textures/gui/" + texture + ".png"); | ||
} | ||
|
||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { | ||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); | ||
this.mc.getTextureManager().bindTexture(GUI_BACKGROUND); | ||
int i = (this.width - this.xSize) / 2; | ||
int j = (this.height - this.ySize) / 2; | ||
this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize); | ||
|
||
} | ||
|
||
public void drawScreen(int mouseX, int mouseY, float partialTicks) { | ||
this.drawDefaultBackground(); | ||
super.drawScreen(mouseX, mouseY, partialTicks); | ||
this.renderHoveredToolTip(mouseX, mouseY); | ||
} | ||
|
||
} |
82 changes: 82 additions & 0 deletions
82
src/main/java/com/windanesz/ancientspellcraft/client/gui/InventoryInItemStack.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package com.windanesz.ancientspellcraft.client.gui; | ||
|
||
import com.windanesz.ancientspellcraft.item.IItemWithSlots; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.inventory.InventoryBasic; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.nbt.NBTTagCompound; | ||
import net.minecraft.nbt.NBTTagList; | ||
|
||
public class InventoryInItemStack extends InventoryBasic { | ||
|
||
private final ItemStack stack; | ||
|
||
public InventoryInItemStack(String title, boolean customName, IItemWithSlots itemWithSlots, ItemStack stack) { | ||
super(title, customName, itemWithSlots.getSlotCount()); | ||
this.stack = stack; | ||
} | ||
|
||
public int getRowCount() { | ||
return ((IItemWithSlots) (stack.getItem())).getRowCount(); | ||
} | ||
|
||
public int getColumnCount() { | ||
return ((IItemWithSlots) (stack.getItem())).getColumnCount(); | ||
} | ||
|
||
@Override | ||
public void openInventory(EntityPlayer player) { | ||
super.openInventory(player); | ||
NBTTagCompound nbt = this.stack.getTagCompound(); | ||
if (nbt == null) { | ||
nbt = new NBTTagCompound(); | ||
} | ||
|
||
if (nbt.hasKey("Items")) { | ||
|
||
NBTTagList items = nbt.getTagList("Items", 10); | ||
|
||
for (int i = 0; i < items.tagCount(); ++i) { | ||
NBTTagCompound nbttagcompound = items.getCompoundTagAt(i); | ||
int j = nbttagcompound.getByte("Slot") & 255; | ||
|
||
if (j < this.getSizeInventory()) { | ||
this.setInventorySlotContents(j, new ItemStack(nbttagcompound)); | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void closeInventory(EntityPlayer player) { | ||
|
||
NBTTagCompound nbt = this.stack.getTagCompound(); | ||
if (nbt == null) { | ||
nbt = new NBTTagCompound(); | ||
} | ||
|
||
NBTTagList items = new NBTTagList(); | ||
|
||
for (int i = 0; i < this.getSizeInventory(); ++i) { | ||
ItemStack itemstack = this.getStackInSlot(i); | ||
|
||
if (!itemstack.isEmpty()) { | ||
NBTTagCompound nbttagcompound = new NBTTagCompound(); | ||
nbttagcompound.setByte("Slot", (byte) i); | ||
itemstack.writeToNBT(nbttagcompound); | ||
items.appendTag(nbttagcompound); | ||
} | ||
} | ||
|
||
nbt.setTag("Items", items); | ||
stack.setTagCompound(nbt); | ||
} | ||
|
||
@Override | ||
public boolean isItemValidForSlot(int index, ItemStack stack) { | ||
if (((IItemWithSlots) (stack.getItem())).isItemValid(stack.getItem())) { | ||
return false; | ||
} | ||
return super.isItemValidForSlot(index, stack); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.