From 40534627803c80c745e3b225729389de33209e98 Mon Sep 17 00:00:00 2001 From: aromaa Date: Sun, 8 Oct 2023 02:37:12 +0300 Subject: [PATCH] Fix few ChangeDataHolderEvent.ValueChange rejection values --- .../common/mixin/core/server/level/ServerPlayerMixin.java | 2 +- .../common/mixin/core/world/entity/EntityMixin.java | 4 ++-- .../common/mixin/core/world/food/FoodDataMixin.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/server/level/ServerPlayerMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/server/level/ServerPlayerMixin.java index b770fc10d49..4067598b88a 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/server/level/ServerPlayerMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/server/level/ServerPlayerMixin.java @@ -881,7 +881,7 @@ public void sendMessage(final OutgoingChatMessage $$0, final boolean $$1, final return (GameType) (Object) event.endResult().successfulValue(Keys.GAME_MODE) .map(Value::get) - .orElse((GameMode) (Object) value); + .orElse((GameMode) (Object) this.gameMode.getGameModeForPlayer()); } @Override diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/EntityMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/EntityMixin.java index 1c913c56bfc..e73b4d1627d 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/EntityMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/EntityMixin.java @@ -1170,10 +1170,10 @@ public void stopRiding() { //If the event is cancelled, well, don't change the underlying value. return; } - this.remainingFireTicks = valueChange.endResult().successfulValue(Keys.FIRE_TICKS) + valueChange.endResult().successfulValue(Keys.FIRE_TICKS) .map(Value::get) .map(t -> (int) t.ticks()) - .orElse(0); + .ifPresent(t -> this.remainingFireTicks = t); } return; } diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/food/FoodDataMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/food/FoodDataMixin.java index aa563a12939..23508dcd0a9 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/food/FoodDataMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/food/FoodDataMixin.java @@ -119,6 +119,6 @@ public abstract class FoodDataMixin implements FoodDataBridge { return event.endResult().successfulValue(key) .map(Value::get) - .orElse(value); + .orElse(currentValue); } }