Update to 1.17

Update to Official classnames
Patchwork
Make the game compile and run
Merge in the new HUD overlay API
Merge in the new render properties API
PEEL
Use Gradle 7.2 snapshot to fix eclipse integration bug in 7.1, Would use 7.0 but FG needs 7.1 for some reason.
New FML installer
Update to 1.17.1

Co-authored-by: LexManos <[email protected]>
Co-authored-by: SizableShrimp <[email protected]>
Co-authored-by: cpw <[email protected]>
Co-authored-by: Curle <[email protected]>
Co-authored-by: Unnoen <[email protected]>
Co-authored-by: covers1624 <[email protected]>
Co-authored-by: DaemonUmbra <[email protected]>
Co-authored-by: gigaherz <[email protected]>
Signed-off-by: SizableShrimp <[email protected]>
This commit is contained in:
authored and Curle committed 2021-07-22 19:57:02 +01:00
1 parent 064ae6961b
commit be5446b91c
1990 files changed
+35661 -37544

No files matched your search

@@ -23,37 +23,39 @@ import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import net.minecraft.data.IDataProvider;
import net.minecraft.client.resources.ResourceIndex;
import net.minecraft.client.resources.VirtualAssetsPack;
import net.minecraft.resources.FilePack;
import net.minecraft.resources.FolderPack;
import net.minecraft.resources.IResource;
import net.minecraft.resources.IResourceManager;
import net.minecraft.resources.IResourcePack;
import net.minecraft.resources.ResourcePackType;
import net.minecraft.resources.SimpleReloadableResourceManager;
import net.minecraft.resources.VanillaPack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.client.resources.ClientPackSource;
import net.minecraft.client.resources.AssetIndex;
import net.minecraft.client.resources.DefaultClientPackResources;
import net.minecraft.data.DataProvider;
import net.minecraft.data.HashCache;
import net.minecraft.server.packs.FilePackResources;
import net.minecraft.server.packs.FolderPackResources;
import net.minecraft.server.packs.repository.ServerPacksSource;
import net.minecraft.server.packs.resources.Resource;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.server.packs.PackResources;
import net.minecraft.server.packs.PackType;
import net.minecraft.server.packs.resources.SimpleReloadableResourceManager;
import net.minecraft.server.packs.VanillaPackResources;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.client.model.generators.ModelBuilder;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.event.lifecycle.GatherDataEvent;
import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
import net.minecraftforge.fml.packs.ModFileResourcePack;
import net.minecraftforge.forge.event.lifecycle.GatherDataEvent;
import net.minecraftforge.fmllegacy.packs.ModFileResourcePack;
import net.minecraftforge.forgespi.language.IModFileInfo;
import javax.annotation.Nullable;
/**
* Enables data providers to check if other data files currently exist. The
* instance provided in the {@link GatherDataEvent} utilizes the standard
* resources (via {@link VanillaPack}), forge's resources, as well as any
* resources (via {@link VanillaPackResources}), forge's resources, as well as any
* extra resource packs passed in via the {@code --existing} argument,
* or mod resources via the {@code --existing-mod} argument.
*/
@@ -61,7 +63,7 @@ public class ExistingFileHelper {
public interface IResourceType {
ResourcePackType getPackType();
PackType getPackType();
String getSuffix();
@@ -70,16 +72,16 @@ public class ExistingFileHelper {
public static class ResourceType implements IResourceType {
final ResourcePackType packType;
final PackType packType;
final String suffix, prefix;
public ResourceType(ResourcePackType type, String suffix, String prefix) {
public ResourceType(PackType type, String suffix, String prefix) {
this.packType = type;
this.suffix = suffix;
this.prefix = prefix;
}
@Override
public ResourcePackType getPackType() { return packType; }
public PackType getPackType() { return packType; }
@Override
public String getSuffix() { return suffix; }
@@ -90,12 +92,7 @@ public class ExistingFileHelper {
private final SimpleReloadableResourceManager clientResources, serverData;
private final boolean enable;
private final Multimap<ResourcePackType, ResourceLocation> generated = HashMultimap.create();
@Deprecated//TODO: Remove in 1.17
public ExistingFileHelper(Collection<Path> existingPacks, boolean enable) {
this(existingPacks, Collections.emptySet(), enable);
}
private final Multimap<PackType, ResourceLocation> generated = HashMultimap.create();
/**
* Create a new helper. This should probably <em>NOT</em> be used by mods, as
@@ -108,33 +105,29 @@ public class ExistingFileHelper {
* @param existingPacks
* @param existingMods
* @param enable
* @param assetIndex
* @param assetsDir
*/
@Deprecated // TODO: Remove in 1.17
public ExistingFileHelper(Collection<Path> existingPacks, Set<String> existingMods, boolean enable) {
this(existingPacks, existingMods, enable, null, null);
}
public ExistingFileHelper(Collection<Path> existingPacks, final Set<String> existingMods, boolean enable, @Nullable final String assetIndex, @Nullable final File assetsDir) {
this.clientResources = new SimpleReloadableResourceManager(ResourcePackType.CLIENT_RESOURCES);
this.serverData = new SimpleReloadableResourceManager(ResourcePackType.SERVER_DATA);
this.clientResources = new SimpleReloadableResourceManager(PackType.CLIENT_RESOURCES);
this.serverData = new SimpleReloadableResourceManager(PackType.SERVER_DATA);
this.clientResources.add(new VanillaPack("minecraft", "realms"));
this.clientResources.add(new VanillaPackResources(ClientPackSource.BUILT_IN, "minecraft", "realms"));
if (assetIndex != null && assetsDir != null)
{
this.clientResources.add(new VirtualAssetsPack(new ResourceIndex(assetsDir, assetIndex)));
this.clientResources.add(new DefaultClientPackResources(ClientPackSource.BUILT_IN, new AssetIndex(assetsDir, assetIndex)));
}
this.serverData.add(new VanillaPack("minecraft"));
this.serverData.add(new VanillaPackResources(ServerPacksSource.BUILT_IN_METADATA, "minecraft"));
for (Path existing : existingPacks) {
File file = existing.toFile();
IResourcePack pack = file.isDirectory() ? new FolderPack(file) : new FilePack(file);
PackResources pack = file.isDirectory() ? new FolderPackResources(file) : new FilePackResources(file);
this.clientResources.add(pack);
this.serverData.add(pack);
}
for (String existingMod : existingMods) {
ModFileInfo modFileInfo = ModList.get().getModFileById(existingMod);
IModFileInfo modFileInfo = ModList.get().getModFileById(existingMod);
if (modFileInfo != null) {
IResourcePack pack = new ModFileResourcePack(modFileInfo.getFile());
PackResources pack = new ModFileResourcePack(modFileInfo.getFile());
this.clientResources.add(pack);
this.serverData.add(pack);
}
@@ -142,8 +135,8 @@ public class ExistingFileHelper {
this.enable = enable;
}
private IResourceManager getManager(ResourcePackType packType) {
return packType == ResourcePackType.CLIENT_RESOURCES ? clientResources : serverData;
private ResourceManager getManager(PackType packType) {
return packType == PackType.CLIENT_RESOURCES ? clientResources : serverData;
}
private ResourceLocation getLocation(ResourceLocation base, String suffix, String prefix) {
@@ -159,7 +152,7 @@ public class ExistingFileHelper {
* @return {@code true} if the resource exists in any pack, {@code false}
* otherwise
*/
public boolean exists(ResourceLocation loc, ResourcePackType packType) {
public boolean exists(ResourceLocation loc, PackType packType) {
if (!enable) {
return true;
}
@@ -195,7 +188,7 @@ public class ExistingFileHelper {
* @return {@code true} if the resource exists in any pack, {@code false}
* otherwise
*/
public boolean exists(ResourceLocation loc, ResourcePackType packType, String pathSuffix, String pathPrefix) {
public boolean exists(ResourceLocation loc, PackType packType, String pathSuffix, String pathPrefix) {
return exists(getLocation(loc, pathSuffix, pathPrefix), packType);
}
@@ -206,7 +199,7 @@ public class ExistingFileHelper {
* <p>
* This should be called by data providers immediately when a new data object is
* created, i.e. not during
* {@link IDataProvider#act(net.minecraft.data.DirectoryCache) act} but instead
* {@link DataProvider#run(net.minecraft.data.HashCache) run} but instead
* when the "builder" (or whatever intermediate object) is created, such as a
* {@link ModelBuilder}.
* <p>
@@ -227,7 +220,7 @@ public class ExistingFileHelper {
* <p>
* This should be called by data providers immediately when a new data object is
* created, i.e. not during
* {@link IDataProvider#act(net.minecraft.data.DirectoryCache) act} but instead
* {@link DataProvider#run(HashCache) run} but instead
* when the "builder" (or whatever intermediate object) is created, such as a
* {@link ModelBuilder}.
* <p>
@@ -241,17 +234,17 @@ public class ExistingFileHelper {
* @param pathPrefix a string to append before the path, before a slash, e.g.
* {@code "models"}
*/
public void trackGenerated(ResourceLocation loc, ResourcePackType packType, String pathSuffix, String pathPrefix) {
public void trackGenerated(ResourceLocation loc, PackType packType, String pathSuffix, String pathPrefix) {
this.generated.put(packType, getLocation(loc, pathSuffix, pathPrefix));
}
@VisibleForTesting
public IResource getResource(ResourceLocation loc, ResourcePackType packType, String pathSuffix, String pathPrefix) throws IOException {
public Resource getResource(ResourceLocation loc, PackType packType, String pathSuffix, String pathPrefix) throws IOException {
return getResource(getLocation(loc, pathSuffix, pathPrefix), packType);
}
@VisibleForTesting
public IResource getResource(ResourceLocation loc, ResourcePackType packType) throws IOException {
public Resource getResource(ResourceLocation loc, PackType packType) throws IOException {
return getManager(packType).getResource(loc);
}
@@ -20,22 +20,22 @@
package net.minecraftforge.common.data;
import net.minecraft.data.DataGenerator;
import net.minecraft.item.DyeColor;
import net.minecraft.world.item.DyeColor;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ITag;
import net.minecraft.util.ResourceLocation;
import net.minecraft.tags.Tag;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.common.Tags;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.data.BlockTagsProvider;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.data.tags.BlockTagsProvider;
import static net.minecraftforge.common.Tags.Blocks.*;
import java.util.Locale;
import java.util.function.Consumer;
public class ForgeBlockTagsProvider extends BlockTagsProvider
public final class ForgeBlockTagsProvider extends BlockTagsProvider
{
public ForgeBlockTagsProvider(DataGenerator gen, ExistingFileHelper existingFileHelper)
{
@@ -97,13 +97,13 @@ public class ForgeBlockTagsProvider extends BlockTagsProvider
tag(STORAGE_BLOCKS_NETHERITE).add(Blocks.NETHERITE_BLOCK);
}
private void addColored(Consumer<Block> consumer, ITag.INamedTag<Block> group, String pattern)
private void addColored(Consumer<Block> consumer, Tag.Named<Block> group, String pattern)
{
String prefix = group.getName().getPath().toUpperCase(Locale.ENGLISH) + '_';
for (DyeColor color : DyeColor.values())
{
ResourceLocation key = new ResourceLocation("minecraft", pattern.replace("{color}", color.getName()));
ITag.INamedTag<Block> tag = getForgeTag(prefix + color.getName());
Tag.Named<Block> tag = getForgeTag(prefix + color.getName());
Block block = ForgeRegistries.BLOCKS.getValue(key);
if (block == null || block == Blocks.AIR)
throw new IllegalStateException("Unknown vanilla block: " + key.toString());
@@ -113,12 +113,12 @@ public class ForgeBlockTagsProvider extends BlockTagsProvider
}
@SuppressWarnings("unchecked")
private ITag.INamedTag<Block> getForgeTag(String name)
private Tag.Named<Block> getForgeTag(String name)
{
try
{
name = name.toUpperCase(Locale.ENGLISH);
return (ITag.INamedTag<Block>)Tags.Blocks.class.getDeclaredField(name).get(null);
return (Tag.Named<Block>)Tags.Blocks.class.getDeclaredField(name).get(null);
}
catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e)
{
@@ -20,12 +20,12 @@
package net.minecraftforge.common.data;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.FluidTagsProvider;
import net.minecraft.data.tags.FluidTagsProvider;
import net.minecraftforge.common.ForgeMod;
import static net.minecraftforge.common.Tags.Fluids.MILK;
public class ForgeFluidTagsProvider extends FluidTagsProvider
public final class ForgeFluidTagsProvider extends FluidTagsProvider
{
public ForgeFluidTagsProvider(DataGenerator gen, ExistingFileHelper existingFileHelper)
{
@@ -22,19 +22,19 @@ package net.minecraftforge.common.data;
import java.util.Locale;
import java.util.function.Consumer;
import net.minecraft.block.Block;
import net.minecraft.data.BlockTagsProvider;
import net.minecraft.world.level.block.Block;
import net.minecraft.data.tags.BlockTagsProvider;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.ItemTagsProvider;
import net.minecraft.item.DyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.tags.ITag;
import net.minecraft.util.ResourceLocation;
import net.minecraft.data.tags.ItemTagsProvider;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.tags.Tag;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.common.Tags;
import net.minecraftforge.registries.ForgeRegistries;
public class ForgeItemTagsProvider extends ItemTagsProvider
public final class ForgeItemTagsProvider extends ItemTagsProvider
{
public ForgeItemTagsProvider(DataGenerator gen, BlockTagsProvider blockTagProvider, ExistingFileHelper existingFileHelper)
{
@@ -141,13 +141,13 @@ public class ForgeItemTagsProvider extends ItemTagsProvider
tag(Tags.Items.STRING).add(Items.STRING);
}
private void addColored(Consumer<ITag.INamedTag<Item>> consumer, ITag.INamedTag<Item> group, String pattern)
private void addColored(Consumer<Tag.Named<Item>> consumer, Tag.Named<Item> group, String pattern)
{
String prefix = group.getName().getPath().toUpperCase(Locale.ENGLISH) + '_';
for (DyeColor color : DyeColor.values())
{
ResourceLocation key = new ResourceLocation("minecraft", pattern.replace("{color}", color.getName()));
ITag.INamedTag<Item> tag = getForgeItemTag(prefix + color.getName());
Tag.Named<Item> tag = getForgeItemTag(prefix + color.getName());
Item item = ForgeRegistries.ITEMS.getValue(key);
if (item == null || item == Items.AIR)
throw new IllegalStateException("Unknown vanilla item: " + key.toString());
@@ -156,26 +156,26 @@ public class ForgeItemTagsProvider extends ItemTagsProvider
}
}
private void func_240521_a_Colored(ITag.INamedTag<Block> blockGroup, ITag.INamedTag<Item> itemGroup)
private void func_240521_a_Colored(Tag.Named<Block> blockGroup, Tag.Named<Item> itemGroup)
{
String blockPre = blockGroup.getName().getPath().toUpperCase(Locale.ENGLISH) + '_';
String itemPre = itemGroup.getName().getPath().toUpperCase(Locale.ENGLISH) + '_';
for (DyeColor color : DyeColor.values())
{
ITag.INamedTag<Block> from = getForgeBlockTag(blockPre + color.getName());
ITag.INamedTag<Item> to = getForgeItemTag(itemPre + color.getName());
Tag.Named<Block> from = getForgeBlockTag(blockPre + color.getName());
Tag.Named<Item> to = getForgeItemTag(itemPre + color.getName());
copy(from, to);
}
copy(getForgeBlockTag(blockPre + "colorless"), getForgeItemTag(itemPre + "colorless"));
}
@SuppressWarnings("unchecked")
private ITag.INamedTag<Block> getForgeBlockTag(String name)
private Tag.Named<Block> getForgeBlockTag(String name)
{
try
{
name = name.toUpperCase(Locale.ENGLISH);
return (ITag.INamedTag<Block>)Tags.Blocks.class.getDeclaredField(name).get(null);
return (Tag.Named<Block>)Tags.Blocks.class.getDeclaredField(name).get(null);
}
catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e)
{
@@ -184,12 +184,12 @@ public class ForgeItemTagsProvider extends ItemTagsProvider
}
@SuppressWarnings("unchecked")
private ITag.INamedTag<Item> getForgeItemTag(String name)
private Tag.Named<Item> getForgeItemTag(String name)
{
try
{
name = name.toUpperCase(Locale.ENGLISH);
return (ITag.INamedTag<Item>)Tags.Items.class.getDeclaredField(name).get(null);
return (Tag.Named<Item>)Tags.Items.class.getDeclaredField(name).get(null);
}
catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e)
{
@@ -20,47 +20,54 @@
package net.minecraftforge.common.data;
import com.mojang.datafixers.util.Pair;
import net.minecraft.advancements.criterion.ItemPredicate;
import net.minecraft.advancements.critereon.ItemPredicate;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.LootTableProvider;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.tags.ITag;
import net.minecraft.util.ResourceLocation;
import net.minecraft.loot.*;
import net.minecraft.loot.conditions.Alternative;
import net.minecraft.loot.conditions.ILootCondition;
import net.minecraft.loot.conditions.Inverted;
import net.minecraft.loot.conditions.MatchTool;
import net.minecraft.data.loot.LootTableProvider;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.tags.Tag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.storage.loot.predicates.AlternativeLootItemCondition;
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
import net.minecraft.world.level.storage.loot.predicates.InvertedLootItemCondition;
import net.minecraft.world.level.storage.loot.predicates.MatchTool;
import net.minecraftforge.common.Tags;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import net.minecraft.world.level.storage.loot.LootPool;
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.ValidationContext;
import net.minecraft.world.level.storage.loot.entries.CompositeEntryBase;
import net.minecraft.world.level.storage.loot.entries.LootPoolEntryContainer;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSet;
/**
* Currently used only for replacing shears item to shears tag
*/
public class ForgeLootTableProvider extends LootTableProvider {
public final class ForgeLootTableProvider extends LootTableProvider {
public ForgeLootTableProvider(DataGenerator gen) {
super(gen);
}
@Override
protected void validate(Map<ResourceLocation, LootTable> map, ValidationTracker validationtracker) {
protected void validate(Map<ResourceLocation, LootTable> map, ValidationContext validationtracker) {
// do not validate against all registered loot tables
}
@Override
protected List<Pair<Supplier<Consumer<BiConsumer<ResourceLocation, LootTable.Builder>>>, LootParameterSet>> getTables() {
protected List<Pair<Supplier<Consumer<BiConsumer<ResourceLocation, LootTable.Builder>>>, LootContextParamSet>> getTables() {
return super.getTables().stream().map(pair -> {
// provides new consumer with filtering only changed loot tables and replacing condition item to condition tag
return new Pair<Supplier<Consumer<BiConsumer<ResourceLocation, LootTable.Builder>>>, LootParameterSet>(() -> replaceAndFilterChangesOnly(pair.getFirst().get()), pair.getSecond());
return new Pair<Supplier<Consumer<BiConsumer<ResourceLocation, LootTable.Builder>>>, LootContextParamSet>(() -> replaceAndFilterChangesOnly(pair.getFirst().get()), pair.getSecond());
}).collect(Collectors.toList());
}
@@ -72,12 +79,12 @@ public class ForgeLootTableProvider extends LootTableProvider {
});
}
private boolean findAndReplaceInLootTableBuilder(LootTable.Builder builder, Item from, ITag.INamedTag<Item> to) {
List<LootPool> lootPools = ObfuscationReflectionHelper.getPrivateValue(LootTable.Builder.class, builder, "field_216041" + "_a");
private boolean findAndReplaceInLootTableBuilder(LootTable.Builder builder, Item from, Tag.Named<Item> to) {
List<LootPool> lootPools = ObfuscationReflectionHelper.getPrivateValue(LootTable.Builder.class, builder, "f_7915" + "6_");
boolean found = false;
if (lootPools == null) {
throw new IllegalStateException(LootTable.Builder.class.getName() + " is missing field field_216041" + "_a");
throw new IllegalStateException(LootTable.Builder.class.getName() + " is missing field f_7915" + "6_");
}
for (LootPool lootPool : lootPools) {
@@ -89,39 +96,39 @@ public class ForgeLootTableProvider extends LootTableProvider {
return found;
}
private boolean findAndReplaceInLootPool(LootPool lootPool, Item from, ITag.INamedTag<Item> to) {
List<LootEntry> lootEntries = ObfuscationReflectionHelper.getPrivateValue(LootPool.class, lootPool, "field_186453" +"_a");
List<ILootCondition> lootConditions = ObfuscationReflectionHelper.getPrivateValue(LootPool.class, lootPool, "field_186454" + "_b");
private boolean findAndReplaceInLootPool(LootPool lootPool, Item from, Tag.Named<Item> to) {
List<LootPoolEntryContainer> lootEntries = ObfuscationReflectionHelper.getPrivateValue(LootPool.class, lootPool, "f_7902" +"3_");
List<LootItemCondition> lootConditions = ObfuscationReflectionHelper.getPrivateValue(LootPool.class, lootPool, "f_7902" + "4_");
boolean found = false;
if (lootEntries == null) {
throw new IllegalStateException(LootPool.class.getName() + " is missing field field_186453" + "_a");
throw new IllegalStateException(LootPool.class.getName() + " is missing field f_7902" + "3_");
}
for (LootEntry lootEntry : lootEntries) {
if (lootEntry instanceof ParentedLootEntry) {
if (findAndReplaceInParentedLootEntry((ParentedLootEntry) lootEntry, from, to)) {
for (LootPoolEntryContainer lootEntry : lootEntries) {
if (lootEntry instanceof CompositeEntryBase) {
if (findAndReplaceInParentedLootEntry((CompositeEntryBase) lootEntry, from, to)) {
found = true;
}
}
}
if (lootConditions == null) {
throw new IllegalStateException(LootPool.class.getName() + " is missing field field_186454" + "_b");
throw new IllegalStateException(LootPool.class.getName() + " is missing field f_7902" + "4_");
}
for (int i = 0; i < lootConditions.size(); i++) {
ILootCondition lootCondition = lootConditions.get(i);
LootItemCondition lootCondition = lootConditions.get(i);
if (lootCondition instanceof MatchTool && checkMatchTool((MatchTool) lootCondition, from)) {
lootConditions.set(i, MatchTool.toolMatches(ItemPredicate.Builder.item().of(to)).build());
found = true;
} else if (lootCondition instanceof Inverted) {
ILootCondition invLootCondition = ObfuscationReflectionHelper.getPrivateValue(Inverted.class, (Inverted) lootCondition, "field_215981" + "_a");
} else if (lootCondition instanceof InvertedLootItemCondition) {
LootItemCondition invLootCondition = ObfuscationReflectionHelper.getPrivateValue(InvertedLootItemCondition.class, (InvertedLootItemCondition) lootCondition, "f_8168" + "1_");
if (invLootCondition instanceof MatchTool && checkMatchTool((MatchTool) invLootCondition, from)) {
lootConditions.set(i, Inverted.invert(MatchTool.toolMatches(ItemPredicate.Builder.item().of(to))).build());
lootConditions.set(i, InvertedLootItemCondition.invert(MatchTool.toolMatches(ItemPredicate.Builder.item().of(to))).build());
found = true;
} else if (invLootCondition instanceof Alternative && findAndReplaceInAlternative((Alternative) invLootCondition, from, to)) {
} else if (invLootCondition instanceof AlternativeLootItemCondition && findAndReplaceInAlternative((AlternativeLootItemCondition) invLootCondition, from, to)) {
found = true;
}
}
@@ -130,15 +137,15 @@ public class ForgeLootTableProvider extends LootTableProvider {
return found;
}
private boolean findAndReplaceInParentedLootEntry(ParentedLootEntry entry, Item from, ITag.INamedTag<Item> to) {
LootEntry[] lootEntries = ObfuscationReflectionHelper.getPrivateValue(ParentedLootEntry.class, entry, "field_216147" + "_c");
private boolean findAndReplaceInParentedLootEntry(CompositeEntryBase entry, Item from, Tag.Named<Item> to) {
LootPoolEntryContainer[] lootEntries = ObfuscationReflectionHelper.getPrivateValue(CompositeEntryBase.class, entry, "f_7942" + "8_");
boolean found = false;
if (lootEntries == null) {
throw new IllegalStateException(ParentedLootEntry.class.getName() + " is missing field field_216147" + "_c");
throw new IllegalStateException(CompositeEntryBase.class.getName() + " is missing field f_7942" + "8_");
}
for (LootEntry lootEntry : lootEntries) {
for (LootPoolEntryContainer lootEntry : lootEntries) {
if (findAndReplaceInLootEntry(lootEntry, from, to)) {
found = true;
}
@@ -147,16 +154,16 @@ public class ForgeLootTableProvider extends LootTableProvider {
return found;
}
private boolean findAndReplaceInLootEntry(LootEntry entry, Item from, ITag.INamedTag<Item> to) {
ILootCondition[] lootConditions = ObfuscationReflectionHelper.getPrivateValue(LootEntry.class, entry, "field_216144" + "_d");
private boolean findAndReplaceInLootEntry(LootPoolEntryContainer entry, Item from, Tag.Named<Item> to) {
LootItemCondition[] lootConditions = ObfuscationReflectionHelper.getPrivateValue(LootPoolEntryContainer.class, entry, "f_7963" + "6_");
boolean found = false;
if (lootConditions == null) {
throw new IllegalStateException(LootEntry.class.getName() + " is missing field field_216144" + "_d");
throw new IllegalStateException(LootPoolEntryContainer.class.getName() + " is missing field f_7963" + "6_");
}
for (int i = 0; i < lootConditions.length; i++) {
if (lootConditions[i] instanceof Alternative && findAndReplaceInAlternative((Alternative) lootConditions[i], from, to)) {
if (lootConditions[i] instanceof AlternativeLootItemCondition && findAndReplaceInAlternative((AlternativeLootItemCondition) lootConditions[i], from, to)) {
found = true;
} else if (lootConditions[i] instanceof MatchTool && checkMatchTool((MatchTool) lootConditions[i], from)) {
lootConditions[i] = MatchTool.toolMatches(ItemPredicate.Builder.item().of(to)).build();
@@ -167,12 +174,12 @@ public class ForgeLootTableProvider extends LootTableProvider {
return found;
}
private boolean findAndReplaceInAlternative(Alternative alternative, Item from, ITag.INamedTag<Item> to) {
ILootCondition[] lootConditions = ObfuscationReflectionHelper.getPrivateValue(Alternative.class, alternative, "field_215962" + "_a");
private boolean findAndReplaceInAlternative(AlternativeLootItemCondition alternative, Item from, Tag.Named<Item> to) {
LootItemCondition[] lootConditions = ObfuscationReflectionHelper.getPrivateValue(AlternativeLootItemCondition.class, alternative, "f_8146" + "8_");
boolean found = false;
if (lootConditions == null) {
throw new IllegalStateException(Alternative.class.getName() + " is missing field field_215962" + "_a");
throw new IllegalStateException(AlternativeLootItemCondition.class.getName() + " is missing field f_8146" + "8_");
}
for (int i = 0; i < lootConditions.length; i++) {
@@ -186,8 +193,8 @@ public class ForgeLootTableProvider extends LootTableProvider {
}
private boolean checkMatchTool(MatchTool lootCondition, Item expected) {
ItemPredicate predicate = ObfuscationReflectionHelper.getPrivateValue(MatchTool.class, lootCondition, "field_216014" + "_a");
Item item = ObfuscationReflectionHelper.getPrivateValue(ItemPredicate.class, predicate, "field_192496" + "_b");
return item != null && item.equals(expected);
ItemPredicate predicate = ObfuscationReflectionHelper.getPrivateValue(MatchTool.class, lootCondition, "f_8199" + "3_");
Set<Item> items = ObfuscationReflectionHelper.getPrivateValue(ItemPredicate.class, predicate, "f_15142" + "7_");
return items != null && items.contains(expected);
}
}
@@ -31,28 +31,28 @@ import java.util.function.Consumer;
import com.google.gson.JsonObject;
import net.minecraft.block.Blocks;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.DirectoryCache;
import net.minecraft.data.IFinishedRecipe;
import net.minecraft.data.RecipeProvider;
import net.minecraft.data.ShapedRecipeBuilder;
import net.minecraft.data.ShapelessRecipeBuilder;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.crafting.Ingredient.IItemList;
import net.minecraft.item.crafting.Ingredient.TagList;
import net.minecraft.item.crafting.Ingredient.SingleItemList;
import net.minecraft.tags.ITag;
import net.minecraft.util.IItemProvider;
import net.minecraft.util.ResourceLocation;
import net.minecraft.data.HashCache;
import net.minecraft.data.recipes.FinishedRecipe;
import net.minecraft.data.recipes.RecipeProvider;
import net.minecraft.data.recipes.ShapedRecipeBuilder;
import net.minecraft.data.recipes.ShapelessRecipeBuilder;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.Ingredient.Value;
import net.minecraft.world.item.crafting.Ingredient.TagValue;
import net.minecraft.world.item.crafting.Ingredient.ItemValue;
import net.minecraft.tags.Tag;
import net.minecraft.world.level.ItemLike;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.common.Tags;
public class ForgeRecipeProvider extends RecipeProvider
public final class ForgeRecipeProvider extends RecipeProvider
{
private Map<Item, ITag<Item>> replacements = new HashMap<>();
private Map<Item, Tag<Item>> replacements = new HashMap<>();
private Set<ResourceLocation> excludes = new HashSet<>();
public ForgeRecipeProvider(DataGenerator generatorIn)
@@ -60,18 +60,18 @@ public class ForgeRecipeProvider extends RecipeProvider
super(generatorIn);
}
private void exclude(IItemProvider item)
private void exclude(ItemLike item)
{
excludes.add(item.asItem().getRegistryName());
}
private void replace(IItemProvider item, ITag<Item> tag)
private void replace(ItemLike item, Tag<Item> tag)
{
replacements.put(item.asItem(), tag);
}
@Override
protected void buildShapelessRecipes(Consumer<IFinishedRecipe> consumer)
protected void buildCraftingRecipes(Consumer<FinishedRecipe> consumer)
{
replace(Items.STICK, Tags.Items.RODS_WOODEN);
replace(Items.GOLD_INGOT, Tags.Items.INGOTS_GOLD);
@@ -94,19 +94,19 @@ public class ForgeRecipeProvider extends RecipeProvider
exclude(Blocks.COBBLESTONE_SLAB);
exclude(Blocks.COBBLESTONE_WALL);
super.buildShapelessRecipes(vanilla -> {
IFinishedRecipe modified = enhance(vanilla);
super.buildCraftingRecipes(vanilla -> {
FinishedRecipe modified = enhance(vanilla);
if (modified != null)
consumer.accept(modified);
});
}
@Override
protected void saveAdvancement(DirectoryCache cache, JsonObject advancementJson, Path pathIn) {
protected void saveAdvancement(HashCache cache, JsonObject advancementJson, Path pathIn) {
//NOOP - We dont replace any of the advancement things yet...
}
private IFinishedRecipe enhance(IFinishedRecipe vanilla)
private FinishedRecipe enhance(FinishedRecipe vanilla)
{
if (vanilla instanceof ShapelessRecipeBuilder.Result)
return enhance((ShapelessRecipeBuilder.Result)vanilla);
@@ -115,7 +115,7 @@ public class ForgeRecipeProvider extends RecipeProvider
return null;
}
private IFinishedRecipe enhance(ShapelessRecipeBuilder.Result vanilla)
private FinishedRecipe enhance(ShapelessRecipeBuilder.Result vanilla)
{
List<Ingredient> ingredients = getField(ShapelessRecipeBuilder.Result.class, vanilla, 4);
boolean modified = false;
@@ -131,7 +131,7 @@ public class ForgeRecipeProvider extends RecipeProvider
return modified ? vanilla : null;
}
private IFinishedRecipe enhance(ShapedRecipeBuilder.Result vanilla)
private FinishedRecipe enhance(ShapedRecipeBuilder.Result vanilla)
{
Map<Character, Ingredient> ingredients = getField(ShapedRecipeBuilder.Result.class, vanilla, 5);
boolean modified = false;
@@ -153,17 +153,17 @@ public class ForgeRecipeProvider extends RecipeProvider
return null;
boolean modified = false;
List<IItemList> items = new ArrayList<>();
IItemList[] vanillaItems = getField(Ingredient.class, vanilla, 2); //This will probably crash between versions, if null fix index
for (IItemList entry : vanillaItems)
List<Value> items = new ArrayList<>();
Value[] vanillaItems = getField(Ingredient.class, vanilla, 2); //This will probably crash between versions, if null fix index
for (Value entry : vanillaItems)
{
if (entry instanceof SingleItemList)
if (entry instanceof ItemValue)
{
ItemStack stack = entry.getItems().stream().findFirst().orElse(ItemStack.EMPTY);
ITag<Item> replacement = replacements.get(stack.getItem());
Tag<Item> replacement = replacements.get(stack.getItem());
if (replacement != null)
{
items.add(new TagList(replacement));
items.add(new TagValue(replacement));
modified = true;
}
else
@@ -25,9 +25,9 @@ import java.nio.file.Path;
import java.util.Map;
import javax.annotation.Nullable;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.TagsProvider;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.Registry;
import net.minecraft.data.tags.TagsProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.Registry;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.ForgeRegistry;
import net.minecraftforge.registries.GameData;
@@ -24,13 +24,12 @@ import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.DirectoryCache;
import net.minecraft.data.IDataProvider;
import net.minecraft.util.ResourceLocation;
import net.minecraft.data.HashCache;
import net.minecraft.data.DataProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Tuple;
import net.minecraftforge.common.loot.GlobalLootModifierSerializer;
import net.minecraftforge.common.loot.IGlobalLootModifier;
import net.minecraftforge.common.loot.LootModifier;
import java.io.IOException;
import java.nio.file.Path;
@@ -41,11 +40,11 @@ import java.util.Map;
import java.util.stream.Collectors;
/**
* Provider for forge's GlobalLootModifier system. See {@link LootModifier} and {@link GlobalLootModifierSerializer}.
* Provider for forge's GlobalLootModifier system. See {@link net.minecraftforge.common.loot.LootModifier} and {@link GlobalLootModifierSerializer}.
*
* This provider only requires implementing {@link #start()} and calling {@link #add} from it.
*/
public abstract class GlobalLootModifierProvider implements IDataProvider
public abstract class GlobalLootModifierProvider implements DataProvider
{
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
private final DataGenerator gen;
@@ -73,7 +72,7 @@ public abstract class GlobalLootModifierProvider implements IDataProvider
protected abstract void start();
@Override
public void run(DirectoryCache cache) throws IOException
public void run(HashCache cache) throws IOException
{
start();
@@ -89,14 +88,14 @@ public abstract class GlobalLootModifierProvider implements IDataProvider
JsonObject json = pair.getB();
json.addProperty("type", pair.getA().getRegistryName().toString());
IDataProvider.save(GSON, cache, json, modifierPath);
DataProvider.save(GSON, cache, json, modifierPath);
}));
JsonObject forgeJson = new JsonObject();
forgeJson.addProperty("replace", this.replace);
forgeJson.add("entries", GSON.toJsonTree(entries.stream().map(ResourceLocation::toString).collect(Collectors.toList())));
IDataProvider.save(GSON, cache, forgeJson, forgePath);
DataProvider.save(GSON, cache, forgeJson, forgePath);
}
/**
@@ -33,19 +33,18 @@ import org.apache.commons.lang3.text.translate.JavaUnicodeEscaper;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import net.minecraft.block.Block;
import net.minecraft.world.level.block.Block;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.DirectoryCache;
import net.minecraft.data.IDataProvider;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.EntityType;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Effect;
import net.minecraft.world.biome.Biome;
import net.minecraft.data.HashCache;
import net.minecraft.data.DataProvider;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.effect.MobEffect;
@SuppressWarnings("deprecation")
public abstract class LanguageProvider implements IDataProvider {
public abstract class LanguageProvider implements DataProvider {
private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create();
private final Map<String, String> data = new TreeMap<>();
private final DataGenerator gen;
@@ -61,7 +60,7 @@ public abstract class LanguageProvider implements IDataProvider {
protected abstract void addTranslations();
@Override
public void run(DirectoryCache cache) throws IOException {
public void run(HashCache cache) throws IOException {
addTranslations();
if (!data.isEmpty())
save(cache, data, this.gen.getOutputFolder().resolve("assets/" + modid + "/lang/" + locale + ".json"));
@@ -72,10 +71,10 @@ public abstract class LanguageProvider implements IDataProvider {
return "Languages: " + locale;
}
private void save(DirectoryCache cache, Object object, Path target) throws IOException {
private void save(HashCache cache, Object object, Path target) throws IOException {
String data = GSON.toJson(object);
data = JavaUnicodeEscaper.outsideOf(0, 0x7f).translate(data); // Escape unicode after the fact so that it's not double escaped by GSON
String hash = IDataProvider.SHA1.hashUnencodedChars(data).toString();
String hash = DataProvider.SHA1.hashUnencodedChars(data).toString();
if (!Objects.equals(cache.getHash(target), hash) || !Files.exists(target)) {
Files.createDirectories(target.getParent());
@@ -129,11 +128,11 @@ public abstract class LanguageProvider implements IDataProvider {
}
*/
public void addEffect(Supplier<? extends Effect> key, String name) {
public void addEffect(Supplier<? extends MobEffect> key, String name) {
add(key.get(), name);
}
public void add(Effect key, String name) {
public void add(MobEffect key, String name) {
add(key.getDescriptionId(), name);
}
@@ -23,7 +23,7 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import net.minecraft.util.ResourceLocation;
import net.minecraft.resources.ResourceLocation;
import javax.annotation.Nullable;
import java.util.ArrayList;
@@ -23,11 +23,11 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.DirectoryCache;
import net.minecraft.data.IDataProvider;
import net.minecraft.resources.ResourcePackType;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraft.data.HashCache;
import net.minecraft.data.DataProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.PackType;
import net.minecraft.sounds.SoundEvent;
import net.minecraftforge.registries.ForgeRegistries;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -44,7 +44,7 @@ import java.util.stream.Collectors;
* Data provider for the {@code sounds.json} file, which identifies sound definitions
* for the various sound events in Minecraft.
*/
public abstract class SoundDefinitionsProvider implements IDataProvider
public abstract class SoundDefinitionsProvider implements DataProvider
{
private static final Logger LOGGER = LogManager.getLogger();
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
@@ -74,7 +74,7 @@ public abstract class SoundDefinitionsProvider implements IDataProvider
public abstract void registerSounds();
@Override
public void run(DirectoryCache cache) throws IOException
public void run(HashCache cache) throws IOException
{
this.sounds.clear();
this.registerSounds();
@@ -249,7 +249,7 @@ public abstract class SoundDefinitionsProvider implements IDataProvider
private boolean validateSound(final String soundName, final ResourceLocation name)
{
final boolean valid = this.helper.exists(name, ResourcePackType.CLIENT_RESOURCES, ".ogg", "sounds");
final boolean valid = this.helper.exists(name, PackType.CLIENT_RESOURCES, ".ogg", "sounds");
if (!valid)
{
final String path = name.getNamespace() + ":sounds/" + name.getPath() + ".ogg";
@@ -268,9 +268,9 @@ public abstract class SoundDefinitionsProvider implements IDataProvider
return valid;
}
private void save(final DirectoryCache cache, final Path targetFile) throws IOException
private void save(final HashCache cache, final Path targetFile) throws IOException
{
IDataProvider.save(GSON, cache, this.mapToJson(this.sounds), targetFile);
DataProvider.save(GSON, cache, this.mapToJson(this.sounds), targetFile);
}
private JsonObject mapToJson(final Map<String, SoundDefinition> map)
@@ -21,5 +21,5 @@
@MethodsReturnNonnullByDefault
package net.minecraftforge.common.data;
import mcp.MethodsReturnNonnullByDefault;
import net.minecraft.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;