mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
81 lines
4.2 KiB
Diff
81 lines
4.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
Date: Fri, 7 Aug 2020 12:53:36 -0500
|
|
Subject: [PATCH] Add no-random-tick block list
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
index 14c3e9fcdfb088d3fe0a15266b50a7da82a5d240..0ef7b405ad9174045128fb5445f0bc0e22a3f2e2 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -318,7 +318,7 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
|
|
this.players = Lists.newArrayList();
|
|
this.entityTickList = new EntityTickList();
|
|
Predicate<Block> predicate = (block) -> { // CraftBukkit - decompile eror
|
|
- return block == null || block.defaultBlockState().isAir();
|
|
+ return block == null || block.defaultBlockState().isAir() || purpurConfig.noRandomTickBlocks.contains(block); // Purpur
|
|
};
|
|
DefaultedRegistry registryblocks = Registry.BLOCK;
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
|
index a107304351381d68fdaa35a4d7ff214e6c1546a6..6e5dcf3c8a537729a18c085ebb5ab46b59c1d24c 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
|
@@ -893,10 +893,12 @@ public abstract class BlockBehaviour {
|
|
}
|
|
|
|
public void tick(ServerLevel world, BlockPos pos, Random random) {
|
|
+ if (world.purpurConfig.noRandomTickBlocks.contains(getBlock())) return; // Purpur
|
|
this.getBlock().tick(this.asState(), world, pos, random);
|
|
}
|
|
|
|
public void randomTick(ServerLevel world, BlockPos pos, Random random) {
|
|
+ if (world.purpurConfig.noRandomTickBlocks.contains(getBlock())) return; // Purpur
|
|
this.getBlock().randomTick(this.asState(), world, pos, random);
|
|
}
|
|
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index f9d66b7aa5d2c13190f438b14bd4bf6626e2c123..7d7644863256cc69077292fd1d2fdc38f9e378f1 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -12,8 +12,10 @@ import org.bukkit.configuration.ConfigurationSection;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
+import java.util.HashSet;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
+import java.util.Set;
|
|
import java.util.logging.Level;
|
|
|
|
import static net.pl3x.purpur.PurpurConfig.log;
|
|
@@ -264,6 +266,28 @@ public class PurpurWorldConfig {
|
|
voidDamageDealt = getDouble("gameplay-mechanics.void-damage-dealt", voidDamageDealt);
|
|
}
|
|
|
|
+ public Set<Block> noRandomTickBlocks = new HashSet<>();
|
|
+ private void noRandomTickBlocks() {
|
|
+ if (PurpurConfig.version < 11) {
|
|
+ List<String> oldList = PurpurConfig.config.getStringList("world-settings." + worldName + ".blocks.no-tick");
|
|
+ if (!oldList.isEmpty()) {
|
|
+ PurpurConfig.config.set("world-settings." + worldName + ".blocks.no-random-tick", oldList);
|
|
+ PurpurConfig.config.set("world-settings." + worldName + ".blocks.no-tick", null);
|
|
+ }
|
|
+ oldList = PurpurConfig.config.getStringList("world-settings.default.blocks.no-tick");
|
|
+ if (!oldList.isEmpty()) {
|
|
+ PurpurConfig.config.set("world-settings.default.blocks.no-random-tick", oldList);
|
|
+ PurpurConfig.config.set("world-settings.default.blocks.no-tick", null);
|
|
+ }
|
|
+ }
|
|
+ getList("blocks.no-random-tick", new ArrayList<>()).forEach(key -> {
|
|
+ Block block = Registry.BLOCK.get(new ResourceLocation(key.toString()));
|
|
+ if (!block.defaultBlockState().isAir()) {
|
|
+ noRandomTickBlocks.add(block);
|
|
+ }
|
|
+ });
|
|
+ }
|
|
+
|
|
public boolean anvilAllowColors = false;
|
|
private void anvilSettings() {
|
|
anvilAllowColors = getBoolean("blocks.anvil.allow-colors", anvilAllowColors);
|