You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
3.4 KiB
Java
104 lines
3.4 KiB
Java
package net.minecraft.block;
|
|
|
|
import java.util.Random;
|
|
import net.minecraft.block.material.Material;
|
|
import net.minecraft.init.Blocks;
|
|
import net.minecraft.world.World;
|
|
|
|
public class BlockStaticLiquid extends BlockLiquid
|
|
{
|
|
private static final String __OBFID = "CL_00000315";
|
|
|
|
protected BlockStaticLiquid(Material p_i45429_1_)
|
|
{
|
|
super(p_i45429_1_);
|
|
this.setTickRandomly(false);
|
|
|
|
if (p_i45429_1_ == Material.lava)
|
|
{
|
|
this.setTickRandomly(true);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
|
|
* their own) Args: x, y, z, neighbor Block
|
|
*/
|
|
public void onNeighborBlockChange(World worldIn, int x, int y, int z, Block neighbor)
|
|
{
|
|
super.onNeighborBlockChange(worldIn, x, y, z, neighbor);
|
|
|
|
if (worldIn.getBlock(x, y, z) == this)
|
|
{
|
|
this.setNotStationary(worldIn, x, y, z);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Changes the block ID to that of an updating fluid.
|
|
*/
|
|
private void setNotStationary(World p_149818_1_, int p_149818_2_, int p_149818_3_, int p_149818_4_)
|
|
{
|
|
int l = p_149818_1_.getBlockMetadata(p_149818_2_, p_149818_3_, p_149818_4_);
|
|
p_149818_1_.setBlock(p_149818_2_, p_149818_3_, p_149818_4_, Block.getBlockById(Block.getIdFromBlock(this) - 1), l, 2);
|
|
p_149818_1_.scheduleBlockUpdate(p_149818_2_, p_149818_3_, p_149818_4_, Block.getBlockById(Block.getIdFromBlock(this) - 1), this.tickRate(p_149818_1_));
|
|
}
|
|
|
|
/**
|
|
* Ticks the block if it's been scheduled
|
|
*/
|
|
public void updateTick(World worldIn, int x, int y, int z, Random random)
|
|
{
|
|
if (this.blockMaterial == Material.lava)
|
|
{
|
|
int l = random.nextInt(3);
|
|
int i1;
|
|
|
|
for (i1 = 0; i1 < l; ++i1)
|
|
{
|
|
x += random.nextInt(3) - 1;
|
|
++y;
|
|
z += random.nextInt(3) - 1;
|
|
Block block = worldIn.getBlock(x, y, z);
|
|
|
|
if (block.blockMaterial == Material.air)
|
|
{
|
|
if (this.isFlammable(worldIn, x - 1, y, z) || this.isFlammable(worldIn, x + 1, y, z) || this.isFlammable(worldIn, x, y, z - 1) || this.isFlammable(worldIn, x, y, z + 1) || this.isFlammable(worldIn, x, y - 1, z) || this.isFlammable(worldIn, x, y + 1, z))
|
|
{
|
|
worldIn.setBlock(x, y, z, Blocks.fire);
|
|
return;
|
|
}
|
|
}
|
|
else if (block.blockMaterial.blocksMovement())
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (l == 0)
|
|
{
|
|
i1 = x;
|
|
int k1 = z;
|
|
|
|
for (int j1 = 0; j1 < 3; ++j1)
|
|
{
|
|
x = i1 + random.nextInt(3) - 1;
|
|
z = k1 + random.nextInt(3) - 1;
|
|
|
|
if (worldIn.isAirBlock(x, y + 1, z) && this.isFlammable(worldIn, x, y, z))
|
|
{
|
|
worldIn.setBlock(x, y + 1, z, Blocks.fire);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Checks to see if the block is flammable.
|
|
*/
|
|
private boolean isFlammable(World p_149817_1_, int p_149817_2_, int p_149817_3_, int p_149817_4_)
|
|
{
|
|
return p_149817_1_.getBlock(p_149817_2_, p_149817_3_, p_149817_4_).getMaterial().getCanBurn();
|
|
}
|
|
} |