Dev/thread (#214)

* Add tic-tacs threading fix

* fix diff and credits
This commit is contained in:
budgidiere 2020-09-28 16:31:36 -05:00 committed by GitHub
parent e37628ad1e
commit 0faeed74aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 53 additions and 2 deletions

View File

@ -4,9 +4,19 @@ Date: Sun, 27 Sep 2020 17:07:16 -0500
Subject: [PATCH] Add IntelliJ IDEA runnable
diff --git a/.gitignore b/.gitignore
index 67fb370cad6924895a6b27052dbd5c1767e3f0c9..a111955550db7b00a6923a4fd715f3c524c7c438 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,3 +37,5 @@ dependency-reduced-pom.xml
/src/main/resources/achievement
/src/main/resources/lang
+
+/testserver/**
diff --git a/.run/Yatopia.run.xml b/.run/Yatopia.run.xml
new file mode 100644
index 0000000000000000000000000000000000000000..8bc8c24cc51f8cae8c44083b977772945eac51dd
index 0000000000000000000000000000000000000000..ebba87ca805d8e57ce7aeb57d7f0b11abda0cc1c
--- /dev/null
+++ b/.run/Yatopia.run.xml
@@ -0,0 +1,23 @@
@ -27,7 +37,7 @@ index 0000000000000000000000000000000000000000..8bc8c24cc51f8cae8c44083b97777294
+ <option name="workingDirectory" />
+ </selectedOptions>
+ <option name="VM_PARAMETERS" value="-Xms2G -Xmx2G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true" />
+ <option name="WORKING_DIRECTORY" value="testserver" />
+ <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/testserver" />
+ <method v="2">
+ <option name="MakeProject" enabled="true" />
+ </method>

View File

@ -0,0 +1,41 @@
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