package net.minecraft.block;

import javax.annotation.Nullable;

import net.hoosiertransfer.EaglerItems;
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityEndGateway;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class BlockEndGateway extends BlockContainer {
    protected BlockEndGateway(Material p_i46687_1_) {
        super(p_i46687_1_);
        this.setLightLevel(1.0F);
    }

    public TileEntity createNewTileEntity(World worldIn, int meta) {
        return new TileEntityEndGateway();
    }

    public boolean shouldSideBeRendered(IBlockAccess iblockaccess, BlockPos blockpos, EnumFacing enumfacing) {
        IBlockState iblockstate = iblockaccess.getBlockState(blockpos.offset(enumfacing));
        Block block = iblockstate.getBlock();
        return !iblockstate.getBlock().isOpaqueCube() && block != EaglerItems.getEaglerBlock("end_gateway");
    }

    public AxisAlignedBB getCollisionBoundingBox(World var1, BlockPos var2, IBlockState var3) {
        return null;
    }

    /**
     * Used to determine ambient occlusion and culling when rebuilding chunks for
     * render
     */
    public boolean isOpaqueCube() {
        return false;
    }

    public boolean isFullCube() {
        return false;
    }

    public int quantityDropped(EaglercraftRandom random) {
        return 0;
    }

    public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, EaglercraftRandom rand) {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityEndGateway) {
            int i = ((TileEntityEndGateway) tileentity).getParticleAmount();

            for (int j = 0; j < i; ++j) {
                double d0 = (double) ((float) pos.getX() + rand.nextFloat());
                double d1 = (double) ((float) pos.getY() + rand.nextFloat());
                double d2 = (double) ((float) pos.getZ() + rand.nextFloat());
                double d3 = ((double) rand.nextFloat() - 0.5D) * 0.5D;
                double d4 = ((double) rand.nextFloat() - 0.5D) * 0.5D;
                double d5 = ((double) rand.nextFloat() - 0.5D) * 0.5D;
                int k = rand.nextInt(2) * 2 - 1;

                if (rand.nextBoolean()) {
                    d2 = (double) pos.getZ() + 0.5D + 0.25D * (double) k;
                    d5 = (double) (rand.nextFloat() * 2.0F * (float) k);
                } else {
                    d0 = (double) pos.getX() + 0.5D + 0.25D * (double) k;
                    d3 = (double) (rand.nextFloat() * 2.0F * (float) k);
                }

                worldIn.spawnParticle(EnumParticleTypes.PORTAL, d0, d1, d2, d3, d4, d5, new int[0]);
            }
        }
    }

    @Nullable
    public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) {
        return null;
    }

    /**
     * Get the MapColor for this Block and the given BlockState
     */
    public MapColor getMapColor(IBlockState state) {
        return MapColor.blackColor;
    }
}
