Skip to content

Commit

Permalink
Merge pull request #28 from ClothCreators/dev
Browse files Browse the repository at this point in the history
Armor sounds, Plants, Block entities, and an extra library
  • Loading branch information
Goldorion committed Jun 16, 2020
2 parents fecf029 + d05dff0 commit e251893
Show file tree
Hide file tree
Showing 19 changed files with 230 additions and 48 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Expand Up @@ -15,3 +15,10 @@ out

# Mac OS Garbage
.DS_Store

# VSCode
.vscode
*.code-workspace

# BBedit
*.bbproject
16 changes: 12 additions & 4 deletions CONTRIBUTING.md
Expand Up @@ -2,12 +2,20 @@

Since we have limited time, we would love to accept pull requests to get things done. We've also put a few ground rules so that pull requests can be maintained easily and follow the same codestyle.

## Rules
* Use the `this` keyword everywhere for instance variables
## Contributing Code
* Create a single commit for each feature, rather than making a huge commit for everything
* Keep minor changes like bug fixes and spelling errors a seperate commit
* Keep minor changes like bug fixes and spelling errors a separate commit
* State all your changes
* Do *not* use newline brackets
* Always commit in past tense
* Report to us if an automatic merge can not be performed. If there are conflicts, it is at our discretion to decide.
* Do not send a huge pull request with multiple large and untraceable commits. Instead, create a single pull request for each major change.

You must also follow the code of conduct.
## Reporting Issues
* Please describe your issue in detail.
* Provide your mcreator.log file, located in <Userdir>/.mcreator/logs. You might need to enable hidden folders to see this file.
* If your issue is a build error or occurs in-game, please provide the full contents of the "console" tab in MCreator in text format.
* Please share long logs in paste websites like [Github Gists](https://gist.github.com/) or [Pastebin](https://pastebin.com/).
* We do not provide support for outdated versions.

You must also follow the [Code Of Conduct](https://github.com/ClothCreators/MCreatorFabricGenerator/blob/1.15.2/CODE_OF_CONDUCT.md).
17 changes: 9 additions & 8 deletions README.md
@@ -1,26 +1,28 @@
# MCreatorFabricGenerator
An unofficial plugin for [MCreator](https://mcreator.net/), a highly advanced Minecraft mod maker. Adds a [Fabric](https://fabricmc.net/) mod generator type. Currently this is very WIP, and most features are incomplete.
An unofficial plugin for [MCreator](https://mcreator.net/), a highly advanced Minecraft mod maker. Adds a [Fabric](https://fabricmc.net/) mod generator type. Currently, this tool is very incomplete.
## Disclaimer
This project is not official. Not affiliated with the respective owners and maintainers of Fabric, Minecraft, or MCreator. Do not expect any official support from their respective communities.

## Features
* Advancement (Mostly complete)
* Armor (Mostly complete) **To don't get an error, you have to select a sound.** (Not all sounds are included because mappings are not finished. Any help is welcome.)
* Armor (Mostly complete) **To not get an error, you have to select an equip sound.**
* Biome (Not complete)
* Block (Mostly complete)
- Ore generation (Nether and Overworld, Netherrack and Stone Respectively)
- Block entities (Non pushable)
- Custom plants
* Food (Mostly complete)
* Fuel (Complete)
* Function (Complete)
* Item (Mostly Complete)
* Itemgroups("Creative Tabs") (Complete)
* Loot table (Complete)
* Recipe (Complete)
* Tag (Complete)
* Tool (Pickaxe, Axe, Shovel, Hoe and Sword)
* Biome (Not complete)
* Ore generation (Nether and Overworld, Netherrack and Stone Respectively)
* Itemgroups (Complete)
* Tool (Supports Pickaxe, Axe, Shovel, Hoe and Sword)
* Sounds (Only useful for Armor. **Sound names can not have any special charecters.**)

## Downloads/Install Instructions

Downloads can be found on the [Release page of this repo](https://github.com/Goldorion/MCreatorFabricGenerator/releases).
The plugin's MCreator forum page is [here](https://mcreator.net/forum/60201/fabric-generator-plugin).

Expand Down Expand Up @@ -49,4 +51,3 @@ Licensed under the GNU Lesser General Public License, version 3.0
* Forked versions of this software must be distributed under the same license as this with attribution, if distributed.
* Changes must be stated if any modified works are to be distributed.
* Under no circumstances can you state that modified works are endorsed by the original creators.

7 changes: 5 additions & 2 deletions src/fabric-1.15.2/generator.yaml
@@ -1,11 +1,11 @@
name: Minecraft Fabric for 1.15.2 (@buildfileversion)
basefeatures: [model_json,model_obj]
partial_support: [block,item,food,armor,biome,tab,sounds,fuel]
partial_support: [block,item,food,armor,biome,sounds]
status: dev
buildfileversion: 0.8.7+build.201

gradle:
setup_task: genSources downloadAssets
setup_task: genSources
run_client: runClient
run_server: runServer
export_file: "build/libs/sources.jar"
Expand All @@ -30,6 +30,9 @@ base_templates:
- template: modbase/biomeRegistry.java.ftl
name: "@SRCROOT/@BASEPACKAGEPATH/registry/@JavaModNameBiomes.java"
canLock: true
- template: modbase/client.java.ftl
name: "@SRCROOT/@BASEPACKAGEPATH/ClientInit.java"
canLock: true
- template: modbase/fabric.mod.json.ftl
writer: json
name: "@RESROOT/fabric.mod.json"
Expand Down
2 changes: 1 addition & 1 deletion src/fabric-1.15.2/loottable.definition.yaml
@@ -1,4 +1,4 @@
templates:
- template: json/loottable.json.ftl
writer: json
name: "@RESROOT/data/@[getNamespace()]/loot_tables/@[getName()].json"
name: "@RESROOT/data/@[getNamespace()]/loot_tables/@[getName()].json"
2 changes: 1 addition & 1 deletion src/fabric-1.15.2/mappings/sounds.yaml
Expand Up @@ -19,7 +19,7 @@ item.armor.equip_chain: ITEM_ARMOR_EQUIP_CHAIN
item.armor.equip_diamond: ITEM_ARMOR_EQUIP_DIAMOND
item.armor.equip_elytra: ITEM_ARMOR_EQUIP_ELYTRA
item.armor.equip_generic: ITEM_ARMOR_EQUIP_GENERIC
item.armor.equip_gold: ITEM_ARMOR_EQUIPE_GOLD
item.armor.equip_gold: ITEM_ARMOR_EQUIP_GOLD
item.armor.equip_iron: ITEM_ARMOR_EQUIP_IRON
item.armor.equip_leather: ITEM_ARMOR_EQUIP_LEATHER
item.armor.equip_turtle: ITEM_ARMOR_EQUIP_TURTLE
Expand Down
30 changes: 30 additions & 0 deletions src/fabric-1.15.2/plant.definition.yaml
@@ -0,0 +1,30 @@
templates:
- template: plant.java.ftl
name: "@SRCROOT/@BASEPACKAGEPATH/block/@NAME.java"
- template: json/plant_item.json.ftl
writer: json
name: "@MODASSETSROOT/models/item/@registryname.json"

- template: json/block.json.ftl
condition: "renderType #= 12"
writer: json
variables: "model=cross;txname=cross"
name: "@MODASSETSROOT/models/block/@registryname.json"
- template: json/block_cmodel.json.ftl
condition: "renderType #= 2"
writer: json
name: "@MODASSETSROOT/models/block/@registryname.json"
- template: json/block_cmodel_obj.json.ftl
condition: "renderType #= 3"
writer: json
name: "@MODASSETSROOT/models/block/@registryname.json"
- template: json/block_states.json.ftl
writer: json
condition: "plantType %= normal"
variables: "variant= "
name: "@MODASSETSROOT/blockstates/@registryname.json"


localizationkeys:
- key: block.@modid.@registryname
mapto: name
8 changes: 6 additions & 2 deletions src/fabric-1.15.2/templates/armorMaterial.java.ftl
Expand Up @@ -5,10 +5,14 @@ package ${package}.item;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import ${package}.${JavaModName};

public enum ${name}Material implements ArmorMaterial {
public enum ${name}Material implements ArmorMaterial {

${name}("${registryname}", ${data.maxDamage}, new int[]{${data.damageValueBoots}, ${data.damageValueLeggings}, ${data.damageValueBody}, ${data.damageValueHelmet}}, ${data.enchantability}, SoundEvents.${data.equipSound}, ${data.toughness}F, () -> {
${name}("${registryname}", ${data.maxDamage}, new int[]{${data.damageValueBoots}, ${data.damageValueLeggings}, ${data.damageValueBody}, ${data.damageValueHelmet}}, ${data.enchantability},
<#if data.equipSound?contains(modid)>${JavaModName}.${data.equipSound?remove_beginning(modid + ":")}Event<#else>
SoundEvents.${data.equipSound}</#if>,
${data.toughness}F, () -> {
return Ingredient.ofItems(<#if data.repairItems?has_content><#list data.repairItems as repairItem>${mappedMCItemToItemStackCode(repairItem)?replace("Blocks.", "Items.")}<#if repairItem?has_next>,</#if></#list><#else>Items.AIR</#if>);
});

Expand Down
25 changes: 24 additions & 1 deletion src/fabric-1.15.2/templates/block.java.ftl
Expand Up @@ -9,7 +9,11 @@ import net.fabricmc.api.Environment;
import net.minecraft.block.HorizontalFacingBlock;
import net.minecraft.util.math.Direction;

public class ${name} extends <#if data.hasGravity>FallingBlock<#else>Block</#if> {
public class ${name} extends
<#if data.hasInventory>BlockWithEntity<#else>
<#if data.hasGravity>FallingBlock<#else>Block</#if>
</#if>
{

public ${name}(){
super(FabricBlockSettings.of(Material.${data.material})<#if data.destroyTool != "Not specified">.breakByTool(FabricToolTags.${data.destroyTool?upper_case}S, ${data.breakHarvestLevel})<#else>
Expand Down Expand Up @@ -286,6 +290,25 @@ public class ${name} extends <#if data.hasGravity>FallingBlock<#else>Block</#if>
</#list>
}

@Override
public BlockRenderType getRenderType(BlockState state) {
return BlockRenderType.MODEL;
}

public static boolean hasBE = <#if data.hasInventory>true<#else>false</#if>;

<#if data.hasInventory>
@Override
public BlockEntity createBlockEntity(BlockView view) {
return new ${name}BlockEntity();
}
</#if>
public static class ${name}BlockEntity extends BlockEntity{
public ${name}BlockEntity() {
super(${JavaModName}.${name}BE);
}
}


}

Expand Down
7 changes: 7 additions & 0 deletions src/fabric-1.15.2/templates/food.java.ftl
Expand Up @@ -36,5 +36,12 @@ public class ${name} extends Item{
public UseAction getUseAction(ItemStack stack) {
return UseAction.${data.animation?upper_case};
}

<#if data.eatingSpeed != 32>
@Override
public int getMaxUseTime(ItemStack stack) {
return ${data.eatingSpeed};
}
</#if>
}
<#-- @formatter:on -->
Expand Down
2 changes: 1 addition & 1 deletion src/fabric-1.15.2/templates/function.mcfunction.ftl
@@ -1 +1 @@
${data.code}
${data.code}
6 changes: 6 additions & 0 deletions src/fabric-1.15.2/templates/json/plant_item.json.ftl
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "${modid}:blocks/${data.texture}"
}
}
18 changes: 18 additions & 0 deletions src/fabric-1.15.2/templates/modbase/client.java.ftl
@@ -0,0 +1,18 @@
package ${package};

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.minecraft.client.render.RenderLayer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

public class ClientInit implements ClientModInitializer{
@Override
public void onInitializeClient(){

<#list w.getElementsOfType("PLANT") as plant>
BlockRenderLayerMap.INSTANCE.putBlock(${JavaModName}.${plant}Plant, RenderLayer.getCutout());
</#list>

}
}
15 changes: 7 additions & 8 deletions src/fabric-1.15.2/templates/modbase/fabric.mod.json.ftl
Expand Up @@ -15,7 +15,7 @@
</#if>
"contact": {
"homepage": "${settings.getWebsiteURL()}",
"sources": ""
"sources": "https://github.com/ClothCreators/MCreatorFabricGenerator"
},

<#if settings.getModPicture()?has_content>
Expand All @@ -26,16 +26,15 @@
"entrypoints": {
"main": [
"${package}.${JavaModName}"
],
"client":[
"${package}.ClientInit"
]
},

"depends": {
"fabricloader": ">=0.8.3",
"fabric": "*",
"minecraft": "1.15.x"
},
"suggests": {
"flamingo": "*"
"fabricloader": ">=0.8.2",
"fabric": "*"
}
}
<#-- @formatter:on -->
<#-- @formatter:on -->
16 changes: 14 additions & 2 deletions src/fabric-1.15.2/templates/modbase/mod.java.ftl
Expand Up @@ -22,13 +22,17 @@ public class ${JavaModName} implements ModInitializer {

<#list sounds as sound>
public static final Identifier ${sound} = new Identifier("${modid}:${sound}");
public static SoundEvent ${sound} = new SoundEvent(${sound});
public static SoundEvent ${sound}Event = new SoundEvent(${sound});
</#list>

<#list w.getElementsOfType("ITEM") as item>
public static final Item ${item} = new ${item}();
</#list>

<#list w.getElementsOfType("PLANT") as plant>
public static final PlantBlock ${plant}Plant = new ${plant}();
</#list>

<#list w.getElementsOfType("ARMOR") as armor>
<#assign ge = armor.getGeneratableElement()>
public static final Item ${armor}_HELMET = new ${armor}ArmorItem(${armor}Material.${armor}, EquipmentSlot.HEAD, (new Item.Settings().group(${ge.creativeTab})));
Expand All @@ -43,13 +47,14 @@ public class ${JavaModName} implements ModInitializer {

<#list w.getElementsOfType("BLOCK") as block>
public static final ${block} ${block} = new ${block}();
public static BlockEntityType<${block}.${block}BlockEntity> ${block}BE;
</#list>

@Override
public void onInitialize() {

<#list sounds as sound>
Registry.register(Registry.${sound}, ${JavaModName}.${sound}, ${sound});
Registry.register(Registry.SOUND_EVENT, ${JavaModName}.${sound}, ${JavaModName}.${sound}Event);
</#list>

<#list w.getElementsOfType("ITEM") as item>
Expand All @@ -69,6 +74,12 @@ ${JavaModName}Biomes.registerBiomes();
OverworldBiomes.addContinentalBiome(${JavaModName}Biomes.${biome?upper_case},OverworldClimate.TEMPERATE,${biome}.WEIGHT);
</#list>

<#list w.getElementsOfType("PLANT") as plant>
<#assign ge = plant.getGeneratableElement()>
Registry.register(Registry.BLOCK,new Identifier("${modid}","${plant.getRegistryName()}"),${plant}Plant);
Registry.register(Registry.ITEM,new Identifier("${modid}","${plant.getRegistryName()}"),new BlockItem(${plant}Plant, new Item.Settings().group(${ge.creativeTab})));
</#list>

<#list w.getElementsOfType("FOOD") as food>
Registry.register(Registry.ITEM, new Identifier("${modid}", "${food.getRegistryName()}"), ${food});
</#list>
Expand All @@ -79,6 +90,7 @@ ${JavaModName}Biomes.registerBiomes();

<#list w.getElementsOfType("BLOCK") as block>
<#assign ge = block.getGeneratableElement()>
if(${block}.hasBE) ${block}BE = Registry.register(Registry.BLOCK_ENTITY_TYPE,new Identifier("${modid}","${block?lower_case}be"),BlockEntityType.Builder.create(${block}.${block}BlockEntity::new).build(null));
Registry.register(Registry.BLOCK, new Identifier("${modid}", "${block.getRegistryName()}"), ${block});
Registry.BIOME.forEach(this.${block}::genBlock);
RegistryEntryAddedCallback.event(Registry.BIOME).register((i, identifier, biome) -> { this.${block}.genBlock(biome); });
Expand Down

0 comments on commit e251893

Please sign in to comment.