Apply more optimizations
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: AlphaKR93 <dev@alpha93.kr>
|
||||
Date: Sun, 5 Nov 2023 12:07:06 +0900
|
||||
Subject: [PATCH] Do not load chunks to spawn phantom
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java b/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java
|
||||
index 27eb9a365006884c85603dc6d9dd8eee009c98b3..958a48d05aba8e500c7b19a466dcca6fea8a8bcc 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java
|
||||
@@ -70,6 +70,7 @@ public class PhantomSpawner implements CustomSpawner {
|
||||
|
||||
if (randomsource.nextInt(j) >= world.paperConfig().entities.behavior.playerInsomniaStartTicks) { // Paper - Ability to control player's insomnia and phantoms
|
||||
BlockPos blockposition1 = blockposition.above(20 + randomsource.nextInt(15)).east(-10 + randomsource.nextInt(21)).south(-10 + randomsource.nextInt(21));
|
||||
+ if (!world.plazmaConfig().entity.phantom.loadChunksToSpawn && !world.hasChunkAt(blockposition1)) continue; // Plazma - Do not load chunks to spawn phantom
|
||||
BlockState iblockdata = world.getBlockState(blockposition1);
|
||||
FluidState fluid = world.getFluidState(blockposition1);
|
||||
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||
index c703237d46b114227cf0d5cdff2e033839bc5f57..a976e2b960a5f3b7ecf6e42afcb1dd3bd140b8bd 100644
|
||||
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||
@@ -31,6 +31,7 @@ public class WorldConfigurations extends ConfigurationPart {
|
||||
public Phantom phantom;
|
||||
public class Phantom extends ConfigurationPart {
|
||||
|
||||
+ public boolean loadChunksToSpawn = !OPTIMIZE;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: AlphaKR93 <dev@alpha93.kr>
|
||||
Date: Sun, 5 Nov 2023 12:16:14 +0900
|
||||
Subject: [PATCH] Add option to disable moved to quickly check for specific
|
||||
players
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index c783c17d45beda8297171d0834350197808a7335..611de28d27d75b73e33a552c8a23d6c0f53582da 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -1749,7 +1749,13 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
}
|
||||
}
|
||||
|
||||
+ // Plazma start - Add option to bypass moved to quickly check
|
||||
private boolean shouldCheckPlayerMovement(boolean elytra) {
|
||||
+ return (!this.player.getBukkitEntity().hasPermission("plazma.bypass-moved-to-quickly-check") || !(org.plazmamc.plazma.configurations.GlobalConfiguration.get().player.checkSpectatorMovedToQuickly && this.player.isSpectator())) && shouldCheckPlayerMovement0(elytra);
|
||||
+ }
|
||||
+
|
||||
+ private boolean shouldCheckPlayerMovement0(boolean elytra) {
|
||||
+ // Plazma end - Add option to bypass moved to quickly check
|
||||
if (this.isSingleplayerOwner()) {
|
||||
return false;
|
||||
} else if (this.player.isChangingDimension()) {
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
index f99a281244f7b736bd979cfc0bcd0787d9da9a42..6d313edc60082a5f2d30ef8ad9fbd57772f361fe 100644
|
||||
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
@@ -43,6 +43,7 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||
public Player player;
|
||||
public class Player extends ConfigurationPart {
|
||||
|
||||
+ public boolean checkSpectatorMovedToQuickly = !OPTIMIZE;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: AlphaKR93 <dev@alpha93.kr>
|
||||
Date: Mon, 6 Nov 2023 11:36:08 +0900
|
||||
Subject: [PATCH] Configurable entity sensor tick
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index 0be6582e50ccc94036bb6782a5f811c0f9c42f01..98b08a2e83cf1c4e1e45a42ddcad2198f42a05e2 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -951,10 +951,11 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
gameprofilerfiller.push("sensing");
|
||||
- this.sensing.tick();
|
||||
+ //this.sensing.tick(); // Plazma - moved down
|
||||
gameprofilerfiller.pop();
|
||||
int i = this.tickCount + this.getId();
|
||||
|
||||
+ if (i % this.level().plazmaConfig().entity.sensorTick == 0) this.sensing.tick(); // Plazma - Configurable entity sensor tick
|
||||
if (i % 2 != 0 && this.tickCount > 1) {
|
||||
gameprofilerfiller.push("targetSelector");
|
||||
if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||
index a976e2b960a5f3b7ecf6e42afcb1dd3bd140b8bd..9e408d6c1826d36a935b3e382e8eb0283f3d1580 100644
|
||||
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||
@@ -28,6 +28,8 @@ public class WorldConfigurations extends ConfigurationPart {
|
||||
public Entity entity;
|
||||
public class Entity extends ConfigurationPart {
|
||||
|
||||
+ public int sensorTick = 1;
|
||||
+
|
||||
public Phantom phantom;
|
||||
public class Phantom extends ConfigurationPart {
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: AlphaKR93 <dev@alpha93.kr>
|
||||
Date: Sun, 27 Oct 2024 13:48:01 +0900
|
||||
Subject: [PATCH] Configurable water flowing speed
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/material/WaterFluid.java b/src/main/java/net/minecraft/world/level/material/WaterFluid.java
|
||||
index 1e741f36b79585f33abe413beafe00cf5205d54f..028aea6640356ba80f5d682e3cc03b7f82f5b9c7 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/material/WaterFluid.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/material/WaterFluid.java
|
||||
@@ -123,7 +123,7 @@ public abstract class WaterFluid extends FlowingFluid {
|
||||
|
||||
@Override
|
||||
public int getTickDelay(LevelReader world) {
|
||||
- return 5;
|
||||
+ return world.getWorldBorder().world.plazmaConfig().block.waterFlowingTick; // Plazma - Configurable water flowing speed
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||
index 0e27e4a1f767842d1dcd2ed235a6a45f120bf32e..c1d4a96cf5be77f4460c54ed19622f527d42ca06 100644
|
||||
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||
@@ -64,7 +64,9 @@ public class WorldConfigurations extends ConfigurationPart {
|
||||
|
||||
public Block block;
|
||||
public class Block extends ConfigurationPart {
|
||||
-
|
||||
+
|
||||
+ public int waterFlowingTick = 5;
|
||||
+
|
||||
public Hopper hopper;
|
||||
public class Hopper extends ConfigurationPart {
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: AlphaKR93 <dev@alpha93.kr>
|
||||
Date: Wed, 22 Jan 2025 11:32:58 +0900
|
||||
Subject: [PATCH] Register every commands
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
|
||||
index 2ef4dc9169a9bec304b4922a2e91c31b966c711d..c416b1eaf27699de59aaa6b352ff1aa991d3f660 100644
|
||||
--- a/src/main/java/net/minecraft/commands/Commands.java
|
||||
+++ b/src/main/java/net/minecraft/commands/Commands.java
|
||||
@@ -44,91 +44,7 @@ import net.minecraft.network.chat.MutableComponent;
|
||||
--- a/net/minecraft/commands/Commands.java
|
||||
+++ b/net/minecraft/commands/Commands.java
|
||||
@@ -44,91 +_,7 @@
|
||||
import net.minecraft.network.protocol.game.ClientboundCommandsPacket;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
@@ -97,15 +89,15 @@ index 2ef4dc9169a9bec304b4922a2e91c31b966c711d..c416b1eaf27699de59aaa6b352ff1aa9
|
||||
-import net.minecraft.server.commands.WeatherCommand;
|
||||
-import net.minecraft.server.commands.WhitelistCommand;
|
||||
-import net.minecraft.server.commands.WorldBorderCommand;
|
||||
+import net.minecraft.server.commands.*; // Plazma - Register all commands
|
||||
+import net.minecraft.server.commands.*; // Plazma - Register every commands
|
||||
import net.minecraft.server.commands.data.DataCommands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.tags.TagKey;
|
||||
@@ -234,6 +150,7 @@ public class Commands {
|
||||
@@ -229,6 +_,7 @@
|
||||
WardenSpawnTrackerCommand.register(this.dispatcher);
|
||||
SpawnArmorTrimsCommand.register(this.dispatcher);
|
||||
ServerPackCommand.register(this.dispatcher);
|
||||
+ ChaseCommand.register(this.dispatcher); // Plazma - Register all commands
|
||||
if (environment.includeDedicated) {
|
||||
+ ChaseCommand.register(this.dispatcher); // Plazma - Register every commands
|
||||
if (selection.includeDedicated) {
|
||||
DebugConfigCommand.register(this.dispatcher);
|
||||
}
|
||||
@@ -9,3 +9,41 @@
|
||||
if (blockState2 != blockState) {
|
||||
this.player.level().setBlock(pos, blockState2, 2);
|
||||
blockEntity.setBlockState(blockState2);
|
||||
@@ -1673,17 +_,28 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // Plazma start - Add option to bypass moved to quickly check
|
||||
+ public static boolean useMovedToQuicklyBypassPermission;
|
||||
+ public static boolean checkSpectatorMovedToQuickly;
|
||||
+
|
||||
private boolean shouldCheckPlayerMovement(boolean isElytraMovement) {
|
||||
- if (this.isSingleplayerOwner()) {
|
||||
- return false;
|
||||
- } else if (this.player.isChangingDimension()) {
|
||||
- return false;
|
||||
- } else {
|
||||
- GameRules gameRules = this.player.serverLevel().getGameRules();
|
||||
- return !gameRules.getBoolean(GameRules.RULE_DISABLE_PLAYER_MOVEMENT_CHECK)
|
||||
- && (!isElytraMovement || !gameRules.getBoolean(GameRules.RULE_DISABLE_ELYTRA_MOVEMENT_CHECK));
|
||||
- }
|
||||
+ if (this.player.isChangingDimension()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (checkSpectatorMovedToQuickly && this.player.isSpectator()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (useMovedToQuicklyBypassPermission && this.player.getBukkitEntity().hasPermission("plazma.bypass-moved-to-quickly-check")) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ final GameRules gameRules = this.player.serverLevel().getGameRules();
|
||||
+ return !gameRules.getBoolean(GameRules.RULE_DISABLE_PLAYER_MOVEMENT_CHECK)
|
||||
+ && (!isElytraMovement || !gameRules.getBoolean(GameRules.RULE_DISABLE_ELYTRA_MOVEMENT_CHECK));
|
||||
}
|
||||
+ // Plazma end - Add option to bypass moved to quickly check
|
||||
|
||||
private boolean updateAwaitingTeleport() {
|
||||
if (this.awaitingPositionFromClient != null) {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
--- a/net/minecraft/world/entity/Mob.java
|
||||
+++ b/net/minecraft/world/entity/Mob.java
|
||||
@@ -884,9 +_,9 @@
|
||||
// Paper end - Allow nerfed mobs to jump and float
|
||||
ProfilerFiller profilerFiller = Profiler.get();
|
||||
profilerFiller.push("sensing");
|
||||
- this.sensing.tick();
|
||||
profilerFiller.pop();
|
||||
int i = this.tickCount + this.getId();
|
||||
+ if (i % this.level().plazmaConfig().entity.sensorTick == 0) this.sensing.tick(); // Plazma - Moved down; Configurable entity sensor tick
|
||||
if (i % 2 != 0 && this.tickCount > 1) {
|
||||
profilerFiller.push("targetSelector");
|
||||
this.targetSelector.tickRunningGoals(false);
|
||||
@@ -0,0 +1,177 @@
|
||||
--- a/net/minecraft/world/level/levelgen/PhantomSpawner.java
|
||||
+++ b/net/minecraft/world/level/levelgen/PhantomSpawner.java
|
||||
@@ -23,81 +_,101 @@
|
||||
|
||||
@Override
|
||||
public int tick(ServerLevel level, boolean spawnEnemies, boolean spawnFriendlies) {
|
||||
- if (!spawnEnemies) {
|
||||
- return 0;
|
||||
- } else if (!level.getGameRules().getBoolean(GameRules.RULE_DOINSOMNIA)) {
|
||||
- return 0;
|
||||
- } else {
|
||||
- // Paper start - Ability to control player's insomnia and phantoms
|
||||
- if (level.paperConfig().entities.behavior.phantomsSpawnAttemptMaxSeconds <= 0) {
|
||||
- return 0;
|
||||
- }
|
||||
- // Paper end - Ability to control player's insomnia and phantoms
|
||||
- RandomSource randomSource = level.random;
|
||||
- this.nextTick--;
|
||||
- if (this.nextTick > 0) {
|
||||
- return 0;
|
||||
- } else {
|
||||
- // Paper start - Ability to control player's insomnia and phantoms
|
||||
- int spawnAttemptMinSeconds = level.paperConfig().entities.behavior.phantomsSpawnAttemptMinSeconds;
|
||||
- int spawnAttemptMaxSeconds = level.paperConfig().entities.behavior.phantomsSpawnAttemptMaxSeconds;
|
||||
- this.nextTick += (spawnAttemptMinSeconds + randomSource.nextInt(spawnAttemptMaxSeconds - spawnAttemptMinSeconds + 1)) * 20;
|
||||
- // Paper end - Ability to control player's insomnia and phantoms
|
||||
- if (level.getSkyDarken() < level.purpurConfig.phantomSpawnMinSkyDarkness && level.dimensionType().hasSkyLight()) { // Purpur - Add phantom spawning options
|
||||
- return 0;
|
||||
- } else {
|
||||
- int i = 0;
|
||||
-
|
||||
- for (ServerPlayer serverPlayer : level.players()) {
|
||||
- if (!serverPlayer.isSpectator() && (!level.paperConfig().entities.behavior.phantomsDoNotSpawnOnCreativePlayers || !serverPlayer.isCreative())) { // Paper - Add phantom creative and insomniac controls
|
||||
- BlockPos blockPos = serverPlayer.blockPosition();
|
||||
- if (!level.dimensionType().hasSkyLight() || (!level.purpurConfig.phantomSpawnOnlyAboveSeaLevel || blockPos.getY() >= level.getSeaLevel()) && (!level.purpurConfig.phantomSpawnOnlyWithVisibleSky || level.canSeeSky(blockPos))) { // Purpur - Add phantom spawning options
|
||||
- DifficultyInstance currentDifficultyAt = level.getCurrentDifficultyAt(blockPos);
|
||||
- if (currentDifficultyAt.isHarderThan(randomSource.nextFloat() * (float) level.purpurConfig.phantomSpawnLocalDifficultyChance)) { // Purpur - Add phantom spawning options
|
||||
- ServerStatsCounter stats = serverPlayer.getStats();
|
||||
- int i1 = Mth.clamp(stats.getValue(Stats.CUSTOM.get(Stats.TIME_SINCE_REST)), 1, Integer.MAX_VALUE);
|
||||
- int i2 = 24000;
|
||||
- if (randomSource.nextInt(i1) >= level.paperConfig().entities.behavior.playerInsomniaStartTicks) { // Paper - Ability to control player's insomnia and phantoms
|
||||
- BlockPos blockPos1 = blockPos.above(20 + randomSource.nextInt(15))
|
||||
- .east(-10 + randomSource.nextInt(21))
|
||||
- .south(-10 + randomSource.nextInt(21));
|
||||
- BlockState blockState = level.getBlockState(blockPos1);
|
||||
- FluidState fluidState = level.getFluidState(blockPos1);
|
||||
- if (NaturalSpawner.isValidEmptySpawnBlock(level, blockPos1, blockState, fluidState, EntityType.PHANTOM)) {
|
||||
- SpawnGroupData spawnGroupData = null;
|
||||
- int i3 = level.purpurConfig.phantomSpawnMinPerAttempt + level.random.nextInt((level.purpurConfig.phantomSpawnMaxPerAttempt < 0 ? currentDifficultyAt.getDifficulty().getId() : level.purpurConfig.phantomSpawnMaxPerAttempt - level.purpurConfig.phantomSpawnMinPerAttempt) + 1); // Purpur - Add phantom spawning options
|
||||
-
|
||||
- for (int i4 = 0; i4 < i3; i4++) {
|
||||
- // Paper start - PhantomPreSpawnEvent
|
||||
- com.destroystokyo.paper.event.entity.PhantomPreSpawnEvent event = new com.destroystokyo.paper.event.entity.PhantomPreSpawnEvent(io.papermc.paper.util.MCUtil.toLocation(level, blockPos1), serverPlayer.getBukkitEntity(), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL);
|
||||
- if (!event.callEvent()) {
|
||||
- if (event.shouldAbortSpawn()) {
|
||||
- break;
|
||||
- }
|
||||
- continue;
|
||||
- }
|
||||
- // Paper end - PhantomPreSpawnEvent
|
||||
- Phantom phantom = EntityType.PHANTOM.create(level, EntitySpawnReason.NATURAL);
|
||||
- if (phantom != null) {
|
||||
- phantom.spawningEntity = serverPlayer.getUUID(); // Paper - PhantomPreSpawnEvent
|
||||
- phantom.moveTo(blockPos1, 0.0F, 0.0F);
|
||||
- spawnGroupData = phantom.finalizeSpawn(
|
||||
- level, currentDifficultyAt, EntitySpawnReason.NATURAL, spawnGroupData
|
||||
- );
|
||||
- level.addFreshEntityWithPassengers(phantom, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit
|
||||
- i++;
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
+ // Plazma start - Improve code quality
|
||||
+ if (!spawnEnemies || !level.getGameRules().getBoolean(GameRules.RULE_DOINSOMNIA)) {
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ // Paper start - Ability to control player's insomnia and phantoms
|
||||
+ if (level.paperConfig().entities.behavior.phantomsSpawnAttemptMaxSeconds <= 0) {
|
||||
+ return 0;
|
||||
+ }
|
||||
+ // Paper end - Ability to control player's insomnia and phantoms
|
||||
+
|
||||
+ this.nextTick--;
|
||||
+ if (this.nextTick > 0) {
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ // Paper start - Ability to control player's insomnia and phantoms
|
||||
+ final int spawnAttemptMinSeconds = level.paperConfig().entities.behavior.phantomsSpawnAttemptMinSeconds;
|
||||
+ final int spawnAttemptMaxSeconds = level.paperConfig().entities.behavior.phantomsSpawnAttemptMaxSeconds;
|
||||
+
|
||||
+ final RandomSource randomSource = level.random; // Plazma - moved down
|
||||
+ this.nextTick += (spawnAttemptMinSeconds + randomSource.nextInt(spawnAttemptMaxSeconds - spawnAttemptMinSeconds + 1)) * 20;
|
||||
+ // Paper end - Ability to control player's insomnia and phantoms
|
||||
+
|
||||
+ if (level.getSkyDarken() < level.purpurConfig.phantomSpawnMinSkyDarkness && level.dimensionType().hasSkyLight()) { // Purpur - Add phantom spawning options
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ int totalSpawned = 0;
|
||||
+ for (final ServerPlayer serverPlayer : level.players()) {
|
||||
+ if (serverPlayer.isSpectator() || (level.paperConfig().entities.behavior.phantomsDoNotSpawnOnCreativePlayers && serverPlayer.isCreative())) { // Paper - Add phantom creative and insomniac controls
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ final BlockPos blockPos = serverPlayer.blockPosition();
|
||||
+ if (level.dimensionType().hasSkyLight()
|
||||
+ && ((level.purpurConfig.phantomSpawnOnlyAboveSeaLevel && blockPos.getY() < level.getSeaLevel())
|
||||
+ || (level.purpurConfig.phantomSpawnOnlyWithVisibleSky && !level.canSeeSky(blockPos))
|
||||
+ )
|
||||
+ ) { // Purpur - Add phantom spawning options
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ final DifficultyInstance currentDifficultyAt = level.getCurrentDifficultyAt(blockPos);
|
||||
+ if (!currentDifficultyAt.isHarderThan(randomSource.nextFloat() * (float) level.purpurConfig.phantomSpawnLocalDifficultyChance)) { // Purpur - Add phantom spawning options
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ final ServerStatsCounter stats = serverPlayer.getStats();
|
||||
+ int timeSinceRest = Mth.clamp(stats.getValue(Stats.CUSTOM.get(Stats.TIME_SINCE_REST)), 1, Integer.MAX_VALUE);
|
||||
+ if (randomSource.nextInt(timeSinceRest) < level.paperConfig().entities.behavior.playerInsomniaStartTicks) { // Paper - Ability to control player's insomnia and phantoms
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ final BlockPos blockPos1 = blockPos.above(20 + randomSource.nextInt(15))
|
||||
+ .east(-10 + randomSource.nextInt(21))
|
||||
+ .south(-10 + randomSource.nextInt(21));
|
||||
+ if (!level.plazmaConfig().entity.phantom.loadChunksToSpawn && !level.hasChunkAt(blockPos1)) { // Plazma - Do not load chunks to spawn phantom
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ final BlockState blockState1 = level.getBlockState(blockPos1);
|
||||
+ final FluidState fluidState1 = level.getFluidState(blockPos1);
|
||||
+ if (!NaturalSpawner.isValidEmptySpawnBlock(level, blockPos1, blockState1, fluidState1, EntityType.PHANTOM)) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ SpawnGroupData spawnGroupData = null;
|
||||
+ int maxAttempts = level.purpurConfig.phantomSpawnMinPerAttempt + level.random.nextInt((level.purpurConfig.phantomSpawnMaxPerAttempt < 0 ? currentDifficultyAt.getDifficulty().getId() : level.purpurConfig.phantomSpawnMaxPerAttempt - level.purpurConfig.phantomSpawnMinPerAttempt) + 1); // Purpur - Add phantom spawning options
|
||||
+
|
||||
+ for (int i = 0; i < maxAttempts; i++) {
|
||||
+ // Paper start - PhantomPreSpawnEvent
|
||||
+ com.destroystokyo.paper.event.entity.PhantomPreSpawnEvent event = new com.destroystokyo.paper.event.entity.PhantomPreSpawnEvent(io.papermc.paper.util.MCUtil.toLocation(level, blockPos1), serverPlayer.getBukkitEntity(), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL);
|
||||
+ if (!event.callEvent()) {
|
||||
+ if (event.shouldAbortSpawn()) {
|
||||
+ break;
|
||||
}
|
||||
-
|
||||
- return i;
|
||||
- }
|
||||
+ continue;
|
||||
+ }
|
||||
+ // Paper end - PhantomPreSpawnEvent
|
||||
+
|
||||
+ final Phantom phantom = EntityType.PHANTOM.create(level, EntitySpawnReason.NATURAL);
|
||||
+ if (phantom == null) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ phantom.spawningEntity = serverPlayer.getUUID(); // Paper - PhantomPreSpawnEvent
|
||||
+ phantom.moveTo(blockPos1, 0.0F, 0.0F);
|
||||
+ spawnGroupData = phantom.finalizeSpawn(level, currentDifficultyAt, EntitySpawnReason.NATURAL, spawnGroupData);
|
||||
+ level.addFreshEntityWithPassengers(phantom, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit
|
||||
+ totalSpawned++;
|
||||
}
|
||||
}
|
||||
+
|
||||
+ return totalSpawned;
|
||||
+ // Plazma end - Improve code quality
|
||||
}
|
||||
}
|
||||
@@ -8,4 +8,13 @@
|
||||
+ return Blocks.LAVA.defaultBlockState().setValue(LiquidBlock.LEVEL, getLegacyLevel(state));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -167,7 +_,7 @@
|
||||
|
||||
@Override
|
||||
public int getDropOff(LevelReader level) {
|
||||
- return level.dimensionType().ultraWarm() ? 1 : 2;
|
||||
+ return level.dimensionType().ultraWarm() ? level.getWorldBorder().world.plazmaConfig().block.lavaDropOffNether : level.getWorldBorder().world.plazmaConfig().block.lavaDropOffNormal; // Plazma - Configurable lava dropOff block
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,4 +8,19 @@
|
||||
+ return Blocks.WATER.defaultBlockState().setValue(LiquidBlock.LEVEL, getLegacyLevel(state));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -110,12 +_,12 @@
|
||||
|
||||
@Override
|
||||
public int getDropOff(LevelReader level) {
|
||||
- return 1;
|
||||
+ return level.getWorldBorder().world.plazmaConfig().block.waterDropOffSize; // Plazma - Configurable water dropOff block
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTickDelay(LevelReader level) {
|
||||
- return 5;
|
||||
+ return level.getWorldBorder().world.plazmaConfig().block.waterFlowingTick; // Plazma - Configurable water flowing speed
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,10 +24,16 @@ public final class GlobalConfiguration extends ConfigurationPart {
|
||||
public Player player;
|
||||
public class Player extends ConfigurationPart {
|
||||
|
||||
boolean useMovedToQuicklyBypassPerm = OPTIMIZE;
|
||||
boolean checkSpectatorMovedToQuickly = !OPTIMIZE;
|
||||
|
||||
int advancementCriterionTriggerIdleTick = OPTIMIZE ? 5 : 0;
|
||||
|
||||
@PostProcess
|
||||
void postProcess() {
|
||||
net.minecraft.server.network.ServerGamePacketListenerImpl.useMovedToQuicklyBypassPermission = this.useMovedToQuicklyBypassPerm;
|
||||
net.minecraft.server.network.ServerGamePacketListenerImpl.checkSpectatorMovedToQuickly = this.checkSpectatorMovedToQuickly;
|
||||
|
||||
net.minecraft.advancements.critereon.InventoryChangeTrigger.idleTick = this.advancementCriterionTriggerIdleTick;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,29 @@ public final class WorldConfiguration extends ConfigurationPart {
|
||||
public Entity entity;
|
||||
public class Entity extends ConfigurationPart {
|
||||
|
||||
public int sensorTick = 1;
|
||||
|
||||
public boolean suppressErrorsFromDirtyAttributes = OPTIMIZE;
|
||||
public boolean populateLootTableOnlyForPlayerInteraction = OPTIMIZE;
|
||||
|
||||
public Phantom phantom;
|
||||
public class Phantom extends ConfigurationPart {
|
||||
|
||||
public boolean loadChunksToSpawn = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Block block;
|
||||
public class Block extends ConfigurationPart {
|
||||
|
||||
public int waterFlowingTick = 5;
|
||||
public int waterDropOffSize = 1;
|
||||
|
||||
public int lavaDropOffNormal = 2;
|
||||
public int lavaDropOffNether = 1;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user