Yatopia/patches/server/0016-lithium-MixinLandPathNodeMaker.patch
Ivan Pekov 5f55124016
Initial 1.16.2 support
This update had major internal changes, which took us 8 hours to figure out and resolve all things untill we have a successful build.
YatopiaMC members wish you happy playing using Yatopia for your server software

MAKE A BACKUP OF YOUR WORLD BEFORE RUNNING IT ON YOUR SERVER. YOU HAVE BEEN WARNED.
People have reported to paper that after upgrading villagers are gone. There could be even more issues we are unknown of.
MAKE A BACKUP OF YOUR WORLD BEFORE RUNNING IT ON YOUR SERVER. YOU HAVE BEEN WARNED.

Co-authored-by: Ovydux <68059159+Ovydux@users.noreply.github.com>
Co-authored-by: Simon Gardling <Titaniumtown@gmail.com>
Co-authored-by: budgidiere <sgidiere@gmail.com>
2020-08-13 18:53:32 +03:00

93 lines
4.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: JellySquid <jellysquid+atwork@protonmail.com>
Date: Mon, 11 May 2020 22:56:27 +0200
Subject: [PATCH] lithium MixinLandPathNodeMaker
Original code by JellySquid, licensed under GNU Lesser General Public License v3.0
you can find the original code on https://github.com/jellysquid3/lithium-fabric/tree/1.16.x/fabric (Yarn mappings)
diff --git a/src/main/java/net/minecraft/server/PathfinderNormal.java b/src/main/java/net/minecraft/server/PathfinderNormal.java
index 9caf6598f8a267ce057e863a32ee29fa5fdb0641..56da391b4d415630b881cccbaa50507eb2c23cc0 100644
--- a/src/main/java/net/minecraft/server/PathfinderNormal.java
+++ b/src/main/java/net/minecraft/server/PathfinderNormal.java
@@ -7,9 +7,15 @@ import it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap;
import java.util.EnumSet;
import java.util.Iterator;
import javax.annotation.Nullable;
+import it.unimi.dsi.fastutil.objects.Reference2ReferenceMap; // Yatopia
+import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap; // Yatopia
public class PathfinderNormal extends PathfinderAbstract {
+ // Yatopia start - this is not thread safe!
+ private static final Reference2ReferenceMap<IBlockData, PathType> commonTypes = new Reference2ReferenceOpenHashMap<>();
+ // Yatopia end
+
protected float j;
private final Long2ObjectMap<PathType> k = new Long2ObjectOpenHashMap();
private final Object2BooleanMap<AxisAlignedBB> l = new Object2BooleanOpenHashMap();
@@ -490,9 +496,22 @@ public class PathfinderNormal extends PathfinderAbstract {
protected static PathType b(IBlockAccess iblockaccess, BlockPosition blockposition) {
IBlockData iblockdata = iblockaccess.getTypeIfLoaded(blockposition); // Paper
if (iblockdata == null) return PathType.BLOCKED; // Paper
- Block block = iblockdata.getBlock();
- Material material = iblockdata.getMaterial();
+ // Yatopia start - replaced logic
+ //Block block = iblockdata.getBlock();
+ //Material material = iblockdata.getMaterial();
+ if (iblockdata.isAir()) return PathType.OPEN;
+ PathType type = commonTypes.get(iblockdata);
+ if (type == null) {
+ commonTypes.put(iblockdata, type = getPathType(iblockdata));
+ }
+ if (type == PathType.OPEN) {
+ if (!iblockdata.a(iblockaccess, blockposition, PathMode.LAND)) {
+ return PathType.BLOCKED;
+ }
+ }
+
+ /*
if (iblockdata.isAir()) {
return PathType.OPEN;
} else if (!iblockdata.a((Tag) TagsBlock.TRAPDOORS) && !iblockdata.a(Blocks.LILY_PAD)) {
@@ -512,7 +531,38 @@ public class PathfinderNormal extends PathfinderAbstract {
} else {
return PathType.TRAPDOOR;
}
+ */
+ return type;
+ // Yatopia end
+ }
+
+ // Yatopia start
+ private static PathType getPathType(IBlockData iblockdata) {
+ Block block = iblockdata.getBlock();
+ if (!block.a(TagsBlock.TRAPDOORS) && block != Blocks.LILY_PAD) {
+ if (block == Blocks.FIRE) {
+ return PathType.DAMAGE_FIRE;
+ } else if (block == Blocks.CACTUS) {
+ return PathType.DAMAGE_CACTUS;
+ } else if (iblockdata.a(Blocks.SWEET_BERRY_BUSH)) {
+ return PathType.DAMAGE_OTHER;
+ } else if (iblockdata.a(Blocks.HONEY_BLOCK)) {
+ return PathType.STICKY_HONEY;
+ } else if (iblockdata.a(Blocks.COCOA)) {
+ return PathType.COCOA;
+ } else {
+ Fluid fluid = iblockdata.getFluid(); // Tuinity - remove another get type call
+
+ if (fluid.a(TagsFluid.WATER)) return PathType.WATER;
+ if (fluid.a(TagsFluid.LAVA)) return PathType.LAVA;
+
+ return PathType.OPEN;
+ }
+ } else {
+ return PathType.TRAPDOOR;
+ }
}
+ // Yatopia end
private static boolean a(IBlockData iblockdata) {
return iblockdata.a((Tag) TagsBlock.FIRE) || iblockdata.a(Blocks.LAVA) || iblockdata.a(Blocks.MAGMA_BLOCK) || BlockCampfire.g(iblockdata);