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.resources.ResourceKey;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.server.level.ServerLevel;
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.level.block.state.BlockBehaviour;
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 bpg) {
        return new TheEndPortalBlockEntity();
    }
    
    @Override
    public VoxelShape getShape(final BlockState cfj, final BlockGetter bpg, final BlockPos fu, final CollisionContext der) {
        return EndPortalBlock.SHAPE;
    }
    
    @Override
    public void entityInside(final BlockState cfj, final Level bqb, final BlockPos fu, final Entity aom) {
        if (bqb instanceof ServerLevel && !aom.isPassenger() && !aom.isVehicle() && aom.canChangeDimensions() && Shapes.joinIsNotEmpty(Shapes.create(aom.getBoundingBox().move(-fu.getX(), -fu.getY(), -fu.getZ())), cfj.getShape(bqb, fu), BooleanOp.AND)) {
            final ResourceKey<Level> ug6 = (bqb.dimension() == Level.END) ? Level.OVERWORLD : Level.END;
            final ServerLevel zd7 = ((ServerLevel)bqb).getServer().getLevel(ug6);
            if (zd7 == null) {
                return;
            }
            aom.changeDimension(zd7);
        }
    }
    
    @Override
    public void animateTick(final BlockState cfj, final Level bqb, final BlockPos fu, final Random random) {
        final double double6 = fu.getX() + random.nextDouble();
        final double double7 = fu.getY() + 0.8;
        final double double8 = fu.getZ() + random.nextDouble();
        bqb.addParticle(ParticleTypes.SMOKE, double6, double7, double8, 0.0, 0.0, 0.0);
    }
    
    @Override
    public ItemStack getCloneItemStack(final BlockGetter bpg, final BlockPos fu, final BlockState cfj) {
        return ItemStack.EMPTY;
    }
    
    @Override
    public boolean canBeReplaced(final BlockState cfj, final Fluid cwz) {
        return false;
    }
    
    static {
        SHAPE = Block.box(0.0, 0.0, 0.0, 16.0, 12.0, 16.0);
    }
}
