mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 16:27:47 +00:00
Expose the data entry point and generate Forge's Tags using it.
This commit is contained in:
1 parent
c30b27fcfe
commit
e1cdb2e558
114 files changed
+673
-117
No files matched your search
@@ -44,13 +44,17 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.resources.SimpleReloadableResourceManager;
|
||||
import net.minecraft.world.storage.SaveHandler;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.common.data.ForgeBlockTagsProvider;
|
||||
import net.minecraftforge.common.data.ForgeItemTagsProvider;
|
||||
import net.minecraftforge.common.model.animation.CapabilityAnimation;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.event.GatherDataEvent;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.resource.ISelectiveResourceReloadListener;
|
||||
@@ -95,6 +99,7 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook
|
||||
modEventBus.addListener(this::preInit);
|
||||
modEventBus.addListener(this::postInit);
|
||||
modEventBus.addListener(this::onAvailable);
|
||||
modEventBus.addListener(this::gatherData);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::serverStarting);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::playerLogin);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::serverStopping);
|
||||
@@ -140,7 +145,11 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook
|
||||
}
|
||||
|
||||
// Brandings need to recompute when language changes
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> ((SimpleReloadableResourceManager)Minecraft.getInstance().getResourceManager()).func_219534_a((ISelectiveResourceReloadListener) BrandingControl::clearCaches));
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
if (mc != null)
|
||||
((SimpleReloadableResourceManager)mc.getResourceManager()).func_219534_a((ISelectiveResourceReloadListener) BrandingControl::clearCaches);
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -223,4 +232,15 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook
|
||||
{
|
||||
return ForgeVersion.MOD_ID;
|
||||
}
|
||||
|
||||
public void gatherData(GatherDataEvent event)
|
||||
{
|
||||
DataGenerator gen = event.getGenerator();
|
||||
|
||||
if (event.includeServer())
|
||||
{
|
||||
gen.addProvider(new ForgeBlockTagsProvider(gen));
|
||||
gen.addProvider(new ForgeItemTagsProvider(gen));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public class Tags
|
||||
public static final Tag<Item> FENCE_GATES = tag("fence_gates");
|
||||
public static final Tag<Item> FENCE_GATES_WOODEN = tag("fence_gates/wooden");
|
||||
public static final Tag<Item> FENCES = tag("fences");
|
||||
public static final Tag<Item> FENCES_NETHER_BRRICK = tag("fences/nether_brick");
|
||||
public static final Tag<Item> FENCES_NETHER_BRICK = tag("fences/nether_brick");
|
||||
public static final Tag<Item> FENCES_WOODEN = tag("fences/wooden");
|
||||
public static final Tag<Item> GEMS = tag("gems");
|
||||
public static final Tag<Item> GEMS_DIAMOND = tag("gems/diamond");
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.data;
|
||||
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.data.BlockTagsProvider;
|
||||
|
||||
import static net.minecraftforge.common.Tags.Blocks.*;
|
||||
|
||||
public class ForgeBlockTagsProvider extends BlockTagsProvider
|
||||
{
|
||||
public ForgeBlockTagsProvider(DataGenerator gen)
|
||||
{
|
||||
super(gen);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTags()
|
||||
{
|
||||
getBuilder(CHESTS).add(CHESTS_ENDER, CHESTS_TRAPPED, CHESTS_WOODEN);
|
||||
getBuilder(CHESTS_ENDER).add(Blocks.ENDER_CHEST);
|
||||
getBuilder(CHESTS_TRAPPED).add(Blocks.TRAPPED_CHEST);
|
||||
getBuilder(CHESTS_WOODEN).add(Blocks.CHEST, Blocks.TRAPPED_CHEST);
|
||||
getBuilder(COBBLESTONE).add(Blocks.COBBLESTONE, Blocks.INFESTED_COBBLESTONE, Blocks.MOSSY_COBBLESTONE);
|
||||
getBuilder(DIRT).add(Blocks.DIRT, Blocks.COARSE_DIRT, Blocks.PODZOL);
|
||||
getBuilder(FENCE_GATES).add(FENCE_GATES_WOODEN);
|
||||
getBuilder(FENCE_GATES_WOODEN).add(Blocks.OAK_FENCE_GATE, Blocks.SPRUCE_FENCE_GATE, Blocks.BIRCH_FENCE_GATE, Blocks.JUNGLE_FENCE_GATE, Blocks.ACACIA_FENCE_GATE, Blocks.DARK_OAK_FENCE_GATE);
|
||||
getBuilder(FENCES).add(FENCES_NETHER_BRICK, FENCES_WOODEN);
|
||||
getBuilder(FENCES_NETHER_BRICK).add(Blocks.NETHER_BRICK_FENCE);
|
||||
getBuilder(FENCES_WOODEN).add(Blocks.OAK_FENCE, Blocks.SPRUCE_FENCE, Blocks.BIRCH_FENCE, Blocks.JUNGLE_FENCE, Blocks.ACACIA_FENCE, Blocks.DARK_OAK_FENCE);
|
||||
getBuilder(ORES).add(ORES_COAL, ORES_DIAMOND, ORES_EMERALD, ORES_GOLD, ORES_IRON, ORES_LAPIS, ORES_REDSTONE, ORES_QUARTZ);
|
||||
getBuilder(ORES_COAL).add(Blocks.COAL_ORE);
|
||||
getBuilder(ORES_DIAMOND).add(Blocks.DIAMOND_ORE);
|
||||
getBuilder(ORES_EMERALD).add(Blocks.EMERALD_ORE);
|
||||
getBuilder(ORES_GOLD).add(Blocks.GOLD_ORE);
|
||||
getBuilder(ORES_IRON).add(Blocks.IRON_ORE);
|
||||
getBuilder(ORES_LAPIS).add(Blocks.LAPIS_ORE);
|
||||
getBuilder(ORES_QUARTZ).add(Blocks.NETHER_QUARTZ_ORE);
|
||||
getBuilder(ORES_REDSTONE).add(Blocks.REDSTONE_ORE);
|
||||
getBuilder(STONE).add(Blocks.ANDESITE, Blocks.DIORITE, Blocks.GRANITE, Blocks.INFESTED_STONE, Blocks.STONE, Blocks.POLISHED_ANDESITE, Blocks.POLISHED_DIORITE, Blocks.POLISHED_GRANITE);
|
||||
getBuilder(STORAGE_BLOCKS).add(STORAGE_BLOCKS_COAL, STORAGE_BLOCKS_DIAMOND, STORAGE_BLOCKS_EMERALD, STORAGE_BLOCKS_GOLD, STORAGE_BLOCKS_IRON, STORAGE_BLOCKS_LAPIS, STORAGE_BLOCKS_QUARTZ, STORAGE_BLOCKS_REDSTONE);
|
||||
getBuilder(STORAGE_BLOCKS_COAL).add(Blocks.COAL_BLOCK);
|
||||
getBuilder(STORAGE_BLOCKS_DIAMOND).add(Blocks.DIAMOND_BLOCK);
|
||||
getBuilder(STORAGE_BLOCKS_EMERALD).add(Blocks.EMERALD_BLOCK);
|
||||
getBuilder(STORAGE_BLOCKS_GOLD).add(Blocks.GOLD_BLOCK);
|
||||
getBuilder(STORAGE_BLOCKS_IRON).add(Blocks.IRON_BLOCK);
|
||||
getBuilder(STORAGE_BLOCKS_LAPIS).add(Blocks.LAPIS_BLOCK);
|
||||
getBuilder(STORAGE_BLOCKS_QUARTZ).add(Blocks.QUARTZ_BLOCK);
|
||||
getBuilder(STORAGE_BLOCKS_REDSTONE).add(Blocks.REDSTONE_BLOCK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "Forge Block Tags";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.data;
|
||||
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.ItemTagsProvider;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraftforge.common.Tags;
|
||||
|
||||
public class ForgeItemTagsProvider extends ItemTagsProvider
|
||||
{
|
||||
public ForgeItemTagsProvider(DataGenerator gen)
|
||||
{
|
||||
super(gen);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTags()
|
||||
{
|
||||
copy(Tags.Blocks.CHESTS, Tags.Items.CHESTS);
|
||||
copy(Tags.Blocks.CHESTS_ENDER, Tags.Items.CHESTS_ENDER);
|
||||
copy(Tags.Blocks.CHESTS_TRAPPED, Tags.Items.CHESTS_TRAPPED);
|
||||
copy(Tags.Blocks.CHESTS_WOODEN, Tags.Items.CHESTS_WOODEN);
|
||||
copy(Tags.Blocks.COBBLESTONE, Tags.Items.COBBLESTONE);
|
||||
getBuilder(Tags.Items.DUSTS).add(Tags.Items.DUSTS_GLOWSTONE, Tags.Items.DUSTS_PRISMARINE, Tags.Items.DUSTS_REDSTONE);
|
||||
getBuilder(Tags.Items.DUSTS_GLOWSTONE).add(Items.GLOWSTONE_DUST);
|
||||
getBuilder(Tags.Items.DUSTS_PRISMARINE).add(Items.PRISMARINE_SHARD);
|
||||
getBuilder(Tags.Items.DUSTS_REDSTONE).add(Items.REDSTONE);
|
||||
getBuilder(Tags.Items.DYES).add(Tags.Items.DYES_BLACK, Tags.Items.DYES_RED, Tags.Items.DYES_GREEN, Tags.Items.DYES_BROWN, Tags.Items.DYES_BLUE, Tags.Items.DYES_PURPLE, Tags.Items.DYES_CYAN, Tags.Items.DYES_LIGHT_GRAY, Tags.Items.DYES_GRAY, Tags.Items.DYES_PINK, Tags.Items.DYES_LIME, Tags.Items.DYES_YELLOW, Tags.Items.DYES_LIGHT_BLUE, Tags.Items.DYES_MAGENTA, Tags.Items.DYES_ORANGE, Tags.Items.DYES_WHITE);
|
||||
getBuilder(Tags.Items.DYES_BLACK).add(Items.INK_SAC);
|
||||
getBuilder(Tags.Items.DYES_BLUE).add(Items.LAPIS_LAZULI);
|
||||
getBuilder(Tags.Items.DYES_BROWN).add(Items.COCOA_BEANS);
|
||||
getBuilder(Tags.Items.DYES_CYAN).add(Items.CYAN_DYE);
|
||||
getBuilder(Tags.Items.DYES_GRAY).add(Items.GRAY_DYE);
|
||||
getBuilder(Tags.Items.DYES_GREEN).add(Items.field_222079_lj);
|
||||
getBuilder(Tags.Items.DYES_LIGHT_BLUE).add(Items.LIGHT_BLUE_DYE);
|
||||
getBuilder(Tags.Items.DYES_LIGHT_GRAY).add(Items.LIGHT_GRAY_DYE);
|
||||
getBuilder(Tags.Items.DYES_LIME).add(Items.LIME_DYE);
|
||||
getBuilder(Tags.Items.DYES_MAGENTA).add(Items.MAGENTA_DYE);
|
||||
getBuilder(Tags.Items.DYES_ORANGE).add(Items.ORANGE_DYE);
|
||||
getBuilder(Tags.Items.DYES_PINK).add(Items.PINK_DYE);
|
||||
getBuilder(Tags.Items.DYES_PURPLE).add(Items.PURPLE_DYE);
|
||||
getBuilder(Tags.Items.DYES_RED).add(Items.field_222078_li);
|
||||
getBuilder(Tags.Items.DYES_WHITE).add(Items.BONE_MEAL);
|
||||
getBuilder(Tags.Items.DYES_YELLOW).add(Items.field_222081_ls);
|
||||
copy(Tags.Blocks.FENCE_GATES, Tags.Items.FENCE_GATES);
|
||||
copy(Tags.Blocks.FENCE_GATES_WOODEN, Tags.Items.FENCE_GATES_WOODEN);
|
||||
copy(Tags.Blocks.FENCES, Tags.Items.FENCES);
|
||||
copy(Tags.Blocks.FENCES_NETHER_BRICK, Tags.Items.FENCES_NETHER_BRICK);
|
||||
copy(Tags.Blocks.FENCES_WOODEN, Tags.Items.FENCES_WOODEN);
|
||||
getBuilder(Tags.Items.GEMS).add(Tags.Items.GEMS_DIAMOND, Tags.Items.GEMS_EMERALD, Tags.Items.GEMS_LAPIS, Tags.Items.GEMS_PRISMARINE, Tags.Items.GEMS_QUARTZ);
|
||||
getBuilder(Tags.Items.GEMS_DIAMOND).add(Items.DIAMOND);
|
||||
getBuilder(Tags.Items.GEMS_EMERALD).add(Items.EMERALD);
|
||||
getBuilder(Tags.Items.GEMS_LAPIS).add(Items.LAPIS_LAZULI);
|
||||
getBuilder(Tags.Items.GEMS_PRISMARINE).add(Items.PRISMARINE_CRYSTALS);
|
||||
getBuilder(Tags.Items.GEMS_QUARTZ).add(Items.QUARTZ);
|
||||
getBuilder(Tags.Items.INGOTS).add(Tags.Items.INGOTS_IRON, Tags.Items.INGOTS_GOLD, Tags.Items.INGOTS_BRICK, Tags.Items.INGOTS_NETHER_BRICK);
|
||||
getBuilder(Tags.Items.INGOTS_BRICK).add(Items.BRICK);
|
||||
getBuilder(Tags.Items.INGOTS_GOLD).add(Items.GOLD_INGOT);
|
||||
getBuilder(Tags.Items.INGOTS_IRON).add(Items.IRON_INGOT);
|
||||
getBuilder(Tags.Items.INGOTS_NETHER_BRICK).add(Items.NETHER_BRICK);
|
||||
getBuilder(Tags.Items.MUSIC_DISCS).add(Items.MUSIC_DISC_13, Items.MUSIC_DISC_CAT, Items.MUSIC_DISC_BLOCKS, Items.MUSIC_DISC_CHIRP, Items.MUSIC_DISC_FAR, Items.MUSIC_DISC_MALL, Items.MUSIC_DISC_MELLOHI, Items.MUSIC_DISC_STAL, Items.MUSIC_DISC_STRAD, Items.MUSIC_DISC_WARD, Items.MUSIC_DISC_11, Items.MUSIC_DISC_WAIT);
|
||||
getBuilder(Tags.Items.NUGGETS).add(Tags.Items.NUGGETS_IRON, Tags.Items.NUGGETS_GOLD);
|
||||
getBuilder(Tags.Items.NUGGETS_IRON).add(Items.IRON_NUGGET);
|
||||
getBuilder(Tags.Items.NUGGETS_GOLD).add(Items.GOLD_NUGGET);
|
||||
copy(Tags.Blocks.ORES, Tags.Items.ORES);
|
||||
copy(Tags.Blocks.ORES_COAL, Tags.Items.ORES_COAL);
|
||||
copy(Tags.Blocks.ORES_DIAMOND, Tags.Items.ORES_DIAMOND);
|
||||
copy(Tags.Blocks.ORES_EMERALD, Tags.Items.ORES_EMERALD);
|
||||
copy(Tags.Blocks.ORES_GOLD, Tags.Items.ORES_GOLD);
|
||||
copy(Tags.Blocks.ORES_IRON, Tags.Items.ORES_IRON);
|
||||
copy(Tags.Blocks.ORES_LAPIS, Tags.Items.ORES_LAPIS);
|
||||
copy(Tags.Blocks.ORES_QUARTZ, Tags.Items.ORES_QUARTZ);
|
||||
copy(Tags.Blocks.ORES_REDSTONE, Tags.Items.ORES_REDSTONE);
|
||||
getBuilder(Tags.Items.RODS).add(Tags.Items.RODS_BLAZE, Tags.Items.RODS_WOODEN);
|
||||
getBuilder(Tags.Items.RODS_BLAZE).add(Items.BLAZE_ROD);
|
||||
getBuilder(Tags.Items.RODS_WOODEN).add(Items.STICK);
|
||||
copy(Tags.Blocks.STONE, Tags.Items.STONE);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS, Tags.Items.STORAGE_BLOCKS);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_COAL, Tags.Items.STORAGE_BLOCKS_COAL);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_DIAMOND, Tags.Items.STORAGE_BLOCKS_DIAMOND);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_EMERALD, Tags.Items.STORAGE_BLOCKS_EMERALD);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_GOLD, Tags.Items.STORAGE_BLOCKS_GOLD);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_IRON, Tags.Items.STORAGE_BLOCKS_IRON);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_LAPIS, Tags.Items.STORAGE_BLOCKS_LAPIS);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_QUARTZ, Tags.Items.STORAGE_BLOCKS_QUARTZ);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_REDSTONE, Tags.Items.STORAGE_BLOCKS_REDSTONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "Forge Item Tags";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.event;
|
||||
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
public class GatherDataEvent extends Event
|
||||
{
|
||||
private final DataGenerator generator;
|
||||
private final boolean server;
|
||||
private final boolean client;
|
||||
private final boolean dev;
|
||||
private final boolean reports;
|
||||
private final boolean validate;
|
||||
|
||||
public GatherDataEvent(DataGenerator gen, boolean server, boolean client, boolean dev, boolean reports, boolean validate)
|
||||
{
|
||||
this.generator = gen;
|
||||
this.server = server;
|
||||
this.client = client;
|
||||
this.dev = dev;
|
||||
this.reports = reports;
|
||||
this.validate = validate;
|
||||
}
|
||||
|
||||
public DataGenerator getGenerator() { return this.generator; }
|
||||
public boolean includeServer() { return this.server; }
|
||||
public boolean includeClient() { return this.client; }
|
||||
public boolean includeDev() { return this.dev; }
|
||||
public boolean includeReports() { return this.reports; }
|
||||
public boolean validate() { return this.validate; }
|
||||
}
|
||||
Reference in new issue
Block a user