From 0e1ed8c9368807f855dc554175a0a1e017b54b4d Mon Sep 17 00:00:00 2001 From: ichttt Date: Tue, 8 Sep 2020 21:25:48 +0200 Subject: [PATCH] Reimplement FarmlandWaterManager (#7213) --- .../minecraftforge/common/FarmlandWaterManager.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/minecraftforge/common/FarmlandWaterManager.java b/src/main/java/net/minecraftforge/common/FarmlandWaterManager.java index 27a105b97..01ef216aa 100644 --- a/src/main/java/net/minecraftforge/common/FarmlandWaterManager.java +++ b/src/main/java/net/minecraftforge/common/FarmlandWaterManager.java @@ -21,8 +21,6 @@ package net.minecraftforge.common; import com.google.common.base.Preconditions; import com.google.common.collect.MapMaker; -import it.unimi.dsi.fastutil.ints.Int2ObjectMap; -import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; @@ -36,15 +34,15 @@ import net.minecraftforge.common.ticket.SimpleTicket; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import java.util.Collections; import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.WeakHashMap; public class FarmlandWaterManager { - private static boolean DEBUG = Boolean.parseBoolean(System.getProperty("forge.debugFarmlandWaterManager", "false")); - private static final Int2ObjectMap>> customWaterHandler = new Int2ObjectOpenHashMap<>(); + private static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("forge.debugFarmlandWaterManager", "false")); + private static final Map>> customWaterHandler = new WeakHashMap<>(); private static final Logger LOGGER = LogManager.getLogger(); /** @@ -63,7 +61,7 @@ public class FarmlandWaterManager public static> T addCustomTicket(World world, T ticket, ChunkPos masterChunk, ChunkPos... additionalChunks) { Preconditions.checkArgument(!world.isRemote, "Water region is only determined server-side"); - Map> ticketMap = Collections.emptyMap();// customWaterHandler.computeIfAbsent(world.getDimension().getType().getId(), id -> new MapMaker().weakValues().makeMap()); //TODO Dimensions + Map> ticketMap = customWaterHandler.computeIfAbsent(world, id -> new MapMaker().weakValues().makeMap()); ChunkTicketManager[] additionalTickets = new ChunkTicketManager[additionalChunks.length]; for (int i = 0; i < additionalChunks.length; i++) additionalTickets[i] = ticketMap.computeIfAbsent(additionalChunks[i], ChunkTicketManager::new); @@ -160,7 +158,7 @@ public class FarmlandWaterManager private static ChunkTicketManager getTicketManager(ChunkPos pos, IWorldReader world) { Preconditions.checkArgument(!world.isRemote(), "Water region is only determined server-side"); - Map> ticketMap = Collections.emptyMap();//customWaterHandler.get(world.getDimension().getType().getId()); //TODO Dimensions + Map> ticketMap = customWaterHandler.get(world); if (ticketMap == null) { return null;