package net.minecraft.world.level.block;

import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.item.ItemStack;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleTypes;
import java.util.Random;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.entity.TheEndPortalBlockEntity;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.phys.shapes.VoxelShape;

public class EndPortalBlock extends BaseEntityBlock {
    protected static final VoxelShape SHAPE;
    
    protected EndPortalBlock(final Properties c) {
        super(c);
    }
    
    @Override
    public BlockEntity newBlockEntity(final BlockGetter bjg) {
        return new TheEndPortalBlockEntity();
    }
    
    @Override
    public VoxelShape getShape(final BlockState byj, final BlockGetter bjg, final BlockPos fk, final CollisionContext cvq) {
        return EndPortalBlock.SHAPE;
    }
    
    @Override
    public void entityInside(final BlockState byj, final Level bjw, final BlockPos fk, final Entity akq) {
        if (!bjw.isClientSide && !akq.isPassenger() && !akq.isVehicle() && akq.canChangeDimensions() && Shapes.joinIsNotEmpty(Shapes.create(akq.getBoundingBox().move(-fk.getX(), -fk.getY(), -fk.getZ())), byj.getShape(bjw, fk), BooleanOp.AND)) {
            akq.changeDimension((bjw.dimension.getType() == DimensionType.THE_END) ? DimensionType.OVERWORLD : DimensionType.THE_END);
        }
    }
    
    @Override
    public void animateTick(final BlockState byj, final Level bjw, final BlockPos fk, final Random random) {
        final double double6 = fk.getX() + (double)random.nextFloat();
        final double double7 = fk.getY() + 0.8;
        final double double8 = fk.getZ() + (double)random.nextFloat();
        final double double9 = 0.0;
        final double double10 = 0.0;
        final double double11 = 0.0;
        bjw.addParticle(ParticleTypes.SMOKE, double6, double7, double8, 0.0, 0.0, 0.0);
    }
    
    @Override
    public ItemStack getCloneItemStack(final BlockGetter bjg, final BlockPos fk, final BlockState byj) {
        return ItemStack.EMPTY;
    }
    
    @Override
    public boolean canBeReplaced(final BlockState byj, final Fluid coi) {
        return false;
    }
    
    static {
        SHAPE = Block.box(0.0, 0.0, 0.0, 16.0, 12.0, 16.0);
    }
}
