Fixes #217
This commit is contained in:
parent
c0ebf03f72
commit
25777b3f96
3 changed files with 67 additions and 3 deletions
|
@ -11,7 +11,7 @@ import techreborn.tiles.TileQuantumTank;
|
|||
public class GuiQuantumTank extends GuiContainer {
|
||||
|
||||
private static final ResourceLocation texture = new ResourceLocation(
|
||||
"techreborn", "textures/gui/ThermalGenerator.png");
|
||||
"techreborn", "textures/gui/thermal_generator.png");
|
||||
|
||||
TileQuantumTank tile;
|
||||
|
||||
|
|
|
@ -96,6 +96,11 @@ public class ModItems {
|
|||
GameRegistry.registerItem(parts, "part");
|
||||
cells = new ItemCells();
|
||||
GameRegistry.registerItem(cells, "cell");
|
||||
for (int i = 0; i < ItemCells.types.length; i++) {
|
||||
if(FluidRegistry.getFluid("fluid" + ItemCells.types[i].toLowerCase()) != null){
|
||||
FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluid("fluid" + ItemCells.types[i].toLowerCase()), ItemCells.getCellByName(ItemCells.types[i]));
|
||||
}
|
||||
}
|
||||
rockCutter = PoweredItem.createItem(ItemRockCutter.class);
|
||||
GameRegistry.registerItem(rockCutter, "rockCutter");
|
||||
lithiumBatpack = PoweredItem.createItem(ItemLithiumBatpack.class);
|
||||
|
|
|
@ -5,18 +5,20 @@ import net.minecraft.client.renderer.texture.IIconRegister;
|
|||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
import reborncore.api.IListInfoProvider;
|
||||
import techreborn.Core;
|
||||
import techreborn.client.TechRebornCreativeTab;
|
||||
import techreborn.init.ModItems;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemCells extends ItemTR {
|
||||
public class ItemCells extends ItemTR implements IFluidContainerItem {
|
||||
|
||||
public static ItemStack getCellByName(String name, int count) {
|
||||
return getCellByName(name, count, true);
|
||||
|
@ -104,8 +106,65 @@ public class ItemCells extends ItemTR {
|
|||
// Adds Dusts SubItems To Creative Tab
|
||||
public void getSubItems(Item item, CreativeTabs creativeTabs, List list) {
|
||||
for (int meta = 0; meta < types.length; ++meta) {
|
||||
list.add(new ItemStack(item, 1, meta));
|
||||
ItemStack stack = new ItemStack(item, 1, meta);
|
||||
if(FluidRegistry.getFluid("fluid" +types[meta].toLowerCase()) != null){
|
||||
this.fill(stack, new FluidStack(FluidRegistry.getFluid("fluid" +types[meta].toLowerCase()), getCapacity(stack)), true);
|
||||
}
|
||||
list.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack getFluid(ItemStack container) {
|
||||
return FluidStack.loadFluidStackFromNBT(container.getTagCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity(ItemStack container) {
|
||||
return 1000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ItemStack container, FluidStack resource, boolean doFill) {
|
||||
if (container.stackSize != 1) {
|
||||
return 0;
|
||||
}
|
||||
if (resource == null || resource.amount != getCapacity(container)) {
|
||||
return 0;
|
||||
}
|
||||
if(FluidRegistry.getFluid("fluid" +types[container.getItemDamage()].toLowerCase()) == null){
|
||||
return 0;
|
||||
}
|
||||
if (doFill)
|
||||
{
|
||||
NBTTagCompound tag = container.getTagCompound();
|
||||
if (tag == null)
|
||||
{
|
||||
tag = new NBTTagCompound();
|
||||
}
|
||||
resource.writeToNBT(tag);
|
||||
container.setTagCompound(tag);
|
||||
}
|
||||
return getCapacity(container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain) {
|
||||
if (maxDrain < getCapacity(container)) {
|
||||
return null;
|
||||
}
|
||||
FluidStack fluidStack = getFluid(container);
|
||||
if (doDrain && fluidStack != null) {
|
||||
ItemStack empty = ItemCells.getCellByName("empty");
|
||||
if(empty != null) {
|
||||
container.setItemDamage(empty.getItemDamage());
|
||||
container.setTagCompound(empty.getTagCompound());
|
||||
}
|
||||
else {
|
||||
container.stackSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return fluidStack;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue