mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-11-14 22:56:29 +01:00
c09ee99f7e
Closes #257 Ports 2 patches from Purpur: Infinity-bow-settings & Allow-infinite-and-mending-enchantments-together Added an option for infinity with no arrows too. Option for custom locale has come! You can put a locale.json file in your server folder to change it. We've got the finest patches from Hydrinity ( Mykyta approved & allowed ) too. We have some amazing new options in yatopia.yml, we're gonna have documentation for them soon so stay tuned! Last but not least, chunk generation patches. We've tested them extensively so no weirdness happens. Thanks for using Yatopia as your production server software. Co-authored-by: Ivan Pekov <ivan@mrivanplays.com>
110 lines
6.6 KiB
Diff
110 lines
6.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: MrIvanPlays <ivan@mrivanplays.com>
|
|
Date: Sun, 9 Aug 2020 22:27:52 +0300
|
|
Subject: [PATCH] Optimize BehaviorController
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/BehaviorController.java b/src/main/java/net/minecraft/server/BehaviorController.java
|
|
index ae2905b403a63396d9cdc61444586ea5548f2974..6b8da8303a19bbd65a4b38c664c49a6a8ac646a4 100644
|
|
--- a/src/main/java/net/minecraft/server/BehaviorController.java
|
|
+++ b/src/main/java/net/minecraft/server/BehaviorController.java
|
|
@@ -53,13 +53,16 @@ public class BehaviorController<E extends EntityLiving> {
|
|
|
|
mutableobject.setValue((new MapCodec<BehaviorController<E>>() {
|
|
public <T> Stream<T> keys(DynamicOps<T> dynamicops) {
|
|
- return collection.stream().flatMap((memorymoduletype) -> {
|
|
- return SystemUtils.a(memorymoduletype.getSerializer().map((codec) -> {
|
|
- return IRegistry.MEMORY_MODULE_TYPE.getKey(memorymoduletype);
|
|
- }));
|
|
- }).map((minecraftkey) -> {
|
|
- return dynamicops.createString(minecraftkey.toString());
|
|
- });
|
|
+ // Yatopia start
|
|
+ // about previous impl: WHY ? WHO DID THIS TO YOU?
|
|
+ Collection<T> candidates = new net.yatopia.server.list.GlueList<>();
|
|
+ for (MemoryModuleType<?> moduleType : collection) {
|
|
+ moduleType.getSerializer()
|
|
+ .map(c -> IRegistry.MEMORY_MODULE_TYPE.getKey(moduleType))
|
|
+ .ifPresent(key -> candidates.add(dynamicops.createString(key.toString())));
|
|
+ }
|
|
+ return candidates.stream();
|
|
+ // Yatopia end
|
|
}
|
|
|
|
public <T> DataResult<BehaviorController<E>> decode(DynamicOps<T> dynamicops, MapLike<T> maplike) {
|
|
@@ -71,23 +74,17 @@ public class BehaviorController<E extends EntityLiving> {
|
|
return this.a(memorymoduletype, dynamicops, pair.getSecond());
|
|
});
|
|
|
|
- mutableobject1.setValue(((DataResult) mutableobject1.getValue()).apply2(Builder::add, dataresult1));
|
|
+ mutableobject1.setValue((mutableobject1.getValue()).apply2(Builder::add, dataresult1)); // Yatopia - decompile fix
|
|
});
|
|
- DataResult dataresult = (DataResult) mutableobject1.getValue();
|
|
- Logger logger = BehaviorController.LOGGER;
|
|
+ DataResult<ImmutableList.Builder<BehaviorController.a<?>>> dataresult = mutableobject1.getValue(); // Yatopia - decompile fix
|
|
|
|
- logger.getClass();
|
|
- ImmutableList<BehaviorController.a<?>> immutablelist = (ImmutableList) dataresult.resultOrPartial(logger::error).map(Builder::build).orElseGet(ImmutableList::of);
|
|
- Collection collection2 = collection;
|
|
- Collection collection3 = collection1;
|
|
- MutableObject mutableobject2 = mutableobject;
|
|
+ ImmutableList<BehaviorController.a<?>> immutablelist = dataresult.resultOrPartial(BehaviorController.LOGGER::error).map(Builder::build).orElseGet(ImmutableList::of); // Yatopia - decompile fix
|
|
|
|
- mutableobject.getClass();
|
|
- return DataResult.success(new BehaviorController<>(collection2, collection3, immutablelist, mutableobject2::getValue));
|
|
+ return DataResult.success(new BehaviorController<>(collection, collection1, immutablelist, mutableobject::getValue)); // Yatopia - decompile fix
|
|
}
|
|
|
|
private <T, U> DataResult<BehaviorController.a<U>> a(MemoryModuleType<U> memorymoduletype, DynamicOps<T> dynamicops, T t0) {
|
|
- return ((DataResult) memorymoduletype.getSerializer().map(DataResult::success).orElseGet(() -> {
|
|
+ return (memorymoduletype.getSerializer().map(DataResult::success).orElseGet(() -> { // Yatopia - decompile fix
|
|
return DataResult.error("No codec for memory: " + memorymoduletype);
|
|
})).flatMap((codec) -> {
|
|
return codec.parse(dynamicops, t0);
|
|
@@ -97,9 +94,9 @@ public class BehaviorController<E extends EntityLiving> {
|
|
}
|
|
|
|
public <T> RecordBuilder<T> encode(BehaviorController<E> behaviorcontroller, DynamicOps<T> dynamicops, RecordBuilder<T> recordbuilder) {
|
|
- behaviorcontroller.j().forEach((behaviorcontroller_a) -> {
|
|
+ for (BehaviorController.a<?> behaviorcontroller_a : behaviorcontroller.memoriesList()) { // Yatopia
|
|
behaviorcontroller_a.a(dynamicops, recordbuilder);
|
|
- });
|
|
+ } // Yatopia
|
|
return recordbuilder;
|
|
}
|
|
}).fieldOf("memories").codec());
|
|
@@ -158,6 +155,15 @@ public class BehaviorController<E extends EntityLiving> {
|
|
return ((Codec) this.b.get()).encodeStart(dynamicops, this);
|
|
}
|
|
|
|
+ // Yatopia start
|
|
+ private List<BehaviorController.a<?>> memoriesList() {
|
|
+ List<BehaviorController.a<?>> ret = new net.yatopia.server.list.GlueList<>();
|
|
+ for (Map.Entry<MemoryModuleType<?>, Optional<? extends ExpirableMemory<?>>> entry : memories.entrySet()) {
|
|
+ ret.add(BehaviorController.a.b(entry.getKey(), (Optional) entry.getValue()));
|
|
+ }
|
|
+ return ret;
|
|
+ }
|
|
+ // Yatopia end
|
|
private Stream<BehaviorController.a<?>> j() {
|
|
return this.memories.entrySet().stream().map((entry) -> {
|
|
return BehaviorController.a.b((MemoryModuleType) entry.getKey(), (Optional) entry.getValue());
|
|
@@ -196,7 +202,7 @@ public class BehaviorController<E extends EntityLiving> {
|
|
}
|
|
|
|
public <U> Optional<U> getMemory(MemoryModuleType<U> memorymoduletype) {
|
|
- return ((Optional) this.memories.get(memorymoduletype)).map(ExpirableMemory::c);
|
|
+ return (Optional<U>) this.memories.get(memorymoduletype).map(ExpirableMemory::c); // Yatopia - Decompile fix
|
|
}
|
|
|
|
public <U> boolean b(MemoryModuleType<U> memorymoduletype, U u0) {
|
|
@@ -535,7 +541,7 @@ public class BehaviorController<E extends EntityLiving> {
|
|
private final MemoryModuleType<U> a;
|
|
private final Optional<? extends ExpirableMemory<U>> b;
|
|
|
|
- private static <U> BehaviorController.a<U> b(MemoryModuleType<U> memorymoduletype, Optional<? extends ExpirableMemory<?>> optional) {
|
|
+ private static <U> BehaviorController.a<U> b(MemoryModuleType<U> memorymoduletype, Optional<? extends ExpirableMemory<U>> optional) { // Yatopia - decompile fix
|
|
return new BehaviorController.a<>(memorymoduletype, optional);
|
|
}
|
|
|