Make Apiarist's Armor protect against potion effects from bees

This commit is contained in:
mezz committed 2014-12-04 00:12:07 -08:00
1 parent 475d99eae8
commit b2d722a4c5
1 file changed
+28 -11
@@ -10,25 +10,25 @@
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.List;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.apiculture.items.ItemArmorApiarist;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import java.util.List;
public class AlleleEffectPotion extends AlleleEffectThrottled {
private int potionId = 0;
private final Potion potion;
private final int duration;
public AlleleEffectPotion(String uid, String name, boolean isDominant, Potion potion, int duration, boolean requiresWorking) {
super(uid, name, isDominant, 200, requiresWorking, false);
potionId = potion.getId();
this.potion = potion;
this.duration = duration;
}
@@ -39,12 +39,29 @@ public class AlleleEffectPotion extends AlleleEffectThrottled {
return storedData;
AxisAlignedBB beatifyBox = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
List list = housing.getWorld().getEntitiesWithinAABB(EntityPlayer.class, beatifyBox);
for (Object obj : list) {
EntityPlayer player = (EntityPlayer) obj;
player.addPotionEffect(new PotionEffect(potionId, duration, 0));
for (Object entity : list) {
if (!(entity instanceof EntityPlayer))
continue;
EntityPlayer player = (EntityPlayer) entity;
int duration = this.duration;
if (potion.isBadEffect()) {
// Players are not attacked if they wear a full set of apiarist's armor.
int count = ItemArmorApiarist.wearsItems((EntityPlayer) entity, getUID(), true);
if (count >= 4)
continue; // Full set, no damage/effect
else if (count == 3)
duration = this.duration / 4;
else if (count == 2)
duration = this.duration / 2;
else if (count == 1)
duration = this.duration * 3 / 4;
}
player.addPotionEffect(new PotionEffect(potion.getId(), duration, 0));
}
return storedData;