List of usage examples for net.minecraftforge.fluids FluidStack FluidStack
public FluidStack(Fluid fluid, int amount, CompoundNBT nbt)
From source file:buildcraft.core.network.serializers.SerializerFluidStack.java
License:Minecraft Mod Public
@Override public Object read(ByteBuf data, Object o, SerializationContext context) { if (!data.readBoolean()) { return null; } else {//from w ww .jav a 2 s .c o m int id = data.readShort(); int amount = data.readerIndex(); NBTTagCompound nbt = null; if (data.readBoolean()) { nbt = Utils.readNBT(data); return new FluidStack(id, amount, nbt); } else { return new FluidStack(id, amount); } } }
From source file:buildcraftAdditions.utils.fluids.Tank.java
License:GNU General Public License
@Override public void readFromByteBuff(ByteBuf buf) { int id = buf.readInt(); int amount = buf.readInt(); NBTTagCompound tag = ByteBufUtils.readTag(buf); if (id < 0 || amount <= 0) setFluid(null);/*from w ww . j a v a 2s.c o m*/ else setFluid(new FluidStack(id, amount, tag)); }
From source file:com.buuz135.industrial.fluid.IFOreFluid.java
License:Open Source License
public FluidStack getWithOre(String ore, int amount) { NBTTagCompound compound = new NBTTagCompound(); compound.setString("Ore", ore); return new FluidStack(this, amount, compound); }
From source file:com.buuz135.industrial.tile.block.BlackHoleTankBlock.java
License:Open Source License
@Override public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {//from w ww.ja v a 2 s .c om super.onBlockPlacedBy(world, pos, state, placer, stack); if (stack.hasTagCompound() && world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof BlackHoleTankTile && FluidRegistry.isFluidRegistered(stack.getTagCompound().getString("FluidName"))) { BlackHoleTankTile tile = (BlackHoleTankTile) world.getTileEntity(pos); tile.getTank() .fill(new FluidStack(FluidRegistry.getFluid(stack.getTagCompound().getString("FluidName")), stack.getTagCompound().getInteger("Amount"), stack.getTagCompound().hasKey("Tag") && !stack.getTagCompound().getTag("Tag").isEmpty() ? stack.getTagCompound().getCompoundTag("Tag") : null), true); } }
From source file:com.elytradev.thermionics.ThermionicsRecipes.java
License:Open Source License
@SubscribeEvent public static void onRegisterRecipes(RegistryEvent.Register<IRecipe> event) { //LOG.info("Registering recipes"); IForgeRegistry<IRecipe> r = event.getRegistry(); recipe(r,//from w ww .j a va 2s . c o m new ShapedOreRecipe(new ResourceLocation("thermionics:ingredients"), new ItemStack(ThermionicsItems.INGREDIENT, 1, EnumIngredient.GEAR_BRASS.ordinal()), " b ", "bib", " b ", 'b', "ingotBrass", 'i', "ingotIron")); for (EnumServerDyeColor dye : EnumServerDyeColor.values()) { ItemStack result = new ItemStack(ThermionicsItems.FABRIC_SQUARE); NBTTagCompound tag = new NBTTagCompound(); tag.setInteger("Color", dye.getColorValue()); result.setTagCompound(tag); ShapelessRecipes recipe = new ShapelessRecipes("thermionics:ingredientDye", result, NonNullList.from(null, Ingredient.fromItem(ThermionicsItems.FABRIC_SQUARE), Ingredient.fromStacks(new ItemStack(Items.DYE, 1, dye.getDyeDamage())))); recipe(r, recipe); } recipe(r, new ShapedOreRecipe(new ResourceLocation("thermionics:blocks"), new ItemStack(ThermionicsBlocks.CABLE_RF, 8), "wlw", 'w', new ItemStack(Blocks.WOOL, 1, OreDictionary.WILDCARD_VALUE), 'l', "ingotLead")); recipe(r, new ShapedOreRecipe(new ResourceLocation("thermionics:blocks"), new ItemStack(ThermionicsBlocks.SCAFFOLD_BASIC, 4), "x x", " x ", "x x", 'x', "ingotIron")); recipe(r, new ShapedOreRecipe(new ResourceLocation("thermionics:blocks"), new ItemStack(ThermionicsBlocks.FIREBOX, 1), "xxx", "x x", "xxx", 'x', "ingotIron")); recipe(r, new ShapedOreRecipe(new ResourceLocation("thermionics:blocks"), new ItemStack(ThermionicsBlocks.OVEN, 1), "xxx", "x x", "xcx", 'x', "ingotIron", 'c', "ingotCopper")); recipe(r, new ShapedOreRecipe(new ResourceLocation("thermionics:blocks"), new ItemStack(ThermionicsBlocks.MASH_TUN, 1), "s s", "s s", "scs", 's', "cobblestone", 'c', "ingotCopper")); recipe(r, new ShapedOreRecipe(new ResourceLocation("thermionics:blocks"), new ItemStack(ThermionicsBlocks.POT_STILL, 1), "bbb", "b b", "bcb", 'b', "ingotBrass", 'c', "ingotCopper")); recipe(r, new ShapedOreRecipe(new ResourceLocation("thermionics:blocks"), new ItemStack(ThermionicsBlocks.MOTOR_CONVECTION), "IcI", "ctc", "IsI", 'I', "blockIron", 'c', "ingotCopper", 't', new ItemStack(Blocks.REDSTONE_TORCH), 's', "ingotSilver")); recipe(r, new ShapedOreRecipe(new ResourceLocation("thermionics:blocks"), new ItemStack(ThermionicsBlocks.GEARBOX), "igi", "g g", "igi", 'g', "gearBrass", 'i', "ingotIron")); recipe(r, new ShapedOreRecipe(new ResourceLocation("thermionics:blocks"), new ItemStack(ThermionicsBlocks.SERGER), "iii", " ig", "bbi", 'i', "ingotIron", 'b', "ingotBrass", 'g', "gearBrass")); recipe(r, new ShapedOreRecipe(new ResourceLocation("thermionics:blocks"), new ItemStack(ThermionicsBlocks.HAMMER_MILL), "IiI", "ifi", "IsI", 'I', "blockIron", 'i', "ingotIron", 's', "ingotSilver", 'f', new ItemStack(Items.FLINT))); recipe(r, new ShapedOreRecipe(new ResourceLocation("thermionics:blocks"), new ItemStack(ThermionicsBlocks.BATTERY_LEAD, 1), " c ", "pLp", " r ", 'L', "blockLead", 'c', "ingotCopper", 'r', new ItemStack(Items.REDSTONE), 'p', new ItemStack(Items.PAPER))); recipe(r, new ShapedOreRecipe(new ResourceLocation("thermionics:blocks"), new ItemStack(ThermionicsBlocks.AXLE_WOOD, 4), "w", "w", "w", 'w', new ItemStack(Blocks.PLANKS))); recipe(r, new ShapedOreRecipe(new ResourceLocation("thermionics:blocks"), new ItemStack(ThermionicsBlocks.AXLE_IRON, 4), "i", "i", "i", 'i', "ingotIron")); recipe(r, new ShapedOreRecipe(new ResourceLocation("thermionics:blocks"), new ItemStack(ThermionicsBlocks.CABLE_HEAT, 4), "c", "c", "c", 'c', "ingotCopper")); recipe(r, new ShapedOreRecipe(new ResourceLocation("thermionics:hammers"), ItemHammer.createTool("ingotIron"), "I", "s", "s", 'I', "blockIron", 's', "stickWood")); recipe(r, new ShapelessOreRecipe(new ResourceLocation("thermionics:spiritbottle"), new ItemStack(ThermionicsItems.EMPTY_SPIRIT_BOTTLE), new ItemStack(Items.GLASS_BOTTLE))); recipe(r, new ShapelessOreRecipe(new ResourceLocation("thermionics:spiritbottle"), new ItemStack(Items.GLASS_BOTTLE), new ItemStack(ThermionicsItems.EMPTY_SPIRIT_BOTTLE))); //NEW TOOL RECIPES /* recipe(r, new ShapedOreRecipe(new ResourceLocation("thermionics:hammers"), ItemHammer.createTool("ingotGold"), "I", "s", "s", 'I', "blockGold", 's', "stickWood" )); recipe(r, new ShapedOreRecipe(new ResourceLocation("thermionics:hammers"), ItemHammer.createTool("gemDiamond"), "I", "s", "s", 'I', "blockDiamond", 's', "stickWood" )); recipe(r, new ShapedOreRecipe(new ResourceLocation("thermionics:hammers"), ItemHammer.createTool("ingotCopper"), "I", "s", "s", 'I', "blockCopper", 's', "stickWood" )); recipe(r, new ShapedOreRecipe(new ResourceLocation("thermionics:hammers"), ItemHammer.createTool("ingotLead"), "I", "s", "s", 'I', "blockLead", 's', "stickWood" )); recipe(r, new ShapedOreRecipe(new ResourceLocation("thermionics:hammers"), ItemHammer.createTool("ingotInvar"), "I", "s", "s", 'I', "blockInvar", 's', "stickWood" ));*/ //LEGACY TOOL RECIPES recipe(r, new ShapedOreRecipe(new ResourceLocation("thermionics:hammers"), new ItemStack(ThermionicsItems.HAMMER_GOLD, 1), "I", "s", "s", 'I', "blockGold", 's', "stickWood")); recipe(r, new ShapedOreRecipe(new ResourceLocation("thermionics:hammers"), new ItemStack(ThermionicsItems.HAMMER_DIAMOND, 1), "I", "s", "s", 'I', "blockDiamond", 's', "stickWood")); recipe(r, new ShapedOreRecipe(new ResourceLocation("thermionics:hammers"), new ItemStack(ThermionicsItems.HAMMER_COPPER, 1), "I", "s", "s", 'I', "blockCopper", 's', "stickWood")); recipe(r, new ShapedOreRecipe(new ResourceLocation("thermionics:hammers"), new ItemStack(ThermionicsItems.HAMMER_LEAD, 1), "I", "s", "s", 'I', "blockLead", 's', "stickWood")); recipe(r, new ShapedOreRecipe(new ResourceLocation("thermionics:hammers"), new ItemStack(ThermionicsItems.HAMMER_INVAR, 1), "I", "s", "s", 'I', "blockInvar", 's', "stickWood")); //Allomancy recipe(r, new ShapelessRecipes("thermionics:items", new ItemStack(ThermionicsItems.MISTCLOAK, 1, 1), //Full mistcloak with allomantic invisibility NonNullList.from(null, Ingredient.fromStacks(new ItemStack(ThermionicsItems.MISTCLOAK, 1, 0)), //Tasselcloak with no special powers + Ingredient.fromStacks(new ItemStack(ThermionicsItems.ALLOMANTIC_POWDER, 1, EnumAllomanticPowder.COPPER.ordinal()))//Allomantic copper ))); GameRegistry.addSmelting(Blocks.GRAVEL, new ItemStack(ThermionicsBlocks.ROAD), 0); craftingCircle(r, ThermionicsBlocks.ROAD); recipe(r, new ShapedOreRecipe(new ResourceLocation("thermionics:compression"), new ItemStack(ThermionicsBlocks.ROAD_COMPRESSED), "xxx", "xgx", "xxx", 'x', new ItemStack(ThermionicsBlocks.ROAD, 1, OreDictionary.WILDCARD_VALUE), 'g', "ingotGold")); //Create a second list for compressed road and make the crafting cycle again craftingCircle(r, ThermionicsBlocks.ROAD_COMPRESSED); //Ore->2xDust, Ingot->1xDust millRecipes("Iron"); millRecipes("Gold"); millRecipes("Copper"); millRecipes("Tin"); millRecipes("Silver"); millRecipes("Lead"); millRecipes("Nickel"); millRecipes("Zinc"); millRecipes("Platinum"); millRecipes("Mithril"); millRecipes("Electrum"); millRecipes("Brass"); millRecipes("Bronze"); millRecipes("Invar"); millRecipes("Steel"); millRecipes("Uranium"); millRecipes("Cobalt"); millRecipes("Ardite"); HammerMillRecipes.registerRecipe(new RotaryOreRecipe("oreCoal", new ItemStack(Items.COAL, 3), 8f, 20f)); HammerMillRecipes .registerRecipe(new RotaryOreRecipe("oreRedstone", new ItemStack(Items.REDSTONE, 6), 8f, 20f)); HammerMillRecipes .registerRecipe(new RotaryOreRecipe("oreDiamond", new ItemStack(Items.DIAMOND, 2), 10f, 20f)); HammerMillRecipes .registerRecipe(new RotaryOreRecipe("oreEmerald", new ItemStack(Items.EMERALD, 2), 8f, 20f)); HammerMillRecipes.registerRecipe(new RotaryOreRecipe("oreLapis", new ItemStack(Items.DYE, 10, 4), 8f, 20f)); HammerMillRecipes.registerRecipe( new RotaryRecipe(new ItemStack(Blocks.GRAVEL), new ItemStack(Items.FLINT, 2), 2f, 20f)); HammerMillRecipes.registerRecipe( new RotaryRecipe(new ItemStack(Blocks.SANDSTONE), new ItemStack(Blocks.SAND, 4), 8f, 20f)); HammerMillRecipes.registerRecipe( new RotaryRecipe(new ItemStack(Blocks.COBBLESTONE), new ItemStack(Blocks.SAND, 1), 8f, 20f)); for (EnumDyeSource dyeSource : EnumDyeSource.values()) { HammerMillRecipes.registerRecipe( new RotaryRecipe(dyeSource.getExemplar(), dyeSource.createOutputStack(), 2f, 20f)); } ItemIngredient potato = ItemIngredient.of(Items.POTATO); ItemIngredient leather = ItemIngredient.of("leather"); ItemIngredient ingotIron = ItemIngredient.of("ingotIron"); ItemIngredient ingotGold = ItemIngredient.of("ingotGold"); ItemIngredient diamond = ItemIngredient.of("gemDiamond"); ItemIngredient string = ItemIngredient.of(Items.STRING); ItemIngredient ribbon = ItemIngredient .of(new ItemStack(ThermionicsItems.INGREDIENT, 1, EnumIngredient.RIBBON.ordinal())); ItemIngredient fabric = ItemIngredient.of(ThermionicsItems.FABRIC_SQUARE); ItemIngredient anyFabric = new WildcardNBTIngredient(ThermionicsItems.FABRIC_SQUARE); ItemIngredient anyScarf = new WildcardNBTIngredient(ThermionicsItems.SCARF); SergerRecipe saddleRecipe = new SergerRecipe(new ShapedInventoryRecipe(new ItemStack(Items.SADDLE), //Output 3, 3, //3x3 grid 3, 2, //3x2 recipe false, //recipe is already horizontally symmetrical leather, leather, leather, ingotIron, null, ingotIron), 10, //Leather requires a steeper torque than the default 8 for cloth 30 //Done after 30 complete axle rotations ); MachineRecipes.register(saddleRecipe); SergerRecipe diamondBardingRecipe = new SergerRecipe( new ShapedInventoryRecipe(new ItemStack(Items.DIAMOND_HORSE_ARMOR), 3, 3, //3x3 grid 3, 3, //3x3 recipe true, //or flipped null, null, diamond, diamond, diamond, diamond, diamond, diamond, diamond), 15, //Lots of torque for hard materials 30 //Done after 30 complete axle rotations ); MachineRecipes.register(diamondBardingRecipe); SergerRecipe goldBardingRecipe = new SergerRecipe( new ShapedInventoryRecipe(new ItemStack(Items.GOLDEN_HORSE_ARMOR), 3, 3, //3x3 grid 3, 3, //3x3 recipe true, //or flipped null, null, ingotGold, ingotGold, ingotGold, ingotGold, ingotGold, ingotGold, ingotGold), 6, //Nothing to it 30 //Done after 30 complete axle rotations ); MachineRecipes.register(goldBardingRecipe); SergerRecipe ironBardingRecipe = new SergerRecipe( new ShapedInventoryRecipe(new ItemStack(Items.IRON_HORSE_ARMOR), 3, 3, //3x3 grid 3, 3, //3x3 recipe true, //or flipped null, null, ingotIron, ingotIron, ingotIron, ingotIron, ingotIron, ingotIron, ingotIron), 15, //Lots of torque for hard materials 30 //Done after 30 complete axle rotations ); MachineRecipes.register(ironBardingRecipe); SergerRecipe ribbonRecipe = new SergerRecipe( new ShapedInventoryRecipe( new ItemStack(ThermionicsItems.INGREDIENT, 1, EnumIngredient.RIBBON.ordinal()), 3, 3, //3x3 serger grid 3, 1, //3x1 recipe false, //symmetrical string, string, string), 6, //soft fabric crafting 10 //*fast* ); MachineRecipes.register(ribbonRecipe); SergerRecipe fabricRecipe = new SergerRecipe( new ShapedInventoryRecipe(new ItemStack(ThermionicsItems.FABRIC_SQUARE, 1), 3, 3, //3x3 serger grid 2, 2, //2x2 recipe false, //symmetrical string, string, string, string), 6, //soft fabric crafting 10 //*fast* ); MachineRecipes.register(fabricRecipe); SergerRecipe scarfRecipe = new SergerRecipe( new ShapedInventoryRecipe(new ItemStack(ThermionicsItems.SCARF, 1), 3, 3, //3x3 serger grid 3, 1, //3x1 recipe false, //symmetrical ribbon, anyFabric, ribbon), 6, //soft fabric crafting 10 //*fast* ); MachineRecipes.register(scarfRecipe); SergerRecipe leftScarfRecipe = new ScarfConstructRecipe( new ShapedInventoryRecipe(new ItemStack(ThermionicsItems.SCARF, 1), 3, 3, //3x3 serger grid 3, 1, //3x1 recipe false, //intentionally asymmetrical anyFabric, string, anyScarf), 6, //soft fabric crafting 10, //*fast* true); MachineRecipes.register(leftScarfRecipe); SergerRecipe rightScarfRecipe = new ScarfConstructRecipe( new ShapedInventoryRecipe(new ItemStack(ThermionicsItems.SCARF, 1), 3, 3, //3x3 serger grid 3, 1, //3x1 recipe false, //intentionally asymmetrical anyScarf, string, anyFabric), 6, //soft fabric crafting 10, //*fast* false); MachineRecipes.register(rightScarfRecipe); SergerRecipe tasselcloakRecipe = new SergerRecipe( new ShapedInventoryRecipe(new ItemStack(ThermionicsItems.MISTCLOAK, 1), 3, 3, //3x3 serger grid 3, 3, //3x3 recipe false, //symmetrical anyFabric, null, anyFabric, anyFabric, anyFabric, anyFabric, ribbon, ribbon, ribbon), 6, //soft fabric crafting 10 //*fast* ); MachineRecipes.register(tasselcloakRecipe); //### MASH TUN and POT STILL### for (Entry<ResourceLocation, Spirit> entry : Spirits.REGISTRY.getEntries()) { //MASH TUN NBTTagCompound mashTag = new NBTTagCompound(); mashTag.setString("Spirit", entry.getKey().toString()); FluidStack mashFluid = new FluidStack(ThermionicsBlocks.FLUID_HOOTCH, 1000, mashTag); MashTunRecipe mashRecipe = new MashTunRecipe(mashFluid, 1000, entry.getValue().getMashBase(), 16); MachineRecipes.register(mashRecipe); //POT STILL NBTTagCompound stillInputTag = new NBTTagCompound(); stillInputTag.setString("Spirit", entry.getKey().toString()); FluidStack stillInput = new FluidStack(ThermionicsBlocks.FLUID_HOOTCH, 4, stillInputTag); NBTTagCompound stillOutputTag = new NBTTagCompound(); stillOutputTag.setString("Spirit", entry.getKey().toString()); FluidStack stillOutput = new FluidStack(ThermionicsBlocks.FLUID_SPIRITS, 3, stillOutputTag); PotStillRecipe distillation = new PotStillRecipe(stillOutput, FluidIngredient.of(stillInput)); MachineRecipes.register(distillation); } }
From source file:growthcraft.api.core.fluids.FluidKey.java
License:Open Source License
@Override public FluidStack asFluidStack(int size) { return new FluidStack(fluid, size, NBTHelper.copyCompoundTag(compoundTag)); }
From source file:org.spongepowered.mod.mixin.core.forge.fluids.MixinFluidStack.java
License:MIT License
@Override public DataHolder copy() { FluidStack fluidStack = new FluidStack(this.fluidDelegate.get(), this.amount, (NBTTagCompound) this.tag.copy()); return (DataHolder) fluidStack; }