<commit_before>package net.mcft.copy.betterstorage.addon.thaumcraft;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.mcft.copy.betterstorage.Config;
import net.mcft.copy.betterstorage.item.ItemBackpack;
import net.mcft.copy.betterstorage.utils.RandomUtils;
import net.mcft.copy.betterstorage.utils.StackUtils;
import net.mcft.copy.betterstorage.utils.WorldUtils;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet28EntityVelocity;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;

import thaumcraft.api.EnumTag;

public abstract class BackpackFluxEffect {
	
	public static Map<EnumTag, BackpackFluxEffect> effects = new HashMap<EnumTag, BackpackFluxEffect>();
	
	static {
		new BackpackFluxEffect(EnumTag.WIND) { @Override public void apply(EntityPlayer player, ItemStack backpack) {
			float motionY = RandomUtils.getFloat(0.3F, 0.65F);
			Packet packet = new Packet28EntityVelocity(player.entityId, 0, motionY, 0);
			((EntityPlayerMP)player).playerNetServerHandler.sendPacketToPlayer(packet);
			player.worldObj.playSoundAtEntity(player, "random.breath", 0.75F, 0.5F);
		} };
		new BackpackFluxEffect(EnumTag.FIRE) { @Override public void apply(EntityPlayer player, ItemStack backpack) {
			player.setFire(RandomUtils.getInt(1, 3));
			player.worldObj.playSoundAtEntity(player, "random.breath", 0.75F, 0.5F);
		} };
		new BackpackFluxEffect(EnumTag.SOUND) { @Override public void apply(EntityPlayer player, ItemStack backpack) {
			player.worldObj.playSoundAtEntity(player, "enderdragon.growl", 1.2F, 0.75F);
		} };
		new BackpackFluxEffect(EnumTag.LIFE) { @Override public void apply(EntityPlayer player, ItemStack backpack) {
			player.addPotionEffect(new PotionEffect(Potion.regeneration.id, RandomUtils.getInt(3 * 20, 5 * 20),0));
			player.worldObj.playSoundAtEntity(player, "random.breath", 0.75F, 0.5F);
		} };
		new BackpackFluxEffect(EnumTag.DEATH) { @Override public void apply(EntityPlayer player, ItemStack backpack) {
			player.addPotionEffect(new PotionEffect(Potion.wither.id, RandomUtils.getInt(2 * 20, 4 * 20), 0));
			player.worldObj.playSoundAtEntity(player, "random.breath", 0.75F, 0.5F);
		} };
		new BackpackFluxEffect(EnumTag.VOID) { @Override public void apply(EntityPlayer player, ItemStack backpack) {
			int size = Config.backpackRows * ((ItemBackpack)backpack.getItem()).getColumns();
			ItemStack[] contents = StackUtils.getStackContents(backpack, size);
			List<Integer> indices = new ArrayList<Integer>();
			for (int i = 0; i < contents.length; i++)
				if (contents[i] != null) indices.add(i);
			if (indices.size() <= 0) return;
			int index = indices.get(RandomUtils.getInt(indices.size()));
			ItemStack item = contents[index].splitStack(1);
			WorldUtils.dropStackFromEntity(player, item).delayBeforeCanPickup = 8;
			if (contents[index].stackSize <= 0)
				contents[index] = null;
			StackUtils.setStackContents(backpack, contents);
			player.worldObj.playSoundAtEntity(player, "random.pop", 0.75F, 0.5F);
		} };
		new BackpackFluxEffect(EnumTag.VISION) { @Override public void apply(EntityPlayer player, ItemStack backpack) {
			if (RandomUtils.getFloat() < 0.5)
				player.addPotionEffect(new PotionEffect(Potion.nightVision.id, RandomUtils.getInt(3 * 20, 8 * 20), 0));
			else player.addPotionEffect(new PotionEffect(Potion.confusion.id, RandomUtils.getInt(2 * 20, 7 * 20), 0));
			player.worldObj.playSoundAtEntity(player, "random.breath", 0.75F, 0.5F);
		} };
		new BackpackFluxEffect(EnumTag.KNOWLEDGE) { @Override public void apply(EntityPlayer player, ItemStack backpack) {
			if (RandomUtils.getFloat() < 0.5) player.addExperienceLevel(1);
			else player.addExperienceLevel(-1);
			player.worldObj.playSoundAtEntity(player, "random.levelup", 0.75F, 0.5F);
		} };
		new BackpackFluxEffect(EnumTag.DESTRUCTION) { @Override public void apply(EntityPlayer player, ItemStack backpack) {
			((ItemBackpack)backpack.getItem()).damageArmor(player, backpack, DamageSource.magic, 8, 0);
			if (backpack.stackSize <= 0)
				player.inventory.armorInventory[2] = null;
			player.worldObj.playSoundAtEntity(player, "random.break", 0.75F, 0.5F);<commit_msg>Fix BackpackFluxEffect for void aspect<commit_after>package net.mcft.copy.betterstorage.addon.thaumcraft;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.mcft.copy.betterstorage.item.ItemBackpack;
import net.mcft.copy.betterstorage.utils.RandomUtils;
import net.mcft.copy.betterstorage.utils.WorldUtils;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet28EntityVelocity;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;

import thaumcraft.api.EnumTag;

public abstract class BackpackFluxEffect {
	
	public static Map<EnumTag, BackpackFluxEffect> effects = new HashMap<EnumTag, BackpackFluxEffect>();
	
	static {
		new BackpackFluxEffect(EnumTag.WIND) { @Override public void apply(EntityPlayer player, ItemStack backpack) {
			float motionY = RandomUtils.getFloat(0.3F, 0.65F);
			Packet packet = new Packet28EntityVelocity(player.entityId, 0, motionY, 0);
			((EntityPlayerMP)player).playerNetServerHandler.sendPacketToPlayer(packet);
			player.worldObj.playSoundAtEntity(player, "random.breath", 0.75F, 0.5F);
		} };
		new BackpackFluxEffect(EnumTag.FIRE) { @Override public void apply(EntityPlayer player, ItemStack backpack) {
			player.setFire(RandomUtils.getInt(1, 3));
			player.worldObj.playSoundAtEntity(player, "random.breath", 0.75F, 0.5F);
		} };
		new BackpackFluxEffect(EnumTag.SOUND) { @Override public void apply(EntityPlayer player, ItemStack backpack) {
			player.worldObj.playSoundAtEntity(player, "enderdragon.growl", 1.2F, 0.75F);
		} };
		new BackpackFluxEffect(EnumTag.LIFE) { @Override public void apply(EntityPlayer player, ItemStack backpack) {
			player.addPotionEffect(new PotionEffect(Potion.regeneration.id, RandomUtils.getInt(3 * 20, 5 * 20),0));
			player.worldObj.playSoundAtEntity(player, "random.breath", 0.75F, 0.5F);
		} };
		new BackpackFluxEffect(EnumTag.DEATH) { @Override public void apply(EntityPlayer player, ItemStack backpack) {
			player.addPotionEffect(new PotionEffect(Potion.wither.id, RandomUtils.getInt(2 * 20, 4 * 20), 0));
			player.worldObj.playSoundAtEntity(player, "random.breath", 0.75F, 0.5F);
		} };
		new BackpackFluxEffect(EnumTag.VOID) { @Override public void apply(EntityPlayer player, ItemStack backpack) {
			ItemBackpack backpackType = (ItemBackpack)backpack.getItem();
			int size = backpackType.getRows() * backpackType.getColumns();
			IInventory inventory = ItemBackpack.getBackpackItems(player);
			List<Integer> indices = new ArrayList<Integer>();
			for (int i = 0; i < inventory.getSizeInventory(); i++)
				if (inventory.getStackInSlot(i) != null) indices.add(i);
			if (indices.size() <= 0) return;
			int index = indices.get(RandomUtils.getInt(indices.size()));
			ItemStack item = inventory.getStackInSlot(index).copy();
			ItemStack drop = item.splitStack(1);
			WorldUtils.dropStackFromEntity(player, drop).delayBeforeCanPickup = 8;
			if (item.stackSize <= 0) item = null;
			inventory.setInventorySlotContents(index, item);
			player.worldObj.playSoundAtEntity(player, "random.pop", 0.75F, 0.5F);
		} };
		new BackpackFluxEffect(EnumTag.VISION) { @Override public void apply(EntityPlayer player, ItemStack backpack) {
			if (RandomUtils.getFloat() < 0.5)
				player.addPotionEffect(new PotionEffect(Potion.nightVision.id, RandomUtils.getInt(3 * 20, 8 * 20), 0));
			else player.addPotionEffect(new PotionEffect(Potion.confusion.id, RandomUtils.getInt(2 * 20, 7 * 20), 0));
			player.worldObj.playSoundAtEntity(player, "random.breath", 0.75F, 0.5F);
		} };
		new BackpackFluxEffect(EnumTag.KNOWLEDGE) { @Override public void apply(EntityPlayer player, ItemStack backpack) {
			if (RandomUtils.getFloat() < 0.5) player.addExperienceLevel(1);
			else player.addExperienceLevel(-1);
			player.worldObj.playSoundAtEntity(player, "random.levelup", 0.75F, 0.5F);
		} };
		new BackpackFluxEffect(EnumTag.DESTRUCTION) { @Override public void apply(EntityPlayer player, ItemStack backpack) {
			((ItemBackpack)backpack.getItem()).damageArmor(player, backpack, DamageSource.magic, 8, 0);
			if (backpack.stackSize <= 0)
				player.inventory.armorInventory[2] = null;
			player.worldObj.playSoundAtEntity(player, "random.break", 0.75F, 0.5F);
{'fraction_non_alphanumeric': 0.12739634418189924, 'fraction_numerical': 0.02251448952296032, 'mean_word_length': 5.681310498883097, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5397804', 'n_tokens_mistral': 3247, 'n_tokens_neox': 2934, 'n_words': 554}