mirror of
https://github.com/Dreeam-qwq/Gale.git
synced 2025-12-22 16:29:26 +00:00
49 lines
2.8 KiB
Diff
49 lines
2.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
|
Date: Wed, 30 Nov 2022 23:16:04 +0100
|
|
Subject: [PATCH] Prevent entities eating blocks in non-ticking chunks
|
|
|
|
License: MIT (https://opensource.org/licenses/MIT)
|
|
|
|
This patch is based on the following patch:
|
|
"Dont eat blocks in non ticking chunks"
|
|
By: BillyGalbreath <blake.galbreath@gmail.com>
|
|
As part of: Purpur (https://github.com/PurpurMC/Purpur)
|
|
Licensed under: MIT (https://opensource.org/licenses/MIT)
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/EatBlockGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/EatBlockGoal.java
|
|
index 80aa539f7c6a6ee44338de084cdcdf5fb4ef996a..cb8fc8a88c14d2374a0bbe35aa1c2056d625b71c 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/goal/EatBlockGoal.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/EatBlockGoal.java
|
|
@@ -31,10 +31,16 @@ public class EatBlockGoal extends Goal {
|
|
|
|
@Override
|
|
public boolean canUse() {
|
|
+ // Gale start - Purpur - prevent entities eating blocks in non-ticking chunks
|
|
+ BlockPos blockposition = this.mob.blockPosition;
|
|
+ net.minecraft.world.level.chunk.LevelChunk chunk = this.mob.level.getChunkIfLoaded(blockposition);
|
|
+ if (this.mob.level.galeConfig().gameplayMechanics.entitiesCanEatBlocksInNonTickingChunks && (chunk == null || chunk.playerChunk == null || !((net.minecraft.server.level.ServerLevel) this.mob.level).isPositionEntityTicking(blockposition))) {
|
|
+ return false;
|
|
+ }
|
|
+ // Gale end - Purpur - prevent entities eating blocks in non-ticking chunks
|
|
if (this.mob.getRandom().nextInt(this.mob.isBaby() ? 50 : 1000) != 0) {
|
|
return false;
|
|
} else {
|
|
- BlockPos blockposition = this.mob.blockPosition();
|
|
|
|
return EatBlockGoal.IS_TALL_GRASS.test(this.level.getBlockState(blockposition)) ? true : this.level.getBlockState(blockposition.below()).is(Blocks.GRASS_BLOCK);
|
|
}
|
|
diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
|
index 3b023cbd132c6aa263dbbe54ed7d30e1049d3875..9470f4fcca253e722c4120fbab12da3959de60ab 100644
|
|
--- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
|
+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
|
@@ -244,6 +244,8 @@ public class GaleWorldConfiguration extends ConfigurationPart {
|
|
public GameplayMechanics gameplayMechanics;
|
|
public class GameplayMechanics extends ConfigurationPart {
|
|
|
|
+ public boolean entitiesCanEatBlocksInNonTickingChunks = false; // Gale - Purpur - prevent entities eating blocks in non-ticking chunks
|
|
+
|
|
public Fixes fixes;
|
|
public class Fixes extends ConfigurationPart {
|
|
|