Jump to content

hungerinpeaceful

Members
  • Posts

    10
  • Joined

  • Last visited

Everything posted by hungerinpeaceful

  1. Wait guys, I still don't don't understand... I shall send my code -- Define the function to decrease hunger local function decreaseHunger(player) local currentHunger = player.getHunger() -- Check if hunger is not already zero if currentHunger > 0 then player.setHunger(currentHunger - 1) end end -- Register event to decrease hunger over time script.registerEvent(EntityPlayer, function(player) while true do -- Decrease hunger every few seconds decreaseHunger(player) script.sleep(1000) -- Sleep for 1 second end end) Any help appriecated. It's been a while since I learnt Javascript or whatever Minecraft is made with... ... ... ... Nicknotname Hungerinpeaceful xx
  2. if(event.player.world.isRemote()) { public void hunger(TickEvent.PlayerTickEvent event) { PlayerEntity player = null; Difficulty difficulty = player.world.getDifficulty(); this.prevFoodLevel = this.foodLevel; if (this.foodExhaustionLevel > 4.0F) { this.foodExhaustionLevel -= 4.0F; if (this.foodSaturationLevel > 0.0F) { this.foodSaturationLevel = Math.max(this.foodSaturationLevel - 1.0F, 0.0F); } else if (difficulty != Difficulty.PEACEFUL) { this.foodLevel = (int) Math.max(this.foodLevel - 1.0f, 0.0f); } } } }
  3. I am getting this error. Cannot resolve symbol event and the word event turns red. How do I fix this?
  4. How would I make my code @SubscribeEvent public void hunger(TickEvent.PlayerTickEvent event) { PlayerEntity player = null; Difficulty difficulty = player.world.getDifficulty(); this.prevFoodLevel = this.foodLevel; if (this.foodExhaustionLevel > 4.0F) { this.foodExhaustionLevel -= 4.0F; if (this.foodSaturationLevel > 0.0F) { this.foodSaturationLevel = Math.max(this.foodSaturationLevel - 1.0F, 0.0F); } else if (difficulty != Difficulty.PEACEFUL) { this.foodLevel = (int) Math.max(this.foodLevel - 1.0f, 0.0f); } } } use world#isRemote?
  5. I read the documentation however I do not understand how to make my event work on the server side only. When I use DistExecuter.runWhenOn runWhenOn cannot be resolved. How could I make my code into server side only?
  6. that didn't work. which event should i use for the event handler?
  7. I don't understand how to do that.
  8. Using PlayerTickEvent and changing the food level that way. Sorry I am a bit of a beginner.
  9. Sorry about that. How would I do that?
  10. I wish to create a forge mod for 1.15.2 which drains the hunger bar in peaceful. I know you can do /gamerule doMobSpawning false but that doesn't stop spawners. In the minecraft code there is a file called FoodStats.java which contains the game logic for hunger. How can I change it so that the hunger goes down in peaceful?
×
×
  • Create New...

Important Information

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