Fix a few minor issues with custom tag types and fix OptionalNamedTags (#7316)

This commit is contained in:
Richard Freimer authored and GitHub committed 2020-09-23 20:12:11 -07:00
1 parent 37be3aff2d
commit af75547d37
18 files changed
+258 -114

No files matched your search

@@ -195,10 +195,10 @@ public class ModLoader
dispatchAndHandleError(ModLoadingStage.CREATE_REGISTRIES, syncExecutor, parallelExecutor, periodicTask);
ObjectHolderRegistry.findObjectHolders();
CapabilityManager.INSTANCE.injectCapabilities(modList.getAllScanData());
statusConsumer.ifPresent(c->c.accept("Populating registries"));
dispatchAndHandleError(ModLoadingStage.LOAD_REGISTRIES, syncExecutor, parallelExecutor, periodicTask);
statusConsumer.ifPresent(c->c.accept("Adding custom tag types"));
GameData.setCustomTagTypesFromRegistries();
statusConsumer.ifPresent(c->c.accept("Populating registries"));
dispatchAndHandleError(ModLoadingStage.LOAD_REGISTRIES, syncExecutor, parallelExecutor, periodicTask);
statusConsumer.ifPresent(c->c.accept("Early mod loading complete"));
}
@@ -26,7 +26,6 @@ import com.google.common.collect.Multimap;
import io.netty.buffer.Unpooled;
import java.util.List;
import java.util.Map;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.IHasContainer;
import net.minecraft.client.gui.ScreenManager;
@@ -34,10 +33,8 @@ import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.fluid.Fluid;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.item.Item;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tags.ITag;
import net.minecraft.tags.ITagCollection;
@@ -414,39 +411,8 @@ public class FMLPlayMessages
// to the last working set of tags
//Note: We gracefully ignore any tag types the server may have that we don't as they won't be in our tag registry
// so they won't be validated
Multimap<ResourceLocation, ResourceLocation> missingTags = TagRegistryManager.func_242198_b(new ITagCollectionSupplier()
{
@Override
public ITagCollection<Block> func_241835_a()
{
return tagCollectionSupplier.func_241835_a();
}
@Override
public ITagCollection<Item> func_241836_b()
{
return tagCollectionSupplier.func_241836_b();
}
@Override
public ITagCollection<Fluid> func_241837_c()
{
return tagCollectionSupplier.func_241837_c();
}
@Override
public ITagCollection<EntityType<?>> func_241838_d()
{
return tagCollectionSupplier.func_241838_d();
}
@Override
public Map<ResourceLocation, ITagCollection<?>> getCustomTagTypes()
{
//Override and use the tags from the packet to test for validation before we actually set them
return msg.customTagTypeCollections;
}
});
//Override and use the tags from the packet to test for validation before we actually set them
Multimap<ResourceLocation, ResourceLocation> missingTags = TagRegistryManager.func_242198_b(ForgeTagHandler.withSpecificCustom(tagCollectionSupplier, msg.customTagTypeCollections));
if (missingTags.isEmpty())
{
//If we have no missing tags, update the custom tag types
@@ -119,9 +119,14 @@ public class NetworkHooks
FMLNetworkConstants.playChannel.sendTo(new FMLPlayMessages.DimensionInfoMessage(player.dimension), manager, NetworkDirection.PLAY_TO_CLIENT);
}*/
public static void handleClientLoginSuccess(NetworkManager manager) {
public static boolean isVanillaConnection(NetworkManager manager)
{
if (manager == null || manager.channel() == null) throw new NullPointerException("ARGH! Network Manager is null (" + manager != null ? "CHANNEL" : "MANAGER"+")" );
if (getConnectionType(()->manager) == ConnectionType.VANILLA) {
return getConnectionType(() -> manager) == ConnectionType.VANILLA;
}
public static void handleClientLoginSuccess(NetworkManager manager) {
if (isVanillaConnection(manager)) {
LOGGER.info("Connected to a vanilla server. Catching up missing behaviour.");
ConfigTracker.INSTANCE.loadDefaultServerConfigs();
} else {