Difference between revisions of "Datageneration/Tags"

From Forge Community Wiki
(Inital write up still needs work in the Custom Type Section)
 
(added {{Under construction}})
Line 1: Line 1:
 +
<span style="color: rgb(220, 221, 222); --darkreader-inline-color:#d3cfc9;" andale="" mono="" wt",="" "andale="" mono",="" "lucida="" console",="" sans="" typewriter",="" "dejavu="" "bitstream="" vera="" "liberation="" "nimbus="" l",="" monaco,="" "courier="" new",="" courier,="" monospace;="" font-size:="" 13.6px;="" font-style:="" normal;="" font-variant-ligatures:="" font-variant-caps:="" font-weight:="" 400;="" letter-spacing:="" orphans:="" 2;="" text-align:="" start;="" text-indent:="" 0px;="" text-transform:="" none;="" white-space:="" pre-wrap;="" widows:="" word-spacing:="" -webkit-text-stroke-width:="" background-color:="" rgb(47,="" 49,="" 54);="" text-decoration-style:="" initial;="" text-decoration-color:="" display:="" inline="" !important;="" float:="" none;"="" data-darkreader-inline-color="">{{Under construction}}</span>
 +
 +
 +
<style data-mw-deduplicate="TemplateStyles:r2197">.mw-parser-output .mw-tpl-construction{display:flex;align-items:center;width:75%;margin:auto;border-radius:0.2em;background:rgb(27,32,35);box-shadow:0 0 0.2em #999999;overflow:auto}.mw-parser-output .mw-tpl-construction-title{color:#FFFFFF;font-size:120%;font-weight:bold;padding:0.25em 1em}.mw-parser-output .mw-tpl-construction-title-icon{float:left;opacity:0.8;margin:1em}.mw-parser-output .mw-tpl-construction-content{padding:0.5em 1em 0.5em 1em;color:#FFFFFF}</style><style class="darkreader darkreader--sync" media="screen"></style><img alt="" src="/images/d/dc/Under_construction.svg" class="mw-tpl-construction-title-icon" width="60" height="60">This page is under construction.This page is incomplete, and needs more work. Feel free to edit and improve this page!
 +
 +
 +
 
Tags can be generated by extending the <code>ItemTagsProvider</code> for Items or <code>BlockTagsProvider</code> for Blocks. For Custom Objects you would need to expand <code>TagsProvider</code> and give it the Object you want tags for. For the registration of you Tags you need to override the <code>TagsProvider#registerTags</code> method.
 
Tags can be generated by extending the <code>ItemTagsProvider</code> for Items or <code>BlockTagsProvider</code> for Blocks. For Custom Objects you would need to expand <code>TagsProvider</code> and give it the Object you want tags for. For the registration of you Tags you need to override the <code>TagsProvider#registerTags</code> method.
  
Line 4: Line 11:
 
{{Colored box|title=Information|content=You can still use <code>TagsProvider</code> for Items and Blocks but you would need to implement a lot of stuff that is already done in <code>ItemTagsProvider</code> and <code>BlockTagsProvider</code>}}
 
{{Colored box|title=Information|content=You can still use <code>TagsProvider</code> for Items and Blocks but you would need to implement a lot of stuff that is already done in <code>ItemTagsProvider</code> and <code>BlockTagsProvider</code>}}
  
== Items/Blocks ==
+
 
First you should make a <code>ITag.INamedTag</code>(NamedTag) with <code>ItemTags#makeWrapperTag</code> for Items or <code>BlockTags#makeWrapperTag</code> for blocks, this will take the name of you Tag, see [[Tags#Conventions]] for more info. After you have the <code>NamedTag</code> you can start with the actual creation of the Tag, you would first call <code>TagsProvider#getOrCreateBuilder</code> which takes the NamedTag as an Argument, this returns a <code>TagsProvider.Builder</code>. Now you can with <code>TagsProvider.Builder#add</code> add one or more Items/Blocks or other Tags to your own Tags.  
+
<style data-mw-deduplicate="TemplateStyles:r2068">.mw-parser-output .mw-tpl-colorbox{box-sizing:border-box;margin:0.5em 0.5em 1em 0.5em;border-radius:0.2em;background:rgb(27,32,35);box-shadow:0 0 0.2em #999999}.mw-parser-output .mw-tpl-colorbox-title{background:rgb(0,71,127);color:#FFFFFF;border-radius:0.2em 0.2em 0 0;padding:0.5em 1em 0.5em 1em}.mw-parser-output .mw-tpl-colorbox-title-icon{opacity:0.8}.mw-parser-output .mw-tpl-colorbox-title-corner{float:right;font-size:0.7em}.mw-parser-output .mw-tpl-colorbox-content{padding:0.5em 1em 0.5em 1em;color:#FFFFFF}</style><style class="darkreader darkreader--sync" media="screen"></style><strong style="">Information</strong>You can still use <code>TagsProvider</code> for Items and Blocks but you would need to implement a lot of stuff that is already done in <code>ItemTagsProvider</code> and <code>BlockTagsProvider</code>
 +
 
 +
 
 +
 
 +
==Items/Blocks==
 +
First you should make a <code>ITag.INamedTag</code>(NamedTag) with <code>ItemTags#makeWrapperTag</code> for Items or <code>BlockTags#makeWrapperTag</code> for blocks, this will take the name of you Tag, see [[Tags#Conventions]]
 +
 
 +
 
 +
for more info. After you have the <code>NamedTag</code> you can start with the actual creation of the Tag, you would first call <code>TagsProvider#getOrCreateBuilder</code> which takes the NamedTag as an Argument, this returns a <code>TagsProvider.Builder</code>. Now you can with <code>TagsProvider.Builder#add</code> add one or more Items/Blocks or other Tags to your own Tags.  
  
 
Example for an Item Tag:
 
Example for an Item Tag:
Line 13: Line 28:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
== Custom Type for Tags ==
+
 
 +
 
 +
==Custom Type for Tags==
 
TBD
 
TBD

Revision as of 14:38, 5 November 2020

This page is under construction.

This page is incomplete, and needs more work. Feel free to edit and improve this page!


<style data-mw-deduplicate="TemplateStyles:r2197">.mw-parser-output .mw-tpl-construction{display:flex;align-items:center;width:75%;margin:auto;border-radius:0.2em;background:rgb(27,32,35);box-shadow:0 0 0.2em #999999;overflow:auto}.mw-parser-output .mw-tpl-construction-title{color:#FFFFFF;font-size:120%;font-weight:bold;padding:0.25em 1em}.mw-parser-output .mw-tpl-construction-title-icon{float:left;opacity:0.8;margin:1em}.mw-parser-output .mw-tpl-construction-content{padding:0.5em 1em 0.5em 1em;color:#FFFFFF}</style><style class="darkreader darkreader--sync" media="screen"></style><img alt="" src="/images/d/dc/Under_construction.svg" class="mw-tpl-construction-title-icon" width="60" height="60">This page is under construction.This page is incomplete, and needs more work. Feel free to edit and improve this page!


Tags can be generated by extending the ItemTagsProvider for Items or BlockTagsProvider for Blocks. For Custom Objects you would need to expand TagsProvider and give it the Object you want tags for. For the registration of you Tags you need to override the TagsProvider#registerTags method.


Information

You can still use TagsProvider for Items and Blocks but you would need to implement a lot of stuff that is already done in ItemTagsProvider and BlockTagsProvider


<style data-mw-deduplicate="TemplateStyles:r2068">.mw-parser-output .mw-tpl-colorbox{box-sizing:border-box;margin:0.5em 0.5em 1em 0.5em;border-radius:0.2em;background:rgb(27,32,35);box-shadow:0 0 0.2em #999999}.mw-parser-output .mw-tpl-colorbox-title{background:rgb(0,71,127);color:#FFFFFF;border-radius:0.2em 0.2em 0 0;padding:0.5em 1em 0.5em 1em}.mw-parser-output .mw-tpl-colorbox-title-icon{opacity:0.8}.mw-parser-output .mw-tpl-colorbox-title-corner{float:right;font-size:0.7em}.mw-parser-output .mw-tpl-colorbox-content{padding:0.5em 1em 0.5em 1em;color:#FFFFFF}</style><style class="darkreader darkreader--sync" media="screen"></style>InformationYou can still use TagsProvider for Items and Blocks but you would need to implement a lot of stuff that is already done in ItemTagsProvider and BlockTagsProvider


Items/Blocks

First you should make a ITag.INamedTag(NamedTag) with ItemTags#makeWrapperTag for Items or BlockTags#makeWrapperTag for blocks, this will take the name of you Tag, see Tags#Conventions


for more info. After you have the NamedTag you can start with the actual creation of the Tag, you would first call TagsProvider#getOrCreateBuilder which takes the NamedTag as an Argument, this returns a TagsProvider.Builder. Now you can with TagsProvider.Builder#add add one or more Items/Blocks or other Tags to your own Tags. 

Example for an Item Tag:

ITag.INamedTag<Item> copperTag = ItemTags.makeWrapperTag("forge:ore/copper");
getOrCreateBuilder(copperTag).add(Init.COPPER_ORE_ITEM.get());


Custom Type for Tags

TBD