Implemented a "Constriction" potion, which prevents using items in your hand (will be refined later)

This commit is contained in:
WayofTime 2016-07-25 17:42:54 -04:00
parent 9cfc8870c1
commit 2af621cced
2 changed files with 17 additions and 0 deletions

View file

@ -18,6 +18,7 @@ public class ModPotions
public static Potion soulSnare;
public static Potion soulFray;
public static Potion fireFuse;
public static Potion constrict;
public static void init()
{
@ -42,6 +43,7 @@ public class ModPotions
PlayerSacrificeHelper.soulFrayId = soulFray;
fireFuse = registerPotion("Fire Fuse", new ResourceLocation("fireFuse"), true, 0xFF3333, 5, 0);
constrict = registerPotion("Constriction", new ResourceLocation("constrict"), true, 0x000000, 6, 0);
// heavyHeart = new PotionBloodMagic("Heavy Heart", new
// ResourceLocation(resourceLocation +
// heavyHeart.getName().toLowerCase()), true, 0, 0, 0);

View file

@ -13,6 +13,7 @@ import net.minecraft.init.Enchantments;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.common.MinecraftForge;
@ -63,6 +64,20 @@ import com.google.common.base.Strings;
@Handler
public class GenericHandler
{
@SubscribeEvent
public void onPlayerClick(PlayerInteractEvent event)
{
if (event.isCancelable() && event.getEntityPlayer().isPotionActive(ModPotions.constrict))
{
EntityPlayer player = event.getEntityPlayer();
int level = player.getActivePotionEffect(ModPotions.constrict).getAmplifier();
if (event.getHand() == EnumHand.OFF_HAND || level > 1)
{
event.setCanceled(true);
}
}
}
@SubscribeEvent
public void onEntityHurt(LivingHurtEvent event)
{