This repository has been archived by the owner on Jan 25, 2020. It is now read-only.
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
9 changed files
with
427 additions
and
8 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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,42 @@ | ||
package tutoriel.client; | ||
|
||
import net.minecraft.client.gui.inventory.GuiContainer; | ||
import net.minecraft.client.resources.I18n; | ||
import net.minecraft.entity.player.InventoryPlayer; | ||
import net.minecraft.inventory.IInventory; | ||
import net.minecraft.util.ResourceLocation; | ||
|
||
import org.lwjgl.opengl.GL11; | ||
|
||
import tutoriel.common.ContainerBigChest; | ||
import tutoriel.common.TileEntityBigChest; | ||
|
||
public class GuiBigChest extends GuiContainer | ||
{ | ||
public static ResourceLocation texture = new ResourceLocation("modtutoriel", "textures/gui/container/bigChest.png"); | ||
private TileEntityBigChest bigChest; | ||
private IInventory playerInventory; | ||
public GuiBigChest(InventoryPlayer inventory, TileEntityBigChest tileEntity) | ||
{ | ||
super(new ContainerBigChest(inventory, tileEntity)); | ||
this.bigChest = tileEntity; | ||
this.playerInventory = inventory; | ||
this.ySize = 230; | ||
} | ||
|
||
protected void drawGuiContainerForegroundLayer(int par1, int par2) | ||
{ | ||
this.fontRenderer.drawString(this.playerInventory.isInvNameLocalized() ? this.playerInventory.getInvName() : I18n.getString(this.playerInventory.getInvName()), 8, 129, 0); | ||
this.fontRenderer.drawString(this.bigChest.isInvNameLocalized() ? this.bigChest.getInvName() : I18n.getString(this.bigChest.getInvName()), 8, 7, 0); | ||
} | ||
|
||
@Override | ||
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) | ||
{ | ||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); | ||
this.mc.getTextureManager().bindTexture(texture); | ||
int x = (this.width - this.xSize) / 2; | ||
int y = (this.height - this.ySize) / 2; | ||
this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package tutoriel.common; | ||
|
||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.entity.player.InventoryPlayer; | ||
import net.minecraft.inventory.Container; | ||
import net.minecraft.inventory.Slot; | ||
import net.minecraft.item.ItemStack; | ||
|
||
public class ContainerBigChest extends Container | ||
{ | ||
private TileEntityBigChest tileEntity; | ||
|
||
public ContainerBigChest(InventoryPlayer playerInventory, TileEntityBigChest teChest) | ||
{ | ||
this.tileEntity = teChest; | ||
|
||
for(int i = 0; i < 6; i++) | ||
{ | ||
for(int j = 0; j < 9; j++) | ||
{ | ||
this.addSlotToContainer(new Slot(teChest, j + i * 9, 8 + j * 18, 18 + i * 18)); | ||
} | ||
} | ||
this.bindPlayerInventory(playerInventory); | ||
} | ||
|
||
private void bindPlayerInventory(InventoryPlayer playerInventory) | ||
{ | ||
int i; | ||
for(i = 0; i < 3; i++) | ||
{ | ||
for(int j = 0; j < 9; j++) | ||
{ | ||
this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 103 + i * 18 + 37)); | ||
} | ||
} | ||
|
||
for(i = 0; i < 9; i++) | ||
{ | ||
this.addSlotToContainer(new Slot(playerInventory, i, 8 + i * 18, 161 + 37)); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean canInteractWith(EntityPlayer player) | ||
{ | ||
return tileEntity.isUseableByPlayer(player); | ||
} | ||
|
||
public ItemStack transferStackInSlot(EntityPlayer player, int slotId) | ||
{ | ||
ItemStack itemstack = null; | ||
Slot slot = (Slot)this.inventorySlots.get(slotId); | ||
|
||
if(slot != null && slot.getHasStack()) | ||
{ | ||
ItemStack itemstack1 = slot.getStack(); | ||
itemstack = itemstack1.copy(); | ||
|
||
if(slotId < 9) | ||
{ | ||
if(!this.mergeItemStack(itemstack1, 9, this.inventorySlots.size(), true)) | ||
{ | ||
return null; | ||
} | ||
} | ||
else if(!this.mergeItemStack(itemstack1, 0, 9, false)) | ||
{ | ||
return null; | ||
} | ||
|
||
if(itemstack1.stackSize == 0) | ||
{ | ||
slot.putStack((ItemStack)null); | ||
} | ||
else | ||
{ | ||
slot.onSlotChanged(); | ||
} | ||
} | ||
return itemstack; | ||
} | ||
} |
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,33 @@ | ||
package tutoriel.common; | ||
|
||
import tutoriel.client.GuiBigChest; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.world.World; | ||
import cpw.mods.fml.common.network.IGuiHandler; | ||
|
||
public class GuiHandlerTutorial implements IGuiHandler | ||
{ | ||
|
||
@Override | ||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) | ||
{ | ||
TileEntity te = world.getBlockTileEntity(x, y, z); | ||
if(te instanceof TileEntityBigChest) | ||
{ | ||
return new ContainerBigChest(player.inventory, (TileEntityBigChest)te); | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) | ||
{ | ||
TileEntity te = world.getBlockTileEntity(x, y, z); | ||
if(te instanceof TileEntityBigChest) | ||
{ | ||
return new GuiBigChest(player.inventory, (TileEntityBigChest)te); | ||
} | ||
return null; | ||
} | ||
} |
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.