mirror of
https://github.com/PaperMC/Folia.git
synced 2024-11-25 12:35:23 +01:00
4a59238743
Very early build, network configuration switching is supported but not tested (note: changes need to be backported to Paper) Changes: - Supports per player mob caps - Adds entity tracker optimisations which are not in Paper (and will not be ported to Paper due to plugin conflicts) - No longer reverts paper distance map optimisations, as those are replaced by the NearbyPlayers class These changes should bring Folia in-line with Paper's optimisations at least (probably more given the entity tracker optimisations), still missing features like world loading / some commands
56 lines
3.7 KiB
Diff
56 lines
3.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
Date: Fri, 31 Mar 2023 20:40:28 -0700
|
|
Subject: [PATCH] MC-Dev fixes
|
|
|
|
|
|
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..21e5d1451f90194aa415cf0a183d1a731854f605 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/Brain.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/Brain.java
|
|
@@ -72,15 +72,15 @@ 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<?>>>> mutableObject2 = new MutableObject<>(DataResult.success(ImmutableList.builder())); // Folia - decompile 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));
|
|
+ mutableObject2.setValue(mutableObject2.getValue().apply2(ImmutableList.Builder::add, dataResult2)); // Folia - decompile fix
|
|
});
|
|
- ImmutableList<Brain.MemoryValue<?>> immutableList = mutableObject.getValue().resultOrPartial(Brain.LOGGER::error).map(ImmutableList.Builder::build).orElseGet(ImmutableList::of);
|
|
+ ImmutableList<Brain.MemoryValue<?>> immutableList = mutableObject2.getValue().resultOrPartial(Brain.LOGGER::error).map(ImmutableList.Builder::build).orElseGet(ImmutableList::of); // Folia - decompile fix
|
|
return DataResult.success(new Brain<>(memoryModules, sensors, immutableList, mutableObject::getValue));
|
|
}
|
|
|
|
@@ -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(ExpirableValue::getValue); // Folia - decompile 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); // Folia - decompile fix
|
|
}
|
|
|
|
public <U> long getTimeUntilExpiry(MemoryModuleType<U> type) {
|
|
@@ -483,7 +483,7 @@ public class Brain<E extends LivingEntity> {
|
|
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);
|
|
+ return new Brain.MemoryValue<>(type, (Optional<? extends ExpirableValue<U>>)data); // Folia - decompile fix
|
|
}
|
|
|
|
MemoryValue(MemoryModuleType<U> type, Optional<? extends ExpirableValue<U>> data) {
|