mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-26 14:52:58 +00:00
Add Mekanism Shaped and Mekanism Shapeless recipe handlers, use ItemDataUtils to consolidate non-subtype-based NBT data into a single compound
This commit is contained in:
1 parent
2f61ea103f
commit
be863a4289
53 files changed
+679
-789
No files matched your search
@@ -2,6 +2,7 @@ package mekanism.client.jei;
|
||||
|
||||
import mekanism.common.MekanismBlocks;
|
||||
import mekanism.common.MekanismItems;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mezz.jei.api.IItemRegistry;
|
||||
import mezz.jei.api.IJeiHelpers;
|
||||
import mezz.jei.api.IJeiRuntime;
|
||||
@@ -9,41 +10,45 @@ import mezz.jei.api.IModPlugin;
|
||||
import mezz.jei.api.IModRegistry;
|
||||
import mezz.jei.api.IRecipeRegistry;
|
||||
import mezz.jei.api.JEIPlugin;
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@JEIPlugin
|
||||
public class MekanismJEI implements IModPlugin
|
||||
{
|
||||
public static final String[] UNUSED_TAGS = new String[] {ItemDataUtils.DATA_ID};
|
||||
|
||||
@Override
|
||||
public void register(IModRegistry registry)
|
||||
{
|
||||
registry.addAdvancedGuiHandlers(new GuiElementHandler());
|
||||
|
||||
registry.addRecipeHandlers(new IRecipeHandler[] {new ShapedMekanismRecipeHandler()});
|
||||
registry.addRecipeHandlers(new IRecipeHandler[] {new ShapelessMekanismRecipeHandler()});
|
||||
|
||||
registry.getJeiHelpers().getItemBlacklist().addItemToBlacklist(new ItemStack(MekanismItems.ItemProxy));
|
||||
registry.getJeiHelpers().getItemBlacklist().addItemToBlacklist(new ItemStack(MekanismBlocks.BoundingBlock));
|
||||
|
||||
registry.getJeiHelpers().getNbtIgnoreList().ignoreNbtTagNames(Item.getItemFromBlock(MekanismBlocks.EnergyCube), UNUSED_TAGS);
|
||||
registry.getJeiHelpers().getNbtIgnoreList().ignoreNbtTagNames(Item.getItemFromBlock(MekanismBlocks.MachineBlock), UNUSED_TAGS);
|
||||
registry.getJeiHelpers().getNbtIgnoreList().ignoreNbtTagNames(Item.getItemFromBlock(MekanismBlocks.MachineBlock2), UNUSED_TAGS);
|
||||
registry.getJeiHelpers().getNbtIgnoreList().ignoreNbtTagNames(Item.getItemFromBlock(MekanismBlocks.MachineBlock3), UNUSED_TAGS);
|
||||
registry.getJeiHelpers().getNbtIgnoreList().ignoreNbtTagNames(Item.getItemFromBlock(MekanismBlocks.BasicBlock), UNUSED_TAGS);
|
||||
registry.getJeiHelpers().getNbtIgnoreList().ignoreNbtTagNames(Item.getItemFromBlock(MekanismBlocks.BasicBlock2), UNUSED_TAGS);
|
||||
registry.getJeiHelpers().getNbtIgnoreList().ignoreNbtTagNames(Item.getItemFromBlock(MekanismBlocks.GasTank), UNUSED_TAGS);
|
||||
registry.getJeiHelpers().getNbtIgnoreList().ignoreNbtTagNames(Item.getItemFromBlock(MekanismBlocks.CardboardBox), UNUSED_TAGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemRegistryAvailable(IItemRegistry registry)
|
||||
{
|
||||
|
||||
}
|
||||
public void onItemRegistryAvailable(IItemRegistry registry) {}
|
||||
|
||||
@Override
|
||||
public void onJeiHelpersAvailable(IJeiHelpers helpers)
|
||||
{
|
||||
|
||||
}
|
||||
public void onJeiHelpersAvailable(IJeiHelpers helpers) {}
|
||||
|
||||
@Override
|
||||
public void onRecipeRegistryAvailable(IRecipeRegistry registry)
|
||||
{
|
||||
|
||||
}
|
||||
public void onRecipeRegistryAvailable(IRecipeRegistry registry) {}
|
||||
|
||||
@Override
|
||||
public void onRuntimeAvailable(IJeiRuntime runtime)
|
||||
{
|
||||
|
||||
}
|
||||
public void onRuntimeAvailable(IJeiRuntime runtime) {}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package mekanism.client.jei;
|
||||
|
||||
import mekanism.common.recipe.ShapedMekanismRecipe;
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
|
||||
|
||||
public class ShapedMekanismRecipeHandler implements IRecipeHandler<ShapedMekanismRecipe>
|
||||
{
|
||||
@Override
|
||||
public String getRecipeCategoryUid()
|
||||
{
|
||||
return VanillaRecipeCategoryUid.CRAFTING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ShapedMekanismRecipe> getRecipeClass()
|
||||
{
|
||||
return ShapedMekanismRecipe.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper(ShapedMekanismRecipe recipe)
|
||||
{
|
||||
return new ShapedMekanismRecipeWrapper(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecipeValid(ShapedMekanismRecipe recipe)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package mekanism.client.jei;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import mekanism.common.recipe.ShapedMekanismRecipe;
|
||||
import mezz.jei.api.recipe.BlankRecipeWrapper;
|
||||
import mezz.jei.api.recipe.wrapper.IShapedCraftingRecipeWrapper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ShapedMekanismRecipeWrapper extends BlankRecipeWrapper implements IShapedCraftingRecipeWrapper
|
||||
{
|
||||
@Nonnull
|
||||
private final ShapedMekanismRecipe recipe;
|
||||
|
||||
public ShapedMekanismRecipeWrapper(@Nonnull ShapedMekanismRecipe r)
|
||||
{
|
||||
recipe = r;
|
||||
|
||||
for(Object input : this.recipe.getInput())
|
||||
{
|
||||
if(input instanceof ItemStack)
|
||||
{
|
||||
ItemStack itemStack = (ItemStack)input;
|
||||
|
||||
if(itemStack.stackSize != 1)
|
||||
{
|
||||
itemStack.stackSize = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List getInputs()
|
||||
{
|
||||
return Arrays.asList(recipe.getInput());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<ItemStack> getOutputs()
|
||||
{
|
||||
return Collections.singletonList(recipe.getRecipeOutput());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth()
|
||||
{
|
||||
return recipe.width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight()
|
||||
{
|
||||
return recipe.height;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package mekanism.client.jei;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import mekanism.common.recipe.ShapelessMekanismRecipe;
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
|
||||
|
||||
public class ShapelessMekanismRecipeHandler implements IRecipeHandler<ShapelessMekanismRecipe>
|
||||
{
|
||||
@Override
|
||||
@Nonnull
|
||||
public Class<ShapelessMekanismRecipe> getRecipeClass()
|
||||
{
|
||||
return ShapelessMekanismRecipe.class;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getRecipeCategoryUid()
|
||||
{
|
||||
return VanillaRecipeCategoryUid.CRAFTING;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public IRecipeWrapper getRecipeWrapper(@Nonnull ShapelessMekanismRecipe recipe)
|
||||
{
|
||||
return new ShapelessMekanismRecipeWrapper(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecipeValid(@Nonnull ShapelessMekanismRecipe recipe)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package mekanism.client.jei;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import mekanism.common.recipe.ShapelessMekanismRecipe;
|
||||
import mezz.jei.api.recipe.BlankRecipeWrapper;
|
||||
import mezz.jei.api.recipe.wrapper.ICraftingRecipeWrapper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ShapelessMekanismRecipeWrapper extends BlankRecipeWrapper implements ICraftingRecipeWrapper
|
||||
{
|
||||
@Nonnull
|
||||
private final ShapelessMekanismRecipe recipe;
|
||||
|
||||
public ShapelessMekanismRecipeWrapper(@Nonnull ShapelessMekanismRecipe r)
|
||||
{
|
||||
recipe = r;
|
||||
|
||||
for(Object input : recipe.getInput())
|
||||
{
|
||||
if(input instanceof ItemStack)
|
||||
{
|
||||
ItemStack itemStack = (ItemStack)input;
|
||||
|
||||
if(itemStack.stackSize != 1)
|
||||
{
|
||||
itemStack.stackSize = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List getInputs()
|
||||
{
|
||||
return recipe.getInput();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<ItemStack> getOutputs()
|
||||
{
|
||||
return Collections.singletonList(recipe.getRecipeOutput());
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,7 @@ import mekanism.common.tile.TileEntityLaserAmplifier;
|
||||
import mekanism.common.tile.TileEntityLogisticalSorter;
|
||||
import mekanism.common.tile.TileEntityMetallurgicInfuser;
|
||||
import mekanism.common.tile.TileEntityPersonalChest;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.SecurityUtils;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -864,14 +865,15 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock
|
||||
|
||||
if(tileEntity instanceof IUpgradeTile)
|
||||
{
|
||||
((IUpgradeTile)tileEntity).getComponent().write(itemStack.getTagCompound());
|
||||
((IUpgradeTile)tileEntity).getComponent().write(ItemDataUtils.getDataMap(itemStack));
|
||||
}
|
||||
|
||||
if(tileEntity instanceof ISideConfiguration)
|
||||
{
|
||||
ISideConfiguration config = (ISideConfiguration)tileEntity;
|
||||
|
||||
config.getConfig().write(itemStack.getTagCompound());
|
||||
config.getConfig().write(ItemDataUtils.getDataMap(itemStack));
|
||||
config.getEjector().write(ItemDataUtils.getDataMap(itemStack));
|
||||
}
|
||||
|
||||
if(tileEntity instanceof ISustainedData)
|
||||
@@ -882,7 +884,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock
|
||||
if(tileEntity instanceof IRedstoneControl)
|
||||
{
|
||||
IRedstoneControl control = (IRedstoneControl)tileEntity;
|
||||
itemStack.getTagCompound().setInteger("controlType", control.getControlType().ordinal());
|
||||
ItemDataUtils.setInt(itemStack, "controlType", control.getControlType().ordinal());
|
||||
}
|
||||
|
||||
if(tileEntity instanceof IStrictEnergyStorage)
|
||||
|
||||
@@ -4,6 +4,7 @@ import mekanism.api.util.StackUtils;
|
||||
import mekanism.common.Tier.BinTier;
|
||||
import mekanism.common.base.ITierItem;
|
||||
import mekanism.common.block.states.BlockStateBasic.BasicBlockType;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@@ -101,22 +102,12 @@ public class InventoryBin
|
||||
|
||||
public int getItemCount()
|
||||
{
|
||||
if(bin.getTagCompound() == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return bin.getTagCompound().getInteger("itemCount");
|
||||
return ItemDataUtils.getInt(bin, "itemCount");
|
||||
}
|
||||
|
||||
public void setItemCount(int count)
|
||||
{
|
||||
if(bin.getTagCompound() == null)
|
||||
{
|
||||
bin.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
bin.getTagCompound().setInteger("itemCount", Math.max(0, count));
|
||||
ItemDataUtils.setInt(bin, "itemCount", Math.max(0, count));
|
||||
|
||||
if(getItemCount() == 0)
|
||||
{
|
||||
@@ -126,29 +117,22 @@ public class InventoryBin
|
||||
|
||||
public ItemStack getItemType()
|
||||
{
|
||||
if(bin.getTagCompound() == null || getItemCount() == 0)
|
||||
if(getItemCount() == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return ItemStack.loadItemStackFromNBT(bin.getTagCompound().getCompoundTag("storedItem"));
|
||||
return ItemStack.loadItemStackFromNBT(ItemDataUtils.getCompound(bin, "storedItem"));
|
||||
}
|
||||
|
||||
public void setItemType(ItemStack stack)
|
||||
{
|
||||
if(bin.getTagCompound() == null)
|
||||
{
|
||||
bin.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if(stack == null)
|
||||
{
|
||||
bin.getTagCompound().removeTag("storedItem");
|
||||
ItemDataUtils.removeData(bin, "storedItem");
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack ret = StackUtils.size(stack, 1);
|
||||
|
||||
bin.getTagCompound().setTag("storedItem", StackUtils.size(stack, 1).writeToNBT(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(bin, "storedItem", StackUtils.size(stack, 1).writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.MekanismConfig.general;
|
||||
import mekanism.api.util.ListUtils;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -18,7 +19,6 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.DamageSource;
|
||||
@@ -276,12 +276,7 @@ public class ItemAtomicDisassembler extends ItemEnergized
|
||||
|
||||
public int getMode(ItemStack itemStack)
|
||||
{
|
||||
if(itemStack.getTagCompound() == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return itemStack.getTagCompound().getInteger("mode");
|
||||
return ItemDataUtils.getInt(itemStack, "mode");
|
||||
}
|
||||
|
||||
public String getModeName(ItemStack itemStack)
|
||||
@@ -307,12 +302,7 @@ public class ItemAtomicDisassembler extends ItemEnergized
|
||||
|
||||
public void toggleMode(ItemStack itemStack)
|
||||
{
|
||||
if(itemStack.getTagCompound() == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemStack.getTagCompound().setInteger("mode", getMode(itemStack) < 4 ? getMode(itemStack)+1 : 0);
|
||||
ItemDataUtils.setInt(itemStack, "mode", getMode(itemStack) < 4 ? getMode(itemStack)+1 : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,6 +24,7 @@ import mekanism.common.tile.TileEntityBin;
|
||||
import mekanism.common.tile.TileEntityInductionCell;
|
||||
import mekanism.common.tile.TileEntityInductionProvider;
|
||||
import mekanism.common.tile.TileEntityMultiblock;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -189,7 +190,7 @@ public class ItemBlockBasic extends ItemBlock implements IEnergizedItem, ITierIt
|
||||
@Override
|
||||
public boolean hasContainerItem(ItemStack stack)
|
||||
{
|
||||
return BasicBlockType.get(stack) == BasicBlockType.BIN && stack.getTagCompound() != null && stack.getTagCompound().hasKey("newCount");
|
||||
return BasicBlockType.get(stack) == BasicBlockType.BIN && ItemDataUtils.hasData(stack, "newCount");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -197,16 +198,16 @@ public class ItemBlockBasic extends ItemBlock implements IEnergizedItem, ITierIt
|
||||
{
|
||||
if(BasicBlockType.get(stack) == BasicBlockType.BIN)
|
||||
{
|
||||
if(stack.getTagCompound() == null || !stack.getTagCompound().hasKey("newCount"))
|
||||
if(!ItemDataUtils.hasData(stack, "newCount"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int newCount = stack.getTagCompound().getInteger("newCount");
|
||||
stack.getTagCompound().removeTag("newCount");
|
||||
int newCount = ItemDataUtils.getInt(stack, "newCount");
|
||||
ItemDataUtils.removeData(stack, "newCount");
|
||||
|
||||
ItemStack ret = stack.copy();
|
||||
ret.getTagCompound().setInteger("itemCount", newCount);
|
||||
ItemDataUtils.setInt(ret, "itemCount", newCount);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -302,12 +303,7 @@ public class ItemBlockBasic extends ItemBlock implements IEnergizedItem, ITierIt
|
||||
{
|
||||
if(BasicBlockType.get(itemStack) == BasicBlockType.INDUCTION_CELL)
|
||||
{
|
||||
if(itemStack.getTagCompound() == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return itemStack.getTagCompound().getDouble("energyStored");
|
||||
return ItemDataUtils.getDouble(itemStack, "energyStored");
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -318,12 +314,7 @@ public class ItemBlockBasic extends ItemBlock implements IEnergizedItem, ITierIt
|
||||
{
|
||||
if(BasicBlockType.get(itemStack) == BasicBlockType.INDUCTION_CELL)
|
||||
{
|
||||
if(itemStack.getTagCompound() == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemStack.getTagCompound().setDouble("energyStored", Math.max(Math.min(amount, getMaxEnergy(itemStack)), 0));
|
||||
ItemDataUtils.setDouble(itemStack, "energyStored", Math.max(Math.min(amount, getMaxEnergy(itemStack)), 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import mekanism.api.MekanismAPI;
|
||||
import mekanism.common.MekanismBlocks;
|
||||
import mekanism.common.block.BlockCardboardBox.BlockData;
|
||||
import mekanism.common.tile.TileEntityCardboardBox;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
@@ -139,22 +140,17 @@ public class ItemBlockCardboardBox extends ItemBlock
|
||||
|
||||
public void setBlockData(ItemStack itemstack, BlockData data)
|
||||
{
|
||||
if(itemstack.getTagCompound() == null)
|
||||
{
|
||||
itemstack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemstack.getTagCompound().setTag("blockData", data.write(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemstack, "blockData", data.write(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
public BlockData getBlockData(ItemStack itemstack)
|
||||
{
|
||||
if(itemstack.getTagCompound() == null || !itemstack.getTagCompound().hasKey("blockData"))
|
||||
if(!ItemDataUtils.hasData(itemstack, "blockData"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return BlockData.read(itemstack.getTagCompound().getCompoundTag("blockData"));
|
||||
return BlockData.read(ItemDataUtils.getCompound(itemstack, "blockData"));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -24,6 +24,7 @@ import mekanism.common.security.ISecurityItem;
|
||||
import mekanism.common.security.ISecurityTile;
|
||||
import mekanism.common.security.ISecurityTile.SecurityMode;
|
||||
import mekanism.common.tile.TileEntityEnergyCube;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.SecurityUtils;
|
||||
@@ -39,7 +40,6 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
import net.minecraftforge.fml.common.Optional.Interface;
|
||||
import net.minecraftforge.fml.common.Optional.InterfaceList;
|
||||
import net.minecraftforge.fml.common.Optional.Method;
|
||||
@@ -59,6 +59,7 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IS
|
||||
super(block);
|
||||
metaBlock = block;
|
||||
setMaxStackSize(1);
|
||||
setHasSubtypes(true);
|
||||
setNoRepair();
|
||||
setCreativeTab(Mekanism.tabMekanism);
|
||||
}
|
||||
@@ -196,14 +197,7 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IS
|
||||
{
|
||||
if(data[0] instanceof ItemStack)
|
||||
{
|
||||
ItemStack itemStack = (ItemStack)data[0];
|
||||
|
||||
if(!itemStack.hasTagCompound())
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemStack.getTagCompound().setTag("Items", nbtTags);
|
||||
ItemDataUtils.setList((ItemStack)data[0], "Items", nbtTags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,14 +206,7 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IS
|
||||
{
|
||||
if(data[0] instanceof ItemStack)
|
||||
{
|
||||
ItemStack itemStack = (ItemStack)data[0];
|
||||
|
||||
if(!itemStack.hasTagCompound())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return itemStack.getTagCompound().getTagList("Items", NBT.TAG_COMPOUND);
|
||||
return ItemDataUtils.getList((ItemStack)data[0], "Items");
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -233,7 +220,7 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IS
|
||||
return 0;
|
||||
}
|
||||
|
||||
return itemStack.getTagCompound().getDouble("electricity");
|
||||
return ItemDataUtils.getDouble(itemStack, "energyStored");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -244,13 +231,7 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IS
|
||||
return;
|
||||
}
|
||||
|
||||
if(!itemStack.hasTagCompound())
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
double electricityStored = Math.max(Math.min(amount, getMaxEnergy(itemStack)), 0);
|
||||
itemStack.getTagCompound().setDouble("electricity", electricityStored);
|
||||
ItemDataUtils.setDouble(itemStack, "energyStored", Math.max(Math.min(amount, getMaxEnergy(itemStack)), 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -363,9 +344,9 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IS
|
||||
@Override
|
||||
public String getOwner(ItemStack stack)
|
||||
{
|
||||
if(stack.hasTagCompound() && stack.getTagCompound().hasKey("owner"))
|
||||
if(ItemDataUtils.hasData(stack, "owner"))
|
||||
{
|
||||
return stack.getTagCompound().getString("owner");
|
||||
return ItemDataUtils.getString(stack, "owner");
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -374,40 +355,25 @@ public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IS
|
||||
@Override
|
||||
public void setOwner(ItemStack stack, String owner)
|
||||
{
|
||||
if(!stack.hasTagCompound())
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if(owner == null || owner.isEmpty())
|
||||
{
|
||||
stack.getTagCompound().removeTag("owner");
|
||||
ItemDataUtils.removeData(stack, "owner");
|
||||
return;
|
||||
}
|
||||
|
||||
stack.getTagCompound().setString("owner", owner);
|
||||
ItemDataUtils.setString(stack, "owner", owner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecurityMode getSecurity(ItemStack stack)
|
||||
{
|
||||
if(!stack.hasTagCompound())
|
||||
{
|
||||
return SecurityMode.PUBLIC;
|
||||
}
|
||||
|
||||
return SecurityMode.values()[stack.getTagCompound().getInteger("security")];
|
||||
return SecurityMode.values()[ItemDataUtils.getInt(stack, "security")];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecurity(ItemStack stack, SecurityMode mode)
|
||||
{
|
||||
if(!stack.hasTagCompound())
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
stack.getTagCompound().setInteger("security", mode.ordinal());
|
||||
ItemDataUtils.setInt(stack, "security", mode.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,6 +23,7 @@ import mekanism.common.security.ISecurityItem;
|
||||
import mekanism.common.security.ISecurityTile;
|
||||
import mekanism.common.security.ISecurityTile.SecurityMode;
|
||||
import mekanism.common.tile.TileEntityGasTank;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.SecurityUtils;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -38,7 +39,6 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedInventory, ITierItem, ISecurityItem
|
||||
@@ -147,31 +147,21 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI
|
||||
@Override
|
||||
public GasStack getGas(ItemStack itemstack)
|
||||
{
|
||||
if(itemstack.getTagCompound() == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return GasStack.readFromNBT(itemstack.getTagCompound().getCompoundTag("stored"));
|
||||
return GasStack.readFromNBT(ItemDataUtils.getCompound(itemstack, "stored"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGas(ItemStack itemstack, GasStack stack)
|
||||
{
|
||||
if(itemstack.getTagCompound() == null)
|
||||
{
|
||||
itemstack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if(stack == null || stack.amount == 0)
|
||||
{
|
||||
itemstack.getTagCompound().removeTag("stored");
|
||||
ItemDataUtils.removeData(itemstack, "stored");
|
||||
}
|
||||
else {
|
||||
int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack)));
|
||||
GasStack gasStack = new GasStack(stack.getGas(), amount);
|
||||
|
||||
itemstack.getTagCompound().setTag("stored", gasStack.write(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemstack, "stored", gasStack.write(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,14 +285,7 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI
|
||||
{
|
||||
if(data[0] instanceof ItemStack)
|
||||
{
|
||||
ItemStack itemStack = (ItemStack)data[0];
|
||||
|
||||
if(!itemStack.hasTagCompound())
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemStack.getTagCompound().setTag("Items", nbtTags);
|
||||
ItemDataUtils.setList((ItemStack)data[0], "Items", nbtTags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,14 +294,7 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI
|
||||
{
|
||||
if(data[0] instanceof ItemStack)
|
||||
{
|
||||
ItemStack itemStack = (ItemStack)data[0];
|
||||
|
||||
if(!itemStack.hasTagCompound())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return itemStack.getTagCompound().getTagList("Items", NBT.TAG_COMPOUND);
|
||||
return ItemDataUtils.getList((ItemStack)data[0], "Items");
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -339,9 +315,9 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI
|
||||
@Override
|
||||
public String getOwner(ItemStack stack)
|
||||
{
|
||||
if(stack.getTagCompound() != null && stack.getTagCompound().hasKey("owner"))
|
||||
if(ItemDataUtils.hasData(stack, "owner"))
|
||||
{
|
||||
return stack.getTagCompound().getString("owner");
|
||||
return ItemDataUtils.getString(stack, "owner");
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -350,40 +326,25 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI
|
||||
@Override
|
||||
public void setOwner(ItemStack stack, String owner)
|
||||
{
|
||||
if(stack.getTagCompound() == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if(owner == null || owner.isEmpty())
|
||||
{
|
||||
stack.getTagCompound().removeTag("owner");
|
||||
ItemDataUtils.removeData(stack, "owner");
|
||||
return;
|
||||
}
|
||||
|
||||
stack.getTagCompound().setString("owner", owner);
|
||||
ItemDataUtils.setString(stack, "owner", owner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecurityMode getSecurity(ItemStack stack)
|
||||
{
|
||||
if(stack.getTagCompound() == null)
|
||||
{
|
||||
return SecurityMode.PUBLIC;
|
||||
}
|
||||
|
||||
return SecurityMode.values()[stack.getTagCompound().getInteger("security")];
|
||||
return SecurityMode.values()[ItemDataUtils.getInt(stack, "security")];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecurity(ItemStack stack, SecurityMode mode)
|
||||
{
|
||||
if(stack.getTagCompound() == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
stack.getTagCompound().setInteger("security", mode.ordinal());
|
||||
ItemDataUtils.setInt(stack, "security", mode.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,6 +38,7 @@ import mekanism.common.tile.TileEntityBasicBlock;
|
||||
import mekanism.common.tile.TileEntityElectricBlock;
|
||||
import mekanism.common.tile.TileEntityFactory;
|
||||
import mekanism.common.tile.TileEntityFluidTank;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.SecurityUtils;
|
||||
@@ -58,7 +59,6 @@ import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -235,9 +235,9 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
|
||||
list.add(EnumColor.AQUA + LangUtils.localize("tooltip.inventory") + ": " + EnumColor.GREY + LangUtils.transYesNo(getInventory(itemstack) != null && getInventory(itemstack).tagCount() != 0));
|
||||
}
|
||||
|
||||
if(type.supportsUpgrades && itemstack.getTagCompound() != null && itemstack.getTagCompound().hasKey("upgrades"))
|
||||
if(type.supportsUpgrades && ItemDataUtils.hasData(itemstack, "upgrades"))
|
||||
{
|
||||
Map<Upgrade, Integer> upgrades = Upgrade.buildMap(itemstack.getTagCompound());
|
||||
Map<Upgrade, Integer> upgrades = Upgrade.buildMap(ItemDataUtils.getDataMap(itemstack));
|
||||
|
||||
for(Map.Entry<Upgrade, Integer> entry : upgrades.entrySet())
|
||||
{
|
||||
@@ -326,9 +326,9 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
|
||||
|
||||
if(tileEntity instanceof IUpgradeTile)
|
||||
{
|
||||
if(stack.getTagCompound() != null && stack.getTagCompound().hasKey("upgrades"))
|
||||
if(ItemDataUtils.hasData(stack, "upgrades"))
|
||||
{
|
||||
((IUpgradeTile)tileEntity).getComponent().read(stack.getTagCompound());
|
||||
((IUpgradeTile)tileEntity).getComponent().read(ItemDataUtils.getDataMap(stack));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -336,9 +336,10 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
|
||||
{
|
||||
ISideConfiguration config = (ISideConfiguration)tileEntity;
|
||||
|
||||
if(stack.getTagCompound() != null && stack.getTagCompound().hasKey("sideDataStored"))
|
||||
if(ItemDataUtils.hasData(stack, "sideDataStored"))
|
||||
{
|
||||
config.getConfig().read(stack.getTagCompound());
|
||||
config.getConfig().read(ItemDataUtils.getDataMap(stack));
|
||||
config.getEjector().read(ItemDataUtils.getDataMap(stack));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,9 +353,9 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
|
||||
|
||||
if(tileEntity instanceof IRedstoneControl)
|
||||
{
|
||||
if(stack.getTagCompound() != null && stack.getTagCompound().hasKey("controlType"))
|
||||
if(ItemDataUtils.hasData(stack, "controlType"))
|
||||
{
|
||||
((IRedstoneControl)tileEntity).setControlType(RedstoneControl.values()[stack.getTagCompound().getInteger("controlType")]);
|
||||
((IRedstoneControl)tileEntity).setControlType(RedstoneControl.values()[ItemDataUtils.getInt(stack, "controlType")]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -611,14 +612,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
|
||||
{
|
||||
if(data[0] instanceof ItemStack)
|
||||
{
|
||||
ItemStack itemStack = (ItemStack)data[0];
|
||||
|
||||
if(itemStack.getTagCompound() == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemStack.getTagCompound().setTag("Items", nbtTags);
|
||||
ItemDataUtils.setList((ItemStack)data[0], "Items", nbtTags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -627,14 +621,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
|
||||
{
|
||||
if(data[0] instanceof ItemStack)
|
||||
{
|
||||
ItemStack itemStack = (ItemStack)data[0];
|
||||
|
||||
if(itemStack.getTagCompound() == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return itemStack.getTagCompound().getTagList("Items", NBT.TAG_COMPOUND);
|
||||
return ItemDataUtils.getList((ItemStack)data[0], "Items");
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -646,18 +633,13 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
|
||||
if(data[0] instanceof ItemStack)
|
||||
{
|
||||
ItemStack itemStack = (ItemStack)data[0];
|
||||
|
||||
if(itemStack.getTagCompound() == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if(fluidStack == null || fluidStack.amount == 0 || fluidStack.getFluid() == null)
|
||||
{
|
||||
itemStack.getTagCompound().removeTag("fluidTank");
|
||||
ItemDataUtils.removeData(itemStack, "fluidTank");
|
||||
}
|
||||
else {
|
||||
itemStack.getTagCompound().setTag("fluidTank", fluidStack.writeToNBT(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemStack, "fluidTank", fluidStack.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -669,15 +651,12 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
|
||||
{
|
||||
ItemStack itemStack = (ItemStack)data[0];
|
||||
|
||||
if(itemStack.getTagCompound() == null)
|
||||
if(!ItemDataUtils.hasData(itemStack, "fluidTank"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if(itemStack.getTagCompound().hasKey("fluidTank"))
|
||||
{
|
||||
return FluidStack.loadFluidStackFromNBT(itemStack.getTagCompound().getCompoundTag("fluidTank"));
|
||||
}
|
||||
return FluidStack.loadFluidStackFromNBT(ItemDataUtils.getCompound(itemStack, "fluidTank"));
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -698,33 +677,23 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
|
||||
|
||||
public void setBucketMode(ItemStack itemStack, boolean bucketMode)
|
||||
{
|
||||
if(itemStack.getTagCompound() == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemStack.getTagCompound().setBoolean("bucketMode", bucketMode);
|
||||
ItemDataUtils.setBoolean(itemStack, "bucketMode", bucketMode);
|
||||
}
|
||||
|
||||
public boolean getBucketMode(ItemStack itemStack)
|
||||
{
|
||||
if(itemStack.getTagCompound() == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return itemStack.getTagCompound().getBoolean("bucketMode");
|
||||
return ItemDataUtils.getBoolean(itemStack, "bucketMode");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getEnergy(ItemStack itemStack)
|
||||
{
|
||||
if(itemStack.getTagCompound() == null || !MachineType.get(itemStack).isElectric)
|
||||
if(!MachineType.get(itemStack).isElectric)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return itemStack.getTagCompound().getDouble("electricity");
|
||||
return ItemDataUtils.getDouble(itemStack, "energyStored");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -735,13 +704,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
|
||||
return;
|
||||
}
|
||||
|
||||
if(itemStack.getTagCompound() == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
double electricityStored = Math.max(Math.min(amount, getMaxEnergy(itemStack)), 0);
|
||||
itemStack.getTagCompound().setDouble("electricity", electricityStored);
|
||||
ItemDataUtils.setDouble(itemStack, "energyStored", Math.max(Math.min(amount, getMaxEnergy(itemStack)), 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -774,14 +737,14 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
|
||||
if(canReceive(theItem))
|
||||
{
|
||||
double energyNeeded = getMaxEnergy(theItem)-getEnergy(theItem);
|
||||
double toReceive = Math.min(energy* general.FROM_TE, energyNeeded);
|
||||
double toReceive = Math.min(energy*general.FROM_TE, energyNeeded);
|
||||
|
||||
if(!simulate)
|
||||
{
|
||||
setEnergy(theItem, getEnergy(theItem) + toReceive);
|
||||
}
|
||||
|
||||
return (int)Math.round(toReceive* general.TO_TE);
|
||||
return (int)Math.round(toReceive*general.TO_TE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -793,14 +756,14 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
|
||||
if(canSend(theItem))
|
||||
{
|
||||
double energyRemaining = getEnergy(theItem);
|
||||
double toSend = Math.min((energy* general.FROM_TE), energyRemaining);
|
||||
double toSend = Math.min((energy*general.FROM_TE), energyRemaining);
|
||||
|
||||
if(!simulate)
|
||||
{
|
||||
setEnergy(theItem, getEnergy(theItem) - toSend);
|
||||
}
|
||||
|
||||
return (int)Math.round(toSend* general.TO_TE);
|
||||
return (int)Math.round(toSend*general.TO_TE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -809,13 +772,13 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
|
||||
@Override
|
||||
public int getEnergyStored(ItemStack theItem)
|
||||
{
|
||||
return (int)(getEnergy(theItem) * general.TO_TE);
|
||||
return (int)(getEnergy(theItem)*general.TO_TE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ItemStack theItem)
|
||||
{
|
||||
return (int)(getMaxEnergy(theItem) * general.TO_TE);
|
||||
return (int)(getMaxEnergy(theItem)*general.TO_TE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -933,9 +896,9 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
|
||||
@Override
|
||||
public String getOwner(ItemStack stack)
|
||||
{
|
||||
if(stack.hasTagCompound() && stack.getTagCompound().hasKey("owner"))
|
||||
if(ItemDataUtils.hasData(stack, "owner"))
|
||||
{
|
||||
return stack.getTagCompound().getString("owner");
|
||||
return ItemDataUtils.getString(stack, "owner");
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -944,40 +907,25 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
|
||||
@Override
|
||||
public void setOwner(ItemStack stack, String owner)
|
||||
{
|
||||
if(!stack.hasTagCompound())
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if(owner == null || owner.isEmpty())
|
||||
{
|
||||
stack.getTagCompound().removeTag("owner");
|
||||
ItemDataUtils.removeData(stack, "owner");
|
||||
return;
|
||||
}
|
||||
|
||||
stack.getTagCompound().setString("owner", owner);
|
||||
ItemDataUtils.setString(stack, "owner", owner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecurityMode getSecurity(ItemStack stack)
|
||||
{
|
||||
if(stack.getTagCompound() == null)
|
||||
{
|
||||
return SecurityMode.PUBLIC;
|
||||
}
|
||||
|
||||
return SecurityMode.values()[stack.getTagCompound().getInteger("security")];
|
||||
return SecurityMode.values()[ItemDataUtils.getInt(stack, "security")];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecurity(ItemStack stack, SecurityMode mode)
|
||||
{
|
||||
if(!stack.hasTagCompound())
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
stack.getTagCompound().setInteger("security", mode.ordinal());
|
||||
ItemDataUtils.setInt(stack, "security", mode.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,6 +9,7 @@ import mekanism.common.base.IRedstoneControl;
|
||||
import mekanism.common.base.IRedstoneControl.RedstoneControl;
|
||||
import mekanism.common.base.ISideConfiguration;
|
||||
import mekanism.common.tile.TileEntityContainerBlock;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -140,35 +141,25 @@ public class ItemConfigurationCard extends ItemMekanism
|
||||
|
||||
public void setData(ItemStack itemstack, NBTTagCompound data)
|
||||
{
|
||||
if(itemstack.hasTagCompound())
|
||||
{
|
||||
itemstack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if(data != null)
|
||||
{
|
||||
itemstack.getTagCompound().setTag("data", data);
|
||||
ItemDataUtils.setCompound(itemstack, "data", data);
|
||||
}
|
||||
else {
|
||||
itemstack.getTagCompound().removeTag("data");
|
||||
ItemDataUtils.removeData(itemstack, "data");
|
||||
}
|
||||
}
|
||||
|
||||
public NBTTagCompound getData(ItemStack itemstack)
|
||||
{
|
||||
if(!itemstack.hasTagCompound())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
NBTTagCompound data = itemstack.getTagCompound().getCompoundTag("data");
|
||||
NBTTagCompound data = ItemDataUtils.getCompound(itemstack, "data");
|
||||
|
||||
if(data.hasNoTags())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return itemstack.getTagCompound().getCompoundTag("data");
|
||||
return ItemDataUtils.getCompound(itemstack, "data");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.tile.TileEntityBasicBlock;
|
||||
import mekanism.common.tile.TileEntityContainerBlock;
|
||||
import mekanism.common.tile.component.TileComponentConfig;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.SecurityUtils;
|
||||
@@ -237,27 +238,12 @@ public class ItemConfigurator extends ItemEnergized implements IMekWrench, ITool
|
||||
|
||||
public void setState(ItemStack itemstack, ConfiguratorMode state)
|
||||
{
|
||||
if(itemstack.getTagCompound() == null)
|
||||
{
|
||||
itemstack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemstack.getTagCompound().setInteger("state", state.ordinal());
|
||||
ItemDataUtils.setInt(itemstack, "state", state.ordinal());
|
||||
}
|
||||
|
||||
public ConfiguratorMode getState(ItemStack itemstack)
|
||||
{
|
||||
if(itemstack.getTagCompound() == null)
|
||||
{
|
||||
return ConfiguratorMode.CONFIGURATE_ITEMS;
|
||||
}
|
||||
|
||||
if(itemstack.getTagCompound().getTag("state") != null)
|
||||
{
|
||||
return ConfiguratorMode.values()[itemstack.getTagCompound().getInteger("state")];
|
||||
}
|
||||
|
||||
return ConfiguratorMode.CONFIGURATE_ITEMS;
|
||||
return ConfiguratorMode.values()[ItemDataUtils.getInt(itemstack, "state")];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.List;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -13,7 +14,6 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -110,32 +110,22 @@ public class ItemCraftingFormula extends ItemMekanism
|
||||
|
||||
public boolean isInvalid(ItemStack stack)
|
||||
{
|
||||
if(!stack.hasTagCompound())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return stack.getTagCompound().getBoolean("invalid");
|
||||
return ItemDataUtils.getBoolean(stack, "invalid");
|
||||
}
|
||||
|
||||
public void setInvalid(ItemStack stack, boolean invalid)
|
||||
{
|
||||
if(!stack.hasTagCompound())
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
stack.getTagCompound().setBoolean("invalid", invalid);
|
||||
ItemDataUtils.setBoolean(stack, "invalid", invalid);
|
||||
}
|
||||
|
||||
public ItemStack[] getInventory(ItemStack stack)
|
||||
{
|
||||
if(!stack.hasTagCompound() || !stack.getTagCompound().hasKey("Items"))
|
||||
if(!ItemDataUtils.hasData(stack, "Items"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
NBTTagList tagList = stack.getTagCompound().getTagList("Items", NBT.TAG_COMPOUND);
|
||||
NBTTagList tagList = ItemDataUtils.getList(stack, "Items");
|
||||
ItemStack[] inventory = new ItemStack[9];
|
||||
|
||||
for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++)
|
||||
@@ -154,14 +144,9 @@ public class ItemCraftingFormula extends ItemMekanism
|
||||
|
||||
public void setInventory(ItemStack stack, ItemStack[] inv)
|
||||
{
|
||||
if(!stack.hasTagCompound())
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if(inv == null)
|
||||
{
|
||||
stack.getTagCompound().removeTag("Items");
|
||||
ItemDataUtils.removeData(stack, "Items");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -178,6 +163,6 @@ public class ItemCraftingFormula extends ItemMekanism
|
||||
}
|
||||
}
|
||||
|
||||
stack.getTagCompound().setTag("Items", tagList);
|
||||
ItemDataUtils.setList(stack, "Items", tagList);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package mekanism.common.item;
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
@@ -11,7 +12,6 @@ import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemElectricBow extends ItemEnergized
|
||||
@@ -107,41 +107,14 @@ public class ItemElectricBow extends ItemEnergized
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the bow's fire state in NBT.
|
||||
* @param itemstack - the bow's itemstack
|
||||
* @param state - state to change to
|
||||
*/
|
||||
public void setFireState(ItemStack itemstack, boolean state)
|
||||
{
|
||||
if(itemstack.getTagCompound() == null)
|
||||
{
|
||||
itemstack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemstack.getTagCompound().setBoolean("fireState", state);
|
||||
ItemDataUtils.setBoolean(itemstack, "fireState", state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bow's fire state from NBT.
|
||||
* @param itemstack - the bow's itemstack
|
||||
* @return fire state
|
||||
*/
|
||||
public boolean getFireState(ItemStack itemstack)
|
||||
{
|
||||
if(itemstack.getTagCompound() == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean state = false;
|
||||
|
||||
if(itemstack.getTagCompound().getTag("fireState") != null)
|
||||
{
|
||||
state = itemstack.getTagCompound().getBoolean("fireState");
|
||||
}
|
||||
|
||||
return state;
|
||||
return ItemDataUtils.getBoolean(itemstack, "fireState");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,13 +10,13 @@ import mekanism.api.MekanismConfig.general;
|
||||
import mekanism.api.energy.IEnergizedItem;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.integration.IC2ItemManager;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.common.Optional.Interface;
|
||||
import net.minecraftforge.fml.common.Optional.InterfaceList;
|
||||
import net.minecraftforge.fml.common.Optional.Method;
|
||||
@@ -116,24 +116,13 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, ISpec
|
||||
@Override
|
||||
public double getEnergy(ItemStack itemStack)
|
||||
{
|
||||
if(itemStack.getTagCompound() == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return itemStack.getTagCompound().getDouble("electricity");
|
||||
return ItemDataUtils.getDouble(itemStack, "energyStored");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergy(ItemStack itemStack, double amount)
|
||||
{
|
||||
if(itemStack.getTagCompound() == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
double electricityStored = Math.max(Math.min(amount, getMaxEnergy(itemStack)), 0);
|
||||
itemStack.getTagCompound().setDouble("electricity", electricityStored);
|
||||
ItemDataUtils.setDouble(itemStack, "energyStored", Math.max(Math.min(amount, getMaxEnergy(itemStack)), 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,6 +8,7 @@ import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -99,17 +100,6 @@ public class ItemFlamethrower extends ItemMekanism implements IGasItem
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GasStack getGas(ItemStack itemstack)
|
||||
{
|
||||
if(itemstack.getTagCompound() == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return GasStack.readFromNBT(itemstack.getTagCompound().getCompoundTag("stored"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDurabilityBar(ItemStack stack)
|
||||
@@ -123,23 +113,24 @@ public class ItemFlamethrower extends ItemMekanism implements IGasItem
|
||||
return 1D-((getGas(stack) != null ? (double)getGas(stack).amount : 0D)/(double)getMaxGas(stack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public GasStack getGas(ItemStack itemstack)
|
||||
{
|
||||
return GasStack.readFromNBT(ItemDataUtils.getCompound(itemstack, "stored"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGas(ItemStack itemstack, GasStack stack)
|
||||
{
|
||||
if(itemstack.getTagCompound() == null)
|
||||
{
|
||||
itemstack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if(stack == null || stack.amount == 0)
|
||||
{
|
||||
itemstack.getTagCompound().removeTag("stored");
|
||||
ItemDataUtils.removeData(itemstack, "stored");
|
||||
}
|
||||
else {
|
||||
int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack)));
|
||||
GasStack gasStack = new GasStack(stack.getGas(), amount);
|
||||
|
||||
itemstack.getTagCompound().setTag("stored", gasStack.write(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemstack, "stored", gasStack.write(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,22 +160,12 @@ public class ItemFlamethrower extends ItemMekanism implements IGasItem
|
||||
|
||||
public FlamethrowerMode getMode(ItemStack stack)
|
||||
{
|
||||
if(stack.getTagCompound() == null)
|
||||
{
|
||||
return FlamethrowerMode.COMBAT;
|
||||
}
|
||||
|
||||
return FlamethrowerMode.values()[stack.getTagCompound().getInteger("mode")];
|
||||
return FlamethrowerMode.values()[ItemDataUtils.getInt(stack, "mode")];
|
||||
}
|
||||
|
||||
public void setMode(ItemStack stack, FlamethrowerMode mode)
|
||||
{
|
||||
if(stack.getTagCompound() == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
stack.getTagCompound().setInteger("mode", mode.ordinal());
|
||||
ItemDataUtils.setInt(stack, "mode", mode.ordinal());
|
||||
}
|
||||
|
||||
public static enum FlamethrowerMode
|
||||
|
||||
@@ -12,6 +12,7 @@ import mekanism.client.render.ModelCustomArmor;
|
||||
import mekanism.client.render.ModelCustomArmor.ArmorModel;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.integration.IC2ItemManager;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
@@ -22,7 +23,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraftforge.common.util.EnumHelper;
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
@@ -49,12 +49,6 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci
|
||||
setCreativeTab(Mekanism.tabMekanism);
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister register) {}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean isValidArmor(ItemStack stack, int armorType, Entity entity)
|
||||
{
|
||||
@@ -142,24 +136,13 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci
|
||||
@Override
|
||||
public double getEnergy(ItemStack itemStack)
|
||||
{
|
||||
if(itemStack.getTagCompound() == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return itemStack.getTagCompound().getDouble("electricity");
|
||||
return ItemDataUtils.getDouble(itemStack, "energyStored");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergy(ItemStack itemStack, double amount)
|
||||
{
|
||||
if(itemStack.getTagCompound() == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
double electricityStored = Math.max(Math.min(amount, getMaxEnergy(itemStack)), 0);
|
||||
itemStack.getTagCompound().setDouble("electricity", electricityStored);
|
||||
ItemDataUtils.setDouble(itemStack, "energyStored", Math.max(Math.min(amount, getMaxEnergy(itemStack)), 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,12 +23,6 @@ public class ItemGasMask extends ItemArmor
|
||||
setCreativeTab(Mekanism.tabMekanism);
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister register) {}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean isValidArmor(ItemStack stack, int armorType, Entity entity)
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -101,14 +102,9 @@ public class ItemGaugeDropper extends ItemMekanism implements IGasItem, IFluidCo
|
||||
|
||||
private FluidStack getFluid_do(ItemStack container)
|
||||
{
|
||||
if(container.getTagCompound() == null)
|
||||
if(ItemDataUtils.hasData(container, "fluidStack"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if(container.getTagCompound().hasKey("fluidStack"))
|
||||
{
|
||||
return FluidStack.loadFluidStackFromNBT(container.getTagCompound().getCompoundTag("fluidStack"));
|
||||
return FluidStack.loadFluidStackFromNBT(ItemDataUtils.getCompound(container, "fluidStack"));
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -122,17 +118,12 @@ public class ItemGaugeDropper extends ItemMekanism implements IGasItem, IFluidCo
|
||||
|
||||
public void setFluid(ItemStack container, FluidStack stack)
|
||||
{
|
||||
if(container.getTagCompound() == null)
|
||||
{
|
||||
container.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if(stack == null || stack.amount == 0 || stack.getFluid() == null)
|
||||
{
|
||||
container.getTagCompound().removeTag("fluidStack");
|
||||
ItemDataUtils.removeData(container, "fluidStack");
|
||||
}
|
||||
else {
|
||||
container.getTagCompound().setTag("fluidStack", stack.writeToNBT(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(container, "fluidStack", stack.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,12 +237,7 @@ public class ItemGaugeDropper extends ItemMekanism implements IGasItem, IFluidCo
|
||||
|
||||
private GasStack getGas_do(ItemStack itemstack)
|
||||
{
|
||||
if(itemstack.getTagCompound() == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return GasStack.readFromNBT(itemstack.getTagCompound().getCompoundTag("gasStack"));
|
||||
return GasStack.readFromNBT(ItemDataUtils.getCompound(itemstack, "gasStack"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -261,22 +247,17 @@ public class ItemGaugeDropper extends ItemMekanism implements IGasItem, IFluidCo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGas(ItemStack itemstack, GasStack stack)
|
||||
public void setGas(ItemStack itemstack, GasStack stack)
|
||||
{
|
||||
if(itemstack.getTagCompound() == null)
|
||||
{
|
||||
itemstack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if(stack == null || stack.amount == 0)
|
||||
{
|
||||
itemstack.getTagCompound().removeTag("gasStack");
|
||||
ItemDataUtils.removeData(itemstack, "gasStack");
|
||||
}
|
||||
else {
|
||||
int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack)));
|
||||
GasStack gasStack = new GasStack(stack.getGas(), amount);
|
||||
|
||||
itemstack.getTagCompound().setTag("gasStack", gasStack.write(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemstack, "gasStack", gasStack.write(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import mekanism.client.render.ModelCustomArmor;
|
||||
import mekanism.client.render.ModelCustomArmor.ArmorModel;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismItems;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
@@ -160,54 +161,34 @@ public class ItemJetpack extends ItemArmor implements IGasItem, ISpecialArmor
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GasStack getGas(ItemStack itemstack)
|
||||
{
|
||||
if(itemstack.getTagCompound() == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return GasStack.readFromNBT(itemstack.getTagCompound().getCompoundTag("stored"));
|
||||
}
|
||||
|
||||
public JetpackMode getMode(ItemStack stack)
|
||||
{
|
||||
if(stack.getTagCompound() == null)
|
||||
{
|
||||
return JetpackMode.NORMAL;
|
||||
}
|
||||
|
||||
return JetpackMode.values()[stack.getTagCompound().getInteger("mode")];
|
||||
return JetpackMode.values()[ItemDataUtils.getInt(stack, "mode")];
|
||||
}
|
||||
|
||||
public void setMode(ItemStack stack, JetpackMode mode)
|
||||
{
|
||||
if(stack.getTagCompound() == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
ItemDataUtils.setInt(stack, "mode", mode.ordinal());
|
||||
}
|
||||
|
||||
stack.getTagCompound().setInteger("mode", mode.ordinal());
|
||||
@Override
|
||||
public GasStack getGas(ItemStack itemstack)
|
||||
{
|
||||
return GasStack.readFromNBT(ItemDataUtils.getCompound(itemstack, "stored"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGas(ItemStack itemstack, GasStack stack)
|
||||
{
|
||||
if(itemstack.getTagCompound() == null)
|
||||
{
|
||||
itemstack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if(stack == null || stack.amount == 0)
|
||||
{
|
||||
itemstack.getTagCompound().removeTag("stored");
|
||||
ItemDataUtils.removeData(itemstack, "stored");
|
||||
}
|
||||
else {
|
||||
int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack)));
|
||||
GasStack gasStack = new GasStack(stack.getGas(), amount);
|
||||
|
||||
itemstack.getTagCompound().setTag("stored", gasStack.write(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemstack, "stored", gasStack.write(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@ import mekanism.client.MekKeyHandler;
|
||||
import mekanism.client.MekanismKeyHandler;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.security.IOwnerItem;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.SecurityUtils;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -99,9 +99,9 @@ public class ItemPortableTeleporter extends ItemEnergized implements IOwnerItem
|
||||
@Override
|
||||
public String getOwner(ItemStack stack)
|
||||
{
|
||||
if(stack.hasTagCompound() && stack.getTagCompound().hasKey("owner"))
|
||||
if(ItemDataUtils.hasData(stack, "owner"))
|
||||
{
|
||||
return stack.getTagCompound().getString("owner");
|
||||
return ItemDataUtils.getString(stack, "owner");
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -115,11 +115,11 @@ public class ItemPortableTeleporter extends ItemEnergized implements IOwnerItem
|
||||
|
||||
if(owner == null || owner.isEmpty())
|
||||
{
|
||||
stack.getTagCompound().removeTag("owner");
|
||||
ItemDataUtils.removeData(stack, "owner");
|
||||
return;
|
||||
}
|
||||
|
||||
stack.getTagCompound().setString("owner", owner);
|
||||
ItemDataUtils.setString(stack, "owner", owner);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -130,29 +130,19 @@ public class ItemPortableTeleporter extends ItemEnergized implements IOwnerItem
|
||||
|
||||
public boolean isPrivateMode(ItemStack stack)
|
||||
{
|
||||
if(stack.hasTagCompound())
|
||||
{
|
||||
return stack.getTagCompound().getBoolean("private");
|
||||
}
|
||||
|
||||
return false;
|
||||
return ItemDataUtils.getBoolean(stack, "private");
|
||||
}
|
||||
|
||||
public void setPrivateMode(ItemStack stack, boolean isPrivate)
|
||||
{
|
||||
if(!stack.hasTagCompound())
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
stack.getTagCompound().setBoolean("private", isPrivate);
|
||||
ItemDataUtils.setBoolean(stack, "private", isPrivate);
|
||||
}
|
||||
|
||||
public String getFrequency(ItemStack stack)
|
||||
{
|
||||
if(stack.hasTagCompound() && stack.getTagCompound().hasKey("frequency"))
|
||||
if(ItemDataUtils.hasData(stack, "frequency"))
|
||||
{
|
||||
return stack.getTagCompound().getString("frequency");
|
||||
return ItemDataUtils.getString(stack, "frequency");
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -160,17 +150,12 @@ public class ItemPortableTeleporter extends ItemEnergized implements IOwnerItem
|
||||
|
||||
public void setFrequency(ItemStack stack, String frequency)
|
||||
{
|
||||
if(!stack.hasTagCompound())
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if(frequency == null || frequency.isEmpty())
|
||||
{
|
||||
stack.getTagCompound().removeTag("frequency");
|
||||
ItemDataUtils.removeData(stack, "frequency");
|
||||
return;
|
||||
}
|
||||
|
||||
stack.getTagCompound().setString("frequency", frequency);
|
||||
ItemDataUtils.setString(stack, "frequency", frequency);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package mekanism.common.item;
|
||||
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -21,14 +22,6 @@ public class ItemProxy extends Item
|
||||
return getSavedItem(stack);
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public boolean doesContainerItemLeaveCraftingGrid(ItemStack stack)
|
||||
{
|
||||
return stack.getTagCompound() == null || !stack.getTagCompound().getBoolean("hasStack");
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean hasContainerItem(ItemStack itemStack)
|
||||
{
|
||||
@@ -37,32 +30,22 @@ public class ItemProxy extends Item
|
||||
|
||||
public void setSavedItem(ItemStack stack, ItemStack save)
|
||||
{
|
||||
if(stack.getTagCompound() == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if(save == null)
|
||||
{
|
||||
stack.getTagCompound().setBoolean("hasStack", false);
|
||||
stack.getTagCompound().removeTag("savedItem");
|
||||
ItemDataUtils.setBoolean(stack, "hasStack", false);
|
||||
ItemDataUtils.removeData(stack, "savedItem");
|
||||
}
|
||||
else {
|
||||
stack.getTagCompound().setBoolean("hasStack", true);
|
||||
stack.getTagCompound().setTag("savedItem", save.writeToNBT(new NBTTagCompound()));
|
||||
ItemDataUtils.setBoolean(stack, "hasStack", true);
|
||||
ItemDataUtils.setCompound(stack, "savedItem", save.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getSavedItem(ItemStack stack)
|
||||
{
|
||||
if(stack.getTagCompound() == null)
|
||||
if(ItemDataUtils.getBoolean(stack, "hasStack"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if(stack.getTagCompound().getBoolean("hasStack"))
|
||||
{
|
||||
return ItemStack.loadItemStackFromNBT(stack.getTagCompound().getCompoundTag("savedItem"));
|
||||
return ItemStack.loadItemStackFromNBT(ItemDataUtils.getCompound(stack, "savedItem"));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -7,10 +7,10 @@ import mekanism.api.EnumColor;
|
||||
import mekanism.common.base.ISustainedInventory;
|
||||
import mekanism.common.entity.EntityRobit;
|
||||
import mekanism.common.tile.TileEntityChargepad;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
@@ -76,24 +76,14 @@ public class ItemRobit extends ItemEnergized implements ISustainedInventory
|
||||
|
||||
public void setName(ItemStack itemstack, String name)
|
||||
{
|
||||
if(itemstack.getTagCompound() == null)
|
||||
{
|
||||
itemstack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemstack.getTagCompound().setString("name", name);
|
||||
ItemDataUtils.setString(itemstack, "name", name);
|
||||
}
|
||||
|
||||
public String getName(ItemStack itemstack)
|
||||
{
|
||||
if(itemstack.getTagCompound() == null)
|
||||
{
|
||||
return "Robit";
|
||||
}
|
||||
String name = ItemDataUtils.getString(itemstack, "name");
|
||||
|
||||
String name = itemstack.getTagCompound().getString("name");
|
||||
|
||||
return name.equals("") ? "Robit" : name;
|
||||
return name.isEmpty() ? "Robit" : name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,14 +91,7 @@ public class ItemRobit extends ItemEnergized implements ISustainedInventory
|
||||
{
|
||||
if(data[0] instanceof ItemStack)
|
||||
{
|
||||
ItemStack itemStack = (ItemStack)data[0];
|
||||
|
||||
if(itemStack.getTagCompound() == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemStack.getTagCompound().setTag("Items", nbtTags);
|
||||
ItemDataUtils.setList((ItemStack)data[0], "Items", nbtTags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,14 +100,7 @@ public class ItemRobit extends ItemEnergized implements ISustainedInventory
|
||||
{
|
||||
if(data[0] instanceof ItemStack)
|
||||
{
|
||||
ItemStack itemStack = (ItemStack)data[0];
|
||||
|
||||
if(itemStack.getTagCompound() == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return itemStack.getTagCompound().getTagList("Items", 10);
|
||||
return ItemDataUtils.getList((ItemStack)data[0], "Items");
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -11,6 +11,7 @@ import mekanism.api.gas.IGasItem;
|
||||
import mekanism.client.render.ModelCustomArmor;
|
||||
import mekanism.client.render.ModelCustomArmor.ArmorModel;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
@@ -153,12 +154,7 @@ public class ItemScubaTank extends ItemArmor implements IGasItem
|
||||
|
||||
public boolean getFlowing(ItemStack stack)
|
||||
{
|
||||
if(stack.getTagCompound() == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return stack.getTagCompound().getBoolean("flowing");
|
||||
return ItemDataUtils.getBoolean(stack, "flowing");
|
||||
}
|
||||
|
||||
public String getFlowingStr(ItemStack stack)
|
||||
@@ -170,12 +166,7 @@ public class ItemScubaTank extends ItemArmor implements IGasItem
|
||||
|
||||
public void setFlowing(ItemStack stack, boolean flowing)
|
||||
{
|
||||
if(stack.getTagCompound() == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
stack.getTagCompound().setBoolean("flowing", flowing);
|
||||
ItemDataUtils.setBoolean(stack, "flowing", flowing);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -193,31 +184,21 @@ public class ItemScubaTank extends ItemArmor implements IGasItem
|
||||
@Override
|
||||
public GasStack getGas(ItemStack itemstack)
|
||||
{
|
||||
if(itemstack.getTagCompound() == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return GasStack.readFromNBT(itemstack.getTagCompound().getCompoundTag("stored"));
|
||||
return GasStack.readFromNBT(ItemDataUtils.getCompound(itemstack, "stored"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGas(ItemStack itemstack, GasStack stack)
|
||||
{
|
||||
if(itemstack.getTagCompound() == null)
|
||||
{
|
||||
itemstack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if(stack == null || stack.amount == 0)
|
||||
{
|
||||
itemstack.getTagCompound().removeTag("stored");
|
||||
ItemDataUtils.removeData(itemstack, "stored");
|
||||
}
|
||||
else {
|
||||
int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack)));
|
||||
GasStack gasStack = new GasStack(stack.getGas(), amount);
|
||||
|
||||
itemstack.getTagCompound().setTag("stored", gasStack.write(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemstack, "stored", gasStack.write(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemWalkieTalkie extends ItemMekanism
|
||||
@@ -62,48 +62,29 @@ public class ItemWalkieTalkie extends ItemMekanism
|
||||
|
||||
public void setOn(ItemStack itemStack, boolean on)
|
||||
{
|
||||
if(itemStack.getTagCompound() == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemStack.getTagCompound().setBoolean("on", on);
|
||||
ItemDataUtils.setBoolean(itemStack, "on", on);
|
||||
}
|
||||
|
||||
public boolean getOn(ItemStack itemStack)
|
||||
{
|
||||
if(itemStack.getTagCompound() == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return itemStack.getTagCompound().getBoolean("on");
|
||||
return ItemDataUtils.getBoolean(itemStack, "on");
|
||||
}
|
||||
|
||||
public void setChannel(ItemStack itemStack, int channel)
|
||||
{
|
||||
if(itemStack.getTagCompound() == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemStack.getTagCompound().setInteger("channel", channel);
|
||||
ItemDataUtils.setInt(itemStack, "channel", channel);
|
||||
}
|
||||
|
||||
public int getChannel(ItemStack itemStack)
|
||||
{
|
||||
if(itemStack.getTagCompound() == null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int channel = itemStack.getTagCompound().getInteger("channel");
|
||||
int channel = ItemDataUtils.getInt(itemStack, "channel");
|
||||
|
||||
if(channel == 0)
|
||||
{
|
||||
setChannel(itemStack, 1);
|
||||
channel = 1;
|
||||
}
|
||||
|
||||
return itemStack.getTagCompound().getInteger("channel");
|
||||
return channel;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import mekanism.common.MekanismItems;
|
||||
import mekanism.common.block.states.BlockStateBasic.BasicBlockType;
|
||||
import mekanism.common.inventory.InventoryBin;
|
||||
import mekanism.common.item.ItemProxy;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -144,7 +145,7 @@ public class BinRecipe implements IRecipe
|
||||
|
||||
ItemStack testRemove = inv.removeStack();
|
||||
|
||||
bin.getTagCompound().setInteger("newCount", size-(testRemove != null ? testRemove.stackSize : 0));
|
||||
ItemDataUtils.setInt(bin, "newCount", size-(testRemove != null ? testRemove.stackSize : 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ import mekanism.common.tile.component.TileComponentSecurity;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -463,14 +464,14 @@ public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock
|
||||
{
|
||||
if(inputTank.getGas() != null)
|
||||
{
|
||||
itemStack.getTagCompound().setTag("inputTank", inputTank.getGas().write(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemStack, "inputTank", inputTank.getGas().write(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSustainedData(ItemStack itemStack)
|
||||
{
|
||||
inputTank.setGas(GasStack.readFromNBT(itemStack.getTagCompound().getCompoundTag("inputTank")));
|
||||
inputTank.setGas(GasStack.readFromNBT(ItemDataUtils.getCompound(itemStack, "inputTank")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,6 +33,7 @@ import mekanism.common.tile.component.TileComponentSecurity;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.StatUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -471,20 +472,20 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectri
|
||||
{
|
||||
if(injectTank.getGas() != null)
|
||||
{
|
||||
itemStack.getTagCompound().setTag("injectTank", injectTank.getGas().write(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemStack, "injectTank", injectTank.getGas().write(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
if(outputTank.getGas() != null)
|
||||
{
|
||||
itemStack.getTagCompound().setTag("outputTank", outputTank.getGas().write(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemStack, "outputTank", outputTank.getGas().write(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSustainedData(ItemStack itemStack)
|
||||
{
|
||||
injectTank.setGas(GasStack.readFromNBT(itemStack.getTagCompound().getCompoundTag("injectTank")));
|
||||
outputTank.setGas(GasStack.readFromNBT(itemStack.getTagCompound().getCompoundTag("outputTank")));
|
||||
injectTank.setGas(GasStack.readFromNBT(ItemDataUtils.getCompound(itemStack, "injectTank")));
|
||||
outputTank.setGas(GasStack.readFromNBT(ItemDataUtils.getCompound(itemStack, "outputTank")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,6 +34,7 @@ import mekanism.common.tile.component.TileComponentSecurity;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -511,26 +512,26 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl
|
||||
{
|
||||
if(leftTank.getGas() != null)
|
||||
{
|
||||
itemStack.getTagCompound().setTag("leftTank", leftTank.getGas().write(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemStack, "leftTank", leftTank.getGas().write(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
if(rightTank.getGas() != null)
|
||||
{
|
||||
itemStack.getTagCompound().setTag("rightTank", rightTank.getGas().write(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemStack, "rightTank", rightTank.getGas().write(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
if(centerTank.getGas() != null)
|
||||
{
|
||||
itemStack.getTagCompound().setTag("centerTank", centerTank.getGas().write(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemStack, "centerTank", centerTank.getGas().write(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSustainedData(ItemStack itemStack)
|
||||
{
|
||||
leftTank.setGas(GasStack.readFromNBT(itemStack.getTagCompound().getCompoundTag("leftTank")));
|
||||
rightTank.setGas(GasStack.readFromNBT(itemStack.getTagCompound().getCompoundTag("rightTank")));
|
||||
centerTank.setGas(GasStack.readFromNBT(itemStack.getTagCompound().getCompoundTag("centerTank")));
|
||||
leftTank.setGas(GasStack.readFromNBT(ItemDataUtils.getCompound(itemStack, "leftTank")));
|
||||
rightTank.setGas(GasStack.readFromNBT(ItemDataUtils.getCompound(itemStack, "rightTank")));
|
||||
centerTank.setGas(GasStack.readFromNBT(ItemDataUtils.getCompound(itemStack, "centerTank")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,6 +31,7 @@ import mekanism.common.tile.component.TileComponentSecurity;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -384,14 +385,14 @@ public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock imp
|
||||
{
|
||||
if(gasTank.getGas() != null)
|
||||
{
|
||||
itemStack.getTagCompound().setTag("gasTank", gasTank.getGas().write(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemStack, "gasTank", gasTank.getGas().write(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSustainedData(ItemStack itemStack)
|
||||
{
|
||||
gasTank.setGas(GasStack.readFromNBT(itemStack.getTagCompound().getCompoundTag("gasTank")));
|
||||
gasTank.setGas(GasStack.readFromNBT(ItemDataUtils.getCompound(itemStack, "gasTank")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -36,6 +36,7 @@ import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.FluidContainerUtils;
|
||||
import mekanism.common.util.FluidContainerUtils.FluidChecker;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.PipeUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -565,26 +566,26 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple
|
||||
{
|
||||
if(fluidTank.getFluid() != null)
|
||||
{
|
||||
itemStack.getTagCompound().setTag("fluidTank", fluidTank.getFluid().writeToNBT(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemStack, "fluidTank", fluidTank.getFluid().writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
if(inputTank.getGas() != null)
|
||||
{
|
||||
itemStack.getTagCompound().setTag("inputTank", inputTank.getGas().write(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemStack, "inputTank", inputTank.getGas().write(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
if(outputTank.getGas() != null)
|
||||
{
|
||||
itemStack.getTagCompound().setTag("outputTank", outputTank.getGas().write(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemStack, "outputTank", outputTank.getGas().write(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSustainedData(ItemStack itemStack)
|
||||
{
|
||||
fluidTank.setFluid(FluidStack.loadFluidStackFromNBT(itemStack.getTagCompound().getCompoundTag("fluidTank")));
|
||||
inputTank.setGas(GasStack.readFromNBT(itemStack.getTagCompound().getCompoundTag("inputTank")));
|
||||
outputTank.setGas(GasStack.readFromNBT(itemStack.getTagCompound().getCompoundTag("outputTank")));
|
||||
fluidTank.setFluid(FluidStack.loadFluidStackFromNBT(ItemDataUtils.getCompound(itemStack, "fluidTank")));
|
||||
inputTank.setGas(GasStack.readFromNBT(ItemDataUtils.getCompound(itemStack, "inputTank")));
|
||||
outputTank.setGas(GasStack.readFromNBT(ItemDataUtils.getCompound(itemStack, "outputTank")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -40,6 +40,7 @@ import mekanism.common.tile.component.TileComponentSecurity;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MinerUtils;
|
||||
import mekanism.common.util.TransporterUtils;
|
||||
@@ -1436,15 +1437,15 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
|
||||
|
||||
public void writeSustainedData(ItemStack itemStack)
|
||||
{
|
||||
itemStack.getTagCompound().setBoolean("hasMinerConfig", true);
|
||||
ItemDataUtils.setBoolean(itemStack, "hasMinerConfig", true);
|
||||
|
||||
itemStack.getTagCompound().setInteger("radius", radius);
|
||||
itemStack.getTagCompound().setInteger("minY", minY);
|
||||
itemStack.getTagCompound().setInteger("maxY", maxY);
|
||||
itemStack.getTagCompound().setBoolean("doEject", doEject);
|
||||
itemStack.getTagCompound().setBoolean("doPull", doPull);
|
||||
itemStack.getTagCompound().setBoolean("silkTouch", silkTouch);
|
||||
itemStack.getTagCompound().setBoolean("inverse", inverse);
|
||||
ItemDataUtils.setInt(itemStack, "radius", radius);
|
||||
ItemDataUtils.setInt(itemStack, "minY", minY);
|
||||
ItemDataUtils.setInt(itemStack, "maxY", maxY);
|
||||
ItemDataUtils.setBoolean(itemStack, "doEject", doEject);
|
||||
ItemDataUtils.setBoolean(itemStack, "doPull", doPull);
|
||||
ItemDataUtils.setBoolean(itemStack, "silkTouch", silkTouch);
|
||||
ItemDataUtils.setBoolean(itemStack, "inverse", inverse);
|
||||
|
||||
NBTTagList filterTags = new NBTTagList();
|
||||
|
||||
@@ -1455,26 +1456,26 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
|
||||
|
||||
if(filterTags.tagCount() != 0)
|
||||
{
|
||||
itemStack.getTagCompound().setTag("filters", filterTags);
|
||||
ItemDataUtils.setList(itemStack, "filters", filterTags);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSustainedData(ItemStack itemStack)
|
||||
{
|
||||
if(itemStack.getTagCompound().hasKey("hasMinerConfig"))
|
||||
if(ItemDataUtils.hasData(itemStack, "hasMinerConfig"))
|
||||
{
|
||||
radius = itemStack.getTagCompound().getInteger("radius");
|
||||
minY = itemStack.getTagCompound().getInteger("minY");
|
||||
maxY = itemStack.getTagCompound().getInteger("maxY");
|
||||
doEject = itemStack.getTagCompound().getBoolean("doEject");
|
||||
doPull = itemStack.getTagCompound().getBoolean("doPull");
|
||||
silkTouch = itemStack.getTagCompound().getBoolean("silkTouch");
|
||||
inverse = itemStack.getTagCompound().getBoolean("inverse");
|
||||
radius = ItemDataUtils.getInt(itemStack, "radius");
|
||||
minY = ItemDataUtils.getInt(itemStack, "minY");
|
||||
maxY = ItemDataUtils.getInt(itemStack, "maxY");
|
||||
doEject = ItemDataUtils.getBoolean(itemStack, "doEject");
|
||||
doPull = ItemDataUtils.getBoolean(itemStack, "doPull");
|
||||
silkTouch = ItemDataUtils.getBoolean(itemStack, "silkTouch");
|
||||
inverse = ItemDataUtils.getBoolean(itemStack, "inverse");
|
||||
|
||||
if(itemStack.getTagCompound().hasKey("filters"))
|
||||
if(ItemDataUtils.hasData(itemStack, "filters"))
|
||||
{
|
||||
NBTTagList tagList = itemStack.getTagCompound().getTagList("filters", NBT.TAG_COMPOUND);
|
||||
NBTTagList tagList = ItemDataUtils.getList(itemStack, "filters");
|
||||
|
||||
for(int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
|
||||
@@ -39,6 +39,7 @@ import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.FluidContainerUtils;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -584,26 +585,26 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
|
||||
{
|
||||
if(fluidTank.getFluid() != null)
|
||||
{
|
||||
itemStack.getTagCompound().setTag("fluidTank", fluidTank.getFluid().writeToNBT(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemStack, "fluidTank", fluidTank.getFluid().writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
if(leftTank.getGas() != null)
|
||||
{
|
||||
itemStack.getTagCompound().setTag("leftTank", leftTank.getGas().write(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemStack, "leftTank", leftTank.getGas().write(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
if(rightTank.getGas() != null)
|
||||
{
|
||||
itemStack.getTagCompound().setTag("rightTank", rightTank.getGas().write(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemStack, "rightTank", rightTank.getGas().write(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSustainedData(ItemStack itemStack)
|
||||
{
|
||||
fluidTank.setFluid(FluidStack.loadFluidStackFromNBT(itemStack.getTagCompound().getCompoundTag("fluidTank")));
|
||||
leftTank.setGas(GasStack.readFromNBT(itemStack.getTagCompound().getCompoundTag("leftTank")));
|
||||
rightTank.setGas(GasStack.readFromNBT(itemStack.getTagCompound().getCompoundTag("rightTank")));
|
||||
fluidTank.setFluid(FluidStack.loadFluidStackFromNBT(ItemDataUtils.getCompound(itemStack, "fluidTank")));
|
||||
leftTank.setGas(GasStack.readFromNBT(ItemDataUtils.getCompound(itemStack, "leftTank")));
|
||||
rightTank.setGas(GasStack.readFromNBT(ItemDataUtils.getCompound(itemStack, "rightTank")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -54,6 +54,7 @@ import mekanism.common.tile.component.TileComponentSecurity;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.StatUtils;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -311,14 +312,9 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
||||
|
||||
ItemStack returnStack = getMachineStack();
|
||||
|
||||
if(returnStack.getTagCompound() == null)
|
||||
{
|
||||
returnStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
upgradeComponent.write(returnStack.getTagCompound());
|
||||
upgradeComponent.write(ItemDataUtils.getDataMap(returnStack));
|
||||
upgradeComponent.setSupported(Upgrade.GAS, toSet.fuelEnergyUpgrades());
|
||||
upgradeComponent.read(inventory[2].getTagCompound());
|
||||
upgradeComponent.read(ItemDataUtils.getDataMap(inventory[2]));
|
||||
|
||||
inventory[2] = null;
|
||||
inventory[3] = returnStack;
|
||||
|
||||
@@ -27,6 +27,7 @@ import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.security.ISecurityTile;
|
||||
import mekanism.common.tile.component.TileComponentSecurity;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.TransporterUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -667,15 +668,15 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
|
||||
@Override
|
||||
public void writeSustainedData(ItemStack itemStack)
|
||||
{
|
||||
itemStack.getTagCompound().setBoolean("hasSorterConfig", true);
|
||||
ItemDataUtils.setBoolean(itemStack, "hasSorterConfig", true);
|
||||
|
||||
if(color != null)
|
||||
{
|
||||
itemStack.getTagCompound().setInteger("color", TransporterUtils.colors.indexOf(color));
|
||||
ItemDataUtils.setInt(itemStack, "color", TransporterUtils.colors.indexOf(color));
|
||||
}
|
||||
|
||||
itemStack.getTagCompound().setBoolean("autoEject", autoEject);
|
||||
itemStack.getTagCompound().setBoolean("roundRobin", roundRobin);
|
||||
ItemDataUtils.setBoolean(itemStack, "autoEject", autoEject);
|
||||
ItemDataUtils.setBoolean(itemStack, "roundRobin", roundRobin);
|
||||
|
||||
NBTTagList filterTags = new NBTTagList();
|
||||
|
||||
@@ -688,26 +689,26 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
|
||||
|
||||
if(filterTags.tagCount() != 0)
|
||||
{
|
||||
itemStack.getTagCompound().setTag("filters", filterTags);
|
||||
ItemDataUtils.setList(itemStack, "filters", filterTags);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSustainedData(ItemStack itemStack)
|
||||
{
|
||||
if(itemStack.getTagCompound().hasKey("hasSorterConfig"))
|
||||
if(ItemDataUtils.hasData(itemStack, "hasSorterConfig"))
|
||||
{
|
||||
if(itemStack.getTagCompound().hasKey("color"))
|
||||
if(ItemDataUtils.hasData(itemStack, "color"))
|
||||
{
|
||||
color = TransporterUtils.colors.get(itemStack.getTagCompound().getInteger("color"));
|
||||
color = TransporterUtils.colors.get(ItemDataUtils.getInt(itemStack, "color"));
|
||||
}
|
||||
|
||||
autoEject = itemStack.getTagCompound().getBoolean("autoEject");
|
||||
roundRobin = itemStack.getTagCompound().getBoolean("roundRobin");
|
||||
autoEject = ItemDataUtils.getBoolean(itemStack, "autoEject");
|
||||
roundRobin = ItemDataUtils.getBoolean(itemStack, "roundRobin");
|
||||
|
||||
if(itemStack.getTagCompound().hasKey("filters"))
|
||||
if(ItemDataUtils.hasData(itemStack, "filters"))
|
||||
{
|
||||
NBTTagList tagList = itemStack.getTagCompound().getTagList("filters", NBT.TAG_COMPOUND);
|
||||
NBTTagList tagList = ItemDataUtils.getList(itemStack, "filters");
|
||||
|
||||
for(int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
|
||||
@@ -20,6 +20,7 @@ import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.security.ISecurityTile;
|
||||
import mekanism.common.tile.component.TileComponentSecurity;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -363,7 +364,7 @@ public class TileEntityOredictionificator extends TileEntityContainerBlock imple
|
||||
@Override
|
||||
public void writeSustainedData(ItemStack itemStack)
|
||||
{
|
||||
itemStack.getTagCompound().setBoolean("hasOredictionificatorConfig", true);
|
||||
ItemDataUtils.setBoolean(itemStack, "hasOredictionificatorConfig", true);
|
||||
|
||||
NBTTagList filterTags = new NBTTagList();
|
||||
|
||||
@@ -376,18 +377,18 @@ public class TileEntityOredictionificator extends TileEntityContainerBlock imple
|
||||
|
||||
if(filterTags.tagCount() != 0)
|
||||
{
|
||||
itemStack.getTagCompound().setTag("filters", filterTags);
|
||||
ItemDataUtils.setList(itemStack, "filters", filterTags);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSustainedData(ItemStack itemStack)
|
||||
{
|
||||
if(itemStack.getTagCompound().hasKey("hasOredictionificatorConfig"))
|
||||
if(ItemDataUtils.hasData(itemStack, "hasOredictionificatorConfig"))
|
||||
{
|
||||
if(itemStack.getTagCompound().hasKey("filters"))
|
||||
if(ItemDataUtils.hasData(itemStack, "filters"))
|
||||
{
|
||||
NBTTagList tagList = itemStack.getTagCompound().getTagList("filters", NBT.TAG_COMPOUND);
|
||||
NBTTagList tagList = ItemDataUtils.getList(itemStack, "filters");
|
||||
|
||||
for(int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
|
||||
@@ -29,6 +29,7 @@ import mekanism.common.tile.component.TileComponentEjector;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -451,26 +452,26 @@ public class TileEntityPRC extends TileEntityBasicMachine<PressurizedInput, Pres
|
||||
{
|
||||
if(inputFluidTank.getFluid() != null)
|
||||
{
|
||||
itemStack.getTagCompound().setTag("inputFluidTank", inputFluidTank.getFluid().writeToNBT(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemStack, "inputFluidTank", inputFluidTank.getFluid().writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
if(inputGasTank.getGas() != null)
|
||||
{
|
||||
itemStack.getTagCompound().setTag("inputGasTank", inputGasTank.getGas().write(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemStack, "inputGasTank", inputGasTank.getGas().write(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
if(outputGasTank.getGas() != null)
|
||||
{
|
||||
itemStack.getTagCompound().setTag("outputGasTank", outputGasTank.getGas().write(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemStack, "outputGasTank", outputGasTank.getGas().write(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSustainedData(ItemStack itemStack)
|
||||
{
|
||||
inputFluidTank.setFluid(FluidStack.loadFluidStackFromNBT(itemStack.getTagCompound().getCompoundTag("inputFluidTank")));
|
||||
inputGasTank.setGas(GasStack.readFromNBT(itemStack.getTagCompound().getCompoundTag("inputGasTank")));
|
||||
outputGasTank.setGas(GasStack.readFromNBT(itemStack.getTagCompound().getCompoundTag("outputGasTank")));
|
||||
inputFluidTank.setFluid(FluidStack.loadFluidStackFromNBT(ItemDataUtils.getCompound(itemStack, "inputFluidTank")));
|
||||
inputGasTank.setGas(GasStack.readFromNBT(ItemDataUtils.getCompound(itemStack, "inputGasTank")));
|
||||
outputGasTank.setGas(GasStack.readFromNBT(ItemDataUtils.getCompound(itemStack, "outputGasTank")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,6 +31,7 @@ import mekanism.common.tile.component.TileComponentSecurity;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.FluidContainerUtils;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.PipeUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -456,20 +457,20 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp
|
||||
{
|
||||
if(fluidTank.getFluid() != null)
|
||||
{
|
||||
itemStack.getTagCompound().setTag("fluidTank", fluidTank.getFluid().writeToNBT(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemStack, "fluidTank", fluidTank.getFluid().writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
if(gasTank.getGas() != null)
|
||||
{
|
||||
itemStack.getTagCompound().setTag("gasTank", gasTank.getGas().write(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemStack, "gasTank", gasTank.getGas().write(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSustainedData(ItemStack itemStack)
|
||||
{
|
||||
fluidTank.setFluid(FluidStack.loadFluidStackFromNBT(itemStack.getTagCompound().getCompoundTag("fluidTank")));
|
||||
gasTank.setGas(GasStack.readFromNBT(itemStack.getTagCompound().getCompoundTag("gasTank")));
|
||||
fluidTank.setFluid(FluidStack.loadFluidStackFromNBT(ItemDataUtils.getCompound(itemStack, "fluidTank")));
|
||||
gasTank.setGas(GasStack.readFromNBT(ItemDataUtils.getCompound(itemStack, "gasTank")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,8 +5,8 @@ import io.netty.buffer.ByteBuf;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.api.MekanismConfig.general;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.api.gas.GasStack;
|
||||
@@ -26,6 +26,7 @@ import mekanism.common.recipe.inputs.GasInput;
|
||||
import mekanism.common.recipe.machines.SolarNeutronRecipe;
|
||||
import mekanism.common.security.ISecurityTile;
|
||||
import mekanism.common.tile.component.TileComponentSecurity;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -345,20 +346,20 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im
|
||||
{
|
||||
if(inputTank.getGas() != null)
|
||||
{
|
||||
itemStack.getTagCompound().setTag("inputTank", inputTank.getGas().write(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemStack, "inputTank", inputTank.getGas().write(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
if(outputTank.getGas() != null)
|
||||
{
|
||||
itemStack.getTagCompound().setTag("outputTank", outputTank.getGas().write(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemStack, "outputTank", outputTank.getGas().write(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSustainedData(ItemStack itemStack)
|
||||
{
|
||||
inputTank.setGas(GasStack.readFromNBT(itemStack.getTagCompound().getCompoundTag("inputTank")));
|
||||
outputTank.setGas(GasStack.readFromNBT(itemStack.getTagCompound().getCompoundTag("outputTank")));
|
||||
inputTank.setGas(GasStack.readFromNBT(ItemDataUtils.getCompound(itemStack, "inputTank")));
|
||||
outputTank.setGas(GasStack.readFromNBT(ItemDataUtils.getCompound(itemStack, "outputTank")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -208,8 +208,8 @@ public class TileComponentConfig implements ITileComponent
|
||||
{
|
||||
for(TransmissionType type : transmissions)
|
||||
{
|
||||
nbtTags.setByteArray("config" + type, sideConfigs.get(type.ordinal()));
|
||||
nbtTags.setBoolean("ejecting" + type, ejecting.get(type.ordinal()));
|
||||
nbtTags.setByteArray("config" + type.ordinal(), sideConfigs.get(type.ordinal()));
|
||||
nbtTags.setBoolean("ejecting" + type.ordinal(), ejecting.get(type.ordinal()));
|
||||
}
|
||||
|
||||
nbtTags.setBoolean("sideDataStored", true);
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
package mekanism.common.util;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
|
||||
public final class ItemDataUtils
|
||||
{
|
||||
public static final String DATA_ID = "mekData";
|
||||
|
||||
public static NBTTagCompound getDataMap(ItemStack stack)
|
||||
{
|
||||
initStack(stack);
|
||||
|
||||
return stack.getTagCompound().getCompoundTag(DATA_ID);
|
||||
}
|
||||
|
||||
public static boolean hasData(ItemStack stack, String key)
|
||||
{
|
||||
initStack(stack);
|
||||
|
||||
return getDataMap(stack).hasKey(key);
|
||||
}
|
||||
|
||||
public static void removeData(ItemStack stack, String key)
|
||||
{
|
||||
initStack(stack);
|
||||
|
||||
getDataMap(stack).removeTag(key);
|
||||
}
|
||||
|
||||
public static int getInt(ItemStack stack, String key)
|
||||
{
|
||||
initStack(stack);
|
||||
|
||||
return getDataMap(stack).getInteger(key);
|
||||
}
|
||||
|
||||
public static boolean getBoolean(ItemStack stack, String key)
|
||||
{
|
||||
initStack(stack);
|
||||
|
||||
return getDataMap(stack).getBoolean(key);
|
||||
}
|
||||
|
||||
public static double getDouble(ItemStack stack, String key)
|
||||
{
|
||||
initStack(stack);
|
||||
|
||||
return getDataMap(stack).getDouble(key);
|
||||
}
|
||||
|
||||
public static String getString(ItemStack stack, String key)
|
||||
{
|
||||
initStack(stack);
|
||||
|
||||
return getDataMap(stack).getString(key);
|
||||
}
|
||||
|
||||
public static NBTTagCompound getCompound(ItemStack stack, String key)
|
||||
{
|
||||
initStack(stack);
|
||||
|
||||
return getDataMap(stack).getCompoundTag(key);
|
||||
}
|
||||
|
||||
public static NBTTagList getList(ItemStack stack, String key)
|
||||
{
|
||||
initStack(stack);
|
||||
|
||||
return getDataMap(stack).getTagList(key, NBT.TAG_COMPOUND);
|
||||
}
|
||||
|
||||
public static void setInt(ItemStack stack, String key, int i)
|
||||
{
|
||||
initStack(stack);
|
||||
|
||||
getDataMap(stack).setInteger(key, i);
|
||||
}
|
||||
|
||||
public static void setBoolean(ItemStack stack, String key, boolean b)
|
||||
{
|
||||
initStack(stack);
|
||||
|
||||
getDataMap(stack).setBoolean(key, b);
|
||||
}
|
||||
|
||||
public static void setDouble(ItemStack stack, String key, double d)
|
||||
{
|
||||
initStack(stack);
|
||||
|
||||
getDataMap(stack).setDouble(key, d);
|
||||
}
|
||||
|
||||
public static void setString(ItemStack stack, String key, String s)
|
||||
{
|
||||
initStack(stack);
|
||||
|
||||
getDataMap(stack).setString(key, s);
|
||||
}
|
||||
|
||||
public static void setCompound(ItemStack stack, String key, NBTTagCompound tag)
|
||||
{
|
||||
initStack(stack);
|
||||
|
||||
getDataMap(stack).setTag(key, tag);
|
||||
}
|
||||
|
||||
public static void setList(ItemStack stack, String key, NBTTagList tag)
|
||||
{
|
||||
initStack(stack);
|
||||
|
||||
getDataMap(stack).setTag(key, tag);
|
||||
}
|
||||
|
||||
private static void initStack(ItemStack stack)
|
||||
{
|
||||
if(stack.getTagCompound() == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if(!stack.getTagCompound().hasKey(DATA_ID))
|
||||
{
|
||||
stack.getTagCompound().setTag(DATA_ID, new NBTTagCompound());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import net.minecraftforge.fml.common.ModContainer;
|
||||
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
|
||||
public class ItemRegistryUtils
|
||||
public final class ItemRegistryUtils
|
||||
{
|
||||
private static final Map<String, String> modIDMap = new HashMap<String, String>();
|
||||
|
||||
|
||||
@@ -703,7 +703,7 @@ public final class MekanismUtils
|
||||
*/
|
||||
public static double getMaxEnergy(ItemStack itemStack, double def)
|
||||
{
|
||||
Map<Upgrade, Integer> upgrades = Upgrade.buildMap(itemStack.getTagCompound());
|
||||
Map<Upgrade, Integer> upgrades = Upgrade.buildMap(ItemDataUtils.getDataMap(itemStack));
|
||||
float numUpgrades = upgrades.get(Upgrade.ENERGY) == null ? 0 : (float)upgrades.get(Upgrade.ENERGY);
|
||||
return def * Math.pow(general.maxUpgradeMultiplier, numUpgrades/(float)Upgrade.ENERGY.getMax());
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ public class RecipeUtils
|
||||
|
||||
if(itemstack != null && BlockStateMachine.MachineType.get(itemstack) != null && BlockStateMachine.MachineType.get(itemstack).supportsUpgrades)
|
||||
{
|
||||
Map<Upgrade, Integer> stackMap = Upgrade.buildMap(itemstack.getTagCompound());
|
||||
Map<Upgrade, Integer> stackMap = Upgrade.buildMap(ItemDataUtils.getDataMap(itemstack));
|
||||
|
||||
for(Map.Entry<Upgrade, Integer> entry : stackMap.entrySet())
|
||||
{
|
||||
@@ -251,12 +251,7 @@ public class RecipeUtils
|
||||
}
|
||||
}
|
||||
|
||||
if(toReturn.getTagCompound() == null)
|
||||
{
|
||||
toReturn.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
Upgrade.saveMap(upgrades, toReturn.getTagCompound());
|
||||
Upgrade.saveMap(upgrades, ItemDataUtils.getDataMap(toReturn));
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package mekanism.generators.client.jei;
|
||||
|
||||
import mekanism.client.jei.MekanismJEI;
|
||||
import mekanism.generators.common.GeneratorsBlocks;
|
||||
import mezz.jei.api.IItemRegistry;
|
||||
import mezz.jei.api.IJeiHelpers;
|
||||
import mezz.jei.api.IJeiRuntime;
|
||||
import mezz.jei.api.IModPlugin;
|
||||
import mezz.jei.api.IModRegistry;
|
||||
import mezz.jei.api.IRecipeRegistry;
|
||||
import mezz.jei.api.JEIPlugin;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
@JEIPlugin
|
||||
public class GeneratorsJEI implements IModPlugin
|
||||
{
|
||||
@Override
|
||||
public void register(IModRegistry registry)
|
||||
{
|
||||
registry.getJeiHelpers().getNbtIgnoreList().ignoreNbtTagNames(Item.getItemFromBlock(GeneratorsBlocks.Generator), MekanismJEI.UNUSED_TAGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemRegistryAvailable(IItemRegistry registry) {}
|
||||
|
||||
@Override
|
||||
public void onJeiHelpersAvailable(IJeiHelpers helpers) {}
|
||||
|
||||
@Override
|
||||
public void onRecipeRegistryAvailable(IRecipeRegistry registry) {}
|
||||
|
||||
@Override
|
||||
public void onRuntimeAvailable(IJeiRuntime runtime) {}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import mekanism.common.security.ISecurityTile;
|
||||
import mekanism.common.security.ISecurityTile.SecurityMode;
|
||||
import mekanism.common.tile.TileEntityBasicBlock;
|
||||
import mekanism.common.tile.TileEntityElectricBlock;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.SecurityUtils;
|
||||
@@ -303,14 +304,7 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp
|
||||
{
|
||||
if(data[0] instanceof ItemStack)
|
||||
{
|
||||
ItemStack itemStack = (ItemStack)data[0];
|
||||
|
||||
if(itemStack.getTagCompound() == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemStack.getTagCompound().setTag("Items", nbtTags);
|
||||
ItemDataUtils.setList((ItemStack)data[0], "Items", nbtTags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,14 +313,7 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp
|
||||
{
|
||||
if(data[0] instanceof ItemStack)
|
||||
{
|
||||
ItemStack itemStack = (ItemStack)data[0];
|
||||
|
||||
if(itemStack.getTagCompound() == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return itemStack.getTagCompound().getTagList("Items", 10);
|
||||
return ItemDataUtils.getList((ItemStack)data[0], "Items");
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -335,21 +322,17 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp
|
||||
@Override
|
||||
public void setFluidStack(FluidStack fluidStack, Object... data)
|
||||
{
|
||||
if(fluidStack == null || fluidStack.amount == 0 || fluidStack.getFluid() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(data[0] instanceof ItemStack)
|
||||
{
|
||||
ItemStack itemStack = (ItemStack)data[0];
|
||||
|
||||
if(itemStack.getTagCompound() == null)
|
||||
|
||||
if(fluidStack == null || fluidStack.amount == 0 || fluidStack.getFluid() == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
ItemDataUtils.removeData(itemStack, "fluidTank");
|
||||
}
|
||||
else {
|
||||
ItemDataUtils.setCompound(itemStack, "fluidTank", fluidStack.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
itemStack.getTagCompound().setTag("fluidTank", fluidStack.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,15 +343,12 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp
|
||||
{
|
||||
ItemStack itemStack = (ItemStack)data[0];
|
||||
|
||||
if(itemStack.getTagCompound() == null)
|
||||
if(!ItemDataUtils.hasData(itemStack, "fluidTank"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if(itemStack.getTagCompound().hasKey("fluidTank"))
|
||||
{
|
||||
return FluidStack.loadFluidStackFromNBT(itemStack.getTagCompound().getCompoundTag("fluidTank"));
|
||||
}
|
||||
return FluidStack.loadFluidStackFromNBT(ItemDataUtils.getCompound(itemStack, "fluidTank"));
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -383,24 +363,13 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp
|
||||
@Override
|
||||
public double getEnergy(ItemStack itemStack)
|
||||
{
|
||||
if(itemStack.getTagCompound() == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return itemStack.getTagCompound().getDouble("electricity");
|
||||
return ItemDataUtils.getDouble(itemStack, "energyStored");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergy(ItemStack itemStack, double amount)
|
||||
{
|
||||
if(itemStack.getTagCompound() == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
double electricityStored = Math.max(Math.min(amount, getMaxEnergy(itemStack)), 0);
|
||||
itemStack.getTagCompound().setDouble("electricity", electricityStored);
|
||||
ItemDataUtils.setDouble(itemStack, "energyStored", Math.max(Math.min(amount, getMaxEnergy(itemStack)), 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -487,9 +456,9 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp
|
||||
@Override
|
||||
public String getOwner(ItemStack stack)
|
||||
{
|
||||
if(stack.getTagCompound() != null && stack.getTagCompound().hasKey("owner"))
|
||||
if(ItemDataUtils.hasData(stack, "owner"))
|
||||
{
|
||||
return stack.getTagCompound().getString("owner");
|
||||
return ItemDataUtils.getString(stack, "owner");
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -498,40 +467,25 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp
|
||||
@Override
|
||||
public void setOwner(ItemStack stack, String owner)
|
||||
{
|
||||
if(stack.getTagCompound() == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if(owner == null || owner.isEmpty())
|
||||
{
|
||||
stack.getTagCompound().removeTag("owner");
|
||||
ItemDataUtils.removeData(stack, "owner");
|
||||
return;
|
||||
}
|
||||
|
||||
stack.getTagCompound().setString("owner", owner);
|
||||
ItemDataUtils.setString(stack, "owner", owner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecurityMode getSecurity(ItemStack stack)
|
||||
{
|
||||
if(stack.getTagCompound() == null)
|
||||
{
|
||||
return SecurityMode.PUBLIC;
|
||||
}
|
||||
|
||||
return SecurityMode.values()[stack.getTagCompound().getInteger("security")];
|
||||
return SecurityMode.values()[ItemDataUtils.getInt(stack, "security")];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecurity(ItemStack stack, SecurityMode mode)
|
||||
{
|
||||
if(stack.getTagCompound() == null)
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
stack.getTagCompound().setInteger("security", mode.ordinal());
|
||||
ItemDataUtils.setInt(stack, "security", mode.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,6 +8,7 @@ import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.common.item.ItemMekanism;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -103,17 +104,6 @@ public class ItemHohlraum extends ItemMekanism implements IGasItem
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GasStack getGas(ItemStack itemstack)
|
||||
{
|
||||
if(itemstack.getTagCompound() == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return GasStack.readFromNBT(itemstack.getTagCompound().getCompoundTag("stored"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDurabilityBar(ItemStack stack)
|
||||
{
|
||||
@@ -126,23 +116,24 @@ public class ItemHohlraum extends ItemMekanism implements IGasItem
|
||||
return 1D-((getGas(stack) != null ? (double)getGas(stack).amount : 0D)/(double)getMaxGas(stack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public GasStack getGas(ItemStack itemstack)
|
||||
{
|
||||
return GasStack.readFromNBT(ItemDataUtils.getCompound(itemstack, "stored"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGas(ItemStack itemstack, GasStack stack)
|
||||
{
|
||||
if(itemstack.getTagCompound() == null)
|
||||
{
|
||||
itemstack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if(stack == null || stack.amount == 0)
|
||||
{
|
||||
itemstack.getTagCompound().removeTag("stored");
|
||||
ItemDataUtils.removeData(itemstack, "stored");
|
||||
}
|
||||
else {
|
||||
int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack)));
|
||||
GasStack gasStack = new GasStack(stack.getGas(), amount);
|
||||
|
||||
itemstack.getTagCompound().setTag("stored", gasStack.write(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemstack, "stored", gasStack.write(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import mekanism.common.FluidSlot;
|
||||
import mekanism.common.MekanismItems;
|
||||
import mekanism.common.base.ISustainedData;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -309,12 +310,12 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui
|
||||
@Override
|
||||
public void writeSustainedData(ItemStack itemStack)
|
||||
{
|
||||
itemStack.getTagCompound().setInteger("fluidStored", bioFuelSlot.fluidStored);
|
||||
ItemDataUtils.setInt(itemStack, "fluidStored", bioFuelSlot.fluidStored);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSustainedData(ItemStack itemStack)
|
||||
{
|
||||
bioFuelSlot.setFluid(itemStack.getTagCompound().getInteger("fluidStored"));
|
||||
bioFuelSlot.setFluid(ItemDataUtils.getInt(itemStack, "fluidStored"));
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import mekanism.common.FuelHandler;
|
||||
import mekanism.common.FuelHandler.FuelGas;
|
||||
import mekanism.common.base.ISustainedData;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -360,16 +361,16 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH
|
||||
{
|
||||
if(fuelTank != null)
|
||||
{
|
||||
itemStack.getTagCompound().setTag("fuelTank", fuelTank.write(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemStack, "fuelTank", fuelTank.write(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSustainedData(ItemStack itemStack)
|
||||
{
|
||||
if(itemStack.getTagCompound().hasKey("fuelTank"))
|
||||
if(ItemDataUtils.hasData(itemStack, "fuelTank"))
|
||||
{
|
||||
fuelTank.read(itemStack.getTagCompound().getCompoundTag("fuelTank"));
|
||||
fuelTank.read(ItemDataUtils.getCompound(itemStack, "fuelTank"));
|
||||
|
||||
boolean isTankEmpty = (fuelTank.getGas() == null);
|
||||
//Update energy output based on any existing fuel in tank
|
||||
|
||||
@@ -12,6 +12,7 @@ import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.FluidContainerUtils;
|
||||
import mekanism.common.util.FluidContainerUtils.FluidChecker;
|
||||
import mekanism.common.util.HeatUtils;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.PipeUtils;
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -387,14 +388,14 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu
|
||||
{
|
||||
if(lavaTank.getFluid() != null)
|
||||
{
|
||||
itemStack.getTagCompound().setTag("lavaTank", lavaTank.getFluid().writeToNBT(new NBTTagCompound()));
|
||||
ItemDataUtils.setCompound(itemStack, "lavaTank", lavaTank.getFluid().writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSustainedData(ItemStack itemStack)
|
||||
{
|
||||
lavaTank.setFluid(FluidStack.loadFluidStackFromNBT(itemStack.getTagCompound().getCompoundTag("lavaTank")));
|
||||
lavaTank.setFluid(FluidStack.loadFluidStackFromNBT(ItemDataUtils.getCompound(itemStack, "lavaTank")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user