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); this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int j = 0; 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); j = compressor.getEnergyScaled(12);
if (j > 0) { if (j > 0) {

View file

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

View file

@ -3,6 +3,7 @@ package techreborn.items;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import me.modmuss50.jsonDestroyer.api.ITexturedItem;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
@ -10,14 +11,16 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World; import net.minecraft.world.World;
import reborncore.RebornCore;
import techreborn.api.ScrapboxList; import techreborn.api.ScrapboxList;
import techreborn.client.TechRebornCreativeTabMisc; import techreborn.client.TechRebornCreativeTabMisc;
public class ItemScrapBox extends ItemTR { public class ItemScrapBox extends ItemTR implements ITexturedItem{
public ItemScrapBox() { public ItemScrapBox() {
setUnlocalizedName("techreborn.scrapbox"); setUnlocalizedName("techreborn.scrapbox");
setCreativeTab(TechRebornCreativeTabMisc.instance); setCreativeTab(TechRebornCreativeTabMisc.instance);
RebornCore.jsonDestroyer.registerObject(this);
} }
@Override @Override
@ -25,7 +28,6 @@ public class ItemScrapBox extends ItemTR {
if(!world.isRemote) { if(!world.isRemote) {
int random = world.rand.nextInt(ScrapboxList.stacks.size()); int random = world.rand.nextInt(ScrapboxList.stacks.size());
ItemStack out = ScrapboxList.stacks.get(random).copy(); 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 xOffset = world.rand.nextFloat() * 0.8F + 0.1F;
float yOffset = 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; float zOffset = world.rand.nextFloat() * 0.8F + 0.1F;
@ -38,4 +40,14 @@ public class ItemScrapBox extends ItemTR {
} }
return itemStack; 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; package techreborn.tiles.teir1;
import ic2.api.tile.IWrenchable; import ic2.api.tile.IWrenchable;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory; import net.minecraft.inventory.ISidedInventory;
@ -8,25 +9,79 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.IChatComponent; import net.minecraft.util.IChatComponent;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.util.Inventory; import reborncore.common.util.Inventory;
import techreborn.api.recipe.RecipeCrafter; import techreborn.api.recipe.RecipeCrafter;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.init.ModItems;
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 progress;
public int time = 100;
public TileRecycler() { public TileRecycler() {
super(1); super(1);
} }
public int gaugeProgressScaled (int scale)
{
return (progress * scale) / time;
}
@Override @Override
public void updateEntity() { public void updateEntity()
super.updateEntity(); {
charge(3); 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 @Override