72 lines
2.5 KiB
Java
72 lines
2.5 KiB
Java
package net.minecraft.world.level.block;
|
|
|
|
import net.minecraft.core.particles.ParticleOptions;
|
|
import net.minecraft.core.particles.ParticleTypes;
|
|
import net.minecraft.world.level.BlockGetter;
|
|
import net.minecraft.core.Direction;
|
|
import java.util.Random;
|
|
import net.minecraft.world.entity.player.Player;
|
|
import net.minecraft.sounds.SoundSource;
|
|
import net.minecraft.sounds.SoundEvents;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.world.level.Level;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
|
|
public class WetSpongeBlock extends Block {
|
|
protected WetSpongeBlock(final Properties c) {
|
|
super(c);
|
|
}
|
|
|
|
@Override
|
|
public void onPlace(final BlockState byg1, final Level bjt, final BlockPos fk, final BlockState byg4, final boolean boolean5) {
|
|
if (bjt.getDimension().isUltraWarm()) {
|
|
bjt.setBlock(fk, Blocks.SPONGE.defaultBlockState(), 3);
|
|
bjt.levelEvent(2009, fk, 0);
|
|
bjt.playSound(null, fk, SoundEvents.FIRE_EXTINGUISH, SoundSource.BLOCKS, 1.0f, (1.0f + bjt.getRandom().nextFloat() * 0.2f) * 0.7f);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void animateTick(final BlockState byg, final Level bjt, final BlockPos fk, final Random random) {
|
|
final Direction fp6 = Direction.getRandomFace(random);
|
|
if (fp6 == Direction.UP) {
|
|
return;
|
|
}
|
|
final BlockPos fk2 = fk.relative(fp6);
|
|
final BlockState byg2 = bjt.getBlockState(fk2);
|
|
if (byg.canOcclude() && byg2.isFaceSturdy(bjt, fk2, fp6.getOpposite())) {
|
|
return;
|
|
}
|
|
double double9 = fk.getX();
|
|
double double10 = fk.getY();
|
|
double double11 = fk.getZ();
|
|
if (fp6 == Direction.DOWN) {
|
|
double10 -= 0.05;
|
|
double9 += random.nextDouble();
|
|
double11 += random.nextDouble();
|
|
}
|
|
else {
|
|
double10 += random.nextDouble() * 0.8;
|
|
if (fp6.getAxis() == Direction.Axis.X) {
|
|
double11 += random.nextDouble();
|
|
if (fp6 == Direction.EAST) {
|
|
double9 += 1.1;
|
|
}
|
|
else {
|
|
double9 += 0.05;
|
|
}
|
|
}
|
|
else {
|
|
double9 += random.nextDouble();
|
|
if (fp6 == Direction.SOUTH) {
|
|
double11 += 1.1;
|
|
}
|
|
else {
|
|
double11 += 0.05;
|
|
}
|
|
}
|
|
}
|
|
bjt.addParticle(ParticleTypes.DRIPPING_WATER, double9, double10, double11, 0.0, 0.0, 0.0);
|
|
}
|
|
}
|