标签系统非常棒!它在模组的配置和兼容性方面带来了翻天覆地的变化。 本模组旨在从 1.13 版本回溯移植标签系统。
本模组完全从零开始编码和升级;其中完全不包含任何原版代码。名称 TagManager 直接引用了较新版本系统的核心部分 “net.minecraft.tags.TagManager.class”。除了进行升级外,本模组经过高度优化和测试。不仅针对性能进行了优化,也针对内存进行了优化。
除了标签(Tags)之外,该模组还添加了表(Tables)和整数表(Integer Tables)。本模组还提供了一些有用的原生标签,例如 “tagmanager:tin_ores”(锡矿石)。
要在条目中指定确切的元数据,请使用 “_:#”。
示例:“minecraft:planks:2” 代表白桦木板。
标签的格式与较新版本中的完全相同。请记住,在 扁平化 之前,许多条目使用不同的 ID 值。还有一种添加可选条目的方法。除了原版方式外,您还可以在 “values” 旁边指定一个 “optional” 列表。
表允许将方块/X 转换为另一个方块/X。这对于 1.12.2 中的深板岩或生物群系的邪恶变体等用途很有用。本模组不添加深板岩或任何新方块。表由一个包含 “to”(目标)和 “from”(来源)属性的列表构成。还有一个 “name”(名称)属性,它在代码中可见但未使用;它只是用于让代码在需要时查找条目。默认情况下,名称将与属性 “to” 匹配。
示例:
{
"values": [
{
"from": "minecraft:log",
"to": "projectazalea:stripped_log"
},
{
"from": "minecraft:log2",
"to": "projectazalea:stripped_log2"
},
{
"from": "projectazalea:bark",
"to": "projectazalea:stripped_bark"
},
{
"name": "projectazalea:newer_bark_blocks",
"from": "projectazalea:bark2",
"to": "projectazalea:stripped_bark2"
}
]
}
整数表将 X 转换为整数。这对于附魔力量等级或矿石价值等用途很有用。这些表的结构包含 “key”(键)和 “value”(值)属性。
示例:
{
"values": [
{
"key": "minecraft:magma_cream",
"value": 2
},
{
"key": "minecraft:blaze_powder",
"value": 3
},
{
"key": "minecraft:torch",
"value": 3
},
{
"key": "minecraft:magma",
"value": 4
},
{
"key": "minecraft:lava_bucket",
"value": 5
},
{
"key": "minecraft:blaze_rod",
"value": 12
}
]
}
加载顺序如下:
1: 运行 TagPrimeEvent
2: 保存 config/default/*.json
3: 加载 config/custom/.json 和 config/default/.json
使用 /reload 命令是有效的(在非开发环境中),因此您每次做出更改后不必重新启动 Minecraft!
免责声明
单独使用时,TagManager 数据没有任何作用。
对于开发者
剧透
与较新版本的 Minecraft 不同,标签是通过代码创建的;在此版本中数据包尚不可被模组修改。它不会在正确的时间刷新,且唯一的模组文件加载代码仅存在于客户端。
要创建标签,您必须创建一个字段来持有标签键。与发生 扁平化 后的较新版本 MC 不同,方块和物品的指定方式有所不同。
方块标签键为: "TagKey<IBlockState>"
物品标签键为: "TagKey<ItemStack>"
该字段以调用 "TagManager.X.createKey(R)" 结尾。'X' 是要为其创建键的注册表,如 BLOCKS 或 ITEMS。'R' 是用作标签 ID 的资源位置。
该字段即为标签引用。
要向您的标签或现有标签中添加条目,您必须使用该注册表的 TagPrimeEvent 子类。从那里您可以检查正在加载哪个标签并向指定的标签添加内容。此 'if' 语句至关重要。
例如:
public static final TagKey<IBlockState>ALLOWS_WEBBED_COBBLESTONE=TagManager.BLOCKS.createKey(new ResourceLocation("mysticalmobs","allows_webbed_cobblestone"));
public static final TagKey<IBlockState>BANE_OF_ARTHROPODS_EFFECTIVE=TagManager.BLOCKS.createKey(new ResourceLocation("mysticalmobs","bane_of_arthropods_effective"));
public static final TagKey<IBlockState>WEBBED_COBBLESTONE_REPLACEABLE=TagManager.BLOCKS.createKey(new ResourceLocation("mysticalmobs","webbed_cobblestone_replaceable"));
public static final TagKey<IBlockState>WEB_CLUSTER_REPLACEABLE=TagManager.BLOCKS.createKey(new ResourceLocation("mysticalmobs","web_cluster_replaceable"));
public static final TagKey<IBlockState>WEB_COCOON_REPLACEABLE=TagManager.BLOCKS.createKey(new ResourceLocation("mysticalmobs","web_cocoon_replaceable"));
@SubscribeEvent public void prime(BlockTagPrimeEvent event){
if(event.tag==BlockTags.BASE_STONE_OVERWORLD)event.required.add("mysticalmobs:webbed_cobblestone");
else if(event.tag==BlockTags.FLOWER_POTS)event.required.add("mysticalmobs:buttercup_flower_pot");
else if(event.tag==BlockTags.SMALL_FLOWERS)event.required.add("mysticalmobs:buttercup");
else if(event.tag==ALLOWS_WEBBED_COBBLESTONE)event.required.add("mysticalmobs:web_cocoon");
else if(event.tag==BANE_OF_ARTHROPODS_EFFECTIVE){
event.required.add("minecraft:monster_egg");
event.required.add("minecraft:web");
event.required.add("mysticalmobs:web");
event.required.add("mysticalmobs:web_cocoon");
event.required.add("mysticalmobs:webbed_cobblestone");
}
else if(event.tag==WEBBED_COBBLESTONE_REPLACEABLE){
event.required.add("minecraft:cobblestone");
event.required.add("minecraft:gravel");
event.required.add("minecraft:monster_egg:0");
event.required.add("minecraft:monster_egg:1");
event.required.add("minecraft:mossy_cobblestone");
event.required.add("minecraft:stone:0");
}
else if(event.tag==WEB_CLUSTER_REPLACEABLE){
event.required.add("minecraft:air");
event.required.add("mysticalmobs:web");
}
else if(event.tag==WEB_COCOON_REPLACEABLE)event.required.add("minecraft:web");
}
持有标签的类必须在 FMLPreInitializationEvent 中被引用,否则游戏将会崩溃!
示例:
MinecraftForge.EVENT_BUS.register(new ModBlockTags());
……或者……
ModBlockTags.WEB_COCOON_REPLACEABLE.location();
要使用标签,你必须调用 X.test(Y)。'X' 是标签键的实例。'Y' 是需要被测试的对象。
本模组可以作为仅使用 Java 反射的标签的软依赖。以下是一种良好的实现方式:
import java.util.function.Predicate;
public static final Predicate<IBlockState>BASE_STONE_OVERWORLD;
public static final Predicate<IBlockState>EXAMPLE_BLOCK_TAG;
public static final Predicate<ItemStack>EXAMPLE_ITEM_TAG;
static{
Predicate<IBlockState>m,n;
Predicate<ItemStack>o;
try{
Method d=Class.forName("com.quethed.tagmanager.TagManager")
.getDeclaredMethod("createKey",ResourceLocation.class,ResourceLocation.class,BiConsumer.class);
ResourceLocation l=new ResourceLocation("minecraft","block");
m=(Predicate<IBlockState>)d.invoke(null,l,new ResourceLocation("minecraft","base_stone_overworld"),null);
n=(Predicate<IBlockState>)d.invoke(null,l,new ResourceLocation("mod","example"),new BiConsumer<ArrayList<String>,ArrayList<String>>(){
@Override public void accept(ArrayList<String>required,ArrayList<String>optional){
required.add("minecraft:carrots");
required.add("minecraft:potatoes");
optional.add("betternether:egg_plant");
}
});
o=(Predicate<ItemStack>)d.invoke(null,new ResourceLocation("minecraft","item"),new ResourceLocation("mod","example"),new BiConsumer<ArrayList<String>,ArrayList<String>>(){
@Override public void accept(ArrayList<String>required,ArrayList<String>optional){
required.add("minecraft:apple");
required.add("minecraft:carrot");
required.add("minecraft:potato");
optional.add("betternether:egg_plant");
}
});
}catch(Throwable e){
m=(a)->{
if(a.getBlock()!=Blocks.STONE)return false;
BlockStone.EnumType b=a.getValue(BlockStone.VARIANT);
return b==BlockStone.EnumType.STONE||b==BlockStone.EnumType.GRANITE||b==BlockStone.EnumType.DIORITE||b==BlockStone.EnumType.ANDESITE;
};
n=(a)->{
Block b=a.getBlock();
return b==Blocks.CARROTS||b==Blocks.POTATOES;
};
o=(a)->{
Item b=a.getItem();
return b==Items.APPLE||b==Items.CARROT||b==Items.POTATO;
};
}
BASE_STONE_OVERWORLD=m;
EXAMPLE_BLOCK_TAG=n;
EXAMPLE_ITEM_TAG=o;
}
现在你已经了解了 TagManager 的基础知识,请查看代码以了解更多细节。
用户须知
剧透警告
整合包开发者可以轻松地修改或读取标签。遗憾的是,目前不支持数据包。若要修改数据:
第一步:找到 :/config/tagmanager/default/T/R/N/P.json。
T = 数据类型。
R = T 对应的注册表。
N = 模组 ID。
P = 条目名称。
默认文件不适合进行修改,并且每次加载时都会重置。默认文件的存在只是为了让你看到游戏正在加载的内容。
第二步:在相同位置创建一个新 JSON 文件,但将目录从 "default" 改为 "custom"。
第三步:在文件中写入新数据。请记住:使用的是 :/config/custom/ 而不是 :/config/default/。除非将 "replace"(替换)设置为 true,否则自定义数据将与默认数据混合。
常见问题:
剧透警告
Q: 我可以分享这个……吗?
A: 你可以分享链接或非商业性质的整合包。你不得在任何地方重新发布此页面。此页面仅在 Modrinth 上发布,以便澄清。你不得通过我的模组牟利!
Q: 我可以在我的整合包中使用它吗?
A: 你不能在任何涉及任何形式的付费行为的整合包中使用它,即使是捐赠特权或在付费服务器上锁定下载也不行。
Q: 你能把它移植到 X 版本/加载器吗?
A: 我只会移植到相邻的旧版本。对于新版本,我计划推出基于数据包的续作 "TableManager"。基本上,在 1.11 版本完成之前,我不会制作 1.10 版本。
Q: 我可以在我的视频中使用它吗?
A: 只要你给予署名并链接到此页面即可。此页面仅在 Modrinth 上发布,以便澄清。如果用于系列视频中,署名可以在首次出现时给出。所有视频中都必须包含链接,建议在描述中附上该链接。
The tag system is awesome! It is night and day for configuration AND compatibility of mods. This mod was made to backport the tag system from 1.13.
This mod was coded and upgraded entirely from the ground up; There is NO VANILLA code in it at all. The name TagManager was in direct reference to the heart of the newer system, "net.minecraft.tags.TagManager.class". In addition to being upgraded, this mod is highly optimized and tested. Not just optimized for performance but for memory too.
In addition to Tags, the mod also adds Tables and Integer Tables. This mod also provides some useful original tags like "tagmanager:tin_ores" for example.
To specify an exact metadata in an entry, use "_:#".
Example: "minecraft:planks:2" is Birch Planks.
The tags use the exact same format as in newer versions. Please remember that many entries use different id values before The Flattening. There is an additional way to add optional entries. Along with the vanilla way, you can specify an "optional" list along with "values".
Tables allow a block/X to be converted into another block/X. This is useful for stuff like deepslate in 1.12.2 or evil variants of biomes. This mod does NOT add deepslate or any new blocks. Tables are made as a list with a "to" and a "from" property. There is also a "name" property which is visible in the code but unused; It is just there so code can find entries if they need to. By default, the name will match the property "to".
Example:
{
"values": [
{
"from": "minecraft:log",
"to": "projectazalea:stripped_log"
},
{
"from": "minecraft:log2",
"to": "projectazalea:stripped_log2"
},
{
"from": "projectazalea:bark",
"to": "projectazalea:stripped_bark"
},
{
"name": "projectazalea:newer_bark_blocks",
"from": "projectazalea:bark2",
"to": "projectazalea:stripped_bark2"
}
]
}
Integer Tables convert X into integers. This is useful for stuff like enchantment power levels or ore values. These tables are structured with a "key" and a "value" property.
Example:
{
"values": [
{
"key": "minecraft:magma_cream",
"value": 2
},
{
"key": "minecraft:blaze_powder",
"value": 3
},
{
"key": "minecraft:torch",
"value": 3
},
{
"key": "minecraft:magma",
"value": 4
},
{
"key": "minecraft:lava_bucket",
"value": 5
},
{
"key": "minecraft:blaze_rod",
"value": 12
}
]
}
The load order is:
1: running TagPrimeEvent
2: saving config/default/*.json
3: loading config/custom/*.json and config/default/*.json
Using /reload DOES WORK (Outside the development environment) so you don't have to restart mc every time you make a change!
DISCLAIMER
Alone, TagManager data does nothing.
FOR DEVELOPERS
Spoiler
Unlike newer Minecraft, tags are made by code; Data packs are not yet modable in this version. It would not refresh at the right time and the only mod file loading code is client sided.
To create a tag, you must make a field to hold the tag key. Unlike newer mc, when The Flattening happened, blocks and items are specified differently.
Block tag keys are: "TagKey<IBlockState>"
Item tag keys are: "TagKey<ItemStack>"
The field ends with a call of "TagManager.X.createKey(R)". 'X' is the registry to create the key for, like BLOCKS or ITEMS. 'R' is the resource location used as the tag id.
That field is the tag reference.
To add entries to your tag or an existing one, you must use the sub class of TagPrimeEvent for the registry. From there you check which tag is being loaded and add to the specifed tag. THIS 'if' STATEMENT IS VITAL.
For example:
public static final TagKey<IBlockState>ALLOWS_WEBBED_COBBLESTONE=TagManager.BLOCKS.createKey(new ResourceLocation("mysticalmobs","allows_webbed_cobblestone"));
public static final TagKey<IBlockState>BANE_OF_ARTHROPODS_EFFECTIVE=TagManager.BLOCKS.createKey(new ResourceLocation("mysticalmobs","bane_of_arthropods_effective"));
public static final TagKey<IBlockState>WEBBED_COBBLESTONE_REPLACEABLE=TagManager.BLOCKS.createKey(new ResourceLocation("mysticalmobs","webbed_cobblestone_replaceable"));
public static final TagKey<IBlockState>WEB_CLUSTER_REPLACEABLE=TagManager.BLOCKS.createKey(new ResourceLocation("mysticalmobs","web_cluster_replaceable"));
public static final TagKey<IBlockState>WEB_COCOON_REPLACEABLE=TagManager.BLOCKS.createKey(new ResourceLocation("mysticalmobs","web_cocoon_replaceable"));
@SubscribeEvent public void prime(BlockTagPrimeEvent event){
if(event.tag==BlockTags.BASE_STONE_OVERWORLD)event.required.add("mysticalmobs:webbed_cobblestone");
else if(event.tag==BlockTags.FLOWER_POTS)event.required.add("mysticalmobs:buttercup_flower_pot");
else if(event.tag==BlockTags.SMALL_FLOWERS)event.required.add("mysticalmobs:buttercup");
else if(event.tag==ALLOWS_WEBBED_COBBLESTONE)event.required.add("mysticalmobs:web_cocoon");
else if(event.tag==BANE_OF_ARTHROPODS_EFFECTIVE){
event.required.add("minecraft:monster_egg");
event.required.add("minecraft:web");
event.required.add("mysticalmobs:web");
event.required.add("mysticalmobs:web_cocoon");
event.required.add("mysticalmobs:webbed_cobblestone");
}
else if(event.tag==WEBBED_COBBLESTONE_REPLACEABLE){
event.required.add("minecraft:cobblestone");
event.required.add("minecraft:gravel");
event.required.add("minecraft:monster_egg:0");
event.required.add("minecraft:monster_egg:1");
event.required.add("minecraft:mossy_cobblestone");
event.required.add("minecraft:stone:0");
}
else if(event.tag==WEB_CLUSTER_REPLACEABLE){
event.required.add("minecraft:air");
event.required.add("mysticalmobs:web");
}
else if(event.tag==WEB_COCOON_REPLACEABLE)event.required.add("minecraft:web");
}
Tag holding classes MUST be referenced in FMLPreInitializationEvent or the game WILL CRASH!
For examples:
MinecraftForge.EVENT_BUS.register(new ModBlockTags());
...or...
ModBlockTags.WEB_COCOON_REPLACEABLE.location();
To use a tag, you must call X.test(Y). 'X' is the instance of the tag key. 'Y' is the thing that needs to be tested.
This mod can be used as a soft dependancy for tags using only Java reflection. Here is a good way to do that:
import java.util.function.Predicate;
public static final Predicate<IBlockState>BASE_STONE_OVERWORLD;
public static final Predicate<IBlockState>EXAMPLE_BLOCK_TAG;
public static final Predicate<ItemStack>EXAMPLE_ITEM_TAG;
static{
Predicate<IBlockState>m,n;
Predicate<ItemStack>o;
try{
Method d=Class.forName("com.quethed.tagmanager.TagManager")
.getDeclaredMethod("createKey",ResourceLocation.class,ResourceLocation.class,BiConsumer.class);
ResourceLocation l=new ResourceLocation("minecraft","block");
m=(Predicate<IBlockState>)d.invoke(null,l,new ResourceLocation("minecraft","base_stone_overworld"),null);
n=(Predicate<IBlockState>)d.invoke(null,l,new ResourceLocation("mod","example"),new BiConsumer<ArrayList<String>,ArrayList<String>>(){
@Override public void accept(ArrayList<String>required,ArrayList<String>optional){
required.add("minecraft:carrots");
required.add("minecraft:potatoes");
optional.add("betternether:egg_plant");
}
});
o=(Predicate<ItemStack>)d.invoke(null,new ResourceLocation("minecraft","item"),new ResourceLocation("mod","example"),new BiConsumer<ArrayList<String>,ArrayList<String>>(){
@Override public void accept(ArrayList<String>required,ArrayList<String>optional){
required.add("minecraft:apple");
required.add("minecraft:carrot");
required.add("minecraft:potato");
optional.add("betternether:egg_plant");
}
});
}catch(Throwable e){
m=(a)->{
if(a.getBlock()!=Blocks.STONE)return false;
BlockStone.EnumType b=a.getValue(BlockStone.VARIANT);
return b==BlockStone.EnumType.STONE||b==BlockStone.EnumType.GRANITE||b==BlockStone.EnumType.DIORITE||b==BlockStone.EnumType.ANDESITE;
};
n=(a)->{
Block b=a.getBlock();
return b==Blocks.CARROTS||b==Blocks.POTATOES;
};
o=(a)->{
Item b=a.getItem();
return b==Items.APPLE||b==Items.CARROT||b==Items.POTATO;
};
}
BASE_STONE_OVERWORLD=m;
EXAMPLE_BLOCK_TAG=n;
EXAMPLE_ITEM_TAG=o;
}
Now that you know the basics of TagManager, please look at the code to learn more.
FOR USERS
Spoiler
Tags can be changed or read by modpack developers easily. There is no data pack support sadly. To change the data:
Step 1: find ":/config/tagmanager/default/T/R/N/P.json".
T = The type of data.
R = The registry for T.
N = The id of the mod.
P = The name of the entry.
The defaults are NOT suitable for modification and WILL RESET every load. The default files are just there so you can see what the game is loading.
Step 2: Make a new json file in the same location but in "custom" instead of "default".
Step 3: Write the new data in the file. REMEMBER: ":/config/custom/" NOT ":/config/default/". The custom data will be mixed with the default unless "replace" is set to true.
FAQ:
Spoiler
Q: Can I share this...?
A: You can share the link or the non-comercial modpack. You may NOT repost this anywhere. This page is on Modrinth only to clarify. YOU CANNOT MAKE MONEY FROM MY MOD!
Q: Can I use this in my modpack?
A: You cannot use this in modpacks with any form of purchase around it, not even donation perks or locking behind paid servers for downloads.
Q: Can you please port to X version/mod loader?
A: I will only port to adjecient older versions. For newer versions, I am planning the data pack sequel, "TableManager". Basically, I will not make 1.10 until 1.11 is done.
Q: Can I use this in my video?
A: As long as you give me credit and link to this page. This page is on Modrinth only to clarify. The credit can be when it first appears only if used in a series. The link must be in all videos, the description is recommended for that.
评论 0
登录后参与评分
还没有评论,来抢沙发吧