66 lines
2.5 KiB
Java
66 lines
2.5 KiB
Java
package net.minecraft.world.level.block;
|
|
|
|
import net.minecraft.world.entity.EntityType;
|
|
import net.minecraft.world.level.material.PushReaction;
|
|
import net.minecraft.world.level.BlockGetter;
|
|
import net.minecraft.world.level.LightLayer;
|
|
import java.util.Random;
|
|
import net.minecraft.server.level.ServerLevel;
|
|
import net.minecraft.world.level.material.Material;
|
|
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
|
import net.minecraft.world.item.enchantment.Enchantments;
|
|
import net.minecraft.world.item.ItemStack;
|
|
import javax.annotation.Nullable;
|
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.world.entity.player.Player;
|
|
import net.minecraft.world.level.Level;
|
|
|
|
public class IceBlock extends HalfTransparentBlock {
|
|
public IceBlock(final Properties c) {
|
|
super(c);
|
|
}
|
|
|
|
@Override
|
|
public void playerDestroy(final Level bjt, final Player ayg, final BlockPos fk, final BlockState byg, @Nullable final BlockEntity bwi, final ItemStack bek) {
|
|
super.playerDestroy(bjt, ayg, fk, byg, bwi, bek);
|
|
if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, bek) == 0) {
|
|
if (bjt.dimension.isUltraWarm()) {
|
|
bjt.removeBlock(fk, false);
|
|
return;
|
|
}
|
|
final Material cok8 = bjt.getBlockState(fk.below()).getMaterial();
|
|
if (cok8.blocksMotion() || cok8.isLiquid()) {
|
|
bjt.setBlockAndUpdate(fk, Blocks.WATER.defaultBlockState());
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void tick(final BlockState byg, final ServerLevel xd, final BlockPos fk, final Random random) {
|
|
if (xd.getBrightness(LightLayer.BLOCK, fk) > 11 - byg.getLightBlock(xd, fk)) {
|
|
this.melt(byg, xd, fk);
|
|
}
|
|
}
|
|
|
|
protected void melt(final BlockState byg, final Level bjt, final BlockPos fk) {
|
|
if (bjt.dimension.isUltraWarm()) {
|
|
bjt.removeBlock(fk, false);
|
|
return;
|
|
}
|
|
bjt.setBlockAndUpdate(fk, Blocks.WATER.defaultBlockState());
|
|
bjt.neighborChanged(fk, Blocks.WATER, fk);
|
|
}
|
|
|
|
@Override
|
|
public PushReaction getPistonPushReaction(final BlockState byg) {
|
|
return PushReaction.NORMAL;
|
|
}
|
|
|
|
@Override
|
|
public boolean isValidSpawn(final BlockState byg, final BlockGetter bjd, final BlockPos fk, final EntityType<?> akr) {
|
|
return akr == EntityType.POLAR_BEAR;
|
|
}
|
|
}
|