Skip to content

Commit

Permalink
1.18.2 - 3.2.1
Browse files Browse the repository at this point in the history
- moved RenderSetup
- reworked Common Events
- reworked Common Setup
- changed standard Configuration
- changed default values of MinecraftConfig
- reworked ModBlocks
- easier ModItems
- cleaned up WildCropBlock
- reworked WildCropConfig
- reworked WildCropFeature
- reworked WildCropGeneration
- reworked Main Class
- bumped version
  • Loading branch information
wolfkidsounds committed Jan 29, 2023
1 parent 2afafb8 commit 2f0ec6b
Show file tree
Hide file tree
Showing 33 changed files with 298 additions and 194 deletions.
15 changes: 8 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ plugins {
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.parchmentmc.librarian.forgegradle'

version = '1.18.2_3.1.1_forge'
group = 'wks.wolfkidsounds'

version = '1.18.2_3.2.1_forge'
group = 'wks.wolfkidsounds' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'wildplants'

// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
Expand All @@ -41,7 +42,7 @@ minecraft {
// Use non-default mappings at your own risk. They may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
// mappings channel: 'official', version: '1.18.2'
mappings channel: 'parchment', version: '2022.08.07-1.18.2'
mappings channel: 'parchment', version: '2022.11.06-1.18.2'

// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default.

Expand Down Expand Up @@ -154,7 +155,7 @@ dependencies {
// Specify the version of Minecraft to use. If this is any group other than 'net.minecraft', it is assumed
// that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied.
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft 'net.minecraftforge:forge:1.18.2-40.1.80'
minecraft 'net.minecraftforge:forge:1.18.2-40.2.0'

// Real mod deobf dependency examples - these get remapped to your current mappings
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency
Expand All @@ -174,17 +175,17 @@ jar {
manifest {
attributes([
"Specification-Title" : "wildplants",
"Specification-Vendor" : "wildplantssareus",
"Specification-Vendor" : "wolfkidsounds",
"Specification-Version" : "1", // We are version 1 of ourselves
"Implementation-Title" : project.name,
"Implementation-Version" : project.jar.archiveVersion,
"Implementation-Vendor" : "wildplantssareus",
"Implementation-Vendor" : "wolfkidsounds",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}

// Example settings to allow publishing using the maven-publish plugin
// Example configuration to allow publishing using the maven-publish plugin
// This is the preferred method to reobfuscate your jar file
jar.finalizedBy('reobfJar')
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
org.gradle.daemon=false
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
18 changes: 18 additions & 0 deletions src/main/java/wks/wolfkidsounds/wildplants/ClientSetup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package wks.wolfkidsounds.wildplants;

import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.RenderType;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import wks.wolfkidsounds.wildplants.block.ModBlocks;
import wks.wolfkidsounds.wildplants.config.Configuration;

public class ClientSetup {
public static void init(final FMLClientSetupEvent event) {
if (Configuration.ENABLE_MINECRAFT.get()) {
ItemBlockRenderTypes.setRenderLayer(ModBlocks.MINECRAFT_WILD_WHEAT.get(), RenderType.cutout());
ItemBlockRenderTypes.setRenderLayer(ModBlocks.MINECRAFT_WILD_CARROTS.get(), RenderType.cutout());
ItemBlockRenderTypes.setRenderLayer(ModBlocks.MINECRAFT_WILD_POTATOES.get(), RenderType.cutout());
ItemBlockRenderTypes.setRenderLayer(ModBlocks.MINECRAFT_WILD_BEETROOTS.get(), RenderType.cutout());
}
}
}
5 changes: 4 additions & 1 deletion src/main/java/wks/wolfkidsounds/wildplants/CommonSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
public class CommonSetup {
public static void init(final FMLCommonSetupEvent event) {
event.enqueueWork(() -> {
if (Configuration.ENABLE_MINECRAFT.get()) {WildCropGeneration.registerWildMinecraftCropGeneration();}
if (Configuration.ENABLE_MINECRAFT.get()) {
WildCropGeneration.registerWildMinecraftCropGeneration();
Wildplants.LOGGER.debug("setup-minecraft");
}
});
}
}
32 changes: 25 additions & 7 deletions src/main/java/wks/wolfkidsounds/wildplants/Wildplants.java
Original file line number Diff line number Diff line change
@@ -1,38 +1,56 @@
package wks.wolfkidsounds.wildplants;

import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Blocks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import wks.wolfkidsounds.wildplants.block.ModBlocks;
import wks.wolfkidsounds.wildplants.config.Configuration;
import wks.wolfkidsounds.wildplants.config.features.MinecraftConfig;
import wks.wolfkidsounds.wildplants.config.MinecraftConfig;
import wks.wolfkidsounds.wildplants.item.ModItems;
import wks.wolfkidsounds.wildplants.registry.ModBiomeFeatures;
import wks.wolfkidsounds.wildplants.registry.ModBlocks;
import wks.wolfkidsounds.wildplants.registry.ModItems;
import wks.wolfkidsounds.wildplants.registry.ModPlacementModifiers;
import wks.wolfkidsounds.wildplants.world.RenderSetup;

import javax.annotation.Nonnull;

@Mod(Wildplants.MOD_ID)
public class Wildplants {
public static final String MOD_ID = "wildplants";
public static final Logger LOGGER = LogManager.getLogger();
public static final CreativeModeTab CREATIVE_MODE_TAB = new CreativeModeTab("wildplants_creative_tab") {
@Nonnull
@Override
public ItemStack makeIcon() {
return new ItemStack(Blocks.GRASS);
}
};

public Wildplants() {
final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();

modEventBus.addListener(CommonSetup::init);
modEventBus.addListener(RenderSetup::init);
modEventBus.addListener(ClientSetup::init);
LOGGER.debug("register-eventbus");

//Configurations
ModLoadingContext.get().registerConfig(net.minecraftforge.fml.config.ModConfig.Type.COMMON, Configuration.SPEC, "wildplants/wildplants-common.toml");
ModLoadingContext.get().registerConfig(net.minecraftforge.fml.config.ModConfig.Type.CLIENT, MinecraftConfig.SPEC, "wildplants/mods/minecraft.toml");
ModLoadingContext.get().registerConfig(net.minecraftforge.fml.config.ModConfig.Type.COMMON, MinecraftConfig.SPEC, "wildplants/mods/minecraft.toml");
LOGGER.debug("register-config");

ModItems.ITEMS.register(modEventBus);
//Registry
ModBlocks.BLOCKS.register(modEventBus);
ModItems.ITEMS.register(modEventBus);
ModBiomeFeatures.FEATURES.register(modEventBus);
ModPlacementModifiers.PLACEMENT_MODIFIERS.register(modEventBus);
LOGGER.debug("register-ModObjects");

MinecraftForge.EVENT_BUS.register(this);
LOGGER.debug("register-eventbus");
}
}
48 changes: 48 additions & 0 deletions src/main/java/wks/wolfkidsounds/wildplants/block/ModBlocks.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package wks.wolfkidsounds.wildplants.block;

import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import wks.wolfkidsounds.wildplants.Wildplants;
import wks.wolfkidsounds.wildplants.config.Configuration;
import wks.wolfkidsounds.wildplants.item.ModItems;

import java.util.function.Supplier;

public class ModBlocks {
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, Wildplants.MOD_ID);

//MINECRAFT
public static final RegistryObject<Block> MINECRAFT_WILD_WHEAT = registerMinecraftBlock("minecraft_wild_wheat", () -> new WildCropBlock(MobEffects.GLOWING, 1, Block.Properties.copy(Blocks.TALL_GRASS)));
public static final RegistryObject<Block> MINECRAFT_WILD_CARROTS = registerMinecraftBlock("minecraft_wild_carrots", () -> new WildCropBlock(MobEffects.GLOWING, 1, Block.Properties.copy(Blocks.TALL_GRASS)));
public static final RegistryObject<Block> MINECRAFT_WILD_POTATOES = registerMinecraftBlock("minecraft_wild_potatoes", () -> new WildCropBlock(MobEffects.GLOWING, 1, Block.Properties.copy(Blocks.TALL_GRASS)));
public static final RegistryObject<Block> MINECRAFT_WILD_BEETROOTS = registerMinecraftBlock("minecraft_wild_beetroots", () -> new WildCropBlock(MobEffects.GLOWING, 1, Block.Properties.copy(Blocks.TALL_GRASS)));

//----------------------------------------------------------------------------------------------
private static <T extends Block> RegistryObject<T> registerMinecraftBlock(String name, Supplier<T> block) {
RegistryObject<T> toReturn = BLOCKS.register(name, block);
if (Configuration.ENABLE_MINECRAFT.get()) {
registerBlockItem(name, toReturn);
Wildplants.LOGGER.debug("register-blocks-minecraft");
}
return toReturn;
}

//----------------------------------------------------------------------------------------------

private static <T extends Block> void registerBlockItem(String name, RegistryObject<T> block) {
ModItems.ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties().tab(Wildplants.CREATIVE_MODE_TAB)));
Wildplants.LOGGER.debug("register-block-ttems");
}

public static void register(IEventBus eventBus) {
BLOCKS.register(eventBus);
Wildplants.LOGGER.debug("register-modblocks-moditems");
}
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,12 @@
package wks.wolfkidsounds.wildplants.block;

import net.minecraft.core.BlockPos;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.FlowerBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import wks.wolfkidsounds.wildplants.Wildplants;

public class WildCropBlock extends FlowerBlock {
protected static final VoxelShape SHAPE = Block.box(2.0D, 0.0D, 2.0D, 14.0D, 13.0D, 14.0D);

public WildCropBlock(MobEffect suspiciousStewEffect, int effectDuration, Properties properties) {
super(suspiciousStewEffect, effectDuration, properties);
}

@Override
public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
return SHAPE;
}

@Override
protected boolean mayPlaceOn(BlockState state, BlockGetter level, BlockPos pos) {
return state.is(BlockTags.DIRT) || state.is(BlockTags.SAND);
Wildplants.LOGGER.debug("configure-cropblock");
}
}
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
package wks.wolfkidsounds.wildplants.config;

import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.common.Mod;

@Mod.EventBusSubscriber
public class Configuration {
public static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
public static final ForgeConfigSpec SPEC;

public static Boolean LOADED_IMMERSIVEENGINEERING = ModList.get().isLoaded("immersiveengineering");
public static Boolean LOADED_VEGGIEWAY = ModList.get().isLoaded("veggie_way");
public static Boolean LOADED_HARVESTCRAFT = ModList.get().isLoaded("pamhc2crops");
public static Boolean LOADED_ENHANCEDFARMING = ModList.get().isLoaded("enhancedfarming");

public static ForgeConfigSpec.ConfigValue<Integer> GLOBAL_FREQUENCY;
public static ForgeConfigSpec.ConfigValue<Integer> GLOBAL_SPREAD_SIZE;

public static ForgeConfigSpec.BooleanValue ENABLE_MINECRAFT;
public static ForgeConfigSpec.BooleanValue ENABLE_IMMERSIVEENGINEERING;
public static ForgeConfigSpec.BooleanValue ENABLE_VEGGIEWAY;
public static ForgeConfigSpec.BooleanValue ENABLE_HARVESTCRAFT;
public static ForgeConfigSpec.BooleanValue ENABLE_ENHANCEDFARMING;


static {

BUILDER.push("General");
BUILDER.push("Global_Modifier");
GLOBAL_FREQUENCY = BUILDER
.comment("How often to try to place a patch. (higher is more) [Default: 50]")
.define("Frequency", 50);
.comment("How often to try to place a patch. (smaller is more) [Default: 64]")
.define("Frequency", 64);
GLOBAL_SPREAD_SIZE = BUILDER
.comment("How far apart crops are planted in a patch. (higher is more) [Default: 6]")
.define("Size", 6);
.define("Size", 4);
BUILDER.pop();
BUILDER.push("Compat");
ENABLE_MINECRAFT = BUILDER
Expand All @@ -36,6 +44,8 @@ public class Configuration {
.define("Veggie_Way", true);
ENABLE_HARVESTCRAFT = BUILDER
.define("Harvestcraft", true);
ENABLE_ENHANCEDFARMING = BUILDER
.define("EnhancedFarming", true);
BUILDER.pop();
BUILDER.pop();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wks.wolfkidsounds.wildplants.config.features;
package wks.wolfkidsounds.wildplants.config;

import net.minecraftforge.common.ForgeConfigSpec;

Expand All @@ -25,32 +25,32 @@ public class MinecraftConfig {
GENERATE_MINECRAFT_WILD_WHEAT = BUILDER
.define("Enabled:", true);
CHANCE_MINECRAFT_WILD_WHEAT = BUILDER
.comment("Default [30]")
.defineInRange("Chance:", 30, 0, Integer.MAX_VALUE);
.comment("SMALLER=MORE - Default [64]")
.defineInRange("Chance:", 64, 0, Integer.MAX_VALUE);
BUILDER.pop();

BUILDER.push("MINECRAFT_WILD CARROTS");
GENERATE_MINECRAFT_WILD_CARROTS = BUILDER
.define("Enabled:", true);
CHANCE_MINECRAFT_WILD_CARROTS = BUILDER
.comment("Default [30]")
.defineInRange("Chance:", 30, 0, Integer.MAX_VALUE);
.comment("SMALLER=MORE - Default [64]")
.defineInRange("Chance:", 64, 0, Integer.MAX_VALUE);
BUILDER.pop();

BUILDER.push("MINECRAFT_WILD POTATOES");
GENERATE_MINECRAFT_WILD_POTATOES = BUILDER
.define("Enabled:", true);
CHANCE_MINECRAFT_WILD_POTATOES = BUILDER
.comment("Default [30]")
.defineInRange("Chance:", 30, 5, Integer.MAX_VALUE);
.comment("SMALLER=MORE - Default [64]")
.defineInRange("Chance:", 64, 5, Integer.MAX_VALUE);
BUILDER.pop();

BUILDER.push("MINECRAFT_WILD BEETROOTS");
GENERATE_MINECRAFT_WILD_BEETROOTS = BUILDER
.define("Enabled:", true);
CHANCE_MINECRAFT_WILD_BEETROOTS = BUILDER
.comment("Default [30]")
.defineInRange("Chance:", 30, 5, Integer.MAX_VALUE);
.comment("SMALLER=MORE - Default [64]")
.defineInRange("Chance:", 64, 5, Integer.MAX_VALUE);
BUILDER.pop();

SPEC = BUILDER.build();
Expand Down
Loading

0 comments on commit 2f0ec6b

Please sign in to comment.