Files
Tenet/patches/cpw/mods/fml/common/FMLCommonHandler.java.patch
2020-10-30 11:35:16 +08:00

86 lines
3.3 KiB
Diff

--- ../src-base/minecraft/cpw/mods/fml/common/FMLCommonHandler.java
+++ ../src-work/minecraft/cpw/mods/fml/common/FMLCommonHandler.java
@@ -31,12 +31,17 @@
import net.minecraft.network.INetHandler;
import net.minecraft.network.NetworkManager;
import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.management.ServerConfigurationManager;
import net.minecraft.world.World;
import net.minecraft.world.storage.SaveHandler;
import net.minecraft.world.storage.WorldInfo;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.entity.Player;
+import org.bukkit.event.player.PlayerChangedWorldEvent;
import com.google.common.base.Joiner;
import com.google.common.base.Strings;
@@ -151,13 +156,7 @@
*/
public Side getEffectiveSide()
{
- Thread thr = Thread.currentThread();
- if ((thr.getName().equals("Server thread")))
- {
- return Side.SERVER;
- }
-
- return Side.CLIENT;
+ return Side.SERVER;
}
/**
* Raise an exception
@@ -385,10 +384,11 @@
{
return;
}
- if (handlerSet.contains(handler))
+ if (handlerSet.contains(handler) || worldInfo.getDimension() != 0) // Cauldron - Only check FML data in main world
{
return;
}
+ // Cauldron - logic below should only be run for overworld as Forge/Vanilla only use 1 SaveHandler
handlerSet.add(handler);
handlerToCheck = new WeakReference<SaveHandler>(handler); // for confirmBackupLevelDatUse
Map<String,NBTBase> additionalProperties = Maps.newHashMap();
@@ -496,7 +496,13 @@
public String getModName()
{
- List<String> modNames = Lists.newArrayListWithExpectedSize(3);
+ // Cauldron start
+ List<String> modNames = Lists.newArrayListWithExpectedSize(6);
+ modNames.add("cauldron");
+ modNames.add("craftbukkit");
+ modNames.add("mcpc");
+ modNames.add("mohist");
+ // Cauldron end
modNames.add("fml");
if (!noForge)
{
@@ -540,8 +546,21 @@
bus().post(new InputEvent.KeyInputEvent());
}
+ // Cauldron start - wrapper to notify plugins for mods that bypass ServerConfigurationManager
public void firePlayerChangedDimensionEvent(EntityPlayer player, int fromDim, int toDim)
{
+ // Thermos - (Robotia) Ok so turns out whoever wrote this bit didn't get enough sleep.
+ // It should've gotten the dim from the fromDim ID, not the player world.
+ // The player world returns the world the player is in after transfer...!
+ // It should be fine now though.
+ this.firePlayerChangedDimensionEvent(player, fromDim, toDim, MinecraftServer.getServer().worldServerForDimension(fromDim).getWorld());
+ }
+
+ public void firePlayerChangedDimensionEvent(EntityPlayer player, int fromDim, int toDim, CraftWorld fromWorld)
+ {
+ PlayerChangedWorldEvent event = new PlayerChangedWorldEvent((Player) player.getBukkitEntity(), fromWorld);
+ Bukkit.getServer().getPluginManager().callEvent(event);
+ // Cauldron end
bus().post(new PlayerEvent.PlayerChangedDimensionEvent(player, fromDim, toDim));
}