9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2026-01-06 15:41:52 +00:00

14/33 done

This commit is contained in:
NONPLAYT
2023-06-10 13:07:47 +03:00
parent 34ef6ecaed
commit 80a1275b04
13 changed files with 51 additions and 50 deletions

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Fix entity serialization
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index e71eca3ddbbeb3168dd73433b6d6ffe9f6755f77..a5b7194823027446117b14fbf916f2cb16e5679f 100644
index 6417fd26d7675c967986055067ce8876a1263e9f..ff8258b1146d2899037a1fbd0ebc985df342eff4 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2184,15 +2184,6 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -2288,15 +2288,6 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
}
@@ -25,7 +25,7 @@ index e71eca3ddbbeb3168dd73433b6d6ffe9f6755f77..a5b7194823027446117b14fbf916f2cb
return this.isPassenger() ? false : this.saveAsPassenger(nbt);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 1bf9a11abf7884a421374cbca5ccc18480717b79..32bc9099fea1fed7c94bff27cb897cdb4aab9e73 100644
index 09c39f72fe1e8e6967f415dfd0d7aea8e50d0379..35f01d3c4d4318383ecd8a08b378285fffe07d62 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -498,8 +498,13 @@ public final class CraftMagicNumbers implements UnsafeValues {

View File

@@ -0,0 +1,22 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Fri, 31 Mar 2023 22:47:12 +0300
Subject: [PATCH] Don't save Fireworks
diff --git a/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java b/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java
index 288910fb168ddc5d3a61971778b8038a56772fa8..f0b208b90f15ffd55572dbe94e2a1cc7a448aa0c 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java
@@ -357,4 +357,11 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier {
public boolean isAttackable() {
return false;
}
+
+ // DivineMC start - Don't save Fireworks
+ @Override
+ public boolean shouldBeSaved() {
+ return false;
+ }
+ // DivineMC end
}

View File

@@ -0,0 +1,19 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 17 Jun 2018 22:16:25 -0400
Subject: [PATCH] EMC - Allow negative Amplifier values
diff --git a/src/main/java/net/minecraft/world/effect/MobEffectInstance.java b/src/main/java/net/minecraft/world/effect/MobEffectInstance.java
index 745e792482f61c571e2efbd4200dd1bdaef6e474..b8451c4b4d4038ffb6eea65a33d645d85101562b 100644
--- a/src/main/java/net/minecraft/world/effect/MobEffectInstance.java
+++ b/src/main/java/net/minecraft/world/effect/MobEffectInstance.java
@@ -369,7 +369,7 @@ public class MobEffectInstance implements Comparable<MobEffectInstance> {
optional = Optional.empty();
}
- return new MobEffectInstance(type, j, Math.max(i, 0), bl, bl2, bl3, mobEffectInstance, optional, key); // Purpur - add key
+ return new MobEffectInstance(type, j, i, bl, bl2, bl3, mobEffectInstance, optional, key); // Purpur - add key // EMC - always use Amplifier, don't check > 0
}
@Override

View File

@@ -0,0 +1,76 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Fri, 31 Mar 2023 23:05:12 +0300
Subject: [PATCH] Remove Spigot tick limiter
Original code by Titaniumtown, modified by NONPLAYT
You can find the original code on https://gitlab.com/Titaniumtown/JettPack
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 454ad3442076898dd476d86706f93facae1939af..e34fdd46a0c00a02dd8828140e294fa66ddb1770 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -182,8 +182,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public final gq.bxteam.divinemc.configuration.DivineWorldConfig divinemcConfig; // DivineMC
public final co.aikar.timings.WorldTimingsHandler timings; // Paper
public static BlockPos lastPhysicsProblem; // Spigot
- private org.spigotmc.TickLimiter entityLimiter;
- private org.spigotmc.TickLimiter tileLimiter;
private int tileTickPosition;
public final Map<Explosion.CacheKey, Float> explosionDensityCache = new HashMap<>(); // Paper - Optimize explosions
public java.util.ArrayDeque<net.minecraft.world.level.block.RedstoneTorchBlock.Toggle> redstoneUpdateInfos; // Paper - Move from Map in BlockRedstoneTorch to here
@@ -407,8 +405,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
// CraftBukkit end
timings = new co.aikar.timings.WorldTimingsHandler(this); // Paper - code below can generate new world and access timings
this.keepSpawnInMemory = this.paperConfig().spawn.keepSpawnLoaded; // Paper
- this.entityLimiter = new org.spigotmc.TickLimiter(spigotConfig.entityMaxTickTime);
- this.tileLimiter = new org.spigotmc.TickLimiter(spigotConfig.tileMaxTickTime);
this.chunkPacketBlockController = this.paperConfig().anticheat.antiXray.enabled ? new com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray(this, executor) : com.destroystokyo.paper.antixray.ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray
}
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 5638290c72e0daeddfa79fd55e87334fa7d86f72..b1ddcb53b77020b43f68e2a5558e05fab207789d 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -448,6 +448,7 @@ public class SpigotWorldConfig
this.hangingTickFrequency = this.getInt( "hanging-tick-frequency", 100 );
}
+ /* DivineMC - remove tick limiter
public int tileMaxTickTime;
public int entityMaxTickTime;
private void maxTickTimes()
@@ -456,6 +457,7 @@ public class SpigotWorldConfig
this.entityMaxTickTime = this.getInt("max-tick-time.entity", 50);
this.log("Tile Max Tick Time: " + this.tileMaxTickTime + "ms Entity max Tick Time: " + this.entityMaxTickTime + "ms");
}
+ */
public int thunderChance;
private void thunderChance()
diff --git a/src/main/java/org/spigotmc/TickLimiter.java b/src/main/java/org/spigotmc/TickLimiter.java
deleted file mode 100644
index 4074538ea6090bf99d8ab04b1e98c2832a0e9a98..0000000000000000000000000000000000000000
--- a/src/main/java/org/spigotmc/TickLimiter.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.spigotmc;
-
-public class TickLimiter {
-
- private final int maxTime;
- private long startTime;
-
- public TickLimiter(int maxtime) {
- this.maxTime = maxtime;
- }
-
- public void initTick() {
- this.startTime = System.currentTimeMillis();
- }
-
- public boolean shouldContinue() {
- long remaining = System.currentTimeMillis() - this.startTime;
- return remaining < this.maxTime;
- }
-}

View File

@@ -0,0 +1,77 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Sat, 10 Jun 2023 13:01:08 +0300
Subject: [PATCH] Boat Settings
diff --git a/src/main/java/gq/bxteam/divinemc/configuration/DivineWorldConfig.java b/src/main/java/gq/bxteam/divinemc/configuration/DivineWorldConfig.java
index 5d16d2250bae9c982a0af9ad2580a63532b140f7..9eede8eb7fefc414f3a1207cd3ca2b33deb5ea13 100644
--- a/src/main/java/gq/bxteam/divinemc/configuration/DivineWorldConfig.java
+++ b/src/main/java/gq/bxteam/divinemc/configuration/DivineWorldConfig.java
@@ -77,4 +77,11 @@ public class DivineWorldConfig {
final Map<String, Object> value = DivineConfig.getMap("world-settings." + worldName + "." + path, null);
return value.isEmpty() ? fallback : value;
}
+
+ public boolean dontEjectPlayerFromBoatUnderwater = true;
+ public boolean alwaysAllowToEnterTheBoat = true;
+ private void boatFeatures() {
+ dontEjectPlayerFromBoatUnderwater = getBoolean("gameplay-mechanics.boat.dont-eject-players-from-boat-underwater", dontEjectPlayerFromBoatUnderwater);
+ alwaysAllowToEnterTheBoat = getBoolean("gameplay-mechanics.boat.always-allow-to-enter-the-boat", alwaysAllowToEnterTheBoat);
+ }
}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
index 8f7666f3c33eaf2bee0d68cc4ef1cfab09dea08a..f1a7dc3e00f90be923828a1d812ae3026a584439 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
@@ -357,7 +357,18 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
}
if (!this.level().isClientSide && this.outOfControlTicks >= 60.0F) {
- this.ejectPassengers();
+ // DivineMC start - Don't eject players
+ if (this.level().divinemcConfig.dontEjectPlayerFromBoatUnderwater) {
+ for (int i = this.passengers.size() - 1; i >= 0; --i) {
+ Entity passenger = this.passengers.get(i);
+ if (!(passenger instanceof Player)) {
+ passenger.stopRiding();
+ }
+ }
+ } else {
+ this.ejectPassengers();
+ }
+ // DivineMC end
}
if (this.getHurtTime() > 0) {
@@ -898,7 +909,13 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
@Override
public InteractionResult interact(Player player, InteractionHand hand) {
- return player.isSecondaryUseActive() ? InteractionResult.PASS : (this.outOfControlTicks < 60.0F ? (!this.level().isClientSide ? (player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS) : InteractionResult.SUCCESS) : InteractionResult.PASS);
+ // DivineMC start - always allow to enter the boat
+ if (this.level().divinemcConfig.alwaysAllowToEnterTheBoat) {
+ return player.isSecondaryUseActive() ? InteractionResult.PASS : (true || this.outOfControlTicks < 60.0F ? (!this.level().isClientSide ? (player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS) : InteractionResult.SUCCESS) : InteractionResult.PASS);
+ } else {
+ return player.isSecondaryUseActive() ? InteractionResult.PASS : (this.outOfControlTicks < 60.0F ? (!this.level().isClientSide ? (player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS) : InteractionResult.SUCCESS) : InteractionResult.PASS);
+ }
+ // DivineMC end
}
@Override
@@ -994,7 +1011,13 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
@Override
protected boolean canAddPassenger(Entity passenger) {
- return this.getPassengers().size() < this.getMaxPassengers() && !this.isEyeInFluid(FluidTags.WATER);
+ // DivineMC start - always allow to enter the boat
+ if (this.level().divinemcConfig.alwaysAllowToEnterTheBoat) {
+ return this.getPassengers().size() < this.getMaxPassengers()/* && !this.isEyeInFluid(FluidTags.WATER)*/;
+ } else {
+ return this.getPassengers().size() < this.getMaxPassengers() && !this.isEyeInFluid(FluidTags.WATER);
+ }
+ // DivineMC end
}
protected int getMaxPassengers() {

View File

@@ -0,0 +1,49 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Sun, 2 Apr 2023 21:27:33 +0300
Subject: [PATCH] Fallback to Dimension if World UUID is unknown
diff --git a/src/main/java/gq/bxteam/divinemc/configuration/DivineConfig.java b/src/main/java/gq/bxteam/divinemc/configuration/DivineConfig.java
index 0a8baeb94ae553c4759b065eafd9e242153cf991..abf8ddccce6ec9d893038d1fafdca617ce0eae4d 100644
--- a/src/main/java/gq/bxteam/divinemc/configuration/DivineConfig.java
+++ b/src/main/java/gq/bxteam/divinemc/configuration/DivineConfig.java
@@ -152,4 +152,9 @@ public class DivineConfig {
}
return builder.build();
}
+
+ public static boolean fallbackToDimensionIfWorldUUIDUnknown = true;
+ private static void fallbackToDimensionIfWorldUUIDUnknown() {
+ fallbackToDimensionIfWorldUUIDUnknown = getBoolean("settings.fallback-to-dimension-if-world-uuid-unknown", fallbackToDimensionIfWorldUUIDUnknown);
+ }
}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 725149019d69f3350b7235391092b1fbe2cd9dfb..fc67dc67664a207b761ff4d8df0a206bd4a41547 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -102,6 +102,7 @@ import net.minecraft.world.scores.PlayerTeam;
import net.minecraft.world.scores.Scoreboard; // Paper
import net.minecraft.world.scores.Team;
import org.slf4j.Logger;
+import gq.bxteam.divinemc.configuration.DivineConfig;
// CraftBukkit start
import java.util.stream.Collectors;
@@ -220,7 +221,14 @@ public abstract class PlayerList {
if (bWorld != null) {
resourcekey = ((CraftWorld) bWorld).getHandle().dimension();
} else {
- resourcekey = Level.OVERWORLD;
+ // DivineMC start - Fallback to Dimension if World UUID is unknown
+ if (DivineConfig.fallbackToDimensionIfWorldUUIDUnknown) {
+ DataResult<ResourceKey<Level>> dataResult = Level.RESOURCE_KEY_CODEC.parse(new Dynamic<>(NbtOps.INSTANCE, nbttagcompound.get("Dimension")));
+ resourcekey = dataResult.result().orElse(Level.OVERWORLD);
+ } else {
+ resourcekey = Level.OVERWORLD;
+ }
+ // DivineMC end
}
} else if (nbttagcompound != null) {
// Vanilla migration support

View File

@@ -0,0 +1,43 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Mon, 3 Apr 2023 23:52:44 +0300
Subject: [PATCH] Allow any username
diff --git a/src/main/java/gq/bxteam/divinemc/configuration/DivineConfig.java b/src/main/java/gq/bxteam/divinemc/configuration/DivineConfig.java
index abf8ddccce6ec9d893038d1fafdca617ce0eae4d..2744315c62f99b48cb689dd90fdfffac405b1bcc 100644
--- a/src/main/java/gq/bxteam/divinemc/configuration/DivineConfig.java
+++ b/src/main/java/gq/bxteam/divinemc/configuration/DivineConfig.java
@@ -157,4 +157,9 @@ public class DivineConfig {
private static void fallbackToDimensionIfWorldUUIDUnknown() {
fallbackToDimensionIfWorldUUIDUnknown = getBoolean("settings.fallback-to-dimension-if-world-uuid-unknown", fallbackToDimensionIfWorldUUIDUnknown);
}
+
+ public static boolean allowAnyUsername = false;
+ private static void allowAnyUsername() {
+ allowAnyUsername = getBoolean("settings.player.allow-any-username", allowAnyUsername);
+ }
}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index f719f8aafe7c75e2ef8fcb05f556a8d6bd94b9a0..66dd73064e515986bebf57c6d293aa74cef88693 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -14,6 +14,8 @@ import java.util.concurrent.atomic.AtomicInteger;
import javax.annotation.Nullable;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
+
+import gq.bxteam.divinemc.configuration.DivineConfig;
import net.minecraft.DefaultUncaughtExceptionHandler;
import net.minecraft.core.UUIDUtil;
import net.minecraft.network.Connection;
@@ -239,7 +241,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
@Override
public void handleHello(ServerboundHelloPacket packet) {
Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet", new Object[0]);
- Validate.validState(ServerLoginPacketListenerImpl.isValidUsername(packet.name()), "Invalid characters in username", new Object[0]);
+ if (!DivineConfig.allowAnyUsername) Validate.validState(ServerLoginPacketListenerImpl.isValidUsername(packet.name()), "Invalid characters in username", new Object[0]); // DivineMC - Allow any username
// Paper start - validate usernames
if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.performUsernameValidation) {
if (!this.iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation && !validateUsername(packet.name())) {

View File

@@ -0,0 +1,29 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Sat, 10 Jun 2023 13:06:44 +0300
Subject: [PATCH] Fix memory leak
diff --git a/src/main/java/net/minecraft/world/level/biome/Biome.java b/src/main/java/net/minecraft/world/level/biome/Biome.java
index 65012a12e1430956ef55ced56773e6354ac26444..2bcd3ee3bbdf246ef429a8310ca96ba3fb4afd2c 100644
--- a/src/main/java/net/minecraft/world/level/biome/Biome.java
+++ b/src/main/java/net/minecraft/world/level/biome/Biome.java
@@ -66,7 +66,8 @@ public final class Biome {
private final BiomeGenerationSettings generationSettings;
private final MobSpawnSettings mobSettings;
private final BiomeSpecialEffects specialEffects;
- private final ThreadLocal<Long2FloatLinkedOpenHashMap> temperatureCache = ThreadLocal.withInitial(() -> {
+ private static final ThreadLocal<Long2FloatLinkedOpenHashMap> temperatureCache = ThreadLocal.withInitial(() -> { // DivineMC - fix memory leak
+
return Util.make(() -> {
Long2FloatLinkedOpenHashMap long2FloatLinkedOpenHashMap = new Long2FloatLinkedOpenHashMap(1024, 0.25F) {
protected void rehash(int i) {
@@ -118,7 +119,7 @@ public final class Biome {
@Deprecated
public float getTemperature(BlockPos blockPos) {
long l = blockPos.asLong();
- Long2FloatLinkedOpenHashMap long2FloatLinkedOpenHashMap = this.temperatureCache.get();
+ Long2FloatLinkedOpenHashMap long2FloatLinkedOpenHashMap = temperatureCache.get(); // DivineMC - fix memory leak
float f = long2FloatLinkedOpenHashMap.get(l);
if (!Float.isNaN(f)) {
return f;