MathiasVO053

Untitled

Aug 6th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.49 KB | None | 0 0
  1. package dk.MathiasVO053.RobinsamseCraft.blocks;
  2.  
  3. import java.util.Random;
  4.  
  5. import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
  6. import cpw.mods.fml.relauncher.Side;
  7. import cpw.mods.fml.relauncher.SideOnly;
  8. import dk.MathiasVO053.RobinsamseCraft.BlockReg;
  9. import dk.MathiasVO053.RobinsamseCraft.Main;
  10. import dk.MathiasVO053.RobinsamseCraft.Strings;
  11. import dk.MathiasVO053.RobinsamseCraft.tile_entity.TileEntityInfuser2;
  12. import net.minecraft.block.Block;
  13. import net.minecraft.block.BlockContainer;
  14. import net.minecraft.block.material.Material;
  15. import net.minecraft.client.renderer.texture.IIconRegister;
  16. import net.minecraft.entity.EntityLivingBase;
  17. import net.minecraft.entity.item.EntityItem;
  18. import net.minecraft.entity.player.EntityPlayer;
  19. import net.minecraft.item.Item;
  20. import net.minecraft.item.ItemStack;
  21. import net.minecraft.nbt.NBTTagCompound;
  22. import net.minecraft.tileentity.TileEntity;
  23. import net.minecraft.util.IIcon;
  24. import net.minecraft.util.MathHelper;
  25. import net.minecraft.world.World;
  26.  
  27. public class Infuser2 extends BlockContainer {
  28.  
  29. private final boolean isActive;
  30.  
  31. @SideOnly(Side.CLIENT)
  32. private IIcon iconFront;
  33.  
  34. @SideOnly(Side.CLIENT)
  35. private IIcon iconTop;
  36.  
  37. private static boolean keepInventory;
  38. private Random rand = new Random();
  39.  
  40. public Infuser2(boolean isActive) {
  41. super(Material.iron);
  42.  
  43. this.isActive = isActive;
  44. }
  45.  
  46. @SideOnly(Side.CLIENT)
  47. public void registerBlockIcons(IIconRegister iconRegister) {
  48. this.blockIcon = iconRegister.registerIcon(Strings.MODID + ":" + (this.isActive ? "InfuserSideActive" : "InfuserSide"));
  49. this.iconFront = iconRegister.registerIcon(Strings.MODID + ":" + (this.isActive ? "InfuserFrontActive" : "InfuserFront"));
  50. this.iconTop = iconRegister.registerIcon(Strings.MODID + ":" + (this.isActive ? "InfuserTopActive" : "InfuserTop"));
  51. }
  52.  
  53. @SideOnly(Side.CLIENT)
  54. public IIcon getIcon(int side, int metadata) {
  55. return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : (side == 0 ? this.iconTop : (side == metadata ? this.iconFront : this.blockIcon));
  56. }
  57.  
  58. public Item getItemDropped(int i, Random random, int j) {
  59. return Item.getItemFromBlock(BlockReg.Infuser2);
  60. }
  61.  
  62. public void onBlockAdded(World world, int x, int y, int z) {
  63. super.onBlockAdded(world, x, y, z);
  64. this.setDefaultDirection(world, x, y, z);
  65. }
  66.  
  67. private void setDefaultDirection(World world, int x, int y, int z) {
  68. if(!world.isRemote) {
  69. Block b1 = world.getBlock(x, y, z - 1);
  70. Block b2 = world.getBlock(x, y, z + 1);
  71. Block b3 = world.getBlock(x - 1, y, z);
  72. Block b4 = world.getBlock(x + 1, y, z);
  73.  
  74. byte b0 = 3;
  75.  
  76. if(b1.func_149730_j() && !b2.func_149730_j()) {
  77. b0 = 3;
  78. }
  79.  
  80. if(b2.func_149730_j() && !b1.func_149730_j()) {
  81. b0 = 2;
  82. }
  83.  
  84. if(b3.func_149730_j() && !b4.func_149730_j()) {
  85. b0 = 5;
  86. }
  87.  
  88. if(b4.func_149730_j() && !b3.func_149730_j()) {
  89. b0 = 4;
  90. }
  91.  
  92. world.setBlockMetadataWithNotify(x, y, x, b0, 2);
  93. }
  94.  
  95. }
  96.  
  97. public boolean onBlockActivated(World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ){
  98. if(w.isRemote){
  99. return true;
  100. }else if(!player.isSneaking()){
  101. TileEntityInfuser2 entity = (TileEntityInfuser2) w.getTileEntity(x, y, z);
  102. if(entity != null){
  103. FMLNetworkHandler.openGui(player, Main.instance, Main.guiIDInfuserMk2, w, x, y, z);
  104. }
  105. return true;
  106. }else{
  107. return false;
  108. }
  109.  
  110. }
  111.  
  112. @Override
  113. public TileEntity createNewTileEntity(World world, int i) {
  114. return new TileEntityInfuser2();
  115. }
  116.  
  117. @SideOnly(Side.CLIENT)
  118. public void randomDisplayTick(World world, int x, int y, int z, Random random) {
  119. if(this.isActive) {
  120. int direction = world.getBlockMetadata(x, y, z);
  121.  
  122. float x1 = (float)x + 0.5F;
  123. float y1 = (float)y + random.nextFloat();
  124. float z1 = (float)z + 0.5F;
  125.  
  126. float f = 0.52F;
  127. float f1 = random.nextFloat() * 0.6F - 0.3F;
  128. }
  129. }
  130.  
  131. public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityplayer, ItemStack itemstack) {
  132. int l = MathHelper.floor_double((double)(entityplayer.rotationYaw * 4.0F / 360.F) + 0.5D) & 3;
  133.  
  134. if(l == 0) {
  135. world.setBlockMetadataWithNotify(x, y, z, 2, 2);
  136. }
  137.  
  138. if(l == 1) {
  139. world.setBlockMetadataWithNotify(x, y, z, 5, 2);
  140. }
  141.  
  142. if(l == 2) {
  143. world.setBlockMetadataWithNotify(x, y, z, 3, 2);
  144. }
  145.  
  146. if(l == 3) {
  147. world.setBlockMetadataWithNotify(x, y, z, 4, 2);
  148. }
  149.  
  150.  
  151. if(itemstack.hasDisplayName()) {
  152. ((TileEntityInfuser2)world.getTileEntity(x, y, z)).setGuiDisplayName(itemstack.getDisplayName());
  153. }
  154. }
  155.  
  156. public static void updateInfuserBlockState(boolean active, World worldObj, int xCoord, int yCoord, int zCoord) {
  157. int i = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
  158.  
  159. TileEntity tileentity = worldObj.getTileEntity(xCoord, yCoord, zCoord);
  160. keepInventory = true;
  161.  
  162. if(active) {
  163. worldObj.setBlock(xCoord, yCoord, zCoord, BlockReg.Infuser2Active);
  164. }else{
  165. worldObj.setBlock(xCoord, yCoord, zCoord, BlockReg.Infuser2);
  166. }
  167.  
  168. keepInventory = false;
  169.  
  170. worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, i, 2);
  171.  
  172. if(tileentity != null) {
  173. tileentity.validate();
  174. worldObj.setTileEntity(xCoord, yCoord, zCoord, tileentity);
  175. }
  176. }
  177.  
  178. public void breakBlock(World world, int x, int y, int z, Block oldblock, int oldMetadata) {
  179. if(!keepInventory) {
  180. TileEntityInfuser2 tileentity = (TileEntityInfuser2) world.getTileEntity(x, y, z);
  181.  
  182. if(tileentity != null) {
  183. for(int i = 0; i < tileentity.getSizeInventory(); i++) {
  184. ItemStack itemstack = tileentity.getStackInSlot(i);
  185.  
  186. if(itemstack != null) {
  187. float f = this.rand.nextFloat() * 0.8F + 0.1F;
  188. float f1 = this.rand.nextFloat() * 0.8F + 0.1F;
  189. float f2 = this.rand.nextFloat() * 0.8F + 0.1F;
  190.  
  191. while(itemstack.stackSize > 0) {
  192. int j = this.rand.nextInt(21) + 10;
  193.  
  194. if(j > itemstack.stackSize) {
  195. j = itemstack.stackSize;
  196. }
  197.  
  198. itemstack.stackSize -= j;
  199.  
  200. EntityItem item = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));
  201.  
  202. if(itemstack.hasTagCompound()) {
  203. item.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
  204. }
  205.  
  206. world.spawnEntityInWorld(item);
  207. }
  208. }
  209. }
  210.  
  211. world.func_147453_f(x, y, z, oldblock);
  212. }
  213. }
  214.  
  215. super.breakBlock(world, x, y, z, oldblock, oldMetadata);
  216. }
  217.  
  218. public Item getItem(World world, int x, int y, int z) {
  219. return Item.getItemFromBlock(BlockReg.Infuser2);
  220. }
  221.  
  222. }
  223.  
  224.  
  225. ---------------------------------------------------------------------------------------------------------------------------------
  226.  
  227.  
  228.  
  229.  
  230. package dk.MathiasVO053.RobinsamseCraft.tile_entity;
  231.  
  232. import cpw.mods.fml.common.registry.GameRegistry;
  233. import dk.MathiasVO053.RobinsamseCraft.ItemReg;
  234. import dk.MathiasVO053.RobinsamseCraft.Crafting.InfuserRecipes;
  235. import dk.MathiasVO053.RobinsamseCraft.blocks.Infuser2;
  236. import net.minecraft.block.Block;
  237. import net.minecraft.entity.player.EntityPlayer;
  238. import net.minecraft.init.Blocks;
  239. import net.minecraft.init.Items;
  240. import net.minecraft.inventory.ISidedInventory;
  241. import net.minecraft.item.Item;
  242. import net.minecraft.item.ItemBlock;
  243. import net.minecraft.item.ItemStack;
  244. import net.minecraft.nbt.NBTTagCompound;
  245. import net.minecraft.nbt.NBTTagList;
  246. import net.minecraft.tileentity.TileEntity;
  247.  
  248. public class TileEntityInfuser2 extends TileEntity implements ISidedInventory {
  249.  
  250. private String localizedName;
  251.  
  252. private static final int[] slots_top = new int[]{0};
  253. private static final int[] slots_bottom = new int[]{2, 1};
  254. private static final int[] slots_side = new int[]{1};
  255.  
  256. public static final int maxInfucium = 900;
  257. public static final int maxFuel = 900;
  258.  
  259. private ItemStack[] slots = new ItemStack [5];
  260.  
  261. public int furnaceSpeed = 150;
  262. public int currentItemBurnTime;
  263. public int cookTime;
  264. public int FuelCount;
  265. public int InfuciumCount;
  266.  
  267.  
  268. public void setGuiDisplayName(String displayName) {
  269. this.localizedName = displayName;
  270. }
  271.  
  272. public String getInventoryName() {
  273. return this.hasCustomInventoryName() ? this.localizedName : "container.Infuser";
  274. }
  275.  
  276. public boolean hasCustomInventoryName() {
  277. return this.localizedName != null && this.localizedName.length() > 0;
  278. }
  279.  
  280. public int getSizeInventory() {
  281. return this.slots.length;
  282. }
  283.  
  284. @Override
  285. public ItemStack getStackInSlot(int var1) {
  286. return this.slots[var1];
  287. }
  288.  
  289. @Override
  290. public ItemStack decrStackSize(int var1, int var2) {
  291. if(this.slots[var1] != null){
  292. ItemStack itemstack;
  293.  
  294. if(this.slots[var1].stackSize <= var2 ){
  295. itemstack = this.slots[var1];
  296. this.slots[var1] = null;
  297. return itemstack;
  298. }else{
  299. itemstack = this.slots[var1].splitStack(var2);
  300.  
  301. if(this.slots[var1].stackSize == 0) {
  302. this.slots[var1] = null;
  303. }
  304.  
  305. return itemstack;
  306. }
  307. }else{
  308. return null;
  309. }
  310. }
  311.  
  312.  
  313. @Override
  314. public ItemStack getStackInSlotOnClosing(int i) {
  315. if(this.slots[i]!= null) {
  316. ItemStack itemstack = this.slots[i];
  317. this.slots[i] = null;
  318. return itemstack;
  319. }
  320. return null;
  321. }
  322.  
  323. @Override
  324. public void setInventorySlotContents(int i, ItemStack itemstack) {
  325. this.slots[i] = itemstack;
  326.  
  327. if(itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()) {
  328. itemstack.stackSize = this.getInventoryStackLimit();
  329. }
  330.  
  331. }
  332.  
  333. @Override
  334. public int getInventoryStackLimit() {
  335. return 64;
  336. }
  337.  
  338. @Override
  339. public boolean isUseableByPlayer(EntityPlayer entityplayer) {
  340. return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : entityplayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
  341. }
  342.  
  343. public void openInventory() {}
  344. public void closeInventory() {}
  345.  
  346. @Override
  347. public boolean isItemValidForSlot(int i, ItemStack itemstack) {
  348. return i == 2 ? false : (i == 1 ? hasItemPower(itemstack) : true);
  349. }
  350.  
  351. private static int getItemInfucium(ItemStack itemstack) {
  352. if(itemstack == null){
  353. return 0;
  354. }else{
  355. Item item = itemstack.getItem();
  356.  
  357. if(item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air) {
  358. Block block = Block.getBlockFromItem(item);
  359.  
  360. //if(block == Blocks.sapling) return 100;
  361. }
  362.  
  363. if(item == ItemReg.InfuciumMk2) return 100;
  364.  
  365. }
  366. return GameRegistry.getFuelValue(itemstack);
  367. }
  368.  
  369. private static int getItemPower(ItemStack itemstack) {
  370. if(itemstack == null){
  371. return 0;
  372. }else{
  373. Item item = itemstack.getItem();
  374.  
  375. if(item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air) {
  376. Block block = Block.getBlockFromItem(item);
  377.  
  378. //if(block == Blocks.sapling) return 100;
  379. }
  380.  
  381. if(item == ItemReg.RainbowPowder) return 100;
  382.  
  383. }
  384. return GameRegistry.getFuelValue(itemstack);
  385. }
  386.  
  387. public boolean hasItemPower(ItemStack itemstack) {
  388. return getItemPower(itemstack) > 0;
  389. }
  390.  
  391. public boolean hasItemInfucium(ItemStack itemstack) {
  392. return getItemInfucium(itemstack) > 0;
  393. }
  394.  
  395.  
  396. public int getFuelRemainingScaled(int i) {
  397. return (FuelCount * i) / maxFuel;
  398. }
  399.  
  400. public int getInfuciumRemainingScaled(int i) {
  401. return (InfuciumCount * i) / maxInfucium;
  402. }
  403.  
  404.  
  405. public boolean hasEnergy() {
  406. return FuelCount > 0;
  407. }
  408. public boolean hasInfucium() {
  409. return InfuciumCount > 0;
  410. }
  411.  
  412. public void updateEntity() {
  413. boolean flag = this.hasEnergy();
  414. boolean flag1 = false;
  415. boolean flag2 = false;
  416.  
  417. if(hasEnergy() && this.isBurning()){
  418. this.FuelCount--;
  419. this.InfuciumCount--;
  420. }
  421.  
  422. if(!worldObj.isRemote){
  423. if(this.hasItemInfucium(this.slots[3]) && this.InfuciumCount < (this.maxInfucium - this.getItemInfucium(this.slots[3]))){
  424. this.InfuciumCount += getItemInfucium(this.slots[3]);
  425.  
  426. if(this.slots[3] != null){
  427. flag2 = true;
  428.  
  429. this.slots[3].stackSize--;
  430.  
  431. if(this.slots[3].stackSize == 0){
  432. this.slots[3] = this.slots[3].getItem().getContainerItem(this.slots[3]);
  433. }
  434. }
  435. }
  436.  
  437. if(!worldObj.isRemote){
  438. if(this.hasItemPower(this.slots[4]) && this.FuelCount < (this.maxFuel - this.getItemPower(this.slots[4]))){
  439. this.FuelCount += getItemPower(this.slots[4]);
  440.  
  441. if(this.slots[4] != null){
  442. flag1 = true;
  443.  
  444. this.slots[4].stackSize--;
  445.  
  446. if(this.slots[4].stackSize == 0){
  447. this.slots[4] = this.slots[4].getItem().getContainerItem(this.slots[4]);
  448. }
  449. }
  450. }
  451. if(hasEnergy() && canSmelt()){
  452. cookTime++;
  453.  
  454. if(this.cookTime == this.furnaceSpeed){
  455. this.cookTime = 0;
  456. this.smeltItem();
  457. flag1 = true;
  458. flag2 = true;
  459. }else{
  460. cookTime = 0;
  461. }
  462. if(flag != this.hasEnergy()){
  463. flag1 = true;
  464. flag2 = true;
  465. Infuser2.updateInfuserBlockState(this.hasEnergy(), worldObj, xCoord, yCoord, zCoord);
  466. }
  467. }
  468. if(flag1 && flag2){
  469. this.markDirty();
  470. }
  471. }
  472. }
  473. }
  474.  
  475. public boolean canSmelt() {
  476. if (this.slots[0] == null) {
  477. return false;
  478. }else{
  479. ItemStack itemstack = InfuserRecipes.smelting().getSmeltingResult(this.slots[0]);
  480.  
  481. if(itemstack == null) return false;
  482. if(this.slots[2] == null) return true;
  483. if(!this.slots[2].isItemEqual(itemstack)) return false;
  484.  
  485. int result = this.slots[2].stackSize + itemstack.stackSize;
  486.  
  487. return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize());
  488. }
  489. }
  490.  
  491. public void smeltItem() {
  492. if(this.canSmelt()) {
  493. ItemStack itemstack = InfuserRecipes.smelting().getSmeltingResult(this.slots[0]);
  494.  
  495. if(this.slots[2] == null) {
  496. this.slots[2] = itemstack.copy();
  497. }else if(this.slots[2].isItemEqual(itemstack)) {
  498. this.slots[2].stackSize += itemstack.stackSize;
  499. }
  500.  
  501. this.slots[0].stackSize--;
  502.  
  503. if(this.slots[0].stackSize <= 0) {
  504. this.slots[0] = null;
  505. }
  506. }
  507. }
  508.  
  509. @Override
  510. public int[] getAccessibleSlotsFromSide(int var1) {
  511. return var1 == 0 ? slots_bottom : (var1 == 1 ? slots_top : slots_side);
  512. }
  513.  
  514. @Override
  515. public boolean canInsertItem(int i, ItemStack itemstack, int j) {
  516. return this.isItemValidForSlot(i, itemstack);
  517. }
  518.  
  519. @Override
  520. public boolean canExtractItem(int i, ItemStack itemstack, int j) {
  521. return j != 0 || i != 1 || itemstack.getItem() == Items.bucket;
  522. }
  523.  
  524. public boolean isBurning(){
  525. return this.cookTime > 0;
  526. }
  527.  
  528. public int getCookProgressScaled(int i) {
  529. return this.cookTime * i / this.furnaceSpeed;
  530. }
  531.  
  532. public void readFromNBT(NBTTagCompound nbt) {
  533. super.readFromNBT(nbt);
  534.  
  535. NBTTagList list = nbt.getTagList("Items", 10);
  536. this.slots = new ItemStack[this.getSizeInventory()];
  537.  
  538. for(int i = 0; i < list.tagCount(); i++) {
  539. NBTTagCompound compound = (NBTTagCompound) list.getCompoundTagAt(i);
  540. byte b = compound.getByte("Slot");
  541.  
  542. if(b >= 0 && b < this.slots.length) {
  543. this.slots[b] = ItemStack.loadItemStackFromNBT(compound);
  544. }
  545. }
  546. this.cookTime = (int)nbt.getShort("CookTime");
  547. this.currentItemBurnTime = (int)nbt.getShort("CurrentBurnTime");
  548. this.InfuciumCount = (int)nbt.getShort("InfuciumCount");
  549. this.FuelCount = (int)nbt.getShort("FuelCount");
  550.  
  551.  
  552. if(nbt.hasKey("CustomName")) {
  553. this.localizedName = nbt.getString("CustomName");
  554. }
  555. }
  556.  
  557. public void writeToNBT(NBTTagCompound nbt) {
  558. super.writeToNBT(nbt);
  559.  
  560. nbt.setShort("CookTime", (short)this.cookTime);
  561. nbt.setShort("CurrentBurnTime", (short)this.currentItemBurnTime);
  562. nbt.setShort("InfuciumCount", (short)this.InfuciumCount);
  563. nbt.setShort("FuelCount", (short)this.FuelCount);
  564.  
  565. NBTTagList list = new NBTTagList();
  566.  
  567. for (int i = 0; i < this.slots.length; i++) {
  568. if(this.slots[i] != null) {
  569. NBTTagCompound compound = new NBTTagCompound();
  570. compound.setByte("Slot", (byte)i);
  571. this.slots[i].writeToNBT(compound);
  572. list.appendTag(compound);
  573. }
  574. }
  575.  
  576. nbt.setTag("Items", list);
  577.  
  578. if (this.hasCustomInventoryName()) {
  579. nbt.setString("CustomName", this.localizedName);
  580. }
  581. }
  582. }
  583.  
  584.  
  585. ------------------------------------------------------------------------------------------------------------------------------
  586.  
  587. package dk.MathiasVO053.RobinsamseCraft.inventory;
  588.  
  589. import org.lwjgl.opengl.GL11;
  590.  
  591. import dk.MathiasVO053.RobinsamseCraft.Strings;
  592. import dk.MathiasVO053.RobinsamseCraft.tile_entity.TileEntityInfuser2;
  593. import net.minecraft.client.Minecraft;
  594. import net.minecraft.client.gui.inventory.GuiContainer;
  595. import net.minecraft.client.resources.I18n;
  596. import net.minecraft.entity.player.InventoryPlayer;
  597. import net.minecraft.util.ResourceLocation;
  598.  
  599. public class InfuserGui2 extends GuiContainer {
  600.  
  601. public static final ResourceLocation bground = new ResourceLocation(Strings.MODID + ":" + "textures/gui/InfuserMk2Gui.png");
  602.  
  603. public TileEntityInfuser2 Infuser;
  604.  
  605. public InfuserGui2(InventoryPlayer inventoryPlayer, TileEntityInfuser2 entity) {
  606. super(new InfuserContainer2(inventoryPlayer, entity));
  607.  
  608. this.Infuser = entity;
  609.  
  610. this.xSize = 176;
  611. this.ySize = 166;
  612. }
  613.  
  614.  
  615. public void drawGuiContainerForegroundLayer(int par1, int par2) {
  616.  
  617. String name = "InfuserMk2";
  618. this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
  619. this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 118, this.ySize - 96 + 2, 4210752);
  620. }
  621.  
  622. @Override
  623. protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {
  624. GL11.glColor4f(1F, 1F, 1F, 1F);
  625.  
  626. Minecraft.getMinecraft().getTextureManager().bindTexture(bground);
  627. drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
  628.  
  629. if (Infuser.hasEnergy())
  630. {
  631. int i1 = Infuser.getFuelRemainingScaled(48);
  632. drawTexturedModalRect(guiLeft + 10, guiTop + 62 - i1, 180, 101 - i1, 16, i1);
  633. }
  634.  
  635. if (Infuser.hasInfucium())
  636. {
  637. int i2 = Infuser.getInfuciumRemainingScaled(48);
  638. drawTexturedModalRect(guiLeft + 150, guiTop + 62 - i2, 198, 101 - i2, 16, i2);
  639. }
  640.  
  641. int k = this.Infuser.getCookProgressScaled(52);
  642. drawTexturedModalRect(guiLeft + 82, guiTop + 19, 176, 0, k + 1, 50);
  643. }
  644.  
  645. }
  646.  
  647.  
  648.  
  649. ------------------------------------------------------------------------------------------------------------------------------
  650.  
  651.  
  652.  
  653. package dk.MathiasVO053.RobinsamseCraft.inventory;
  654.  
  655. import net.minecraft.entity.player.EntityPlayer;
  656. import net.minecraft.entity.player.InventoryPlayer;
  657. import net.minecraft.inventory.Container;
  658. import net.minecraft.inventory.ICrafting;
  659. import net.minecraft.inventory.Slot;
  660. import net.minecraft.inventory.SlotFurnace;
  661. import net.minecraft.item.ItemStack;
  662. import cpw.mods.fml.relauncher.Side;
  663. import cpw.mods.fml.relauncher.SideOnly;
  664. import dk.MathiasVO053.RobinsamseCraft.Crafting.InfuserRecipes;
  665. import dk.MathiasVO053.RobinsamseCraft.tile_entity.TileEntityInfuser2;
  666.  
  667.  
  668. public class InfuserContainer2 extends Container{
  669.  
  670. private TileEntityInfuser2 Infuser;
  671.  
  672. public int fuelCount;
  673. public int infuciumCount;
  674. public int lastCookTime;
  675.  
  676. public InfuserContainer2(InventoryPlayer inventory, TileEntityInfuser2 tileentity) {
  677. this.Infuser = tileentity;
  678.  
  679. this.addSlotToContainer(new Slot(tileentity, 0, 66, 16)); /*input 1*/
  680. this.addSlotToContainer(new Slot(tileentity, 1, 66, 56)); /*input 2*/
  681. this.addSlotToContainer(new SlotFurnace(inventory.player, tileentity, 2, 113, 36)); /*output*/
  682. this.addSlotToContainer(new Slot(tileentity, 3, 150, 65)); /*infucium*/
  683. this.addSlotToContainer(new Slot(tileentity, 4, 10, 65)); /*fuel*/
  684.  
  685. for(int i = 0; i < 3; i++) {
  686. for(int j = 0; j < 9; j++) {
  687. this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
  688. }
  689. }
  690.  
  691. for(int i = 0; i < 9; i++) {
  692. this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 142));
  693. }
  694. }
  695.  
  696. public void addCraftingToCrafters (ICrafting icrafting) {
  697. super.addCraftingToCrafters(icrafting);
  698. icrafting.sendProgressBarUpdate(this, 1, this.Infuser.cookTime);
  699. icrafting.sendProgressBarUpdate(this, 2, this.Infuser.currentItemBurnTime);
  700. icrafting.sendProgressBarUpdate(this, 3, this.Infuser.FuelCount);
  701. icrafting.sendProgressBarUpdate(this, 4, this.Infuser.InfuciumCount);
  702. }
  703.  
  704. public void detectAndSendChanges() {
  705. super.detectAndSendChanges();
  706. for(int i = 0; i < this.crafters.size(); i++) {
  707. ICrafting icrafting = (ICrafting) this.crafters.get(i);
  708.  
  709. if(this.lastCookTime != this.Infuser.cookTime) {
  710. icrafting.sendProgressBarUpdate(this, 1, this.Infuser.cookTime);
  711. }
  712.  
  713. if(this.fuelCount != this.Infuser.FuelCount) {
  714. icrafting.sendProgressBarUpdate(this, 2, this.Infuser.FuelCount);
  715. }
  716.  
  717. if(this.infuciumCount != this.Infuser.InfuciumCount) {
  718. icrafting.sendProgressBarUpdate(this, 3, this.Infuser.InfuciumCount);
  719. }
  720.  
  721. }
  722.  
  723. this.lastCookTime = this.Infuser.cookTime;
  724. this.infuciumCount = this.Infuser.InfuciumCount;
  725. this.fuelCount = this.Infuser.FuelCount;
  726.  
  727. }
  728.  
  729. @SideOnly(Side.CLIENT)
  730. public void updateProgressBar(int i, int j){
  731. if(i == 1){
  732. Infuser.cookTime = j;
  733. }
  734. if(i == 2){
  735. Infuser.FuelCount = j;
  736. }
  737. if(i == 3){
  738. Infuser.InfuciumCount = j;
  739. }
  740. }
  741.  
  742. public boolean canInteractWith(EntityPlayer var1) {
  743. return true;
  744. }
  745.  
  746. }
Advertisement
Add Comment
Please, Sign In to add comment