Jump to content

[1.16.4]Is it a bug with effect after I removed it from server-side? Anyway to bypass it?


Recommended Posts

Posted

I wrote code to remove effect from player suck as blindness under certain situcation:

    @SubscribeEvent
    public static void shadowbornEnchantmentEvent(TickEvent.PlayerTickEvent event){
        if(!event.player.world.isRemote()){
            if(event.player.isPotionActive(Effects.BLINDNESS)){
                if(event.player.world.getLight(new BlockPos(event.player.getPosition()))>=5){
                    if(PlayerUtil.isPlayerArmorEnchanted(event.player,EnchantmentRegistry.shadowborn_enchantment.get())){
                        event.player.removeActivePotionEffect(Effects.BLINDNESS);
                    }
                }
            }
            if(event.player.world.getLight(new BlockPos(event.player.getPosition()))<=5){
                if(PlayerUtil.isPlayerArmorEnchanted(event.player,EnchantmentRegistry.shadowborn_enchantment.get())){
                    if(!event.player.isPotionActive(Effects.NIGHT_VISION)){
                        event.player.addPotionEffect(new EffectInstance(Effects.NIGHT_VISION,1200));
                    }
                }
            }
        }
    }

I think this thing is purely logic-thing so i run it on !world.isRemote, the logic server-side.

But in game(Client), the blindness effect has never been removed.

I checked the debug panel and it's said the the effect has been removed in server-side.

SO is it a bug or I wrote code wrongly? If it's a bug how can I fix or bypass it?

Thanks so much!

Posted
2 hours ago, diesieben07 said:

First of all, TickEvent always fires twice every tick, check TickEvent#phase.

Other than that, the code looks correct and should work.

Thank you. I'll Check it.

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



×
×
  • Create New...

Important Information

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