package net.minecraft.world;

import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.ItemStack;
import net.minecraft.core.NonNullList;
import net.minecraft.world.entity.Entity;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import java.util.Random;

public class Containers {
    private static final Random RANDOM;
    
    public static void dropContents(final Level bqb, final BlockPos fu, final Container amz) {
        dropContents(bqb, fu.getX(), fu.getY(), fu.getZ(), amz);
    }
    
    public static void dropContents(final Level bqb, final Entity aom, final Container amz) {
        dropContents(bqb, aom.getX(), aom.getY(), aom.getZ(), amz);
    }
    
    private static void dropContents(final Level bqb, final double double2, final double double3, final double double4, final Container amz) {
        for (int integer9 = 0; integer9 < amz.getContainerSize(); ++integer9) {
            dropItemStack(bqb, double2, double3, double4, amz.getItem(integer9));
        }
    }
    
    public static void dropContents(final Level bqb, final BlockPos fu, final NonNullList<ItemStack> gi) {
        gi.forEach(bki -> dropItemStack(bqb, fu.getX(), fu.getY(), fu.getZ(), bki));
    }
    
    public static void dropItemStack(final Level bqb, final double double2, final double double3, final double double4, final ItemStack bki) {
        final double double5 = EntityType.ITEM.getWidth();
        final double double6 = 1.0 - double5;
        final double double7 = double5 / 2.0;
        final double double8 = Math.floor(double2) + Containers.RANDOM.nextDouble() * double6 + double7;
        final double double9 = Math.floor(double3) + Containers.RANDOM.nextDouble() * double6;
        final double double10 = Math.floor(double4) + Containers.RANDOM.nextDouble() * double6 + double7;
        while (!bki.isEmpty()) {
            final ItemEntity bbg21 = new ItemEntity(bqb, double8, double9, double10, bki.split(Containers.RANDOM.nextInt(21) + 10));
            final float float22 = 0.05f;
            bbg21.setDeltaMovement(Containers.RANDOM.nextGaussian() * 0.05000000074505806, Containers.RANDOM.nextGaussian() * 0.05000000074505806 + 0.20000000298023224, Containers.RANDOM.nextGaussian() * 0.05000000074505806);
            bqb.addFreshEntity(bbg21);
        }
    }
    
    static {
        RANDOM = new Random();
    }
}
