private Conversion(String in, String out, int factor, int mint, long minp) {
      inputFluid = FluidRegistry.getFluid(in);
      outputFluid = FluidRegistry.getFluid(out);
      conversionFactor = factor;

      minTorque = mint;
      minPower = minp;
    }
 public static FluidStack getFluidStack(ItemStack stack, String key) {
   if (hasTag(stack)) {
     NBTTagCompound tag = getTagCompound(stack, key);
     String name = tag.getString("fluid");
     int amount = tag.getInteger("amount");
     if (FluidRegistry.getFluid(name) != null)
       return new FluidStack(FluidRegistry.getFluid(name), amount);
   }
   return null;
 }
Esempio n. 3
0
 private void registerLiquids() {
   highPressureWater = new FluidMari(FluidDictionary.hp_water, -1);
   if (!FluidRegistry.registerFluid(highPressureWater))
     highPressureWater = FluidRegistry.getFluid(FluidDictionary.hp_water);
   highPressureWaterBlock =
       new BlockFluidMari(highPressureWater, Material.water).setBlockName("highPressureWater");
   GameRegistry.registerBlock(highPressureWaterBlock, "Mariculture_highPressureWaterBlock");
   highPressureWater.setBlock(highPressureWaterBlock);
   registerHeatBottle(FluidDictionary.hp_water, 1000, FluidContainerMeta.BOTTLE_HP_WATER);
 }
Esempio n. 4
0
 public FluidLoader(FMLPreInitializationEvent event) {
   if (FluidRegistry.isFluidRegistered(fluidMercury)) {
     event
         .getModLog()
         .info("Found fluid {}, the registration is canceled. ", fluidMercury.getName());
     fluidMercury = FluidRegistry.getFluid(fluidMercury.getName());
   } else {
     FluidRegistry.registerFluid(fluidMercury);
   }
 }
  @Override
  public void handlePacketData(ByteBuf dataStream) {
    if (!worldObj.isRemote) {
      int type = dataStream.readInt();

      switch (type) {
        case 0:
          if (getReactor() != null) getReactor().setInjectionRate(dataStream.readInt());
          break;
      }

      return;
    }

    super.handlePacketData(dataStream);

    if (worldObj.isRemote) {
      boolean formed = dataStream.readBoolean();

      if (formed) {
        if (getReactor() == null || !((FusionReactor) getReactor()).formed) {
          Mekanism.proxy.doGenericSparkle(
              this,
              new INodeChecker() {
                @Override
                public boolean isNode(TileEntity tile) {
                  return tile instanceof TileEntityReactorBlock;
                }
              });
        }

        if (getReactor() == null) {
          setReactor(new FusionReactor(this));
          MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
        }

        ((FusionReactor) getReactor()).formed = true;
        getReactor().setPlasmaTemp(dataStream.readDouble());
        getReactor().setCaseTemp(dataStream.readDouble());
        getReactor().setInjectionRate(dataStream.readInt());
        getReactor().setBurning(dataStream.readBoolean());
        fuelTank.setGas(new GasStack(GasRegistry.getGas("fusionFuelDT"), dataStream.readInt()));
        deuteriumTank.setGas(new GasStack(GasRegistry.getGas("deuterium"), dataStream.readInt()));
        tritiumTank.setGas(new GasStack(GasRegistry.getGas("tritium"), dataStream.readInt()));
        waterTank.setCapacity(dataStream.readInt());
        waterTank.setFluid(new FluidStack(FluidRegistry.getFluid("water"), dataStream.readInt()));
        steamTank.setCapacity(dataStream.readInt());
        steamTank.setFluid(new FluidStack(FluidRegistry.getFluid("steam"), dataStream.readInt()));
      } else if (getReactor() != null) {
        setReactor(null);
        MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
      }
    }
  }
 /**
  * @param add
  * @param internalFluidIndex
  * @param fluid
  * @return amount added
  */
 public int addFluid(int add, Fluid fluid) {
   if (hasFluid(fluid) != -1) {
     int newAmount = internalFluids.get(hasFluid(fluid)).amount + add;
     Fluid fluidToAdd = FluidRegistry.getFluid(fluid.getName());
     internalFluids.set(hasFluid(fluid), new FluidStack(fluidToAdd, newAmount));
     return add;
   } else {
     internalFluids.add(new FluidStack(FluidRegistry.getFluid(fluid.getName()), add));
     return add;
   }
 }
Esempio n. 7
0
  @Override
  public ModelFluid process(ImmutableMap<String, String> customData) {
    if (!customData.containsKey("fluid")) return this;

    String fluidStr = customData.get("fluid");
    JsonElement e = new JsonParser().parse(fluidStr);
    String fluid = e.getAsString();
    if (!FluidRegistry.isFluidRegistered(fluid)) {
      FMLLog.severe("fluid '%s' not found", fluid);
      return WATER;
    }
    return new ModelFluid(FluidRegistry.getFluid(fluid));
  }
Esempio n. 8
0
 @Override
 public boolean isValidFluid(Fluid f) {
   if (f.equals(FluidRegistry.getFluid("rc jet fuel"))) return false;
   if (f.equals(FluidRegistry.getFluid("rc lubricant"))) return false;
   if (f.equals(FluidRegistry.getFluid("rc ethanol"))) return false;
   if (f.equals(FluidRegistry.getFluid("bioethanol"))) return false;
   if (f.equals(FluidRegistry.getFluid("fuel"))) return false;
   if (f.equals(FluidRegistry.getFluid("rocket fuel"))) return false;
   if (f.equals(FluidRegistry.getFluid("rc co2"))) return false;
   if (f.equals(FluidRegistry.getFluid("rc hot co2"))) return false;
   if (f.equals(FluidRegistry.getFluid("chlorine"))) return false;
   if (f.equals(FluidRegistry.getFluid("rc oxygen"))) return false;
   return true;
 }
Esempio n. 9
0
 /** Associates this fluid with the material. Used for melting/casting items. */
 public Material setFluid(Fluid fluid) {
   if (fluid != null && !FluidRegistry.isFluidRegistered(fluid)) {
     TinkerRegistry.log.warn("Materials cannot have an unregistered fluid associated with them!");
   }
   this.fluid = fluid;
   return this;
 }
Esempio n. 10
0
  /** Initializes Variables */
  public void initialize() {
    timeFluid = new Fluid("timeFluid").setLuminosity(7).setDensity(2000).setViscosity(3000);
    FluidRegistry.registerFluid(timeFluid);
    timeLiquid = new BlockTimeFluid(timeFluid, Material.water);

    paradoximer = new ItemParadoximer();
    bottledParadox = new BottledParadox();
    condensedParadox = new CondensedParadox();
    emptyBottle = new EmptyBottle();
    expEnhance = new ItemExpEnhance();
    // flashback = new ItemFlashback();
    bucket = new TimeFluidBucket(timeLiquid);

    slowHelmet = new SlowArmor(ArmorMaterial.IRON, 4, 0).setUnlocalizedName("slowHelmet");
    slowChestplate = new SlowArmor(ArmorMaterial.IRON, 4, 1).setUnlocalizedName("slowChestplate");
    slowLeggings = new SlowArmor(ArmorMaterial.IRON, 4, 2).setUnlocalizedName("slowLeggings");
    slowBoots = new SlowArmor(ArmorMaterial.IRON, 4, 3).setUnlocalizedName("slowBoots");

    timeDistorter = new TimeDistorter();
    marker = new BlockMarker();
    travelTime = new BlockTimeTraveler();
    paradoxCondenser = new BlockParadoxCondenser();
    paradoxExtractor = new ParadoxExtractor(true);
    collisionBlock = new Collision(Material.glass);
    timeTravel = new BlockTime();
    timeField = new BlockTimeField();
    ftm = new FutureTravelMechanics();
  }
 @Override
 public boolean canFill(ForgeDirection from, Fluid fluid) {
   if (fluid != null) {
     return fluids.containsKey(FluidRegistry.getFluidName(fluid));
   }
   return false;
 }
 public ItemStack tryPlaceContainedLiquid(
     World world, ItemStack bucket, int x, int y, int z, int side) {
   if (world.isRemote) return bucket;
   CarbonContainer item = (CarbonContainer) bucket.getItem();
   int id = bucket.getItemDamage();
   if (id != 0) {
     if (!item.canPlaceInWorld) return bucket;
     FluidStack liquid = LiquidRegistry.getLiquid(id);
     if (world.setBlock(x, y, z, liquid.getFluid().getBlock(), 0, 3))
       return item.getContainerItem(bucket);
     return bucket;
   }
   if (!item.canBeFilledFromWorld) return bucket;
   Block block = world.getBlock(x, y, z);
   if (block instanceof IFluidBlock) {
     FluidStack liquid = ((IFluidBlock) block).drain(world, x, y, z, false);
     if (liquid != null && FluidRegistry.isFluidRegistered(liquid.getFluid())) {
       ItemStack r = FluidContainerRegistry.fillFluidContainer(liquid, bucket);
       if (r != null && FluidContainerRegistry.isFilledContainer(r)) {
         ((IFluidBlock) block).drain(world, x, y, z, true);
         return r;
       }
     }
   }
   return bucket;
 }
Esempio n. 13
0
  public static Fluid getFluid(EntityItem item, boolean below) {
    double d0 = item.posY + (double) item.getEyeHeight();
    int i = MathHelper.floor_double(item.posX);
    int j = MathHelper.floor_float((float) MathHelper.floor_double(d0));
    if (below) j--;
    int k = MathHelper.floor_double(item.posZ);
    Block block = item.worldObj.getBlock(i, j, k);

    Fluid fluid = FluidRegistry.lookupFluidForBlock(block);
    if (fluid == null && block instanceof IFluidBlock) fluid = ((IFluidBlock) block).getFluid();
    else if (block instanceof BlockLiquid) fluid = FluidRegistry.WATER;

    if (below) return fluid;

    double filled = 1.0f; // If it's not a liquid assume it's a solid block
    if (block instanceof IFluidBlock) {
      filled = ((IFluidBlock) block).getFilledPercentage(item.worldObj, i, j, k);
    }

    if (filled < 0) {
      filled *= -1;
      // filled -= 0.11111111F; //Why this is needed.. not sure...
      if (d0 > (double) (j + (1 - filled))) return fluid;
    } else {
      if (d0 < (double) (j + filled)) return fluid;
    }
    return null;
  }
Esempio n. 14
0
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int side,
      float hitX,
      float hitY,
      float hitZ) {
    if (world.isRemote) {
      return true;
    }

    ItemStack held = player.getHeldItem();
    FluidStack fluidHeld = FluidContainerRegistry.getFluidForFilledItem(held);
    TileEntity tileEntity = world.getTileEntity(x, y, z);
    if (fluidHeld != null
        && fluidHeld.getFluid() == FluidRegistry.getFluid("water")
        && tileEntity instanceof TileSolarCollector) {
      TileSolarCollector tank = (TileSolarCollector) tileEntity;
      if (tank.canReceiveWaterBucket()) {
        tank.addBucketOfWater();
        if (FluidContainerRegistry.isBucket(held)
            && !(((EntityPlayerMP) player).theItemInWorldManager.isCreative())) {
          int heldLocation = player.inventory.currentItem;
          player.inventory.decrStackSize(heldLocation, 1);
          world.spawnEntityInWorld(
              new EntityItem(
                  world, player.posX, player.posY, player.posZ, new ItemStack(Items.bucket, 1)));
          //                    player.inventory.setInventorySlotContents(heldLocation, new
          // ItemStack(Items.bucket, 1));
        }
      }
      return true;
    }
    if (held != null
        && held.getItem() == Items.bucket
        && tileEntity instanceof TileSolarCollector) {
      TileSolarCollector tank = (TileSolarCollector) tileEntity;
      if (tank.canGiveSolarWater()) {
        ItemStack filledBucket =
            FluidContainerRegistry.fillFluidContainer(
                new FluidStack(ModFluids.fluidSolarWater, 1000), new ItemStack(Items.bucket, 1));
        tank.removeBucketOfSolarWater();
        if (!(((EntityPlayerMP) player).theItemInWorldManager.isCreative())) {
          player.inventory.decrStackSize(player.inventory.currentItem, 1);
          // player.inventory.setInventorySlotContents(player.inventory.getFirstEmptyStack(),
          // filledBucket);
          world.spawnEntityInWorld(
              new EntityItem(world, player.posX, player.posY, player.posZ, filledBucket));
        }
        return true;
      }
    }

    return false;
  }
Esempio n. 15
0
  public static void liquidRegisters() {
    TCInits.plainSerumFluid = new Fluid(Strings.PLAIN_SERUM_KEY);
    FluidRegistry.registerFluid(TCInits.plainSerumFluid);
    TCInits.plainSerum =
        new TCFluid(TCInits.plainSerumFluid, Material.water, Strings.PLAIN_SERUM_KEY)
            .setBlockName(Strings.PLAIN_SERUM_KEY);
    GameRegistry.registerBlock(TCInits.plainSerum, Strings.PLAIN_SERUM_KEY);
    TCInits.plainSerumFluid.setUnlocalizedName(Strings.PLAIN_SERUM_KEY);

    TCInits.dilutionLiquidFluid = new Fluid(Strings.DILUTION_LIQUID_KEY);
    FluidRegistry.registerFluid(TCInits.dilutionLiquidFluid);
    TCInits.dilutionLiquid =
        new TCFluid(TCInits.dilutionLiquidFluid, Material.water, Strings.DILUTION_LIQUID_KEY)
            .setBlockName(Strings.DILUTION_LIQUID_KEY);
    GameRegistry.registerBlock(TCInits.dilutionLiquid, Strings.DILUTION_LIQUID_KEY);
    TCInits.dilutionLiquidFluid.setUnlocalizedName(Strings.DILUTION_LIQUID_KEY);
  }
Esempio n. 16
0
 public static void registerFluidContainers() {
   FluidContainerRegistry.registerFluidContainer(
       FluidRegistry.getFluidStack("latex", FluidContainerRegistry.BUCKET_VOLUME / 4),
       new ItemStack(BCTFCItems.LatexBowl),
       new ItemStack(Items.bowl));
   FluidContainerRegistry.registerFluidContainer(
       FluidRegistry.getFluidStack("latex", FluidContainerRegistry.BUCKET_VOLUME),
       new ItemStack(BCTFCItems.Buckets, 1, 0),
       new ItemStack(TFCItems.woodenBucketEmpty));
   FluidContainerRegistry.registerFluidContainer(
       FluidRegistry.getFluidStack("saltwater", FluidContainerRegistry.BUCKET_VOLUME),
       new ItemStack(BCTFCItems.Buckets, 1, 2),
       new ItemStack(BCTFCItems.Buckets, 1, 1));
   FluidContainerRegistry.registerFluidContainer(
       FluidRegistry.getFluidStack("freshwater", FluidContainerRegistry.BUCKET_VOLUME),
       new ItemStack(BCTFCItems.Buckets, 1, 3),
       new ItemStack(BCTFCItems.Buckets, 1, 1));
   FluidContainerRegistry.registerFluidContainer(
       FluidRegistry.getFluidStack("hotwater", FluidContainerRegistry.BUCKET_VOLUME),
       new ItemStack(BCTFCItems.Buckets, 1, 4),
       new ItemStack(BCTFCItems.Buckets, 1, 1));
   FluidContainerRegistry.registerFluidContainer(
       FluidRegistry.getFluidStack("oil", FluidContainerRegistry.BUCKET_VOLUME),
       new ItemStack(BCTFCItems.Buckets, 1, 6),
       new ItemStack(BCTFCItems.Buckets, 1, 5));
   FluidContainerRegistry.registerFluidContainer(
       FluidRegistry.getFluidStack("fuel", FluidContainerRegistry.BUCKET_VOLUME),
       new ItemStack(BCTFCItems.Buckets, 1, 7),
       new ItemStack(BCTFCItems.Buckets, 1, 5));
 }
 public static void registerAsContainer(Fluid fluid) {
   FluidStack stack =
       FluidRegistry.getFluidStack(fluid.getName(), FluidContainerRegistry.BUCKET_VOLUME);
   stack = stack.copy();
   stack.amount = cell.volume;
   FluidContainerRegistry.registerFluidContainer(
       new FluidContainerData(
           stack, new ItemStack(cell, 1, LiquidRegistry.getID(stack)), new ItemStack(cell, 1, 0)));
 }
Esempio n. 18
0
  @Override
  @SideOnly(Side.CLIENT)
  public void registerBlockIcons(IIconRegister ir) {

    icons = new IIcon[2];

    if (textures[0] != null && textures[1] != null) {
      for (int i = 0; i < 2; i++) {
        icons[i] = ir.registerIcon(textures[i]);
      }
    }
    if (icons[0] == null) {
      icons[0] = FluidRegistry.getFluid(fluidName).getStillIcon();
    }
    if (icons[1] == null) {
      icons[1] = FluidRegistry.getFluid(fluidName).getFlowingIcon();
    }
  }
Esempio n. 19
0
  public static Fluid getFluidTypeOfBlock(Block block) {
    Fluid fluid = FluidRegistry.lookupFluidForBlock(block);

    if (fluid != null) return fluid;
    else if (isBlockMaterialWater(block)) return FluidRegistry.WATER;
    else if (isBlockMaterialLava(block)) return FluidRegistry.LAVA;

    return null;
  }
 private void convertSteam() {
   if (steam > 0) {
     Fluid f = FluidRegistry.getFluid("steam");
     if (f != null) {
       int amt = Math.min(1 + steam / 4, tank.getRemainingSpace() / RATIO);
       tank.addLiquid(amt * RATIO, f);
       steam -= amt;
     }
   }
 }
 @Override
 public final int onTick(TileEntity te, FluidStack stored) {
   if (stored != null
       && stored.amount >= 1000
       && stored.getFluid() == FluidRegistry.getFluid("chroma")) {
     return this.doTick(te, stored);
   } else {
     return 0;
   }
 }
  @Override
  public void readFromNBT(NBTTagCompound data) {
    super.readFromNBT(data);

    for (int i = 0; i < fluids.length; ++i) {
      NBTTagCompound nbttagcompound = data.getCompoundTag("fluidStack[" + i + "]");
      if (nbttagcompound != null)
        fluids[i] = FluidRegistry.getFluid(nbttagcompound.getString("FluidName"));
    }
  }
Esempio n. 23
0
  @Override
  public final void updateEntity(World world, int x, int y, int z, int meta) {
    super.updateEntity(world, x, y, z, meta);

    // if (ModList.BCFACTORY.isLoaded() && ModList.REACTORCRAFT.isLoaded()) { //Only if, since need
    // a way to pipe it
    if (this.contains(FluidRegistry.getFluid("uranium hexafluoride"))
        || this.contains(FluidRegistry.getFluid("hydrofluoric acid"))) {
      ReikaSoundHelper.playSoundAtBlock(world, x, y, z, "random.fizz");
      for (int i = 0; i < 6; i++) {
        ForgeDirection dir = dirs[i];
        int dx = x + dir.offsetX;
        int dy = y + dir.offsetY;
        int dz = z + dir.offsetZ;
        MachineRegistry m = MachineRegistry.getMachine(world, dx, dy, dz);
        if (m == MachineRegistry.PIPE) {
          TileEntityPipe p = (TileEntityPipe) world.getTileEntity(dx, dy, dz);
          p.setFluid(liquid);
          p.addFluid(5);
          // ReikaParticleHelper.SMOKE.spawnAroundBlock(world, dx, dy, dz, 8);
        }
      }
      world.setBlockToAir(x, y, z);
      ReikaParticleHelper.SMOKE.spawnAroundBlock(world, x, y, z, 8);
    }
    // }

    if (rand.nextInt(60) == 0) {
      ReikaWorldHelper.temperatureEnvironment(world, x, y, z, this.getTemperature());
    }

    if (liquid != null) {
      int temp = liquid.getTemperature(worldObj, xCoord, yCoord, zCoord);
      temperature = temp > 750 ? temp - 425 : temp - 273;
      if (temperature > this.getMaxTemperature()) {
        this.overheat(worldObj, xCoord, yCoord, zCoord);
      }
    } else {
      temperature = ReikaWorldHelper.getAmbientTemperatureAt(world, x, y, z);
    }
  }
Esempio n. 24
0
 @ForgeSubscribe
 public void onItemIconRegister(final TextureStitchEvent.Post event) {
   FluidRegistry.getFluid("milk").setStillIcon(ExtraIcons.liquidMilk);
   FluidRegistry.getFluid("beer").setStillIcon(ExtraIcons.liquidBeer);
   FluidRegistry.getFluid("hotcocoa").setStillIcon(ExtraIcons.liquidHotcocoa);
   FluidRegistry.getFluid("cookingoil").setStillIcon(ExtraIcons.vineger);
   FluidRegistry.getFluid("vodka").setStillIcon(ExtraIcons.liquidVodka);
   FluidRegistry.getFluid("cider").setStillIcon(ExtraIcons.liquidCider);
   FluidRegistry.getFluid("vinegar").setStillIcon(ExtraIcons.vineger);
 }
 @Override
 public void readData(DataInputStream data) throws IOException {
   NBTBase nbt = NBTBase.readNamedTag(data);
   if (nbt instanceof NBTTagCompound) {
     for (int i = 0; i < fluids.length; ++i) {
       NBTTagCompound nbttagcompound =
           ((NBTTagCompound) nbt).getCompoundTag("fluidStack[" + i + "]");
       if (nbttagcompound != null)
         fluids[i] = FluidRegistry.getFluid(nbttagcompound.getString("FluidName"));
     }
   }
 }
Esempio n. 26
0
 private static void initClayRecipes() {
   // Basic crafting.
   FluidStack waterStack =
       FluidRegistry.getFluidStack("water", FluidContainerRegistry.BUCKET_VOLUME);
   for (FluidContainerData containerData :
       FluidContainerRegistry.getRegisteredFluidContainerData()) {
     if (containerData.fluid.isFluidEqual(waterStack)) {
       GameRegistry.addShapelessRecipe(
           new ItemStack(Item.clay, 8), Block.gravel, containerData.filledContainer);
     }
   }
 }
Esempio n. 27
0
  public static ItemStack createFilledTank(Fluid fluid) {
    final int tankCapacity = TileEntityTank.getTankCapacity();
    FluidStack stack = FluidRegistry.getFluidStack(fluid.getName(), tankCapacity);
    if (stack == null) return null;

    FluidTank tank = new FluidTank(tankCapacity);
    tank.setFluid(stack);

    ItemStack item = new ItemStack(OpenBlocks.Blocks.tank);
    saveTank(item, tank);
    return item;
  }
Esempio n. 28
0
 @Override
 protected void readEntityFromNBT(NBTTagCompound nbt) {
   if (nbt.hasKey("Fluid")) {
     fluid = FluidRegistry.getFluid(nbt.getString("Fluid"));
     dataManager.set(COLOR, fluid.getColor());
     isFluid = true;
   } else if (nbt.hasKey("Potion")) {
     potion = PotionType.getPotionTypeForName(nbt.getString("Potion"));
     dataManager.set(COLOR, fluid.getColor());
     isFluid = false;
   } else setDead();
   dataManager.setDirty(COLOR);
 }
  @Override
  public int addFuel(FluidStack liquid, boolean doFill) {
    final FluidStack liquidInTank = this.spaceshipFuelTank.getFluid();

    if (liquid != null && FluidRegistry.getFluidName(liquid).equalsIgnoreCase("Fuel")) {
      if (liquidInTank == null
          || liquidInTank.amount + liquid.amount <= this.spaceshipFuelTank.getCapacity()) {
        return this.spaceshipFuelTank.fill(liquid, doFill);
      }
    }

    return 0;
  }
Esempio n. 30
0
  @Override
  public ArrayList<Object> getNetworkedData(ArrayList<Object> data) {
    super.getNetworkedData(data);

    data.add(tier.ordinal());
    data.add(isActive);
    data.add(valve);
    data.add(editMode.ordinal());

    if (valve > 0) {
      data.add(FluidRegistry.getFluidName(valveFluid));
    }

    if (fluidTank.getFluid() != null) {
      data.add(1);
      data.add(FluidRegistry.getFluidName(fluidTank.getFluid()));
      data.add(fluidTank.getFluid().amount);
    } else {
      data.add(0);
    }

    return data;
  }