Java Code Examples for net.minecraftforge.fluids.FluidRegistry#getFluid()
The following examples show how to use
net.minecraftforge.fluids.FluidRegistry#getFluid() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContainerPack.java From SimplyJetpacks with MIT License | 6 votes |
public ContainerPack(ItemStack chestplate, ItemPack packItem, PackBase pack) { this.chestplate = chestplate; this.packItem = packItem; this.pack = pack; int fuel = packItem.getFuelStored(chestplate); int maxFuel = pack.tier > 9000 ? -1 : packItem.getMaxFuelStored(chestplate); switch (pack.fuelType) { case ENERGY: this.energyStored = new EnergyStorage(maxFuel); this.energyStored.setEnergyStored(fuel); this.fluidStored = null; break; case FLUID: this.energyStored = null; this.fluidStored = new FluidTank(FluidRegistry.getFluid(pack.fuelFluid), fuel, maxFuel); break; default: this.energyStored = null; this.fluidStored = null; } this.lastFuel = fuel; }
Example 2
Source File: TileEntityAerialInterface.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void readFromNBT(NBTTagCompound tag){ super.readFromNBT(tag); // Read in the ItemStacks in the inventory from NBT redstoneMode = tag.getInteger("redstoneMode"); feedMode = tag.getInteger("feedMode"); setPlayer(tag.getString("playerName"), tag.getString("playerUUID")); isConnectedToPlayer = tag.getBoolean("connected"); if(tag.hasKey("curXpFluid")) curXpFluid = FluidRegistry.getFluid(tag.getString("curXpFluid")); if(energyRF != null) readRF(tag); NBTTagList tagList = tag.getTagList("Items", 10); inventory = new ItemStack[4]; for(int i = 0; i < tagList.tagCount(); ++i) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); byte slot = tagCompound.getByte("Slot"); if(slot >= 0 && slot < inventory.length) { inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound); } } dispenserUpgradeInserted = getUpgrades(ItemMachineUpgrade.UPGRADE_DISPENSER_DAMAGE) > 0; }
Example 3
Source File: PacketUpdateGui.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
public static Object readField(ByteBuf buf, int type){ switch(type){ case 0: return buf.readInt(); case 1: return buf.readFloat(); case 2: return buf.readDouble(); case 3: return buf.readBoolean(); case 4: return ByteBufUtils.readUTF8String(buf); case 5: return buf.readByte(); case 6: return ByteBufUtils.readItemStack(buf); case 7: if(!buf.readBoolean()) return null; return new FluidStack(FluidRegistry.getFluid(ByteBufUtils.readUTF8String(buf)), buf.readInt(), ByteBufUtils.readTag(buf)); } throw new IllegalArgumentException("Invalid sync type! " + type); }
Example 4
Source File: GuiLiquidCompressor.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
private List<String> getAllFuels(){ List<String> fuels = new ArrayList<String>(); fuels.add("L/Bucket | Fluid"); for(Map.Entry<String, Integer> map : sortByValue(PneumaticCraftAPIHandler.getInstance().liquidFuels).entrySet()) { String value = map.getValue() / 1000 + ""; while(fontRendererObj.getStringWidth(value) < 25) { value = value + " "; } Fluid fluid = FluidRegistry.getFluid(map.getKey()); fuels.add(value + "| " + fluid.getLocalizedName(new FluidStack(fluid, 1))); } return fuels; }
Example 5
Source File: ItemPack.java From SimplyJetpacks with MIT License | 5 votes |
@Override public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain) { T pack = this.getPack(container); if (pack == null || pack.fuelType != FuelType.FLUID || pack.fuelFluid == null) { return null; } FluidStack fluid = this.getFluid(container); int amount = fluid != null ? fluid.amount : 0; int fluidExtracted = Math.min(amount, Math.min(maxDrain, pack.fuelPerTickOut)); if (doDrain) { amount -= fluidExtracted; NBTHelper.getNBT(container).setInteger(TAG_FLUID, amount); } return fluidExtracted > 0 ? new FluidStack(FluidRegistry.getFluid(pack.fuelFluid), fluidExtracted) : null; }
Example 6
Source File: SyncableTank.java From OpenModsLib with MIT License | 5 votes |
@Override public void readFromStream(PacketBuffer stream) throws IOException { if (stream.readBoolean()) { String fluidName = stream.readString(Short.MAX_VALUE); Fluid fluid = FluidRegistry.getFluid(fluidName); int fluidAmount = stream.readInt(); this.fluid = new FluidStack(fluid, fluidAmount); this.fluid.tag = stream.readCompoundTag(); } else { this.fluid = null; } }
Example 7
Source File: ItemPack.java From SimplyJetpacks with MIT License | 5 votes |
@Override public FluidStack getFluid(ItemStack container) { T pack = this.getPack(container); if (pack == null || pack.fuelType != FuelType.FLUID || pack.fuelFluid == null) { return null; } int amount = NBTHelper.getNBT(container).getInteger(TAG_FLUID); return amount > 0 ? new FluidStack(FluidRegistry.getFluid(pack.fuelFluid), amount) : null; }
Example 8
Source File: JSHandler.java From OmniOcular with Apache License 2.0 | 5 votes |
public static String getFluidName(String uName) { if (fluidList.containsKey(uName)) { return fluidList.get(uName); } else { try { Fluid f = FluidRegistry.getFluid(uName.toLowerCase()); FluidStack fs = new FluidStack(f, 1); String lName = fs.getLocalizedName(); fluidList.put(uName, lName); return lName; } catch (Exception e) { return "__ERROR__"; } } }
Example 9
Source File: ProgWidgetCC.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
private ProgWidgetLiquidFilter getFilterForArgs(String fluidName) throws IllegalArgumentException{ Fluid fluid = FluidRegistry.getFluid(fluidName); if(fluid == null) throw new IllegalArgumentException("Can't find fluid for the name \"" + fluidName + "\"!"); ProgWidgetLiquidFilter filter = new ProgWidgetLiquidFilter(); filter.setFluid(fluid); return filter; }
Example 10
Source File: ContainerFluidKineticGenerator.java From Production-Line with MIT License | 5 votes |
@Override @SideOnly(Side.CLIENT) public void updateProgressBar(int id, int var) { super.updateProgressBar(id, var); switch (id) { case 0: if (this.tile.fluidTank.getFluid() != null) { this.tile.fluidTank.getFluid().amount = var; } case 1: if (FluidRegistry.getFluid(var) != null) { this.tile.fluidTank.setFluid(new FluidStack(FluidRegistry.getFluid(var), this.tile.fluidTank.getFluidAmount())); } } }
Example 11
Source File: PacketSyncAmadronOffers.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
public static Object getFluidOrItemStack(ByteBuf buf){ if(buf.readByte() == 0) { return ByteBufUtils.readItemStack(buf); } else { return new FluidStack(FluidRegistry.getFluid(ByteBufUtils.readUTF8String(buf)), buf.readInt(), ByteBufUtils.readTag(buf)); } }
Example 12
Source File: CompatTConstruct.java From ExNihiloAdscensio with MIT License | 5 votes |
public static void registerMelting() { for (ItemOre ore : OreRegistry.getItemOreRegistry()) { if (FluidRegistry.isFluidRegistered(ore.getOre().getName())) { Fluid fluid = FluidRegistry.getFluid(ore.getOre().getName()); TinkerRegistry.registerMelting(new ItemStack(ore, 1, 1), fluid, 2*Material.VALUE_Ingot); } } }
Example 13
Source File: PneumaticCraft.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@EventHandler public void validateFluids(FMLServerStartedEvent event){ Fluid oil = FluidRegistry.getFluid(Fluids.oil.getName()); if(oil.getBlock() == null) { String modName = FluidRegistry.getDefaultFluidName(oil).split(":")[0]; throw new IllegalStateException(String.format("Oil fluid does not have a block associated with it. The fluid is owned by %s. This could be fixed by creating the world with having this mod loaded after PneumaticCraft. This can be done by adding a injectedDependencies.json inside the config folder containing: [{\"modId\": \"%s\",\"deps\": [{\"type\":\"after\",\"target\":\"%s\"}]}]", modName, modName, Names.MOD_ID)); } }
Example 14
Source File: IngredientFluidStackFactory.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@Nonnull @Override public Ingredient parse(JsonContext context, JsonObject json) { String name = JsonUtils.getString(json, "fluid"); int amount = JsonUtils.getInt(json, "amount", 1000); Fluid fluid = FluidRegistry.getFluid(name); if (fluid == null) throw new JsonSyntaxException("Fluid with name " + name + " could not be found"); return new IngredientFluidStack(fluid, amount); }
Example 15
Source File: GTTileTranslocatorFluid.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); if (nbt.hasKey(NBT_FLUIDFILTER)) { Fluid storedFluid = FluidRegistry.getFluid(nbt.getString(NBT_FLUIDFILTER)); if (storedFluid != null) { this.filter = new FluidStack(FluidRegistry.getFluid(nbt.getString(NBT_FLUIDFILTER)), 1000); } } }
Example 16
Source File: GT_TileEntity_BioVat.java From bartworks with MIT License | 5 votes |
@Override public void loadNBTData(NBTTagCompound aNBT) { this.height = aNBT.getInteger("mFluidHeight"); this.mCulture = BioCulture.getBioCulture(aNBT.getString("mCulture")); if (!aNBT.getString("mFluid").isEmpty()) this.mFluid = FluidRegistry.getFluid(aNBT.getString("mFluid")); this.mSievert = aNBT.getInteger("mSievert"); this.mNeededSievert = aNBT.getInteger("mNeededSievert"); super.loadNBTData(aNBT); }
Example 17
Source File: BarrelModeFluidTransform.java From ExNihiloAdscensio with MIT License | 4 votes |
@Override public void update(TileBarrel barrel) { if (transformer == null) { transformer = FluidTransformRegistry.getFluidTransformer(inputStack .getFluid().getName(), outputStack.getFluid().getName()); } if (transformer == null) return; if (progress < 1) { int numberOfBlocks = Util.getNumSurroundingBlocksAtLeastOneOf( transformer.getTransformingBlocks(), barrel.getPos().add(0, -1, 0), barrel.getWorld()) + Util.getNumSurroundingBlocksAtLeastOneOf( transformer.getTransformingBlocks(), barrel.getPos(), barrel.getWorld()); if (numberOfBlocks > 0) { progress += numberOfBlocks * 1.0 / transformer.getDuration(); if (barrel.getWorld().rand.nextDouble() < 0.005) { boolean spawned = false; ArrayList<BlockInfo> blockList = new ArrayList<BlockInfo>( Arrays.asList(transformer.getTransformingBlocks())); for (int xShift = -1; xShift <= 1; xShift++) { for (int zShift = -1; zShift <= 1; zShift++) { if (!spawned) { BlockPos testPos = barrel.getPos().add(xShift, -1, zShift); if (blockList.contains(new BlockInfo(barrel .getWorld().getBlockState(testPos))) && barrel.getWorld().isAirBlock( testPos.add(0, 1, 0))) { BlockInfo[] toSpawn = transformer .getBlocksToSpawn(); if (toSpawn != null && toSpawn.length > 0) { barrel.getWorld() .setBlockState( testPos.add(0, 1, 0), toSpawn[barrel .getWorld().rand .nextInt(toSpawn.length)] .getBlockState()); spawned = true; } } } } } } } PacketHandler.sendNBTUpdate(barrel); } if (progress >= 1) { barrel.setMode("fluid"); FluidTank tank = barrel.getMode().getFluidHandler(barrel); Fluid fluid = FluidRegistry.getFluid(transformer.getOutputFluid()); tank.setFluid(new FluidStack(fluid, 1000)); PacketHandler.sendNBTUpdate(barrel); } }
Example 18
Source File: FluidKineticGeneratorRecipes.java From Production-Line with MIT License | 4 votes |
public void register(String fluidName, int amount) { if (FluidRegistry.getFluid(fluidName) != null) { processList.add(new RecipePartFluidKineticGenerator(FluidRegistry.getFluidStack(fluidName, amount))); } }
Example 19
Source File: ProgWidgetLiquidFilter.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override public void readFromNBT(NBTTagCompound tag){ super.readFromNBT(tag); fluid = FluidRegistry.getFluid(tag.getString("fluid")); }
Example 20
Source File: GTTileMagicEnergyConverter.java From GT-Classic with GNU Lesser General Public License v3.0 | 4 votes |
public static void addModRecipe(String name) { Fluid input = FluidRegistry.getFluid(name); if (input != null) { addRecipe(input); } }