use of gregtech.api.fluids.fluidType.FluidType in project GregTech by GregTechCEu.
the class MaterialPropertyExpansion method addFluid.
@ZenMethod
public static void addFluid(Material m, @Optional FluidType fluidType, @Optional boolean hasBlock) {
if (checkFrozen("add a Fluid to a material"))
return;
FluidType type = validateFluidTypeNoPlasma(fluidType == null ? null : fluidType.getName());
if (m.hasProperty(PropertyKey.FLUID)) {
m.getProperty(PropertyKey.FLUID).setIsGas(type == FluidTypes.GAS);
m.getProperty(PropertyKey.FLUID).setHasBlock(hasBlock);
} else
m.setProperty(PropertyKey.FLUID, new FluidProperty(type, hasBlock));
}
use of gregtech.api.fluids.fluidType.FluidType in project GregTech by GregTechCEu.
the class MaterialPropertyExpansion method addFluid.
@ZenMethod
public static void addFluid(Material m, @Optional String fluidTypeName, @Optional boolean hasBlock) {
if (checkFrozen("add a Fluid to a material"))
return;
FluidType type = validateFluidTypeNoPlasma(fluidTypeName);
if (m.hasProperty(PropertyKey.FLUID)) {
m.getProperty(PropertyKey.FLUID).setIsGas(type == FluidTypes.GAS);
m.getProperty(PropertyKey.FLUID).setHasBlock(hasBlock);
} else
m.setProperty(PropertyKey.FLUID, new FluidProperty(type, hasBlock));
}
use of gregtech.api.fluids.fluidType.FluidType in project GregTech by GregTechCEu.
the class MetaFluids method registerFluid.
@Nonnull
public static Fluid registerFluid(@Nonnull Material material, @Nonnull FluidType fluidType, int temperature, boolean generateBlock) {
String materialName = material.toString();
String fluidName = fluidType.getNameForMaterial(material);
Fluid fluid = FluidRegistry.getFluid(fluidName);
// check if fluid is registered from elsewhere under an alternative name
if (fluid == null && alternativeFluidNames.containsKey(fluidName)) {
String altName = alternativeFluidNames.get(fluidName);
fluid = FluidRegistry.getFluid(altName);
}
// if the material is still not registered by this point, register it
if (fluid == null) {
// determine texture for use
ResourceLocation textureLocation = fluidTextureMap.computeIfAbsent(material, key -> {
Map<FluidType, ResourceLocation> map = new Object2ObjectOpenHashMap<>();
if (fluidType.equals(FluidTypes.PLASMA))
map.put(fluidType, AUTO_GENERATED_PLASMA_TEXTURE);
else
map.put(fluidType, MaterialIconType.fluid.getBlockPath(material.getMaterialIconSet()));
return map;
}).computeIfAbsent(fluidType, key -> {
Map<FluidType, ResourceLocation> map = fluidTextureMap.get(material);
if (fluidType.equals(FluidTypes.PLASMA))
map.put(fluidType, AUTO_GENERATED_PLASMA_TEXTURE);
else
map.put(fluidType, MaterialIconType.fluid.getBlockPath(material.getMaterialIconSet()));
return map.get(fluidType);
});
// create the new fluid
fluid = new MaterialFluid(fluidName, material, fluidType, textureLocation);
fluid.setTemperature(temperature);
if (material.hasFluidColor())
fluid.setColor(GTUtility.convertRGBtoOpaqueRGBA_MC(material.getMaterialRGB()));
else
fluid.setColor(0xFFFFFFFF);
// set properties and register
FluidType.setFluidProperties(fluidType, fluid);
((MaterialFluid) fluid).registerFluidTooltip();
FluidRegistry.registerFluid(fluid);
}
// add buckets for each fluid
FluidRegistry.addBucketForFluid(fluid);
// generate fluid blocks if the material has one, and the current state being handled is not plasma
if (generateBlock && fluid.getBlock() == null && fluidType != FluidTypes.PLASMA) {
BlockFluidBase fluidBlock = new BlockFluidClassic(fluid, net.minecraft.block.material.Material.WATER);
fluidBlock.setRegistryName("fluid." + materialName);
MetaBlocks.FLUID_BLOCKS.add(fluidBlock);
}
fluidToMaterialMappings.put(fluid.getName(), material);
return fluid;
}
Aggregations