mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 11:29:15 +00:00
Add methods to Fluid to allow custom vaporization overrides (#2959)
This commit is contained in:
1 parent
883bfe57ab
commit
c776d97691
2 files changed
+57
-16
No files matched your search
@@ -1,14 +1,19 @@
|
||||
package net.minecraftforge.fluids;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Locale;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldProvider;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
|
||||
@@ -193,6 +198,42 @@ public class Fluid
|
||||
return block != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* Based on {@link net.minecraft.item.ItemBucket#tryPlaceContainedLiquid(EntityPlayer, World, BlockPos)}
|
||||
*
|
||||
* @param fluidStack The fluidStack is trying to be placed.
|
||||
* @return true if this fluid should vaporize in dimensions where water vaporizes when placed.
|
||||
*/
|
||||
public boolean doesVaporize(FluidStack fluidStack)
|
||||
{
|
||||
if (block == null)
|
||||
return false;
|
||||
return block.getDefaultState().getMaterial() == Material.WATER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called instead of placing the fluid block if {@link WorldProvider#doesWaterVaporize()} and {@link #doesVaporize(FluidStack)} are true.
|
||||
* Override this to make your explosive liquid blow up instead of the default smoke, etc.
|
||||
* Based on {@link net.minecraft.item.ItemBucket#tryPlaceContainedLiquid(EntityPlayer, World, BlockPos)}
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
public void vaporize(@Nullable EntityPlayer player, World worldIn, BlockPos pos, FluidStack fluidStack)
|
||||
{
|
||||
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)
|
||||
{
|
||||
worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, (double) pos.getX() + Math.random(), (double) pos.getY() + Math.random(), (double) pos.getZ() + Math.random(), 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the localized name of this fluid.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user