Recycler output is now a random chance

This commit is contained in:
gigabit101 2016-03-07 12:45:54 +00:00
parent f170f9a418
commit 007f9266e5
3 changed files with 42 additions and 27 deletions

View file

@ -38,7 +38,7 @@ public class GuiRecycler extends GuiContainer {
int j = 0; int j = 0;
j = compressor.gaugeProgressScaled(1); j = compressor.gaugeProgressScaled(24);
if (j > 0) { if (j > 0) {
this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16); this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16);
} }
@ -54,5 +54,4 @@ public class GuiRecycler extends GuiContainer {
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752); this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
} }
} }

View file

@ -62,7 +62,7 @@ public class RecipeCompact implements IRecipeCompact {
recipes.put("hvTransformer", ItemParts.getPartByName("hvTransformer")); recipes.put("hvTransformer", ItemParts.getPartByName("hvTransformer"));
recipes.put("windMill", new ItemStack(ModBlocks.windMill)); recipes.put("windMill", new ItemStack(ModBlocks.windMill));
recipes.put("energyCrystal", new ItemStack(ModItems.energyCrystal)); recipes.put("energyCrystal", new ItemStack(ModItems.energyCrystal));
recipes.put("lapotronCrystal", new ItemStack(ModItems.lapotronCrystal)); // recipes.put("lapotronCrystal", new ItemStack(ModItems.lapotronCrystal));
inited = false; inited = false;
} }

View file

@ -1,5 +1,7 @@
package techreborn.tiles.teir1; package techreborn.tiles.teir1;
import java.util.Random;
import ic2.api.tile.IWrenchable; import ic2.api.tile.IWrenchable;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -18,13 +20,15 @@ import techreborn.init.ModItems;
import techreborn.items.ItemParts; import techreborn.items.ItemParts;
import techreborn.lib.Reference; import techreborn.lib.Reference;
public class TileRecycler extends TilePowerAcceptor implements IWrenchable, IInventory, ISidedInventory{ public class TileRecycler extends TilePowerAcceptor implements IWrenchable, IInventory, ISidedInventory {
public Inventory inventory = new Inventory(6, "TileRecycler", 64, this); public Inventory inventory = new Inventory(6, "TileRecycler", 64, this);
public int capacity = 1000; public int capacity = 1000;
public int cost = 20; public int cost = 20;
public int progress; public int progress;
public int time = 100; public int time = 800;
public int chance = 4;
public int random;
public TileRecycler() { public TileRecycler() {
super(1); super(1);
@ -38,14 +42,16 @@ public class TileRecycler extends TilePowerAcceptor implements IWrenchable, IInv
@Override @Override
public void updateEntity() public void updateEntity()
{ {
if(!worldObj.isRemote) boolean updateInventory = false;
{
if(getEnergy() > cost) if(getEnergy() > cost)
{ {
if(getStackInSlot(0) != null) if(getStackInSlot(0) != null)
{ {
if(progress == 0) if(progress == 0)
{ {
int randchance = worldObj.rand.nextInt(chance);
random = randchance;
if(getStackInSlot(0).stackSize > 1) if(getStackInSlot(0).stackSize > 1)
{ {
decrStackSize(0, 1); decrStackSize(0, 1);
@ -54,22 +60,32 @@ public class TileRecycler extends TilePowerAcceptor implements IWrenchable, IInv
{ {
setInventorySlotContents(0, null); setInventorySlotContents(0, null);
} }
updateInventory = true;
} }
progress++; progress++;
if(progress >= cost) if(progress >= time)
{
if(random == 1)
{ {
if(getStackInSlot(1) == null) if(getStackInSlot(1) == null)
{ {
setInventorySlotContents(1, ItemParts.getPartByName("scrap")); setInventorySlotContents(1, ItemParts.getPartByName("scrap"));
progress = 0; progress = 0;
updateInventory = true;
} }
if(getStackInSlot(1).stackSize >= 1) else if(getStackInSlot(1).stackSize >= 1)
{ {
getStackInSlot(1).stackSize++; getStackInSlot(1).stackSize++;
progress = 0; progress = 0;
updateInventory = true;
} }
} }
if(random != 1)
{
progress = 0;
updateInventory = true;
}
} }
} }
} }