Premier commit - Extrait du pauvre jar après perte des sources

This commit is contained in:
Mysaa
2021-05-28 22:57:57 +02:00
commit 29ef10e9f9
54 changed files with 1355 additions and 0 deletions
@@ -0,0 +1,39 @@
/* */ package com.bernard.torch.gui;
/* */
/* */ import com.bernard.torch.blocks.tileentities.TorchRechargerTileEntity;
/* */ import cpw.mods.fml.common.network.IGuiHandler;
/* */ import java.io.PrintStream;
/* */ import net.minecraft.entity.player.EntityPlayer;
/* */ import net.minecraft.tileentity.TileEntity;
/* */ import net.minecraft.world.World;
/* */
/* */ public class TorchGuiHandler implements IGuiHandler
/* */ {
/* */ public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
/* */ {
/* 14 */ if (ID == 0) {
/* 15 */ TileEntity te = world.getTileEntity(x, y, z);
/* 16 */ if ((te instanceof TorchRechargerTileEntity)) {
/* 17 */ System.out.println("S:" + te.toString());
/* 18 */ return new TorchRechargerContainer((TorchRechargerTileEntity)te, player.inventory);
/* */ }
/* */ }
/* */
/* 22 */ return null;
/* */ }
/* */
/* */ public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
/* */ {
/* 27 */ if (ID == 0) {
/* 28 */ TileEntity te = world.getTileEntity(x, y, z);
/* 29 */ if ((te instanceof TorchRechargerTileEntity)) {
/* 30 */ System.out.println("C:" + te.toString());
/* 31 */ return new TorchRechargerGuiContainer((TorchRechargerTileEntity)te, player.inventory);
/* */ }
/* */ }
/* */
/* 35 */ return null;
/* */ }
/* */ }
@@ -0,0 +1,102 @@
/* */ package com.bernard.torch.gui;
/* */
/* */ import com.bernard.torch.api.ITorchRechargable;
/* */ import com.bernard.torch.blocks.tileentities.TorchRechargerTileEntity;
/* */ import com.bernard.torch.init.CoalStickAndTorchesRegister;
/* */ import java.util.List;
/* */ import net.minecraft.entity.player.EntityPlayer;
/* */ import net.minecraft.entity.player.InventoryPlayer;
/* */ import net.minecraft.inventory.Container;
/* */ import net.minecraft.inventory.IInventory;
/* */ import net.minecraft.inventory.Slot;
/* */ import net.minecraft.item.ItemStack;
/* */
/* */ public class TorchRechargerContainer extends Container
/* */ {
/* */ TorchRechargerTileEntity tile;
/* */
/* */ public TorchRechargerContainer(TorchRechargerTileEntity te, InventoryPlayer inventory)
/* */ {
/* 20 */ this.tile = te;
/* 21 */ this.tile.openChest();
/* 22 */ addSlotToContainer(new InputSlot(this.tile, 0, 14, 33));
/* 23 */ addSlotToContainer(new OutputSlot(this.tile, 1, 138, 33));
/* 24 */ bindPlayerInventory(inventory);
/* */ }
/* */
/* */ public void bindPlayerInventory(InventoryPlayer inventory)
/* */ {
/* 29 */ for (int i = 0; i < 3; i++) {
/* 30 */ for (int j = 0; j < 9; j++) {
/* 31 */ addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
/* */ }
/* */ }
/* 34 */ for (i = 0; i < 9; i++) {
/* 35 */ addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 142));
/* */ }
/* */ }
/* */
/* */ public boolean canInteractWith(EntityPlayer player)
/* */ {
/* 41 */ return this.tile.isUseableByPlayer(player);
/* */ }
/* */
/* */ public void onContainerClosed(EntityPlayer player)
/* */ {
/* 46 */ super.onContainerClosed(player);
/* 47 */ this.tile.closeChest();
/* */ }
/* */
/* */ public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex)
/* */ {
/* 52 */ ItemStack stack = null;
/* 53 */ Slot slot = (Slot)this.inventorySlots.get(slotIndex);
/* 54 */ if ((slot != null) && (slot.getHasStack())) {
/* 55 */ ItemStack stackBis = slot.getStack();
/* 56 */ stack = stackBis.copy();
/* 57 */ if (slotIndex < this.tile.getSizeInventory()) {
/* 58 */ if (!mergeItemStack(stackBis, this.tile.getSizeInventory(), this.inventorySlots.size(), true)) {
/* 59 */ return null;
/* */ }
/* 61 */ } else if (!mergeItemStack(stackBis, 0, this.tile.getSizeInventory(), false)) {
/* 62 */ return null;
/* */ }
/* 64 */ if (stackBis.stackSize == 0) {
/* 65 */ slot.putStack((ItemStack)null);
/* */ } else {
/* 67 */ slot.onSlotChanged();
/* */ }
/* */ }
/* 70 */ return stack;
/* */ }
/* */
/* */ public class InputSlot extends Slot
/* */ {
/* */ public InputSlot(IInventory inventory, int i, int j, int k) {
/* 76 */ super(i, j, k);
/* */ }
/* */
/* */ public boolean isItemValid(ItemStack stack)
/* */ {
/* 81 */ if (stack == null)
/* 82 */ return false;
/* 83 */ return CoalStickAndTorchesRegister.isRegistered(stack.getItem());
/* */ }
/* */ }
/* */
/* */ public class OutputSlot extends Slot
/* */ {
/* */ public OutputSlot(IInventory inventory, int i, int j, int k) {
/* 90 */ super(i, j, k);
/* */ }
/* */
/* */ public boolean isItemValid(ItemStack stack)
/* */ {
/* 95 */ if (stack == null)
/* 96 */ return false;
/* 97 */ return stack.getItem() instanceof ITorchRechargable;
/* */ }
/* */ }
/* */ }
@@ -0,0 +1,121 @@
package com.bernard.torch.gui;
import com.bernard.torch.blocks.tileentities.TorchRechargerTileEntity;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class TorchRechargerGuiContainer
extends GuiContainer
{
private static final ResourceLocation background = new ResourceLocation("torch_mod", "textures/guis/torch_recharger.png");
public TorchRechargerTileEntity tile;
public IInventory playerInventory;
private float mouseX = 0.0F; private float mouseY = 0.0F;
public TorchRechargerGuiContainer(TorchRechargerTileEntity te, InventoryPlayer inventory) {
super(new TorchRechargerContainer(te, inventory));
this.tile = te;
this.playerInventory = inventory;
this.allowUserInput = false;
this.xSize = 176;
this.ySize = 166;
}
public boolean doesGuiPauseGame()
{
return false;
}
public void drawScreen(int x, int y, float par3)
{
this.mouseX = x;
this.mouseY = y;
super.drawScreen(x, y, par3);
}
protected void drawGuiContainerForegroundLayer(int x, int y)
{
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
if ((this.mouseX >= k + 101) && (this.mouseX < k + 116) && (this.mouseY >= l + 8) && (this.mouseY < l + 81)) {
List<String> li = new ArrayList();
li.add("Torches stock�s :");
li.add(Integer.toString(this.tile.getTorchValue(), 10));
drawHoveringText(li, (int)this.mouseX - k, (int)this.mouseY - l, this.fontRendererObj);
} else if ((this.mouseX >= k + 45) && (this.mouseX < k + 70) && (this.mouseY >= l + 9) && (this.mouseY < l + 38)) {
List<String> li = new ArrayList();
li.add("Charbon stock� :");
li.add(Integer.toString(this.tile.getCoalValue(), 10));
drawHoveringText(li, (int)this.mouseX - k, (int)this.mouseY - l, this.fontRendererObj);
} else if ((this.mouseX >= k + 56) && (this.mouseX < k + 60) && (this.mouseY >= l + 40) && (this.mouseY < l + 67)) {
List<String> li = new ArrayList();
li.add("Batons stock�s :");
li.add(Integer.toString(this.tile.getStickValue(), 10));
drawHoveringText(li, (int)this.mouseX - k, (int)this.mouseY - l, this.fontRendererObj);
}
}
protected void drawGuiContainerBackgroundLayer(float partialRenderTick, int x, int y)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(background);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int meta = this.tile.blockMetadata;
if (meta < 0)
meta = 0;
int torchPixels = Math.floorDiv(this.tile.getTorchValue() * 80, this.tile.getMaxTorchValue());
drawTexturedModalRect(k + 94, l + 1 + 80 - torchPixels, this.xSize, 80 - torchPixels, 29, torchPixels);
int coalPixels = Math.floorDiv(this.tile.getCoalValue() * 32, this.tile.getMaxCoalValue());
drawTexturedModalRect(k + 42, l + 7 + 32 - coalPixels, this.xSize, 112 - coalPixels, 30, coalPixels);
int stickPixels = Math.floorDiv(this.tile.getStickValue() * 40, this.tile.getMaxStickValue());
drawTexturedModalRect(k + 53, l + 39 + 40 - stickPixels, this.xSize, 152 - stickPixels, 9, stickPixels);
}
}