HeidFanatic Posted April 25, 2021 Posted April 25, 2021 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! Quote
HeidFanatic Posted April 25, 2021 Author Posted April 25, 2021 On 4/25/2021 at 8:13 AM, diesieben07 said: First of all, TickEvent always fires twice every tick, check TickEvent#phase. Other than that, the code looks correct and should work. Expand Thank you. I'll Check it. Quote
Recommended Posts
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.