Posted July 9, 20187 yr I have an entity that uses world.isDaytime() to check whether it should despawn, however it does not seem to work since they despawn at night. From my entity class: public void onUpdate() { super.onUpdate(); this.motionY *= 0.6000000238418579D; if(this.world.isDaytime()) { if(this.rand.nextInt(1000) == 0) { this.setDead(); System.out.println("despawn"); } } } The console gets flooded with the test message "despawn" during night. Beds use the same boolean so it is clearly working...but not with this entity? SOLVED, solution by diesieben07: it only works on the server side, added check for !this.world.isRemote Edited July 9, 20187 yr by jt9
July 9, 20187 yr I've an idea but for exact explanation I need the full code of the entity. My Projects: Cruelars Triforcemod (1.12 release; 1.14 alpha soon coming) Important: As my mod is on at least 10 different third party sites without my permission, I want to warn you about that with a link to StopModReposts
July 9, 20187 yr Author This is the only relevant piece of code in the entity class. Given that System.out.println("despawn"); is constantly being executed, it shows that the if statement isn't working correctly. I can see the mobs die as soon as I spawn them
July 9, 20187 yr I'm interessed in what it extends My Projects: Cruelars Triforcemod (1.12 release; 1.14 alpha soon coming) Important: As my mod is on at least 10 different third party sites without my permission, I want to warn you about that with a link to StopModReposts
July 9, 20187 yr Author 6 minutes ago, diesieben07 said: isDaytime only works on the server. You need to check if you are on the server before despawning anyways. Oops! That makes sense. Fixed it, thanks
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.