This commit is contained in:
Etil
2021-12-07 21:27:26 +01:00
parent 32ee0c0571
commit 4cd20287bd
3 changed files with 126 additions and 3 deletions

View File

@@ -2,7 +2,7 @@ group=wtf.etil.mirai
version=1.18-R0.1-SNAPSHOT
mcVersion=1.18
pufferfishRef=57bea54d83a5ca504af039c06b73c7313c0a42f0
pufferfishRef=caa7c232ca111706730b5e7ff645fb984b1e74df
org.gradle.caching=true
org.gradle.caching.debug=false

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Swaps the predicate order of collision
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 401a20fb67e232d1e33b8d9167ba2ba609f4dba9..2e28df553c10e8a1174aed97a378358575b0d3fa 100644
index 2bbb547e9f96984b50554e5783fc9ad2601eb52b..6513716ba8eef2c586a8af54ce9d314bf23c7ed4 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -1763,37 +1763,35 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
@@ -1769,37 +1769,35 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
public void playerTouch(Player player) {}
public void push(Entity entity) {

View File

@@ -0,0 +1,123 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Etil <81570777+etil2jz@users.noreply.github.com>
Date: Sat, 4 Dec 2021 22:52:50 +0100
Subject: [PATCH] Utilities
diff --git a/build.gradle.kts b/build.gradle.kts
index d3fdca4fe0de48446987f8fae650daab6665ae17..20b4c362d0ea1f6396df51423ce654a4f66959fe 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -39,6 +39,7 @@ dependencies {
implementation("org.apache.logging.log4j:log4j-iostreams:2.14.1") // Paper
implementation("org.ow2.asm:asm:9.2")
implementation("org.ow2.asm:asm-commons:9.2") // Paper - ASM event executor generation
+ implementation("org.apache.commons:commons-rng-core:1.4") // Yatopia
runtimeOnly("org.xerial:sqlite-jdbc:3.36.0.3")
runtimeOnly("mysql:mysql-connector-java:8.0.27")
runtimeOnly("com.lmax:disruptor:3.4.4") // Paper
diff --git a/src/main/java/org/yatopiamc/yatopia/server/util/FastRandom.java b/src/main/java/org/yatopiamc/yatopia/server/util/FastRandom.java
new file mode 100644
index 0000000000000000000000000000000000000000..03e5260bd50c8af3db4ed71f6748fbb89267309e
--- /dev/null
+++ b/src/main/java/org/yatopiamc/yatopia/server/util/FastRandom.java
@@ -0,0 +1,64 @@
+package org.yatopiamc.yatopia.server.util;
+
+import org.apache.commons.rng.core.source64.XoRoShiRo128PlusPlus;
+
+import java.util.Random;
+import java.util.SplittableRandom;
+
+public class FastRandom extends Random {
+
+ private XoRoShiRo128PlusPlus random;
+
+ public FastRandom() {
+ super();
+ SplittableRandom randomseed = new SplittableRandom();
+ this.random = new XoRoShiRo128PlusPlus(randomseed.nextLong(), randomseed.nextLong());
+ }
+
+ public FastRandom(long seed) {
+ super(seed);
+ SplittableRandom randomseed = new SplittableRandom(seed);
+ this.random = new XoRoShiRo128PlusPlus(randomseed.nextLong(), randomseed.nextLong());
+ }
+
+ @Override
+ public boolean nextBoolean() {
+ return random.nextBoolean();
+ }
+
+ @Override
+ public int nextInt() {
+ return random.nextInt();
+ }
+
+ @Override
+ public float nextFloat() {
+ return (float) random.nextDouble();
+ }
+
+ @Override
+ public double nextDouble() {
+ return random.nextDouble();
+ }
+
+ @Override
+ public synchronized void setSeed(long seed) {
+ SplittableRandom randomseed = new SplittableRandom(seed);
+ this.random = new XoRoShiRo128PlusPlus(randomseed.nextLong(), randomseed.nextLong());
+ }
+
+ @Override
+ public void nextBytes(byte[] bytes) {
+ random.nextBytes(bytes);
+ }
+
+ @Override
+ public int nextInt(int bound) {
+ return random.nextInt(bound);
+ }
+
+ @Override
+ public long nextLong() {
+ return random.nextLong();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/yatopiamc/yatopia/server/util/TimeUtils.java b/src/main/java/org/yatopiamc/yatopia/server/util/TimeUtils.java
new file mode 100644
index 0000000000000000000000000000000000000000..bb023bcb4b1e1ab5261c83358ce0951cc35ba16d
--- /dev/null
+++ b/src/main/java/org/yatopiamc/yatopia/server/util/TimeUtils.java
@@ -0,0 +1,27 @@
+package org.yatopiamc.yatopia.server.util;
+
+import java.util.concurrent.TimeUnit;
+
+public class TimeUtils {
+
+ public static String getFriendlyName(TimeUnit unit) {
+ switch (unit) {
+ case NANOSECONDS:
+ return "ns";
+ case MILLISECONDS:
+ return "ms";
+ case MICROSECONDS:
+ return "micros";
+ case SECONDS:
+ return "s";
+ case MINUTES:
+ return "m";
+ case DAYS:
+ return "d";
+ case HOURS:
+ return "h";
+ default:
+ throw new AssertionError();
+ }
+ }
+}
\ No newline at end of file