Skip to content

Commit

Permalink
Merge pull request #20 from ClothCreators/dev
Browse files Browse the repository at this point in the history
Biomes, Itemgroup fixes, Ore generation and Falling blocks
  • Loading branch information
BoogieMonster1O1 authored Jun 15, 2020
2 parents 4b2db31 + 80a4437 commit a3cfda6
Show file tree
Hide file tree
Showing 10 changed files with 271 additions and 36 deletions.
5 changes: 2 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
**Version:-** 0.X.X+foo
**Version:-** Release/Snapshot 0.X.X+foo

### Changes
* State
* Your
* Changes
* Changes
* Here

### Bug Fixes
Expand All @@ -14,4 +14,3 @@
* Minor
* Changes
* Here

36 changes: 14 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,20 @@ An unofficial plugin for [MCreator](https://mcreator.net/), a highly advanced Mi
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, procedure triggered advancements don't work)

- Armor (Mostly complete, custom 3D models need to be hardcoded) **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.)

- Block (Mostly complete)

- Food (Mostly complete)

- Fuel (Complete)

- Function (Complete)

- Item (Mostly Complete)

- Loot table (Complete)

- Recipe (Complete)

- Tag (Complete)

- Tool (Pickaxe, Axe, Shovel, Hoe and Sword)
* 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.)
* Block (Mostly complete)
* Food (Mostly complete)
* Fuel (Complete)
* Function (Complete)
* Item (Mostly 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)

## Downloads/Install Instructions

Expand Down
3 changes: 3 additions & 0 deletions src/fabric-1.15.2/biome.definition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
templates:
- template: biome.java.ftl
name: "@SRCROOT/@BASEPACKAGEPATH/world/biome/@NAME.java"
7 changes: 5 additions & 2 deletions src/fabric-1.15.2/generator.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Minecraft Fabric for 1.15.2 (@buildfileversion)
basefeatures: [model_json,model_obj,sounds]
partial_support: [block,item,food,armor]
basefeatures: [model_json,model_obj]
partial_support: [block,item,food,armor,biome,tab,sounds,fuel]
status: dev
buildfileversion: 0.8.7+build.201

Expand All @@ -27,6 +27,9 @@ base_templates:
- template: modbase/mod.java.ftl
name: "@SRCROOT/@BASEPACKAGEPATH/@JavaModName.java"
canLock: true
- template: modbase/biomeRegistry.java.ftl
name: "@SRCROOT/@BASEPACKAGEPATH/registry/@JavaModNameBiomes.java"
canLock: true
- template: modbase/fabric.mod.json.ftl
writer: json
name: "@RESROOT/fabric.mod.json"
Expand Down
118 changes: 118 additions & 0 deletions src/fabric-1.15.2/templates/biome.java.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<#-- @formatter:off -->
package ${package}.world.biome;

import net.fabricmc.fabric.api.biomes.v1.OverworldClimate;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

public class ${name} extends Biome{

public static final int WEIGHT = ${data.biomeWeight};

public ${name}(){
super(new Biome.Settings().configureSurfaceBuilder(SurfaceBuilder.DEFAULT, SurfaceBuilder.GRASS_CONFIG)
.precipitation(Biome.Precipitation.<#if (data.rainingPossibility > 0)><#if (data.temperature > 0.15)>RAIN<#else>SNOW</#if><#else>NONE</#if>)
.category(Biome.Category.PLAINS)
.depth(${data.baseHeight}f)
.scale(${data.heightVariation}f)
.temperature(${data.temperature}f)
.precipitation(Precipitation.<#if (data.rainingPossibility > 0)><#if (data.temperature > 0.15)>RAIN<#else>SNOW</#if><#else>NONE</#if>)
.downfall(${data.rainingPossibility}f)
<#if data.customColors>
.waterColor(${data.waterColor.getRGB()}).waterFogColor(${data.waterColor.getRGB()})
<#else>
.waterColor(4159204).waterFogColor(329011)
</#if>
<#if data.parent?? && data.parent.getUnmappedValue() != "No parent">
.parent("${data.parent}")
<#else>
.parent((String)null));
</#if>

this.addStructureFeature(Feature.MINESHAFT.configure(new MineshaftFeatureConfig(0.004D, MineshaftFeature.Type.NORMAL)));
this.addStructureFeature(Feature.STRONGHOLD.configure(FeatureConfig.DEFAULT));
DefaultBiomeFeatures.addLandCarvers(this);
DefaultBiomeFeatures.addDefaultStructures(this);
DefaultBiomeFeatures.addDungeons(this);
DefaultBiomeFeatures.addDefaultOres(this);
DefaultBiomeFeatures.addDefaultDisks(this);
DefaultBiomeFeatures.addDefaultVegetation(this);
DefaultBiomeFeatures.addSprings(this);
DefaultBiomeFeatures.addFrozenTopLayer(this);
<#if (data.flowersPerChunk > 0)>
DefaultBiomeFeatures.addDefaultFlowers(this);
</#if>
<#if (data.grassPerChunk > 0)>
DefaultBiomeFeatures.addDefaultGrass(this);
</#if>
<#if (data.flowersPerChunk > 0)>
DefaultBiomeFeatures.addForestFlowers(this);
</#if>
<#if data.generateLakes>
DefaultBiomeFeatures.addDefaultLakes(this);
</#if>
<#if (data.mushroomsPerChunk > 0)>
DefaultBiomeFeatures.addDefaultMushrooms(this);
</#if>
<#if (data.treesPerChunk > 0)>
<#if data.vanillaTreeType == "Big trees">
DefaultBiomeFeatures.addTallBirchTrees(this);
DefaultBiomeFeatures.addForestTrees(this);
<#elseif data.vanillaTreeType == "Savanna trees">
DefaultBiomeFeatures.addSavannaTrees(this);
<#elseif data.vanillaTreeType == "Mega pine trees">
DefaultBiomeFeatures.addGiantTreeTaigaTrees(this);
<#elseif data.vanillaTreeType == "Mega spruce trees">
DefaultBiomeFeatures.addGiantSpruceTaigaTrees(this);
<#elseif data.vanillaTreeType == "Birch trees">
DefaultBiomeFeatures.addBirchTrees(this);
<#else>
DefaultBiomeFeatures.addBirchTrees(this);
DefaultBiomeFeatures.addForestTrees(this);
</#if>
</#if>
<#if (data.bigMushroomsChunk > 0)>
DefaultBiomeFeatures.addMushroomFieldsFeatures(this);
</#if>
<#if (data.reedsPerChunk > 0)>
DefaultBiomeFeatures.addBamboo(this);
</#if>
<#if (data.cactiPerChunk > 0)>
DefaultBiomeFeatures.addDesertFeatures(this);
</#if>

this.addSpawn(EntityCategory.CREATURE, new Biome.SpawnEntry(EntityType.SHEEP, 12, 4, 4));
this.addSpawn(EntityCategory.CREATURE, new Biome.SpawnEntry(EntityType.PIG, 10, 4, 4));
this.addSpawn(EntityCategory.CREATURE, new Biome.SpawnEntry(EntityType.CHICKEN, 10, 4, 4));
this.addSpawn(EntityCategory.CREATURE, new Biome.SpawnEntry(EntityType.COW, 8, 4, 4));
this.addSpawn(EntityCategory.AMBIENT, new Biome.SpawnEntry(EntityType.BAT, 10, 8, 8));
this.addSpawn(EntityCategory.MONSTER, new Biome.SpawnEntry(EntityType.SPIDER, 100, 4, 4));
this.addSpawn(EntityCategory.MONSTER, new Biome.SpawnEntry(EntityType.ZOMBIE, 95, 4, 4));
this.addSpawn(EntityCategory.MONSTER, new Biome.SpawnEntry(EntityType.ZOMBIE_VILLAGER, 5, 1, 1));
this.addSpawn(EntityCategory.MONSTER, new Biome.SpawnEntry(EntityType.SKELETON, 100, 4, 4));
this.addSpawn(EntityCategory.MONSTER, new Biome.SpawnEntry(EntityType.CREEPER, 100, 4, 4));
this.addSpawn(EntityCategory.MONSTER, new Biome.SpawnEntry(EntityType.SLIME, 100, 4, 4));
this.addSpawn(EntityCategory.MONSTER, new Biome.SpawnEntry(EntityType.ENDERMAN, 10, 1, 4));
this.addSpawn(EntityCategory.MONSTER, new Biome.SpawnEntry(EntityType.WITCH, 5, 1, 1));
}
<#if data.customColors>
@Environment(EnvType.CLIENT)
@Override
public int getSkyColor() {
return ${data.airColor.getRGB()};
}

@Environment(EnvType.CLIENT)
@Override
public int getGrassColorAt(double x, double z) {
return ${data.grassColor.getRGB()};
}

@Environment(EnvType.CLIENT)
@Override
public int getFoliageColor() {
return ${data.grassColor.getRGB()};
}
</#if>
}
<#-- @formatter:on -->
77 changes: 77 additions & 0 deletions src/fabric-1.15.2/templates/block.java.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,83 @@ public class ${name} extends <#if data.hasGravity>FallingBlock<#else>Block</#if>
}
</#if>

public void genBlock(Biome biome){
<#list data.spawnWorldTypes as worldType>
<#if worldType=="Surface">
try{
<#if (data.spawnWorldTypes?size > 0)>
if(biome.getCategory() != Biome.Category.THEEND
<#if data.restrictionBiomes?has_content>
<#list data.restrictionBiomes as restrictionBiome>
&& biome != Registry.BIOME.get(new Identifier("${restrictionBiome}"))
</#list>
</#if>
){
biome.addFeature(
GenerationStep
.Feature
.UNDERGROUND_ORES,Feature
.ORE
.configure(
new OreFeatureConfig(OreFeatureConfig
.Target
.NATURAL_STONE,
${JavaModName}
.${name}
.getDefaultState(),
${data.frequencyOnChunk}
)).createDecoratedFeature(Decorator
.COUNT_RANGE.
configure(new RangeDecoratorConfig(
${data.frequencyPerChunks},
${data.minGenerateHeight},
${data.minGenerateHeight},
${data.maxGenerateHeight}
))));
}</#if>
}catch(Throwable ignored){}
</#if>

<#if worldType == "Nether">
try{
<#if (data.spawnWorldTypes?size > 0)>
if(biome.getCategory() != Biome.Category.THEEND
<#if data.restrictionBiomes?has_content>
<#list data.restrictionBiomes as restrictionBiome>
&& biome != Registry.BIOME.get(new Identifier("${restrictionBiome}"))
</#list>
</#if>
){
biome.addFeature(
GenerationStep
.Feature
.UNDERGROUND_ORES,Feature
.ORE
.configure(
new OreFeatureConfig(OreFeatureConfig
.Target
.NETHERRACK,
${JavaModName}
.${name}
.getDefaultState(),
${data.frequencyOnChunk}
)).createDecoratedFeature(Decorator
.COUNT_RANGE.
configure(new RangeDecoratorConfig(
${data.frequencyPerChunks},
${data.minGenerateHeight},
${data.minGenerateHeight},
${data.maxGenerateHeight}
))));
}</#if>
}catch(Throwable ignored){}
</#if>

</#list>
}


}


<#-- @formatter:on -->
36 changes: 36 additions & 0 deletions src/fabric-1.15.2/templates/modbase/biomeRegistry.java.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<#-- @formatter:off -->
/*
* MCreator note:
*
* If you lock base mod element files, you can edit this file and the proxy files
* and they won't get overwritten. If you change your mod package or modid, you
* need to apply these changes to this file MANUALLY.
*
*
*
* If you do not lock base mod element files in Workspace settings, this file
* will be REGENERATED on each build.
*
*/
package ${package}.registry;

public class ${JavaModName}Biomes {

<#list w.getElementsOfType("BIOME") as biome>
public static Biome ${biome?upper_case};
</#list>

public static void registerBiomes()
{
<#list w.getElementsOfType("BIOME") as biome>
${biome?upper_case} = register(new ${biome}(), "${modid}");
FabricBiomes.addSpawnBiome(${JavaModName}Biomes.${biome?upper_case});
</#list>
}

private static Biome register(Biome biome, String id) {
return Registry.register(Registry.BIOME, id, biome);
}

}
<#-- @formatter:on -->
17 changes: 12 additions & 5 deletions src/fabric-1.15.2/templates/modbase/mod.java.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
* need to apply these changes to this file MANUALLY.
*
*
* Keep the ${JavaModName}Elements object in this class and all calls to this object
* INTACT in order to preserve functionality of mod elements generated by MCreator.
*
* If you do not lock base mod element files in Workspace settings, this file
* will be REGENERATED on each build.
*
Expand All @@ -18,6 +15,8 @@
package ${package};

import ${package}.item;
import net.fabricmc.fabric.api.biomes.v1.OverworldBiomes;
import net.fabricmc.fabric.api.biomes.v1.OverworldClimate;

public class ${JavaModName} implements ModInitializer {

Expand All @@ -43,7 +42,7 @@ public class ${JavaModName} implements ModInitializer {
</#list>

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

@Override
Expand All @@ -64,6 +63,12 @@ public class ${JavaModName} implements ModInitializer {
Registry.register(Registry.ITEM,new Identifier("${modid}","${armor.getRegistryName()}_boots"), ${armor}_BOOTS);
</#list>

${JavaModName}Biomes.registerBiomes();

<#list w.getElementsOfType("BIOME") as biome>
OverworldBiomes.addContinentalBiome(${JavaModName}Biomes.${biome?upper_case},OverworldClimate.TEMPERATE,${biome}.WEIGHT);
</#list>

<#list w.getElementsOfType("FOOD") as food>
Registry.register(Registry.ITEM, new Identifier("${modid}", "${food.getRegistryName()}"), ${food});
</#list>
Expand All @@ -75,11 +80,13 @@ public class ${JavaModName} implements ModInitializer {
<#list w.getElementsOfType("BLOCK") as block>
<#assign ge = block.getGeneratableElement()>
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); });
Registry.register(Registry.ITEM, new Identifier("${modid}", "${block.getRegistryName()}"), new BlockItem(${block}, new Item.Settings().group(${ge.creativeTab})));
</#list>

<#list w.getElementsOfType("FUEL") as fuel>
${fuel}Fuel.initialize();
${fuel}Fuel.initialize();
</#list>
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/fabric-1.15.2/utils/mcitems.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<#return mappedBlock>
<#elseif mappedBlock.toString().startsWith("CUSTOM:")>
<#if !mappedBlock.toString().contains(".")>
<#return (generator.getElementPlainName(mappedBlock))
+ (generator.getRecipeElementType(mappedBlock.toString()) == "BLOCK")?then("Block", "Item") + ".block.getDefaultState()">
<#return JavaModName + "." + (generator.getElementPlainName(mappedBlock))
+ (generator.getRecipeElementType(mappedBlock.toString()) == "BLOCK")?then("Block", "Item") + ".getDefaultState()">
<#else>
<#return (generator.getElementPlainName(mappedBlock))
<#return JavaModName + "." + (generator.getElementPlainName(mappedBlock))
+ (generator.getRecipeElementType(mappedBlock.toString()) == "BLOCK")?then("Block", "Item") + "." + generator.getElementExtension(mappedBlock) + ".getDefaultState()">
</#if>
<#else>
Expand Down
Loading

0 comments on commit a3cfda6

Please sign in to comment.