mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-06-25 06:05:05 +02:00
on the latest version now
This commit is contained in:
parent
16ba48ea61
commit
2c205e034e
|
@ -8,6 +8,7 @@ # Patches
|
|||
|
||||
| Side | Patch | Author | CoAuthors |
|
||||
| ----- | ------------- |:-------------:| -----:|
|
||||
| server | (AI-Improvements) Optimized tan for ControllerLook | bl4ckscor3 | |
|
||||
| server | AFK API | William Blake Galbreath | |
|
||||
| api | AFK API | William Blake Galbreath | |
|
||||
| server | Ability to re-add farmland mechanics from Alpha | Yive | |
|
||||
|
@ -250,6 +251,7 @@ # Patches
|
|||
| api | Lagging threshold | William Blake Galbreath | |
|
||||
| server | Left handed API | BillyGalbreath | |
|
||||
| api | Left handed API | BillyGalbreath | |
|
||||
| server | Lithium: CompactSineLUT | JellySquid | |
|
||||
| server | LivingEntity safeFallDistance | William Blake Galbreath | |
|
||||
| api | LivingEntity safeFallDistance | William Blake Galbreath | |
|
||||
| server | LivingEntity#broadcastItemBreak | William Blake Galbreath | |
|
||||
|
@ -329,6 +331,8 @@ # Patches
|
|||
| api | PlayerSetSpawnerTypeWithEggEvent | William Blake Galbreath | |
|
||||
| server | Players should not cram to death | William Blake Galbreath | |
|
||||
| server | Populator seed controls | Spottedleaf | |
|
||||
| server | Port Cadmium | Lucy-t | |
|
||||
| server | Port LazyDFU | Andrew Steinborn | |
|
||||
| server | Preload ProtocolLib EnumWrappers | ishland | |
|
||||
| server | Prevent long map entry creation in light engine | Spottedleaf | |
|
||||
| server | Prevent unload() calls removing tickets for sync loads | Spottedleaf | |
|
||||
|
|
|
@ -24,5 +24,22 @@ val libraryImports = setOf<LibraryImport>(
|
|||
LibraryImport("com.mojang", "brigadier", "com/mojang/brigadier", "CommandDispatcher"),
|
||||
LibraryImport("com.mojang", "brigadier", "com/mojang/brigadier/tree", "LiteralCommandNode"),
|
||||
LibraryImport("com.mojang", "brigadier", "com/mojang/brigadier/suggestion", "SuggestionsBuilder"),
|
||||
LibraryImport("com.mojang", "brigadier", "com/mojang/brigadier/arguments", "BoolArgumentType")
|
||||
)
|
||||
LibraryImport("com.mojang", "brigadier", "com/mojang/brigadier/arguments", "BoolArgumentType"),
|
||||
LibraryImport("com.mojang", "datafixerupper", "com/mojang/datafixers", "FieldFinder"),
|
||||
LibraryImport("com.mojang", "datafixerupper", "com/mojang/datafixers", "DataFixUtils"),
|
||||
LibraryImport("com.mojang", "datafixerupper", "com/mojang/datafixers", "TypeRewriteRule"),
|
||||
LibraryImport("com.mojang", "datafixerupper", "com/mojang/datafixers", "Typed"),
|
||||
LibraryImport("com.mojang", "datafixerupper", "com/mojang/datafixers", "TypedOptic"),
|
||||
LibraryImport("com.mojang", "datafixerupper", "com/mojang/datafixers", "View"),
|
||||
LibraryImport("com.mojang", "datafixerupper", "com/mojang/datafixers/functions", "Apply"),
|
||||
LibraryImport("com.mojang", "datafixerupper", "com/mojang/datafixers/functions", "Comp"),
|
||||
LibraryImport("com.mojang", "datafixerupper", "com/mojang/datafixers/functions", "PointFree"),
|
||||
LibraryImport("com.mojang", "datafixerupper", "com/mojang/datafixers/functions", "PointFreeRule"),
|
||||
LibraryImport("com.mojang", "datafixerupper", "com/mojang/datafixers/optics", "IdAdapter"),
|
||||
LibraryImport("com.mojang", "datafixerupper", "com/mojang/datafixers/optics", "Inj1"),
|
||||
LibraryImport("com.mojang", "datafixerupper", "com/mojang/datafixers/optics", "Inj2"),
|
||||
LibraryImport("com.mojang", "datafixerupper", "com/mojang/datafixers/optics", "Optics"),
|
||||
LibraryImport("com.mojang", "datafixerupper", "com/mojang/datafixers/optics", "Proj1"),
|
||||
LibraryImport("com.mojang", "datafixerupper", "com/mojang/datafixers/optics", "Proj2"),
|
||||
LibraryImport("com.mojang", "datafixerupper", "com/mojang/datafixers/types", "Type")
|
||||
)
|
1248
patches/server/0060-Port-Cadmium.patch
Normal file
1248
patches/server/0060-Port-Cadmium.patch
Normal file
File diff suppressed because it is too large
Load Diff
49
patches/server/0061-Port-LazyDFU.patch
Normal file
49
patches/server/0061-Port-LazyDFU.patch
Normal file
|
@ -0,0 +1,49 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Steinborn <git@steinborn.me>
|
||||
Date: Tue, 2 Feb 2021 20:59:35 -0500
|
||||
Subject: [PATCH] Port LazyDFU
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/steinborn/lazydfu/mod/LazyDataFixerBuilder.java b/src/main/java/me/steinborn/lazydfu/mod/LazyDataFixerBuilder.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..081aa46531a9df1dc732669a2c1e3180790468c4
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/steinborn/lazydfu/mod/LazyDataFixerBuilder.java
|
||||
@@ -0,0 +1,23 @@
|
||||
+package me.steinborn.lazydfu.mod;
|
||||
+
|
||||
+import com.mojang.datafixers.DataFixerBuilder;
|
||||
+import com.mojang.datafixers.DataFixer;
|
||||
+
|
||||
+import java.util.concurrent.Executor;
|
||||
+
|
||||
+/**
|
||||
+ * This version of {@code DataFixerBuilder} does not immediately initialize rules.
|
||||
+ */
|
||||
+public class LazyDataFixerBuilder extends DataFixerBuilder {
|
||||
+
|
||||
+ private static final Executor NO_OP_EXECUTOR = command -> {};
|
||||
+
|
||||
+ public LazyDataFixerBuilder(int dataVersion) {
|
||||
+ super(dataVersion);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public DataFixer build(Executor executor) {
|
||||
+ return super.build(NO_OP_EXECUTOR);
|
||||
+ }
|
||||
+}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/net/minecraft/util/datafix/DataConverterRegistry.java b/src/main/java/net/minecraft/util/datafix/DataConverterRegistry.java
|
||||
index 625dcfaeffb83a0b8b53778c32287cac8daae540..5a22fd08cc2a09d8695ca060dee80183364164a1 100644
|
||||
--- a/src/main/java/net/minecraft/util/datafix/DataConverterRegistry.java
|
||||
+++ b/src/main/java/net/minecraft/util/datafix/DataConverterRegistry.java
|
||||
@@ -202,7 +202,7 @@ public class DataConverterRegistry {
|
||||
// Yatopia start
|
||||
private static final DataFixer c;
|
||||
static {
|
||||
- DataFixerBuilder datafixerbuilder = new DataFixerBuilder(SharedConstants.getGameVersion().getWorldVersion());
|
||||
+ DataFixerBuilder datafixerbuilder = new me.steinborn.lazydfu.mod.LazyDataFixerBuilder(SharedConstants.getGameVersion().getWorldVersion()); // Yatopia - Port LazyDFU
|
||||
|
||||
a(datafixerbuilder);
|
||||
c = datafixerbuilder.build(SystemUtils.d);
|
138
patches/server/0062-Lithium-CompactSineLUT.patch
Normal file
138
patches/server/0062-Lithium-CompactSineLUT.patch
Normal file
|
@ -0,0 +1,138 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: JellySquid <jellysquid+atwork@protonmail.com>
|
||||
Date: Fri, 5 Feb 2021 00:16:30 -0600
|
||||
Subject: [PATCH] Lithium: CompactSineLUT
|
||||
|
||||
Original code by JellySquid, licensed under GNU Lesser General Public License v3.0
|
||||
you can find the original code on https://github.com/CaffeineMC/lithium-fabric/ (Yarn mappings)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/util/MathHelper.java b/src/main/java/net/minecraft/util/MathHelper.java
|
||||
index e9e7fcf2b63febe2a7d055826fabb86bc13a5cf3..b95115aca72ba0cf6451096ddbd8b50a8f3bb5c6 100644
|
||||
--- a/src/main/java/net/minecraft/util/MathHelper.java
|
||||
+++ b/src/main/java/net/minecraft/util/MathHelper.java
|
||||
@@ -5,6 +5,7 @@ import java.util.UUID;
|
||||
import java.util.function.IntPredicate;
|
||||
import net.minecraft.SystemUtils;
|
||||
import net.minecraft.core.BaseBlockPosition;
|
||||
+import org.yatopiamc.yatopia.server.math.CompactSineLUT;
|
||||
|
||||
public class MathHelper {
|
||||
|
||||
@@ -15,6 +16,7 @@ public class MathHelper {
|
||||
}
|
||||
|
||||
});
|
||||
+ public static float[] getSinTable() { return b; } // Yatopia - OBFHELPER
|
||||
private static final Random c = new Random();
|
||||
private static final int[] d = new int[]{0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9};
|
||||
private static final double e = Double.longBitsToDouble(4805340802404319232L);
|
||||
@@ -22,11 +24,11 @@ public class MathHelper {
|
||||
private static final double[] g = new double[257];
|
||||
|
||||
public static float sin(float f) {
|
||||
- return MathHelper.b[(int) (f * 10430.378F) & '\uffff'];
|
||||
+ return CompactSineLUT.sin(f); // Yatopia - CompactSineLUT
|
||||
}
|
||||
|
||||
public static float cos(float f) {
|
||||
- return MathHelper.b[(int) (f * 10430.378F + 16384.0F) & '\uffff'];
|
||||
+ return CompactSineLUT.cos(f); // Yatopia - CompactSineLUT
|
||||
}
|
||||
|
||||
public static float c(float f) {
|
||||
diff --git a/src/main/java/org/yatopiamc/yatopia/server/math/CompactSineLUT.java b/src/main/java/org/yatopiamc/yatopia/server/math/CompactSineLUT.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..1bb8ba3836af872bc2e58898f16a0b91036b9b02
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/yatopiamc/yatopia/server/math/CompactSineLUT.java
|
||||
@@ -0,0 +1,90 @@
|
||||
+package org.yatopiamc.yatopia.server.math;
|
||||
+
|
||||
+import net.minecraft.util.MathHelper;
|
||||
+
|
||||
+/**
|
||||
+ * A replacement for the sine angle lookup table used in {@link MathHelper}, both reducing the size of LUT and improving
|
||||
+ * the access patterns for common paired sin/cos operations.
|
||||
+ *
|
||||
+ * sin(-x) = -sin(x)
|
||||
+ * ... to eliminate negative angles from the LUT.
|
||||
+ *
|
||||
+ * sin(x) = sin(pi/2 - x)
|
||||
+ * ... to eliminate supplementary angles from the LUT.
|
||||
+ *
|
||||
+ * Using these identities allows us to reduce the LUT from 64K entries (256 KB) to just 16K entries (64 KB), enabling
|
||||
+ * it to better fit into the CPU's caches at the expense of some cycles on the fast path. The implementation has been
|
||||
+ * tightly optimized to avoid branching where possible and to use very quick integer operations.
|
||||
+ *
|
||||
+ * Generally speaking, reducing the size of a lookup table is always a good optimization, but since we need to spend
|
||||
+ * extra CPU cycles trying to maintain parity with vanilla, there is the potential risk that this implementation ends
|
||||
+ * up being slower than vanilla when the lookup table is able to be kept in cache memory.
|
||||
+ *
|
||||
+ * Unlike other "fast math" implementations, the values returned by this class are *bit-for-bit identical* with those
|
||||
+ * from {@link MathHelper}. Validation is performed during runtime to ensure that the table is correct.
|
||||
+ *
|
||||
+ * @author coderbot16 Author of the original (and very clever) implementation in Rust:
|
||||
+ * https://gitlab.com/coderbot16/i73/-/tree/master/i73-trig/src
|
||||
+ * @author jellysquid3 Additional optimizations, port to Java
|
||||
+ */
|
||||
+public class CompactSineLUT {
|
||||
+ private static final int[] SINE_TABLE_INT = new int[16384 + 1];
|
||||
+ private static final float SINE_TABLE_MIDPOINT;
|
||||
+
|
||||
+ static {
|
||||
+ final float[] SINE_TABLE = MathHelper.getSinTable();
|
||||
+ // Copy the sine table, covering to raw int bits
|
||||
+ for (int i = 0; i < SINE_TABLE_INT.length; i++) {
|
||||
+ SINE_TABLE_INT[i] = Float.floatToRawIntBits(SINE_TABLE[i]);
|
||||
+ }
|
||||
+
|
||||
+ SINE_TABLE_MIDPOINT = SINE_TABLE[SINE_TABLE.length / 2];
|
||||
+
|
||||
+ // Test that the lookup table is correct during runtime
|
||||
+ for (int i = 0; i < SINE_TABLE.length; i++) {
|
||||
+ float expected = SINE_TABLE[i];
|
||||
+ float value = lookup(i);
|
||||
+
|
||||
+ if (expected != value) {
|
||||
+ throw new IllegalArgumentException(String.format("LUT error at index %d (expected: %s, found: %s)", i, expected, value));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // [VanillaCopy] MathHelper#sin(float)
|
||||
+ public static float sin(float f) {
|
||||
+ return lookup((int) (f * 10430.38) & 0xFFFF);
|
||||
+ }
|
||||
+
|
||||
+ // [VanillaCopy] MathHelper#cos(float)
|
||||
+ public static float cos(float f) {
|
||||
+ return lookup((int) (f * 10430.38 + 16384.0) & 0xFFFF);
|
||||
+ }
|
||||
+
|
||||
+ private static float lookup(int index) {
|
||||
+ // A special case... Is there some way to eliminate this?
|
||||
+ if (index == 32768) {
|
||||
+ return SINE_TABLE_MIDPOINT;
|
||||
+ }
|
||||
+
|
||||
+ // Trigonometric identity: sin(-x) = -sin(x)
|
||||
+ // Given a domain of 0 <= x <= 2*pi, just negate the value if x > pi.
|
||||
+ // This allows the sin table size to be halved.
|
||||
+ int neg = (index & 0x8000) << 16;
|
||||
+
|
||||
+ // All bits set if (pi/2 <= x), none set otherwise
|
||||
+ // Extracts the 15th bit from 'half'
|
||||
+ int mask = (index << 17) >> 31;
|
||||
+
|
||||
+ // Trigonometric identity: sin(x) = sin(pi/2 - x)
|
||||
+ int pos = (0x8001 & mask) + (index ^ mask);
|
||||
+
|
||||
+ // Wrap the position in the table. Moving this down to immediately before the array access
|
||||
+ // seems to help the Hotspot compiler optimize the bit math better.
|
||||
+ pos &= 0x7fff;
|
||||
+
|
||||
+ // Fetch the corresponding value from the LUT and invert the sign bit as needed
|
||||
+ // This directly manipulate the sign bit on the float bits to simplify logic
|
||||
+ return Float.intBitsToFloat(SINE_TABLE_INT[pos] ^ neg);
|
||||
+ }
|
||||
+}
|
|
@ -0,0 +1,94 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: bl4ckscor3 <bl4ckscor33@gmail.com>
|
||||
Date: Tue, 2 Feb 2021 21:38:12 -0500
|
||||
Subject: [PATCH] (AI-Improvements) Optimized tan for ControllerLook
|
||||
|
||||
Code originally licenced under MIT from: https://github.com/BuiltBrokenModding/AI-Improvements/tree/1.16
|
||||
|
||||
diff --git a/src/main/java/com/builtbroken/ai/improvements/FastTrig.java b/src/main/java/com/builtbroken/ai/improvements/FastTrig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..82150126c0d1608de0af9a8582571628efe53c2d
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/builtbroken/ai/improvements/FastTrig.java
|
||||
@@ -0,0 +1,59 @@
|
||||
+package com.builtbroken.ai.improvements;
|
||||
+
|
||||
+public class FastTrig {
|
||||
+ private static final int ATAN2_BITS = 8;
|
||||
+
|
||||
+ private static final int ATAN2_BITS2 = ATAN2_BITS << 1;
|
||||
+ private static final int ATAN2_MASK = ~(-1 << ATAN2_BITS2);
|
||||
+ private static final int ATAN2_COUNT = ATAN2_MASK + 1;
|
||||
+ private static final int ATAN2_DIM = (int) Math.sqrt(ATAN2_COUNT);
|
||||
+
|
||||
+ private static final float INV_ATAN2_DIM_MINUS_1 = 1.0f / (ATAN2_DIM - 1);
|
||||
+
|
||||
+ private static final float[] atan2 = new float[ATAN2_COUNT];
|
||||
+ static {
|
||||
+ for (int i = 0; i < ATAN2_DIM; i++) {
|
||||
+ for (int j = 0; j < ATAN2_DIM; j++) {
|
||||
+ float x0 = (float) i / ATAN2_DIM;
|
||||
+ float y0 = (float) j / ATAN2_DIM;
|
||||
+
|
||||
+ atan2[j * ATAN2_DIM + i] = (float) Math.atan2(y0, x0);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public static final float atan2(double y, double x) {
|
||||
+ float add, mul;
|
||||
+
|
||||
+ if (x < 0.0f) {
|
||||
+ if (y < 0.0f) {
|
||||
+ x = -x;
|
||||
+ y = -y;
|
||||
+
|
||||
+ mul = 1.0f;
|
||||
+ } else {
|
||||
+ x = -x;
|
||||
+ mul = -1.0f;
|
||||
+ }
|
||||
+
|
||||
+ add = -3.141592653f;
|
||||
+ } else {
|
||||
+ if (y < 0.0f) {
|
||||
+ y = -y;
|
||||
+ mul = -1.0f;
|
||||
+ } else {
|
||||
+ mul = 1.0f;
|
||||
+ }
|
||||
+
|
||||
+ add = 0.0f;
|
||||
+ }
|
||||
+
|
||||
+ double invDiv = 1.0f / (((x < y) ? y : x) * INV_ATAN2_DIM_MINUS_1);
|
||||
+
|
||||
+ int xi = (int) (x * invDiv);
|
||||
+ int yi = (int) (y * invDiv);
|
||||
+
|
||||
+ return (atan2[yi * ATAN2_DIM + xi] + add) * mul;
|
||||
+ }
|
||||
+}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/control/ControllerLook.java b/src/main/java/net/minecraft/world/entity/ai/control/ControllerLook.java
|
||||
index 3ce9edde641c8b8eea75479615bcd2866ffd2198..b44481633a798c560af5b55723daa32264bb2be3 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/control/ControllerLook.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/control/ControllerLook.java
|
||||
@@ -86,14 +86,14 @@ public class ControllerLook {
|
||||
double d2 = this.g - this.a.locZ();
|
||||
double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2);
|
||||
|
||||
- return (float) (-(MathHelper.d(d1, d3) * 57.2957763671875D));
|
||||
+ return (float) (-(com.builtbroken.ai.improvements.FastTrig.atan2(d1, d3) * 57.2957763671875D)); // Yatopia - Optimized tan implementation
|
||||
}
|
||||
|
||||
protected float h() {
|
||||
double d0 = this.e - this.a.locX();
|
||||
double d1 = this.g - this.a.locZ();
|
||||
|
||||
- return (float) (MathHelper.d(d1, d0) * 57.2957763671875D) - 90.0F;
|
||||
+ return (float) (com.builtbroken.ai.improvements.FastTrig.atan2(d1, d0) * 57.2957763671875D) - 90.0F; // Yatopia - Optimized tan implementation
|
||||
}
|
||||
|
||||
protected float a(float f, float f1, float f2) {
|
Loading…
Reference in New Issue
Block a user