Final patching

Signed-off-by: cpw <[email protected]>
This commit is contained in:
Anthony Anderson authored and cpw committed 2020-06-25 17:55:54 -04:00
1 parent 80eb12e59d
commit ca2ed1ff7a
139 files changed
+1034 -4067

No files matched your search

@@ -225,72 +225,6 @@ public class GuiScreenEvent extends Event
}
}
@Deprecated // Remove in 1.16
public static class ActionPerformedEvent extends GuiScreenEvent
{
private Button button;
private List<Button> buttonList;
public ActionPerformedEvent(Screen gui, Button button, List<Button> buttonList)
{
super(gui);
this.setButton(button);
this.setButtonList(new ArrayList<Button>(buttonList));
}
/**
* The button that was clicked.
*/
public Button getButton()
{
return button;
}
public void setButton(Button button)
{
this.button = button;
}
/**
* A COPY of the {@link #buttonList} field from the GuiScreen referenced by {@link #gui}.
*/
public List<Button> getButtonList()
{
return buttonList;
}
public void setButtonList(List<Button> buttonList)
{
this.buttonList = buttonList;
}
/**
* This event fires once it has been determined that a GuiButton object has been clicked.
* Cancel this event to bypass {@link GuiScreen#actionPerformed(GuiButton)}.
* Replace button with a different button from buttonList to have that button's action executed.
*/
@Cancelable
public static class Pre extends ActionPerformedEvent
{
public Pre(Screen gui, Button button, List<Button> buttonList)
{
super(gui, button, buttonList);
}
}
/**
* This event fires after {@link GuiScreen#actionPerformed(GuiButton)} provided that the active
* screen has not been changed as a result of {@link GuiScreen#actionPerformed(GuiButton)}.
*/
public static class Post extends ActionPerformedEvent
{
public Post(Screen gui, Button button, List<Button> buttonList)
{
super(gui, button, buttonList);
}
}
}
public static abstract class MouseInputEvent extends GuiScreenEvent
{
private final double mouseX;
@@ -28,6 +28,8 @@ import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.InputMappings;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import org.lwjgl.glfw.GLFW;
public enum KeyModifier {
@@ -53,11 +55,10 @@ public enum KeyModifier {
}
@Override
public String getLocalizedComboName(InputMappings.Input key, Supplier<String> defaultLogic)
public ITextComponent getCombinedName(InputMappings.Input key, Supplier<ITextComponent> defaultLogic)
{
String keyName = defaultLogic.get();
String localizationFormatKey = Minecraft.IS_RUNNING_ON_MAC ? "forge.controlsgui.control.mac" : "forge.controlsgui.control";
return I18n.format(localizationFormatKey, keyName);
return new TranslationTextComponent(localizationFormatKey).func_240702_b_(" + ").func_230529_a_(defaultLogic.get());
}
},
SHIFT {
@@ -74,9 +75,9 @@ public enum KeyModifier {
}
@Override
public String getLocalizedComboName(InputMappings.Input key, Supplier<String> defaultLogic)
public ITextComponent getCombinedName(InputMappings.Input key, Supplier<ITextComponent> defaultLogic)
{
return I18n.format("forge.controlsgui.shift", defaultLogic.get());
return new TranslationTextComponent("forge.controlsgui.shift").func_240702_b_(" + ").func_230529_a_(defaultLogic.get());
}
},
ALT {
@@ -93,9 +94,9 @@ public enum KeyModifier {
}
@Override
public String getLocalizedComboName(InputMappings.Input keyCode, Supplier<String> defaultLogic)
public ITextComponent getCombinedName(InputMappings.Input keyCode, Supplier<ITextComponent> defaultLogic)
{
return I18n.format("forge.controlsgui.alt", defaultLogic.get());
return new TranslationTextComponent("forge.controlsgui.alt").func_240702_b_(" + ").func_230529_a_(defaultLogic.get());
}
},
NONE {
@@ -122,7 +123,7 @@ public enum KeyModifier {
}
@Override
public String getLocalizedComboName(InputMappings.Input key, Supplier<String> defaultLogic)
public ITextComponent getCombinedName(InputMappings.Input key, Supplier<ITextComponent> defaultLogic)
{
return defaultLogic.get();
}
@@ -170,5 +171,5 @@ public enum KeyModifier {
public abstract boolean isActive(@Nullable IKeyConflictContext conflictContext);
public abstract String getLocalizedComboName(InputMappings.Input key, Supplier<String> defaultLogic);
public abstract ITextComponent getCombinedName(InputMappings.Input key, Supplier<ITextComponent> defaultLogic);
}
@@ -29,8 +29,9 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Objects;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -39,6 +40,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Queues;
import com.google.common.collect.Sets;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
@@ -50,6 +52,7 @@ import net.minecraft.fluid.*;
import net.minecraft.loot.LootContext;
import net.minecraft.loot.LootTable;
import net.minecraft.loot.LootTableManager;
import net.minecraft.tags.ITag;
import net.minecraft.util.*;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
@@ -87,7 +90,6 @@ import net.minecraft.network.play.server.SChangeBlockPacket;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionUtils;
import net.minecraft.stats.Stats;
import net.minecraft.tags.Tag;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.text.*;
import net.minecraft.world.spawner.AbstractSpawner;
@@ -106,8 +108,7 @@ import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraftforge.common.loot.IGlobalLootModifier;
import net.minecraftforge.common.loot.LootModifierManager;
import net.minecraftforge.common.data.IOptionalTagEntry;
import net.minecraftforge.common.util.BlockSnapshot;
import net.minecraftforge.event.AnvilUpdateEvent;
import net.minecraftforge.event.DifficultyChangeEvent;
@@ -1074,9 +1075,7 @@ public class ForgeHooks
return res == Result.DEFAULT ? 0 : res == Result.DENY ? -1 : 1;
}
/*
@SuppressWarnings("deprecation")
public static <T> void deserializeTagAdditions(Tag.Builder<T> builder, Function<ResourceLocation, Optional<T>> valueGetter, JsonObject json)
public static <T> void deserializeTagAdditions(List<ITag.ITagEntry> list, JsonObject json, List<ITag.Proxy> allList)
{
if (json.has("optional"))
{
@@ -1084,9 +1083,9 @@ public class ForgeHooks
{
String s = JSONUtils.getString(entry, "value");
if (!s.startsWith("#"))
builder.addOptional(valueGetter, Collections.singleton(new ResourceLocation(s)));
list.add(ForgeHooks.makeOptionalTag(true, Collections.singleton(new ResourceLocation(s))));
else
builder.addOptionalTag(new ResourceLocation(s.substring(1)));
list.add(ForgeHooks.makeOptionalTag(false, Collections.singleton(new ResourceLocation(s.substring(1)))));
}
}
@@ -1095,23 +1094,15 @@ public class ForgeHooks
for (JsonElement entry : JSONUtils.getJsonArray(json, "remove"))
{
String s = JSONUtils.getString(entry, "value");
ITag.ITagEntry dummy;
if (!s.startsWith("#"))
{
T value = valueGetter.apply(new ResourceLocation(s)).orElse(null);
if (value != null)
{
Tag.ITagEntry<T> dummyEntry = new Tag.ListEntry<>(Collections.singleton(value));
builder.remove(dummyEntry);
}
} else
{
Tag.ITagEntry<T> dummyEntry = new Tag.TagEntry<>(new ResourceLocation(s.substring(1)));
builder.remove(dummyEntry);
}
dummy = new ITag.ItemEntry(new ResourceLocation(s));
else
dummy = new ITag.TagEntry(new ResourceLocation(s.substring(1)));
allList.removeIf(e -> e.func_232968_a_().equals(dummy));
}
}
}
*/
private static final Map<IDataSerializer<?>, DataSerializerEntry> serializerEntries = GameData.getSerializerMap();
//private static final ForgeRegistry<DataSerializerEntry> serializerRegistry = (ForgeRegistry<DataSerializerEntry>) ForgeRegistries.DATA_SERIALIZERS;
@@ -1189,4 +1180,61 @@ public class ForgeHooks
return list;
}
@Deprecated//INTERNAL
public static IOptionalTagEntry makeOptionalTag(boolean items, Collection<ResourceLocation> locations) {
return items ? new OptionalItemTarget(locations) : new OptionalTagTarget(locations);
}
private static class OptionalTagTarget implements IOptionalTagEntry
{
private final Collection<ResourceLocation> referents;
public OptionalTagTarget(Collection<ResourceLocation> referents)
{
this.referents = referents;
}
@Override
public <T> boolean func_230238_a_(Function<ResourceLocation, ITag<T>> tagLookup, Function<ResourceLocation, T> itemLookup, Consumer<T> collector)
{
referents.stream()
.map(tagLookup)
.filter(Objects::nonNull)
.map(ITag::func_230236_b_)
.flatMap(List::stream)
.forEach(collector);
return true;
}
@Override
public void func_230237_a_(JsonArray array)
{
referents.stream().map(e -> "#" + e).forEach(array::add);
}
}
private static class OptionalItemTarget implements IOptionalTagEntry
{
private final Collection<ResourceLocation> locations;
public OptionalItemTarget(Collection<ResourceLocation> locations)
{
this.locations = locations;
}
@Override
public <T> boolean func_230238_a_(Function<ResourceLocation, ITag<T>> tagLookup, Function<ResourceLocation, T> itemLookup, Consumer<T> collector)
{
locations.stream().map(itemLookup).filter(Objects::nonNull).forEach(collector);
return true;
}
@Override
public void func_230237_a_(JsonArray array)
{
locations.stream().map(ResourceLocation::toString).forEach(array::add);
}
}
}
@@ -19,15 +19,16 @@
package net.minecraftforge.common;
import java.util.Collections;
import java.util.List;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
*
@@ -37,11 +38,7 @@ import javax.annotation.Nonnull;
* to support mod-shears as well.
*
*/
//TODO Change to World, not IWorldReader and make Implementor responsible for removing itself from the world.
//Better mimics vanilla behavior and allows more control for the user.
@Deprecated //TODO: Reevaluate the entire thing, loot from blocks is now a loot table. So this is just a marker now.
public interface IShearable
public interface IForgeShearable
{
/**
* Checks if the object is currently shearable
@@ -52,7 +49,8 @@ public interface IShearable
* @param pos Block's position in world.
* @return If this is shearable, and onSheared should be called.
*/
default boolean isShearable(@Nonnull ItemStack item, IWorldReader world, BlockPos pos) {
default boolean isShearable(@Nonnull ItemStack item, World world, BlockPos pos)
{
return true;
}
@@ -75,7 +73,8 @@ public interface IShearable
* @return A List containing all items from this shearing. May be empty.
*/
@Nonnull
default List<ItemStack> onSheared(@Nonnull ItemStack item, IWorld world, BlockPos pos, int fortune) {
return NonNullList.create();
default List<ItemStack> onSheared(@Nullable PlayerEntity player, @Nonnull ItemStack item, World world, BlockPos pos, int fortune)
{
return Collections.emptyList();
}
}
@@ -30,16 +30,16 @@ import net.minecraft.world.IBlockReader;
public interface IPlantable
{
default PlantType getPlantType(IBlockReader world, BlockPos pos) {
if (this instanceof CropsBlock) return PlantType.Crop;
if (this instanceof SaplingBlock) return PlantType.Plains;
if (this instanceof FlowerBlock) return PlantType.Plains;
if (this == Blocks.DEAD_BUSH) return PlantType.Desert;
if (this == Blocks.LILY_PAD) return PlantType.Water;
if (this == Blocks.RED_MUSHROOM) return PlantType.Cave;
if (this == Blocks.BROWN_MUSHROOM) return PlantType.Cave;
if (this == Blocks.NETHER_WART) return PlantType.Nether;
if (this == Blocks.TALL_GRASS) return PlantType.Plains;
return net.minecraftforge.common.PlantType.Plains;
if (this instanceof CropsBlock) return PlantType.CROP;
if (this instanceof SaplingBlock) return PlantType.PLAINS;
if (this instanceof FlowerBlock) return PlantType.PLAINS;
if (this == Blocks.DEAD_BUSH) return PlantType.DESERT;
if (this == Blocks.LILY_PAD) return PlantType.WATER;
if (this == Blocks.RED_MUSHROOM) return PlantType.CAVE;
if (this == Blocks.BROWN_MUSHROOM) return PlantType.CAVE;
if (this == Blocks.NETHER_WART) return PlantType.NETHER;
if (this == Blocks.TALL_GRASS) return PlantType.PLAINS;
return net.minecraftforge.common.PlantType.PLAINS;
}
BlockState getPlant(IBlockReader world, BlockPos pos);
@@ -22,16 +22,22 @@ package net.minecraftforge.common;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorldReader;
// TODO 1.16: This should not be an enum. Change it to something that functions similarly to ToolType
public enum PlantType implements IExtensibleEnum
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
public final class PlantType
{
Plains,
Desert,
Beach,
Cave,
Water,
Nether,
Crop;
private static final Pattern INVALID_CHARACTERS = Pattern.compile("[^a-z_]"); //Only a-z and _ are allowed, meaning names must be lower case. And use _ to separate words.
private static final Map<String, PlantType> VALUES = new HashMap<>();
public static final PlantType PLAINS = get("plains");
public static final PlantType DESERT = get("desert");
public static final PlantType BEACH = get("beach");
public static final PlantType CAVE = get("cave");
public static final PlantType WATER = get("water");
public static final PlantType NETHER = get("nether");
public static final PlantType CROP = get("crop");
/**
* Getting a custom {@link PlantType}, or an existing one if it has the same name as that one. Your plant should implement {@link IPlantable}
@@ -46,9 +52,25 @@ public enum PlantType implements IExtensibleEnum
* @param name the name of the type of plant, you had better follow the style above
* @return the acquired {@link PlantType}, a new one if not found.
*/
public static PlantType create(String name)
public static PlantType get(String name)
{
throw new IllegalStateException("Enum not extended");
return VALUES.computeIfAbsent(name, e -> {
if (INVALID_CHARACTERS.matcher(e).find())
throw new IllegalArgumentException("PlantType.get() called with invalid name: " + name);
return new PlantType(e);
});
}
private final String name;
private PlantType(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
}
@@ -37,7 +37,7 @@ public final class ToolType
public static ToolType get(String name)
{
if (VALID_NAME.matcher(name).find())
throw new IllegalArgumentException("ToolType.create() called with invalid name: " + name);
throw new IllegalArgumentException("ToolType.get() called with invalid name: " + name);
return values.computeIfAbsent(name, k -> new ToolType(name));
}
@@ -17,11 +17,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
//package net.minecraftforge.common.data;
package net.minecraftforge.common.data;
//import net.minecraft.tags.Tag.ITagEntry;
import net.minecraft.tags.ITag;
/**
* Marker class used by Forge to make a tag entry optional at runtime
*/
//public interface IOptionalTagEntry<T> extends ITagEntry<T> {}
public interface IOptionalTagEntry extends ITag.ITagEntry {}
@@ -1059,6 +1059,6 @@ public interface IForgeBlock
*/
default boolean shouldDisplayFluidOverlay(BlockState state, IBlockDisplayReader world, BlockPos pos, FluidState fluidState)
{
return state.getBlock() instanceof BreakableBlock || state.getBlock() instanceof StainedGlassBlock;
return state.getBlock() instanceof BreakableBlock || state.getBlock() instanceof LeavesBlock;
}
}
@@ -21,7 +21,13 @@ package net.minecraftforge.common.extensions;
import net.minecraft.data.TagsProvider;
import net.minecraft.tags.ITag;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.ForgeHooks;
import java.util.Arrays;
import java.util.Collection;
//TODO, Tag removal support.
public interface IForgeTagBuilder<T>
{
@@ -37,73 +43,32 @@ public interface IForgeTagBuilder<T>
return builder;
}
/*default Tag.Builder<T> addOptional(final TagCollection<T> collection, final ResourceLocation... locations)
{
return addOptional(collection, Arrays.asList(locations));
default TagsProvider.Builder<T> replace() {
return replace(true);
}
default Tag.Builder<T> addOptional(final TagCollection<T> collection, final Collection<ResourceLocation> locations)
{
return addOptional(collection.getEntryLookup(), locations);
default TagsProvider.Builder<T> replace(boolean value) {
getBuilder().getInternalBuilder().replace(value);
return getBuilder();
}
@Deprecated //Use the TagCollection version
default Tag.Builder<T> addOptional(final Function<ResourceLocation, Optional<T>> entryLookup, final Collection<ResourceLocation> locations)
default TagsProvider.Builder<T> addOptional(final ResourceLocation... locations)
{
return ((Tag.Builder<T>)this).add(new IOptionalTagEntry<T>() {
@Override
public void populate(Collection<T> itemsIn)
{
locations.stream().map(entryLookup).forEach(e -> e.ifPresent(itemsIn::add));
}
@Override
public void serialize(JsonArray array, Function<T, ResourceLocation> getNameForObject)
{
locations.stream().map(ResourceLocation::toString).forEach(array::add);
}
});
return addOptional(Arrays.asList(locations));
}
default Tag.Builder<T> addOptionalTag(final TagCollection<T> collection, @SuppressWarnings("unchecked") final Tag<T>... tags)
default TagsProvider.Builder<T> addOptional(final Collection<ResourceLocation> locations)
{
for (Tag<T> tag : tags)
addOptionalTag(tag.getId());
return ((Tag.Builder<T>)this);
return getBuilder().add(ForgeHooks.makeOptionalTag(true, locations));
}
default Tag.Builder<T> addOptionalTag(final ResourceLocation... tags)
default TagsProvider.Builder<T> addOptionalTag(final ResourceLocation... locations)
{
for (ResourceLocation rl : tags)
addOptionalTag(rl);
return ((Tag.Builder<T>)this);
return addOptionalTag(Arrays.asList(locations));
}
default Tag.Builder<T> addOptionalTag(ResourceLocation tag)
default TagsProvider.Builder<T> addOptionalTag(final Collection<ResourceLocation> locations)
{
class TagTarget<U> extends Tag.TagEntry<U> implements IOptionalTagEntry<U>
{
private Tag<U> resolvedTag = null;
protected TagTarget(ResourceLocation referent) {
super(referent);
}
@Override
public boolean resolve(@Nonnull Function<ResourceLocation, Tag<U>> resolver)
{
if (this.resolvedTag == null)
this.resolvedTag = resolver.apply(this.getSerializedId());
return true; // never fail if resolver returns null
}
@Override
public void populate(@Nonnull Collection<U> items)
{
if (this.resolvedTag != null)
items.addAll(this.resolvedTag.getAllElements());
}
};
return ((Tag.Builder<T>)this).add(new TagTarget<>(tag));
}*/
return getBuilder().add(ForgeHooks.makeOptionalTag(false, locations));
}
}
@@ -99,12 +99,6 @@ public class ChunkDataEvent extends ChunkEvent
**/
public static class Save extends ChunkDataEvent
{
@Deprecated // remove in 1.16
public Save(IChunk chunk, CompoundNBT data)
{
super(chunk, data);
}
public Save(IChunk chunk, IWorld world, CompoundNBT data)
{
super(chunk, world, data);
@@ -111,7 +111,7 @@ public final class FMLWorldPersistenceHook implements WorldPersistenceHooks.Worl
if (tag.contains("ModItemData") || tag.contains("ItemData")) // Pre 1.7
{
StartupQuery.notify("This save predates 1.7.10, it can no longer be loaded here. Please load in 1.7.10 or 1.8 first");
StartupQuery.builder().text("This save predates 1.7.10, it can no longer be loaded here. Please load in 1.7.10 or 1.8 first").notification();
StartupQuery.abort();
}
else if (tag.contains("Registries")) // 1.8, genericed out the 'registries' list
@@ -138,7 +138,7 @@ public final class FMLWorldPersistenceHook implements WorldPersistenceHooks.Worl
entries.forEach(rl -> buf.append(" ").append(rl).append("\n"));
});
StartupQuery.notify(buf.toString());
StartupQuery.builder().text(buf.toString()).notification();
StartupQuery.abort();
}
}
@@ -99,20 +99,8 @@ public class StartupQuery {
return new QueryBuilder();
}
@Deprecated // TODO 1.16 remove
public static boolean confirm(String text)
{
return builder().text(text).confirm();
}
private InterruptedException exception;
@Deprecated // TODO 1.16 remove
public static void notify(String text)
{
builder().text(text).notification();
}
public static void abort()
{
MinecraftServer server = ServerLifecycleHooks.getCurrentServer();
@@ -66,10 +66,6 @@ public class GatherDataEvent extends ModLifecycleEvent
private final boolean flat;
private List<DataGenerator> generators = new ArrayList<>();
@Deprecated //Remove in 1.16
public DataGeneratorConfig(final Set<String> mods, final Path path, final Collection<Path> inputs, final boolean server, final boolean client, final boolean dev, final boolean reports, final boolean validate) {
this(mods, path, inputs, server, client, dev, reports, validate, false);
}
public DataGeneratorConfig(final Set<String> mods, final Path path, final Collection<Path> inputs, final boolean server, final boolean client, final boolean dev, final boolean reports, final boolean validate, final boolean flat) {
this.mods = mods;
this.path = path;
@@ -90,8 +90,7 @@ public class DeferredRegister<T extends IForgeRegistryEntry<T>>
this.modid = modid;
}
@Deprecated // Make private in 1.16, Use create. Constructors are an implementation detail.
public DeferredRegister(IForgeRegistry<T> reg, String modid)
private DeferredRegister(IForgeRegistry<T> reg, String modid)
{
this(reg.getRegistrySuperType(), modid);
this.type = reg;
@@ -47,6 +47,7 @@ import net.minecraft.world.gen.blockplacer.BlockPlacerType;
import net.minecraft.world.gen.blockstateprovider.BlockStateProviderType;
import net.minecraft.world.gen.carver.WorldCarver;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.structure.Structure;
import net.minecraft.world.gen.foliageplacer.FoliagePlacerType;
import net.minecraft.world.gen.placement.Placement;
import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder;
@@ -96,6 +97,7 @@ public class ForgeRegistries
public static final IForgeRegistry<Placement<?>> DECORATORS = RegistryManager.ACTIVE.getRegistry(Placement.class);
// public static final IForgeRegistry<ChunkGeneratorType<?, ?>> CHUNK_GENERATOR_TYPES = RegistryManager.ACTIVE.getRegistry(ChunkGeneratorType.class);
public static final IForgeRegistry<ChunkStatus> CHUNK_STATUS = RegistryManager.ACTIVE.getRegistry(ChunkStatus.class);
public static final IForgeRegistry<Structure<?>> STRUCTURE_FEATURES = RegistryManager.ACTIVE.getRegistry(Structure.class);
public static final IForgeRegistry<BlockStateProviderType<?>> BLOCK_STATE_PROVIDER_TYPES = RegistryManager.ACTIVE.getRegistry(BlockStateProviderType.class);
public static final IForgeRegistry<BlockPlacerType<?>> BLOCK_PLACER_TYPES = RegistryManager.ACTIVE.getRegistry(BlockPlacerType.class);
public static final IForgeRegistry<FoliagePlacerType<?>> FOLIAGE_PLACER_TYPES = RegistryManager.ACTIVE.getRegistry(FoliagePlacerType.class);
@@ -142,6 +142,7 @@ public class GameData
public static final ResourceLocation DECORATORS = new ResourceLocation("decorator");
public static final ResourceLocation BIOME_PROVIDER_TYPES = new ResourceLocation("biome_source_type");
public static final ResourceLocation CHUNK_STATUS = new ResourceLocation("chunk_status");
public static final ResourceLocation STRUCTURE_FEATURES = new ResourceLocation("structure_feature");
public static final ResourceLocation BLOCK_STATE_PROVIDER_TYPES = new ResourceLocation("block_state_provider_type");
public static final ResourceLocation BLOCK_PLACER_TYPES = new ResourceLocation("block_placer_type");
public static final ResourceLocation FOLIAGE_PLACER_TYPES = new ResourceLocation("foliage_placer_type");
@@ -156,7 +157,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 SERIALIZER_TO_ENTRY = new ResourceLocation("forge:serializer_to_entry");
//private static final ResourceLocation STRUCTURE_FEATURES = new ResourceLocation("minecraft:structure_feature");
private static final ResourceLocation STRUCTURES = new ResourceLocation("minecraft:structures");
private static boolean hasInit = false;
@@ -211,6 +211,7 @@ public class GameData
makeRegistry(FEATURES, Feature.class).addCallback(FeatureCallbacks.INSTANCE).disableSaving().create();
makeRegistry(DECORATORS, Placement.class).disableSaving().disableSync().create();
makeRegistry(CHUNK_STATUS, ChunkStatus.class, new ResourceLocation("empty")).disableSaving().disableSync().create();
makeRegistry(STRUCTURE_FEATURES, Structure.class).disableSaving().disableSync().create();
makeRegistry(BLOCK_STATE_PROVIDER_TYPES, BlockStateProviderType.class).disableSaving().disableSync().create();
makeRegistry(BLOCK_PLACER_TYPES, BlockPlacerType.class).disableSaving().disableSync().create();
makeRegistry(FOLIAGE_PLACER_TYPES, FoliagePlacerType.class).disableSaving().disableSync().create();
@@ -272,14 +273,6 @@ public class GameData
return RegistryManager.ACTIVE.getRegistry(DataSerializerEntry.class).getSlaveMap(SERIALIZER_TO_ENTRY, Map.class);
}
/*
@SuppressWarnings("unchecked")
public static Registry<Structure<?>> getStructureFeatures()
{
return (Registry<Structure<?>>) RegistryManager.ACTIVE.getRegistry(Feature.class).getSlaveMap(STRUCTURE_FEATURES, Registry.class);
}
*/
@SuppressWarnings("unchecked")
public static BiMap<String, Structure<?>> getStructureMap()
{
@@ -570,42 +563,19 @@ public class GameData
}
}
private static class FeatureCallbacks implements IForgeRegistry.AddCallback<Feature<?>>, IForgeRegistry.ClearCallback<Feature<?>>, IForgeRegistry.CreateCallback<Feature<?>>
private static class FeatureCallbacks implements IForgeRegistry.ClearCallback<Feature<?>>, IForgeRegistry.CreateCallback<Feature<?>>
{
static final FeatureCallbacks INSTANCE = new FeatureCallbacks();
@Override
public void onAdd(IForgeRegistryInternal<Feature<?>> owner, RegistryManager stage, int id, Feature<?> obj, Feature<?> oldObj)
{
/*TODO, Structures arent Features anymore.
if (obj instanceof Structure)
{
Structure<?> structure = (Structure<?>) obj;
String key = structure.getStructureName().toLowerCase(Locale.ROOT);
@SuppressWarnings("unchecked")
Registry<Structure<?>> reg = owner.getSlaveMap(STRUCTURE_FEATURES, Registry.class);
Registry.register(reg, key, structure);
@SuppressWarnings("unchecked")
BiMap<String, Structure<?>> map = owner.getSlaveMap(STRUCTURES, BiMap.class);
if (oldObj != null && oldObj instanceof Structure) map.remove(((Structure<?>)oldObj).getStructureName());
map.put(key, structure);
}
*/
}
@Override
public void onClear(IForgeRegistryInternal<Feature<?>> owner, RegistryManager stage)
{
//owner.getSlaveMap(STRUCTURE_FEATURES, ClearableRegistry.class).clear();
owner.getSlaveMap(STRUCTURES, BiMap.class).clear();
}
@Override
public void onCreate(IForgeRegistryInternal<Feature<?>> owner, RegistryManager stage)
{
//owner.setSlaveMap(STRUCTURE_FEATURES, new ClearableRegistry<>(owner.getRegistryName()));
owner.setSlaveMap(STRUCTURES, HashBiMap.create());
}
}