81 lines
3.4 KiB
Java
81 lines
3.4 KiB
Java
package net.minecraft.world.level.block;
|
|
|
|
import net.minecraft.world.level.pathfinder.PathComputationType;
|
|
import net.minecraft.world.level.LevelReader;
|
|
import net.minecraft.core.particles.ParticleOptions;
|
|
import net.minecraft.core.particles.ParticleTypes;
|
|
import net.minecraft.util.Mth;
|
|
import net.minecraft.world.InteractionResult;
|
|
import net.minecraft.world.phys.BlockHitResult;
|
|
import net.minecraft.world.InteractionHand;
|
|
import net.minecraft.world.entity.player.Player;
|
|
import net.minecraft.world.level.Level;
|
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.world.level.BlockGetter;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
|
|
public class DragonEggBlock extends FallingBlock {
|
|
protected static final VoxelShape SHAPE;
|
|
|
|
public DragonEggBlock(final Properties c) {
|
|
super(c);
|
|
}
|
|
|
|
@Override
|
|
public VoxelShape getShape(final BlockState byg, final BlockGetter bjd, final BlockPos fk, final CollisionContext cvn) {
|
|
return DragonEggBlock.SHAPE;
|
|
}
|
|
|
|
@Override
|
|
public InteractionResult use(final BlockState byg, final Level bjt, final BlockPos fk, final Player ayg, final InteractionHand ajh, final BlockHitResult cvd) {
|
|
this.teleport(byg, bjt, fk);
|
|
return InteractionResult.SUCCESS;
|
|
}
|
|
|
|
@Override
|
|
public void attack(final BlockState byg, final Level bjt, final BlockPos fk, final Player ayg) {
|
|
this.teleport(byg, bjt, fk);
|
|
}
|
|
|
|
private void teleport(final BlockState byg, final Level bjt, final BlockPos fk) {
|
|
for (int integer5 = 0; integer5 < 1000; ++integer5) {
|
|
final BlockPos fk2 = fk.offset(bjt.random.nextInt(16) - bjt.random.nextInt(16), bjt.random.nextInt(8) - bjt.random.nextInt(8), bjt.random.nextInt(16) - bjt.random.nextInt(16));
|
|
if (bjt.getBlockState(fk2).isAir()) {
|
|
if (bjt.isClientSide) {
|
|
for (int integer6 = 0; integer6 < 128; ++integer6) {
|
|
final double double8 = bjt.random.nextDouble();
|
|
final float float10 = (bjt.random.nextFloat() - 0.5f) * 0.2f;
|
|
final float float11 = (bjt.random.nextFloat() - 0.5f) * 0.2f;
|
|
final float float12 = (bjt.random.nextFloat() - 0.5f) * 0.2f;
|
|
final double double9 = Mth.lerp(double8, fk2.getX(), fk.getX()) + (bjt.random.nextDouble() - 0.5) + 0.5;
|
|
final double double10 = Mth.lerp(double8, fk2.getY(), fk.getY()) + bjt.random.nextDouble() - 0.5;
|
|
final double double11 = Mth.lerp(double8, fk2.getZ(), fk.getZ()) + (bjt.random.nextDouble() - 0.5) + 0.5;
|
|
bjt.addParticle(ParticleTypes.PORTAL, double9, double10, double11, float10, float11, float12);
|
|
}
|
|
}
|
|
else {
|
|
bjt.setBlock(fk2, byg, 2);
|
|
bjt.removeBlock(fk, false);
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public int getTickDelay(final LevelReader bjw) {
|
|
return 5;
|
|
}
|
|
|
|
@Override
|
|
public boolean isPathfindable(final BlockState byg, final BlockGetter bjd, final BlockPos fk, final PathComputationType cqo) {
|
|
return false;
|
|
}
|
|
|
|
static {
|
|
SHAPE = Block.box(1.0, 0.0, 1.0, 15.0, 16.0, 15.0);
|
|
}
|
|
}
|