Skip to content

Commit

Permalink
fix spawner drops
Browse files Browse the repository at this point in the history
  • Loading branch information
RecursivePineapple committed Dec 29, 2024
1 parent 3f38580 commit a29f669
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.function.Function;

import net.minecraft.block.Block;
Expand All @@ -18,6 +19,7 @@
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidBlock;
Expand Down Expand Up @@ -154,9 +156,19 @@ protected void removeBlock(World world, int x, int y, int z, Block existing, int
} else if (existing == Blocks.water || existing == Blocks.lava) {
givePlayerFluids(new FluidStack(existing == Blocks.water ? FluidRegistry.WATER : FluidRegistry.LAVA, 1000));
} else {
givePlayerItems(
existing.getDrops(world, x, y, z, existingMeta, 0)
.toArray(new ItemStack[0]));
ArrayList<ItemStack> items = existing.getDrops(world, x, y, z, existingMeta, 0);
float chance = ForgeEventFactory.fireBlockHarvesting(items, world, existing, x, y, z, existingMeta, 0, 1, false, player);

Iterator<ItemStack> iter = items.iterator();

while (iter.hasNext()) {
iter.next();
if (world.rand.nextFloat() > chance) {
iter.remove();
}
}

givePlayerItems(items.toArray(new ItemStack[0]));
}

world.setBlockToAir(x, y, z);
Expand Down

0 comments on commit a29f669

Please sign in to comment.