Fix warning screen about missing minecraft registry entries (#6363)
This commit is contained in:
parent
47a1f7529a
commit
83ebdcd8f2
1 changed files with 24 additions and 0 deletions
|
@ -19,6 +19,7 @@
|
|||
|
||||
package net.minecraftforge.common;
|
||||
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.*;
|
||||
|
@ -71,6 +72,9 @@ import net.minecraftforge.fml.common.Mod;
|
|||
import org.apache.logging.log4j.Marker;
|
||||
import org.apache.logging.log4j.MarkerManager;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Mod("forge")
|
||||
public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook
|
||||
{
|
||||
|
@ -97,6 +101,7 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook
|
|||
modEventBus.register(this);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::serverStarting);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::serverStopping);
|
||||
MinecraftForge.EVENT_BUS.addGenericListener(SoundEvent.class, this::missingSoundMapping);
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, ForgeConfig.clientSpec);
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, ForgeConfig.serverSpec);
|
||||
modEventBus.register(ForgeConfig.class);
|
||||
|
@ -177,6 +182,25 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook
|
|||
}
|
||||
}
|
||||
|
||||
public void missingSoundMapping(RegistryEvent.MissingMappings<SoundEvent> event)
|
||||
{
|
||||
//Removed in 1.15, see https://minecraft.gamepedia.com/Parrot#History
|
||||
List<String> removedSounds = Arrays.asList("entity.parrot.imitate.panda", "entity.parrot.imitate.zombie_pigman", "entity.parrot.imitate.enderman", "entity.parrot.imitate.polar_bear", "entity.parrot.imitate.wolf");
|
||||
for (RegistryEvent.MissingMappings.Mapping<SoundEvent> mapping : event.getAllMappings())
|
||||
{
|
||||
ResourceLocation regName = mapping.key;
|
||||
if (regName != null && regName.getNamespace().equals("minecraft"))
|
||||
{
|
||||
String path = regName.getPath();
|
||||
if (removedSounds.stream().anyMatch(s -> s.equals(path)))
|
||||
{
|
||||
LOGGER.info("Ignoring removed minecraft sound {}", regName);
|
||||
mapping.ignore();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent //ModBus, can't use addListener due to nested genetics.
|
||||
public void registerRecipeSerialziers(RegistryEvent.Register<IRecipeSerializer<?>> event)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue