Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package darkevilmac.MotherOfPearl.events;
- import java.util.ArrayList;
- import java.util.Random;
- import net.minecraft.block.BlockClay;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.MathHelper;
- import net.minecraftforge.event.ForgeSubscribe;
- import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;
- import tcc.MotherOfPearl.items.ModItems;
- import darkevilmac.MotherOfPearl.utils.Utilities;
- public class ClayBreakHandler {
- public static Random random = new Random();
- public static final ItemStack clayItemRandom = new ItemStack(Item.clay, Utilities.getRandom(1, 3), 0);
- public static final ItemStack oysterRandom = new ItemStack(ModItems.oyster, Utilities.getRandom(1, 2), 0);
- public static final ItemStack oysterRandomFortune = new ItemStack(ModItems.oyster, Utilities.getRandom(1, 4), 0);
- @ForgeSubscribe
- public void onBlockBreak(HarvestDropsEvent oEvent) {
- if (!oEvent.world.isRemote) {
- if (oEvent.block instanceof BlockClay) {
- GenerateLootList(oEvent.drops,
- Item.clay.itemID,
- ModItems.oyster.itemID,
- ModItems.oyster.itemID,
- oEvent.fortuneLevel);
- oEvent.dropChance = 1.0F;
- return;
- }
- }
- }
- private void GenerateLootList(ArrayList<ItemStack> oList, int cItemID, int oItemID, int foItemID, int flevel)
- {
- int cCount = MathHelper.getRandomIntegerInRange(random, 1, 4);
- int oCount = 4 - cCount;
- int foCount = MathHelper.getRandomIntegerInRange(random, 0, flevel);
- oList.clear();
- for(int i = 0; i < cCount; ++i)
- {
- ItemStack cdrop = new ItemStack(cItemID, 1, 0);
- oList.add(cdrop);
- }
- for(int i = 0; i < oCount; ++i)
- {
- ItemStack odrop = new ItemStack(oItemID, 1, 0);
- oList.add(odrop);
- }
- for(int i = 0; i < foCount; ++i)
- {
- ItemStack fodrop = new ItemStack(foItemID, 1, 0);
- oList.add(fodrop);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment