2016-06-23 03:49:47 +00:00
|
|
|
/*
|
|
|
|
* Minecraft Forge
|
2020-07-02 17:49:11 +00:00
|
|
|
* Copyright (c) 2016-2020.
|
2016-06-23 03:49:47 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation version 2.1
|
|
|
|
* of the License.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2013-05-23 05:01:19 +00:00
|
|
|
package net.minecraftforge.fluids;
|
|
|
|
|
2016-06-09 09:30:06 +00:00
|
|
|
import javax.annotation.Nullable;
|
2017-12-08 10:18:45 +00:00
|
|
|
|
2019-07-28 19:35:30 +00:00
|
|
|
import net.minecraft.block.BlockState;
|
2019-09-11 14:00:32 +00:00
|
|
|
import net.minecraft.fluid.Fluid;
|
2020-06-19 14:58:45 +00:00
|
|
|
import net.minecraft.fluid.FluidState;
|
2019-08-29 01:01:11 +00:00
|
|
|
import net.minecraft.item.ItemStack;
|
2019-05-23 23:02:15 +00:00
|
|
|
import net.minecraft.particles.ParticleTypes;
|
2019-09-11 14:00:32 +00:00
|
|
|
import net.minecraft.util.*;
|
2019-07-28 19:35:30 +00:00
|
|
|
import net.minecraft.util.text.ITextComponent;
|
|
|
|
import net.minecraft.util.text.TranslationTextComponent;
|
2020-06-19 14:58:45 +00:00
|
|
|
import net.minecraft.world.IBlockDisplayReader;
|
2018-09-14 16:30:56 +00:00
|
|
|
|
2019-09-11 14:00:32 +00:00
|
|
|
import java.util.function.BiFunction;
|
|
|
|
import java.util.stream.Stream;
|
2019-07-28 19:35:30 +00:00
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
import net.minecraft.entity.player.PlayerEntity;
|
2016-03-01 12:58:03 +00:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2013-05-23 05:01:19 +00:00
|
|
|
import net.minecraft.world.World;
|
2019-05-23 23:02:15 +00:00
|
|
|
import net.minecraft.item.Rarity;
|
2019-09-11 14:00:32 +00:00
|
|
|
import net.minecraft.world.biome.BiomeColors;
|
2013-05-23 05:01:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Minecraft Forge Fluid Implementation
|
2013-07-27 23:06:16 +00:00
|
|
|
*
|
2013-05-23 05:01:19 +00:00
|
|
|
* This class is a fluid (liquid or gas) equivalent to "Item." It describes the nature of a fluid
|
|
|
|
* and contains its general properties.
|
2013-07-27 23:06:16 +00:00
|
|
|
*
|
2013-05-23 05:01:19 +00:00
|
|
|
* These properties do not have inherent gameplay mechanics - they are provided so that mods may
|
|
|
|
* choose to take advantage of them.
|
2013-07-27 23:06:16 +00:00
|
|
|
*
|
2013-05-23 05:01:19 +00:00
|
|
|
* Fluid implementations are not required to actively use these properties, nor are objects
|
|
|
|
* interfacing with fluids required to make use of them, but it is encouraged.
|
2013-07-27 23:06:16 +00:00
|
|
|
*
|
2013-05-23 05:01:19 +00:00
|
|
|
* The default values can be used as a reference point for mods adding fluids such as oil or heavy
|
|
|
|
* water.
|
2013-07-27 23:06:16 +00:00
|
|
|
*
|
2013-05-23 05:01:19 +00:00
|
|
|
*/
|
2019-07-28 19:35:30 +00:00
|
|
|
public class FluidAttributes
|
2013-07-17 04:40:49 +00:00
|
|
|
{
|
2016-06-04 01:26:41 +00:00
|
|
|
public static final int BUCKET_VOLUME = 1000;
|
|
|
|
|
2019-07-28 19:35:30 +00:00
|
|
|
private String translationKey;
|
2013-05-23 05:01:19 +00:00
|
|
|
|
2019-12-17 04:22:13 +00:00
|
|
|
private final ResourceLocation stillTexture;
|
|
|
|
private final ResourceLocation flowingTexture;
|
2015-06-18 11:14:46 +00:00
|
|
|
|
2018-07-18 03:37:20 +00:00
|
|
|
@Nullable
|
2019-12-17 04:22:13 +00:00
|
|
|
private final ResourceLocation overlayTexture;
|
2018-07-18 03:37:20 +00:00
|
|
|
|
2019-07-28 19:35:30 +00:00
|
|
|
private final SoundEvent fillSound;
|
|
|
|
private final SoundEvent emptySound;
|
2016-05-16 20:20:31 +00:00
|
|
|
|
2013-05-23 05:01:19 +00:00
|
|
|
/**
|
|
|
|
* The light level emitted by this fluid.
|
2013-07-27 23:06:16 +00:00
|
|
|
*
|
2013-05-23 05:01:19 +00:00
|
|
|
* Default value is 0, as most fluids do not actively emit light.
|
|
|
|
*/
|
2019-07-28 19:35:30 +00:00
|
|
|
private final int luminosity;
|
2013-05-23 05:01:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Density of the fluid - completely arbitrary; negative density indicates that the fluid is
|
|
|
|
* lighter than air.
|
2013-07-27 23:06:16 +00:00
|
|
|
*
|
2013-05-23 05:01:19 +00:00
|
|
|
* Default value is approximately the real-life density of water in kg/m^3.
|
|
|
|
*/
|
2019-07-28 19:35:30 +00:00
|
|
|
private final int density;
|
2013-05-23 05:01:19 +00:00
|
|
|
|
2013-08-01 03:15:42 +00:00
|
|
|
/**
|
|
|
|
* Temperature of the fluid - completely arbitrary; higher temperature indicates that the fluid is
|
|
|
|
* hotter than air.
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
*
|
2013-08-01 03:15:42 +00:00
|
|
|
* Default value is approximately the real-life room temperature of water in degrees Kelvin.
|
|
|
|
*/
|
2019-07-28 19:35:30 +00:00
|
|
|
private final int temperature;
|
2013-08-01 03:15:42 +00:00
|
|
|
|
2013-05-23 05:01:19 +00:00
|
|
|
/**
|
|
|
|
* Viscosity ("thickness") of the fluid - completely arbitrary; negative values are not
|
|
|
|
* permissible.
|
2013-07-27 23:06:16 +00:00
|
|
|
*
|
2013-05-23 05:01:19 +00:00
|
|
|
* Default value is approximately the real-life density of water in m/s^2 (x10^-3).
|
2015-04-05 20:13:17 +00:00
|
|
|
*
|
2015-03-25 05:27:15 +00:00
|
|
|
* Higher viscosity means that a fluid flows more slowly, like molasses.
|
|
|
|
* Lower viscosity means that a fluid flows more quickly, like helium.
|
2015-04-05 20:13:17 +00:00
|
|
|
*
|
2013-05-23 05:01:19 +00:00
|
|
|
*/
|
2019-07-28 19:35:30 +00:00
|
|
|
private final int viscosity;
|
2013-05-23 05:01:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This indicates if the fluid is gaseous.
|
2013-07-27 23:06:16 +00:00
|
|
|
*
|
2013-05-23 05:01:19 +00:00
|
|
|
* Generally this is associated with negative density fluids.
|
|
|
|
*/
|
2019-07-28 19:35:30 +00:00
|
|
|
private final boolean isGaseous;
|
2013-05-23 05:01:19 +00:00
|
|
|
|
2013-09-13 22:04:31 +00:00
|
|
|
/**
|
|
|
|
* The rarity of the fluid.
|
|
|
|
*
|
|
|
|
* Used primarily in tool tips.
|
|
|
|
*/
|
2019-07-28 19:35:30 +00:00
|
|
|
private final Rarity rarity;
|
2013-09-13 22:04:31 +00:00
|
|
|
|
2017-12-08 10:18:45 +00:00
|
|
|
/**
|
|
|
|
* Color used by universal bucket and the ModelFluid baked model.
|
|
|
|
* Note that this int includes the alpha so converting this to RGB with alpha would be
|
|
|
|
* float r = ((color >> 16) & 0xFF) / 255f; // red
|
|
|
|
* float g = ((color >> 8) & 0xFF) / 255f; // green
|
|
|
|
* float b = ((color >> 0) & 0xFF) / 255f; // blue
|
|
|
|
* float a = ((color >> 24) & 0xFF) / 255f; // alpha
|
|
|
|
*/
|
2019-07-28 19:35:30 +00:00
|
|
|
private final int color;
|
|
|
|
|
2019-09-11 14:00:32 +00:00
|
|
|
protected FluidAttributes(Builder builder, Fluid fluid)
|
2019-07-28 19:35:30 +00:00
|
|
|
{
|
2019-09-11 14:00:32 +00:00
|
|
|
this.translationKey = builder.translationKey != null ? builder.translationKey : Util.makeTranslationKey("fluid", fluid.getRegistryName());
|
2019-07-28 19:35:30 +00:00
|
|
|
this.stillTexture = builder.stillTexture;
|
|
|
|
this.flowingTexture = builder.flowingTexture;
|
|
|
|
this.overlayTexture = builder.overlayTexture;
|
|
|
|
this.color = builder.color;
|
|
|
|
this.fillSound = builder.fillSound;
|
|
|
|
this.emptySound = builder.emptySound;
|
|
|
|
this.luminosity = builder.luminosity;
|
|
|
|
this.temperature = builder.temperature;
|
|
|
|
this.viscosity = builder.viscosity;
|
|
|
|
this.density = builder.density;
|
|
|
|
this.isGaseous = builder.isGaseous;
|
|
|
|
this.rarity = builder.rarity;
|
2013-05-23 05:01:19 +00:00
|
|
|
}
|
|
|
|
|
2019-08-29 01:01:11 +00:00
|
|
|
public ItemStack getBucket(FluidStack stack)
|
|
|
|
{
|
2019-08-29 19:09:42 +00:00
|
|
|
return new ItemStack(stack.getFluid().getFilledBucket());
|
2019-08-29 01:01:11 +00:00
|
|
|
}
|
|
|
|
|
2020-06-19 14:58:45 +00:00
|
|
|
public BlockState getBlock(IBlockDisplayReader reader, BlockPos pos, FluidState state)
|
2017-12-08 10:18:45 +00:00
|
|
|
{
|
2019-08-29 19:09:42 +00:00
|
|
|
return state.getBlockState();
|
2017-12-08 10:18:45 +00:00
|
|
|
}
|
2016-05-16 20:20:31 +00:00
|
|
|
|
2020-06-19 14:58:45 +00:00
|
|
|
public FluidState getStateForPlacement(IBlockDisplayReader reader, BlockPos pos, FluidStack state)
|
2013-07-17 04:40:49 +00:00
|
|
|
{
|
2019-07-28 19:35:30 +00:00
|
|
|
return state.getFluid().getDefaultState();
|
2013-05-23 05:01:19 +00:00
|
|
|
}
|
|
|
|
|
2020-06-19 14:58:45 +00:00
|
|
|
public final boolean canBePlacedInWorld(IBlockDisplayReader reader, BlockPos pos, FluidState state)
|
2013-07-17 04:40:49 +00:00
|
|
|
{
|
2019-08-29 19:09:42 +00:00
|
|
|
return !getBlock(reader, pos, state).isAir(reader, pos);
|
2013-05-23 05:01:19 +00:00
|
|
|
}
|
|
|
|
|
2020-06-19 14:58:45 +00:00
|
|
|
public final boolean canBePlacedInWorld(IBlockDisplayReader reader, BlockPos pos, FluidStack state)
|
2013-07-17 04:40:49 +00:00
|
|
|
{
|
2019-08-29 19:09:42 +00:00
|
|
|
return !getBlock(reader, pos, getStateForPlacement(reader, pos, state)).isAir(reader, pos);
|
2013-05-23 05:01:19 +00:00
|
|
|
}
|
|
|
|
|
2018-07-18 03:37:20 +00:00
|
|
|
public final boolean isLighterThanAir()
|
|
|
|
{
|
2018-09-15 07:59:19 +00:00
|
|
|
return this.density <= 0;
|
2018-07-18 03:37:20 +00:00
|
|
|
}
|
|
|
|
|
2018-09-15 07:59:19 +00:00
|
|
|
/**
|
2016-06-09 09:30:06 +00:00
|
|
|
* Determines if this fluid should vaporize in dimensions where water vaporizes when placed.
|
|
|
|
* To preserve the intentions of vanilla, fluids that can turn lava into obsidian should vaporize.
|
|
|
|
* This prevents players from making the nether safe with a single bucket.
|
2019-05-23 23:02:15 +00:00
|
|
|
* Based on {@link net.minecraft.item.BucketItem#tryPlaceContainedLiquid(PlayerEntity, World, BlockPos)}
|
2016-06-09 09:30:06 +00:00
|
|
|
*
|
|
|
|
* @param fluidStack The fluidStack is trying to be placed.
|
|
|
|
* @return true if this fluid should vaporize in dimensions where water vaporizes when placed.
|
|
|
|
*/
|
2020-06-19 14:58:45 +00:00
|
|
|
public boolean doesVaporize(IBlockDisplayReader reader, BlockPos pos, FluidStack fluidStack)
|
2016-06-09 09:30:06 +00:00
|
|
|
{
|
2019-07-28 19:35:30 +00:00
|
|
|
BlockState blockstate = getBlock(reader, pos, getStateForPlacement(reader, pos, fluidStack));
|
|
|
|
if (blockstate == null)
|
2016-06-09 09:30:06 +00:00
|
|
|
return false;
|
2019-12-11 02:27:07 +00:00
|
|
|
return blockstate.getMaterial() == net.minecraft.block.material.Material.WATER;
|
2016-06-09 09:30:06 +00:00
|
|
|
}
|
|
|
|
|
2018-09-15 07:59:19 +00:00
|
|
|
/**
|
2019-05-23 23:02:15 +00:00
|
|
|
* Called instead of placing the fluid block if {@link net.minecraft.world.dimension.Dimension#doesWaterVaporize()} and {@link #doesVaporize(FluidStack)} are true.
|
2016-06-09 09:30:06 +00:00
|
|
|
* Override this to make your explosive liquid blow up instead of the default smoke, etc.
|
2019-05-23 23:02:15 +00:00
|
|
|
* Based on {@link net.minecraft.item.BucketItem#tryPlaceContainedLiquid(PlayerEntity, World, BlockPos)}
|
2016-06-09 09:30:06 +00:00
|
|
|
*
|
|
|
|
* @param player Player who tried to place the fluid. May be null for blocks like dispensers.
|
|
|
|
* @param worldIn World to vaporize the fluid in.
|
|
|
|
* @param pos The position in the world the fluid block was going to be placed.
|
|
|
|
* @param fluidStack The fluidStack that was going to be placed.
|
|
|
|
*/
|
2019-05-23 23:02:15 +00:00
|
|
|
public void vaporize(@Nullable PlayerEntity player, World worldIn, BlockPos pos, FluidStack fluidStack)
|
2016-06-09 09:30:06 +00:00
|
|
|
{
|
|
|
|
worldIn.playSound(player, pos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);
|
|
|
|
|
|
|
|
for (int l = 0; l < 8; ++l)
|
|
|
|
{
|
2019-05-23 23:02:15 +00:00
|
|
|
worldIn.addOptionalParticle(ParticleTypes.LARGE_SMOKE, (double) pos.getX() + Math.random(), (double) pos.getY() + Math.random(), (double) pos.getZ() + Math.random(), 0.0D, 0.0D, 0.0D);
|
2016-06-09 09:30:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-23 05:01:19 +00:00
|
|
|
/**
|
|
|
|
* Returns the localized name of this fluid.
|
|
|
|
*/
|
2019-07-28 19:35:30 +00:00
|
|
|
public ITextComponent getDisplayName(FluidStack stack)
|
2013-07-17 04:40:49 +00:00
|
|
|
{
|
2019-07-28 19:35:30 +00:00
|
|
|
return new TranslationTextComponent(getTranslationKey());
|
2013-05-23 05:01:19 +00:00
|
|
|
}
|
|
|
|
|
2014-07-10 12:25:53 +00:00
|
|
|
/**
|
2019-09-11 14:00:32 +00:00
|
|
|
* A FluidStack sensitive version of getTranslationKey
|
2014-07-10 12:25:53 +00:00
|
|
|
*/
|
2019-07-28 19:35:30 +00:00
|
|
|
public String getTranslationKey(FluidStack stack)
|
2014-07-10 12:25:53 +00:00
|
|
|
{
|
2019-07-28 19:35:30 +00:00
|
|
|
return this.getTranslationKey();
|
2014-07-10 12:25:53 +00:00
|
|
|
}
|
|
|
|
|
2013-05-23 05:01:19 +00:00
|
|
|
/**
|
2019-09-11 14:00:32 +00:00
|
|
|
* Returns the translation key of this fluid.
|
2013-05-23 05:01:19 +00:00
|
|
|
*/
|
2019-07-28 19:35:30 +00:00
|
|
|
public String getTranslationKey()
|
2013-07-17 04:40:49 +00:00
|
|
|
{
|
2019-09-11 14:00:32 +00:00
|
|
|
return this.translationKey;
|
2013-05-23 05:01:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Default Accessors */
|
2013-07-17 04:40:49 +00:00
|
|
|
public final int getLuminosity()
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
return this.luminosity;
|
|
|
|
}
|
|
|
|
|
2013-07-17 04:40:49 +00:00
|
|
|
public final int getDensity()
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
return this.density;
|
|
|
|
}
|
|
|
|
|
2013-08-01 03:15:42 +00:00
|
|
|
public final int getTemperature()
|
|
|
|
{
|
|
|
|
return this.temperature;
|
|
|
|
}
|
|
|
|
|
2013-07-17 04:40:49 +00:00
|
|
|
public final int getViscosity()
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
return this.viscosity;
|
|
|
|
}
|
|
|
|
|
2013-07-17 04:40:49 +00:00
|
|
|
public final boolean isGaseous()
|
|
|
|
{
|
2013-05-23 05:01:19 +00:00
|
|
|
return this.isGaseous;
|
|
|
|
}
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public Rarity getRarity()
|
2013-09-13 22:04:31 +00:00
|
|
|
{
|
|
|
|
return rarity;
|
|
|
|
}
|
2013-05-23 05:01:19 +00:00
|
|
|
|
2013-07-17 04:40:49 +00:00
|
|
|
public int getColor()
|
|
|
|
{
|
2017-12-08 10:18:45 +00:00
|
|
|
return color;
|
2013-05-23 05:01:19 +00:00
|
|
|
}
|
|
|
|
|
2019-12-17 04:22:13 +00:00
|
|
|
public ResourceLocation getStillTexture()
|
2015-06-18 11:14:46 +00:00
|
|
|
{
|
2019-07-28 19:35:30 +00:00
|
|
|
return stillTexture;
|
2015-06-18 11:14:46 +00:00
|
|
|
}
|
2015-01-16 22:30:00 +00:00
|
|
|
|
2019-12-17 04:22:13 +00:00
|
|
|
public ResourceLocation getFlowingTexture()
|
2015-06-18 11:14:46 +00:00
|
|
|
{
|
2019-07-28 19:35:30 +00:00
|
|
|
return flowingTexture;
|
2015-06-18 11:14:46 +00:00
|
|
|
}
|
|
|
|
|
2018-07-18 03:37:20 +00:00
|
|
|
@Nullable
|
2019-12-17 04:22:13 +00:00
|
|
|
public ResourceLocation getOverlayTexture()
|
2018-07-18 03:37:20 +00:00
|
|
|
{
|
2019-07-28 19:35:30 +00:00
|
|
|
return overlayTexture;
|
2018-07-18 03:37:20 +00:00
|
|
|
}
|
|
|
|
|
2016-05-16 20:20:31 +00:00
|
|
|
public SoundEvent getFillSound()
|
|
|
|
{
|
|
|
|
return fillSound;
|
|
|
|
}
|
|
|
|
|
|
|
|
public SoundEvent getEmptySound()
|
|
|
|
{
|
|
|
|
return emptySound;
|
|
|
|
}
|
|
|
|
|
2013-07-17 04:40:49 +00:00
|
|
|
/* Stack-based Accessors */
|
|
|
|
public int getLuminosity(FluidStack stack){ return getLuminosity(); }
|
|
|
|
public int getDensity(FluidStack stack){ return getDensity(); }
|
2013-08-01 03:15:42 +00:00
|
|
|
public int getTemperature(FluidStack stack){ return getTemperature(); }
|
2013-07-17 04:40:49 +00:00
|
|
|
public int getViscosity(FluidStack stack){ return getViscosity(); }
|
|
|
|
public boolean isGaseous(FluidStack stack){ return isGaseous(); }
|
2019-05-23 23:02:15 +00:00
|
|
|
public Rarity getRarity(FluidStack stack){ return getRarity(); }
|
2013-07-17 04:40:49 +00:00
|
|
|
public int getColor(FluidStack stack){ return getColor(); }
|
2019-12-17 04:22:13 +00:00
|
|
|
public ResourceLocation getStillTexture(FluidStack stack) { return getStillTexture(); }
|
|
|
|
public ResourceLocation getFlowingTexture(FluidStack stack) { return getFlowingTexture(); }
|
2016-05-16 20:20:31 +00:00
|
|
|
public SoundEvent getFillSound(FluidStack stack) { return getFillSound(); }
|
|
|
|
public SoundEvent getEmptySound(FluidStack stack) { return getEmptySound(); }
|
2015-06-18 11:14:46 +00:00
|
|
|
|
2013-07-17 04:40:49 +00:00
|
|
|
/* World-based Accessors */
|
2020-06-19 14:58:45 +00:00
|
|
|
public int getLuminosity(IBlockDisplayReader world, BlockPos pos){ return getLuminosity(); }
|
|
|
|
public int getDensity(IBlockDisplayReader world, BlockPos pos){ return getDensity(); }
|
|
|
|
public int getTemperature(IBlockDisplayReader world, BlockPos pos){ return getTemperature(); }
|
|
|
|
public int getViscosity(IBlockDisplayReader world, BlockPos pos){ return getViscosity(); }
|
|
|
|
public boolean isGaseous(IBlockDisplayReader world, BlockPos pos){ return isGaseous(); }
|
|
|
|
public Rarity getRarity(IBlockDisplayReader world, BlockPos pos){ return getRarity(); }
|
|
|
|
public int getColor(IBlockDisplayReader world, BlockPos pos){ return getColor(); }
|
|
|
|
public ResourceLocation getStillTexture(IBlockDisplayReader world, BlockPos pos) { return getStillTexture(); }
|
|
|
|
public ResourceLocation getFlowingTexture(IBlockDisplayReader world, BlockPos pos) { return getFlowingTexture(); }
|
|
|
|
public SoundEvent getFillSound(IBlockDisplayReader world, BlockPos pos) { return getFillSound(); }
|
|
|
|
public SoundEvent getEmptySound(IBlockDisplayReader world, BlockPos pos) { return getEmptySound(); }
|
2019-12-11 02:27:07 +00:00
|
|
|
|
2019-12-17 04:22:13 +00:00
|
|
|
public static Builder builder(ResourceLocation stillTexture, ResourceLocation flowingTexture) {
|
2019-09-11 14:00:32 +00:00
|
|
|
return new Builder(stillTexture, flowingTexture, FluidAttributes::new);
|
|
|
|
}
|
|
|
|
|
2019-12-17 04:22:13 +00:00
|
|
|
public Stream<ResourceLocation> getTextures()
|
2019-09-11 14:00:32 +00:00
|
|
|
{
|
|
|
|
if (overlayTexture != null)
|
|
|
|
return Stream.of(stillTexture, flowingTexture, overlayTexture);
|
|
|
|
return Stream.of(stillTexture, flowingTexture);
|
2019-07-28 19:35:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static class Builder
|
|
|
|
{
|
2019-12-17 04:22:13 +00:00
|
|
|
private final ResourceLocation stillTexture;
|
|
|
|
private final ResourceLocation flowingTexture;
|
|
|
|
private ResourceLocation overlayTexture;
|
2019-09-11 14:00:32 +00:00
|
|
|
private int color = 0xFFFFFFFF;
|
2019-07-28 19:35:30 +00:00
|
|
|
private String translationKey;
|
|
|
|
private SoundEvent fillSound;
|
|
|
|
private SoundEvent emptySound;
|
|
|
|
private int luminosity = 0;
|
|
|
|
private int density = 1000;
|
|
|
|
private int temperature = 300;
|
|
|
|
private int viscosity = 1000;
|
|
|
|
private boolean isGaseous;
|
|
|
|
private Rarity rarity = Rarity.COMMON;
|
2019-09-11 14:00:32 +00:00
|
|
|
private BiFunction<Builder,Fluid,FluidAttributes> factory;
|
2019-07-28 19:35:30 +00:00
|
|
|
|
2019-12-17 04:22:13 +00:00
|
|
|
protected Builder(ResourceLocation stillTexture, ResourceLocation flowingTexture, BiFunction<Builder,Fluid,FluidAttributes> factory) {
|
2019-09-11 14:00:32 +00:00
|
|
|
this.factory = factory;
|
2019-07-28 19:35:30 +00:00
|
|
|
this.stillTexture = stillTexture;
|
|
|
|
this.flowingTexture = flowingTexture;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Builder translationKey(String translationKey)
|
|
|
|
{
|
|
|
|
this.translationKey = translationKey;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Builder color(int color)
|
|
|
|
{
|
|
|
|
this.color = color;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2019-12-17 04:22:13 +00:00
|
|
|
public final Builder overlay(ResourceLocation texture)
|
2019-07-28 19:35:30 +00:00
|
|
|
{
|
|
|
|
overlayTexture = texture;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Builder luminosity(int luminosity)
|
|
|
|
{
|
|
|
|
this.luminosity = luminosity;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Builder density(int density)
|
|
|
|
{
|
|
|
|
this.density = density;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Builder temperature(int temperature)
|
|
|
|
{
|
|
|
|
this.temperature = temperature;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Builder viscosity(int viscosity)
|
|
|
|
{
|
|
|
|
this.viscosity = viscosity;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Builder gaseous()
|
|
|
|
{
|
|
|
|
isGaseous = true;
|
|
|
|
return this;
|
|
|
|
}
|
2013-07-27 23:06:16 +00:00
|
|
|
|
2019-07-28 19:35:30 +00:00
|
|
|
public final Builder rarity(Rarity rarity)
|
|
|
|
{
|
|
|
|
this.rarity = rarity;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Builder sound(SoundEvent sound)
|
|
|
|
{
|
|
|
|
this.fillSound = this.emptySound = sound;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Builder sound(SoundEvent fillSound, SoundEvent emptySound)
|
|
|
|
{
|
|
|
|
this.fillSound = fillSound;
|
|
|
|
this.emptySound = emptySound;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2019-09-11 14:00:32 +00:00
|
|
|
public FluidAttributes build(Fluid fluid)
|
2019-07-28 19:35:30 +00:00
|
|
|
{
|
2019-09-11 14:00:32 +00:00
|
|
|
return factory.apply(this, fluid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class Water extends FluidAttributes
|
|
|
|
{
|
|
|
|
protected Water(Builder builder, Fluid fluid)
|
|
|
|
{
|
|
|
|
super(builder, fluid);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-06-19 14:58:45 +00:00
|
|
|
public int getColor(IBlockDisplayReader world, BlockPos pos)
|
2019-09-11 14:00:32 +00:00
|
|
|
{
|
2020-02-26 03:45:14 +00:00
|
|
|
return BiomeColors.getWaterColor(world, pos) | 0xFF000000;
|
2019-09-11 14:00:32 +00:00
|
|
|
}
|
|
|
|
|
2019-12-17 04:22:13 +00:00
|
|
|
public static Builder builder(ResourceLocation stillTexture, ResourceLocation flowingTexture) {
|
2019-09-11 14:00:32 +00:00
|
|
|
return new Builder(stillTexture, flowingTexture, Water::new);
|
2019-07-28 19:35:30 +00:00
|
|
|
}
|
|
|
|
}
|
2013-05-23 05:01:19 +00:00
|
|
|
}
|