Fix BrandingControl caching text through resource reload
This commit is contained in:
parent
98a470d813
commit
98ef5049f4
2 changed files with 21 additions and 0 deletions
|
@ -20,6 +20,8 @@
|
|||
package net.minecraftforge.common;
|
||||
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.BrandingControl;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.FMLWorldPersistenceHook;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.VersionChecker;
|
||||
|
@ -39,13 +41,17 @@ import net.minecraftforge.versions.mcp.MCPVersion;
|
|||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.resources.SimpleReloadableResourceManager;
|
||||
import net.minecraft.world.storage.SaveHandler;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.common.model.animation.CapabilityAnimation;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.resource.ISelectiveResourceReloadListener;
|
||||
import net.minecraftforge.fluids.UniversalBucket;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
|
||||
|
@ -128,6 +134,9 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook
|
|||
{
|
||||
VersionChecker.startVersionCheck();
|
||||
}
|
||||
|
||||
// Brandings need to recompute when language changes
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> ((SimpleReloadableResourceManager)Minecraft.getInstance().getResourceManager()).addReloadListener((ISelectiveResourceReloadListener) BrandingControl::clearCaches));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -21,11 +21,16 @@ package net.minecraftforge.fml;
|
|||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraftforge.resource.IResourceType;
|
||||
import net.minecraftforge.resource.VanillaResourceType;
|
||||
import net.minecraftforge.versions.forge.ForgeVersion;
|
||||
import net.minecraftforge.versions.mcp.MCPVersion;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class BrandingControl
|
||||
|
@ -70,4 +75,11 @@ public class BrandingControl
|
|||
public static String getServerBranding() {
|
||||
return "forge";
|
||||
}
|
||||
|
||||
public static void clearCaches(IResourceManager resourceManager, Predicate<IResourceType> resourcePredicate) {
|
||||
if (resourcePredicate.test(VanillaResourceType.LANGUAGES)) {
|
||||
brandings = null;
|
||||
brandingsNoMC = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue