mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2025-02-15 11:51:57 +01:00
Fixes #226 All these were doing some kind of weirdness to the chunk generation, thats why they were dropped. Unfortunately this will decrease performance, but bugs is our priority before speed.
42 lines
1.5 KiB
Diff
42 lines
1.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: gegy1000 <gegy1000@gmail.com>
|
|
Date: Mon, 28 Sep 2020 14:20:17 -0500
|
|
Subject: [PATCH] tic-tacs Threading Fix
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/WeightedList.java b/src/main/java/net/minecraft/server/WeightedList.java
|
|
index 5d9d58411f2fad9d5da703f964d269b4a7c2b205..b9c0037cdfe54fcd5ed6c887f9902be3a2deadba 100644
|
|
--- a/src/main/java/net/minecraft/server/WeightedList.java
|
|
+++ b/src/main/java/net/minecraft/server/WeightedList.java
|
|
@@ -64,9 +64,30 @@ public class WeightedList<U> {
|
|
return this.list.stream().map(WeightedList.a::a); // Paper - decompile conflict
|
|
}
|
|
|
|
+ // Yatopia Start - Tic Tacs threading fix
|
|
+ public U b(Random random) {
|
|
+ WeightedList.a<U> selectedEntry = null;
|
|
+ double selectedValue = 0.0;
|
|
+
|
|
+ for (WeightedList.a<U> entry : this.list) {
|
|
+ double value = Math.pow(random.nextFloat(), 1.0F / entry.b);
|
|
+ if (value > selectedValue) {
|
|
+ selectedEntry = entry;
|
|
+ selectedValue = value;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (selectedEntry == null) {
|
|
+ throw new IllegalStateException("no entries in WeightedList");
|
|
+ }
|
|
+
|
|
+ return selectedEntry.a();
|
|
+ }
|
|
+ /*
|
|
public U b(Random random) {
|
|
return this.a(random).c().findFirst().orElseThrow(RuntimeException::new);
|
|
}
|
|
+ */ //Yatopia End
|
|
|
|
public String toString() {
|
|
return "WeightedList[" + this.list + "]"; // Paper - decompile conflict
|