Jump to content

DasNone

Members
  • Posts

    3
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

DasNone's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Oh right, I'll get on it right away. I will come back for status later on.
  2. I got it now, thank you diesieben07 for the fast reply and help. I didn't really take the route diesieben07 suggested going about it but the code below worked as well and because of that, issues may arise, only time will tell though. Code for anyone interested: package net.dascraft.init; import net.dascraft.Dascraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.PotionEffect; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class DascraftEventHooks { @SubscribeEvent public void onEntityUpdate(LivingUpdateEvent event) { if (event.entityLiving.isPotionActive(Dascraft.protectionPotion)) { if (event.entityLiving.worldObj.rand.nextInt(20) == 0) { if (event.entityLiving instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.entityLiving; player.capabilities.allowEdit = false; player.sendPlayerAbilities(); } } PotionEffect effect = event.entityLiving.getActivePotionEffect(Dascraft.protectionPotion); if (effect.onUpdate(event.entityLiving) && effect.getDuration() == 1) { System.out.println("DOES IT WORK? YES IT DOES."); EntityPlayer player = (EntityPlayer) event.entityLiving; player.capabilities.allowEdit = true; player.sendPlayerAbilities(); return; } } } }
  3. Hello everybody, Just signed up but I have been lurking here for well over 2 years now. Now, my issue is following: Whenever the potion is applied, it works as intended but as soon as it get cancelled out the functions won't get called (tested with the "System.out.println"). package net.dascraft.init; import net.dascraft.Dascraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class DascraftEventHooks { @SubscribeEvent public void onEntityUpdate(LivingUpdateEvent event) { if (event.entityLiving.isPotionActive(Dascraft.protectionPotion)) { if (event.entityLiving.worldObj.rand.nextInt(20) == 0) { if (event.entityLiving instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.entityLiving; player.capabilities.allowEdit = false; player.sendPlayerAbilities(); } if (event.entityLiving.getActivePotionEffect(Dascraft.protectionPotion).getDuration() == 0) { event.entityLiving.removePotionEffect(Dascraft.protectionPotion.id); if (event.entityLiving instanceof EntityPlayer) { System.out.println("DOES IT WORK? YES IT DOES."); EntityPlayer player = (EntityPlayer) event.entityLiving; player.capabilities.allowEdit = true; player.sendPlayerAbilities(); return; } } } } } } I can't figure out for the life of me what's wrong with this code so I figured you might be able to help.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.