Blood Letter's Pack + Coat of Arms

This commit is contained in:
Nick 2015-11-11 10:45:46 -08:00
parent 4b7ad55016
commit 9a6d8d6d60
13 changed files with 317 additions and 21 deletions

View file

@ -1,16 +1,41 @@
package WayofTime.bloodmagic.util.handler;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import WayofTime.bloodmagic.item.gear.ItemPackSacrifice;
import WayofTime.bloodmagic.registry.ModBlocks;
import WayofTime.bloodmagic.registry.ModItems;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.event.entity.player.FillBucketEvent;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
public class EventHandler {
@SubscribeEvent
public void onEntityDeath(LivingHurtEvent event) {
int chestIndex = 2;
if (event.source.getEntity() instanceof EntityPlayer && !PlayerHelper.isFakePlayer((EntityPlayer) event.source.getEntity())) {
EntityPlayer player = (EntityPlayer) event.source.getEntity();
if (player.getCurrentArmor(chestIndex) != null && player.getCurrentArmor(chestIndex).getItem() instanceof ItemPackSacrifice) {
ItemPackSacrifice pack = (ItemPackSacrifice) player.getCurrentArmor(chestIndex).getItem();
boolean shouldSyphon = pack.getStoredLP(player.getCurrentArmor(chestIndex)) < pack.CAPACITY;
int totalLP = Math.round(event.ammount * pack.CONVERSION);
if (shouldSyphon)
pack.addLP(player.getCurrentArmor(chestIndex), totalLP);
}
}
}
@SubscribeEvent
public void onBucketFill(FillBucketEvent event) {
if (event.current.getItem() != Items.bucket)