Skip to content

Commit

Permalink
Remove structures slave map to Feature registry (MinecraftForge#9091)
Browse files Browse the repository at this point in the history
  • Loading branch information
sciwhiz12 authored Oct 21, 2022
1 parent 8980252 commit 8f407c3
Showing 1 changed file with 4 additions and 21 deletions.
25 changes: 4 additions & 21 deletions src/main/java/net/minecraftforge/registries/GameData.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.levelgen.DebugLevelSource;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.Material;
import net.minecraftforge.common.ForgeHooks;
Expand All @@ -54,6 +53,7 @@
import org.apache.commons.lang3.Validate;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;

import java.util.Collection;
Expand All @@ -75,6 +75,7 @@
* INTERNAL ONLY
* MODDERS SHOULD HAVE NO REASON TO USE THIS CLASS
*/
@ApiStatus.Internal
public class GameData
{
private static final Logger LOGGER = LogManager.getLogger();
Expand All @@ -83,7 +84,6 @@ public class GameData
private static final ResourceLocation BLOCK_TO_ITEM = new ResourceLocation("minecraft:blocktoitemmap");
private static final ResourceLocation BLOCKSTATE_TO_ID = new ResourceLocation("minecraft:blockstatetoid");
private static final ResourceLocation BLOCKSTATE_TO_POINT_OF_INTEREST_TYPE = new ResourceLocation("minecraft:blockstatetopointofinteresttype");
private static final ResourceLocation STRUCTURES = new ResourceLocation("minecraft:structures");

private static boolean hasInit = false;
private static final boolean DISABLE_VANILLA_REGISTRIES = Boolean.parseBoolean(System.getProperty("forge.disableVanillaGameData", "false")); // Use for unit tests/debugging
Expand Down Expand Up @@ -133,7 +133,7 @@ public static void init()

// Worldgen
makeRegistry(WORLD_CARVERS).disableSaving().disableSync().create();
makeRegistry(FEATURES).addCallback(FeatureCallbacks.INSTANCE).disableSaving().disableSync().create();
makeRegistry(FEATURES).disableSaving().disableSync().create();
makeRegistry(CHUNK_STATUS, "empty").disableSaving().disableSync().create();
makeRegistry(BLOCK_STATE_PROVIDER_TYPES).disableSaving().disableSync().create();
makeRegistry(FOLIAGE_PLACER_TYPES).disableSaving().disableSync().create();
Expand Down Expand Up @@ -167,7 +167,7 @@ static RegistryBuilder<FluidType> getFluidTypeRegistryBuilder()
{
return makeRegistry(FLUID_TYPES).disableSaving();
}

static RegistryBuilder<HolderSetType> getHolderSetTypeRegistryBuilder()
{
return new RegistryBuilder<HolderSetType>().disableSaving().disableSync();
Expand Down Expand Up @@ -534,23 +534,6 @@ public void onValidate(IForgeRegistryInternal<Attribute> owner, RegistryManager
}
}

private static class FeatureCallbacks implements IForgeRegistry.ClearCallback<Feature<?>>, IForgeRegistry.CreateCallback<Feature<?>>
{
static final FeatureCallbacks INSTANCE = new FeatureCallbacks();

@Override
public void onClear(IForgeRegistryInternal<Feature<?>> owner, RegistryManager stage)
{
owner.getSlaveMap(STRUCTURES, BiMap.class).clear();
}

@Override
public void onCreate(IForgeRegistryInternal<Feature<?>> owner, RegistryManager stage)
{
owner.setSlaveMap(STRUCTURES, HashBiMap.create());
}
}

private static class PointOfInterestTypeCallbacks implements IForgeRegistry.AddCallback<PoiType>, IForgeRegistry.ClearCallback<PoiType>, IForgeRegistry.CreateCallback<PoiType>
{
static final PointOfInterestTypeCallbacks INSTANCE = new PointOfInterestTypeCallbacks();
Expand Down

0 comments on commit 8f407c3

Please sign in to comment.