Update for 1.16.5

This commit is contained in:
QuImUfu 2021-04-01 21:59:22 +02:00
parent 68721965eb
commit 344ae127a9
9 changed files with 159 additions and 87 deletions

View File

@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '0.2.6-SNAPSHOT'
id 'fabric-loom' version '0.6-SNAPSHOT'
id 'maven-publish'
}
@ -13,6 +13,11 @@ group = project.maven_group
minecraft {
}
repositories {
maven { url "https://maven.shedaniel.me/" }
maven { url "https://maven.terraformersmc.com/releases/" }
}
dependencies {
//to change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
@ -21,11 +26,15 @@ dependencies {
implementation 'com.google.code.findbugs:jsr305:3.0.2'
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
modCompile "me.sargunvohra.mcmods:autoconfig1u:2.0"
include "me.sargunvohra.mcmods:autoconfig1u:2.0"
modApi "me.shedaniel.cloth:config-2:2.13.1"
include "me.shedaniel.cloth:config-2:2.13.1"
modImplementation "io.github.prospector:modmenu:1.10.0+build.28"
modApi("me.shedaniel.cloth:cloth-config-fabric:4.11.18") {
exclude(group: "net.fabricmc.fabric-api")
}
modApi("com.terraformersmc:modmenu:1.16.8")
//modCompile "me.sargunvohra.mcmods:autoconfig1u:2.0"
//include "me.sargunvohra.mcmods:autoconfig1u:2.0"
//modApi "me.shedaniel.cloth:config-2:2.13.1"
//include "me.shedaniel.cloth:config-2:2.13.1"
//modImplementation "io.github.prospector:modmenu:1.10.0+build.28"
}
processResources {

View File

@ -1,14 +1,14 @@
org.gradle.jvmargs = -Xmx1G
#Fabric properties
minecraft_version = 1.15.2
yarn_mappings = 1.15.2+build.15
loader_version = 0.8.2+build.194
minecraft_version = 1.16.5
yarn_mappings = 1.16.5+build.6
loader_version = 0.11.3
#Mod properties
mod_version = 0.8.0
mod_version = 0.9.0
maven_group = quimufu.simple_creator
archives_base_name = simple_creator
#Dependencies
fabric_api_version = 0.5.12+build.296-1.15
fabric_api_version = 0.32.5+1.16

View File

@ -4,6 +4,9 @@ import com.google.common.collect.Maps;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import net.fabricmc.fabric.mixin.object.builder.AbstractBlockSettingsAccessor;
import net.minecraft.block.*;
import net.minecraft.block.piston.PistonBehavior;
import net.minecraft.item.BlockItem;
@ -16,7 +19,6 @@ import net.minecraft.util.Pair;
import net.minecraft.util.registry.Registry;
import org.apache.logging.log4j.Level;
import java.lang.reflect.Field;
import java.util.Map;
import static quimufu.simple_creator.SimpleCreatorMod.log;
@ -58,7 +60,7 @@ public class BlockResourceLoader extends GenericManualResourceLoader<Pair<Block,
//build material
material = getSettings(mspj);
} else {
material = Material.EARTH;
material = Material.SOIL;
}
// get block information
@ -74,29 +76,23 @@ public class BlockResourceLoader extends GenericManualResourceLoader<Pair<Block,
Block resB = new Block(bs);
Item resI = new BlockItem(resB, new Item.Settings().group(g));
FireBlock fireBlock = (FireBlock) Blocks.FIRE;
int burnChance = JsonHelper.getInt(jo,"burnChance", -1);
int spreadChance = JsonHelper.getInt(jo,"spreadChance", -1);
if(burnChance!=-1 && spreadChance!=-1){
//spreadChance and burnChance are the wrong way around in yarn
fireBlock.registerFlammableBlock(resB, spreadChance, burnChance);
FlammableBlockRegistry.getDefaultInstance().add(resB, spreadChance, burnChance);
}
return new Pair<>(resB, resI);
}
private Material getSettings(MaterialSettingsPojo mspj) {
return new Material(
MaterialColor.PINK,
getMaterialColor(mspj.materialColor),
mspj.liquid,
mspj.solid,
mspj.blocksMovement,
mspj.blocksLight,
mspj.breakByHand,
mspj.burnable,
mspj.replaceable,
getPistonBehavior(mspj.pistonBehavior));
}
@ -123,7 +119,8 @@ public class BlockResourceLoader extends GenericManualResourceLoader<Pair<Block,
private MaterialColor getMaterialColor(String color) {
switch (color.toUpperCase()) {
case "AIR":
return MaterialColor.AIR;
case "CLEAR":
return MaterialColor.CLEAR;
case "GRASS":
return MaterialColor.GRASS;
case "SAND":
@ -226,6 +223,21 @@ public class BlockResourceLoader extends GenericManualResourceLoader<Pair<Block,
return MaterialColor.RED_TERRACOTTA;
case "BLACK_TERRACOTTA":
return MaterialColor.BLACK_TERRACOTTA;
case "CRIMSON_NYLIUM":
return MaterialColor.field_25702;
case "CRIMSON_WOOD":
return MaterialColor.field_25703;
case "CRIMSON_HYPHAE":
return MaterialColor.field_25704;
case "WARPED_NYLIUM":
return MaterialColor.field_25705;
case "WARPED_WOOD":
return MaterialColor.field_25706;
case "WARPED_HYPHAE":
return MaterialColor.field_25707;
case "WARPED_WART_BLOCK":
return MaterialColor.field_25708;
default:
log(Level.WARN, "MapColor " + color + " not found, using pink");
return MaterialColor.PINK;
@ -233,37 +245,21 @@ public class BlockResourceLoader extends GenericManualResourceLoader<Pair<Block,
}
private Block.Settings getSettings(Material material, BlockSettingsPojo bspj) {
Block.Settings bs = Block.Settings.of(material, material.getColor());
Field[] fields = Block.Settings.class.getDeclaredFields();
try {
fields[0].setAccessible(true);
fields[0].set(bs, material);
fields[1].setAccessible(true);
fields[1].set(bs, getMaterialColor(bspj.mapColor));
fields[2].setAccessible(true);
fields[2].setBoolean(bs, bspj.collidable);
fields[3].setAccessible(true);
fields[3].set(bs, getSoundGroup(bspj.soundGroup));
fields[4].setAccessible(true);
fields[4].setInt(bs, bspj.lightLevel);
fields[5].setAccessible(true);
fields[5].setFloat(bs, bspj.explosionResistance);
fields[6].setAccessible(true);
fields[6].setFloat(bs, bspj.hardness);
fields[8].setAccessible(true);
fields[8].setFloat(bs, bspj.slipperiness);
fields[9].setAccessible(true);
fields[9].setFloat(bs, bspj.slowDownMultiplier);
fields[10].setAccessible(true);
fields[10].setFloat(bs, bspj.jumpVelocityMultiplier);
fields[11].setAccessible(true);
fields[11].set(bs, getDropTableId(bspj.dropTableId));
fields[12].setAccessible(true);
fields[12].setBoolean(bs, bspj.opaque);
} catch (IllegalAccessException ex) {
ex.printStackTrace();
}
return bs;
FabricBlockSettings fabricBlockSettings = FabricBlockSettings.of(material, material.getColor());
AbstractBlockSettingsAccessor bs = (AbstractBlockSettingsAccessor) fabricBlockSettings;
bs.setMaterial(material);
bs.setMaterialColorFactory(ignored -> material.getColor());
bs.setCollidable(bspj.collidable);
fabricBlockSettings.sounds(getSoundGroup(bspj.soundGroup));
bs.setLuminanceFunction(ignored -> bspj.lightLevel);
bs.setResistance(bspj.explosionResistance);
bs.setHardness(bspj.hardness);
fabricBlockSettings.slipperiness(bspj.slipperiness);
fabricBlockSettings.velocityMultiplier(bspj.slowDownMultiplier);
fabricBlockSettings.jumpVelocityMultiplier(bspj.jumpVelocityMultiplier);
bs.setLootTableId(getDropTableId(bspj.dropTableId));
bs.setOpaque(bspj.opaque);
return fabricBlockSettings;
}
private Identifier getDropTableId(String s) {
@ -285,6 +281,8 @@ public class BlockResourceLoader extends GenericManualResourceLoader<Pair<Block,
return BlockSoundGroup.GRAVEL;
case "GRASS":
return BlockSoundGroup.GRASS;
case "LILY_PAD":
return BlockSoundGroup.LILY_PAD;
case "STONE":
return BlockSoundGroup.STONE;
case "METAL":
@ -321,10 +319,56 @@ public class BlockResourceLoader extends GenericManualResourceLoader<Pair<Block,
return BlockSoundGroup.CROP;
case "STEM":
return BlockSoundGroup.STEM;
case "VINE":
return BlockSoundGroup.VINE;
case "NETHER_WART":
return BlockSoundGroup.NETHER_WART;
case "LANTERN":
return BlockSoundGroup.LANTERN;
case "NETHER_STEM":
return BlockSoundGroup.NETHER_STEM;
case "NYLIUM":
return BlockSoundGroup.NYLIUM;
case "FUNGUS":
return BlockSoundGroup.FUNGUS;
case "ROOTS":
return BlockSoundGroup.ROOTS;
case "SHROOMLIGHT":
return BlockSoundGroup.SHROOMLIGHT;
case "WEEPING_VINES":
return BlockSoundGroup.WEEPING_VINES;
case "WEEPING_VINES_LOW_PITCH":
return BlockSoundGroup.WEEPING_VINES_LOW_PITCH;
case "SOUL_SAND":
return BlockSoundGroup.SOUL_SAND;
case "SOUL_SOIL":
return BlockSoundGroup.SOUL_SOIL;
case "BASALT":
return BlockSoundGroup.BASALT;
case "WART_BLOCK":
return BlockSoundGroup.WART_BLOCK;
case "NETHERRACK":
return BlockSoundGroup.NETHERRACK;
case "NETHER_BRICKS":
return BlockSoundGroup.NETHER_BRICKS;
case "NETHER_SPROUTS":
return BlockSoundGroup.NETHER_SPROUTS;
case "NETHER_ORE":
return BlockSoundGroup.NETHER_ORE;
case "BONE":
return BlockSoundGroup.BONE;
case "NETHERITE":
return BlockSoundGroup.NETHERITE;
case "ANCIENT_DEBRIS":
return BlockSoundGroup.ANCIENT_DEBRIS;
case "LODESTONE":
return BlockSoundGroup.LODESTONE;
case "CHAIN":
return BlockSoundGroup.CHAIN;
case "NETHER_GOLD_ORE":
return BlockSoundGroup.NETHER_GOLD_ORE;
case "GILDED_BLACKSTONE":
return BlockSoundGroup.GILDED_BLACKSTONE;
default:
log(Level.WARN, "Sound group " + s + " not found, using stone");
return BlockSoundGroup.STONE;
@ -347,40 +391,52 @@ public class BlockResourceLoader extends GenericManualResourceLoader<Pair<Block,
return Material.UNDERWATER_PLANT;
case "REPLACEABLE_PLANT":
return Material.REPLACEABLE_PLANT;
case "NETHER_SHOOTS":
return Material.NETHER_SHOOTS;
case "REPLACEABLE_UNDERWATER_PLANT":
case "SEAGRASS":
return Material.SEAGRASS;
return Material.REPLACEABLE_UNDERWATER_PLANT;
case "WATER":
return Material.WATER;
case "BUBBLE_COLUMN":
return Material.BUBBLE_COLUMN;
case "LAVA":
return Material.LAVA;
case "SNOW_LAYER":
case "SNOW":
return Material.SNOW;
return Material.SNOW_LAYER;
case "FIRE":
return Material.FIRE;
case "SUPPORTED":
case "PART":
return Material.PART;
return Material.SUPPORTED;
case "COBWEB":
return Material.COBWEB;
case "REDSTONE_LAMP":
return Material.REDSTONE_LAMP;
case "ORGANIC_PRODUCT":
case "CLAY":
return Material.CLAY;
return Material.ORGANIC_PRODUCT;
case "SOIL":
case "EARTH":
return Material.EARTH;
return Material.SOIL;
case "SOLID_ORGANIC":
case "ORGANIC":
return Material.ORGANIC;
return Material.SOLID_ORGANIC;
case "DENSE_ICE":
case "PACKED_ICE":
return Material.PACKED_ICE;
return Material.DENSE_ICE;
case "AGGREGATE":
case "SAND":
return Material.SAND;
return Material.AGGREGATE;
case "SPONGE":
return Material.SPONGE;
case "SHULKER_BOX":
return Material.SHULKER_BOX;
case "WOOD":
return Material.WOOD;
case "NETHER_WOOD":
return Material.NETHER_WOOD;
case "BAMBOO_SAPLING":
return Material.BAMBOO_SAPLING;
case "BAMBOO":
@ -403,16 +459,18 @@ public class BlockResourceLoader extends GenericManualResourceLoader<Pair<Block,
return Material.METAL;
case "SNOW_BLOCK":
return Material.SNOW_BLOCK;
case "REPAIR_STATION":
case "ANVIL":
return Material.ANVIL;
return Material.REPAIR_STATION;
case "BARRIER":
return Material.BARRIER;
case "PISTON":
return Material.PISTON;
case "UNUSED_PLANT":
return Material.UNUSED_PLANT;
case "GOURD":
case "PUMPKIN":
return Material.PUMPKIN;
return Material.GOURD;
case "EGG":
return Material.EGG;
case "CAKE":

View File

@ -5,7 +5,7 @@ import com.google.common.collect.Maps;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
import me.shedaniel.autoconfig.AutoConfig;
import net.fabricmc.fabric.impl.resource.loader.ModResourcePackCreator;
import net.minecraft.resource.*;
import net.minecraft.util.Identifier;
@ -16,7 +16,9 @@ import org.apache.logging.log4j.Level;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.stream.Collectors;
import static net.minecraft.resource.ResourcePackSource.method_29486;
import static quimufu.simple_creator.SimpleCreatorMod.log;
public abstract class GenericManualResourceLoader<T> {
@ -50,11 +52,19 @@ public abstract class GenericManualResourceLoader<T> {
public void load() {
config = AutoConfig.getConfigHolder(SimpleCreatorConfig.class).getConfig();
ResourcePackManager<ResourcePackProfile> resourcePackManager = new ResourcePackManager<>(ResourcePackProfile::new);
resourcePackManager.registerProvider(new VanillaDataPackProvider());
resourcePackManager.registerProvider(new FileResourcePackProvider(new File("./datapacks")));
if (config.enableTestThings)
resourcePackManager.registerProvider(new ModResourcePackCreator(ResourceType.SERVER_DATA));
ResourcePackManager resourcePackManager;
if (!config.enableTestThings) {
resourcePackManager =
new ResourcePackManager(ResourcePackProfile::new,
new VanillaDataPackProvider(),
new FileResourcePackProvider(new File("./datapacks"), method_29486("pack.source.global")));
} else {
resourcePackManager =
new ResourcePackManager(ResourcePackProfile::new,
new VanillaDataPackProvider(),
new FileResourcePackProvider(new File("./datapacks"), method_29486("pack.source.global")),
new ModResourcePackCreator(ResourceType.SERVER_DATA));
}
resourcePackManager.scanPacks();
List<ResourcePackProfile> ep = Lists.newArrayList(resourcePackManager.getEnabledProfiles());
for (ResourcePackProfile rpp : resourcePackManager.getProfiles()) {
@ -62,8 +72,7 @@ public abstract class GenericManualResourceLoader<T> {
rpp.getInitialPosition().insert(ep, rpp, resourcePackProfile -> resourcePackProfile, false);
}
}
resourcePackManager.setEnabledProfiles(ep);
resourcePackManager.setEnabledProfiles(ep.stream().map(ResourcePackProfile::getName).collect(Collectors.toList()));
ArrayList<Pair<Identifier, JsonObject>> itemJsonList = new ArrayList<>();
HashMap<Identifier, JsonObject> itemJsonMap = Maps.newHashMap();

View File

@ -136,12 +136,12 @@ public class ItemResourceLoader extends GenericManualResourceLoader<Item> {
public static ItemGroup findGroup(String filter) {
for (ItemGroup g : ItemGroup.GROUPS) {
if (g.getName().toLowerCase().equals(filter.toLowerCase())) {
if (g.getName().equalsIgnoreCase(filter)) {
return g;
}
}
log(Level.WARN, "Item Group " + filter + " not found, using misc");
log(Level.INFO, "Valid groups:" + Arrays.stream(ItemGroup.GROUPS).map(ItemGroup::getId));
log(Level.INFO, "Valid groups:" + Arrays.stream(ItemGroup.GROUPS).map(ItemGroup::getName));
return ItemGroup.MISC;
}

View File

@ -4,12 +4,12 @@ import net.minecraft.block.MaterialColor;
import net.minecraft.block.piston.PistonBehavior;
public class MaterialSettingsPojo {
String materialColor = "PINK";
String pistonBehavior = "normal";
boolean blocksMovement = true;
boolean burnable = false;
boolean breakByHand = true;
boolean liquid = false;
boolean replaceable = false;
boolean solid = true;
boolean blocksLight = true;
}

View File

@ -1,7 +1,7 @@
package quimufu.simple_creator;
import me.sargunvohra.mcmods.autoconfig1u.ConfigData;
import me.sargunvohra.mcmods.autoconfig1u.annotation.Config;
import me.shedaniel.autoconfig.ConfigData;
import me.shedaniel.autoconfig.annotation.Config;
@Config(name = "simple_creator")
public class SimpleCreatorConfig implements ConfigData {

View File

@ -1,8 +1,7 @@
package quimufu.simple_creator;
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
import me.sargunvohra.mcmods.autoconfig1u.ConfigHolder;
import me.sargunvohra.mcmods.autoconfig1u.serializer.GsonConfigSerializer;
import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.serializer.GsonConfigSerializer;
import net.fabricmc.api.ModInitializer;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;

View File

@ -1,15 +1,12 @@
package quimufu.simple_creator;
import io.github.prospector.modmenu.api.ConfigScreenFactory;
import io.github.prospector.modmenu.api.ModMenuApi;
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import me.shedaniel.autoconfig.AutoConfig;
import net.minecraft.client.gui.screen.Screen;
public class SimpleCreatorModMenuIntegration implements ModMenuApi {
@Override
public String getModId() {
return SimpleCreatorMod.MOD_ID;
}
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {