More work on recycler

This commit is contained in:
gigabit101 2016-03-07 00:21:22 +00:00
parent fa5c568adf
commit 77e2edc005
4 changed files with 79 additions and 5 deletions

View file

@ -37,6 +37,11 @@ public class GuiRecycler extends GuiContainer {
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = 0;
j = compressor.gaugeProgressScaled(1);
if (j > 0) {
this.drawTexturedModalRect(k + 78, l + 35, 176, 14, j + 1, 16);
}
j = compressor.getEnergyScaled(12);
if (j > 0) {

View file

@ -120,6 +120,8 @@ public class ModRecipes {
ScrapboxList.addItemStackToList(new ItemStack(Blocks.cocoa));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.tallgrass));
ScrapboxList.addItemStackToList(new ItemStack(Blocks.chest));
ScrapboxList.addItemStackToList(ItemGems.getGemByName("ruby"));
}
static void addWireRecipes() {

View file

@ -3,6 +3,7 @@ package techreborn.items;
import java.util.List;
import java.util.Random;
import me.modmuss50.jsonDestroyer.api.ITexturedItem;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
@ -10,14 +11,16 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
import reborncore.RebornCore;
import techreborn.api.ScrapboxList;
import techreborn.client.TechRebornCreativeTabMisc;
public class ItemScrapBox extends ItemTR {
public class ItemScrapBox extends ItemTR implements ITexturedItem{
public ItemScrapBox() {
setUnlocalizedName("techreborn.scrapbox");
setCreativeTab(TechRebornCreativeTabMisc.instance);
RebornCore.jsonDestroyer.registerObject(this);
}
@Override
@ -25,7 +28,6 @@ public class ItemScrapBox extends ItemTR {
if(!world.isRemote) {
int random = world.rand.nextInt(ScrapboxList.stacks.size());
ItemStack out = ScrapboxList.stacks.get(random).copy();
player.addChatComponentMessage(new ChatComponentText("int " + random + " stack " + out.getDisplayName()));
float xOffset = world.rand.nextFloat() * 0.8F + 0.1F;
float yOffset = world.rand.nextFloat() * 0.8F + 0.1F;
float zOffset = world.rand.nextFloat() * 0.8F + 0.1F;
@ -38,4 +40,14 @@ public class ItemScrapBox extends ItemTR {
}
return itemStack;
}
@Override
public int getMaxMeta() {
return 1;
}
@Override
public String getTextureName(int arg0) {
return "techreborn:items/misc/scrapBox";
}
}

View file

@ -1,6 +1,7 @@
package techreborn.tiles.teir1;
import ic2.api.tile.IWrenchable;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
@ -8,25 +9,79 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IChatComponent;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.init.ModBlocks;
import techreborn.init.ModItems;
import techreborn.items.ItemParts;
import techreborn.lib.Reference;
public class TileRecycler extends TilePowerAcceptor implements IWrenchable, IInventory, ISidedInventory{
public Inventory inventory = new Inventory(6, "TileRecycler", 64, this);
public int capacity = 1000;
public int cost = 20;
public int progress;
public int time = 100;
public TileRecycler() {
super(1);
}
public int gaugeProgressScaled (int scale)
{
return (progress * scale) / time;
}
@Override
public void updateEntity() {
super.updateEntity();
charge(3);
public void updateEntity()
{
if(!worldObj.isRemote)
{
if(getEnergy() > cost)
{
if(getStackInSlot(0) != null)
{
if(progress == 0)
{
if(getStackInSlot(0).stackSize > 1)
{
decrStackSize(0, 1);
}
if(getStackInSlot(0).stackSize == 1)
{
setInventorySlotContents(0, null);
}
}
progress++;
if(progress >= cost)
{
if(getStackInSlot(1) == null)
{
setInventorySlotContents(1, ItemParts.getPartByName("scrap"));
progress = 0;
}
if(getStackInSlot(1).stackSize >= 1)
{
getStackInSlot(1).stackSize++;
progress = 0;
}
}
}
}
}
}
public void updateState(){
IBlockState blockState = worldObj.getBlockState(pos);
if(blockState.getBlock() instanceof BlockMachineBase){
BlockMachineBase blockMachineBase = (BlockMachineBase) blockState.getBlock();
if(blockState.getValue(BlockMachineBase.ACTIVE) != progress > 0)
blockMachineBase.setActive(progress > 0, worldObj, pos);
}
}
@Override