mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-22 16:39:22 +00:00
[ci skip] Drop useless patches
This commit is contained in:
@@ -1,200 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
|
||||||
Date: Tue, 5 Sep 2023 03:51:38 -0400
|
|
||||||
Subject: [PATCH] Use commons-lang3
|
|
||||||
|
|
||||||
Plugin incompatible
|
|
||||||
|
|
||||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
|
||||||
index 6efb27e3b86f36aed1dc76e9b95124e557a6894e..1fa65de0bc0cc51876baa86b043bfefd2968e57e 100644
|
|
||||||
--- a/build.gradle.kts
|
|
||||||
+++ b/build.gradle.kts
|
|
||||||
@@ -44,7 +44,7 @@ dependencies {
|
|
||||||
implementation("org.ow2.asm:asm-commons:9.5") // Paper - ASM event executor generation
|
|
||||||
testImplementation("org.mockito:mockito-core:5.5.0") // Paper - switch to mockito
|
|
||||||
implementation("org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT") // Paper - config files
|
|
||||||
- implementation("commons-lang:commons-lang:2.6")
|
|
||||||
+ implementation("org.apache.commons:commons-lang3:3.13.0")
|
|
||||||
implementation("net.fabricmc:mapping-io:0.4.2") // Paper - needed to read mappings for stacktrace deobfuscation
|
|
||||||
runtimeOnly("org.xerial:sqlite-jdbc:3.43.0.0")
|
|
||||||
runtimeOnly("com.mysql:mysql-connector-j:8.1.0")
|
|
||||||
diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java
|
|
||||||
index 61fc65624f7d9a3bfa399a58112efb7f55b31652..5b08d669d348787453bce57a7f439c6ecbae8df0 100644
|
|
||||||
--- a/src/main/java/co/aikar/timings/TimingsExport.java
|
|
||||||
+++ b/src/main/java/co/aikar/timings/TimingsExport.java
|
|
||||||
@@ -29,7 +29,7 @@ import net.kyori.adventure.text.event.ClickEvent;
|
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
|
||||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
-import org.apache.commons.lang.StringUtils;
|
|
||||||
+import org.apache.commons.lang3.StringUtils; // Leaf - Use commons-lang3
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/entity/PaperPathfinder.java b/src/main/java/com/destroystokyo/paper/entity/PaperPathfinder.java
|
|
||||||
index 064712e7b27a200b29c72076a82f4f5611fa507f..d4b1f608248bad0ecde768e125ef49c5f481ea78 100644
|
|
||||||
--- a/src/main/java/com/destroystokyo/paper/entity/PaperPathfinder.java
|
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/entity/PaperPathfinder.java
|
|
||||||
@@ -1,6 +1,6 @@
|
|
||||||
package com.destroystokyo.paper.entity;
|
|
||||||
|
|
||||||
-import org.apache.commons.lang.Validate;
|
|
||||||
+import org.apache.commons.lang3.Validate; // Leaf - Use commons-lang3
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
diff --git a/src/main/java/gg/airplane/structs/ItemListWithBitset.java b/src/main/java/gg/airplane/structs/ItemListWithBitset.java
|
|
||||||
index a45b135af87324c99a9fdd6ba9564255e5beb199..f1b1fcdb36957404042255c212cd0fbb40a55ad2 100644
|
|
||||||
--- a/src/main/java/gg/airplane/structs/ItemListWithBitset.java
|
|
||||||
+++ b/src/main/java/gg/airplane/structs/ItemListWithBitset.java
|
|
||||||
@@ -4,7 +4,7 @@ package gg.airplane.structs;
|
|
||||||
|
|
||||||
import net.minecraft.core.NonNullList;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
-import org.apache.commons.lang.Validate;
|
|
||||||
+import org.apache.commons.lang3.Validate; // Leaf - Use commons-lang3
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java
|
|
||||||
index 1eaa559b177f2dc982865f96dfc7654bcfabc62c..6b0f3029e539892f4a8c2ec9af2324d42fa362b5 100644
|
|
||||||
--- a/src/main/java/io/papermc/paper/util/MCUtil.java
|
|
||||||
+++ b/src/main/java/io/papermc/paper/util/MCUtil.java
|
|
||||||
@@ -33,7 +33,7 @@ import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
|
||||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
-import org.apache.commons.lang.exception.ExceptionUtils;
|
|
||||||
+import org.apache.commons.lang3.exception.ExceptionUtils; // Leaf - Use commons-lang3
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
@@ -195,7 +195,7 @@ public final class MCUtil {
|
|
||||||
* @return Stacktrace
|
|
||||||
*/
|
|
||||||
public static String stack() {
|
|
||||||
- return ExceptionUtils.getFullStackTrace(new Throwable());
|
|
||||||
+ return ExceptionUtils.getStackTrace(new Throwable()); // Leaf - Use commons-lang3
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@@ -205,8 +205,8 @@ public final class MCUtil {
|
|
||||||
* @return Stacktrace
|
|
||||||
*/
|
|
||||||
public static String stack(String str) {
|
|
||||||
- return ExceptionUtils.getFullStackTrace(new Throwable(str));
|
|
||||||
- }
|
|
||||||
+ return ExceptionUtils.getStackTrace(new Throwable(str));
|
|
||||||
+ } // Leaf - Use commons-lang3
|
|
||||||
|
|
||||||
public static long getCoordinateKey(final BlockPos blockPos) {
|
|
||||||
return ((long)(blockPos.getZ() >> 4) << 32) | ((blockPos.getX() >> 4) & 0xFFFFFFFFL);
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/util/ServerEnvironment.java b/src/main/java/io/papermc/paper/util/ServerEnvironment.java
|
|
||||||
index 148d233f4f5278ff39eacdaa0f4f0e7d73be936a..91eb919fd7465958bdd8cea8e8c18ee3480c0a71 100644
|
|
||||||
--- a/src/main/java/io/papermc/paper/util/ServerEnvironment.java
|
|
||||||
+++ b/src/main/java/io/papermc/paper/util/ServerEnvironment.java
|
|
||||||
@@ -2,7 +2,7 @@ package io.papermc.paper.util;
|
|
||||||
|
|
||||||
import com.sun.security.auth.module.NTSystem;
|
|
||||||
import com.sun.security.auth.module.UnixSystem;
|
|
||||||
-import org.apache.commons.lang.SystemUtils;
|
|
||||||
+import org.apache.commons.lang3.SystemUtils; // Leaf - Use commons-lang3
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/food/FoodData.java b/src/main/java/net/minecraft/world/food/FoodData.java
|
|
||||||
index e54af9ff2a786e919b8261aa27509be942e70261..29e5e752f65d19c55edf8eb9001c6b1457d47550 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/food/FoodData.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/food/FoodData.java
|
|
||||||
@@ -27,7 +27,7 @@ public class FoodData {
|
|
||||||
|
|
||||||
// CraftBukkit start - added EntityHuman constructor
|
|
||||||
public FoodData(Player entityhuman) {
|
|
||||||
- org.apache.commons.lang.Validate.notNull(entityhuman);
|
|
||||||
+ org.apache.commons.lang3.Validate.notNull(entityhuman); // Leaf - Use commons-lang3
|
|
||||||
this.entityhuman = entityhuman;
|
|
||||||
}
|
|
||||||
// CraftBukkit end
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftCampfire.java b/src/main/java/org/bukkit/craftbukkit/block/CraftCampfire.java
|
|
||||||
index eafba0532920a3162575dbe656e07734605590f5..64a3cae53997c3fe061c486299c6dd1d87ebd395 100644
|
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftCampfire.java
|
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCampfire.java
|
|
||||||
@@ -63,7 +63,7 @@ public class CraftCampfire extends CraftBlockEntityState<CampfireBlockEntity> im
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean stopCooking(int index) {
|
|
||||||
- org.apache.commons.lang.Validate.isTrue(-1 < index && index < 4, "Slot index must be between 0 (incl) to 3 (incl)");
|
|
||||||
+ org.apache.commons.lang3.Validate.isTrue(-1 < index && index < 4, "Slot index must be between 0 (incl) to 3 (incl)"); // Leaf - Use commons-lang3
|
|
||||||
boolean previous = this.isCookingDisabled(index);
|
|
||||||
getSnapshot().stopCooking[index] = true;
|
|
||||||
return previous;
|
|
||||||
@@ -71,7 +71,7 @@ public class CraftCampfire extends CraftBlockEntityState<CampfireBlockEntity> im
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean startCooking(int index) {
|
|
||||||
- org.apache.commons.lang.Validate.isTrue(-1 < index && index < 4, "Slot index must be between 0 (incl) to 3 (incl)");
|
|
||||||
+ org.apache.commons.lang3.Validate.isTrue(-1 < index && index < 4, "Slot index must be between 0 (incl) to 3 (incl)"); // Leaf - Use commons-lang3
|
|
||||||
boolean previous = this.isCookingDisabled(index);
|
|
||||||
getSnapshot().stopCooking[index] = false;
|
|
||||||
return previous;
|
|
||||||
@@ -79,7 +79,7 @@ public class CraftCampfire extends CraftBlockEntityState<CampfireBlockEntity> im
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCookingDisabled(int index) {
|
|
||||||
- org.apache.commons.lang.Validate.isTrue(-1 < index && index < 4, "Slot index must be between 0 (incl) to 3 (incl)");
|
|
||||||
+ org.apache.commons.lang3.Validate.isTrue(-1 < index && index < 4, "Slot index must be between 0 (incl) to 3 (incl)"); // Leaf - Use commons-lang3
|
|
||||||
return getSnapshot().stopCooking[index];
|
|
||||||
}
|
|
||||||
// Paper end
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java
|
|
||||||
index 492fdc855fe9735b614b6831aa5baaa6b252cfb6..498205a7eb265f56fc47f1f2ee6d0240880547e1 100644
|
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java
|
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java
|
|
||||||
@@ -86,7 +86,7 @@ public class CraftEnderDragon extends CraftMob implements EnderDragon, CraftEnem
|
|
||||||
if (location == null) {
|
|
||||||
this.getHandle().setPodium(null);
|
|
||||||
} else {
|
|
||||||
- org.apache.commons.lang.Validate.isTrue(location.getWorld() == null || location.getWorld().equals(getWorld()), "You cannot set a podium in a different world to where the dragon is");
|
|
||||||
+ org.apache.commons.lang3.Validate.isTrue(location.getWorld() == null || location.getWorld().equals(getWorld()), "You cannot set a podium in a different world to where the dragon is"); // Leaf - Use commons-lang3
|
|
||||||
this.getHandle().setPodium(io.papermc.paper.util.MCUtil.toBlockPos(location));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java b/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java
|
|
||||||
index 58ea78d3917d2f264515c41f4df2f9ff6f8e4667..89b721088e84f12f3aaf575022055b6e97f28eb9 100644
|
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java
|
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java
|
|
||||||
@@ -18,7 +18,7 @@ import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import net.minecraft.Util;
|
|
||||||
import net.minecraft.server.dedicated.DedicatedServer;
|
|
||||||
-import org.apache.commons.lang.StringUtils;
|
|
||||||
+import org.apache.commons.lang3.StringUtils; // Leaf - Use commons-lang3
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.configuration.serialization.SerializableAs;
|
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
|
||||||
diff --git a/src/main/java/org/dreeam/leaf/path/NodeEvaluatorCache.java b/src/main/java/org/dreeam/leaf/path/NodeEvaluatorCache.java
|
|
||||||
index 13e01a9ec678804a6e670c08d8757efea5fa0b8c..f0ff597679bd5dc3b1378188607e4bdfd4caa291 100644
|
|
||||||
--- a/src/main/java/org/dreeam/leaf/path/NodeEvaluatorCache.java
|
|
||||||
+++ b/src/main/java/org/dreeam/leaf/path/NodeEvaluatorCache.java
|
|
||||||
@@ -2,7 +2,7 @@ package org.dreeam.leaf.path;
|
|
||||||
|
|
||||||
import net.minecraft.world.level.pathfinder.NodeEvaluator;
|
|
||||||
|
|
||||||
-import org.apache.commons.lang.Validate;
|
|
||||||
+import org.apache.commons.lang3.Validate; // Leaf - Use commons-lang3
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
||||||
index 2056fc462ab11a86f17c630e868b70eea4f35553..5a1d9daba0db678446e1e8a0d63a9f0c2645cd21 100644
|
|
||||||
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
||||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
||||||
@@ -16,7 +16,7 @@ import org.purpurmc.purpur.tool.Strippable;
|
|
||||||
import org.purpurmc.purpur.tool.Tillable;
|
|
||||||
import org.purpurmc.purpur.tool.Waxable;
|
|
||||||
import org.purpurmc.purpur.tool.Weatherable;
|
|
||||||
-import org.apache.commons.lang.BooleanUtils;
|
|
||||||
+import org.apache.commons.lang3.BooleanUtils; // Leaf - Use commons-lang3
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
|
||||||
Date: Thu, 7 Sep 2023 06:21:32 -0400
|
|
||||||
Subject: [PATCH] Optimize explosions
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
|
|
||||||
index d3c20e4ae510028d25a05915e4662b03e6d0b128..fd195f38f239e322114a794e30b7f5032ac2c18c 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/Explosion.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
|
|
||||||
@@ -82,9 +82,11 @@ public class Explosion {
|
|
||||||
}
|
|
||||||
|
|
||||||
public Explosion(Level world, @Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Explosion.BlockInteraction destructionType) {
|
|
||||||
- this.random = world == null || world.random == null ? RandomSource.create() : world.random; // Gale - Patina - reduce RandomSource instances
|
|
||||||
- this.toBlow = new ObjectArrayList();
|
|
||||||
- this.hitPlayers = Maps.newHashMap();
|
|
||||||
+ // Leaf start - Optimize explosion
|
|
||||||
+ this.random = world == null || world.random == null ? RandomSource.createThreadSafe() : world.random; // Gale - Patina - reduce RandomSource instances
|
|
||||||
+ this.toBlow = new ObjectArrayList<>();
|
|
||||||
+ this.hitPlayers = Maps.newConcurrentMap();
|
|
||||||
+ // Leaf end
|
|
||||||
this.level = world;
|
|
||||||
this.source = entity;
|
|
||||||
this.radius = (float) (world == null || world.purpurConfig.explosionClampRadius ? Math.max(power, 0.0) : power); // CraftBukkit - clamp bad values // Purpur
|
|
||||||
@@ -425,7 +427,7 @@ public class Explosion {
|
|
||||||
//Purpur end
|
|
||||||
|
|
||||||
this.level.gameEvent(this.source, GameEvent.EXPLODE, new Vec3(this.x, this.y, this.z));
|
|
||||||
- Set<BlockPos> set = Sets.newHashSet();
|
|
||||||
+ Set<BlockPos> set = Sets.newConcurrentHashSet(); // Leaf - Optimize explosion - Use ConcurrentHashSet
|
|
||||||
boolean flag = true;
|
|
||||||
|
|
||||||
int i;
|
|
||||||
@@ -757,10 +759,7 @@ public class Explosion {
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.fire) {
|
|
||||||
- ObjectListIterator objectlistiterator1 = this.toBlow.iterator();
|
|
||||||
-
|
|
||||||
- while (objectlistiterator1.hasNext()) {
|
|
||||||
- BlockPos blockposition2 = (BlockPos) objectlistiterator1.next();
|
|
||||||
+ for (BlockPos blockposition2 : this.toBlow) {
|
|
||||||
|
|
||||||
if (this.random.nextInt(3) == 0 && this.level.getBlockState(blockposition2).isAir() && this.level.getBlockState(blockposition2.below()).isSolidRender(this.level, blockposition2.below())) {
|
|
||||||
// CraftBukkit start - Ignition by explosion
|
|
||||||
@@ -868,11 +867,7 @@ public class Explosion {
|
|
||||||
return this.getSeenFraction(vec3d, entity, blockCache, blockPos); // Paper - optimise explosions
|
|
||||||
}
|
|
||||||
CacheKey key = new CacheKey(this, entity.getBoundingBox());
|
|
||||||
- Float blockDensity = this.level.explosionDensityCache.get(key);
|
|
||||||
- if (blockDensity == null) {
|
|
||||||
- blockDensity = this.getSeenFraction(vec3d, entity, blockCache, blockPos); // Paper - optimise explosions;
|
|
||||||
- this.level.explosionDensityCache.put(key, blockDensity);
|
|
||||||
- }
|
|
||||||
+ Float blockDensity = this.level.explosionDensityCache.computeIfAbsent(key, k -> this.getSeenFraction(vec3d, entity, blockCache, blockPos)); // Paper - optimise explosions; // Leaf - Optimize explosion - Reduce cache key check load
|
|
||||||
|
|
||||||
return blockDensity;
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
|
||||||
index 275557da9faa7f27dd2fbfbdfbda620d4add0f8a..039a0f3af6907974031c2b568b396246aee201f9 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
|
||||||
@@ -3,11 +3,13 @@ package net.minecraft.world.level;
|
|
||||||
import com.destroystokyo.paper.event.server.ServerExceptionEvent;
|
|
||||||
import com.destroystokyo.paper.exception.ServerInternalException;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
+import com.google.common.collect.Maps;
|
|
||||||
import com.mojang.serialization.Codec;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
+import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
@@ -181,7 +183,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
|
||||||
private org.spigotmc.TickLimiter entityLimiter;
|
|
||||||
private org.spigotmc.TickLimiter tileLimiter;
|
|
||||||
private int tileTickPosition;
|
|
||||||
- public final Map<Explosion.CacheKey, Float> explosionDensityCache = new HashMap<>(); // Paper - Optimize explosions
|
|
||||||
+ public final Map<Explosion.CacheKey, Float> explosionDensityCache = Maps.newConcurrentMap(); // Paper - Optimize explosions // Leaf - Optimize explosion
|
|
||||||
public java.util.ArrayDeque<net.minecraft.world.level.block.RedstoneTorchBlock.Toggle> redstoneUpdateInfos; // Paper - Move from Map in BlockRedstoneTorch to here
|
|
||||||
|
|
||||||
public final io.papermc.paper.util.math.ThreadUnsafeRandom randomTickRandom = new io.papermc.paper.util.math.ThreadUnsafeRandom(this.random.nextLong()); // Gale - Pufferfish - move random tick random
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: rafaelflromao <12960698+rafaelflromao@users.noreply.github.com>
|
|
||||||
Date: Sat, 24 Jun 2023 13:53:38 +0100
|
|
||||||
Subject: [PATCH] JettPack Fix McDev Decomp
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/Brain.java b/src/main/java/net/minecraft/world/entity/ai/Brain.java
|
|
||||||
index dea20f16ac97402f754c8e47d03e9ef38de73190..9cdfe4c9d4487082c9b3577ff572675d9b8fc9b9 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/entity/ai/Brain.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/ai/Brain.java
|
|
||||||
@@ -72,16 +72,16 @@ public class Brain<E extends LivingEntity> {
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> DataResult<Brain<E>> decode(DynamicOps<T> dynamicOps, MapLike<T> mapLike) {
|
|
||||||
- MutableObject<DataResult<ImmutableList.Builder<Brain.MemoryValue<?>>>> mutableObject = new MutableObject<>(DataResult.success(ImmutableList.builder()));
|
|
||||||
+ MutableObject<DataResult<ImmutableList.Builder<Brain.MemoryValue<?>>>> decode_mutableObject = new MutableObject<>(DataResult.success(ImmutableList.builder())); // JettPack - decomp fix
|
|
||||||
mapLike.entries().forEach((pair) -> {
|
|
||||||
DataResult<MemoryModuleType<?>> dataResult = BuiltInRegistries.MEMORY_MODULE_TYPE.byNameCodec().parse(dynamicOps, pair.getFirst());
|
|
||||||
DataResult<? extends Brain.MemoryValue<?>> dataResult2 = dataResult.flatMap((memoryType) -> {
|
|
||||||
return this.captureRead(memoryType, dynamicOps, (T)pair.getSecond());
|
|
||||||
});
|
|
||||||
- mutableObject.setValue(mutableObject.getValue().apply2(ImmutableList.Builder::add, dataResult2));
|
|
||||||
+ decode_mutableObject.setValue(decode_mutableObject.getValue().apply2(ImmutableList.Builder::add, dataResult2)); // JettPack - decomp fix
|
|
||||||
});
|
|
||||||
- ImmutableList<Brain.MemoryValue<?>> immutableList = mutableObject.getValue().resultOrPartial(Brain.LOGGER::error).map(ImmutableList.Builder::build).orElseGet(ImmutableList::of);
|
|
||||||
- return DataResult.success(new Brain<>(memoryModules, sensors, immutableList, mutableObject::getValue));
|
|
||||||
+ ImmutableList<Brain.MemoryValue<?>> immutableList = decode_mutableObject.getValue().resultOrPartial(Brain.LOGGER::error).map(ImmutableList.Builder::build).orElseGet(ImmutableList::of); // JettPack - decomp fix
|
|
||||||
+ return DataResult.success(new Brain<E>(memoryModules, sensors, immutableList, mutableObject::getValue)); // JettPack - decomp fix
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T, U> DataResult<Brain.MemoryValue<U>> captureRead(MemoryModuleType<U> memoryType, DynamicOps<T> ops, T value) {
|
|
||||||
@@ -135,7 +135,7 @@ public class Brain<E extends LivingEntity> {
|
|
||||||
|
|
||||||
Stream<Brain.MemoryValue<?>> memories() {
|
|
||||||
return this.memories.entrySet().stream().map((entry) -> {
|
|
||||||
- return Brain.MemoryValue.createUnchecked(entry.getKey(), entry.getValue());
|
|
||||||
+ return Brain.MemoryValue.createUnchecked((MemoryModuleType)entry.getKey(), (Optional)entry.getValue()); // JettPack - decomp fix
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -181,14 +181,14 @@ public class Brain<E extends LivingEntity> {
|
|
||||||
if (optional == null) {
|
|
||||||
throw new IllegalStateException("Unregistered memory fetched: " + type);
|
|
||||||
} else {
|
|
||||||
- return optional.map(ExpirableValue::getValue);
|
|
||||||
+ return (Optional<U>) optional.map(object -> ((ExpirableValue)object).getValue()); // JettPack - decomp fix
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public <U> Optional<U> getMemoryInternal(MemoryModuleType<U> type) {
|
|
||||||
Optional<? extends ExpirableValue<?>> optional = this.memories.get(type);
|
|
||||||
- return optional == null ? null : optional.map(ExpirableValue::getValue);
|
|
||||||
+ return optional == null ? null : (Optional<U>) optional.map(ExpirableValue::getValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
public <U> long getTimeUntilExpiry(MemoryModuleType<U> type) {
|
|
||||||
@@ -371,7 +371,7 @@ public class Brain<E extends LivingEntity> {
|
|
||||||
}
|
|
||||||
|
|
||||||
public Brain<E> copyWithoutBehaviors() {
|
|
||||||
- Brain<E> brain = new Brain<>(this.memories.keySet(), this.sensors.keySet(), ImmutableList.of(), this.codec);
|
|
||||||
+ Brain<E> brain = new Brain<E>(this.memories.keySet(), this.sensors. keySet(), ImmutableList.of(), this.codec); // JettPack - decomp fix
|
|
||||||
|
|
||||||
for(Map.Entry<MemoryModuleType<?>, Optional<? extends ExpirableValue<?>>> entry : this.memories.entrySet()) {
|
|
||||||
MemoryModuleType<?> memoryModuleType = entry.getKey();
|
|
||||||
@@ -482,8 +482,8 @@ public class Brain<E extends LivingEntity> {
|
|
||||||
private final MemoryModuleType<U> type;
|
|
||||||
private final Optional<? extends ExpirableValue<U>> value;
|
|
||||||
|
|
||||||
- static <U> Brain.MemoryValue<U> createUnchecked(MemoryModuleType<U> type, Optional<? extends ExpirableValue<?>> data) {
|
|
||||||
- return new Brain.MemoryValue<>(type, data);
|
|
||||||
+ static <U> Brain.MemoryValue<U> createUnchecked(MemoryModuleType<U> type, Optional<? extends ExpirableValue<U>> data) { // JettPack - decomp fix
|
|
||||||
+ return new Brain.MemoryValue<U>(type, data); // JettPack - decomp fix
|
|
||||||
}
|
|
||||||
|
|
||||||
MemoryValue(MemoryModuleType<U> type, Optional<? extends ExpirableValue<U>> data) {
|
|
||||||
Reference in New Issue
Block a user