mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2026-01-06 15:51:31 +00:00
78 lines
5.1 KiB
Diff
78 lines
5.1 KiB
Diff
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) {
|