• 0

    posted a message on Start an effect Right After the another one ends

    Feel dumb to post here again in less then a week but... I´m trying to make an ablity on my weapon that adds an slowness effect when the other 3 effects are gone Is there any way to do that? also if it helps here is the code of my weapon class

    package com.KiiNGz_8.fantasy_equipment.events;
    
    import com.KiiNGz_8.fantasy_equipment.FantasyEquipment;
    import com.KiiNGz_8.fantasy_equipment.tools.ModItemTier;
    import com.KiiNGz_8.fantasy_equipment.utility.RegistryHandler;
    import net.minecraft.entity.player.PlayerEntity;
    import net.minecraft.inventory.EquipmentSlotType;
    import net.minecraft.item.*;
    import net.minecraft.potion.EffectInstance;
    import net.minecraft.potion.Effects;
    import net.minecraft.util.ActionResult;
    import net.minecraft.util.Hand;
    import net.minecraft.world.World;
    
    public class ForestStriker extends SwordItem{
            public ForestStriker(IItemTier tier, int attackDamageIn, float attackSpeedIn, Item.Properties p_i48460_4_)
    { super(ModItemTier.STRIKER, 2, -2.2F, new Item.Properties().group(FantasyEquipment.TAB)); }
    
        @Override
        public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
            playerIn.getCooldownTracker().setCooldown(RegistryHandler.FOREST_STRIKER.get(), 40 * 20);
            playerIn.addPotionEffect(new EffectInstance(Effects.SPEED, 15 * 20));
            playerIn.addPotionEffect(new EffectInstance(Effects.RESISTANCE, 15 * 20));
            playerIn.addPotionEffect(new EffectInstance(Effects.JUMP_BOOST, 15 * 20));
            playerIn.getItemStackFromSlot(EquipmentSlotType.MAINHAND).damageItem(900, playerIn, e -> e.sendBreakAnimation(EquipmentSlotType.MAINHAND));
            return super.onItemRightClick(worldIn, playerIn, handIn);
            }
    }
    Posted in: Modification Development
  • 0

    posted a message on [Solved] Make an event take durability of a tool

    This works perfectly! thank you so much for your help, also is there some place where you could see all of this methods?

    Posted in: Modification Development
  • 0

    posted a message on [Solved] Make an event take durability of a tool

    Hello guys! I'm making a mod that adds some weapons with abilitys to the game, however when using the ability I want to damage the sword by an x amount of it's durability, its there anyway a could do that?


    package com.KiiNGz_8.fantasy_equipment.events;
    
    import com.KiiNGz_8.fantasy_equipment.FantasyEquipment;
    import com.KiiNGz_8.fantasy_equipment.utility.RegistryHandler;
    import net.minecraft.entity.player.PlayerEntity;
    import net.minecraft.potion.EffectInstance;
    import net.minecraft.potion.Effects;
    import net.minecraftforge.api.distmarker.Dist;
    import net.minecraftforge.event.entity.player.PlayerInteractEvent;
    import net.minecraftforge.eventbus.api.SubscribeEvent;
    import net.minecraftforge.fml.common.Mod;
    
    
    @Mod.EventBusSubscriber(modid = FantasyEquipment.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
    public class WBEvents{
        @SubscribeEvent
        public static void BeastMode(PlayerInteractEvent.RightClickItem event) {
            PlayerEntity player = event.getPlayer();
            if(event.getEntityLiving().getHeldItemMainhand().getItem() == RegistryHandler.WOLFBLOOD_SWORD.get()) {
                player.getCooldownTracker().setCooldown(RegistryHandler.WOLFBLOOD_SWORD.get(), 30*20);
                player.addPotionEffect(new EffectInstance(Effects.SPEED, 10 * 20));
                player.addPotionEffect(new EffectInstance(Effects.STRENGTH, 10 * 20, 1));
            }
        }
    }
    Posted in: Modification Development
  • 0

    posted a message on [SOLVED]Help with cooldown on event

    it works perfectly! :D


    Thank you so much for the help, I've been looking everywhere for a solution but I was only finding a solution for bukkit/spigot

    Posted in: Modification Development
  • 0

    posted a message on [SOLVED]Help with cooldown on event

    Hello everyone! I am new to forge and I starting following a tutorial for this and I need help on my first mod. So what i am trying to do here is to add a cooldown after right clicking. I've done the RightClickItem event and it works correctly however every solution I see uses Spigot or Bukkit and I think thats only for Plugins can Anyone help please?


    Heres the code I have for my event. thanks in advance!


        @SubscribeEvent
        public static void Beastmode(PlayerInteractEvent.RightClickItem event) {
            PlayerEntity player = event.getPlayer();
            if (event.getEntityLiving().getHeldItemMainhand().getItem() == RegistryHandler.WOLFBLOOD_SWORD.get()) {
                player.addPotionEffect(new EffectInstance(Effects.SPEED, 10 * 20));
                player.addPotionEffect(new EffectInstance(Effects.STRENGTH, 10 * 20, 1));
            }
        }
    }
    Posted in: Modification Development
  • To post a comment, please .