9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-21 15:59:23 +00:00

add some patches

This commit is contained in:
NONPLAYT
2025-02-23 01:18:17 +03:00
parent 61cfe231ec
commit 48f4dcad02
10 changed files with 252 additions and 8 deletions

View File

@@ -8,6 +8,8 @@ private-f net.minecraft.world.level.levelgen.RandomState router
private-f net.minecraft.world.level.levelgen.RandomState sampler
public net.minecraft.util.Mth SIN
public net.minecraft.world.entity.ai.Brain sensors
public net.minecraft.world.entity.ai.memory.NearestVisibleLivingEntities lineOfSightTest
public net.minecraft.world.entity.ai.memory.NearestVisibleLivingEntities nearbyEntities
public net.minecraft.world.entity.ai.sensing.Sensor scanRate
public net.minecraft.world.entity.ai.sensing.Sensor timeToTick
public net.minecraft.world.level.ServerExplosion damageSource

View File

@@ -374,6 +374,34 @@ index ec90ea4e66c6c38d7ad41805a16c63e006e44be4..0204fe68c97d152a7c3201620b6709a8
private boolean isAcceptableLandingPosition(ServerLevel level, E entity, BlockPos pos) {
BlockPos blockPos = entity.blockPosition();
diff --git a/net/minecraft/world/entity/ai/sensing/VillagerBabiesSensor.java b/net/minecraft/world/entity/ai/sensing/VillagerBabiesSensor.java
index 24d1928445b5571e040a2b12d5c82e77a880d9bd..dac0a23aebf2dea1972c07d5c82079da7c9837ac 100644
--- a/net/minecraft/world/entity/ai/sensing/VillagerBabiesSensor.java
+++ b/net/minecraft/world/entity/ai/sensing/VillagerBabiesSensor.java
@@ -21,9 +21,22 @@ public class VillagerBabiesSensor extends Sensor<LivingEntity> {
entity.getBrain().setMemory(MemoryModuleType.VISIBLE_VILLAGER_BABIES, this.getNearestVillagerBabies(entity));
}
+ // DivineMC start - Optimize baby villager sensor
private List<LivingEntity> getNearestVillagerBabies(LivingEntity livingEntity) {
- return ImmutableList.copyOf(this.getVisibleEntities(livingEntity).findAll(this::isVillagerBaby));
+ NearestVisibleLivingEntities visibleEntities = this.getVisibleEntities(livingEntity);
+ ImmutableList.Builder<LivingEntity> babies = ImmutableList.builder();
+
+ for (LivingEntity target : visibleEntities.nearbyEntities) {
+ if (target.getType() == EntityType.VILLAGER
+ && target.isBaby()
+ && visibleEntities.lineOfSightTest.test(target)) {
+ babies.add(target);
+ }
+ }
+
+ return babies.build();
}
+ // DivineMC end - Optimize baby villager sensor
private boolean isVillagerBaby(LivingEntity livingEntity) {
return livingEntity.getType() == EntityType.VILLAGER && livingEntity.isBaby();
diff --git a/net/minecraft/world/entity/animal/goat/Goat.java b/net/minecraft/world/entity/animal/goat/Goat.java
index 6f106f10466440f8e65e04511f67d48f082d703f..15728d4fbe7a12c7a3b94a9ef88e7141b1225fa3 100644
--- a/net/minecraft/world/entity/animal/goat/Goat.java

View File

@@ -0,0 +1,18 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Sun, 23 Feb 2025 01:03:59 +0300
Subject: [PATCH] Configurable MC-67
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 356a1bfc610214912f58c4126cdd5694ffecfcb8..55bde2487078d0c7dcb3a367d070838770fc0f4e 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -4020,6 +4020,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
}
public boolean canTeleport(Level fromLevel, Level toLevel) {
+ if (!fromLevel.divineConfig.allowEntityPortalWithPassenger && (this.isPassenger() || this.isVehicle())) return false; // DivineMC - Allow entity teleport with passenger
if (!this.isAlive() || !this.valid) return false; // Paper - Fix item duplication and teleport issues
if (fromLevel.dimension() == Level.END && toLevel.dimension() == Level.OVERWORLD) {
for (Entity entity : this.getPassengers()) {

View File

@@ -0,0 +1,44 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Sun, 23 Feb 2025 01:04:29 +0300
Subject: [PATCH] Option to disable saving of snowball and firework
diff --git a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java
index 774ca9e0b56fd175ae246051de762d0c4256ca58..3a380d038ef1231624a646c38b60a4344694e321 100644
--- a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java
+++ b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java
@@ -364,4 +364,14 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier {
double d1 = entity.position().z - this.position().z;
return DoubleDoubleImmutablePair.of(d, d1);
}
+
+ // DivineMC start - Option to disable saving firework
+ @Override
+ public boolean shouldBeSaved() {
+ if (this.level().divineConfig.disableFireworkSaving) {
+ return false;
+ }
+ return super.shouldBeSaved();
+ }
+ // DivineMC end - Option to disable saving firework
}
diff --git a/net/minecraft/world/entity/projectile/Snowball.java b/net/minecraft/world/entity/projectile/Snowball.java
index cad1f8cb68ef9615587e651a3120f68a3c32add0..18298f3ba544e07110ea8d5b15ae753f7e3de65a 100644
--- a/net/minecraft/world/entity/projectile/Snowball.java
+++ b/net/minecraft/world/entity/projectile/Snowball.java
@@ -100,4 +100,14 @@ public class Snowball extends ThrowableItemProjectile {
this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
}
}
+
+ // DivineMC start - Option to disable snowball saving
+ @Override
+ public boolean shouldBeSaved() {
+ if (this.level().divineConfig.disableSnowballSaving) {
+ return false;
+ }
+ return super.shouldBeSaved();
+ }
+ // DivineMC end - Option to disable snowball saving
}

View File

@@ -0,0 +1,83 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Sun, 23 Feb 2025 01:14:54 +0300
Subject: [PATCH] Catch update suppressors
diff --git a/net/minecraft/network/protocol/PacketUtils.java b/net/minecraft/network/protocol/PacketUtils.java
index 4535858701b2bb232b9d2feb2af6551526232ddc..aa4dd7517e8be167aef1eaf7aa907e3ce7cc0e62 100644
--- a/net/minecraft/network/protocol/PacketUtils.java
+++ b/net/minecraft/network/protocol/PacketUtils.java
@@ -27,6 +27,10 @@ public class PacketUtils {
if (processor.shouldHandleMessage(packet)) {
try {
packet.handle(processor);
+ // DivineMC start - Catch update suppressors
+ } catch (org.bxteam.divinemc.util.exception.UpdateSuppressorException e) {
+ LOGGER.info(e.getMessage());
+ // DivineMC end - Catch update suppressors
} catch (Exception var4) {
if (var4 instanceof ReportedException reportedException && reportedException.getCause() instanceof OutOfMemoryError) {
throw makeReportedException(var4, packet, processor);
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
index b7815831ff1a2fa9aa52e96f1a50a5aa6823ff8a..85f81c83aff81133289a03f12a059729b7d2e00e 100644
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -1789,6 +1789,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
serverLevel.tickTimes10s.add(this.tickCount, j);
serverLevel.tickTimes60s.add(this.tickCount, j);
// DivineMC end - MSPT Tracking for each world
+ // DivineMC start - Catch update suppressors
+ } catch (org.bxteam.divinemc.util.exception.UpdateSuppressorException e) {
+ LOGGER.info(e.getMessage());
+ // DivineMC end - Catch update suppressors
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Exception ticking world");
diff --git a/net/minecraft/world/level/block/ShulkerBoxBlock.java b/net/minecraft/world/level/block/ShulkerBoxBlock.java
index cdf835ff107bc1eadde706d69384e687626fce70..c04c66668395fa9167e027131daf75c0e9ee6eff 100644
--- a/net/minecraft/world/level/block/ShulkerBoxBlock.java
+++ b/net/minecraft/world/level/block/ShulkerBoxBlock.java
@@ -234,7 +234,17 @@ public class ShulkerBoxBlock extends BaseEntityBlock {
@Override
protected int getAnalogOutputSignal(BlockState blockState, Level level, BlockPos pos) {
- return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos));
+ // DivineMC start - Catch update suppressors
+ try {
+ return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos));
+ } catch (ClassCastException ex) {
+ if (org.bxteam.divinemc.DivineConfig.updateSuppressionCrashFix) {
+ throw new org.bxteam.divinemc.util.exception.UpdateSuppressorException(pos, this);
+ } else {
+ throw ex;
+ }
+ }
+ // DivineMC end - Catch update suppressors
}
public static Block getBlockByColor(@Nullable DyeColor color) {
diff --git a/net/minecraft/world/level/redstone/NeighborUpdater.java b/net/minecraft/world/level/redstone/NeighborUpdater.java
index 26c15c60d358273a3b369c286771c81d6f0979dd..94fde31891e9f549ca356955913385cbaad02dca 100644
--- a/net/minecraft/world/level/redstone/NeighborUpdater.java
+++ b/net/minecraft/world/level/redstone/NeighborUpdater.java
@@ -63,9 +63,19 @@ public interface NeighborUpdater {
state.handleNeighborChanged(level, pos, neighborBlock, orientation, movedByPiston);
// Spigot start
} catch (StackOverflowError ex) {
+ // DivineMC start - Catch update suppressors
+ if (org.bxteam.divinemc.DivineConfig.updateSuppressionCrashFix) {
+ throw new org.bxteam.divinemc.util.exception.UpdateSuppressorException(pos, neighborBlock);
+ }
+ // DivineMC end - Catch update suppressors
level.lastPhysicsProblem = new BlockPos(pos);
// Spigot end
} catch (Throwable var9) {
+ // DivineMC start - Catch update suppressors
+ if (org.bxteam.divinemc.DivineConfig.updateSuppressionCrashFix) {
+ throw new org.bxteam.divinemc.util.exception.UpdateSuppressorException(pos, neighborBlock);
+ }
+ // DivineMC end - Catch update suppressors
CrashReport crashReport = CrashReport.forThrowable(var9, "Exception while updating neighbours");
CrashReportCategory crashReportCategory = crashReport.addCategory("Block being updated");
crashReportCategory.setDetail(

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Add chunk worker algorithm
diff --git a/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseCommon.java b/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseCommon.java
index 632920e04686d8a0fd0a60e87348be1fe7862a3c..38b8cdac418ab2308c0392be49289356cbe81fb7 100644
index 632920e04686d8a0fd0a60e87348be1fe7862a3c..27447481c6e6b526cda032aff54a5c87256c217d 100644
--- a/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseCommon.java
+++ b/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseCommon.java
@@ -3,6 +3,8 @@ package ca.spottedleaf.moonrise.common.util;
@@ -17,6 +17,15 @@ index 632920e04686d8a0fd0a60e87348be1fe7862a3c..38b8cdac418ab2308c0392be49289356
import org.slf4j.Logger;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@@ -29,7 +31,7 @@ public final class MoonriseCommon {
}
}
);
- public static final long WORKER_QUEUE_HOLD_TIME = (long)(20.0e6); // 20ms
+ public static final long WORKER_QUEUE_HOLD_TIME = (long)(2.0e6); // 2ms // DivineMC - Reduce from 20ms to 2ms
public static final int CLIENT_DIVISION = 0;
public static final PrioritisedThreadPool.ExecutorGroup RENDER_EXECUTOR_GROUP = MoonriseCommon.WORKER_POOL.createExecutorGroup(CLIENT_DIVISION, 0);
public static final int SERVER_DIVISION = 1;
@@ -38,26 +40,16 @@ public final class MoonriseCommon {
public static final PrioritisedThreadPool.ExecutorGroup LOAD_GROUP = MoonriseCommon.WORKER_POOL.createExecutorGroup(SERVER_DIVISION, 0);

View File

@@ -0,0 +1,18 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Sun, 23 Feb 2025 00:43:23 +0300
Subject: [PATCH] Configurable thread pool priority
diff --git a/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseCommon.java b/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseCommon.java
index 27447481c6e6b526cda032aff54a5c87256c217d..87d22532c680b7c6d3244a13e91fccbcc1a7e004 100644
--- a/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseCommon.java
+++ b/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseCommon.java
@@ -28,6 +28,7 @@ public final class MoonriseCommon {
LOGGER.error("Uncaught exception in thread " + thread.getName(), throwable);
}
});
+ thread.setPriority(DivineConfig.threadPoolPriority); // DivineMC - Configurable thread pool priority
}
}
);

View File

@@ -2,8 +2,6 @@ package org.bxteam.divinemc;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableMap;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.configuration.ConfigurationSection;
@@ -23,7 +21,7 @@ import java.util.logging.Level;
@SuppressWarnings("unused")
@NullMarked
public final class DivineConfig {
public final class DivineConfig { // TODO: Remake config system
private DivineConfig() {
throw new IllegalStateException("Utility class");
}
@@ -194,6 +192,7 @@ public final class DivineConfig {
public static long chunkDataCacheLimit = 32678L;
public static int maxViewDistance = 32;
public static ChunkSystemAlgorithms chunkWorkerAlgorithm = ChunkSystemAlgorithms.C2ME;
public static int threadPoolPriority = Thread.NORM_PRIORITY + 1;
public static boolean enableSecureSeed = false;
public static boolean enableDensityFunctionCompiler = false;
public static boolean enableStructureLayoutOptimizer = true;
@@ -203,9 +202,7 @@ public final class DivineConfig {
nativeAccelerationEnabled = getBoolean(config, "settings.chunk-generation.native-acceleration-enabled", nativeAccelerationEnabled);
allowAVX512 = getBoolean(config, "settings.chunk-generation.allow-avx512", allowAVX512,
"Enables AVX512 support for natives-math optimizations",
"",
"Read more about AVX512: https://en.wikipedia.org/wiki/AVX-512");
"Enables AVX512 support for natives-math optimizations");
isaTargetLevelOverride = getInt(config, "settings.chunk-generation.isa-target-level-override", isaTargetLevelOverride,
"Overrides the ISA target located by the native loader, which allows forcing AVX512 (must be a value between 6-9 for AVX512 support).",
"Value must be between 1-9, and -1 to disable override");
@@ -222,6 +219,8 @@ public final class DivineConfig {
chunkWorkerAlgorithm = ChunkSystemAlgorithms.valueOf(getString(config, "settings.chunk-generation.chunk-worker-algorithm", chunkWorkerAlgorithm.name(),
"Modifies what algorithm the chunk system will use to define thread counts. values: MOONRISE, C2ME, C2ME_AGGRESSIVE"));
threadPoolPriority = getInt(config, "settings.chunk-generation.thread-pool-priority", threadPoolPriority,
"Sets the priority of the thread pool used for chunk generation");
enableSecureSeed = getBoolean(config, "settings.misc.enable-secure-seed", enableSecureSeed,
"This feature is based on Secure Seed mod by Earthcomputer.",
@@ -258,6 +257,7 @@ public final class DivineConfig {
public static boolean clumpOrbs = true;
public static boolean ignoreMovedTooQuicklyWhenLagging = true;
public static boolean alwaysAllowWeirdMovement = true;
public static boolean updateSuppressionCrashFix = true;
private static void miscSettings() {
skipUselessSecondaryPoiSensor = getBoolean(config, "settings.misc.skip-useless-secondary-poi-sensor", skipUselessSecondaryPoiSensor);
@@ -267,6 +267,7 @@ public final class DivineConfig {
"Improves general gameplay experience of the player when the server is lagging, as they won't get lagged back (message 'moved too quickly')");
alwaysAllowWeirdMovement = getBoolean(config, "settings.misc.always-allow-weird-movement", alwaysAllowWeirdMovement,
"Means ignoring messages like 'moved too quickly' and 'moved wrongly'");
updateSuppressionCrashFix = getBoolean(config, "settings.misc.update-suppression-crash-fix", updateSuppressionCrashFix);
}
public static boolean enableFasterTntOptimization = true;

View File

@@ -10,6 +10,7 @@ import java.util.Map;
import static org.bxteam.divinemc.DivineConfig.log;
@SuppressWarnings("unused")
@NullMarked
public final class DivineWorldConfig {
private final YamlConfiguration config;
@@ -74,9 +75,18 @@ public final class DivineWorldConfig {
}
public boolean snowballCanKnockback = true;
public boolean disableSnowballSaving = false;
public boolean eggCanKnockback = true;
private void setSnowballAndEggKnockback() {
public boolean disableFireworkSaving = false;
private void projectilesSettings() {
snowballCanKnockback = getBoolean("gameplay-mechanics.projectiles.snowball.knockback", snowballCanKnockback);
disableSnowballSaving = getBoolean("gameplay-mechanics.projectiles.snowball.disable-saving", disableSnowballSaving);
eggCanKnockback = getBoolean("gameplay-mechanics.projectiles.egg.knockback", eggCanKnockback);
disableFireworkSaving = getBoolean("gameplay-mechanics.projectiles.firework.disable-saving", disableFireworkSaving);
}
public boolean allowEntityPortalWithPassenger = true;
private void unsupportedFeatures() {
allowEntityPortalWithPassenger = getBoolean("unsupported-features.allow-entity-portal-with-passenger", allowEntityPortalWithPassenger);
}
}

View File

@@ -0,0 +1,31 @@
package org.bxteam.divinemc.util.exception;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.Block;
public class UpdateSuppressorException extends RuntimeException {
private final BlockPos pos;
private final Block source;
public UpdateSuppressorException(BlockPos pos, Block source) {
super("Update suppression");
this.pos = pos;
this.source = source;
}
public BlockPos getPos() {
return pos;
}
public Block getSource() {
return source;
}
public String getMessage() {
if (pos != null) {
return "An update suppression processed, form [%s] to [x:%d,y:%d,z:%d]".formatted(source.getName(), pos.getX(), pos.getY(), pos.getZ());
} else {
return "An update suppression processed, form [%s]".formatted(source.getName());
}
}
}