Jump to content

(1.14.4) Potion effect wont remove


ImperialDragon99

Recommended Posts

Im making a custom swordItem that gives the player the wither effect when you right click the sword and when you click it again the effect goes away. My problem is when I try and get rid of the effect it visually goes away but im still taking damage and after a few seconds the visual effect comes back. http://prntscr.com/p8poj9

Edited by ImperialDragon99
Link to comment
Share on other sites

  • 2 weeks later...
9 minutes ago, ImperialDragon99 said:

How do you modify potions server side?

Make sure World#isRemote is false.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

49 minutes ago, ImperialDragon99 said:

How would I get a line of code to run on the logical server?

You query the isRemote field of a World object...

if (!world.isRemote) { /*Whatever*/ }

...where world is an instance of World.

 

Fancy 3D Graphing Calculator mod, with many different coordinate systems.

Lightweight 3D/2D position/vector transformations library, also with support for different coordinate systems.

Link to comment
Share on other sites

2 hours ago, diesieben07 said:

You can't "make it run" on the logical server. Either the method you are using is called on only one side (then you dont need to check) or it's called on both sides, then you can use isRemote to check the current one.

So I checked world.isremote and it = true right now which means its on the logical client. Thats interesting and all but how could I get playerIn.removeActivePotionEffect(Effects.WITHER); to actually remove the effect?

Link to comment
Share on other sites

2 hours ago, ImperialDragon99 said:

So I checked world.isremote and it = true right now which means its on the logical client.

It should be called twice. Post your updated code.

 

2 hours ago, ImperialDragon99 said:

but how could I get playerIn.removeActivePotionEffect(Effects.WITHER); to actually remove the effect?

You have to do it on the logical server.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

10 minutes ago, Animefan8888 said:

It should be called twice. Post your updated code.

 

You have to do it on the logical server.

public class WitherSwordItem extends SwordItem{

    private ArrayList<String> active = new ArrayList<String>();
    private CoolDowns cooldown = new CoolDowns();

    public WitherSwordItem(IItemTier p_i484601, int p_i484602, float p_i484603, Properties p_i484604) {
        super(p_i484601, p_i484602, p_i484603, p_i484604);
    }
    
    @Override
    public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn){

        String pName = playerIn.getDisplayName().toString();
        ItemStack item = playerIn.getHeldItem(handIn);
        if(!worldIn.isRemote) {
            if (cooldown.isDone("WitherSwordRightClick", pName , 3000)){
                if(!active.contains(pName)){
                    System.out.println("On");
                    active.add(pName);
                    playerIn.addPotionEffect(new EffectInstance(Effects.WITHER, 999999999, 0));
                    playerIn.playSound(SoundEvents.ENTITY_WITHER_AMBIENT, 100, 0);
                }else{
                    System.out.println("Off");
                    active.remove(pName);
                    System.out.println(worldIn.isRemote());
                    playerIn.removeActivePotionEffect(Effects.WITHER);
                    playerIn.playSound(SoundEvents.BLOCK_LAVA_EXTINGUISH, 100, 0);
                    
               
                }
            item.damageItem(1, playerIn, null);
            }

        }
        return new ActionResult<ItemStack>(ActionResultType.SUCCESS, item);
    }
    
}

I know if(!worldIn.isRemote) makes it false but the code doesn't run, I'm sorry i'm not getting how to do this

Link to comment
Share on other sites

4 minutes ago, ImperialDragon99 said:

the code doesn't run

Which part of the code? All of it(the method never gets called)? Past a certain if statement?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

23 minutes ago, ImperialDragon99 said:

  Well all the code runs but the playsound, addpotioneffect, removepotioneffect does nothing when I have if(!worldIn.isremote)

How did you confirm this? Those methods should all work save for the EntityPlayer#playSound which doesnt work on the logical server you need to use another method. See here for more info.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

7 minutes ago, Animefan8888 said:

How did you confirm this? Those methods should all work save for the EntityPlayer#playSound which doesnt work on the logical server you need to use another method. See here for more info.

I managed to get everything to work except getting rid of the wither effect on the client side, I made a if(worldIn.isremote) statement to add the sounds which works fine. How would I get rid of the visual effect client side?

Link to comment
Share on other sites

2 minutes ago, ImperialDragon99 said:

I made a if(worldIn.isremote) statement to add the sounds which works fine.

No don't do that. That's not what you should do at all use one of the other methods of playing a sound.

 

2 minutes ago, ImperialDragon99 said:

How would I get rid of the visual effect client side?

It should go away when you remove it on the server.

Edited by Animefan8888

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

1 minute ago, Animefan8888 said:

No don't do that. That's not what you should do at all use one of the other methods of playing a sound.

 

It should go away when you remove it from the server.

The damage dealing goes away but the visual effect stays, isn't checking if world.isremote is false doing it server side?

Link to comment
Share on other sites

2 hours ago, diesieben07 said:

Post updated code.

public class WitherSwordItem extends SwordItem{

    private ArrayList<String> active = new ArrayList<String>();
    private CoolDowns cooldown = new CoolDowns();

    public WitherSwordItem(IItemTier p_i484601, int damage, float p_i484603, Properties p_i484604) {
        super(p_i484601, damage, p_i484603, p_i484604);
    }
    
    @Override
    public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn){

        String pName = playerIn.getDisplayName().toString();
        ItemStack item = playerIn.getHeldItem(handIn);
        if(!worldIn.isRemote) {
            if (cooldown.isDone("WitherSwordRightClick", pName , 3000)){
                if(!active.contains(pName)){
                    System.out.println("On");
                    active.add(pName);
                    playerIn.addPotionEffect(new EffectInstance(Effects.WITHER, 999999999, 0));
                    item.addAttributeModifier(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier",10, AttributeModifier.Operation.ADDITION), EquipmentSlotType.MAINHAND);
                    item.damageItem(100, playerIn, null);
                
                    
                }else{
                    System.out.println("Off");
                    active.remove(pName);
                    playerIn.removeActivePotionEffect(Effects.WITHER);
                    
               }
            }
            

        }
        
        if(worldIn.isRemote) {
            if (cooldown.isDone("WitherSwordRightClick2", pName , 3000)){
                if(!active.contains(pName)) {
                    playerIn.playSound(SoundEvents.ENTITY_WITHER_AMBIENT, 30, 0);
                
                }else {
                    playerIn.playSound(SoundEvents.BLOCK_LAVA_EXTINGUISH, 30, 0);
                }
            }
    }
        return new ActionResult<ItemStack>(ActionResultType.SUCCESS, item);
    }
}

Link to comment
Share on other sites

3 minutes ago, EhAdam said:

No. Capabilities exist.

Also good job linking someone using 1.14.4 to the 1.9.4 documentation.

Edited by Draco18s
  • Like 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Baba  Serege [[+27-73 590 8989]] has experience of 27 years in helping and guiding many people from all over the world. His psychic abilities may help you answer and resolve many unanswered questions. He specialize in helping women and men from all walks of life.. 1) – Bring back lost lover. even if lost for a long time. 2) – My lover is abusing alcohol, partying and cheating on me I urgently need help” 3) – Divorce or court issues. 4) – Is your love falling apart? 5) – Do you want your love to grow stronger? 6) – Is your partner losing interest in you? 7) – Do you want to catch your partner cheating on you? – We help to keep your partner faithful and loyal to you. 9) – We recover love and happiness when relationship breaks down. 10) – Making your partner loves you alone. 11) – We create loyalty and everlasting love between couples. 12) – Get a divorce settlement quickly from your ex-partner. 13) – We create everlasting love between couples. 14) – We help you look for the best suitable partner. 15) – We bring back lost lover even if lost for a long time. 16) – We strengthen bonds in all love relationship and marriages 17) – Are you an herbalist who wants to get more powers? 18) – Buy a house or car of your dream. 19) – Unfinished jobs by other doctors come to me. 20) – I help those seeking employment. 21) – Pensioners free treatment. 22) – Win business tenders and contracts. 23) – Do you need to recover your lost property? 24) – Promotion at work and better pay. 25) – Do you want to be protected from bad spirits and nightmares? 26) – Financial problems. 27) – Why you can’t keep money or lovers? 28) – Why you have a lot of enemies? 29) – Why you are fired regularly on jobs? 30) – Speed up money claim spell, delayed payments, pension and accident funds 31) – I help students pass their exams/interviews. 33) – Removal of bad luck and debts. 34) – Are struggling to sleep because of a spiritual wife or husband. 35- ) Recover stolen property
    • OLXTOTO adalah situs bandar togel online resmi terbesar dan terpercaya di Indonesia. Bergabunglah dengan OLXTOTO dan nikmati pengalaman bermain togel yang aman dan terjamin. Koleksi toto 4D dan togel toto terlengkap di OLXTOTO membuat para member memiliki pilihan taruhan yang lebih banyak. Sebagai situs togel terpercaya, OLXTOTO menjaga keamanan dan kenyamanan para membernya dengan sistem keamanan terbaik dan enkripsi data. Transaksi yang cepat, aman, dan terpercaya merupakan jaminan dari OLXTOTO. Nikmati layanan situs toto terbaik dari OLXTOTO dengan tampilan yang user-friendly dan mudah digunakan. Layanan pelanggan tersedia 24/7 untuk membantu para member. Bergabunglah dengan OLXTOTO sekarang untuk merasakan pengalaman bermain togel yang menyenangkan dan menguntungkan.
    • Baba  Serege [[+27-73 590 8989]] has experience of 27 years in helping and guiding many people from all over the world. His psychic abilities may help you answer and resolve many unanswered questions. He specialize in helping women and men from all walks of life.. 1) – Bring back lost lover. even if lost for a long time. 2) – My lover is abusing alcohol, partying and cheating on me I urgently need help” 3) – Divorce or court issues. 4) – Is your love falling apart? 5) – Do you want your love to grow stronger? 6) – Is your partner losing interest in you? 7) – Do you want to catch your partner cheating on you? – We help to keep your partner faithful and loyal to you. 9) – We recover love and happiness when relationship breaks down. 10) – Making your partner loves you alone. 11) – We create loyalty and everlasting love between couples. 12) – Get a divorce settlement quickly from your ex-partner. 13) – We create everlasting love between couples. 14) – We help you look for the best suitable partner. 15) – We bring back lost lover even if lost for a long time. 16) – We strengthen bonds in all love relationship and marriages 17) – Are you an herbalist who wants to get more powers? 18) – Buy a house or car of your dream. 19) – Unfinished jobs by other doctors come to me. 20) – I help those seeking employment. 21) – Pensioners free treatment. 22) – Win business tenders and contracts. 23) – Do you need to recover your lost property? 24) – Promotion at work and better pay. 25) – Do you want to be protected from bad spirits and nightmares? 26) – Financial problems. 27) – Why you can’t keep money or lovers? 28) – Why you have a lot of enemies? 29) – Why you are fired regularly on jobs? 30) – Speed up money claim spell, delayed payments, pension and accident funds 31) – I help students pass their exams/interviews. 33) – Removal of bad luck and debts. 34) – Are struggling to sleep because of a spiritual wife or husband. 35- ) Recover stolen property
  • Topics

×
×
  • Create New...

Important Information

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