mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
104 lines
6.9 KiB
Diff
104 lines
6.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
Date: Thu, 24 Jun 2021 21:19:30 -0500
|
|
Subject: [PATCH] Burp delay, burp after eating food fills hunger bar
|
|
completely
|
|
|
|
|
|
diff --git a/net/minecraft/world/effect/SaturationMobEffect.java b/net/minecraft/world/effect/SaturationMobEffect.java
|
|
index 837bdc7d6bd4e05b0deded829c678c86ae3d79d5..0c7c0524e487ff32e16dd9939d92bc6441602747 100644
|
|
--- a/net/minecraft/world/effect/SaturationMobEffect.java
|
|
+++ b/net/minecraft/world/effect/SaturationMobEffect.java
|
|
@@ -21,6 +21,7 @@ class SaturationMobEffect extends InstantenousMobEffect {
|
|
int oldFoodLevel = entityhuman.getFoodData().foodLevel;
|
|
org.bukkit.event.entity.FoodLevelChangeEvent event = CraftEventFactory.callFoodLevelChangeEvent(entityhuman, amplifier + 1 + oldFoodLevel);
|
|
if (!event.isCancelled()) {
|
|
+ if (entityhuman.level().purpurConfig.playerBurpWhenFull && event.getFoodLevel() == 20 && oldFoodLevel < 20) entityhuman.burpDelay = entityhuman.level().purpurConfig.playerBurpDelay; // Purpur
|
|
entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, entity.level().purpurConfig.humanSaturationRegenAmount); // Purpur
|
|
}
|
|
|
|
diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java
|
|
index bc3c67e8f70890831a0bb1799a3b7c10852b1273..a8b5869160cb75c314459403a0a229ec68b69086 100644
|
|
--- a/net/minecraft/world/entity/player/Player.java
|
|
+++ b/net/minecraft/world/entity/player/Player.java
|
|
@@ -201,6 +201,7 @@ public abstract class Player extends LivingEntity {
|
|
public boolean affectsSpawning = true; // Paper - Affects Spawning API
|
|
public net.kyori.adventure.util.TriState flyingFallDamage = net.kyori.adventure.util.TriState.NOT_SET; // Paper - flying fall damage
|
|
public int sixRowEnderchestSlotCount = -1; // Purpur
|
|
+ public int burpDelay = 0; // Purpur
|
|
|
|
// CraftBukkit start
|
|
public boolean fauxSleeping;
|
|
@@ -276,6 +277,12 @@ public abstract class Player extends LivingEntity {
|
|
|
|
@Override
|
|
public void tick() {
|
|
+ // Purpur start
|
|
+ if (this.burpDelay > 0 && --this.burpDelay == 0) {
|
|
+ this.level().playSound(null, getX(), getY(), getZ(), SoundEvents.PLAYER_BURP, SoundSource.PLAYERS, 1.0F, this.level().random.nextFloat() * 0.1F + 0.9F);
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
this.noPhysics = this.isSpectator();
|
|
if (this.isSpectator() || this.isPassenger()) {
|
|
this.setOnGround(false);
|
|
diff --git a/net/minecraft/world/food/FoodData.java b/net/minecraft/world/food/FoodData.java
|
|
index 6a686be6a69ae890d519a54ca099d4ba14e5b9e1..4f8ee2e5db3352306f3c035052866d95630f4aaf 100644
|
|
--- a/net/minecraft/world/food/FoodData.java
|
|
+++ b/net/minecraft/world/food/FoodData.java
|
|
@@ -44,6 +44,7 @@ public class FoodData {
|
|
org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityplayer, foodinfo.nutrition() + oldFoodLevel, itemstack);
|
|
|
|
if (!event.isCancelled()) {
|
|
+ if (entityplayer.level().purpurConfig.playerBurpWhenFull && event.getFoodLevel() == 20 && oldFoodLevel < 20) entityplayer.burpDelay = entityplayer.level().purpurConfig.playerBurpDelay; // Purpur
|
|
this.add(event.getFoodLevel() - oldFoodLevel, foodinfo.saturation());
|
|
}
|
|
|
|
diff --git a/net/minecraft/world/food/FoodProperties.java b/net/minecraft/world/food/FoodProperties.java
|
|
index 882b72799ae532f4e181214d5756ec024af223e2..9a3f2a95debcf8b94f7deb375922ea09b30aabab 100644
|
|
--- a/net/minecraft/world/food/FoodProperties.java
|
|
+++ b/net/minecraft/world/food/FoodProperties.java
|
|
@@ -33,7 +33,7 @@ public record FoodProperties(int nutrition, float saturation, boolean canAlwaysE
|
|
world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), (SoundEvent) consumable.sound().value(), SoundSource.NEUTRAL, 1.0F, randomsource.triangle(1.0F, 0.4F));
|
|
if (user instanceof Player entityhuman) {
|
|
entityhuman.getFoodData().eat(this, stack, (ServerPlayer) entityhuman); // CraftBukkit
|
|
- world.playSound((Player) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEvents.PLAYER_BURP, SoundSource.PLAYERS, 0.5F, Mth.randomBetween(randomsource, 0.9F, 1.0F));
|
|
+ //world.playSound((Player) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEvents.PLAYER_BURP, SoundSource.PLAYERS, 0.5F, Mth.randomBetween(randomsource, 0.9F, 1.0F)); // Purpur - moved to Player#tick()
|
|
}
|
|
|
|
}
|
|
diff --git a/net/minecraft/world/level/block/CakeBlock.java b/net/minecraft/world/level/block/CakeBlock.java
|
|
index 648c2510beb162e73aed236a3169d0bbb8fc5050..3563a241c0b697dc0167cf7b1aa73fef7d1e7934 100644
|
|
--- a/net/minecraft/world/level/block/CakeBlock.java
|
|
+++ b/net/minecraft/world/level/block/CakeBlock.java
|
|
@@ -119,6 +119,7 @@ public class CakeBlock extends Block {
|
|
org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(player, 2 + oldFoodLevel);
|
|
|
|
if (!event.isCancelled()) {
|
|
+ if (player.level().purpurConfig.playerBurpWhenFull && event.getFoodLevel() == 20 && oldFoodLevel < 20) player.burpDelay = player.level().purpurConfig.playerBurpDelay; // Purpur
|
|
player.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 0.1F);
|
|
}
|
|
|
|
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
index 2b5543f070925421e3b924e373a9610fd9b24f2a..849532c99cfad2870fd22be6e759e153e8fae10b 100644
|
|
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
@@ -383,6 +383,8 @@ public class PurpurWorldConfig {
|
|
public boolean playerSleepNearMonsters = false;
|
|
public boolean playersSkipNight = true;
|
|
public double playerCriticalDamageMultiplier = 1.5D;
|
|
+ public int playerBurpDelay = 10;
|
|
+ public boolean playerBurpWhenFull = false;
|
|
private void playerSettings() {
|
|
if (PurpurConfig.version < 19) {
|
|
boolean oldVal = getBoolean("gameplay-mechanics.player.idle-timeout.mods-target", idleTimeoutTargetPlayer);
|
|
@@ -403,6 +405,8 @@ public class PurpurWorldConfig {
|
|
playerSleepNearMonsters = getBoolean("gameplay-mechanics.player.sleep-ignore-nearby-mobs", playerSleepNearMonsters);
|
|
playersSkipNight = getBoolean("gameplay-mechanics.player.can-skip-night", playersSkipNight);
|
|
playerCriticalDamageMultiplier = getDouble("gameplay-mechanics.player.critical-damage-multiplier", playerCriticalDamageMultiplier);
|
|
+ playerBurpDelay = getInt("gameplay-mechanics.player.burp-delay", playerBurpDelay);
|
|
+ playerBurpWhenFull = getBoolean("gameplay-mechanics.player.burp-when-full", playerBurpWhenFull);
|
|
}
|
|
|
|
public boolean silkTouchEnabled = false;
|