Compare commits
16 Commits
1.21.5-785
...
ver/1.21.5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c9fa9d9e1 | ||
|
|
a4124d5cda | ||
|
|
3eedf86153 | ||
|
|
68e8267c24 | ||
|
|
cd8a4e11dc | ||
|
|
c69087ba64 | ||
|
|
784ce10986 | ||
|
|
25b9e3f213 | ||
|
|
4855a4f76f | ||
|
|
818e1132df | ||
|
|
4cb423d24a | ||
|
|
6eebbe4221 | ||
|
|
85f3e2875f | ||
|
|
07f2fcd405 | ||
|
|
9e3360efa0 | ||
|
|
8c0a143ce1 |
@@ -2,7 +2,7 @@ group = me.earthme.luminol
|
||||
version=1.21.5-R0.1-SNAPSHOT
|
||||
mcVersion=1.21.5
|
||||
|
||||
foliaRef=3aba0068ded3f23bf8fa5cac6c70cb48f1d70478
|
||||
foliaRef=dfa3ca475215e9c496e5aa6629f1897f93f7a7d4
|
||||
|
||||
org.gradle.configuration-cache=true
|
||||
org.gradle.caching=true
|
||||
|
||||
@@ -4,177 +4,6 @@ Date: Sun, 12 Jan 2025 13:27:38 +0800
|
||||
Subject: [PATCH] Pufferfish Sentry
|
||||
|
||||
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/sentry/SentryContext.java b/src/main/java/gg/pufferfish/pufferfish/sentry/SentryContext.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..c7772aac00f6db664f7a5673bc2585fa025e6aad
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/sentry/SentryContext.java
|
||||
@@ -0,0 +1,165 @@
|
||||
+package gg.pufferfish.pufferfish.sentry;
|
||||
+
|
||||
+import com.google.gson.Gson;
|
||||
+
|
||||
+import java.lang.reflect.Field;
|
||||
+import java.lang.reflect.Modifier;
|
||||
+import java.util.Map;
|
||||
+import java.util.TreeMap;
|
||||
+
|
||||
+import org.apache.logging.log4j.ThreadContext;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.bukkit.event.player.PlayerEvent;
|
||||
+import org.bukkit.plugin.Plugin;
|
||||
+import org.bukkit.plugin.RegisteredListener;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+public class SentryContext {
|
||||
+
|
||||
+ private static final Gson GSON = new Gson();
|
||||
+
|
||||
+ public static void setPluginContext(@Nullable Plugin plugin) {
|
||||
+ if (plugin != null) {
|
||||
+ ThreadContext.put("pufferfishsentry_pluginname", plugin.getName());
|
||||
+ ThreadContext.put("pufferfishsentry_pluginversion", plugin.getPluginMeta().getVersion());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void removePluginContext() {
|
||||
+ ThreadContext.remove("pufferfishsentry_pluginname");
|
||||
+ ThreadContext.remove("pufferfishsentry_pluginversion");
|
||||
+ }
|
||||
+
|
||||
+ public static void setSenderContext(@Nullable CommandSender sender) {
|
||||
+ if (sender != null) {
|
||||
+ ThreadContext.put("pufferfishsentry_playername", sender.getName());
|
||||
+ if (sender instanceof Player player) {
|
||||
+ ThreadContext.put("pufferfishsentry_playerid", player.getUniqueId().toString());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void removeSenderContext() {
|
||||
+ ThreadContext.remove("pufferfishsentry_playername");
|
||||
+ ThreadContext.remove("pufferfishsentry_playerid");
|
||||
+ }
|
||||
+
|
||||
+ public static void setEventContext(Event event, RegisteredListener registration) {
|
||||
+ setPluginContext(registration.getPlugin());
|
||||
+
|
||||
+ try {
|
||||
+ // Find the player that was involved with this event
|
||||
+ Player player = null;
|
||||
+ if (event instanceof PlayerEvent) {
|
||||
+ player = ((PlayerEvent) event).getPlayer();
|
||||
+ } else {
|
||||
+ Class<? extends Event> eventClass = event.getClass();
|
||||
+
|
||||
+ Field playerField = null;
|
||||
+
|
||||
+ for (Field field : eventClass.getDeclaredFields()) {
|
||||
+ if (field.getType().equals(Player.class)) {
|
||||
+ playerField = field;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (playerField != null) {
|
||||
+ playerField.setAccessible(true);
|
||||
+ player = (Player) playerField.get(event);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (player != null) {
|
||||
+ setSenderContext(player);
|
||||
+ }
|
||||
+ } catch (Exception ignored) {
|
||||
+ } // We can't really safely log exceptions.
|
||||
+
|
||||
+ ThreadContext.put("pufferfishsentry_eventdata", GSON.toJson(serializeFields(event)));
|
||||
+ }
|
||||
+
|
||||
+ public static void removeEventContext() {
|
||||
+ removePluginContext();
|
||||
+ removeSenderContext();
|
||||
+ ThreadContext.remove("pufferfishsentry_eventdata");
|
||||
+ }
|
||||
+
|
||||
+ private static Map<String, String> serializeFields(Object object) {
|
||||
+ Map<String, String> fields = new TreeMap<>();
|
||||
+ fields.put("_class", object.getClass().getName());
|
||||
+ for (Field declaredField : object.getClass().getDeclaredFields()) {
|
||||
+ try {
|
||||
+ if (Modifier.isStatic(declaredField.getModifiers())) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ String fieldName = declaredField.getName();
|
||||
+ if (fieldName.equals("handlers")) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ declaredField.setAccessible(true);
|
||||
+ Object value = declaredField.get(object);
|
||||
+ if (value != null) {
|
||||
+ fields.put(fieldName, value.toString());
|
||||
+ } else {
|
||||
+ fields.put(fieldName, "<null>");
|
||||
+ }
|
||||
+ } catch (Exception ignored) {
|
||||
+ } // We can't really safely log exceptions.
|
||||
+ }
|
||||
+ return fields;
|
||||
+ }
|
||||
+
|
||||
+ public static class State {
|
||||
+
|
||||
+ private Plugin plugin;
|
||||
+ private Command command;
|
||||
+ private String commandLine;
|
||||
+ private Event event;
|
||||
+ private RegisteredListener registeredListener;
|
||||
+
|
||||
+ public Plugin getPlugin() {
|
||||
+ return plugin;
|
||||
+ }
|
||||
+
|
||||
+ public void setPlugin(Plugin plugin) {
|
||||
+ this.plugin = plugin;
|
||||
+ }
|
||||
+
|
||||
+ public Command getCommand() {
|
||||
+ return command;
|
||||
+ }
|
||||
+
|
||||
+ public void setCommand(Command command) {
|
||||
+ this.command = command;
|
||||
+ }
|
||||
+
|
||||
+ public String getCommandLine() {
|
||||
+ return commandLine;
|
||||
+ }
|
||||
+
|
||||
+ public void setCommandLine(String commandLine) {
|
||||
+ this.commandLine = commandLine;
|
||||
+ }
|
||||
+
|
||||
+ public Event getEvent() {
|
||||
+ return event;
|
||||
+ }
|
||||
+
|
||||
+ public void setEvent(Event event) {
|
||||
+ this.event = event;
|
||||
+ }
|
||||
+
|
||||
+ public RegisteredListener getRegisteredListener() {
|
||||
+ return registeredListener;
|
||||
+ }
|
||||
+
|
||||
+ public void setRegisteredListener(RegisteredListener registeredListener) {
|
||||
+ this.registeredListener = registeredListener;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||
index ab36e3aaff57e2f27b5aed06b4bdfe277f86a35e..96da9f1082ab134d197b3a6069f2fcdf38585efe 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||
|
||||
@@ -4,177 +4,6 @@ Date: Sun, 12 Jan 2025 14:00:28 +0800
|
||||
Subject: [PATCH] Pufferfish SIMD Utilities
|
||||
|
||||
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..856de1331b15542c00e01990f471fa5152722c11
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java
|
||||
@@ -0,0 +1,35 @@
|
||||
+package gg.pufferfish.pufferfish.simd;
|
||||
+
|
||||
+import jdk.incubator.vector.FloatVector;
|
||||
+import jdk.incubator.vector.IntVector;
|
||||
+import jdk.incubator.vector.VectorSpecies;
|
||||
+import org.slf4j.Logger;
|
||||
+
|
||||
+/**
|
||||
+ * Basically, java is annoying and we have to push this out to its own class.
|
||||
+ */
|
||||
+@Deprecated
|
||||
+public class SIMDChecker {
|
||||
+
|
||||
+ @Deprecated
|
||||
+ public static boolean canEnable(Logger logger) {
|
||||
+ try {
|
||||
+ SIMDDetection.testRun = true;
|
||||
+
|
||||
+ VectorSpecies<Integer> ISPEC = IntVector.SPECIES_PREFERRED;
|
||||
+ VectorSpecies<Float> FSPEC = FloatVector.SPECIES_PREFERRED;
|
||||
+
|
||||
+ logger.info("Max SIMD vector size on this system is {} bits (int)", ISPEC.vectorBitSize());
|
||||
+ logger.info("Max SIMD vector size on this system is " + FSPEC.vectorBitSize() + " bits (float)");
|
||||
+
|
||||
+ if (ISPEC.elementSize() < 2 || FSPEC.elementSize() < 2) {
|
||||
+ logger.warn("SIMD is not properly supported on this system!");
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+ } catch (NoClassDefFoundError | Exception ignored) {} // Basically, we don't do anything. This lets us detect if it's not functional and disable it.
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0a64cd0e88083ac4af6674ad0fb07b771109c737
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java
|
||||
@@ -0,0 +1,34 @@
|
||||
+package gg.pufferfish.pufferfish.simd;
|
||||
+
|
||||
+import org.slf4j.Logger;
|
||||
+
|
||||
+@Deprecated
|
||||
+public class SIMDDetection {
|
||||
+
|
||||
+ public static boolean isEnabled = false;
|
||||
+ public static boolean testRun = false;
|
||||
+
|
||||
+ @Deprecated
|
||||
+ public static boolean canEnable(Logger logger) {
|
||||
+ try {
|
||||
+ return SIMDChecker.canEnable(logger);
|
||||
+ } catch (NoClassDefFoundError | Exception ignored) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Deprecated
|
||||
+ public static int getJavaVersion() {
|
||||
+ // https://stackoverflow.com/a/2591122
|
||||
+ String version = System.getProperty("java.version");
|
||||
+ if(version.startsWith("1.")) {
|
||||
+ version = version.substring(2, 3);
|
||||
+ } else {
|
||||
+ int dot = version.indexOf(".");
|
||||
+ if(dot != -1) { version = version.substring(0, dot); }
|
||||
+ }
|
||||
+ version = version.split("-")[0]; // Azul is stupid
|
||||
+ return Integer.parseInt(version);
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/VectorMapPalette.java b/src/main/java/gg/pufferfish/pufferfish/simd/VectorMapPalette.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..c26dcaaa2e85882730c854099df80d69eec70f33
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/simd/VectorMapPalette.java
|
||||
@@ -0,0 +1,84 @@
|
||||
+package gg.pufferfish.pufferfish.simd;
|
||||
+
|
||||
+import jdk.incubator.vector.FloatVector;
|
||||
+import jdk.incubator.vector.IntVector;
|
||||
+import jdk.incubator.vector.VectorMask;
|
||||
+import jdk.incubator.vector.VectorSpecies;
|
||||
+import org.bukkit.map.MapPalette;
|
||||
+
|
||||
+import java.awt.*;
|
||||
+
|
||||
+@Deprecated
|
||||
+public class VectorMapPalette {
|
||||
+
|
||||
+ private static final VectorSpecies<Integer> I_SPEC = IntVector.SPECIES_PREFERRED;
|
||||
+ private static final VectorSpecies<Float> F_SPEC = FloatVector.SPECIES_PREFERRED;
|
||||
+
|
||||
+ @Deprecated
|
||||
+ public static void matchColorVectorized(int[] in, byte[] out) {
|
||||
+ int speciesLength = I_SPEC.length();
|
||||
+ int i;
|
||||
+ for (i = 0; i < in.length - speciesLength; i += speciesLength) {
|
||||
+ float[] redsArr = new float[speciesLength];
|
||||
+ float[] bluesArr = new float[speciesLength];
|
||||
+ float[] greensArr = new float[speciesLength];
|
||||
+ int[] alphasArr = new int[speciesLength];
|
||||
+
|
||||
+ for (int j = 0; j < speciesLength; j++) {
|
||||
+ alphasArr[j] = (in[i + j] >> 24) & 0xFF;
|
||||
+ redsArr[j] = (in[i + j] >> 16) & 0xFF;
|
||||
+ greensArr[j] = (in[i + j] >> 8) & 0xFF;
|
||||
+ bluesArr[j] = (in[i + j] >> 0) & 0xFF;
|
||||
+ }
|
||||
+
|
||||
+ IntVector alphas = IntVector.fromArray(I_SPEC, alphasArr, 0);
|
||||
+ FloatVector reds = FloatVector.fromArray(F_SPEC, redsArr, 0);
|
||||
+ FloatVector greens = FloatVector.fromArray(F_SPEC, greensArr, 0);
|
||||
+ FloatVector blues = FloatVector.fromArray(F_SPEC, bluesArr, 0);
|
||||
+ IntVector resultIndex = IntVector.zero(I_SPEC);
|
||||
+ VectorMask<Integer> modificationMask = VectorMask.fromLong(I_SPEC, 0xffffffff);
|
||||
+
|
||||
+ modificationMask = modificationMask.and(alphas.lt(128).not());
|
||||
+ FloatVector bestDistances = FloatVector.broadcast(F_SPEC, Float.MAX_VALUE);
|
||||
+
|
||||
+ for (int c = 4; c < MapPalette.colors.length; c++) {
|
||||
+ // We're using 32-bit floats here because it's 2x faster and nobody will know the difference.
|
||||
+ // For correctness, the original algorithm uses 64-bit floats instead. Completely unnecessary.
|
||||
+ FloatVector compReds = FloatVector.broadcast(F_SPEC, MapPalette.colors[c].getRed());
|
||||
+ FloatVector compGreens = FloatVector.broadcast(F_SPEC, MapPalette.colors[c].getGreen());
|
||||
+ FloatVector compBlues = FloatVector.broadcast(F_SPEC, MapPalette.colors[c].getBlue());
|
||||
+
|
||||
+ FloatVector rMean = reds.add(compReds).div(2.0f);
|
||||
+ FloatVector rDiff = reds.sub(compReds);
|
||||
+ FloatVector gDiff = greens.sub(compGreens);
|
||||
+ FloatVector bDiff = blues.sub(compBlues);
|
||||
+
|
||||
+ FloatVector weightR = rMean.div(256.0f).add(2);
|
||||
+ FloatVector weightG = FloatVector.broadcast(F_SPEC, 4.0f);
|
||||
+ FloatVector weightB = FloatVector.broadcast(F_SPEC, 255.0f).sub(rMean).div(256.0f).add(2.0f);
|
||||
+
|
||||
+ FloatVector distance = weightR.mul(rDiff).mul(rDiff).add(weightG.mul(gDiff).mul(gDiff)).add(weightB.mul(bDiff).mul(bDiff));
|
||||
+
|
||||
+ // Now we compare to the best distance we've found.
|
||||
+ // This mask contains a "1" if better, and a "0" otherwise.
|
||||
+ VectorMask<Float> bestDistanceMask = distance.lt(bestDistances);
|
||||
+ bestDistances = bestDistances.blend(distance, bestDistanceMask); // Update the best distances
|
||||
+
|
||||
+ // Update the result array
|
||||
+ // We also AND with the modification mask because we don't want to interfere if the alpha value isn't large enough.
|
||||
+ resultIndex = resultIndex.blend(c, bestDistanceMask.cast(I_SPEC).and(modificationMask)); // Update the results
|
||||
+ }
|
||||
+
|
||||
+ for (int j = 0; j < speciesLength; j++) {
|
||||
+ int index = resultIndex.lane(j);
|
||||
+ out[i + j] = (byte) (index < 128 ? index : -129 + (index - 127));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // For the final ones, fall back to the regular method
|
||||
+ for (; i < in.length; i++) {
|
||||
+ out[i] = MapPalette.matchColor(new Color(in[i], true));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/map/MapPalette.java b/src/main/java/org/bukkit/map/MapPalette.java
|
||||
index fc9728342de7605da69813fb44b008c1343124c0..d322e6c47d751b41e4b2f2fc45bb8d7498bff21d 100644
|
||||
--- a/src/main/java/org/bukkit/map/MapPalette.java
|
||||
|
||||
@@ -4,193 +4,6 @@ Date: Mon, 27 Jan 2025 13:01:59 +0800
|
||||
Subject: [PATCH] Tick regions api
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/api/RegionStats.java b/src/main/java/me/earthme/luminol/api/RegionStats.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..96147cace1550d14c682258dab0397587dcf76a4
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/api/RegionStats.java
|
||||
@@ -0,0 +1,25 @@
|
||||
+package me.earthme.luminol.api;
|
||||
+
|
||||
+/**
|
||||
+ * A simple package of folia's tick region state.It linked to the RegionStats of the nms part so that</br>
|
||||
+ * You could call these methods to get the status of this tick region</br>
|
||||
+ */
|
||||
+public interface RegionStats {
|
||||
+ /**
|
||||
+ * Get the entity count in this tick region
|
||||
+ * @return the entity count
|
||||
+ */
|
||||
+ int getEntityCount();
|
||||
+
|
||||
+ /**
|
||||
+ * Get the player count in this tick region
|
||||
+ * @return the player count
|
||||
+ */
|
||||
+ int getPlayerCount();
|
||||
+
|
||||
+ /**
|
||||
+ * Get the chunk count in this tick region
|
||||
+ * @return the chunk count
|
||||
+ */
|
||||
+ int getChunkCount();
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/api/ThreadedRegion.java b/src/main/java/me/earthme/luminol/api/ThreadedRegion.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..01dac0602b5f66f80c0adfbb779666fe0325a24f
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/api/ThreadedRegion.java
|
||||
@@ -0,0 +1,56 @@
|
||||
+package me.earthme.luminol.api;
|
||||
+
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.World;
|
||||
+
|
||||
+import javax.annotation.Nullable;
|
||||
+
|
||||
+/**
|
||||
+ * A mirror of folia's ThreadedRegion</br>
|
||||
+ * Including some handy methods to get the information of the tick region</br>
|
||||
+ * Note: You should call these methods inside this tick region's thread context
|
||||
+ */
|
||||
+public interface ThreadedRegion {
|
||||
+ /**
|
||||
+ * Get the center chunk pos of this tick region</br>
|
||||
+ * Note:</br>
|
||||
+ * 1.Global region will return a null value(But we don't finish the global region yet()</br>
|
||||
+ * 2.You should call these methods inside this tick region's thread context
|
||||
+ * @return The center chunk pos
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ Location getCenterChunkPos();
|
||||
+
|
||||
+ /**
|
||||
+ * Get the dead section percent of this tick region
|
||||
+ * Note: </br>
|
||||
+ * 1.Dead percent is mean the percent of the unloaded chunk count of this tick region, which is also used for determine
|
||||
+ * that the tick region should or not check for splitting</br>
|
||||
+ * 2.You should call these methods inside this tick region's thread context
|
||||
+ * @return The dead section percent
|
||||
+ */
|
||||
+ double getDeadSectionPercent();
|
||||
+
|
||||
+ /**
|
||||
+ * Get the tick region data of this tick region</br>
|
||||
+ * Note:</br>
|
||||
+ * 1.You should call this method inside this tick region's thread context</br>
|
||||
+ * 2.You should call these methods inside this tick region's thread context
|
||||
+ * @return The tick region data
|
||||
+ */
|
||||
+ TickRegionData getTickRegionData();
|
||||
+
|
||||
+ /**
|
||||
+ * Get the world of this tick region</br>
|
||||
+ * Note: Global region will return a null value too
|
||||
+ * @return The world of this tick region
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ World getWorld();
|
||||
+
|
||||
+ /**
|
||||
+ * Get the id of the tick region</br>
|
||||
+ * @return The id of the tick region
|
||||
+ */
|
||||
+ long getId();
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/api/ThreadedRegionizer.java b/src/main/java/me/earthme/luminol/api/ThreadedRegionizer.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..ff31a68a019fd9e5e687e6818f8729f4950bc060
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/api/ThreadedRegionizer.java
|
||||
@@ -0,0 +1,56 @@
|
||||
+package me.earthme.luminol.api;
|
||||
+
|
||||
+import org.bukkit.Location;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+import java.util.Collection;
|
||||
+
|
||||
+/**
|
||||
+ * A mirror of folia's ThreadedRegionizer
|
||||
+ */
|
||||
+public interface ThreadedRegionizer {
|
||||
+ /**
|
||||
+ * Get all the tick regions
|
||||
+ * @return Temporary copied collection of all tick regions
|
||||
+ */
|
||||
+ Collection<ThreadedRegion> getAllRegions();
|
||||
+
|
||||
+ /**
|
||||
+ * Get the tick region at the given chunk coordinates
|
||||
+ * @param chunkX Chunk X
|
||||
+ * @param chunkZ Chunk Z
|
||||
+ * @return The tick region at the given chunk coordinates
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ ThreadedRegion getAtSynchronized(int chunkX, int chunkZ);
|
||||
+
|
||||
+ /**
|
||||
+ * Get the tick region at the given chunk coordinates
|
||||
+ * @param chunkX Chunk X
|
||||
+ * @param chunkZ Chunk Z
|
||||
+ * @return The tick region at the given chunk coordinates
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ ThreadedRegion getAtUnSynchronized(int chunkX, int chunkZ);
|
||||
+
|
||||
+ /**
|
||||
+ * Get the tick region at the given location
|
||||
+ * @param pos The location
|
||||
+ * @return The tick region at the given location
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ default ThreadedRegion getAtSynchronized(@NotNull Location pos) {
|
||||
+ return this.getAtSynchronized(pos.getBlockX() >> 4, pos.getBlockZ() >> 4);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the tick region at the given location
|
||||
+ * @param pos The location
|
||||
+ * @return The tick region at the given location
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ default ThreadedRegion getAtUnSynchronized(@NotNull Location pos) {
|
||||
+ return this.getAtUnSynchronized(pos.getBlockX() >> 4, pos.getBlockZ() >> 4);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/api/TickRegionData.java b/src/main/java/me/earthme/luminol/api/TickRegionData.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..ecde4462b08d701b8bff9f26902f17754cf791dd
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/api/TickRegionData.java
|
||||
@@ -0,0 +1,26 @@
|
||||
+package me.earthme.luminol.api;
|
||||
+
|
||||
+import org.bukkit.World;
|
||||
+
|
||||
+/**
|
||||
+ * A mirror of folia's tick region data
|
||||
+ */
|
||||
+public interface TickRegionData {
|
||||
+ /**
|
||||
+ * Get the world it's currently holding
|
||||
+ * @return the world
|
||||
+ */
|
||||
+ World getWorld();
|
||||
+
|
||||
+ /**
|
||||
+ * Get the current tick count
|
||||
+ * @return the current tick count
|
||||
+ */
|
||||
+ long getCurrentTickCount();
|
||||
+
|
||||
+ /**
|
||||
+ * Get the region stats
|
||||
+ * @return the region stats
|
||||
+ */
|
||||
+ RegionStats getRegionStats();
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
|
||||
index a8b64f78bf3c453094074b4b4d3c8fd07b9eb273..7927012c1afe5289d22879353a88a4574da91e01 100644
|
||||
--- a/src/main/java/org/bukkit/World.java
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Thu, 30 Jan 2025 09:29:03 +0800
|
||||
From: MrHua269 <mrhua269@gmail.com>
|
||||
Date: Thu, 12 Jun 2025 08:00:15 +0800
|
||||
Subject: [PATCH] Purpur Lobotomize stuck villagers
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Villager.java b/src/main/java/org/bukkit/entity/Villager.java
|
||||
index 02b86d9615f8150b13ff0beefd5ca502c0494f99..3a444609ea9fdeee9057d593fbd4d38cc9e1ad68 100644
|
||||
index 4d88bb2eaa43709fb6103a6f77d8c01e83bfe743..60b87d52c20cec947b196f47fc333bc643accbd2 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Villager.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Villager.java
|
||||
@@ -391,4 +391,13 @@ public interface Villager extends AbstractVillager {
|
||||
* reputation regardless of its impact and the player associated.
|
||||
@@ -408,4 +408,13 @@ public interface Villager extends AbstractVillager {
|
||||
* Demand is still updated even if all events are canceled.
|
||||
*/
|
||||
public void clearReputations();
|
||||
public void restock();
|
||||
+ // Purpur start
|
||||
+
|
||||
+ /**
|
||||
|
||||
@@ -1,357 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Fri, 31 Jan 2025 20:28:47 +0800
|
||||
Subject: [PATCH] Add missing teleportation apis for folia
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/earthme/luminol/api/entity/EntityTeleportAsyncEvent.java b/src/main/java/me/earthme/luminol/api/entity/EntityTeleportAsyncEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..a31c803831dad3d31386924cbe27deff59855fc9
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/api/entity/EntityTeleportAsyncEvent.java
|
||||
@@ -0,0 +1,68 @@
|
||||
+package me.earthme.luminol.api.entity;
|
||||
+
|
||||
+import org.apache.commons.lang3.Validate;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.entity.Entity;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * A simple event fired when a teleportAsync was called
|
||||
+ * @see org.bukkit.entity.Entity#teleportAsync(org.bukkit.Location, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause)
|
||||
+ * @see org.bukkit.entity.Entity#teleportAsync(org.bukkit.Location)
|
||||
+ * (Also fired when teleportAsync called from nms)
|
||||
+ */
|
||||
+public class EntityTeleportAsyncEvent extends Event {
|
||||
+ private static final HandlerList HANDLERS = new HandlerList();
|
||||
+
|
||||
+ private final Entity entity;
|
||||
+ private final PlayerTeleportEvent.TeleportCause teleportCause;
|
||||
+ private final Location destination;
|
||||
+
|
||||
+ public EntityTeleportAsyncEvent(Entity entity, PlayerTeleportEvent.TeleportCause teleportCause, Location destination) {
|
||||
+ Validate.notNull(entity, "entity cannot be a null value!");
|
||||
+ Validate.notNull(teleportCause, "teleportCause cannot be a null value!");
|
||||
+ Validate.notNull(destination, "destination cannot be a null value!");
|
||||
+
|
||||
+ this.entity = entity;
|
||||
+ this.teleportCause = teleportCause;
|
||||
+ this.destination = destination;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the entity is about to be teleported
|
||||
+ * @return that entity
|
||||
+ */
|
||||
+ public @NotNull Entity getEntity() {
|
||||
+ return this.entity;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the cause of the teleport
|
||||
+ * @return the cause
|
||||
+ */
|
||||
+ public @NotNull PlayerTeleportEvent.TeleportCause getTeleportCause() {
|
||||
+ return this.teleportCause;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the destination of the teleport
|
||||
+ * @return the destination
|
||||
+ */
|
||||
+ public @NotNull Location getDestination() {
|
||||
+ return this.destination;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull HandlerList getHandlers() {
|
||||
+ return HANDLERS;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return HANDLERS;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/api/entity/PostEntityPortalEvent.java b/src/main/java/me/earthme/luminol/api/entity/PostEntityPortalEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..dd3087b407ccf4e96448701e6fbf75705498f982
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/api/entity/PostEntityPortalEvent.java
|
||||
@@ -0,0 +1,41 @@
|
||||
+package me.earthme.luminol.api.entity;
|
||||
+
|
||||
+import org.apache.commons.lang3.Validate;
|
||||
+import org.bukkit.entity.Entity;
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * A simple event created for missing teleport events api of folia
|
||||
+ * This event is fired when the entity portal process has been done
|
||||
+ */
|
||||
+public class PostEntityPortalEvent extends Event {
|
||||
+ private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
+
|
||||
+ private final Entity teleportedEntity;
|
||||
+
|
||||
+ public PostEntityPortalEvent(Entity teleportedEntity) {
|
||||
+ Validate.notNull(teleportedEntity, "teleportedEntity cannot be null!");
|
||||
+
|
||||
+ this.teleportedEntity = teleportedEntity;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the entity which was teleported
|
||||
+ * @return the entity which was teleported
|
||||
+ */
|
||||
+ public Entity getTeleportedEntity() {
|
||||
+ return this.teleportedEntity;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull HandlerList getHandlers() {
|
||||
+ return HANDLER_LIST;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return HANDLER_LIST;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/api/entity/PreEntityPortalEvent.java b/src/main/java/me/earthme/luminol/api/entity/PreEntityPortalEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..fc844429e3ecfe2529c0a49b8a5d958eeb188ad9
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/api/entity/PreEntityPortalEvent.java
|
||||
@@ -0,0 +1,78 @@
|
||||
+package me.earthme.luminol.api.entity;
|
||||
+
|
||||
+import org.apache.commons.lang3.Validate;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.World;
|
||||
+import org.bukkit.entity.Entity;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * A simple event created for missing teleport events api of folia
|
||||
+ * This event will be fired when a portal teleportation is about to happen
|
||||
+ */
|
||||
+public class PreEntityPortalEvent extends Event implements Cancellable {
|
||||
+ private static final HandlerList HANDLERS = new HandlerList();
|
||||
+
|
||||
+ private final Entity entity;
|
||||
+ private final Location portalPos;
|
||||
+ private final World destination;
|
||||
+
|
||||
+ private boolean cancelled = false;
|
||||
+
|
||||
+ public PreEntityPortalEvent(Entity entity, Location portalPos, World destination) {
|
||||
+ Validate.notNull(entity, "entity cannot be null!");
|
||||
+ Validate.notNull(portalPos, "portalPos cannot be null!");
|
||||
+ Validate.notNull(destination, "destination cannot be null!");
|
||||
+
|
||||
+ this.entity = entity;
|
||||
+ this.portalPos = portalPos;
|
||||
+ this.destination = destination;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the entity that is about to teleport
|
||||
+ * @return the entity
|
||||
+ */
|
||||
+ public @NotNull Entity getEntity() {
|
||||
+ return this.entity;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the location of the portal
|
||||
+ * @return the portal location
|
||||
+ */
|
||||
+ public @NotNull Location getPortalPos() {
|
||||
+ return this.portalPos;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the destination world
|
||||
+ * @return the destination world
|
||||
+ */
|
||||
+ public @NotNull World getDestination() {
|
||||
+ return this.destination;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return this.cancelled;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ this.cancelled = cancel;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull HandlerList getHandlers() {
|
||||
+ return HANDLERS;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return HANDLERS;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/api/entity/player/PostPlayerRespawnEvent.java b/src/main/java/me/earthme/luminol/api/entity/player/PostPlayerRespawnEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..9a561455560dfeee1d8762297ebf15a7c11de4d1
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/api/entity/player/PostPlayerRespawnEvent.java
|
||||
@@ -0,0 +1,40 @@
|
||||
+package me.earthme.luminol.api.entity.player;
|
||||
+
|
||||
+import org.apache.commons.lang3.Validate;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * A simple event fired when the respawn process of player is done
|
||||
+ */
|
||||
+public class PostPlayerRespawnEvent extends Event {
|
||||
+ private static final HandlerList HANDLERS = new HandlerList();
|
||||
+
|
||||
+ private final Player player;
|
||||
+
|
||||
+ public PostPlayerRespawnEvent(Player player) {
|
||||
+ Validate.notNull(player, "Player cannot be a null value!");
|
||||
+
|
||||
+ this.player = player;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the respawned player
|
||||
+ * @return the player
|
||||
+ */
|
||||
+ public @NotNull Player getPlayer() {
|
||||
+ return this.player;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull HandlerList getHandlers() {
|
||||
+ return HANDLERS;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return HANDLERS;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/api/portal/EndPlatformCreateEvent.java b/src/main/java/me/earthme/luminol/api/portal/EndPlatformCreateEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..cf87a7cce5d1ebec9709b762595609344807150b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/api/portal/EndPlatformCreateEvent.java
|
||||
@@ -0,0 +1,35 @@
|
||||
+package me.earthme.luminol.api.portal;
|
||||
+
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * A event fired when an end platform is created.
|
||||
+ */
|
||||
+public class EndPlatformCreateEvent extends Event implements Cancellable {
|
||||
+ private static final HandlerList HANDLERS = new HandlerList();
|
||||
+
|
||||
+ private boolean cancelled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return this.cancelled;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ this.cancelled = cancel;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull HandlerList getHandlers() {
|
||||
+ return HANDLERS;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return HANDLERS;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/earthme/luminol/api/portal/PortalLocateEvent.java b/src/main/java/me/earthme/luminol/api/portal/PortalLocateEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..e09ffb99aad6f6acca3d6a411877715b90413eb0
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/api/portal/PortalLocateEvent.java
|
||||
@@ -0,0 +1,53 @@
|
||||
+package me.earthme.luminol.api.portal;
|
||||
+
|
||||
+import org.apache.commons.lang3.Validate;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * A event fired when the portal process started locating the destination position
|
||||
+ * Notice: If you changed the destination to an another position in end teleportation.The end platform won't create under the entity and won't create
|
||||
+ * if the position is out of current tick region
|
||||
+ */
|
||||
+public class PortalLocateEvent extends Event {
|
||||
+ private static final HandlerList HANDLERS = new HandlerList();
|
||||
+
|
||||
+ private final Location original;
|
||||
+ private final Location destination;
|
||||
+
|
||||
+ public PortalLocateEvent(Location original, Location destination) {
|
||||
+ Validate.notNull(original, "original couldn't be null!");
|
||||
+ Validate.notNull(destination, "destination couldn't be null!");
|
||||
+
|
||||
+ this.original = original;
|
||||
+ this.destination = destination;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the destination position of this teleportation
|
||||
+ * @return the destination position
|
||||
+ */
|
||||
+ public Location getDestination() {
|
||||
+ return this.destination;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the original portal position of this teleportation
|
||||
+ * @return the original portal position
|
||||
+ */
|
||||
+ public Location getOriginal() {
|
||||
+ return this.original;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull HandlerList getHandlers() {
|
||||
+ return HANDLERS;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return HANDLERS;
|
||||
+ }
|
||||
+}
|
||||
@@ -0,0 +1,165 @@
|
||||
package gg.pufferfish.pufferfish.sentry;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.apache.logging.log4j.ThreadContext;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredListener;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class SentryContext {
|
||||
|
||||
private static final Gson GSON = new Gson();
|
||||
|
||||
public static void setPluginContext(@Nullable Plugin plugin) {
|
||||
if (plugin != null) {
|
||||
ThreadContext.put("pufferfishsentry_pluginname", plugin.getName());
|
||||
ThreadContext.put("pufferfishsentry_pluginversion", plugin.getPluginMeta().getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
public static void removePluginContext() {
|
||||
ThreadContext.remove("pufferfishsentry_pluginname");
|
||||
ThreadContext.remove("pufferfishsentry_pluginversion");
|
||||
}
|
||||
|
||||
public static void setSenderContext(@Nullable CommandSender sender) {
|
||||
if (sender != null) {
|
||||
ThreadContext.put("pufferfishsentry_playername", sender.getName());
|
||||
if (sender instanceof Player player) {
|
||||
ThreadContext.put("pufferfishsentry_playerid", player.getUniqueId().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeSenderContext() {
|
||||
ThreadContext.remove("pufferfishsentry_playername");
|
||||
ThreadContext.remove("pufferfishsentry_playerid");
|
||||
}
|
||||
|
||||
public static void setEventContext(Event event, RegisteredListener registration) {
|
||||
setPluginContext(registration.getPlugin());
|
||||
|
||||
try {
|
||||
// Find the player that was involved with this event
|
||||
Player player = null;
|
||||
if (event instanceof PlayerEvent) {
|
||||
player = ((PlayerEvent) event).getPlayer();
|
||||
} else {
|
||||
Class<? extends Event> eventClass = event.getClass();
|
||||
|
||||
Field playerField = null;
|
||||
|
||||
for (Field field : eventClass.getDeclaredFields()) {
|
||||
if (field.getType().equals(Player.class)) {
|
||||
playerField = field;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (playerField != null) {
|
||||
playerField.setAccessible(true);
|
||||
player = (Player) playerField.get(event);
|
||||
}
|
||||
}
|
||||
|
||||
if (player != null) {
|
||||
setSenderContext(player);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
} // We can't really safely log exceptions.
|
||||
|
||||
ThreadContext.put("pufferfishsentry_eventdata", GSON.toJson(serializeFields(event)));
|
||||
}
|
||||
|
||||
public static void removeEventContext() {
|
||||
removePluginContext();
|
||||
removeSenderContext();
|
||||
ThreadContext.remove("pufferfishsentry_eventdata");
|
||||
}
|
||||
|
||||
private static Map<String, String> serializeFields(Object object) {
|
||||
Map<String, String> fields = new TreeMap<>();
|
||||
fields.put("_class", object.getClass().getName());
|
||||
for (Field declaredField : object.getClass().getDeclaredFields()) {
|
||||
try {
|
||||
if (Modifier.isStatic(declaredField.getModifiers())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String fieldName = declaredField.getName();
|
||||
if (fieldName.equals("handlers")) {
|
||||
continue;
|
||||
}
|
||||
declaredField.setAccessible(true);
|
||||
Object value = declaredField.get(object);
|
||||
if (value != null) {
|
||||
fields.put(fieldName, value.toString());
|
||||
} else {
|
||||
fields.put(fieldName, "<null>");
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
} // We can't really safely log exceptions.
|
||||
}
|
||||
return fields;
|
||||
}
|
||||
|
||||
public static class State {
|
||||
|
||||
private Plugin plugin;
|
||||
private Command command;
|
||||
private String commandLine;
|
||||
private Event event;
|
||||
private RegisteredListener registeredListener;
|
||||
|
||||
public Plugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public Command getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public void setCommand(Command command) {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public String getCommandLine() {
|
||||
return commandLine;
|
||||
}
|
||||
|
||||
public void setCommandLine(String commandLine) {
|
||||
this.commandLine = commandLine;
|
||||
}
|
||||
|
||||
public Event getEvent() {
|
||||
return event;
|
||||
}
|
||||
|
||||
public void setEvent(Event event) {
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
public RegisteredListener getRegisteredListener() {
|
||||
return registeredListener;
|
||||
}
|
||||
|
||||
public void setRegisteredListener(RegisteredListener registeredListener) {
|
||||
this.registeredListener = registeredListener;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package gg.pufferfish.pufferfish.simd;
|
||||
|
||||
import jdk.incubator.vector.FloatVector;
|
||||
import jdk.incubator.vector.IntVector;
|
||||
import jdk.incubator.vector.VectorSpecies;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
/**
|
||||
* Basically, java is annoying and we have to push this out to its own class.
|
||||
*/
|
||||
@Deprecated
|
||||
public class SIMDChecker {
|
||||
|
||||
@Deprecated
|
||||
public static boolean canEnable(Logger logger) {
|
||||
try {
|
||||
SIMDDetection.testRun = true;
|
||||
|
||||
VectorSpecies<Integer> ISPEC = IntVector.SPECIES_PREFERRED;
|
||||
VectorSpecies<Float> FSPEC = FloatVector.SPECIES_PREFERRED;
|
||||
|
||||
logger.info("Max SIMD vector size on this system is {} bits (int)", ISPEC.vectorBitSize());
|
||||
logger.info("Max SIMD vector size on this system is " + FSPEC.vectorBitSize() + " bits (float)");
|
||||
|
||||
if (ISPEC.elementSize() < 2 || FSPEC.elementSize() < 2) {
|
||||
logger.warn("SIMD is not properly supported on this system!");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (NoClassDefFoundError | Exception ignored) {} // Basically, we don't do anything. This lets us detect if it's not functional and disable it.
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package gg.pufferfish.pufferfish.simd;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@Deprecated
|
||||
public class SIMDDetection {
|
||||
|
||||
public static boolean isEnabled = false;
|
||||
public static boolean testRun = false;
|
||||
|
||||
@Deprecated
|
||||
public static boolean canEnable(Logger logger) {
|
||||
try {
|
||||
return SIMDChecker.canEnable(logger);
|
||||
} catch (NoClassDefFoundError | Exception ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static int getJavaVersion() {
|
||||
// https://stackoverflow.com/a/2591122
|
||||
String version = System.getProperty("java.version");
|
||||
if(version.startsWith("1.")) {
|
||||
version = version.substring(2, 3);
|
||||
} else {
|
||||
int dot = version.indexOf(".");
|
||||
if(dot != -1) { version = version.substring(0, dot); }
|
||||
}
|
||||
version = version.split("-")[0]; // Azul is stupid
|
||||
return Integer.parseInt(version);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package gg.pufferfish.pufferfish.simd;
|
||||
|
||||
import jdk.incubator.vector.FloatVector;
|
||||
import jdk.incubator.vector.IntVector;
|
||||
import jdk.incubator.vector.VectorMask;
|
||||
import jdk.incubator.vector.VectorSpecies;
|
||||
import org.bukkit.map.MapPalette;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
@Deprecated
|
||||
public class VectorMapPalette {
|
||||
|
||||
private static final VectorSpecies<Integer> I_SPEC = IntVector.SPECIES_PREFERRED;
|
||||
private static final VectorSpecies<Float> F_SPEC = FloatVector.SPECIES_PREFERRED;
|
||||
|
||||
@Deprecated
|
||||
public static void matchColorVectorized(int[] in, byte[] out) {
|
||||
int speciesLength = I_SPEC.length();
|
||||
int i;
|
||||
for (i = 0; i < in.length - speciesLength; i += speciesLength) {
|
||||
float[] redsArr = new float[speciesLength];
|
||||
float[] bluesArr = new float[speciesLength];
|
||||
float[] greensArr = new float[speciesLength];
|
||||
int[] alphasArr = new int[speciesLength];
|
||||
|
||||
for (int j = 0; j < speciesLength; j++) {
|
||||
alphasArr[j] = (in[i + j] >> 24) & 0xFF;
|
||||
redsArr[j] = (in[i + j] >> 16) & 0xFF;
|
||||
greensArr[j] = (in[i + j] >> 8) & 0xFF;
|
||||
bluesArr[j] = (in[i + j] >> 0) & 0xFF;
|
||||
}
|
||||
|
||||
IntVector alphas = IntVector.fromArray(I_SPEC, alphasArr, 0);
|
||||
FloatVector reds = FloatVector.fromArray(F_SPEC, redsArr, 0);
|
||||
FloatVector greens = FloatVector.fromArray(F_SPEC, greensArr, 0);
|
||||
FloatVector blues = FloatVector.fromArray(F_SPEC, bluesArr, 0);
|
||||
IntVector resultIndex = IntVector.zero(I_SPEC);
|
||||
VectorMask<Integer> modificationMask = VectorMask.fromLong(I_SPEC, 0xffffffff);
|
||||
|
||||
modificationMask = modificationMask.and(alphas.lt(128).not());
|
||||
FloatVector bestDistances = FloatVector.broadcast(F_SPEC, Float.MAX_VALUE);
|
||||
|
||||
for (int c = 4; c < MapPalette.colors.length; c++) {
|
||||
// We're using 32-bit floats here because it's 2x faster and nobody will know the difference.
|
||||
// For correctness, the original algorithm uses 64-bit floats instead. Completely unnecessary.
|
||||
FloatVector compReds = FloatVector.broadcast(F_SPEC, MapPalette.colors[c].getRed());
|
||||
FloatVector compGreens = FloatVector.broadcast(F_SPEC, MapPalette.colors[c].getGreen());
|
||||
FloatVector compBlues = FloatVector.broadcast(F_SPEC, MapPalette.colors[c].getBlue());
|
||||
|
||||
FloatVector rMean = reds.add(compReds).div(2.0f);
|
||||
FloatVector rDiff = reds.sub(compReds);
|
||||
FloatVector gDiff = greens.sub(compGreens);
|
||||
FloatVector bDiff = blues.sub(compBlues);
|
||||
|
||||
FloatVector weightR = rMean.div(256.0f).add(2);
|
||||
FloatVector weightG = FloatVector.broadcast(F_SPEC, 4.0f);
|
||||
FloatVector weightB = FloatVector.broadcast(F_SPEC, 255.0f).sub(rMean).div(256.0f).add(2.0f);
|
||||
|
||||
FloatVector distance = weightR.mul(rDiff).mul(rDiff).add(weightG.mul(gDiff).mul(gDiff)).add(weightB.mul(bDiff).mul(bDiff));
|
||||
|
||||
// Now we compare to the best distance we've found.
|
||||
// This mask contains a "1" if better, and a "0" otherwise.
|
||||
VectorMask<Float> bestDistanceMask = distance.lt(bestDistances);
|
||||
bestDistances = bestDistances.blend(distance, bestDistanceMask); // Update the best distances
|
||||
|
||||
// Update the result array
|
||||
// We also AND with the modification mask because we don't want to interfere if the alpha value isn't large enough.
|
||||
resultIndex = resultIndex.blend(c, bestDistanceMask.cast(I_SPEC).and(modificationMask)); // Update the results
|
||||
}
|
||||
|
||||
for (int j = 0; j < speciesLength; j++) {
|
||||
int index = resultIndex.lane(j);
|
||||
out[i + j] = (byte) (index < 128 ? index : -129 + (index - 127));
|
||||
}
|
||||
}
|
||||
|
||||
// For the final ones, fall back to the regular method
|
||||
for (; i < in.length; i++) {
|
||||
out[i] = MapPalette.matchColor(new Color(in[i], true));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package me.earthme.luminol.api;
|
||||
|
||||
/**
|
||||
* A simple package of folia's tick region state.It linked to the RegionStats of the nms part so that</br>
|
||||
* You could call these methods to get the status of this tick region</br>
|
||||
*/
|
||||
public interface RegionStats {
|
||||
/**
|
||||
* Get the entity count in this tick region
|
||||
* @return the entity count
|
||||
*/
|
||||
int getEntityCount();
|
||||
|
||||
/**
|
||||
* Get the player count in this tick region
|
||||
* @return the player count
|
||||
*/
|
||||
int getPlayerCount();
|
||||
|
||||
/**
|
||||
* Get the chunk count in this tick region
|
||||
* @return the chunk count
|
||||
*/
|
||||
int getChunkCount();
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package me.earthme.luminol.api;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A mirror of folia's ThreadedRegion</br>
|
||||
* Including some handy methods to get the information of the tick region</br>
|
||||
* Note: You should call these methods inside this tick region's thread context
|
||||
*/
|
||||
public interface ThreadedRegion {
|
||||
/**
|
||||
* Get the center chunk pos of this tick region</br>
|
||||
* Note:</br>
|
||||
* 1.Global region will return a null value(But we don't finish the global region yet()</br>
|
||||
* 2.You should call these methods inside this tick region's thread context
|
||||
* @return The center chunk pos
|
||||
*/
|
||||
@Nullable
|
||||
Location getCenterChunkPos();
|
||||
|
||||
/**
|
||||
* Get the dead section percent of this tick region
|
||||
* Note: </br>
|
||||
* 1.Dead percent is mean the percent of the unloaded chunk count of this tick region, which is also used for determine
|
||||
* that the tick region should or not check for splitting</br>
|
||||
* 2.You should call these methods inside this tick region's thread context
|
||||
* @return The dead section percent
|
||||
*/
|
||||
double getDeadSectionPercent();
|
||||
|
||||
/**
|
||||
* Get the tick region data of this tick region</br>
|
||||
* Note:</br>
|
||||
* 1.You should call this method inside this tick region's thread context</br>
|
||||
* 2.You should call these methods inside this tick region's thread context
|
||||
* @return The tick region data
|
||||
*/
|
||||
TickRegionData getTickRegionData();
|
||||
|
||||
/**
|
||||
* Get the world of this tick region</br>
|
||||
* Note: Global region will return a null value too
|
||||
* @return The world of this tick region
|
||||
*/
|
||||
@Nullable
|
||||
World getWorld();
|
||||
|
||||
/**
|
||||
* Get the id of the tick region</br>
|
||||
* @return The id of the tick region
|
||||
*/
|
||||
long getId();
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package me.earthme.luminol.api;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* A mirror of folia's ThreadedRegionizer
|
||||
*/
|
||||
public interface ThreadedRegionizer {
|
||||
/**
|
||||
* Get all the tick regions
|
||||
* @return Temporary copied collection of all tick regions
|
||||
*/
|
||||
Collection<ThreadedRegion> getAllRegions();
|
||||
|
||||
/**
|
||||
* Get the tick region at the given chunk coordinates
|
||||
* @param chunkX Chunk X
|
||||
* @param chunkZ Chunk Z
|
||||
* @return The tick region at the given chunk coordinates
|
||||
*/
|
||||
@Nullable
|
||||
ThreadedRegion getAtSynchronized(int chunkX, int chunkZ);
|
||||
|
||||
/**
|
||||
* Get the tick region at the given chunk coordinates
|
||||
* @param chunkX Chunk X
|
||||
* @param chunkZ Chunk Z
|
||||
* @return The tick region at the given chunk coordinates
|
||||
*/
|
||||
@Nullable
|
||||
ThreadedRegion getAtUnSynchronized(int chunkX, int chunkZ);
|
||||
|
||||
/**
|
||||
* Get the tick region at the given location
|
||||
* @param pos The location
|
||||
* @return The tick region at the given location
|
||||
*/
|
||||
@Nullable
|
||||
default ThreadedRegion getAtSynchronized(@NotNull Location pos) {
|
||||
return this.getAtSynchronized(pos.getBlockX() >> 4, pos.getBlockZ() >> 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tick region at the given location
|
||||
* @param pos The location
|
||||
* @return The tick region at the given location
|
||||
*/
|
||||
@Nullable
|
||||
default ThreadedRegion getAtUnSynchronized(@NotNull Location pos) {
|
||||
return this.getAtUnSynchronized(pos.getBlockX() >> 4, pos.getBlockZ() >> 4);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package me.earthme.luminol.api;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
/**
|
||||
* A mirror of folia's tick region data
|
||||
*/
|
||||
public interface TickRegionData {
|
||||
/**
|
||||
* Get the world it's currently holding
|
||||
* @return the world
|
||||
*/
|
||||
World getWorld();
|
||||
|
||||
/**
|
||||
* Get the current tick count
|
||||
* @return the current tick count
|
||||
*/
|
||||
long getCurrentTickCount();
|
||||
|
||||
/**
|
||||
* Get the region stats
|
||||
* @return the region stats
|
||||
*/
|
||||
RegionStats getRegionStats();
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package me.earthme.luminol.api.entity;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A simple event fired when a teleportAsync was called
|
||||
* @see org.bukkit.entity.Entity#teleportAsync(org.bukkit.Location, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause)
|
||||
* @see org.bukkit.entity.Entity#teleportAsync(org.bukkit.Location)
|
||||
* (Also fired when teleportAsync called from nms)
|
||||
*/
|
||||
public class EntityTeleportAsyncEvent extends Event {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final Entity entity;
|
||||
private final PlayerTeleportEvent.TeleportCause teleportCause;
|
||||
private final Location destination;
|
||||
|
||||
public EntityTeleportAsyncEvent(Entity entity, PlayerTeleportEvent.TeleportCause teleportCause, Location destination) {
|
||||
Validate.notNull(entity, "entity cannot be a null value!");
|
||||
Validate.notNull(teleportCause, "teleportCause cannot be a null value!");
|
||||
Validate.notNull(destination, "destination cannot be a null value!");
|
||||
|
||||
this.entity = entity;
|
||||
this.teleportCause = teleportCause;
|
||||
this.destination = destination;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entity is about to be teleported
|
||||
* @return that entity
|
||||
*/
|
||||
public @NotNull Entity getEntity() {
|
||||
return this.entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cause of the teleport
|
||||
* @return the cause
|
||||
*/
|
||||
public @NotNull PlayerTeleportEvent.TeleportCause getTeleportCause() {
|
||||
return this.teleportCause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the destination of the teleport
|
||||
* @return the destination
|
||||
*/
|
||||
public @NotNull Location getDestination() {
|
||||
return this.destination;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package me.earthme.luminol.api.entity;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A simple event created for missing teleport events api of folia
|
||||
* This event is fired when the entity portal process has been done
|
||||
*/
|
||||
public class PostEntityPortalEvent extends Event {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Entity teleportedEntity;
|
||||
|
||||
public PostEntityPortalEvent(Entity teleportedEntity) {
|
||||
Validate.notNull(teleportedEntity, "teleportedEntity cannot be null!");
|
||||
|
||||
this.teleportedEntity = teleportedEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entity which was teleported
|
||||
* @return the entity which was teleported
|
||||
*/
|
||||
public Entity getTeleportedEntity() {
|
||||
return this.teleportedEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package me.earthme.luminol.api.entity;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A simple event created for missing teleport events api of folia
|
||||
* This event will be fired when a portal teleportation is about to happen
|
||||
*/
|
||||
public class PreEntityPortalEvent extends Event implements Cancellable {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final Entity entity;
|
||||
private final Location portalPos;
|
||||
private final World destination;
|
||||
|
||||
private boolean cancelled = false;
|
||||
|
||||
public PreEntityPortalEvent(Entity entity, Location portalPos, World destination) {
|
||||
Validate.notNull(entity, "entity cannot be null!");
|
||||
Validate.notNull(portalPos, "portalPos cannot be null!");
|
||||
Validate.notNull(destination, "destination cannot be null!");
|
||||
|
||||
this.entity = entity;
|
||||
this.portalPos = portalPos;
|
||||
this.destination = destination;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entity that is about to teleport
|
||||
* @return the entity
|
||||
*/
|
||||
public @NotNull Entity getEntity() {
|
||||
return this.entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the location of the portal
|
||||
* @return the portal location
|
||||
*/
|
||||
public @NotNull Location getPortalPos() {
|
||||
return this.portalPos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the destination world
|
||||
* @return the destination world
|
||||
*/
|
||||
public @NotNull World getDestination() {
|
||||
return this.destination;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package me.earthme.luminol.api.entity.player;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A simple event fired when the respawn process of player is done
|
||||
*/
|
||||
public class PostPlayerRespawnEvent extends Event {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final Player player;
|
||||
|
||||
public PostPlayerRespawnEvent(Player player) {
|
||||
Validate.notNull(player, "Player cannot be a null value!");
|
||||
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the respawned player
|
||||
* @return the player
|
||||
*/
|
||||
public @NotNull Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package me.earthme.luminol.api.portal;
|
||||
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A event fired when an end platform is created.
|
||||
*/
|
||||
public class EndPlatformCreateEvent extends Event implements Cancellable {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private boolean cancelled = false;
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package me.earthme.luminol.api.portal;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A event fired when the portal process started locating the destination position
|
||||
* Notice: If you changed the destination to an another position in end teleportation.The end platform won't create under the entity and won't create
|
||||
* if the position is out of current tick region
|
||||
*/
|
||||
public class PortalLocateEvent extends Event {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final Location original;
|
||||
private final Location destination;
|
||||
|
||||
public PortalLocateEvent(Location original, Location destination) {
|
||||
Validate.notNull(original, "original couldn't be null!");
|
||||
Validate.notNull(destination, "destination couldn't be null!");
|
||||
|
||||
this.original = original;
|
||||
this.destination = destination;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the destination position of this teleportation
|
||||
* @return the destination position
|
||||
*/
|
||||
public Location getDestination() {
|
||||
return this.destination;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the original portal position of this teleportation
|
||||
* @return the original portal position
|
||||
*/
|
||||
public Location getOriginal() {
|
||||
return this.original;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@
|
||||
}
|
||||
}
|
||||
val log4jPlugins = sourceSets.create("log4jPlugins") {
|
||||
@@ -153,7 +_,14 @@
|
||||
@@ -153,12 +_,20 @@
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -64,6 +64,12 @@
|
||||
implementation("ca.spottedleaf:concurrentutil:0.0.3")
|
||||
implementation("org.jline:jline-terminal-ffm:3.27.1") // use ffm on java 22+
|
||||
implementation("org.jline:jline-terminal-jni:3.27.1") // fall back to jni on java 21
|
||||
implementation("net.minecrell:terminalconsoleappender:1.3.0")
|
||||
implementation("net.kyori:adventure-text-serializer-ansi:4.21.0") // Keep in sync with adventureVersion from Paper-API build file
|
||||
+ implementation("net.openhft:affinity:3.23.3") // Luminol
|
||||
runtimeConfiguration(sourceSets.main.map { it.runtimeClasspath })
|
||||
|
||||
/*
|
||||
@@ -217,26 +_,33 @@
|
||||
implementation("me.lucko:spark-paper:1.10.133-20250413.112336-1")
|
||||
}
|
||||
@@ -104,14 +110,3 @@
|
||||
"Build-Number" to (build ?: ""),
|
||||
"Build-Time" to buildTime.toString(),
|
||||
"Git-Branch" to gitBranch,
|
||||
@@ -393,3 +_,10 @@
|
||||
classpath(tasks.createReobfPaperclipJar.flatMap { it.outputZip })
|
||||
mainClass.set(null as String?)
|
||||
}
|
||||
+
|
||||
+// Pufferfish Start
|
||||
+tasks.withType<JavaCompile> {
|
||||
+ val compilerArgs = options.compilerArgs
|
||||
+ compilerArgs.add("--add-modules=jdk.incubator.vector")
|
||||
+}
|
||||
+// Pufferfish End
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Sun, 12 Jan 2025 10:36:31 +0800
|
||||
Subject: [PATCH] Add config for command block command execution
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/level/BaseCommandBlock.java b/net/minecraft/world/level/BaseCommandBlock.java
|
||||
index 91e30f9c83259abc0589f4ee69c429cd4305d6ea..21a22d6fca111dd6a8cd4c7a6f994aa87d06feb4 100644
|
||||
--- a/net/minecraft/world/level/BaseCommandBlock.java
|
||||
+++ b/net/minecraft/world/level/BaseCommandBlock.java
|
||||
@@ -102,7 +102,7 @@ public abstract class BaseCommandBlock implements CommandSource {
|
||||
}
|
||||
|
||||
public boolean performCommand(Level level) {
|
||||
- if (true) return false; // Folia - region threading
|
||||
+ if (!me.earthme.luminol.config.modules.experiment.CommandBlockConfig.enabled) return false; // Folia - region threading // Luminol
|
||||
if (level.isClientSide || level.getGameTime() == this.lastExecution) {
|
||||
return false;
|
||||
} else if ("Searge".equalsIgnoreCase(this.command)) {
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Add config for vanilla random
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 414be522896c63c34100199177788d71e8f2d326..bf177d9f7e5d9f643d13fcb9ea23686fd0f32dc5 100644
|
||||
index 8357e4a3f381014b976067d8ed06fc073d23db44..b5838a0320c729778f27f0d6a623eed4ef7c3a52 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -261,7 +261,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -1,27 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||
Date: Wed, 21 May 2025 13:04:00 +0800
|
||||
Subject: [PATCH] Add config to disable end crystal check
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/level/dimension/end/EndDragonFight.java b/net/minecraft/world/level/dimension/end/EndDragonFight.java
|
||||
index 4fa8371c212dcc02b8cf5fd267b736e1cf3f50c1..e80afd034eba10c9adaa5df776c728253e874af4 100644
|
||||
--- a/net/minecraft/world/level/dimension/end/EndDragonFight.java
|
||||
+++ b/net/minecraft/world/level/dimension/end/EndDragonFight.java
|
||||
@@ -547,6 +547,8 @@ public class EndDragonFight {
|
||||
|
||||
blockPos = this.portalLocation;
|
||||
}
|
||||
+ // Luminol start - Disable end crystal check
|
||||
+ if (!me.earthme.luminol.config.modules.misc.DisableEndCrystalCheckConfig.disableEndCrystalCheck) {
|
||||
// Paper start - Perf: Do crystal-portal proximity check before entity lookup
|
||||
if (placedEndCrystalPos != null) {
|
||||
// The end crystal must be 0 or 1 higher than the portal origin
|
||||
@@ -562,6 +564,7 @@ public class EndDragonFight {
|
||||
}
|
||||
}
|
||||
// Paper end - Perf: Do crystal-portal proximity check before entity lookup
|
||||
+ } // Luminol end - Disable end crystal check
|
||||
|
||||
|
||||
List<EndCrystal> list = Lists.newArrayList();
|
||||
@@ -30,7 +30,7 @@ index 8a3a8b0fdf9545a41501dc992c6982d9c8ce7b66..8f9f5b0bf098a32a732e3ff9f636e3ea
|
||||
}
|
||||
}
|
||||
diff --git a/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java b/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java
|
||||
index 49b810ae9d9a8d0718a5f8c512e15a5573ed04fd..37ebb23c9c053de0530254d98f2120058833f232 100644
|
||||
index 49b810ae9d9a8d0718a5f8c512e15a5573ed04fd..7d5fc6860ed426c4906f8c3eb2c10fd6db4296e5 100644
|
||||
--- a/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java
|
||||
+++ b/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java
|
||||
@@ -28,6 +28,11 @@ public class EndPlatformFeature extends Feature<NoneFeatureConfiguration> {
|
||||
@@ -89,14 +89,13 @@ index 49b810ae9d9a8d0718a5f8c512e15a5573ed04fd..37ebb23c9c053de0530254d98f212005
|
||||
+ blockList.placeBlocks();
|
||||
+ }
|
||||
} else {
|
||||
- blockList.placeBlocks();
|
||||
+ if (dropBlocks) {
|
||||
+ blockList.getSnapshotBlocks().forEach((state) -> {
|
||||
+ level.destroyBlock(state.getPosition(), !blockList1.contains(state.getPosition()), null);
|
||||
+ state.update();
|
||||
+ });
|
||||
+ // Luminol - prevent tripwire dupe in end platform generate
|
||||
+ }
|
||||
blockList.placeBlocks();
|
||||
}
|
||||
// CraftBukkit end
|
||||
}
|
||||
@@ -1,167 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||
Date: Thu, 1 May 2025 22:43:08 +0800
|
||||
Subject: [PATCH] Add config to enable tick command
|
||||
|
||||
|
||||
diff --git a/io/papermc/paper/threadedregions/RegionizedServer.java b/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||
index 8e91ec81128bdbd5f78e1f04fe17bcbd6e5dc280..55476f0d4898c67e433dcee769a5cf8bd6109930 100644
|
||||
--- a/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||
+++ b/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||
@@ -299,6 +299,11 @@ public final class RegionizedServer {
|
||||
this.randomWalk();
|
||||
*/
|
||||
++this.tickCount;
|
||||
+ // Luminol start - Add a config to enable tick command
|
||||
+ if (me.earthme.luminol.config.modules.experiment.CommandTickConfig.enabled) {
|
||||
+ MinecraftServer.tickRateManager.tick();
|
||||
+ }
|
||||
+ // Luminol end - Add a config to enable tick command
|
||||
// expire invalid click command callbacks
|
||||
io.papermc.paper.adventure.providers.ClickCallbackProviderImpl.CALLBACK_MANAGER.handleQueue((int)this.tickCount);
|
||||
|
||||
@@ -321,6 +326,13 @@ public final class RegionizedServer {
|
||||
this.globalTick(world, tickCount);
|
||||
}
|
||||
|
||||
+ // Luminol start - Add a config to enable tick command
|
||||
+ if (me.earthme.luminol.config.modules.experiment.CommandTickConfig.enabled) {
|
||||
+ MinecraftServer.tickRateManager.reduceSprintTicks();
|
||||
+ MinecraftServer.tickRateManager.endTickWork();
|
||||
+ }
|
||||
+ // Luminol end - Add a config to enable tick command
|
||||
+
|
||||
// tick connections
|
||||
this.tickConnections();
|
||||
|
||||
@@ -454,7 +466,7 @@ public final class RegionizedServer {
|
||||
}
|
||||
|
||||
private void tickTime(final ServerLevel world, final int tickCount) {
|
||||
- if (world.tickTime) {
|
||||
+ if ((!me.earthme.luminol.config.modules.experiment.CommandTickConfig.enabled || world.tickRateManager().runsNormally()) && world.tickTime) { // Luminol - Add a config to enable tick command
|
||||
if (world.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) {
|
||||
world.setDayTime(world.levelData.getDayTime() + (long)tickCount);
|
||||
}
|
||||
diff --git a/io/papermc/paper/threadedregions/TickRegionScheduler.java b/io/papermc/paper/threadedregions/TickRegionScheduler.java
|
||||
index 7123b3eb2f2e52946b8ef9de993a6828eb0bb6f7..82948984404a183711588932a4a026dc4c241feb 100644
|
||||
--- a/io/papermc/paper/threadedregions/TickRegionScheduler.java
|
||||
+++ b/io/papermc/paper/threadedregions/TickRegionScheduler.java
|
||||
@@ -31,8 +31,8 @@ public final class TickRegionScheduler {
|
||||
}
|
||||
}
|
||||
|
||||
- public static final int TICK_RATE = 20;
|
||||
- public static final long TIME_BETWEEN_TICKS = 1_000_000_000L / TICK_RATE; // ns
|
||||
+ public static float TICK_RATE = 20; // Luminol - Add tick command support
|
||||
+ public static long TIME_BETWEEN_TICKS = (long) (1_000_000_000L / TICK_RATE); // ns // Luminol - Add tick command support
|
||||
|
||||
// Folia start - watchdog
|
||||
public static final FoliaWatchdogThread WATCHDOG_THREAD = new FoliaWatchdogThread();
|
||||
@@ -375,8 +375,23 @@ public final class TickRegionScheduler {
|
||||
final long cpuStart = MEASURE_CPU_TIME ? THREAD_MX_BEAN.getCurrentThreadCpuTime() : 0L;
|
||||
final long tickStart = System.nanoTime();
|
||||
|
||||
- // use max(), don't assume that tickStart >= scheduledStart
|
||||
- final int tickCount = Math.max(1, this.tickSchedule.getPeriodsAhead(TIME_BETWEEN_TICKS, tickStart));
|
||||
+ // Luminol start - Add a config to enable tick command
|
||||
+ final int tickCount;
|
||||
+ if (me.earthme.luminol.config.modules.experiment.CommandTickConfig.enabled) {
|
||||
+ if (MinecraftServer.tickRateManager.isSprinting() && MinecraftServer.tickRateManager.checkShouldSprintThisTick()) {
|
||||
+ TICK_RATE = net.minecraft.server.commands.TickCommand.MAX_TICKRATE;
|
||||
+ TIME_BETWEEN_TICKS = (long) (1_000_000_000L / TICK_RATE);
|
||||
+ tickCount = 1;
|
||||
+ } else {
|
||||
+ TICK_RATE = MinecraftServer.tickRateManager.tickrate();
|
||||
+ TIME_BETWEEN_TICKS = (long) (1_000_000_000L / TICK_RATE);
|
||||
+ tickCount = Math.max(1, this.tickSchedule.getPeriodsAhead(TIME_BETWEEN_TICKS, tickStart));
|
||||
+ }
|
||||
+ } else {
|
||||
+ // use max(), don't assume that tickStart >= scheduledStart
|
||||
+ tickCount = Math.max(1, this.tickSchedule.getPeriodsAhead(TIME_BETWEEN_TICKS, tickStart));
|
||||
+ }
|
||||
+ // Luminol end - Add tick command support
|
||||
|
||||
if (!this.tryMarkTicking()) {
|
||||
if (!this.cancelled.get()) {
|
||||
@@ -416,6 +431,11 @@ public final class TickRegionScheduler {
|
||||
try {
|
||||
// next start isn't updated until the end of this tick
|
||||
this.tickRegion(tickCount, tickStart, scheduledEnd);
|
||||
+ // Luminol start - Add a config to enable tick command
|
||||
+ if (me.earthme.luminol.config.modules.experiment.CommandTickConfig.enabled) {
|
||||
+ MinecraftServer.tickRateManager.endTickWork();
|
||||
+ }
|
||||
+ // Luminol end - Add a config to enable tick command
|
||||
} catch (final Throwable thr) {
|
||||
this.scheduler.regionFailed(this, false, thr);
|
||||
// regionFailed will schedule a shutdown, so we should avoid letting this region tick further
|
||||
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
||||
index 4e3bfa25ec4917d2bca594b050e38be3bdea077b..fca716bf52e114b196c7617f352e9394c7185271 100644
|
||||
--- a/net/minecraft/commands/Commands.java
|
||||
+++ b/net/minecraft/commands/Commands.java
|
||||
@@ -212,7 +212,11 @@ public class Commands {
|
||||
TeleportCommand.register(this.dispatcher);
|
||||
TellRawCommand.register(this.dispatcher, context);
|
||||
//TestCommand.register(this.dispatcher, context); // Folia - region threading
|
||||
- //TickCommand.register(this.dispatcher); // Folia - region threading - TODO later
|
||||
+ // Luminol start - Add a config to enable tick command
|
||||
+ if (me.earthme.luminol.config.modules.experiment.CommandTickConfig.enabled) {
|
||||
+ TickCommand.register(this.dispatcher); // Folia - region threading - TODO later
|
||||
+ }
|
||||
+ // Luminol end - Add a config to enable tick command
|
||||
TimeCommand.register(this.dispatcher);
|
||||
TitleCommand.register(this.dispatcher, context);
|
||||
//TriggerCommand.register(this.dispatcher); // Folia - region threading - TODO later
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index db435869dd2a2dfe0c36c62e46e5389170cfb0cd..a90ac07eaea956cb7c50b66a27dd47c955f98feb 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -266,7 +266,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
private String serverId;
|
||||
public MinecraftServer.ReloadableResources resources;
|
||||
private final StructureTemplateManager structureTemplateManager;
|
||||
- private final ServerTickRateManager tickRateManager;
|
||||
+ public static ServerTickRateManager tickRateManager; // Luminol - Add tick command support
|
||||
protected WorldData worldData;
|
||||
public PotionBrewing potionBrewing;
|
||||
private FuelValues fuelValues;
|
||||
diff --git a/net/minecraft/server/ServerTickRateManager.java b/net/minecraft/server/ServerTickRateManager.java
|
||||
index 40338efd1c0e56d869d03f1d0687e7ff0fcbf11a..d0d90a25a10bbecfffceee1992af88c60d14fd87 100644
|
||||
--- a/net/minecraft/server/ServerTickRateManager.java
|
||||
+++ b/net/minecraft/server/ServerTickRateManager.java
|
||||
@@ -105,7 +105,7 @@ public class ServerTickRateManager extends TickRateManager {
|
||||
return false;
|
||||
} else if (this.remainingSprintTicks > 0L) {
|
||||
this.sprintTickStartTime = System.nanoTime();
|
||||
- this.remainingSprintTicks--;
|
||||
+ // this.remainingSprintTicks--; // Luminol - Add tick command support
|
||||
return true;
|
||||
} else {
|
||||
this.finishTickSprint();
|
||||
@@ -113,6 +113,12 @@ public class ServerTickRateManager extends TickRateManager {
|
||||
}
|
||||
}
|
||||
|
||||
+ // Luminol start - Add tick command support
|
||||
+ public void reduceSprintTicks() {
|
||||
+ this.remainingSprintTicks--;
|
||||
+ }
|
||||
+ // Luminol end - Add tick command support
|
||||
+
|
||||
public void endTickWork() {
|
||||
this.sprintTimeSpend = this.sprintTimeSpend + (System.nanoTime() - this.sprintTickStartTime);
|
||||
}
|
||||
diff --git a/net/minecraft/server/commands/TickCommand.java b/net/minecraft/server/commands/TickCommand.java
|
||||
index 6b6c8ce49eda6806c8288d70848dd143ba2c4703..5d09d2c8bb45cc10b2a13100793249adc7b5a7e9 100644
|
||||
--- a/net/minecraft/server/commands/TickCommand.java
|
||||
+++ b/net/minecraft/server/commands/TickCommand.java
|
||||
@@ -14,7 +14,7 @@ import net.minecraft.server.ServerTickRateManager;
|
||||
import net.minecraft.util.TimeUtil;
|
||||
|
||||
public class TickCommand {
|
||||
- private static final float MAX_TICKRATE = 10000.0F;
|
||||
+ public static final float MAX_TICKRATE = 10000.0F; // Luminol - Add tick command support
|
||||
private static final String DEFAULT_TICKRATE = String.valueOf(20);
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
|
||||
@@ -55,7 +55,7 @@ index 51c126735ace8fdde89ad97b5cab62f244212db0..c7d4d944eb198ac53a3eeae717a25c7d
|
||||
+ public void moonrise$write(final abomination.IRegionFile regionFile) throws IOException; // Luminol - Configurable region file format
|
||||
}
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index a90ac07eaea956cb7c50b66a27dd47c955f98feb..ecf185fce582a542c65a9544388b84835643978b 100644
|
||||
index db435869dd2a2dfe0c36c62e46e5389170cfb0cd..b437132634f636f4c1d76c86146f377090b5fdb2 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -978,10 +978,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -1,204 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||
Date: Fri, 11 Apr 2025 16:53:57 +0800
|
||||
Subject: [PATCH] Add config to revert raid changes
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/effect/BadOmenMobEffect.java b/net/minecraft/world/effect/BadOmenMobEffect.java
|
||||
index 80f17f33f670018240c854df589cf90cdeab6e70..8672757a4d5fb5c247599782fece6b8d7d6ec921 100644
|
||||
--- a/net/minecraft/world/effect/BadOmenMobEffect.java
|
||||
+++ b/net/minecraft/world/effect/BadOmenMobEffect.java
|
||||
@@ -22,6 +22,11 @@ class BadOmenMobEffect extends MobEffect {
|
||||
&& !serverPlayer.isSpectator()
|
||||
&& level.getDifficulty() != Difficulty.PEACEFUL
|
||||
&& level.isVillage(serverPlayer.blockPosition())) {
|
||||
+ // Leaves start - Revert raid changes
|
||||
+ if (me.earthme.luminol.config.modules.misc.RaidChangesConfig.trigger) {
|
||||
+ return level.getRaids().createOrExtendRaid(serverPlayer, serverPlayer.blockPosition()) == null;
|
||||
+ }
|
||||
+ // Leaves end - Revert raid changes
|
||||
Raid raidAt = level.getRaidAt(serverPlayer.blockPosition());
|
||||
if (raidAt == null || raidAt.getRaidOmenLevel() < raidAt.getMaxRaidOmenLevel()) {
|
||||
serverPlayer.addEffect(new MobEffectInstance(MobEffects.RAID_OMEN, 600, amplifier));
|
||||
diff --git a/net/minecraft/world/entity/raid/Raid.java b/net/minecraft/world/entity/raid/Raid.java
|
||||
index dbb207c638a64b733dc21704033ff55ca1f44f1d..8401b3e9968e48c7a936386f3290315091501d4f 100644
|
||||
--- a/net/minecraft/world/entity/raid/Raid.java
|
||||
+++ b/net/minecraft/world/entity/raid/Raid.java
|
||||
@@ -340,7 +340,20 @@ public class Raid {
|
||||
}
|
||||
|
||||
if (flag1) {
|
||||
- this.waveSpawnPos = this.getValidSpawnPos(level);
|
||||
+ // Luminol Start - Raid revert
|
||||
+ if (!me.earthme.luminol.config.modules.misc.RaidChangesConfig.posRevert) {
|
||||
+ this.waveSpawnPos = this.getValidSpawnPos(level);
|
||||
+ } else {
|
||||
+ int n4 = 0;
|
||||
+ if (this.raidCooldownTicks < 100) {
|
||||
+ n4 = 1;
|
||||
+ }
|
||||
+ if (this.raidCooldownTicks < 40) {
|
||||
+ n4 = 2;
|
||||
+ }
|
||||
+ this.waveSpawnPos = this.getValidSpawnPos(level, n4);
|
||||
+ }
|
||||
+ // Luminol End - Raid revert
|
||||
}
|
||||
|
||||
if (this.raidCooldownTicks == 300 || this.raidCooldownTicks % 20 == 0) {
|
||||
@@ -375,7 +388,14 @@ public class Raid {
|
||||
int i = 0;
|
||||
|
||||
while (this.shouldSpawnGroup()) {
|
||||
- BlockPos blockPos = this.waveSpawnPos.orElseGet(() -> this.findRandomSpawnPos(level, 20));
|
||||
+ // Luminol Start - Raid revert
|
||||
+ BlockPos blockPos;
|
||||
+ if (!me.earthme.luminol.config.modules.misc.RaidChangesConfig.posRevert) {
|
||||
+ blockPos = this.waveSpawnPos.orElseGet(() -> this.findRandomSpawnPos(level, 20));
|
||||
+ } else {
|
||||
+ blockPos = this.waveSpawnPos.isPresent() ? this.waveSpawnPos.get() : this.findRandomSpawnPos(level, i, 20);
|
||||
+ }
|
||||
+ // Luminol End - Raid revert
|
||||
if (blockPos != null) {
|
||||
this.started = true;
|
||||
this.spawnGroup(level, blockPos);
|
||||
@@ -387,7 +407,7 @@ public class Raid {
|
||||
i++;
|
||||
}
|
||||
|
||||
- if (i > 5) {
|
||||
+ if (i > (me.earthme.luminol.config.modules.misc.RaidChangesConfig.posRevert ? 3 : 5)) { // Luminol - Raid revert
|
||||
org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(level, this, org.bukkit.event.raid.RaidStopEvent.Reason.UNSPAWNABLE); // CraftBukkit
|
||||
this.stop();
|
||||
break;
|
||||
@@ -458,6 +478,17 @@ public class Raid {
|
||||
return blockPos != null ? Optional.of(blockPos) : Optional.empty();
|
||||
}
|
||||
|
||||
+ // Luminol Start - Raid revert
|
||||
+ private Optional<BlockPos> getValidSpawnPos(ServerLevel level, int n) {
|
||||
+ for (int i = 0; i < 3; ++i) {
|
||||
+ BlockPos blockPos = this.findRandomSpawnPos(level, n, 1);
|
||||
+ if (blockPos == null) continue;
|
||||
+ return Optional.of(blockPos);
|
||||
+ }
|
||||
+ return Optional.empty();
|
||||
+ }
|
||||
+ // Luminol End - Raid revert
|
||||
+
|
||||
private boolean hasMoreWaves() {
|
||||
return this.hasBonusWave() ? !this.hasSpawnedBonusWave() : !this.isFinalWave();
|
||||
}
|
||||
@@ -683,7 +714,7 @@ public class Raid {
|
||||
int i2 = this.center.getX() + Mth.floor(Mth.cos(f2) * 32.0F * f) + level.random.nextInt(3) * Mth.floor(f);
|
||||
int i3 = this.center.getZ() + Mth.floor(Mth.sin(f2) * 32.0F * f) + level.random.nextInt(3) * Mth.floor(f);
|
||||
int height = level.getHeight(Heightmap.Types.WORLD_SURFACE, i2, i3);
|
||||
- if (Mth.abs(height - this.center.getY()) <= 96) {
|
||||
+ if (me.earthme.luminol.config.modules.misc.RaidChangesConfig.heightCheck || Mth.abs(height - this.center.getY()) <= 96) { // Leaves - Disable height check
|
||||
mutableBlockPos.set(i2, height, i3);
|
||||
if (!level.isVillage(mutableBlockPos) || i <= 7) {
|
||||
int i4 = 10;
|
||||
@@ -702,6 +733,26 @@ public class Raid {
|
||||
return null;
|
||||
}
|
||||
|
||||
+ // Luminol Start - Raid revert
|
||||
+ @Nullable
|
||||
+ private BlockPos findRandomSpawnPos(ServerLevel level, int n, int n2) {
|
||||
+ int n3 = 2 - n;
|
||||
+ BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos();
|
||||
+ SpawnPlacementType spawnPlacementType = SpawnPlacements.getPlacementType(EntityType.RAVAGER);
|
||||
+ for (int i = 0; i < n2; ++i) {
|
||||
+ float f = level.random.nextFloat() * ((float)Math.PI * 2);
|
||||
+ int n4 = this.center.getX() + Mth.floor(Mth.cos(f) * 32.0f * (float)n3) + level.random.nextInt(5);
|
||||
+ int n5 = this.center.getZ() + Mth.floor(Mth.sin(f) * 32.0f * (float)n3) + level.random.nextInt(5);
|
||||
+ int n6 = level.getHeight(Heightmap.Types.WORLD_SURFACE, n4, n5);
|
||||
+ mutableBlockPos.set(n4, n6, n5);
|
||||
+ if (level.isVillage(mutableBlockPos) && n < 2) continue;
|
||||
+ if (!level.hasChunksAt(mutableBlockPos.getX() - 10, mutableBlockPos.getZ() - 10, mutableBlockPos.getX() + 10, mutableBlockPos.getZ() + 10) || !level.isPositionEntityTicking(mutableBlockPos) || !spawnPlacementType.isSpawnPositionOk(level, mutableBlockPos, EntityType.RAVAGER) && (!level.getBlockState(mutableBlockPos.below()).is(Blocks.SNOW) || !level.getBlockState(mutableBlockPos).isAir())) continue;
|
||||
+ return mutableBlockPos;
|
||||
+ }
|
||||
+ return null;
|
||||
+ }
|
||||
+ // Luminol End - Raid revert
|
||||
+
|
||||
private boolean addWaveMob(ServerLevel level, int wave, Raider raider) {
|
||||
// Folia start - make raids thread-safe
|
||||
if (!this.ownsRaid(level)) {
|
||||
diff --git a/net/minecraft/world/entity/raid/Raider.java b/net/minecraft/world/entity/raid/Raider.java
|
||||
index f6f36c15120da6c57c0cbea3743a0819252cb6cc..cb537b243b16876e7922cd732ab8dad8d046a450 100644
|
||||
--- a/net/minecraft/world/entity/raid/Raider.java
|
||||
+++ b/net/minecraft/world/entity/raid/Raider.java
|
||||
@@ -127,6 +127,41 @@ public abstract class Raider extends PatrollingMonster {
|
||||
|
||||
currentRaid.removeFromRaid(serverLevel, this, false);
|
||||
}
|
||||
+
|
||||
+ // Leaves start - Revert raid changes
|
||||
+ if (me.earthme.luminol.config.modules.misc.RaidChangesConfig.effect && !this.hasRaid()) {
|
||||
+ ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD);
|
||||
+ net.minecraft.world.entity.player.Player entityhuman = null;
|
||||
+ if (entity instanceof net.minecraft.world.entity.player.Player player) {
|
||||
+ entityhuman = player;
|
||||
+ } else if (entity instanceof net.minecraft.world.entity.animal.wolf.Wolf wolf) {
|
||||
+ LivingEntity entityliving = wolf.getOwner();
|
||||
+ if (wolf.isTame() && entityliving instanceof net.minecraft.world.entity.player.Player player) {
|
||||
+ entityhuman = player;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (entityhuman != null && !itemstack.isEmpty() && this.isCaptain()) {
|
||||
+ net.minecraft.world.effect.MobEffectInstance mobeffect = entityhuman.getEffect(net.minecraft.world.effect.MobEffects.BAD_OMEN);
|
||||
+ int i = 1;
|
||||
+
|
||||
+ if (mobeffect != null) {
|
||||
+ i += mobeffect.getAmplifier();
|
||||
+ entityhuman.removeEffectNoUpdate(net.minecraft.world.effect.MobEffects.BAD_OMEN);
|
||||
+ } else {
|
||||
+ --i;
|
||||
+ }
|
||||
+
|
||||
+ i = net.minecraft.util.Mth.clamp(i, 0, 4);
|
||||
+ net.minecraft.world.effect.MobEffectInstance mobeffect1 = new net.minecraft.world.effect.MobEffectInstance(net.minecraft.world.effect.MobEffects.BAD_OMEN, me.earthme.luminol.config.modules.misc.RaidChangesConfig.infinite ? net.minecraft.world.effect.MobEffectInstance.INFINITE_DURATION : 120000, i, false, false, true);
|
||||
+
|
||||
+ if (!serverLevel.getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_DISABLE_RAIDS)) {
|
||||
+ entityhuman.addEffect(mobeffect1, entityhuman, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.PATROL_CAPTAIN, true); // CraftBukkit
|
||||
+ }
|
||||
+ this.setPatrolLeader(false);
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaves end - Revert raid changes
|
||||
}
|
||||
|
||||
super.die(cause);
|
||||
@@ -155,7 +190,7 @@ public abstract class Raider extends PatrollingMonster {
|
||||
}
|
||||
|
||||
public boolean hasRaid() {
|
||||
- return this.level() instanceof ServerLevel serverLevel && (this.getCurrentRaid() != null || serverLevel.getRaidAt(this.blockPosition()) != null);
|
||||
+ return !me.earthme.luminol.config.modules.misc.RaidChangesConfig.selfCheck && (this.level() instanceof ServerLevel serverLevel && (this.getCurrentRaid() != null || serverLevel.getRaidAt(this.blockPosition()) != null)); // Leaves - Disable raid self check
|
||||
}
|
||||
|
||||
public boolean hasActiveRaid() {
|
||||
diff --git a/net/minecraft/world/item/component/OminousBottleAmplifier.java b/net/minecraft/world/item/component/OminousBottleAmplifier.java
|
||||
index 33907bb190ffa22ccf9ea424b1e536297878711a..ee8f7d840520b113036e7d2e5e36f626651e1fa5 100644
|
||||
--- a/net/minecraft/world/item/component/OminousBottleAmplifier.java
|
||||
+++ b/net/minecraft/world/item/component/OminousBottleAmplifier.java
|
||||
@@ -29,7 +29,7 @@ public record OminousBottleAmplifier(int value) implements ConsumableListener, T
|
||||
|
||||
@Override
|
||||
public void onConsume(Level level, LivingEntity entity, ItemStack stack, Consumable consumable) {
|
||||
- entity.addEffect(new MobEffectInstance(MobEffects.BAD_OMEN, 120000, this.value, false, false, true)); // Paper - properly resend entities - diff on change for below
|
||||
+ entity.addEffect(new MobEffectInstance(MobEffects.BAD_OMEN, me.earthme.luminol.config.modules.misc.RaidChangesConfig.infinite ? net.minecraft.world.effect.MobEffectInstance.INFINITE_DURATION : 120000, this.value, false, false, true)); // Paper - properly resend entities - diff on change for below // Luminol - Raid effect infinite
|
||||
}
|
||||
|
||||
// Paper start - properly resend entities - collect packets for bundle
|
||||
@@ -41,7 +41,7 @@ public record OminousBottleAmplifier(int value) implements ConsumableListener, T
|
||||
|
||||
@Override
|
||||
public void addToTooltip(Item.TooltipContext context, Consumer<Component> tooltipAdder, TooltipFlag flag, DataComponentGetter componentGetter) {
|
||||
- List<MobEffectInstance> list = List.of(new MobEffectInstance(MobEffects.BAD_OMEN, 120000, this.value, false, false, true));
|
||||
+ List<MobEffectInstance> list = List.of(new MobEffectInstance(MobEffects.BAD_OMEN, me.earthme.luminol.config.modules.misc.RaidChangesConfig.infinite ? net.minecraft.world.effect.MobEffectInstance.INFINITE_DURATION : 120000, this.value, false, false, true)); // Luminol - Raid effect infinite
|
||||
PotionContents.addPotionTooltip(list, tooltipAdder, 1.0F, context.tickRate());
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Add force the data command to be enabled config
|
||||
|
||||
|
||||
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
||||
index fca716bf52e114b196c7617f352e9394c7185271..5a275b9ac7e706012ae5d8a12ee8a3f00f129f93 100644
|
||||
index 4e3bfa25ec4917d2bca594b050e38be3bdea077b..ea50e3c0c4044f03dc8257680814f808fbf3a177 100644
|
||||
--- a/net/minecraft/commands/Commands.java
|
||||
+++ b/net/minecraft/commands/Commands.java
|
||||
@@ -162,7 +162,9 @@ public class Commands {
|
||||
@@ -1,154 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||
Date: Tue, 29 Apr 2025 23:03:56 +0800
|
||||
Subject: [PATCH] Add config to enable Cross Region Damage trace
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index f90defbc0d06b48bdfd6bdfa1a2bf4a6267a45d2..d42f4375952239ecc53a8fbca449120d8a1c52a6 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -1289,6 +1289,13 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
this.awardStat(Stats.ENTITY_KILLED_BY.get(killCredit.getType()));
|
||||
killCredit.awardKillScore(this, cause);
|
||||
this.createWitherRose(killCredit);
|
||||
+ // Luminol Start - Cross Region Damage trace
|
||||
+ } else if (me.earthme.luminol.config.modules.experiment.EntityDamageSourceTraceConfig.enabled) {
|
||||
+ final LivingEntity entitylivingnew = this.getKillCreditOrigin();
|
||||
+ if (entitylivingnew != null) {
|
||||
+ this.damageTransferToAsync(entitylivingnew, cause);
|
||||
+ }
|
||||
+ // Luminol End - Cross Region Damage trace
|
||||
}
|
||||
|
||||
this.level().broadcastEntityEvent(this, (byte)3);
|
||||
@@ -1303,6 +1310,24 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
this.setClientLoaded(false);
|
||||
}
|
||||
|
||||
+ // Luminol Start - Cross Region Damage trace
|
||||
+ private void damageTransferToAsync(LivingEntity entity, DamageSource cause) {
|
||||
+ // Operations running on current entity
|
||||
+ this.awardStat(Stats.ENTITY_KILLED_BY.get(entity.getType()));
|
||||
+ this.createWitherRose(entity);
|
||||
+
|
||||
+ // the entity might be in another tickregion sometimes, so we need to schedule the task onto the entity
|
||||
+ // to ensure thread safe
|
||||
+ entity.getBukkitEntity().taskScheduler.schedule((LivingEntity nmsEntity) -> {
|
||||
+ try {
|
||||
+ nmsEntity.awardKillScore(this, cause);
|
||||
+ } catch (Throwable ex) {
|
||||
+ LOGGER.error(ex.getMessage(), ex);
|
||||
+ }
|
||||
+ }, null, 1L );
|
||||
+ }
|
||||
+ // Luminol End - Cross Region Damage trace
|
||||
+
|
||||
private void tellNeutralMobsThatIDied() {
|
||||
AABB aabb = new AABB(this.blockPosition()).inflate(32.0, 10.0, 32.0);
|
||||
this.level()
|
||||
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
||||
index 6102493315f1db2695478ecd7a346cc3f371ebe0..c1d53987991a0808733eac3b500d5d5a0f5d7ac2 100644
|
||||
--- a/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -1190,6 +1190,29 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
}
|
||||
}
|
||||
|
||||
+ // Luminol Start - raid revert adapt Cross Region Damage trace
|
||||
+ public boolean addEffect(MobEffectInstance effectInstance, @Nullable Entity entity, EntityPotionEffectEvent.Cause cause, boolean fireEvent, boolean async) {
|
||||
+ if (ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(entity)) {
|
||||
+ return addEffect(effectInstance, entity, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.PATROL_CAPTAIN, true);
|
||||
+ } else if (me.earthme.luminol.config.modules.experiment.EntityDamageSourceTraceConfig.enabled) {
|
||||
+ postToEntityThreadAddEffect(effectInstance, entity, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.PATROL_CAPTAIN, true);
|
||||
+ return true;
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ private void postToEntityThreadAddEffect(MobEffectInstance effectInstance, @Nullable Entity entity, EntityPotionEffectEvent.Cause cause, boolean fireEvent) {
|
||||
+ if (entity != null)
|
||||
+ entity.getBukkitEntity().taskScheduler.schedule((Entity nmsEntity) -> {
|
||||
+ try {
|
||||
+ addEffect(effectInstance, nmsEntity, cause, fireEvent);
|
||||
+ } catch (Throwable ex) {
|
||||
+ LOGGER.error(ex.getMessage(), ex);
|
||||
+ }
|
||||
+ }, null, 1L );
|
||||
+ }
|
||||
+ // Luminol End - raid revert adapt Cross Region Damage trace
|
||||
+
|
||||
public boolean canBeAffected(MobEffectInstance effectInstance) {
|
||||
if (this.getType().is(EntityTypeTags.IMMUNE_TO_INFESTED)) {
|
||||
return !effectInstance.is(MobEffects.INFESTED);
|
||||
@@ -1914,6 +1937,13 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
final LivingEntity killer = this.getKillCredit();
|
||||
if (killer != null) {
|
||||
killer.awardKillScore(this, damageSource);
|
||||
+ // Luminol Start - Cross Region Damage trace
|
||||
+ } else if (me.earthme.luminol.config.modules.experiment.EntityDamageSourceTraceConfig.enabled) {
|
||||
+ final LivingEntity killernew = this.getKillCreditOrigin();
|
||||
+ if (killernew != null) {
|
||||
+ this.damageTransferToAsync(killernew, damageSource);
|
||||
+ }
|
||||
+ // Luminol End - Cross Region Damage trace
|
||||
}
|
||||
}); // Paper end
|
||||
this.postDeathDropItems(deathEvent); // Paper
|
||||
@@ -1924,6 +1954,18 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
return deathEvent; // Paper
|
||||
}
|
||||
|
||||
+ // Luminol Start - Cross Region Damage trace
|
||||
+ private void damageTransferToAsync(LivingEntity entity, DamageSource damageSource) {
|
||||
+ entity.getBukkitEntity().taskScheduler.schedule((LivingEntity nmsEntity) -> {
|
||||
+ try {
|
||||
+ nmsEntity.awardKillScore(this, damageSource);
|
||||
+ } catch (Throwable ex) {
|
||||
+ LOGGER.error(ex.getMessage(), ex);
|
||||
+ }
|
||||
+ }, null, 1L );
|
||||
+ }
|
||||
+ // Luminol End - Cross Region Damage trace
|
||||
+
|
||||
protected void dropEquipment(ServerLevel level) {
|
||||
}
|
||||
protected void postDeathDropItems(org.bukkit.event.entity.EntityDeathEvent event) {} // Paper - method for post death logic that cannot be ran before the event is potentially cancelled
|
||||
@@ -2508,6 +2550,18 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
}
|
||||
}
|
||||
|
||||
+ // Luminol Start - Cross Region Damage trace
|
||||
+ @Nullable
|
||||
+ public LivingEntity getKillCreditOrigin() {
|
||||
+ if (this.lastHurtByPlayer != null) {
|
||||
+ return this.lastHurtByPlayer.getEntity(this.level(), Player.class);
|
||||
+ } else if (this.lastHurtByMob != null) {
|
||||
+ return this.lastHurtByMob.getEntity(this.level(), LivingEntity.class);
|
||||
+ }
|
||||
+ return null;
|
||||
+ }
|
||||
+ // Luminol End - Cross Region Damage trace
|
||||
+
|
||||
public final float getMaxHealth() {
|
||||
return (float)this.getAttributeValue(Attributes.MAX_HEALTH);
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/raid/Raider.java b/net/minecraft/world/entity/raid/Raider.java
|
||||
index cb537b243b16876e7922cd732ab8dad8d046a450..c25f4b6bb3e11cc13d2de6f2d123d8c7d5a58649 100644
|
||||
--- a/net/minecraft/world/entity/raid/Raider.java
|
||||
+++ b/net/minecraft/world/entity/raid/Raider.java
|
||||
@@ -156,7 +156,13 @@ public abstract class Raider extends PatrollingMonster {
|
||||
net.minecraft.world.effect.MobEffectInstance mobeffect1 = new net.minecraft.world.effect.MobEffectInstance(net.minecraft.world.effect.MobEffects.BAD_OMEN, me.earthme.luminol.config.modules.misc.RaidChangesConfig.infinite ? net.minecraft.world.effect.MobEffectInstance.INFINITE_DURATION : 120000, i, false, false, true);
|
||||
|
||||
if (!serverLevel.getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_DISABLE_RAIDS)) {
|
||||
- entityhuman.addEffect(mobeffect1, entityhuman, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.PATROL_CAPTAIN, true); // CraftBukkit
|
||||
+ if (me.earthme.luminol.config.modules.experiment.EntityDamageSourceTraceConfig.enabled) {
|
||||
+ // Luminol start - Raid changes adapt DamageSource trace
|
||||
+ entityhuman.addEffect(mobeffect1, entityhuman, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.PATROL_CAPTAIN, true, true);
|
||||
+ } else {
|
||||
+ entityhuman.addEffect(mobeffect1, entityhuman, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.PATROL_CAPTAIN, true); // CraftBukkit
|
||||
+ }
|
||||
+ // Luminol end - Raid changes adapt DamageSource trace
|
||||
}
|
||||
this.setPatrolLeader(false);
|
||||
}
|
||||
@@ -17,7 +17,7 @@ index bd3ce123652af11974be4cbf8d2e96f1b2ee0a68..5f26fd89704aa3fd9c37a1d68a7c4c65
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index ecf185fce582a542c65a9544388b84835643978b..12062e37c0e832f27ba52844739d0e8d5519a30a 100644
|
||||
index b437132634f636f4c1d76c86146f377090b5fdb2..6fbdff0eeed6e37aaa7650708c7b0164795f8d0b 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1663,7 +1663,46 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -120,7 +120,7 @@ index 94fb1c99baefbdde91dc5fcf103683c7ffda6baf..b4fdbdba579fa7c7de4928c259b5ff16
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index 111f2f05d0ad3f290dab97f231caf8516821e030..047279cce3ff3a9eedd54db370b8fa6754d85ee4 100644
|
||||
index d2ab8110871ecf8af9d35f8b47f1d67888e15df3..ec4047312cf17f3ba91348ac8d71f747202bef87 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -420,7 +420,9 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -187,14 +187,15 @@ index bfd904e468bbf2cc1a5b3353d3a69ad5087c81ae..116933975ac975bb5a801be81e1c0e9b
|
||||
+ // KioCG end
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index e9ea86d77395975afbe189993ee0dbbd066c3536..0228471a16805042f13158b86379a77371600489 100644
|
||||
index 99301832bbb90f4ab00963f9062c54e829cc813b..46359300e533221cdc2d8aff9f9b98afe593c92b 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -6000,5 +6000,4 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
return false;
|
||||
return this.outOfCamera;
|
||||
@@ -5961,4 +5961,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
return ((ServerLevel) this.level()).isPositionEntityTicking(this.blockPosition());
|
||||
}
|
||||
-
|
||||
// Paper end - Expose entity id counter
|
||||
+
|
||||
+ public boolean shouldTickHot() { return this.tickCount > 20 * 10 && this.isAlive(); } // KioCG
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/LightningBolt.java b/net/minecraft/world/entity/LightningBolt.java
|
||||
index c1c63c77598786d86b4aa4475cc4d36e60955085..27dd86d1d94959cbe8376ee714e3306732151105 100644
|
||||
@@ -261,10 +262,10 @@ index 70cc20483905d3877e2ffb51afb4902bd59f0cd0..fff3965d892e20a3ad9c84fad2c2df2f
|
||||
+ // KioCG end
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java
|
||||
index 5af32286092222f09ad2b54dd2fa6bd9ad3a8f40..0d774fd4be1cdcf03e76db8b17309bbf01bafc55 100644
|
||||
index aed525af488eb839d31d6bec0673b7e128ca4068..543750bee43bfaaaf33f2cec53eb0de05e7a1dd2 100644
|
||||
--- a/net/minecraft/world/entity/player/Player.java
|
||||
+++ b/net/minecraft/world/entity/player/Player.java
|
||||
@@ -1521,6 +1521,13 @@ public abstract class Player extends LivingEntity {
|
||||
@@ -1481,6 +1481,13 @@ public abstract class Player extends LivingEntity {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,160 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Wed, 5 Feb 2025 15:22:19 +0800
|
||||
Subject: [PATCH] Add config to enable Raytracing tracker
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java
|
||||
index d0c03dc51c8ad4997963b244ada855827a4c4065..99a8b9a8ee2032107be03bbc13d0275a337faf7b 100644
|
||||
--- a/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -1278,7 +1278,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
double d1 = vec3_dx * vec3_dx + vec3_dz * vec3_dz; // Paper
|
||||
double d2 = d * d;
|
||||
// Paper start - Configurable entity tracking range by Y
|
||||
- boolean flag = d1 <= d2;
|
||||
+ boolean flag = d1 <= d2 && !entity.isCulled(); // Luminol - Ray tracing entity tracker
|
||||
if (flag && level.paperConfig().entities.trackingRangeY.enabled) {
|
||||
double rangeY = level.paperConfig().entities.trackingRangeY.get(this.entity, -1);
|
||||
if (rangeY != -1) {
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index b5838a0320c729778f27f0d6a623eed4ef7c3a52..e9ea86d77395975afbe189993ee0dbbd066c3536 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -140,7 +140,7 @@ import net.minecraft.world.scores.ScoreHolder;
|
||||
import net.minecraft.world.scores.Team;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
|
||||
-public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder, DataComponentGetter, ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity, ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity { // Paper - rewrite chunk system // Paper - optimise entity tracker
|
||||
+public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder, DataComponentGetter, ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity, ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity, dev.tr7zw.entityculling.versionless.access.Cullable { // Paper - rewrite chunk system // Paper - optimise entity tracker // Luminol - Ray tracing entity tracker
|
||||
// CraftBukkit start
|
||||
private static final org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getLogger();
|
||||
private static final int CURRENT_LEVEL = 2;
|
||||
@@ -5957,4 +5957,48 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
return ((ServerLevel) this.level()).isPositionEntityTicking(this.blockPosition());
|
||||
}
|
||||
// Paper end - Expose entity id counter
|
||||
+
|
||||
+ public boolean shouldTickHot() { return this.tickCount > 20 * 10 && this.isAlive(); } // KioCG
|
||||
+
|
||||
+ private long lasttime = 0;
|
||||
+ private boolean culled = false;
|
||||
+ private boolean outOfCamera = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public void setTimeout() {
|
||||
+ this.lasttime = System.currentTimeMillis() + 1000;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isForcedVisible() {
|
||||
+ return this.lasttime > System.currentTimeMillis();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCulled(boolean value) {
|
||||
+ this.culled = value;
|
||||
+ if (!value) {
|
||||
+ setTimeout();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCulled() {
|
||||
+ if (!me.earthme.luminol.config.modules.experiment.RayTrackingEntityTrackerConfig.enabled)
|
||||
+ return false;
|
||||
+ return this.culled;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setOutOfCamera(boolean value) {
|
||||
+ this.outOfCamera = value;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isOutOfCamera() {
|
||||
+ if (!me.earthme.luminol.config.modules.experiment.RayTrackingEntityTrackerConfig.enabled)
|
||||
+ return false;
|
||||
+ return this.outOfCamera;
|
||||
+ }
|
||||
+
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/EntityType.java b/net/minecraft/world/entity/EntityType.java
|
||||
index 6b72ab233508e6df1eca34360ce76d102ee25a41..f39ee4605cc15102d6560afd1dad5f56dd53cf4e 100644
|
||||
--- a/net/minecraft/world/entity/EntityType.java
|
||||
+++ b/net/minecraft/world/entity/EntityType.java
|
||||
@@ -1109,6 +1109,9 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
|
||||
public final int passengerTickTimerId;
|
||||
public final int passengerInactiveTickTimerId;
|
||||
// Folia end - profiler
|
||||
+ // Luminol - Raytracing entity tracker
|
||||
+ public boolean skipRaytracningCheck = false;
|
||||
+ // Luminol end
|
||||
|
||||
public EntityType(
|
||||
EntityType.EntityFactory<T> factory,
|
||||
diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java
|
||||
index aed525af488eb839d31d6bec0673b7e128ca4068..5af32286092222f09ad2b54dd2fa6bd9ad3a8f40 100644
|
||||
--- a/net/minecraft/world/entity/player/Player.java
|
||||
+++ b/net/minecraft/world/entity/player/Player.java
|
||||
@@ -220,6 +220,25 @@ public abstract class Player extends LivingEntity {
|
||||
return (org.bukkit.craftbukkit.entity.CraftHumanEntity) super.getBukkitEntity();
|
||||
}
|
||||
// CraftBukkit end
|
||||
+ // Luminol start - Raytracing entity tracker
|
||||
+ public dev.tr7zw.entityculling.CullTask cullTask;
|
||||
+ {
|
||||
+ if (!me.earthme.luminol.config.modules.experiment.RayTrackingEntityTrackerConfig.enabled) {
|
||||
+ this.cullTask = null;
|
||||
+ }else {
|
||||
+ final com.logisticscraft.occlusionculling.OcclusionCullingInstance culling = new com.logisticscraft.occlusionculling.OcclusionCullingInstance(
|
||||
+ me.earthme.luminol.config.modules.experiment.RayTrackingEntityTrackerConfig.tracingDistance,
|
||||
+ new dev.tr7zw.entityculling.DefaultChunkDataProvider(this.level())
|
||||
+ );
|
||||
+
|
||||
+ this.cullTask = new dev.tr7zw.entityculling.CullTask(
|
||||
+ culling, this,
|
||||
+ me.earthme.luminol.config.modules.experiment.RayTrackingEntityTrackerConfig.hitboxLimit,
|
||||
+ me.earthme.luminol.config.modules.experiment.RayTrackingEntityTrackerConfig.checkIntervalMs
|
||||
+ );
|
||||
+ }
|
||||
+ }
|
||||
+ // Luminol end
|
||||
|
||||
public Player(Level level, BlockPos pos, float yRot, GameProfile gameProfile) {
|
||||
super(EntityType.PLAYER, level);
|
||||
@@ -277,6 +296,26 @@ public abstract class Player extends LivingEntity {
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
+ // Luminol start - Ray tracing entity tracker
|
||||
+ if (!me.earthme.luminol.config.modules.experiment.RayTrackingEntityTrackerConfig.enabled) {
|
||||
+ if (this.cullTask != null) this.cullTask.signalStop();
|
||||
+ this.cullTask = null;
|
||||
+ }else {
|
||||
+ final com.logisticscraft.occlusionculling.OcclusionCullingInstance culling = new com.logisticscraft.occlusionculling.OcclusionCullingInstance(
|
||||
+ me.earthme.luminol.config.modules.experiment.RayTrackingEntityTrackerConfig.tracingDistance,
|
||||
+ new dev.tr7zw.entityculling.DefaultChunkDataProvider(this.level())
|
||||
+ );
|
||||
+
|
||||
+ this.cullTask = new dev.tr7zw.entityculling.CullTask(
|
||||
+ culling, this,
|
||||
+ me.earthme.luminol.config.modules.experiment.RayTrackingEntityTrackerConfig.hitboxLimit,
|
||||
+ me.earthme.luminol.config.modules.experiment.RayTrackingEntityTrackerConfig.checkIntervalMs
|
||||
+ );
|
||||
+ }
|
||||
+ if (this.cullTask != null) this.cullTask.setup();
|
||||
+ if (this.cullTask != null) this.cullTask.requestCullSignal(); // Luminol - Ray tracing entity tracker
|
||||
+ // Luminol end
|
||||
+
|
||||
this.noPhysics = this.isSpectator();
|
||||
if (this.isSpectator() || this.isPassenger()) {
|
||||
this.setOnGround(false);
|
||||
@@ -1415,6 +1454,7 @@ public abstract class Player extends LivingEntity {
|
||||
if (this.containerMenu != null && this.hasContainerOpen()) {
|
||||
this.doCloseContainer();
|
||||
}
|
||||
+ if (this.cullTask != null) this.cullTask.signalStop(); // Luminol - Ray tracing entity tracker
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -5,10 +5,10 @@ Subject: [PATCH] Add missing teleportation apis for folia
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index 047279cce3ff3a9eedd54db370b8fa6754d85ee4..bcc0c3cfa5be4daeec6e95a1b63a6cd38890f04d 100644
|
||||
index ec4047312cf17f3ba91348ac8d71f747202bef87..56d00caf9db21798fdcbd6ec2cd84a841a5dfd99 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -1631,6 +1631,9 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -1606,6 +1606,9 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
if (respawnComplete != null) {
|
||||
respawnComplete.accept(ServerPlayer.this);
|
||||
}
|
||||
@@ -19,10 +19,10 @@ index 047279cce3ff3a9eedd54db370b8fa6754d85ee4..bcc0c3cfa5be4daeec6e95a1b63a6cd3
|
||||
);
|
||||
});
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 0228471a16805042f13158b86379a77371600489..9d945f615187f86913be8a9b83b1aada3a1336b6 100644
|
||||
index 46359300e533221cdc2d8aff9f9b98afe593c92b..cb347fe9e2876f3b26f004785c882f5faef560d7 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -4108,6 +4108,31 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -4112,6 +4112,31 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
|
||||
// TODO any events that can modify go HERE
|
||||
@@ -54,7 +54,7 @@ index 0228471a16805042f13158b86379a77371600489..9d945f615187f86913be8a9b83b1aada
|
||||
|
||||
// check for same region
|
||||
if (destination == this.level()) {
|
||||
@@ -4224,7 +4249,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -4228,7 +4253,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
// we just select the spawn position
|
||||
case END: {
|
||||
if (destination.getTypeKey() == net.minecraft.world.level.dimension.LevelStem.END) {
|
||||
@@ -74,7 +74,7 @@ index 0228471a16805042f13158b86379a77371600489..9d945f615187f86913be8a9b83b1aada
|
||||
// need to load chunks so we can create the platform
|
||||
destination.moonrise$loadChunksAsync(
|
||||
targetPos, 16, // load 16 blocks to be safe from block physics
|
||||
@@ -4245,7 +4281,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -4249,7 +4285,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
);
|
||||
} else {
|
||||
@@ -94,7 +94,7 @@ index 0228471a16805042f13158b86379a77371600489..9d945f615187f86913be8a9b83b1aada
|
||||
// need to load chunk for heightmap
|
||||
destination.moonrise$loadChunksAsync(
|
||||
spawnPos, 0,
|
||||
@@ -4296,8 +4343,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -4300,8 +4347,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
|
||||
WorldBorder destinationBorder = destination.getWorldBorder();
|
||||
double dimensionScale = net.minecraft.world.level.dimension.DimensionType.getTeleportationScale(origin.dimensionType(), destination.dimensionType());
|
||||
@@ -114,7 +114,7 @@ index 0228471a16805042f13158b86379a77371600489..9d945f615187f86913be8a9b83b1aada
|
||||
ca.spottedleaf.concurrentutil.completable.CallbackCompletable<BlockUtil.FoundRectangle> portalFound
|
||||
= new ca.spottedleaf.concurrentutil.completable.CallbackCompletable<>();
|
||||
|
||||
@@ -4434,6 +4491,15 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -4438,6 +4495,15 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
if (!this.canPortalAsync(destination, takePassengers)) {
|
||||
return false;
|
||||
}
|
||||
@@ -130,7 +130,7 @@ index 0228471a16805042f13158b86379a77371600489..9d945f615187f86913be8a9b83b1aada
|
||||
|
||||
Vec3 initialPosition = this.position();
|
||||
ChunkPos initialPositionChunk = new ChunkPos(
|
||||
@@ -4501,6 +4567,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -4505,6 +4571,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
if (teleportComplete != null) {
|
||||
teleportComplete.accept(teleported);
|
||||
}
|
||||
@@ -10,10 +10,10 @@ VMP (https://github.com/RelativityMC/VMP-fabric)
|
||||
Licensed under: MIT (https://opensource.org/licenses/MIT)
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 9d945f615187f86913be8a9b83b1aada3a1336b6..06496237f947af4849cb7f364eacf11d53736e3d 100644
|
||||
index cb347fe9e2876f3b26f004785c882f5faef560d7..95fd1fc621a01d4a2a97e78f471a1d1a599db612 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -1081,7 +1081,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -1085,7 +1085,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
private double moveStartZ;
|
||||
// Paper end - detailed watchdog information
|
||||
|
||||
@@ -28,7 +28,7 @@ index 9d945f615187f86913be8a9b83b1aada3a1336b6..06496237f947af4849cb7f364eacf11d
|
||||
final Vec3 originalMovement = movement; // Paper - Expose pre-collision velocity
|
||||
// Paper start - detailed watchdog information
|
||||
ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread("Cannot move an entity off-main");
|
||||
@@ -5048,6 +5055,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -5052,6 +5059,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
|
||||
public final void setBoundingBox(AABB bb) {
|
||||
@@ -53,7 +53,7 @@ index f6518e29f805018c72222f5aaa7b662071665b65..8d082996a0f361cfd12af6a2138efd70
|
||||
this.get("generator-settings", property -> GsonHelper.parse(!property.isEmpty() ? property : "{}"), new JsonObject()),
|
||||
this.get("level-type", property -> property.toLowerCase(Locale.ROOT), WorldPresets.NORMAL.location().toString())
|
||||
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
||||
index 357d81d42f187fb1c52584e6c9cfe611fe755aba..6dc5b1a8bdba998e11bcdf352bcc0fc7161a484c 100644
|
||||
index 977fefea7f81d69b40dca46f72b9629f8c491c44..f8322334fb6a0cea38c4d1981862ba673fd1b100 100644
|
||||
--- a/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -674,6 +674,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
@@ -8,7 +8,7 @@ As part of: Leaves (https://github.com/LeavesMC/Leaves/blob/f553c53e4230aa032e54
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 77546196289bccbbc0c40c2d69ff9ddd2bc98ffe..d6a284bcdd9cb6b7442f99f9c7e9f2293fa0a218 100644
|
||||
index d60a1d4c4c8bd7650170775e37e8ca76b46a1588..4fc3c9f2b04711569c12a0efa027601fdd0a40b5 100644
|
||||
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -573,7 +573,7 @@ public class ServerGamePacketListenerImpl
|
||||
@@ -8,7 +8,7 @@ As part of: Leaves (https://github.com/LeavesMC/Leaves/blob/f553c53e4230aa032e54
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index bcc0c3cfa5be4daeec6e95a1b63a6cd38890f04d..e83c6a81e318a05580f5c811cb2543a83435f04c 100644
|
||||
index 56d00caf9db21798fdcbd6ec2cd84a841a5dfd99..4c811d989382f9b04f2c978ea5d1b845a55cc000 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -1285,7 +1285,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -20,9 +20,9 @@ index bcc0c3cfa5be4daeec6e95a1b63a6cd38890f04d..e83c6a81e318a05580f5c811cb2543a8
|
||||
// we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory.
|
||||
if (!event.getKeepInventory()) {
|
||||
// Paper start - PlayerDeathEvent#getItemsToKeep
|
||||
@@ -1357,6 +1357,15 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -1332,6 +1332,15 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
this.setClientLoaded(false);
|
||||
}
|
||||
// Luminol End - Cross Region Damage trace
|
||||
|
||||
+ // Leaves start - exp fix
|
||||
+ private boolean shouldDropExperience(boolean eventResult, boolean forceUseEvent) {
|
||||
@@ -37,7 +37,7 @@ index bcc0c3cfa5be4daeec6e95a1b63a6cd38890f04d..e83c6a81e318a05580f5c811cb2543a8
|
||||
AABB aabb = new AABB(this.blockPosition()).inflate(32.0, 10.0, 32.0);
|
||||
this.level()
|
||||
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
||||
index c1d53987991a0808733eac3b500d5d5a0f5d7ac2..dcec5d26950bc654f67e7de7688c074cc502e486 100644
|
||||
index 6102493315f1db2695478ecd7a346cc3f371ebe0..99a0f521c2a327121f20821188356e2e415bc380 100644
|
||||
--- a/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -264,6 +264,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -48,7 +48,7 @@ index c1d53987991a0808733eac3b500d5d5a0f5d7ac2..dcec5d26950bc654f67e7de7688c074c
|
||||
public List<DefaultDrop> drops = new java.util.ArrayList<>(); // Paper - Restore vanilla drops behavior
|
||||
public final org.bukkit.craftbukkit.attribute.CraftAttributeMap craftAttributes;
|
||||
public boolean collides = true;
|
||||
@@ -1870,6 +1871,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -1847,6 +1848,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
entity.killedEntity((ServerLevel) this.level(), this);
|
||||
}
|
||||
this.gameEvent(GameEvent.ENTITY_DIE);
|
||||
@@ -56,7 +56,7 @@ index c1d53987991a0808733eac3b500d5d5a0f5d7ac2..dcec5d26950bc654f67e7de7688c074c
|
||||
} else {
|
||||
this.dead = false;
|
||||
this.setHealth((float) deathEvent.getReviveHealth());
|
||||
@@ -1950,7 +1952,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -1920,7 +1922,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
this.drops = new java.util.ArrayList<>();
|
||||
// this.dropEquipment(level); // CraftBukkit - moved up
|
||||
// CraftBukkit end
|
||||
@@ -12,10 +12,10 @@ As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric)
|
||||
Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
||||
|
||||
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
||||
index dcec5d26950bc654f67e7de7688c074cc502e486..0a06dc4b7fac7c7d63996553e2cb2a38ddb5f195 100644
|
||||
index 99a0f521c2a327121f20821188356e2e415bc380..9d10ca1808ba66a792f41ed4484897607d037303 100644
|
||||
--- a/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -2746,6 +2746,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -2692,6 +2692,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
}
|
||||
|
||||
protected void updateSwingTime() {
|
||||
@@ -23,7 +23,7 @@ index dcec5d26950bc654f67e7de7688c074cc502e486..0a06dc4b7fac7c7d63996553e2cb2a38
|
||||
int currentSwingDuration = this.getCurrentSwingDuration();
|
||||
if (this.swinging) {
|
||||
this.swingTime++;
|
||||
@@ -3629,6 +3630,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -3575,6 +3576,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
protected void updateFallFlying() {
|
||||
this.checkSlowFallDistance();
|
||||
if (!this.level().isClientSide) {
|
||||
@@ -8,10 +8,10 @@ As part of: Kaiiju (https://github.com/KaiijuMC/Kaiiju/blob/c2b7aec8f7b418a39a2e
|
||||
Licensed under: GPL-3.0 (https://github.com/KaiijuMC/Kaiiju/blob/c2b7aec8f7b418a39a2ec408e6411e6f752379da/LICENSE)
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 06496237f947af4849cb7f364eacf11d53736e3d..af793516943582d92fe02a222b8c73f759ee8aae 100644
|
||||
index 95fd1fc621a01d4a2a97e78f471a1d1a599db612..75b5856b892272aaa70616c35dea75ba3ac76058 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -4273,14 +4273,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -4277,14 +4277,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
targetPos, 16, // load 16 blocks to be safe from block physics
|
||||
ca.spottedleaf.concurrentutil.util.Priority.HIGH,
|
||||
(chunks) -> {
|
||||
@@ -34,7 +34,7 @@ index 06496237f947af4849cb7f364eacf11d53736e3d..af793516943582d92fe02a222b8c73f7
|
||||
TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET),
|
||||
org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL
|
||||
)
|
||||
@@ -4306,11 +4310,15 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -4310,11 +4314,15 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
ca.spottedleaf.concurrentutil.util.Priority.HIGH,
|
||||
(chunks) -> {
|
||||
BlockPos adjustedSpawn = destination.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, spawnPos);
|
||||
@@ -52,7 +52,7 @@ index 06496237f947af4849cb7f364eacf11d53736e3d..af793516943582d92fe02a222b8c73f7
|
||||
Relative.union(Relative.DELTA, Relative.ROTATION),
|
||||
TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET),
|
||||
org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL
|
||||
@@ -4507,6 +4515,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -4511,6 +4519,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
return false;
|
||||
}
|
||||
// Luminol end
|
||||
@@ -63,7 +63,7 @@ index 06496237f947af4849cb7f364eacf11d53736e3d..af793516943582d92fe02a222b8c73f7
|
||||
|
||||
Vec3 initialPosition = this.position();
|
||||
ChunkPos initialPositionChunk = new ChunkPos(
|
||||
@@ -4571,8 +4583,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -4575,8 +4587,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
info.postTeleportTransition().onTransition(teleported);
|
||||
}
|
||||
|
||||
@@ -21,10 +21,10 @@ index aec5370b285d4648280b3e1c4c2fcaa501376739..21ca0737d07e4edb5c9f52a703ba1ea0
|
||||
}
|
||||
if (entity instanceof final Mob mob && mob.getTarget() != null) {
|
||||
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
||||
index 0a06dc4b7fac7c7d63996553e2cb2a38ddb5f195..ae83447f99f483e1b509c52060353bd13ddbc458 100644
|
||||
index 9d10ca1808ba66a792f41ed4484897607d037303..5b5e63c4dc10076ba33a8ddf0ebae96643b1161f 100644
|
||||
--- a/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -2156,6 +2156,20 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -2114,6 +2114,20 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
return this.lastClimbablePos;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ Co-authored by: MrPowerGamerBR <git@mrpowergamerbr.com>
|
||||
As part of: SparklyPaper (https://github.com/SparklyPower/SparklyPaper/blob/a69d3690472c9967772ffd4d4bd1f41403b7ea6f/sparklypaper-server/paper-patches/features/0005-Optimize-canSee-checks.patch)
|
||||
|
||||
diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java
|
||||
index 99a8b9a8ee2032107be03bbc13d0275a337faf7b..607091ecbd4a7261f2c0d839ee4dd1d27fa2190a 100644
|
||||
index d0c03dc51c8ad4997963b244ada855827a4c4065..ee53f78396f4377d3e5c2998826f231208066ef6 100644
|
||||
--- a/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -1294,7 +1294,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Correct player respawn place
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index e83c6a81e318a05580f5c811cb2543a83435f04c..2f2726ed97658732751032b21752840702da233e 100644
|
||||
index 4c811d989382f9b04f2c978ea5d1b845a55cc000..c3201cb0ba6f928f658d4c74a1ef2b7e8900b1f6 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -492,8 +492,10 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -6,7 +6,7 @@ Subject: [PATCH] Force disable builtin spark plugin
|
||||
The spark passed down from paper has some memory leaking issue, so we fully removed it from the code to prevent that memory leaking issue.
|
||||
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index 12062e37c0e832f27ba52844739d0e8d5519a30a..87625b365e04ce05fa2b6cdf2003c839255c4393 100644
|
||||
index 6fbdff0eeed6e37aaa7650708c7b0164795f8d0b..33d596c0f07d076886c0dd8eb93e901cdb56e438 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -781,8 +781,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -1,175 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||
Date: Thu, 20 Feb 2025 01:00:28 +0800
|
||||
Subject: [PATCH] Purpur: Barrels and enderchests 6 rows
|
||||
|
||||
Co-authored by: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
As part of: Purpur (https://github.com/PurpurMC/Purpur/blob/09f547de09fc5d886f18f6d99ff389289766ec9d/purpur-server/minecraft-patches/features/0003-Barrels-and-enderchests-6-rows.patch)
|
||||
Licensed under: MIT (https://github.com/PurpurMC/Purpur/blob/09f547de09fc5d886f18f6d99ff389289766ec9d/LICENSE)
|
||||
|
||||
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
|
||||
index 001483b7098523f3645a95c81fcf0e38b551705e..8a32580897c6814ca7cbc7cdfc3a3e41b4ce788f 100644
|
||||
--- a/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/net/minecraft/server/players/PlayerList.java
|
||||
@@ -1116,6 +1116,10 @@ public abstract class PlayerList {
|
||||
player.getBukkitEntity().recalculatePermissions(); // CraftBukkit
|
||||
this.server.getCommands().sendCommands(player);
|
||||
} // Paper - Add sendOpLevel API
|
||||
+
|
||||
+ // Purpur start - Barrels and enderchests 6 rows
|
||||
+ player.enderChestSlotCount = me.earthme.luminol.config.modules.misc.ContainerExpansionConfig.enderchestRows < 7 && me.earthme.luminol.config.modules.misc.ContainerExpansionConfig.enderchestRows > 0 ? 9 * me.earthme.luminol.config.modules.misc.ContainerExpansionConfig.enderchestRows : 27;
|
||||
+ // Purpur end - Barrels and enderchests 6 rows
|
||||
}
|
||||
|
||||
public boolean isWhiteListed(GameProfile profile) {
|
||||
diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java
|
||||
index 0d774fd4be1cdcf03e76db8b17309bbf01bafc55..1230effe955a627ff24866fdac4c55bff45cc241 100644
|
||||
--- a/net/minecraft/world/entity/player/Player.java
|
||||
+++ b/net/minecraft/world/entity/player/Player.java
|
||||
@@ -210,6 +210,7 @@ public abstract class Player extends LivingEntity {
|
||||
private int currentImpulseContextResetGraceTime = 0;
|
||||
public boolean affectsSpawning = true; // Paper - Affects Spawning API
|
||||
public net.kyori.adventure.util.TriState flyingFallDamage = net.kyori.adventure.util.TriState.NOT_SET; // Paper - flying fall damage
|
||||
+ public int enderChestSlotCount = -1; // Purpur - Barrels and enderchests 6 rows
|
||||
|
||||
// CraftBukkit start
|
||||
public boolean fauxSleeping;
|
||||
diff --git a/net/minecraft/world/inventory/ChestMenu.java b/net/minecraft/world/inventory/ChestMenu.java
|
||||
index 0fffa384f928ab84451331380968fb4650eafe26..d84a10396395939149da88bcb01be59e220c340e 100644
|
||||
--- a/net/minecraft/world/inventory/ChestMenu.java
|
||||
+++ b/net/minecraft/world/inventory/ChestMenu.java
|
||||
@@ -66,10 +66,30 @@ public class ChestMenu extends AbstractContainerMenu {
|
||||
return new ChestMenu(MenuType.GENERIC_9x6, containerId, playerInventory, 6);
|
||||
}
|
||||
|
||||
+ // Purpur start - Barrels and enderchests 6 rows
|
||||
+ public static ChestMenu oneRow(int syncId, Inventory playerInventory, Container inventory) {
|
||||
+ return new ChestMenu(MenuType.GENERIC_9x1, syncId, playerInventory, inventory, 1);
|
||||
+ }
|
||||
+
|
||||
+ public static ChestMenu twoRows(int syncId, Inventory playerInventory, Container inventory) {
|
||||
+ return new ChestMenu(MenuType.GENERIC_9x2, syncId, playerInventory, inventory, 2);
|
||||
+ }
|
||||
+ // Purpur end - Barrels and enderchests 6 rows
|
||||
+
|
||||
public static ChestMenu threeRows(int containerId, Inventory playerInventory, Container container) {
|
||||
return new ChestMenu(MenuType.GENERIC_9x3, containerId, playerInventory, container, 3);
|
||||
}
|
||||
|
||||
+ // Purpur start - Barrels and enderchests 6 rows
|
||||
+ public static ChestMenu fourRows(int syncId, Inventory playerInventory, Container inventory) {
|
||||
+ return new ChestMenu(MenuType.GENERIC_9x4, syncId, playerInventory, inventory, 4);
|
||||
+ }
|
||||
+
|
||||
+ public static ChestMenu fiveRows(int syncId, Inventory playerInventory, Container inventory) {
|
||||
+ return new ChestMenu(MenuType.GENERIC_9x5, syncId, playerInventory, inventory, 5);
|
||||
+ }
|
||||
+ // Purpur end - Barrels and enderchests 6 rows
|
||||
+
|
||||
public static ChestMenu sixRows(int containerId, Inventory playerInventory, Container container) {
|
||||
return new ChestMenu(MenuType.GENERIC_9x6, containerId, playerInventory, container, 6);
|
||||
}
|
||||
diff --git a/net/minecraft/world/inventory/PlayerEnderChestContainer.java b/net/minecraft/world/inventory/PlayerEnderChestContainer.java
|
||||
index bc2b95973192069fc64581b59583b19df876f55d..72b8532acd7838e94e2cc0e2085d2ad84ba56f5e 100644
|
||||
--- a/net/minecraft/world/inventory/PlayerEnderChestContainer.java
|
||||
+++ b/net/minecraft/world/inventory/PlayerEnderChestContainer.java
|
||||
@@ -25,11 +25,18 @@ public class PlayerEnderChestContainer extends SimpleContainer {
|
||||
}
|
||||
|
||||
public PlayerEnderChestContainer(Player owner) {
|
||||
- super(27);
|
||||
+ super(me.earthme.luminol.config.modules.misc.ContainerExpansionConfig.enderchestRows < 7 && me.earthme.luminol.config.modules.misc.ContainerExpansionConfig.enderchestRows > 0 ? 9 * me.earthme.luminol.config.modules.misc.ContainerExpansionConfig.enderchestRows : 27);
|
||||
this.owner = owner;
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
||||
+ // Purpur start - Barrels and enderchests 6 rows
|
||||
+ @Override
|
||||
+ public int getContainerSize() {
|
||||
+ return owner.enderChestSlotCount < 0 ? super.getContainerSize() : owner.enderChestSlotCount;
|
||||
+ }
|
||||
+ // Purpur end - Barrels and enderchests 6 rows
|
||||
+
|
||||
public void setActiveChest(EnderChestBlockEntity enderChestBlockEntity) {
|
||||
this.activeChest = enderChestBlockEntity;
|
||||
}
|
||||
diff --git a/net/minecraft/world/level/block/EnderChestBlock.java b/net/minecraft/world/level/block/EnderChestBlock.java
|
||||
index 5077a9ff7b78801bdc53536a37aee07b8d86ee4d..17b43a2c793dff0576a26e6ac3764b87faf4112e 100644
|
||||
--- a/net/minecraft/world/level/block/EnderChestBlock.java
|
||||
+++ b/net/minecraft/world/level/block/EnderChestBlock.java
|
||||
@@ -85,8 +85,14 @@ public class EnderChestBlock extends AbstractChestBlock<EnderChestBlockEntity> i
|
||||
enderChestInventory.setActiveChest(enderChestBlockEntity); // Needs to happen before ChestMenu.threeRows as it is required for opening animations
|
||||
if (level instanceof ServerLevel serverLevel && player.openMenu(
|
||||
new SimpleMenuProvider(
|
||||
- (containerId, playerInventory, player1) -> ChestMenu.threeRows(containerId, playerInventory, enderChestInventory), CONTAINER_TITLE
|
||||
- )
|
||||
+ (containerId, playerInventory, player1) -> switch (me.earthme.luminol.config.modules.misc.ContainerExpansionConfig.enderchestRows) {
|
||||
+ case 6 -> ChestMenu.sixRows(containerId, playerInventory, enderChestInventory);
|
||||
+ case 5 -> ChestMenu.fiveRows(containerId, playerInventory, enderChestInventory);
|
||||
+ case 4 -> ChestMenu.fourRows(containerId, playerInventory, enderChestInventory);
|
||||
+ case 2 -> ChestMenu.twoRows(containerId, playerInventory, enderChestInventory);
|
||||
+ case 1 -> ChestMenu.oneRow(containerId, playerInventory, enderChestInventory);
|
||||
+ default -> ChestMenu.threeRows(containerId, playerInventory, enderChestInventory);
|
||||
+ }, CONTAINER_TITLE) // Purpur - Barrels and enderchests 6 rows
|
||||
).isPresent()) {
|
||||
// Paper end - Fix InventoryOpenEvent cancellation - moved up;
|
||||
player.awardStat(Stats.OPEN_ENDERCHEST);
|
||||
diff --git a/net/minecraft/world/level/block/entity/BarrelBlockEntity.java b/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
|
||||
index 027502d0af5512c31878978c4d05c52fa3029cca..2724b762bfb44e48619d4449560cf968a8fa7dee 100644
|
||||
--- a/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
|
||||
+++ b/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
|
||||
@@ -56,7 +56,17 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity {
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
- private NonNullList<ItemStack> items = NonNullList.withSize(27, ItemStack.EMPTY);
|
||||
+ // Purpur start - Barrels and enderchests 6 rows
|
||||
+ private NonNullList<ItemStack> items = NonNullList.withSize(switch (me.earthme.luminol.config.modules.misc.ContainerExpansionConfig.barrelRows) {
|
||||
+ case 6 -> 54;
|
||||
+ case 5 -> 45;
|
||||
+ case 4 -> 36;
|
||||
+ case 2 -> 18;
|
||||
+ case 1 -> 9;
|
||||
+ default -> 27;
|
||||
+ }, ItemStack.EMPTY);
|
||||
+ // Purpur end - Barrels and enderchests 6 rows
|
||||
+
|
||||
public final ContainerOpenersCounter openersCounter = new ContainerOpenersCounter() {
|
||||
@Override
|
||||
protected void onOpen(Level level, BlockPos pos, BlockState state) {
|
||||
@@ -108,7 +118,16 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity {
|
||||
|
||||
@Override
|
||||
public int getContainerSize() {
|
||||
- return 27;
|
||||
+ // Purpur start - Barrels and enderchests 6 rows
|
||||
+ return switch (me.earthme.luminol.config.modules.misc.ContainerExpansionConfig.barrelRows) {
|
||||
+ case 6 -> 54;
|
||||
+ case 5 -> 45;
|
||||
+ case 4 -> 36;
|
||||
+ case 2 -> 18;
|
||||
+ case 1 -> 9;
|
||||
+ default -> 27;
|
||||
+ };
|
||||
+ // Purpur end - Barrels and enderchests 6 rows
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -128,7 +147,16 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity {
|
||||
|
||||
@Override
|
||||
protected AbstractContainerMenu createMenu(int id, Inventory player) {
|
||||
- return ChestMenu.threeRows(id, player, this);
|
||||
+ // Purpur start - Barrels and enderchests 6 rows
|
||||
+ return switch (me.earthme.luminol.config.modules.misc.ContainerExpansionConfig.barrelRows) {
|
||||
+ case 6 -> ChestMenu.sixRows(id, player, this);
|
||||
+ case 5 -> ChestMenu.fiveRows(id, player, this);
|
||||
+ case 4 -> ChestMenu.fourRows(id, player, this);
|
||||
+ case 2 -> ChestMenu.twoRows(id, player, this);
|
||||
+ case 1 -> ChestMenu.oneRow(id, player, this);
|
||||
+ default -> ChestMenu.threeRows(id, player, this);
|
||||
+ };
|
||||
+ // Purpur end - Barrels and enderchests 6 rows
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,7 +46,7 @@ index 8329bc0cf531a1317ff8e213e948019d28df1eea..84a6bf575902676fc06211562b578064
|
||||
} else {entity.inactiveTick();} // Paper - EAR 2
|
||||
profilerFiller.pop();
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index af793516943582d92fe02a222b8c73f759ee8aae..9f1d0c85631a585e00a8b20f3536f1f61b011201 100644
|
||||
index 75b5856b892272aaa70616c35dea75ba3ac76058..cf634aa6898ccdb53a34a410266aeecb86c5f0de 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -350,6 +350,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -57,7 +57,7 @@ index af793516943582d92fe02a222b8c73f759ee8aae..9f1d0c85631a585e00a8b20f3536f1f6
|
||||
|
||||
public void inactiveTick() {
|
||||
}
|
||||
@@ -3223,6 +3224,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -3227,6 +3228,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
} else {
|
||||
if (this.portalProcess == null || !this.portalProcess.isSamePortal(portal)) {
|
||||
this.portalProcess = new PortalProcessor(portal, pos.immutable());
|
||||
@@ -6,10 +6,10 @@ Subject: [PATCH] Fix off tickregion sync teleport
|
||||
Folis's teleportAsync implementation has some checks missing during the sync teleportation checks, if we are teleport to the edge of the tickregion, it is still asserting that we are in the same tickregion and moved us directly, but there is actually some logics is already touching the stuff out of current tickregion.So we added some new edge checks to the sync teleportation checks which will check the tickregion belonging in a shape of cycle which is in min(entity's bounding box + simulate distance, 6) of radius to fix that issue
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 9f1d0c85631a585e00a8b20f3536f1f61b011201..87e22d1fed087886ac845f6e816be5bf20fac9fb 100644
|
||||
index cf634aa6898ccdb53a34a410266aeecb86c5f0de..4743de5c39ee52bdde1f70e340d547a6cc7f4ead 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -4024,6 +4024,21 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -4028,6 +4028,21 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
this.resetStoredPositions();
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ index 9f1d0c85631a585e00a8b20f3536f1f61b011201..87e22d1fed087886ac845f6e816be5bf
|
||||
protected final void transform(TeleportTransition telpeort) {
|
||||
PositionMoveRotation move = PositionMoveRotation.calculateAbsolute(
|
||||
PositionMoveRotation.of(this), PositionMoveRotation.of(telpeort), telpeort.relatives()
|
||||
@@ -4146,7 +4161,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -4150,7 +4165,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
// check for same region
|
||||
if (destination == this.level()) {
|
||||
Vec3 currPos = this.position();
|
||||
@@ -6,10 +6,10 @@ Subject: [PATCH] Teleport async if entity was moving to another region at once
|
||||
On folia, entity usually cannot move out of the tickregion, but sometimes it actually does(like some end pearl gun that can shoot an end pearl to the block faraway than 10000 blocks even more). To fix this, we added a temporary fix which teleport these entities to the destination instead running its move logics so that we could ensure anything is under control.But one thing need to consider is that teleportAsync is actually calling halfway of the entity tick and there is still something running when teleportAsync called, which is actually modified the entity in another thread, so there is still need an improvement
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 87e22d1fed087886ac845f6e816be5bf20fac9fb..b163c43f5398b9f38c75ae7af6a3015b686624ce 100644
|
||||
index 4743de5c39ee52bdde1f70e340d547a6cc7f4ead..a023cc399fc8bfee7771e5ca6716578f89b7072f 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -1084,6 +1084,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -1088,6 +1088,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
|
||||
private boolean boundingBoxChanged = false; // Gale - VMP - skip entity move if movement is zero
|
||||
|
||||
@@ -20,7 +20,7 @@ index 87e22d1fed087886ac845f6e816be5bf20fac9fb..b163c43f5398b9f38c75ae7af6a3015b
|
||||
public void move(MoverType type, Vec3 movement) {
|
||||
// Gale start - VMP - skip entity move if movement is zero
|
||||
if (!this.boundingBoxChanged && movement.equals(Vec3.ZERO)) {
|
||||
@@ -1099,6 +1103,32 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -1103,6 +1107,32 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
this.moveStartZ = this.getZ();
|
||||
this.moveVector = movement;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <mrhua269@gmail.com>
|
||||
Date: Sun, 15 Jun 2025 16:58:05 +0800
|
||||
Subject: [PATCH] Do not fire pre creature spawn event unless some plugin is
|
||||
listening it
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/level/NaturalSpawner.java b/net/minecraft/world/level/NaturalSpawner.java
|
||||
index f324a74a191d3fe3e270556d07c4543ec34e0195..2fb36cba4cda3f7b84efae9cba6bed2394fb0457 100644
|
||||
--- a/net/minecraft/world/level/NaturalSpawner.java
|
||||
+++ b/net/minecraft/world/level/NaturalSpawner.java
|
||||
@@ -360,16 +360,18 @@ public final class NaturalSpawner {
|
||||
) {
|
||||
EntityType<?> entityType = data.type();
|
||||
// Paper start - PreCreatureSpawnEvent
|
||||
- com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent(
|
||||
- org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, level),
|
||||
- org.bukkit.craftbukkit.entity.CraftEntityType.minecraftToBukkit(entityType), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL
|
||||
- );
|
||||
- if (!event.callEvent()) {
|
||||
- if (event.shouldAbortSpawn()) {
|
||||
- return PreSpawnStatus.ABORT;
|
||||
+ if (com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent.getHandlerList().getRegisteredListeners().length != 0) { // Luminol - Do not fire pre creature spawn event unless some plugin is listening it
|
||||
+ com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent(
|
||||
+ org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, level),
|
||||
+ org.bukkit.craftbukkit.entity.CraftEntityType.minecraftToBukkit(entityType), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL
|
||||
+ );
|
||||
+ if (!event.callEvent()) {
|
||||
+ if (event.shouldAbortSpawn()) {
|
||||
+ return PreSpawnStatus.ABORT;
|
||||
+ }
|
||||
+ return PreSpawnStatus.CANCELLED;
|
||||
}
|
||||
- return PreSpawnStatus.CANCELLED;
|
||||
- }
|
||||
+ } // Luminol - Do not fire pre creature spawn event unless some plugin is listening it
|
||||
final boolean success = entityType.getCategory() != MobCategory.MISC
|
||||
// Paper end - PreCreatureSpawnEvent
|
||||
&& (
|
||||
@@ -0,0 +1,36 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
Date: Tue, 9 Nov 2077 00:00:00 +0800
|
||||
Subject: [PATCH] Cpu affinity
|
||||
|
||||
|
||||
diff --git a/io/papermc/paper/threadedregions/TickRegionScheduler.java b/io/papermc/paper/threadedregions/TickRegionScheduler.java
|
||||
index fa6b8d756195c1b430cc11214a901bd42eebc98d..0357792de0ed8ec9058d1847c8b45c33ff365af6 100644
|
||||
--- a/io/papermc/paper/threadedregions/TickRegionScheduler.java
|
||||
+++ b/io/papermc/paper/threadedregions/TickRegionScheduler.java
|
||||
@@ -49,6 +49,25 @@ public final class TickRegionScheduler {
|
||||
|
||||
@Override
|
||||
public Thread newThread(final Runnable run) {
|
||||
+ // Luminol start - cpu affinity
|
||||
+ if (me.earthme.luminol.config.modules.misc.CpuAffinityConfig.cpuAffinityEnabled) {
|
||||
+ Runnable affinityRunnable = new Runnable() {
|
||||
+ private boolean affinitySet = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public void run() {
|
||||
+ if (!this.affinitySet) {
|
||||
+ this.affinitySet = true;
|
||||
+ net.openhft.affinity.Affinity.setAffinity(me.earthme.luminol.config.modules.misc.CpuAffinityConfig.tickRegionAffinityBitSet);
|
||||
+ }
|
||||
+ run.run();
|
||||
+ }
|
||||
+ };
|
||||
+ final Thread ret = new TickThreadRunner(affinityRunnable, "Region Scheduler Thread #" + this.idGenerator.getAndIncrement());
|
||||
+ ret.setUncaughtExceptionHandler(TickRegionScheduler.this::uncaughtException);
|
||||
+ return ret;
|
||||
+ }
|
||||
+ // Luminol end - cpu affinity
|
||||
final Thread ret = new TickThreadRunner(run, "Region Scheduler Thread #" + this.idGenerator.getAndIncrement());
|
||||
ret.setUncaughtExceptionHandler(TickRegionScheduler.this::uncaughtException);
|
||||
return ret;
|
||||
@@ -0,0 +1,21 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||
Date: Wed, 18 Jun 2025 23:46:20 +0800
|
||||
Subject: [PATCH] Temporarily fix teleport yam and pitch
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/commands/TeleportCommand.java b/net/minecraft/server/commands/TeleportCommand.java
|
||||
index 174122905addbc88e818cd4946e831aec051b91a..4451f79df614c6e57e813996888b4e99a14c87d5 100644
|
||||
--- a/net/minecraft/server/commands/TeleportCommand.java
|
||||
+++ b/net/minecraft/server/commands/TeleportCommand.java
|
||||
@@ -283,8 +283,8 @@ public class TeleportCommand {
|
||||
if (true) {
|
||||
ServerLevel worldFinal = level;
|
||||
Vec3 posFinal = new Vec3(x, y, z);
|
||||
- Float yawFinal = Float.valueOf(f);
|
||||
- Float pitchFinal = Float.valueOf(f1);
|
||||
+ Float yawFinal = Float.valueOf(f + target.getYRot());
|
||||
+ Float pitchFinal = Float.valueOf(f1 + target.getXRot());
|
||||
target.getBukkitEntity().taskScheduler.schedule((Entity nmsEntity) -> {
|
||||
nmsEntity.unRide();
|
||||
nmsEntity.teleportAsync(
|
||||
@@ -1,26 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <mrhua269@gmail.com>
|
||||
Date: Thu, 5 Jun 2025 21:11:31 +0800
|
||||
Subject: [PATCH] Fix off region thrown egg new entity creating
|
||||
|
||||
should set pos before so that we could correctly modify the entity's other attribute on-region without triggering the async catchers
|
||||
|
||||
diff --git a/net/minecraft/world/entity/projectile/ThrownEgg.java b/net/minecraft/world/entity/projectile/ThrownEgg.java
|
||||
index 73ec34b43f3fb2aa3edc3f1cb48a923d1fa32036..5760ae39e8c452b8291353ed59ce7f8ef4d43dc1 100644
|
||||
--- a/net/minecraft/world/entity/projectile/ThrownEgg.java
|
||||
+++ b/net/minecraft/world/entity/projectile/ThrownEgg.java
|
||||
@@ -97,12 +97,13 @@ public class ThrownEgg extends ThrowableItemProjectile {
|
||||
for (int i1 = 0; i1 < i; i1++) {
|
||||
net.minecraft.world.entity.Entity chicken = newEntityType.create(this.level(), net.minecraft.world.entity.EntitySpawnReason.TRIGGERED); // CraftBukkit
|
||||
if (chicken != null) {
|
||||
+ chicken.snapTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F); // Luminol - Fix off region thrown egg - move up
|
||||
// CraftBukkit start
|
||||
if (chicken.getBukkitEntity() instanceof org.bukkit.entity.Ageable ageable) {
|
||||
ageable.setBaby();
|
||||
}
|
||||
// CraftBukkit end
|
||||
- chicken.snapTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F);
|
||||
+ // chicken.snapTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F); // Luminol - Fix off region thrown egg - move up
|
||||
// CraftBukkit start
|
||||
if (chicken instanceof Chicken realChicken) {
|
||||
Optional.ofNullable(this.getItem().get(DataComponents.CHICKEN_VARIANT))
|
||||
@@ -18,7 +18,7 @@ index a0b84535a9d3833d4df692b85b272f145559dd80..c2ba46408b5ad727d7a17f21d47b2898
|
||||
return;
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 1091d2747c04166447540b37d86f51fe2591adc8..e0cee79b949fd2a4684bdfe7aa257c2ea96914b0 100644
|
||||
index 7c30289ff28c4f0b91597da9c4aa192e7ff559cc..51543cc35e9158c3c083f4082304ecd4da5cf0a2 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -314,7 +314,7 @@ public final class CraftServer implements Server {
|
||||
@@ -23,7 +23,7 @@ index 631bec0adee5b01bfb931c25195b949eaf2efd27..05d364bcadb137af4e1a8c955643b7dc
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index e0cee79b949fd2a4684bdfe7aa257c2ea96914b0..047369190b8d03c5765595ba898da3a5c463a6c0 100644
|
||||
index 51543cc35e9158c3c083f4082304ecd4da5cf0a2..e86347245b674b552a8d9e5a109ec8a41999f7ee 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -1392,7 +1392,11 @@ public final class CraftServer implements Server {
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Leaves Fix SculkCatalyst exp skip
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
index ee8fcf73665de82fa3968e0998b3221d9088647b..7bb22db40f18be2dbc3ca33a0cb864cf8389ac1e 100644
|
||||
index 77871ce6d0eb0005893ea10b17e711ce87d7bfdd..9c8a4d90974a8cf45a24aca00bf36cebd352b507 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
@@ -851,7 +851,7 @@ public class CraftEventFactory {
|
||||
@@ -1,52 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Suisuroru <qwertyuiop14077@qq.com>
|
||||
Date: Thu, 20 Feb 2025 01:00:29 +0800
|
||||
Subject: [PATCH] Purpur-Barrels-and-enderchests-6-rows
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java
|
||||
index c00ddfe41439954fa0fd87c0933f274c8a752eb6..f60e3896411ff8342639e3f3422d551c84d5871e 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java
|
||||
@@ -150,9 +150,26 @@ public class CraftContainer extends AbstractContainerMenu {
|
||||
case PLAYER:
|
||||
case CHEST:
|
||||
case ENDER_CHEST:
|
||||
- case BARREL:
|
||||
- this.delegate = new ChestMenu(net.minecraft.world.inventory.MenuType.GENERIC_9x3, windowId, bottom, top, top.getContainerSize() / 9);
|
||||
+ // Purpur start - Barrels and enderchests 6 rows
|
||||
+ this.delegate = new ChestMenu(switch (me.earthme.luminol.config.modules.misc.ContainerExpansionConfig.enderchestRows) {
|
||||
+ case 6 -> net.minecraft.world.inventory.MenuType.GENERIC_9x6;
|
||||
+ case 5 -> net.minecraft.world.inventory.MenuType.GENERIC_9x5;
|
||||
+ case 4 -> net.minecraft.world.inventory.MenuType.GENERIC_9x4;
|
||||
+ case 2 -> net.minecraft.world.inventory.MenuType.GENERIC_9x2;
|
||||
+ case 1 -> net.minecraft.world.inventory.MenuType.GENERIC_9x1;
|
||||
+ default -> net.minecraft.world.inventory.MenuType.GENERIC_9x3;
|
||||
+ }, windowId, bottom, top, top.getContainerSize() / 9);
|
||||
break;
|
||||
+ case BARREL:
|
||||
+ this.delegate = new ChestMenu(switch (me.earthme.luminol.config.modules.misc.ContainerExpansionConfig.barrelRows) {
|
||||
+ case 6 -> net.minecraft.world.inventory.MenuType.GENERIC_9x6;
|
||||
+ case 5 -> net.minecraft.world.inventory.MenuType.GENERIC_9x5;
|
||||
+ case 4 -> net.minecraft.world.inventory.MenuType.GENERIC_9x4;
|
||||
+ case 2 -> net.minecraft.world.inventory.MenuType.GENERIC_9x2;
|
||||
+ case 1 -> net.minecraft.world.inventory.MenuType.GENERIC_9x1;
|
||||
+ default -> net.minecraft.world.inventory.MenuType.GENERIC_9x3;
|
||||
+ }, windowId, bottom, top, top.getContainerSize() / 9);
|
||||
+ // Purpur end - Barrels and enderchests 6 rows
|
||||
case DISPENSER:
|
||||
case DROPPER:
|
||||
this.delegate = new DispenserMenu(windowId, bottom, top);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
|
||||
index f850e6cea92edc87ed54cf54488b5ebb606913ed..f4db38de4348fb03db0b769bd5b5993184dd4abb 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
|
||||
@@ -84,7 +84,7 @@ public class CraftInventory implements Inventory {
|
||||
|
||||
@Override
|
||||
public void setContents(ItemStack[] items) {
|
||||
- Preconditions.checkArgument(items.length <= this.getSize(), "Invalid inventory size (%s); expected %s or less", items.length, this.getSize());
|
||||
+ // Preconditions.checkArgument(items.length <= this.getSize(), "Invalid inventory size (%s); expected %s or less", items.length, this.getSize()); // Purpur - Barrels and enderchests 6 rows
|
||||
|
||||
for (int i = 0; i < this.getSize(); i++) {
|
||||
if (i >= items.length) {
|
||||
@@ -1,16 +1,16 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <wangxyper@163.com>
|
||||
Date: Tue, 11 Feb 2025 12:01:39 +0800
|
||||
From: MrHua269 <mrhua269@gmail.com>
|
||||
Date: Thu, 12 Jun 2025 07:59:03 +0800
|
||||
Subject: [PATCH] Purpur Lobotomize stuck villagers
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java
|
||||
index e86f69f75d406b81d9ca32f9cad5e31cb8c55b54..9ca1d60cb7f3e65cdf491bd65c1c0c38cd2c73e8 100644
|
||||
index 2ec652c1675a999d7cf157a5a002aba9d58afa0d..49bfeb81bdc998afc4aa55939840ac75397d8530 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java
|
||||
@@ -381,4 +381,11 @@ public class CraftVillager extends CraftAbstractVillager implements Villager {
|
||||
public void clearReputations() {
|
||||
getHandle().getGossips().gossips.clear();
|
||||
@@ -391,4 +391,11 @@ public class CraftVillager extends CraftAbstractVillager implements Villager {
|
||||
public void restock() {
|
||||
getHandle().restock();
|
||||
}
|
||||
+
|
||||
+ // Purpur start
|
||||
@@ -1,44 +0,0 @@
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/abomination/IRegionFile.java
|
||||
@@ -1,0 +_,41 @@
|
||||
+package abomination;
|
||||
+
|
||||
+import ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemRegionFile;
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
+import net.minecraft.world.level.ChunkPos;
|
||||
+
|
||||
+import java.io.DataInputStream;
|
||||
+import java.io.DataOutputStream;
|
||||
+import java.io.IOException;
|
||||
+import java.nio.ByteBuffer;
|
||||
+import java.nio.file.Path;
|
||||
+
|
||||
+public interface IRegionFile extends ChunkSystemRegionFile, AutoCloseable {
|
||||
+ Path getPath();
|
||||
+
|
||||
+ DataInputStream getChunkDataInputStream(ChunkPos pos) throws IOException;
|
||||
+
|
||||
+ boolean doesChunkExist(ChunkPos pos) throws Exception;
|
||||
+
|
||||
+ DataOutputStream getChunkDataOutputStream(ChunkPos pos) throws IOException;
|
||||
+
|
||||
+ void flush() throws IOException;
|
||||
+
|
||||
+ void clear(ChunkPos pos) throws IOException;
|
||||
+
|
||||
+ boolean hasChunk(ChunkPos pos);
|
||||
+
|
||||
+ void close() throws IOException;
|
||||
+
|
||||
+ void write(ChunkPos pos, ByteBuffer buf) throws IOException;
|
||||
+
|
||||
+ CompoundTag getOversizedData(int x, int z) throws IOException;
|
||||
+
|
||||
+ boolean isOversized(int x, int z);
|
||||
+
|
||||
+ boolean recalculateHeader() throws IOException;
|
||||
+
|
||||
+ void setOversized(int x, int z, boolean oversized) throws IOException;
|
||||
+
|
||||
+ default int getRecalculateCount() {return 0;} // Luminol - Configurable region file format
|
||||
+}
|
||||
@@ -1,625 +0,0 @@
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/abomination/LinearRegionFile.java
|
||||
@@ -1,0 +_,622 @@
|
||||
+package abomination;
|
||||
+
|
||||
+import ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO;
|
||||
+import com.github.luben.zstd.ZstdInputStream;
|
||||
+import com.github.luben.zstd.ZstdOutputStream;
|
||||
+import com.mojang.logging.LogUtils;
|
||||
+import net.jpountz.lz4.LZ4Compressor;
|
||||
+import net.jpountz.lz4.LZ4Factory;
|
||||
+import net.jpountz.lz4.LZ4FastDecompressor;
|
||||
+import net.openhft.hashing.LongHashFunction;
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
+import net.minecraft.world.level.chunk.storage.RegionStorageInfo;
|
||||
+import net.minecraft.world.level.chunk.storage.RegionFileVersion;
|
||||
+import net.minecraft.world.level.ChunkPos;
|
||||
+import org.slf4j.Logger;
|
||||
+
|
||||
+import javax.annotation.Nullable;
|
||||
+import java.io.*;
|
||||
+import java.nio.ByteBuffer;
|
||||
+import java.nio.file.Files;
|
||||
+import java.nio.file.Path;
|
||||
+import java.nio.file.StandardCopyOption;
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.Arrays;
|
||||
+import java.util.List;
|
||||
+import java.util.concurrent.TimeUnit;
|
||||
+import java.util.concurrent.locks.LockSupport;
|
||||
+import java.util.concurrent.locks.ReentrantLock;
|
||||
+
|
||||
+// LinearRegionFile_implementation_version_0_5byXymb
|
||||
+// Just gonna use this string to inform other forks about updates ;-)
|
||||
+public class LinearRegionFile implements IRegionFile{
|
||||
+ private static final long SUPERBLOCK = 0xc3ff13183cca9d9aL;
|
||||
+ private static final byte VERSION = 3;
|
||||
+ private static final int HEADER_SIZE = 27;
|
||||
+ private static final int FOOTER_SIZE = 8;
|
||||
+ private static final Logger LOGGER = LogUtils.getLogger();
|
||||
+
|
||||
+ private byte[][] bucketBuffers;
|
||||
+ private final byte[][] buffer = new byte[1024][];
|
||||
+ private final int[] bufferUncompressedSize = new int[1024];
|
||||
+
|
||||
+ private final long[] chunkTimestamps = new long[1024];
|
||||
+ private final Object markedToSaveLock = new Object();
|
||||
+
|
||||
+ private final LZ4Compressor compressor;
|
||||
+ private final LZ4FastDecompressor decompressor;
|
||||
+
|
||||
+ private boolean markedToSave = false;
|
||||
+ private boolean close = false;
|
||||
+
|
||||
+ public final ReentrantLock fileLock = new ReentrantLock(true);
|
||||
+ public Path regionFile;
|
||||
+
|
||||
+ private final int compressionLevel;
|
||||
+ private int gridSize = 8;
|
||||
+ private int bucketSize = 4;
|
||||
+ private final Thread bindThread;
|
||||
+
|
||||
+ public Path getRegionFile() {
|
||||
+ return this.regionFile;
|
||||
+ }
|
||||
+
|
||||
+ public ReentrantLock getFileLock() {
|
||||
+ return this.fileLock;
|
||||
+ }
|
||||
+
|
||||
+ private int chunkToBucketIdx(int chunkX, int chunkZ) {
|
||||
+ int bx = chunkX / bucketSize, bz = chunkZ / bucketSize;
|
||||
+ return bx * gridSize + bz;
|
||||
+ }
|
||||
+
|
||||
+ private void openBucket(int chunkX, int chunkZ) {
|
||||
+ chunkX = Math.floorMod(chunkX, 32);
|
||||
+ chunkZ = Math.floorMod(chunkZ, 32);
|
||||
+ int idx = chunkToBucketIdx(chunkX, chunkZ);
|
||||
+
|
||||
+ if (bucketBuffers == null) return;
|
||||
+ if (bucketBuffers[idx] != null) {
|
||||
+ try {
|
||||
+ ByteArrayInputStream bucketByteStream = new ByteArrayInputStream(bucketBuffers[idx]);
|
||||
+ ZstdInputStream zstdStream = new ZstdInputStream(bucketByteStream);
|
||||
+ ByteBuffer bucketBuffer = ByteBuffer.wrap(zstdStream.readAllBytes());
|
||||
+
|
||||
+ int bx = chunkX / bucketSize, bz = chunkZ / bucketSize;
|
||||
+
|
||||
+ for (int cx = 0; cx < 32 / gridSize; cx++) {
|
||||
+ for (int cz = 0; cz < 32 / gridSize; cz++) {
|
||||
+ int chunkIndex = (bx * (32 / gridSize) + cx) + (bz * (32 / gridSize) + cz) * 32;
|
||||
+
|
||||
+ int chunkSize = bucketBuffer.getInt();
|
||||
+ long timestamp = bucketBuffer.getLong();
|
||||
+ this.chunkTimestamps[chunkIndex] = timestamp;
|
||||
+
|
||||
+ if (chunkSize > 0) {
|
||||
+ byte[] chunkData = new byte[chunkSize - 8];
|
||||
+ bucketBuffer.get(chunkData);
|
||||
+
|
||||
+ int maxCompressedLength = this.compressor.maxCompressedLength(chunkData.length);
|
||||
+ byte[] compressed = new byte[maxCompressedLength];
|
||||
+ int compressedLength = this.compressor.compress(chunkData, 0, chunkData.length, compressed, 0, maxCompressedLength);
|
||||
+ byte[] finalCompressed = new byte[compressedLength];
|
||||
+ System.arraycopy(compressed, 0, finalCompressed, 0, compressedLength);
|
||||
+
|
||||
+ // TODO: Optimization - return the requested chunk immediately to save on one LZ4 decompression
|
||||
+ this.buffer[chunkIndex] = finalCompressed;
|
||||
+ this.bufferUncompressedSize[chunkIndex] = chunkData.length;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ } catch (IOException ex) {
|
||||
+ throw new RuntimeException("Region file corrupted: " + regionFile + " bucket: " + idx);
|
||||
+ // TODO: Make sure the server crashes instead of corrupting the world
|
||||
+ }
|
||||
+ bucketBuffers[idx] = null;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public boolean regionFileOpen = false;
|
||||
+
|
||||
+ private synchronized void openRegionFile() {
|
||||
+ if (regionFileOpen) return;
|
||||
+ regionFileOpen = true;
|
||||
+
|
||||
+ File regionFile = new File(this.regionFile.toString());
|
||||
+
|
||||
+ if(!regionFile.canRead()) {
|
||||
+ this.bindThread.start();
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ try {
|
||||
+ byte[] fileContent = Files.readAllBytes(this.regionFile);
|
||||
+ ByteBuffer buffer = ByteBuffer.wrap(fileContent);
|
||||
+
|
||||
+ long superBlock = buffer.getLong();
|
||||
+ if (superBlock != SUPERBLOCK)
|
||||
+ throw new RuntimeException("Invalid superblock: " + superBlock + " file " + this.regionFile);
|
||||
+
|
||||
+ byte version = buffer.get();
|
||||
+ if (version == 1 || version == 2) {
|
||||
+ parseLinearV1(buffer);
|
||||
+ } else if (version == 3) {
|
||||
+ parseLinearV2(buffer);
|
||||
+ } else {
|
||||
+ throw new RuntimeException("Invalid version: " + version + " file " + this.regionFile);
|
||||
+ }
|
||||
+
|
||||
+ this.bindThread.start();
|
||||
+ } catch (IOException e) {
|
||||
+ throw new RuntimeException("Failed to open region file " + this.regionFile, e);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private void parseLinearV1(ByteBuffer buffer) throws IOException {
|
||||
+ final int HEADER_SIZE = 32;
|
||||
+ final int FOOTER_SIZE = 8;
|
||||
+
|
||||
+ // Skip newestTimestamp (Long) + Compression level (Byte) + Chunk count (Short): Unused.
|
||||
+ buffer.position(buffer.position() + 11);
|
||||
+
|
||||
+ int dataCount = buffer.getInt();
|
||||
+ long fileLength = this.regionFile.toFile().length();
|
||||
+ if (fileLength != HEADER_SIZE + dataCount + FOOTER_SIZE) {
|
||||
+ throw new IOException("Invalid file length: " + this.regionFile + " " + fileLength + " " + (HEADER_SIZE + dataCount + FOOTER_SIZE));
|
||||
+ }
|
||||
+
|
||||
+ buffer.position(buffer.position() + 8); // Skip data hash (Long): Unused.
|
||||
+
|
||||
+ byte[] rawCompressed = new byte[dataCount];
|
||||
+ buffer.get(rawCompressed);
|
||||
+
|
||||
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(rawCompressed);
|
||||
+ ZstdInputStream zstdInputStream = new ZstdInputStream(byteArrayInputStream);
|
||||
+ ByteBuffer decompressedBuffer = ByteBuffer.wrap(zstdInputStream.readAllBytes());
|
||||
+
|
||||
+ int[] starts = new int[1024];
|
||||
+ for (int i = 0; i < 1024; i++) {
|
||||
+ starts[i] = decompressedBuffer.getInt();
|
||||
+ decompressedBuffer.getInt(); // Skip timestamps (Int): Unused.
|
||||
+ }
|
||||
+
|
||||
+ for (int i = 0; i < 1024; i++) {
|
||||
+ if (starts[i] > 0) {
|
||||
+ int size = starts[i];
|
||||
+ byte[] chunkData = new byte[size];
|
||||
+ decompressedBuffer.get(chunkData);
|
||||
+
|
||||
+ int maxCompressedLength = this.compressor.maxCompressedLength(size);
|
||||
+ byte[] compressed = new byte[maxCompressedLength];
|
||||
+ int compressedLength = this.compressor.compress(chunkData, 0, size, compressed, 0, maxCompressedLength);
|
||||
+ byte[] finalCompressed = new byte[compressedLength];
|
||||
+ System.arraycopy(compressed, 0, finalCompressed, 0, compressedLength);
|
||||
+
|
||||
+ this.buffer[i] = finalCompressed;
|
||||
+ this.bufferUncompressedSize[i] = size;
|
||||
+ this.chunkTimestamps[i] = getTimestamp(); // Use current timestamp as we don't have the original
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private void parseLinearV2(ByteBuffer buffer) throws IOException {
|
||||
+ buffer.getLong(); // Skip newestTimestamp (Long)
|
||||
+ gridSize = buffer.get();
|
||||
+ if (gridSize != 1 && gridSize != 2 && gridSize != 4 && gridSize != 8 && gridSize != 16 && gridSize != 32)
|
||||
+ throw new RuntimeException("Invalid grid size: " + gridSize + " file " + this.regionFile);
|
||||
+ bucketSize = 32 / gridSize;
|
||||
+
|
||||
+ buffer.getInt(); // Skip region_x (Int)
|
||||
+ buffer.getInt(); // Skip region_z (Int)
|
||||
+
|
||||
+ boolean[] chunkExistenceBitmap = deserializeExistenceBitmap(buffer);
|
||||
+
|
||||
+ while (true) {
|
||||
+ byte featureNameLength = buffer.get();
|
||||
+ if (featureNameLength == 0) break;
|
||||
+ byte[] featureNameBytes = new byte[featureNameLength];
|
||||
+ buffer.get(featureNameBytes);
|
||||
+ String featureName = new String(featureNameBytes);
|
||||
+ int featureValue = buffer.getInt();
|
||||
+ // System.out.println("NBT Feature: " + featureName + " = " + featureValue);
|
||||
+ }
|
||||
+
|
||||
+ int[] bucketSizes = new int[gridSize * gridSize];
|
||||
+ byte[] bucketCompressionLevels = new byte[gridSize * gridSize];
|
||||
+ long[] bucketHashes = new long[gridSize * gridSize];
|
||||
+ for (int i = 0; i < gridSize * gridSize; i++) {
|
||||
+ bucketSizes[i] = buffer.getInt();
|
||||
+ bucketCompressionLevels[i] = buffer.get();
|
||||
+ bucketHashes[i] = buffer.getLong();
|
||||
+ }
|
||||
+
|
||||
+ bucketBuffers = new byte[gridSize * gridSize][];
|
||||
+ for (int i = 0; i < gridSize * gridSize; i++) {
|
||||
+ if (bucketSizes[i] > 0) {
|
||||
+ bucketBuffers[i] = new byte[bucketSizes[i]];
|
||||
+ buffer.get(bucketBuffers[i]);
|
||||
+ long rawHash = LongHashFunction.xx().hashBytes(bucketBuffers[i]);
|
||||
+ if (rawHash != bucketHashes[i]) throw new IOException("Region file hash incorrect " + this.regionFile);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ long footerSuperBlock = buffer.getLong();
|
||||
+ if (footerSuperBlock != SUPERBLOCK)
|
||||
+ throw new IOException("Footer superblock invalid " + this.regionFile);
|
||||
+ }
|
||||
+
|
||||
+ public LinearRegionFile(RegionStorageInfo storageKey, Path directory, Path path, boolean dsync, int compressionLevel) throws IOException {
|
||||
+ this(storageKey, directory, path, RegionFileVersion.getCompressionFormat(), dsync, compressionLevel);
|
||||
+ }
|
||||
+
|
||||
+ public LinearRegionFile(RegionStorageInfo storageKey, Path path, Path directory, RegionFileVersion compressionFormat, boolean dsync, int compressionLevel) throws IOException {
|
||||
+ Runnable flushCheck = () -> {
|
||||
+ while (!close) {
|
||||
+ synchronized (saveLock) {
|
||||
+ if (markedToSave && activeSaveThreads < SAVE_THREAD_MAX_COUNT) {
|
||||
+ activeSaveThreads++;
|
||||
+ Runnable flushOperation = () -> {
|
||||
+ try {
|
||||
+ flush();
|
||||
+ } catch (IOException ex) {
|
||||
+ LOGGER.error("Region file {} flush failed", this.regionFile.toAbsolutePath(), ex);
|
||||
+ } finally {
|
||||
+ synchronized (saveLock) {
|
||||
+ activeSaveThreads--;
|
||||
+ }
|
||||
+ }
|
||||
+ };
|
||||
+
|
||||
+ Thread saveThread = USE_VIRTUAL_THREAD ?
|
||||
+ Thread.ofVirtual().name("Linear IO - " + LinearRegionFile.this.hashCode()).unstarted(flushOperation) :
|
||||
+ Thread.ofPlatform().name("Linear IO - " + LinearRegionFile.this.hashCode()).unstarted(flushOperation);
|
||||
+ saveThread.setPriority(Thread.NORM_PRIORITY - 3);
|
||||
+ saveThread.start();
|
||||
+ }
|
||||
+ }
|
||||
+ LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(SAVE_DELAY_MS));
|
||||
+ }
|
||||
+ };
|
||||
+ this.bindThread = USE_VIRTUAL_THREAD ? Thread.ofVirtual().unstarted(flushCheck) : Thread.ofPlatform().unstarted(flushCheck);
|
||||
+ this.bindThread.setName("Linear IO Schedule - " + this.hashCode());
|
||||
+ this.regionFile = path;
|
||||
+ this.compressionLevel = compressionLevel;
|
||||
+
|
||||
+ this.compressor = LZ4Factory.fastestInstance().fastCompressor();
|
||||
+ this.decompressor = LZ4Factory.fastestInstance().fastDecompressor();
|
||||
+ }
|
||||
+
|
||||
+ private synchronized void markToSave() {
|
||||
+ synchronized(markedToSaveLock) {
|
||||
+ markedToSave = true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private synchronized boolean isMarkedToSave() {
|
||||
+ synchronized(markedToSaveLock) {
|
||||
+ if(markedToSave) {
|
||||
+ markedToSave = false;
|
||||
+ return true;
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static int SAVE_THREAD_MAX_COUNT = 6;
|
||||
+ public static int SAVE_DELAY_MS = 100;
|
||||
+ public static boolean USE_VIRTUAL_THREAD = true;
|
||||
+ private static final Object saveLock = new Object();
|
||||
+ private static int activeSaveThreads = 0;
|
||||
+
|
||||
+ /*public void run() {
|
||||
+ while (!close) {
|
||||
+ synchronized (saveLock) {
|
||||
+ if (markedToSave && activeSaveThreads < SAVE_THREAD_MAX_COUNT) {
|
||||
+ activeSaveThreads++;
|
||||
+ Thread saveThread = new Thread(() -> {
|
||||
+ try {
|
||||
+ flush();
|
||||
+ } catch (IOException ex) {
|
||||
+ LOGGER.error("Region file " + this.regionFile.toAbsolutePath() + " flush failed", ex);
|
||||
+ } finally {
|
||||
+ synchronized (saveLock) {
|
||||
+ activeSaveThreads--;
|
||||
+ }
|
||||
+ }
|
||||
+ }, "RegionFileFlush");
|
||||
+ saveThread.setPriority(Thread.NORM_PRIORITY - 3);
|
||||
+ saveThread.start();
|
||||
+ }
|
||||
+ }
|
||||
+ LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(SAVE_DELAY_MS));
|
||||
+ }
|
||||
+ }*/
|
||||
+
|
||||
+ public synchronized boolean doesChunkExist(ChunkPos pos) throws Exception {
|
||||
+ openRegionFile();
|
||||
+ throw new Exception("doesChunkExist is a stub");
|
||||
+ }
|
||||
+
|
||||
+ public synchronized void flush() throws IOException {
|
||||
+ if(!isMarkedToSave()) return;
|
||||
+
|
||||
+ openRegionFile();
|
||||
+
|
||||
+ long timestamp = getTimestamp();
|
||||
+
|
||||
+long writeStart = System.nanoTime();
|
||||
+ File tempFile = new File(regionFile.toString() + ".tmp");
|
||||
+ FileOutputStream fileStream = new FileOutputStream(tempFile);
|
||||
+ DataOutputStream dataStream = new DataOutputStream(fileStream);
|
||||
+
|
||||
+ dataStream.writeLong(SUPERBLOCK);
|
||||
+ dataStream.writeByte(VERSION);
|
||||
+ dataStream.writeLong(timestamp);
|
||||
+ dataStream.writeByte(gridSize);
|
||||
+
|
||||
+ String fileName = regionFile.getFileName().toString();
|
||||
+ String[] parts = fileName.split("\\.");
|
||||
+ int regionX = 0;
|
||||
+ int regionZ = 0;
|
||||
+ try {
|
||||
+ if (parts.length >= 4) {
|
||||
+ regionX = Integer.parseInt(parts[1]);
|
||||
+ regionZ = Integer.parseInt(parts[2]);
|
||||
+ } else {
|
||||
+ LOGGER.warn("Unexpected file name format: " + fileName);
|
||||
+ }
|
||||
+ } catch (NumberFormatException e) {
|
||||
+ LOGGER.error("Failed to parse region coordinates from file name: " + fileName, e);
|
||||
+ }
|
||||
+
|
||||
+ dataStream.writeInt(regionX);
|
||||
+ dataStream.writeInt(regionZ);
|
||||
+
|
||||
+ boolean[] chunkExistenceBitmap = new boolean[1024];
|
||||
+ for (int i = 0; i < 1024; i++) {
|
||||
+ chunkExistenceBitmap[i] = (this.bufferUncompressedSize[i] > 0);
|
||||
+ }
|
||||
+ writeSerializedExistenceBitmap(dataStream, chunkExistenceBitmap);
|
||||
+
|
||||
+ writeNBTFeatures(dataStream);
|
||||
+
|
||||
+ int bucketMisses = 0;
|
||||
+ byte[][] buckets = new byte[gridSize * gridSize][];
|
||||
+ for (int bx = 0; bx < gridSize; bx++) {
|
||||
+ for (int bz = 0; bz < gridSize; bz++) {
|
||||
+ if (bucketBuffers != null && bucketBuffers[bx * gridSize + bz] != null) {
|
||||
+ buckets[bx * gridSize + bz] = bucketBuffers[bx * gridSize + bz];
|
||||
+ continue;
|
||||
+ }
|
||||
+ bucketMisses++;
|
||||
+
|
||||
+ ByteArrayOutputStream bucketStream = new ByteArrayOutputStream();
|
||||
+ ZstdOutputStream zstdStream = new ZstdOutputStream(bucketStream, this.compressionLevel);
|
||||
+ DataOutputStream bucketDataStream = new DataOutputStream(zstdStream);
|
||||
+
|
||||
+ boolean hasData = false;
|
||||
+ for (int cx = 0; cx < 32 / gridSize; cx++) {
|
||||
+ for (int cz = 0; cz < 32 / gridSize; cz++) {
|
||||
+ int chunkIndex = (bx * 32 / gridSize + cx) + (bz * 32 / gridSize + cz) * 32;
|
||||
+ if (this.bufferUncompressedSize[chunkIndex] > 0) {
|
||||
+ hasData = true;
|
||||
+ byte[] chunkData = new byte[this.bufferUncompressedSize[chunkIndex]];
|
||||
+ this.decompressor.decompress(this.buffer[chunkIndex], 0, chunkData, 0, this.bufferUncompressedSize[chunkIndex]);
|
||||
+ bucketDataStream.writeInt(chunkData.length + 8);
|
||||
+ bucketDataStream.writeLong(this.chunkTimestamps[chunkIndex]);
|
||||
+ bucketDataStream.write(chunkData);
|
||||
+ } else {
|
||||
+ bucketDataStream.writeInt(0);
|
||||
+ bucketDataStream.writeLong(this.chunkTimestamps[chunkIndex]);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ bucketDataStream.close();
|
||||
+
|
||||
+ if (hasData) {
|
||||
+ buckets[bx * gridSize + bz] = bucketStream.toByteArray();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ for (int i = 0; i < gridSize * gridSize; i++) {
|
||||
+ dataStream.writeInt(buckets[i] != null ? buckets[i].length : 0);
|
||||
+ dataStream.writeByte(this.compressionLevel);
|
||||
+ long rawHash = 0;
|
||||
+ if (buckets[i] != null) {
|
||||
+ rawHash = LongHashFunction.xx().hashBytes(buckets[i]);
|
||||
+ }
|
||||
+ dataStream.writeLong(rawHash);
|
||||
+ }
|
||||
+
|
||||
+ for (int i = 0; i < gridSize * gridSize; i++) {
|
||||
+ if (buckets[i] != null) {
|
||||
+ dataStream.write(buckets[i]);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ dataStream.writeLong(SUPERBLOCK);
|
||||
+
|
||||
+ dataStream.flush();
|
||||
+ fileStream.getFD().sync();
|
||||
+ fileStream.getChannel().force(true); // Ensure atomicity on Btrfs
|
||||
+ dataStream.close();
|
||||
+
|
||||
+ fileStream.close();
|
||||
+ Files.move(tempFile.toPath(), this.regionFile, StandardCopyOption.REPLACE_EXISTING);
|
||||
+//System.out.println("writeStart REGION FILE FLUSH " + (System.nanoTime() - writeStart) + " misses: " + bucketMisses);
|
||||
+ }
|
||||
+
|
||||
+ private void writeNBTFeatures(DataOutputStream dataStream) throws IOException {
|
||||
+ // writeNBTFeature(dataStream, "example", 1);
|
||||
+ dataStream.writeByte(0); // End of NBT features
|
||||
+ }
|
||||
+
|
||||
+ private void writeNBTFeature(DataOutputStream dataStream, String featureName, int featureValue) throws IOException {
|
||||
+ byte[] featureNameBytes = featureName.getBytes();
|
||||
+ dataStream.writeByte(featureNameBytes.length);
|
||||
+ dataStream.write(featureNameBytes);
|
||||
+ dataStream.writeInt(featureValue);
|
||||
+ }
|
||||
+
|
||||
+ public static final int MAX_CHUNK_SIZE = 500 * 1024 * 1024; // Abomination - prevent chunk dupe
|
||||
+
|
||||
+ public synchronized void write(ChunkPos pos, ByteBuffer buffer) {
|
||||
+ openRegionFile();
|
||||
+ openBucket(pos.x, pos.z);
|
||||
+ try {
|
||||
+ byte[] b = toByteArray(new ByteArrayInputStream(buffer.array()));
|
||||
+ int uncompressedSize = b.length;
|
||||
+
|
||||
+ if (uncompressedSize > MAX_CHUNK_SIZE) {
|
||||
+ LOGGER.error("Chunk dupe attempt " + this.regionFile);
|
||||
+ clear(pos);
|
||||
+ } else {
|
||||
+ int maxCompressedLength = this.compressor.maxCompressedLength(b.length);
|
||||
+ byte[] compressed = new byte[maxCompressedLength];
|
||||
+ int compressedLength = this.compressor.compress(b, 0, b.length, compressed, 0, maxCompressedLength);
|
||||
+ b = new byte[compressedLength];
|
||||
+ System.arraycopy(compressed, 0, b, 0, compressedLength);
|
||||
+
|
||||
+ int index = getChunkIndex(pos.x, pos.z);
|
||||
+ this.buffer[index] = b;
|
||||
+ this.chunkTimestamps[index] = getTimestamp();
|
||||
+ this.bufferUncompressedSize[getChunkIndex(pos.x, pos.z)] = uncompressedSize;
|
||||
+ }
|
||||
+ } catch (IOException e) {
|
||||
+ LOGGER.error("Chunk write IOException " + e + " " + this.regionFile);
|
||||
+ }
|
||||
+ markToSave();
|
||||
+ }
|
||||
+
|
||||
+ public DataOutputStream getChunkDataOutputStream(ChunkPos pos) {
|
||||
+ openRegionFile();
|
||||
+ openBucket(pos.x, pos.z);
|
||||
+ return new DataOutputStream(new BufferedOutputStream(new LinearRegionFile.ChunkBuffer(pos)));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public MoonriseRegionFileIO.RegionDataController.WriteData moonrise$startWrite(CompoundTag data, ChunkPos pos) throws IOException {
|
||||
+ final DataOutputStream out = this.getChunkDataOutputStream(pos);
|
||||
+
|
||||
+ return new ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionDataController.WriteData(
|
||||
+ data, ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionDataController.WriteData.WriteResult.WRITE,
|
||||
+ out, regionFile -> out.close()
|
||||
+ );
|
||||
+ }
|
||||
+
|
||||
+ private class ChunkBuffer extends ByteArrayOutputStream {
|
||||
+
|
||||
+ private final ChunkPos pos;
|
||||
+
|
||||
+ public ChunkBuffer(ChunkPos chunkcoordintpair) {
|
||||
+ super();
|
||||
+ this.pos = chunkcoordintpair;
|
||||
+ }
|
||||
+
|
||||
+ public void close() throws IOException {
|
||||
+ ByteBuffer bytebuffer = ByteBuffer.wrap(this.buf, 0, this.count);
|
||||
+ LinearRegionFile.this.write(this.pos, bytebuffer);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private byte[] toByteArray(InputStream in) throws IOException {
|
||||
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
+ byte[] tempBuffer = new byte[4096];
|
||||
+
|
||||
+ int length;
|
||||
+ while ((length = in.read(tempBuffer)) >= 0) {
|
||||
+ out.write(tempBuffer, 0, length);
|
||||
+ }
|
||||
+
|
||||
+ return out.toByteArray();
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ public synchronized DataInputStream getChunkDataInputStream(ChunkPos pos) {
|
||||
+ openRegionFile();
|
||||
+ openBucket(pos.x, pos.z);
|
||||
+
|
||||
+ if(this.bufferUncompressedSize[getChunkIndex(pos.x, pos.z)] != 0) {
|
||||
+ byte[] content = new byte[bufferUncompressedSize[getChunkIndex(pos.x, pos.z)]];
|
||||
+ this.decompressor.decompress(this.buffer[getChunkIndex(pos.x, pos.z)], 0, content, 0, bufferUncompressedSize[getChunkIndex(pos.x, pos.z)]);
|
||||
+ return new DataInputStream(new ByteArrayInputStream(content));
|
||||
+ }
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ public synchronized void clear(ChunkPos pos) {
|
||||
+ openRegionFile();
|
||||
+ openBucket(pos.x, pos.z);
|
||||
+ int i = getChunkIndex(pos.x, pos.z);
|
||||
+ this.buffer[i] = null;
|
||||
+ this.bufferUncompressedSize[i] = 0;
|
||||
+ this.chunkTimestamps[i] = 0;
|
||||
+ markToSave();
|
||||
+ }
|
||||
+
|
||||
+ public synchronized boolean hasChunk(ChunkPos pos) {
|
||||
+ openRegionFile();
|
||||
+ openBucket(pos.x, pos.z);
|
||||
+ return this.bufferUncompressedSize[getChunkIndex(pos.x, pos.z)] > 0;
|
||||
+ }
|
||||
+
|
||||
+ public synchronized void close() throws IOException {
|
||||
+ openRegionFile();
|
||||
+ close = true;
|
||||
+ try {
|
||||
+ flush();
|
||||
+ } catch(IOException e) {
|
||||
+ throw new IOException("Region flush IOException " + e + " " + this.regionFile);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static int getChunkIndex(int x, int z) {
|
||||
+ return (x & 31) + ((z & 31) << 5);
|
||||
+ }
|
||||
+
|
||||
+ private static int getTimestamp() {
|
||||
+ return (int) (System.currentTimeMillis() / 1000L);
|
||||
+ }
|
||||
+
|
||||
+ public boolean recalculateHeader() {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ public void setOversized(int x, int z, boolean something) {}
|
||||
+
|
||||
+ public CompoundTag getOversizedData(int x, int z) throws IOException {
|
||||
+ throw new IOException("getOversizedData is a stub " + this.regionFile);
|
||||
+ }
|
||||
+
|
||||
+ public boolean isOversized(int x, int z) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ public Path getPath() {
|
||||
+ return this.regionFile;
|
||||
+ }
|
||||
+
|
||||
+ private boolean[] deserializeExistenceBitmap(ByteBuffer buffer) {
|
||||
+ boolean[] result = new boolean[1024];
|
||||
+ for (int i = 0; i < 128; i++) {
|
||||
+ byte b = buffer.get();
|
||||
+ for (int j = 0; j < 8; j++) {
|
||||
+ result[i * 8 + j] = ((b >> (7 - j)) & 1) == 1;
|
||||
+ }
|
||||
+ }
|
||||
+ return result;
|
||||
+ }
|
||||
+
|
||||
+ private void writeSerializedExistenceBitmap(DataOutputStream out, boolean[] bitmap) throws IOException {
|
||||
+ for (int i = 0; i < 128; i++) {
|
||||
+ byte b = 0;
|
||||
+ for (int j = 0; j < 8; j++) {
|
||||
+ if (bitmap[i * 8 + j]) {
|
||||
+ b |= (1 << (7 - j));
|
||||
+ }
|
||||
+ }
|
||||
+ out.writeByte(b);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
@@ -1,93 +0,0 @@
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/kiocg/ChunkHot.java
|
||||
@@ -1,0 +_,90 @@
|
||||
+package com.kiocg;
|
||||
+
|
||||
+import java.util.Arrays;
|
||||
+
|
||||
+public class ChunkHot {
|
||||
+ // 热度统计总区间数量
|
||||
+ private static final int TIMES_LENGTH = 10;
|
||||
+ // 当前统计区间下标
|
||||
+ private int index = -1;
|
||||
+
|
||||
+ // 热度统计区间
|
||||
+ private final long[] times = new long[TIMES_LENGTH];
|
||||
+ // 存放临时的区间数值
|
||||
+ // 用于修正正在统计的当前区间热度没有计入总值的问题
|
||||
+ private long temp;
|
||||
+ // 所有区间的热度总值
|
||||
+ private long total;
|
||||
+
|
||||
+ // 用于每个具体统计的计算
|
||||
+ private long nanos;
|
||||
+ // 当前统计是否进行中
|
||||
+ private volatile boolean started = false;
|
||||
+
|
||||
+ /**
|
||||
+ * 更新区间下标
|
||||
+ */
|
||||
+ public void nextTick() {
|
||||
+ this.index = ++this.index % TIMES_LENGTH;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * 开始统计一个新区间
|
||||
+ */
|
||||
+ public void start() {
|
||||
+ started = true;
|
||||
+ temp = times[this.index];
|
||||
+ times[this.index] = 0L;
|
||||
+ }
|
||||
+
|
||||
+ public boolean isStarted(){
|
||||
+ return this.started;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * 结束当前区间的统计
|
||||
+ * 将统计值更新入热度总值
|
||||
+ */
|
||||
+ public void stop() {
|
||||
+ started = false;
|
||||
+ total -= temp;
|
||||
+ total += times[this.index];
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * 开始一个具体统计
|
||||
+ */
|
||||
+ public void startTicking() {
|
||||
+ if (!started) return;
|
||||
+ nanos = System.nanoTime();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * 结束一个具体统计
|
||||
+ * 将统计值计入当前热度区间
|
||||
+ */
|
||||
+ public void stopTickingAndCount() {
|
||||
+ if (!started) return;
|
||||
+ // 定义一个具体统计的最大值为 1,000,000
|
||||
+ // 有时候某个具体统计的计算值会在某1刻飙升,可能是由于保存数据到磁盘?
|
||||
+ times[this.index] += Math.min(System.nanoTime() - nanos, 1000000L);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * 清空统计 (当区块卸载时)
|
||||
+ */
|
||||
+ public void clear() {
|
||||
+ started = false;
|
||||
+ Arrays.fill(times, 0L);
|
||||
+ temp = 0L;
|
||||
+ total = 0L;
|
||||
+ nanos = 0L;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * @return 获取区块热度平均值
|
||||
+ */
|
||||
+ public long getAverage() {
|
||||
+ return total / ((long) TIMES_LENGTH * 20L);
|
||||
+ }
|
||||
+}
|
||||
@@ -1,37 +0,0 @@
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/logisticscraft/occlusionculling/DataProvider.java
|
||||
@@ -1,0 +_,34 @@
|
||||
+package com.logisticscraft.occlusionculling;
|
||||
+
|
||||
+import com.logisticscraft.occlusionculling.util.Vec3d;
|
||||
+
|
||||
+public interface DataProvider {
|
||||
+
|
||||
+ /**
|
||||
+ * Prepares the requested chunk. Returns true if the chunk is ready, false when
|
||||
+ * not loaded. Should not reload the chunk when the x and y are the same as the
|
||||
+ * last request!
|
||||
+ *
|
||||
+ * @param chunkX
|
||||
+ * @param chunkZ
|
||||
+ * @return
|
||||
+ */
|
||||
+ boolean prepareChunk(int chunkX, int chunkZ);
|
||||
+
|
||||
+ /**
|
||||
+ * Location is inside the chunk.
|
||||
+ *
|
||||
+ * @param x
|
||||
+ * @param y
|
||||
+ * @param z
|
||||
+ * @return
|
||||
+ */
|
||||
+ boolean isOpaqueFullCube(int x, int y, int z);
|
||||
+
|
||||
+ default void cleanup() {
|
||||
+ }
|
||||
+
|
||||
+ default void checkingPosition(Vec3d[] targetPoints, int size, Vec3d viewerPosition) {
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
@@ -1,518 +0,0 @@
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/logisticscraft/occlusionculling/OcclusionCullingInstance.java
|
||||
@@ -1,0 +_,515 @@
|
||||
+package com.logisticscraft.occlusionculling;
|
||||
+
|
||||
+import java.util.Arrays;
|
||||
+import java.util.BitSet;
|
||||
+
|
||||
+import com.logisticscraft.occlusionculling.cache.ArrayOcclusionCache;
|
||||
+import com.logisticscraft.occlusionculling.cache.OcclusionCache;
|
||||
+import com.logisticscraft.occlusionculling.util.MathUtilities;
|
||||
+import com.logisticscraft.occlusionculling.util.Vec3d;
|
||||
+
|
||||
+public class OcclusionCullingInstance {
|
||||
+
|
||||
+ private static final int ON_MIN_X = 0x01;
|
||||
+ private static final int ON_MAX_X = 0x02;
|
||||
+ private static final int ON_MIN_Y = 0x04;
|
||||
+ private static final int ON_MAX_Y = 0x08;
|
||||
+ private static final int ON_MIN_Z = 0x10;
|
||||
+ private static final int ON_MAX_Z = 0x20;
|
||||
+
|
||||
+ private final int reach;
|
||||
+ private final double aabbExpansion;
|
||||
+ private final DataProvider provider;
|
||||
+ private final OcclusionCache cache;
|
||||
+
|
||||
+ // Reused allocated data structures
|
||||
+ private final BitSet skipList = new BitSet(); // Grows bigger in case some mod introduces giant hitboxes
|
||||
+ private final Vec3d[] targetPoints = new Vec3d[15];
|
||||
+ private final Vec3d targetPos = new Vec3d(0, 0, 0);
|
||||
+ private final int[] cameraPos = new int[3];
|
||||
+ private final boolean[] dotselectors = new boolean[14];
|
||||
+ private boolean allowRayChecks = false;
|
||||
+ private final int[] lastHitBlock = new int[3];
|
||||
+ private boolean allowWallClipping = false;
|
||||
+
|
||||
+
|
||||
+ public OcclusionCullingInstance(int maxDistance, DataProvider provider) {
|
||||
+ this(maxDistance, provider, new ArrayOcclusionCache(maxDistance), 0.5);
|
||||
+ }
|
||||
+
|
||||
+ public OcclusionCullingInstance(int maxDistance, DataProvider provider, OcclusionCache cache, double aabbExpansion) {
|
||||
+ this.reach = maxDistance;
|
||||
+ this.provider = provider;
|
||||
+ this.cache = cache;
|
||||
+ this.aabbExpansion = aabbExpansion;
|
||||
+ for(int i = 0; i < targetPoints.length; i++) {
|
||||
+ targetPoints[i] = new Vec3d(0, 0, 0);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public boolean isAABBVisible(Vec3d aabbMin, Vec3d aabbMax, Vec3d viewerPosition) {
|
||||
+ try {
|
||||
+ int maxX = MathUtilities.floor(aabbMax.x
|
||||
+ + aabbExpansion);
|
||||
+ int maxY = MathUtilities.floor(aabbMax.y
|
||||
+ + aabbExpansion);
|
||||
+ int maxZ = MathUtilities.floor(aabbMax.z
|
||||
+ + aabbExpansion);
|
||||
+ int minX = MathUtilities.floor(aabbMin.x
|
||||
+ - aabbExpansion);
|
||||
+ int minY = MathUtilities.floor(aabbMin.y
|
||||
+ - aabbExpansion);
|
||||
+ int minZ = MathUtilities.floor(aabbMin.z
|
||||
+ - aabbExpansion);
|
||||
+
|
||||
+ cameraPos[0] = MathUtilities.floor(viewerPosition.x);
|
||||
+ cameraPos[1] = MathUtilities.floor(viewerPosition.y);
|
||||
+ cameraPos[2] = MathUtilities.floor(viewerPosition.z);
|
||||
+
|
||||
+ Relative relX = Relative.from(minX, maxX, cameraPos[0]);
|
||||
+ Relative relY = Relative.from(minY, maxY, cameraPos[1]);
|
||||
+ Relative relZ = Relative.from(minZ, maxZ, cameraPos[2]);
|
||||
+
|
||||
+ if(relX == Relative.INSIDE && relY == Relative.INSIDE && relZ == Relative.INSIDE) {
|
||||
+ return true; // We are inside of the AABB, don't cull
|
||||
+ }
|
||||
+
|
||||
+ skipList.clear();
|
||||
+
|
||||
+ // Just check the cache first
|
||||
+ int id = 0;
|
||||
+ for (int x = minX; x <= maxX; x++) {
|
||||
+ for (int y = minY; y <= maxY; y++) {
|
||||
+ for (int z = minZ; z <= maxZ; z++) {
|
||||
+ int cachedValue = getCacheValue(x, y, z);
|
||||
+
|
||||
+ if (cachedValue == 1) {
|
||||
+ // non-occluding
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ if (cachedValue != 0) {
|
||||
+ // was checked and it wasn't visible
|
||||
+ skipList.set(id);
|
||||
+ }
|
||||
+ id++;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // only after the first hit wall the cache becomes valid.
|
||||
+ allowRayChecks = false;
|
||||
+
|
||||
+ // since the cache wasn't helpfull
|
||||
+ id = 0;
|
||||
+ for (int x = minX; x <= maxX; x++) {
|
||||
+ byte visibleOnFaceX = 0;
|
||||
+ byte faceEdgeDataX = 0;
|
||||
+ faceEdgeDataX |= (x == minX) ? ON_MIN_X : 0;
|
||||
+ faceEdgeDataX |= (x == maxX) ? ON_MAX_X : 0;
|
||||
+ visibleOnFaceX |= (x == minX && relX == Relative.POSITIVE) ? ON_MIN_X : 0;
|
||||
+ visibleOnFaceX |= (x == maxX && relX == Relative.NEGATIVE) ? ON_MAX_X : 0;
|
||||
+ for (int y = minY; y <= maxY; y++) {
|
||||
+ byte faceEdgeDataY = faceEdgeDataX;
|
||||
+ byte visibleOnFaceY = visibleOnFaceX;
|
||||
+ faceEdgeDataY |= (y == minY) ? ON_MIN_Y : 0;
|
||||
+ faceEdgeDataY |= (y == maxY) ? ON_MAX_Y : 0;
|
||||
+ visibleOnFaceY |= (y == minY && relY == Relative.POSITIVE) ? ON_MIN_Y : 0;
|
||||
+ visibleOnFaceY |= (y == maxY && relY == Relative.NEGATIVE) ? ON_MAX_Y : 0;
|
||||
+ for (int z = minZ; z <= maxZ; z++) {
|
||||
+ byte faceEdgeData = faceEdgeDataY;
|
||||
+ byte visibleOnFace = visibleOnFaceY;
|
||||
+ faceEdgeData |= (z == minZ) ? ON_MIN_Z : 0;
|
||||
+ faceEdgeData |= (z == maxZ) ? ON_MAX_Z : 0;
|
||||
+ visibleOnFace |= (z == minZ && relZ == Relative.POSITIVE) ? ON_MIN_Z : 0;
|
||||
+ visibleOnFace |= (z == maxZ && relZ == Relative.NEGATIVE) ? ON_MAX_Z : 0;
|
||||
+ if(skipList.get(id)) { // was checked and it wasn't visible
|
||||
+ id++;
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ if (visibleOnFace != 0) {
|
||||
+ targetPos.set(x, y, z);
|
||||
+ if (isVoxelVisible(viewerPosition, targetPos, faceEdgeData, visibleOnFace)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ id++;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+ } catch (Throwable t) {
|
||||
+ // Failsafe
|
||||
+ t.printStackTrace();
|
||||
+ }
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * @param viewerPosition
|
||||
+ * @param position
|
||||
+ * @param faceData contains rather this Block is on the outside for a given face
|
||||
+ * @param visibleOnFace contains rather a face should be concidered
|
||||
+ * @return
|
||||
+ */
|
||||
+ private boolean isVoxelVisible(Vec3d viewerPosition, Vec3d position, byte faceData, byte visibleOnFace) {
|
||||
+ int targetSize = 0;
|
||||
+ Arrays.fill(dotselectors, false);
|
||||
+ if((visibleOnFace & ON_MIN_X) == ON_MIN_X){
|
||||
+ dotselectors[0] = true;
|
||||
+ if((faceData & ~ON_MIN_X) != 0) {
|
||||
+ dotselectors[1] = true;
|
||||
+ dotselectors[4] = true;
|
||||
+ dotselectors[5] = true;
|
||||
+ }
|
||||
+ dotselectors[8] = true;
|
||||
+ }
|
||||
+ if((visibleOnFace & ON_MIN_Y) == ON_MIN_Y){
|
||||
+ dotselectors[0] = true;
|
||||
+ if((faceData & ~ON_MIN_Y) != 0) {
|
||||
+ dotselectors[3] = true;
|
||||
+ dotselectors[4] = true;
|
||||
+ dotselectors[7] = true;
|
||||
+ }
|
||||
+ dotselectors[9] = true;
|
||||
+ }
|
||||
+ if((visibleOnFace & ON_MIN_Z) == ON_MIN_Z){
|
||||
+ dotselectors[0] = true;
|
||||
+ if((faceData & ~ON_MIN_Z) != 0) {
|
||||
+ dotselectors[1] = true;
|
||||
+ dotselectors[4] = true;
|
||||
+ dotselectors[5] = true;
|
||||
+ }
|
||||
+ dotselectors[10] = true;
|
||||
+ }
|
||||
+ if((visibleOnFace & ON_MAX_X) == ON_MAX_X){
|
||||
+ dotselectors[4] = true;
|
||||
+ if((faceData & ~ON_MAX_X) != 0) {
|
||||
+ dotselectors[5] = true;
|
||||
+ dotselectors[6] = true;
|
||||
+ dotselectors[7] = true;
|
||||
+ }
|
||||
+ dotselectors[11] = true;
|
||||
+ }
|
||||
+ if((visibleOnFace & ON_MAX_Y) == ON_MAX_Y){
|
||||
+ dotselectors[1] = true;
|
||||
+ if((faceData & ~ON_MAX_Y) != 0) {
|
||||
+ dotselectors[2] = true;
|
||||
+ dotselectors[5] = true;
|
||||
+ dotselectors[6] = true;
|
||||
+ }
|
||||
+ dotselectors[12] = true;
|
||||
+ }
|
||||
+ if((visibleOnFace & ON_MAX_Z) == ON_MAX_Z){
|
||||
+ dotselectors[2] = true;
|
||||
+ if((faceData & ~ON_MAX_Z) != 0) {
|
||||
+ dotselectors[3] = true;
|
||||
+ dotselectors[6] = true;
|
||||
+ dotselectors[7] = true;
|
||||
+ }
|
||||
+ dotselectors[13] = true;
|
||||
+ }
|
||||
+
|
||||
+ if (dotselectors[0])targetPoints[targetSize++].setAdd(position, 0.05, 0.05, 0.05);
|
||||
+ if (dotselectors[1])targetPoints[targetSize++].setAdd(position, 0.05, 0.95, 0.05);
|
||||
+ if (dotselectors[2])targetPoints[targetSize++].setAdd(position, 0.05, 0.95, 0.95);
|
||||
+ if (dotselectors[3])targetPoints[targetSize++].setAdd(position, 0.05, 0.05, 0.95);
|
||||
+ if (dotselectors[4])targetPoints[targetSize++].setAdd(position, 0.95, 0.05, 0.05);
|
||||
+ if (dotselectors[5])targetPoints[targetSize++].setAdd(position, 0.95, 0.95, 0.05);
|
||||
+ if (dotselectors[6])targetPoints[targetSize++].setAdd(position, 0.95, 0.95, 0.95);
|
||||
+ if (dotselectors[7])targetPoints[targetSize++].setAdd(position, 0.95, 0.05, 0.95);
|
||||
+ // middle points
|
||||
+ if (dotselectors[8])targetPoints[targetSize++].setAdd(position, 0.05, 0.5, 0.5);
|
||||
+ if (dotselectors[9])targetPoints[targetSize++].setAdd(position, 0.5, 0.05, 0.5);
|
||||
+ if (dotselectors[10])targetPoints[targetSize++].setAdd(position, 0.5, 0.5, 0.05);
|
||||
+ if (dotselectors[11])targetPoints[targetSize++].setAdd(position, 0.95, 0.5, 0.5);
|
||||
+ if (dotselectors[12])targetPoints[targetSize++].setAdd(position, 0.5, 0.95, 0.5);
|
||||
+ if (dotselectors[13])targetPoints[targetSize++].setAdd(position, 0.5, 0.5, 0.95);
|
||||
+
|
||||
+ return isVisible(viewerPosition, targetPoints, targetSize);
|
||||
+ }
|
||||
+
|
||||
+ private boolean rayIntersection(int[] b, Vec3d rayOrigin, Vec3d rayDir) {
|
||||
+ Vec3d rInv = new Vec3d(1, 1, 1).div(rayDir);
|
||||
+
|
||||
+ double t1 = (b[0] - rayOrigin.x) * rInv.x;
|
||||
+ double t2 = (b[0] + 1 - rayOrigin.x) * rInv.x;
|
||||
+ double t3 = (b[1] - rayOrigin.y) * rInv.y;
|
||||
+ double t4 = (b[1] + 1 - rayOrigin.y) * rInv.y;
|
||||
+ double t5 = (b[2] - rayOrigin.z) * rInv.z;
|
||||
+ double t6 = (b[2] + 1 - rayOrigin.z) * rInv.z;
|
||||
+
|
||||
+ double tmin = Math.max(Math.max(Math.min(t1, t2), Math.min(t3, t4)), Math.min(t5, t6));
|
||||
+ double tmax = Math.min(Math.min(Math.max(t1, t2), Math.max(t3, t4)), Math.max(t5, t6));
|
||||
+
|
||||
+ // if tmax > 0, ray (line) is intersecting AABB, but the whole AABB is behind us
|
||||
+ if (tmax > 0) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ // if tmin > tmax, ray doesn't intersect AABB
|
||||
+ if (tmin > tmax) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * returns the grid cells that intersect with this Vec3d<br>
|
||||
+ * <a href=
|
||||
+ * "http://playtechs.blogspot.de/2007/03/raytracing-on-grid.html">http://playtechs.blogspot.de/2007/03/raytracing-on-grid.html</a>
|
||||
+ * <p>
|
||||
+ * Caching assumes that all Vec3d's are inside the same block
|
||||
+ */
|
||||
+ private boolean isVisible(Vec3d start, Vec3d[] targets, int size) {
|
||||
+ // start cell coordinate
|
||||
+ int x = cameraPos[0];
|
||||
+ int y = cameraPos[1];
|
||||
+ int z = cameraPos[2];
|
||||
+
|
||||
+ for (int v = 0; v < size; v++) {
|
||||
+ // ray-casting target
|
||||
+ Vec3d target = targets[v];
|
||||
+
|
||||
+ double relativeX = start.x - target.getX();
|
||||
+ double relativeY = start.y - target.getY();
|
||||
+ double relativeZ = start.z - target.getZ();
|
||||
+
|
||||
+ if(allowRayChecks && rayIntersection(lastHitBlock, start, new Vec3d(relativeX, relativeY, relativeZ).normalize())) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ // horizontal and vertical cell amount spanned
|
||||
+ double dimensionX = Math.abs(relativeX);
|
||||
+ double dimensionY = Math.abs(relativeY);
|
||||
+ double dimensionZ = Math.abs(relativeZ);
|
||||
+
|
||||
+ // distance between horizontal intersection points with cell border as a
|
||||
+ // fraction of the total Vec3d length
|
||||
+ double dimFracX = 1f / dimensionX;
|
||||
+ // distance between vertical intersection points with cell border as a fraction
|
||||
+ // of the total Vec3d length
|
||||
+ double dimFracY = 1f / dimensionY;
|
||||
+ double dimFracZ = 1f / dimensionZ;
|
||||
+
|
||||
+ // total amount of intersected cells
|
||||
+ int intersectCount = 1;
|
||||
+
|
||||
+ // 1, 0 or -1
|
||||
+ // determines the direction of the next cell (horizontally / vertically)
|
||||
+ int x_inc, y_inc, z_inc;
|
||||
+
|
||||
+ // the distance to the next horizontal / vertical intersection point with a cell
|
||||
+ // border as a fraction of the total Vec3d length
|
||||
+ double t_next_y, t_next_x, t_next_z;
|
||||
+
|
||||
+ if (dimensionX == 0f) {
|
||||
+ x_inc = 0;
|
||||
+ t_next_x = dimFracX; // don't increment horizontally because the Vec3d is perfectly vertical
|
||||
+ } else if (target.x > start.x) {
|
||||
+ x_inc = 1; // target point is horizontally greater than starting point so increment every
|
||||
+ // step by 1
|
||||
+ intersectCount += MathUtilities.floor(target.x) - x; // increment total amount of intersecting cells
|
||||
+ t_next_x = (float) ((x + 1 - start.x) * dimFracX); // calculate the next horizontal
|
||||
+ // intersection
|
||||
+ // point based on the position inside
|
||||
+ // the first cell
|
||||
+ } else {
|
||||
+ x_inc = -1; // target point is horizontally smaller than starting point so reduce every step
|
||||
+ // by 1
|
||||
+ intersectCount += x - MathUtilities.floor(target.x); // increment total amount of intersecting cells
|
||||
+ t_next_x = (float) ((start.x - x)
|
||||
+ * dimFracX); // calculate the next horizontal
|
||||
+ // intersection point
|
||||
+ // based on the position inside
|
||||
+ // the first cell
|
||||
+ }
|
||||
+
|
||||
+ if (dimensionY == 0f) {
|
||||
+ y_inc = 0;
|
||||
+ t_next_y = dimFracY; // don't increment vertically because the Vec3d is perfectly horizontal
|
||||
+ } else if (target.y > start.y) {
|
||||
+ y_inc = 1; // target point is vertically greater than starting point so increment every
|
||||
+ // step by 1
|
||||
+ intersectCount += MathUtilities.floor(target.y) - y; // increment total amount of intersecting cells
|
||||
+ t_next_y = (float) ((y + 1 - start.y)
|
||||
+ * dimFracY); // calculate the next vertical
|
||||
+ // intersection
|
||||
+ // point based on the position inside
|
||||
+ // the first cell
|
||||
+ } else {
|
||||
+ y_inc = -1; // target point is vertically smaller than starting point so reduce every step
|
||||
+ // by 1
|
||||
+ intersectCount += y - MathUtilities.floor(target.y); // increment total amount of intersecting cells
|
||||
+ t_next_y = (float) ((start.y - y)
|
||||
+ * dimFracY); // calculate the next vertical intersection
|
||||
+ // point
|
||||
+ // based on the position inside
|
||||
+ // the first cell
|
||||
+ }
|
||||
+
|
||||
+ if (dimensionZ == 0f) {
|
||||
+ z_inc = 0;
|
||||
+ t_next_z = dimFracZ; // don't increment vertically because the Vec3d is perfectly horizontal
|
||||
+ } else if (target.z > start.z) {
|
||||
+ z_inc = 1; // target point is vertically greater than starting point so increment every
|
||||
+ // step by 1
|
||||
+ intersectCount += MathUtilities.floor(target.z) - z; // increment total amount of intersecting cells
|
||||
+ t_next_z = (float) ((z + 1 - start.z)
|
||||
+ * dimFracZ); // calculate the next vertical
|
||||
+ // intersection
|
||||
+ // point based on the position inside
|
||||
+ // the first cell
|
||||
+ } else {
|
||||
+ z_inc = -1; // target point is vertically smaller than starting point so reduce every step
|
||||
+ // by 1
|
||||
+ intersectCount += z - MathUtilities.floor(target.z); // increment total amount of intersecting cells
|
||||
+ t_next_z = (float) ((start.z - z)
|
||||
+ * dimFracZ); // calculate the next vertical intersection
|
||||
+ // point
|
||||
+ // based on the position inside
|
||||
+ // the first cell
|
||||
+ }
|
||||
+
|
||||
+ boolean finished = stepRay(start, x, y, z,
|
||||
+ dimFracX, dimFracY, dimFracZ, intersectCount, x_inc, y_inc,
|
||||
+ z_inc, t_next_y, t_next_x, t_next_z);
|
||||
+ provider.cleanup();
|
||||
+ if (finished) {
|
||||
+ cacheResult(targets[0], true);
|
||||
+ return true;
|
||||
+ } else {
|
||||
+ allowRayChecks = true;
|
||||
+ }
|
||||
+ }
|
||||
+ cacheResult(targets[0], false);
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ private boolean stepRay(Vec3d start, int currentX, int currentY,
|
||||
+ int currentZ, double distInX, double distInY,
|
||||
+ double distInZ, int n, int x_inc, int y_inc,
|
||||
+ int z_inc, double t_next_y, double t_next_x,
|
||||
+ double t_next_z) {
|
||||
+ allowWallClipping = true; // initially allow rays to go through walls till they are on the outside
|
||||
+ // iterate through all intersecting cells (n times)
|
||||
+ for (; n > 1; n--) { // n-1 times because we don't want to check the last block
|
||||
+ // towards - where from
|
||||
+
|
||||
+
|
||||
+ // get cached value, 0 means uncached (default)
|
||||
+ int cVal = getCacheValue(currentX, currentY, currentZ);
|
||||
+
|
||||
+ if (cVal == 2 && !allowWallClipping) {
|
||||
+ // block cached as occluding, stop ray
|
||||
+ lastHitBlock[0] = currentX;
|
||||
+ lastHitBlock[1] = currentY;
|
||||
+ lastHitBlock[2] = currentZ;
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (cVal == 0) {
|
||||
+ // save current cell
|
||||
+ int chunkX = currentX >> 4;
|
||||
+ int chunkZ = currentZ >> 4;
|
||||
+
|
||||
+ if (!provider.prepareChunk(chunkX, chunkZ)) { // Chunk not ready
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (provider.isOpaqueFullCube(currentX, currentY, currentZ)) {
|
||||
+ if (!allowWallClipping) {
|
||||
+ cache.setLastHidden();
|
||||
+ lastHitBlock[0] = currentX;
|
||||
+ lastHitBlock[1] = currentY;
|
||||
+ lastHitBlock[2] = currentZ;
|
||||
+ return false;
|
||||
+ }
|
||||
+ } else {
|
||||
+ // outside of wall, now clipping is not allowed
|
||||
+ allowWallClipping = false;
|
||||
+ cache.setLastVisible();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if(cVal == 1) {
|
||||
+ // outside of wall, now clipping is not allowed
|
||||
+ allowWallClipping = false;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ if (t_next_y < t_next_x && t_next_y < t_next_z) { // next cell is upwards/downwards because the distance to
|
||||
+ // the next vertical
|
||||
+ // intersection point is smaller than to the next horizontal intersection point
|
||||
+ currentY += y_inc; // move up/down
|
||||
+ t_next_y += distInY; // update next vertical intersection point
|
||||
+ } else if (t_next_x < t_next_y && t_next_x < t_next_z) { // next cell is right/left
|
||||
+ currentX += x_inc; // move right/left
|
||||
+ t_next_x += distInX; // update next horizontal intersection point
|
||||
+ } else {
|
||||
+ currentZ += z_inc; // move right/left
|
||||
+ t_next_z += distInZ; // update next horizontal intersection point
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ // -1 = invalid location, 0 = not checked yet, 1 = visible, 2 = occluding
|
||||
+ private int getCacheValue(int x, int y, int z) {
|
||||
+ x -= cameraPos[0];
|
||||
+ y -= cameraPos[1];
|
||||
+ z -= cameraPos[2];
|
||||
+ if (Math.abs(x) > reach - 2 || Math.abs(y) > reach - 2
|
||||
+ || Math.abs(z) > reach - 2) {
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ // check if target is already known
|
||||
+ return cache.getState(x + reach, y + reach, z + reach);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private void cacheResult(int x, int y, int z, boolean result) {
|
||||
+ int cx = x - cameraPos[0] + reach;
|
||||
+ int cy = y - cameraPos[1] + reach;
|
||||
+ int cz = z - cameraPos[2] + reach;
|
||||
+ if (result) {
|
||||
+ cache.setVisible(cx, cy, cz);
|
||||
+ } else {
|
||||
+ cache.setHidden(cx, cy, cz);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private void cacheResult(Vec3d vector, boolean result) {
|
||||
+ int cx = MathUtilities.floor(vector.x) - cameraPos[0] + reach;
|
||||
+ int cy = MathUtilities.floor(vector.y) - cameraPos[1] + reach;
|
||||
+ int cz = MathUtilities.floor(vector.z) - cameraPos[2] + reach;
|
||||
+ if (result) {
|
||||
+ cache.setVisible(cx, cy, cz);
|
||||
+ } else {
|
||||
+ cache.setHidden(cx, cy, cz);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public void resetCache() {
|
||||
+ this.cache.resetCache();
|
||||
+ }
|
||||
+
|
||||
+ private enum Relative {
|
||||
+ INSIDE, POSITIVE, NEGATIVE;
|
||||
+
|
||||
+ public static Relative from(int min, int max, int pos) {
|
||||
+ if (max > pos && min > pos) {
|
||||
+ return POSITIVE;
|
||||
+ } else if (min < pos && max < pos) {
|
||||
+ return NEGATIVE;
|
||||
+ }
|
||||
+ return INSIDE;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user