diff --git a/.gitignore b/.gitignore index 9dbb757..31d2550 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,7 @@ build # other eclipse run -cottonly-main +runs +run-data -# Files from Forge MDK -forge*changelog.txt +repo \ No newline at end of file diff --git a/build.gradle b/build.gradle index 3d8a5d6..e6e8b36 100644 --- a/build.gradle +++ b/build.gradle @@ -1,133 +1,83 @@ plugins { + id 'java-library' id 'eclipse' + id 'idea' id 'maven-publish' - id 'net.minecraftforge.gradle' version '5.1.+' - id 'com.matthewprenger.cursegradle' version '1.4.0' + id 'net.neoforged.gradle.userdev' version '7.0.57' + id "me.modmuss50.mod-publish-plugin" version "0.4.5" } +def ENV = System.getenv() +version = "${ENV.GITHUB_RUN_NUMBER}" ? "${mod_version}.${ENV.GITHUB_RUN_NUMBER}" : "${mod_version}.nobuildnumber" +group = project.maven_group + repositories { + mavenLocal() maven { - url "https://www.cursemaven.com" + url "https://maven.curse.tools" } } -def ENV = System.getenv() -version = "${ENV.GITHUB_RUN_NUMBER}" ? "${mod_version}.${ENV.GITHUB_RUN_NUMBER}" : "${mod_version}.nobuildnumber" -group = 'net.manmaed.cottonly' -archivesBaseName = 'cottonly' -// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. +base { + archivesName = project.archives_base_name + "-neo" +} + java.toolchain.languageVersion = JavaLanguageVersion.of(17) -println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" -minecraft { - mappings channel: "${minecraft_mappings}", version: "${minecraft_version}" runs { - client { - workingDirectory project.file('run') - property 'forge.logging.markers', 'REGISTRIES' - property 'forge.logging.console.level', 'debug' - property 'forge.enabledGameTestNamespaces', 'cottonly' - mods { - cottonly { - source sourceSets.main - } - } - } + configureEach { + systemProperty 'forge.logging.markers', 'REGISTRIES' + systemProperty 'forge.logging.console.level', 'debug' + modSource project.sourceSets.main + } - server { - workingDirectory project.file('run') - property 'forge.logging.markers', 'REGISTRIES' - property 'forge.logging.console.level', 'debug' - property 'forge.enabledGameTestNamespaces', 'cottonly' - mods { - cottonly { - source sourceSets.main - } - } - } + client { + systemProperty 'forge.enabledGameTestNamespaces', project.archives_base_name + } - gameTestServer { - workingDirectory project.file('run') - property 'forge.logging.markers', 'REGISTRIES' - property 'forge.logging.console.level', 'debug' - property 'forge.enabledGameTestNamespaces', 'cottonly' - mods { - cottonly { - source sourceSets.main - } - } - } + server { + systemProperty 'forge.enabledGameTestNamespaces', project.archives_base_name + programArgument '--nogui' + } - data { - workingDirectory project.file('run') - property 'forge.logging.markers', 'REGISTRIES' - property 'forge.logging.console.level', 'debug' - args '--mod', 'cottonly', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') - mods { - cottonly { - source sourceSets.main - } - } - } + data { + programArguments.addAll '--mod', project.archives_base_name, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath() } } -sourceSets.main.resources { srcDir 'src/generated/resources' } - -repositories { -} +sourceSets.main.resources { + srcDir 'src/generated/resources' + } dependencies { - minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" -} - -jar { - manifest { - attributes([ - "Specification-Title" : "cottonly", - "Specification-Vendor" : "manmaed", - "Specification-Version" : "1", // We are version 1 of ourselves - "Implementation-Title" : project.name, - "Implementation-Version" : project.jar.archiveVersion, - "Implementation-Vendor" : "manmaed", - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") - ]) - } + implementation "net.neoforged:neoforge:${neo_version}" } +tasks.withType(ProcessResources).configureEach { + var replaceProperties = [ + version: version + ] + inputs.properties replaceProperties -jar.finalizedBy('reobfJar') - -publishing { - publications { - mavenJava(MavenPublication) { - artifact jar - } - } - repositories { - maven { - url "file://${project.projectDir}/mcmodsrepo" - } + filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) { + expand replaceProperties + [project: project] } } -if (ENV.CURSE_DEPLOY) { +publishMods { + dryRun = providers.environmentVariable("CURSE_DEPLOY").getOrNull() == null + file = jar.archiveFile + modLoaders.add("neoforge") + type = BETA + changelog = "changeme" + displayName = "${mod_name} v${project.version} - NeoForge - ${minecraft_version}" curseforge { - apiKey = ENV.CURSE_DEPLOY - project { - id = project.curseforge_id - releaseType = "${curseforge_releasetype}" - addGameVersion "Forge" - addGameVersion "Java 17" - addGameVersion "${minecraft_version}" - mainArtifact(jar) { - displayName = "${mod_name} v${version} - ${minecraft_version}" - } - changelog = "changeme" - - } + accessToken = providers.environmentVariable("CURSE_DEPLOY") + projectId = project.curseforge_id + minecraftVersions.add("Java 17") + minecraftVersions.add("${minecraft_version}") } } tasks.withType(JavaCompile).configureEach { options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation -} +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 0b940e8..1a045aa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,14 +3,18 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -# Forge Stuff -minecraft_version=1.19.3 -forge_version=44.0.18 +# Neo Stuff +minecraft_version=1.20.4 +neo_version=20.4.3-beta minecraft_mappings=official +# Mod Props +maven_group = net.manmaed +archives_base_name = cottonly + # Mod Stuff mod_name=Cottonly -mod_version=0.13 +mod_version=0.14 #CurseForge Stuff curseforge_id=515461 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 249e583..943f0cb 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ae04661..37aef8d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index a69d9cb..79a61d4 100644 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,10 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' @@ -143,12 +143,16 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac diff --git a/settings.gradle b/settings.gradle index bdcf2cd..db26097 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,7 +1,10 @@ pluginManagement { repositories { + mavenLocal() gradlePluginPortal() - maven { url = 'https://forge.modpacks.ch/maven' } - maven { url = 'https://maven.minecraftforge.net/' } + maven { url = 'https://maven.creeperhost.net/' } } +} +plugins { + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0' } \ No newline at end of file diff --git a/src/main/java/net/manmaed/cottonly/Cottonly.java b/src/main/java/net/manmaed/cottonly/Cottonly.java index 0186694..f9fae75 100644 --- a/src/main/java/net/manmaed/cottonly/Cottonly.java +++ b/src/main/java/net/manmaed/cottonly/Cottonly.java @@ -1,27 +1,24 @@ package net.manmaed.cottonly; import net.manmaed.cottonly.blocks.CBlocks; -import net.manmaed.cottonly.config.CottonConfig; import net.manmaed.cottonly.items.CItems; -import net.manmaed.cottonly.libs.LogHelper; import net.manmaed.cottonly.loot.CLoots; +import net.minecraft.core.registries.Registries; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.block.ComposterBlock; -import net.minecraftforge.data.event.GatherDataEvent; -import net.minecraftforge.event.CreativeModeTabEvent; -import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.ModLoadingContext; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.config.ModConfig; -import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.registries.ForgeRegistries; -import org.jline.utils.Log; +import net.neoforged.bus.api.IEventBus; +import net.neoforged.fml.common.Mod; +import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; +import net.neoforged.neoforge.registries.DeferredHolder; +import net.neoforged.neoforge.registries.DeferredRegister; + +import java.util.Arrays; +import java.util.List; + /** * Created by manmaed on 16/05/2021. @@ -34,26 +31,29 @@ public class Cottonly { * TODOs: * */ + public static final DeferredRegister CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MOD_ID); + public static final DeferredHolder cottonlyTab = CREATIVE_MODE_TABS.register(MOD_ID, () -> CreativeModeTab.builder() + .icon(() -> new ItemStack(Items.WITHER_ROSE)) + .title(Component.translatable("itemGroup." + MOD_ID)) + .displayItems((parms, output) -> { + List> myItems = Arrays.asList( + CItems.ITEMS + ); + for (DeferredRegister register : myItems) { + register.getEntries().forEach(entry -> output.accept(entry.get())); + } + }) + .build()); + - /*public static final CreativeModeTab itemGroup = new CreativeModeTab(MOD_ID) { - @Override - public ItemStack makeIcon() { - return new ItemStack(Items.WITHER_ROSE); - } - };*/ - public Cottonly() { - IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus(); + public Cottonly(IEventBus eventBus) { CItems.ITEMS.register(eventBus); CBlocks.BLOCKS.register(eventBus); eventBus.addListener(this::init); CLoots.LOOT_MODIFIERS.register(eventBus); - eventBus.addListener(this::createTabs); -/* - ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, CottonConfig.COMMON_CONFIG); -*/ - /*ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, CottonConfig.CLIENT_CONFIG); - ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, CottonConfig.SERVER_CONFIG);*/ + CREATIVE_MODE_TABS.register(eventBus); + } private void init(FMLCommonSetupEvent event) { @@ -64,7 +64,7 @@ private static void registerCompostable(float chance, Item itemIn) { ComposterBlock.COMPOSTABLES.put(itemIn, chance); } - public void createTabs(CreativeModeTabEvent.Register event) { + /*public void createTabs(CreativeModeTabEvent.Register event) { event.registerCreativeModeTab(new ResourceLocation(MOD_ID, "creative_tab"), builder -> builder .icon(() -> new ItemStack(Items.WITHER_ROSE)) .title(Component.translatable("itemGroup." + MOD_ID)) @@ -78,6 +78,6 @@ public void createTabs(CreativeModeTabEvent.Register event) { } }) ); - } + }*/ } diff --git a/src/main/java/net/manmaed/cottonly/CottonlyClient.java b/src/main/java/net/manmaed/cottonly/CottonlyClient.java index 9a0f301..350db19 100644 --- a/src/main/java/net/manmaed/cottonly/CottonlyClient.java +++ b/src/main/java/net/manmaed/cottonly/CottonlyClient.java @@ -1,9 +1,7 @@ package net.manmaed.cottonly; -import net.manmaed.cottonly.blocks.CBlocks; -import net.minecraft.client.renderer.ItemBlockRenderTypes; -import net.minecraft.client.renderer.RenderType; -import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; + +import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; /** * Created by manmaed on 16/05/2021. diff --git a/src/main/java/net/manmaed/cottonly/blocks/CBlocks.java b/src/main/java/net/manmaed/cottonly/blocks/CBlocks.java index 3fcb1a3..3564e6d 100644 --- a/src/main/java/net/manmaed/cottonly/blocks/CBlocks.java +++ b/src/main/java/net/manmaed/cottonly/blocks/CBlocks.java @@ -7,18 +7,17 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraft.world.level.material.Material; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.RegistryObject; +import net.neoforged.neoforge.registries.DeferredBlock; +import net.neoforged.neoforge.registries.DeferredItem; +import net.neoforged.neoforge.registries.DeferredRegister; /** * Created by manmaed on 16/05/2021. */ public class CBlocks { - public static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, Cottonly.MOD_ID); + public static final DeferredRegister.Blocks BLOCKS = DeferredRegister.createBlocks(Cottonly.MOD_ID); - public static final RegistryObject COTTON_PLANT = BLOCKS.register("cotton_plant", () -> new CottonPlant(BlockBehaviour.Properties.of(Material.PLANT).noCollission().randomTicks().instabreak().sound(SoundType.CROP))); - public static final RegistryObject COTTON_PLANT_ITEM = CItems.ITEMS.register("cotton_plant", () -> new BlockItem(COTTON_PLANT.get(), new Item.Properties())); + public static final DeferredBlock COTTON_PLANT = BLOCKS.register("cotton_plant", () -> new CottonPlant(BlockBehaviour.Properties.of().noCollission().randomTicks().instabreak().sound(SoundType.CROP))); + public static final DeferredItem COTTON_PLANT_ITEM = CItems.ITEMS.register("cotton_plant", () -> new BlockItem(COTTON_PLANT.get(), new Item.Properties())); } \ No newline at end of file diff --git a/src/main/java/net/manmaed/cottonly/blocks/CottonPlant.java b/src/main/java/net/manmaed/cottonly/blocks/CottonPlant.java index 37ec2a6..f7973de 100644 --- a/src/main/java/net/manmaed/cottonly/blocks/CottonPlant.java +++ b/src/main/java/net/manmaed/cottonly/blocks/CottonPlant.java @@ -1,14 +1,8 @@ package net.manmaed.cottonly.blocks; import net.manmaed.cottonly.items.CItems; -import net.minecraft.core.BlockPos; -import net.minecraft.core.NonNullList; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.block.CropBlock; -import net.minecraftforge.common.PlantType; /** * Created by manmaed on 16/05/2021. @@ -23,8 +17,4 @@ public ItemLike getBaseSeedId() { return CItems.COTTON_SEED.get(); } - @Override - public PlantType getPlantType(BlockGetter world, BlockPos pos) { - return PlantType.CROP; - } } diff --git a/src/main/java/net/manmaed/cottonly/config/CottonConfig.java b/src/main/java/net/manmaed/cottonly/config/CottonConfig.java index ab2a103..433e791 100644 --- a/src/main/java/net/manmaed/cottonly/config/CottonConfig.java +++ b/src/main/java/net/manmaed/cottonly/config/CottonConfig.java @@ -1,12 +1,11 @@ package net.manmaed.cottonly.config; -import net.minecraftforge.common.ForgeConfigSpec; /** * Created by manmaed on 15/08/2021. */ public class CottonConfig { - private static final ForgeConfigSpec.Builder COMMON_BUILDER = new ForgeConfigSpec.Builder(); + /*private static final ForgeConfigSpec.Builder COMMON_BUILDER = new ForgeConfigSpec.Builder(); private static final ForgeConfigSpec.Builder CLIENT_BUILDER = new ForgeConfigSpec.Builder(); private static final ForgeConfigSpec.Builder SERVER_BUILDER = new ForgeConfigSpec.Builder(); @@ -28,5 +27,5 @@ public class CottonConfig { private static void doLootTableMagic() { REMOVE_GRASS_LOOT_TABLE = COMMON_BUILDER.comment("Remove Cotton seeds from the grass & fern loot table? [DEFAULT:false]").define("remove_cotton_seeds_loot_table", false); - } + }*/ } diff --git a/src/main/java/net/manmaed/cottonly/items/ArmorMaterialCotton.java b/src/main/java/net/manmaed/cottonly/items/ArmorMaterialCotton.java index cd00ef0..0f396e4 100644 --- a/src/main/java/net/manmaed/cottonly/items/ArmorMaterialCotton.java +++ b/src/main/java/net/manmaed/cottonly/items/ArmorMaterialCotton.java @@ -1,37 +1,49 @@ package net.manmaed.cottonly.items; +import net.minecraft.Util; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.util.LazyLoadedValue; -import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.ArmorMaterial; import net.minecraft.world.item.crafting.Ingredient; +import java.util.EnumMap; import java.util.function.Supplier; /** * Complete copy paste from {@link net.minecraft.world.item.ArmorMaterials} */ public enum ArmorMaterialCotton implements ArmorMaterial { - COTTON("cotton_armor_material", 5, new int[]{1, 2, 3, 1}, 15, SoundEvents.ARMOR_EQUIP_LEATHER, 0.0F, 0.0F, () -> { + COTTON("cotton_armor_material", 5, Util.make(new EnumMap<>(ArmorItem.Type.class), type -> { + type.put(ArmorItem.Type.BOOTS, 1); + type.put(ArmorItem.Type.LEGGINGS, 2); + type.put(ArmorItem.Type.CHESTPLATE, 3); + type.put(ArmorItem.Type.HELMET, 1); + }), 15, SoundEvents.ARMOR_EQUIP_LEATHER, 0.0F, 0.0F, () -> { return Ingredient.of(CItems.COTTON_BALL.get()); }); - private static final int[] HEALTH_PER_SLOT = new int[]{13, 15, 16, 11}; + private static final EnumMap HEALTH_FUNCTION_FOR_TYPE = Util.make(new EnumMap<>(ArmorItem.Type.class), type -> { + type.put(ArmorItem.Type.BOOTS, 13); + type.put(ArmorItem.Type.LEGGINGS, 15); + type.put(ArmorItem.Type.CHESTPLATE, 16); + type.put(ArmorItem.Type.HELMET, 11); + }); private final String name; private final int durabilityMultiplier; - private final int[] slotProtections; + private final EnumMap protectionFunctionForType; private final int enchantmentValue; private final SoundEvent sound; private final float toughness; private final float knockbackResistance; private final LazyLoadedValue repairIngredient; - ArmorMaterialCotton(String name, int durabilityMultiplier, int[] slotProtections, int enchantmentValue, SoundEvent sound, float toughness, float knockbackResistance, Supplier repairMaterial) { + ArmorMaterialCotton(String name, int durabilityMultiplier, EnumMap protection, int enchantmentValue, SoundEvent sound, float toughness, float knockbackResistance, Supplier repairMaterial) { this.name = name; this.durabilityMultiplier = durabilityMultiplier; - this.slotProtections = slotProtections; + this.protectionFunctionForType = protection; this.enchantmentValue = enchantmentValue; this.sound = sound; this.toughness = toughness; @@ -39,12 +51,14 @@ public enum ArmorMaterialCotton implements ArmorMaterial { this.repairIngredient = new LazyLoadedValue<>(repairMaterial); } - public int getDurabilityForSlot(EquipmentSlot equipmentSlot) { - return HEALTH_PER_SLOT[equipmentSlot.getIndex()] * this.durabilityMultiplier; + @Override + public int getDurabilityForType(ArmorItem.Type type) { + return HEALTH_FUNCTION_FOR_TYPE.get(type) * this.durabilityMultiplier; } - public int getDefenseForSlot(EquipmentSlot equipmentSlot) { - return this.slotProtections[equipmentSlot.getIndex()]; + @Override + public int getDefenseForType(ArmorItem.Type type) { + return this.protectionFunctionForType.get(type); } public int getEnchantmentValue() { diff --git a/src/main/java/net/manmaed/cottonly/items/CArmorItem.java b/src/main/java/net/manmaed/cottonly/items/CArmorItem.java index f625d13..629d42c 100644 --- a/src/main/java/net/manmaed/cottonly/items/CArmorItem.java +++ b/src/main/java/net/manmaed/cottonly/items/CArmorItem.java @@ -14,8 +14,8 @@ * mostly copy paste from (it auto gened the constrcture) {@link net.minecraft.world.item.DyeableArmorItem} */ public class CArmorItem extends DyeableArmorItem { - public CArmorItem(ArmorMaterial materialIn, EquipmentSlot slot, Properties builderIn) { - super(materialIn, slot, builderIn); + public CArmorItem(ArmorMaterial materialIn, ArmorItem.Type type, Properties builderIn) { + super(materialIn, type, builderIn); } @Override diff --git a/src/main/java/net/manmaed/cottonly/items/CItems.java b/src/main/java/net/manmaed/cottonly/items/CItems.java index d68fd14..651bd05 100644 --- a/src/main/java/net/manmaed/cottonly/items/CItems.java +++ b/src/main/java/net/manmaed/cottonly/items/CItems.java @@ -1,26 +1,26 @@ package net.manmaed.cottonly.items; + import net.manmaed.cottonly.Cottonly; import net.manmaed.cottonly.blocks.CBlocks; -import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemNameBlockItem; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.RegistryObject; +import net.neoforged.neoforge.registries.DeferredItem; +import net.neoforged.neoforge.registries.DeferredRegister; /** * Created by manmaed on 16/05/2021. */ public class CItems { - public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, Cottonly.MOD_ID); + public static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(Cottonly.MOD_ID); - public static final RegistryObject COTTON_SEED = ITEMS.register("cotton_seeds", () -> new ItemNameBlockItem(CBlocks.COTTON_PLANT.get(), (new Item.Properties()))); - public static final RegistryObject COTTON_BALL = ITEMS.register("ball", () -> new Item(new Item.Properties())); - public static final RegistryObject COTTON_HAT = ITEMS.register("cotton_hat", () -> new CArmorItem(ArmorMaterialCotton.COTTON, EquipmentSlot.HEAD, (new Item.Properties()))); - public static final RegistryObject COTTON_SHIRT = ITEMS.register("cotton_shirt", () -> new CArmorItem(ArmorMaterialCotton.COTTON, EquipmentSlot.CHEST, (new Item.Properties()))); - public static final RegistryObject COTTON_TROUSERS = ITEMS.register("cotton_trousers", () -> new CArmorItem(ArmorMaterialCotton.COTTON, EquipmentSlot.LEGS, (new Item.Properties()))); - public static final RegistryObject COTTON_SOCKS = ITEMS.register("cotton_socks", () -> new CArmorItem(ArmorMaterialCotton.COTTON, EquipmentSlot.FEET, (new Item.Properties()))); + public static final DeferredItem COTTON_SEED = ITEMS.register("cotton_seeds", () -> new ItemNameBlockItem(CBlocks.COTTON_PLANT.get(), (new Item.Properties()))); + public static final DeferredItem COTTON_BALL = ITEMS.register("ball", () -> new Item(new Item.Properties())); + public static final DeferredItem COTTON_HAT = ITEMS.register("cotton_hat", () -> new CArmorItem(ArmorMaterialCotton.COTTON, ArmorItem.Type.HELMET, new Item.Properties())); + public static final DeferredItem COTTON_SHIRT = ITEMS.register("cotton_shirt", () -> new CArmorItem(ArmorMaterialCotton.COTTON, ArmorItem.Type.CHESTPLATE, new Item.Properties())); + public static final DeferredItem COTTON_TROUSERS = ITEMS.register("cotton_trousers", () -> new CArmorItem(ArmorMaterialCotton.COTTON, ArmorItem.Type.LEGGINGS, new Item.Properties())); + public static final DeferredItem COTTON_SOCKS = ITEMS.register("cotton_socks", () -> new CArmorItem(ArmorMaterialCotton.COTTON, ArmorItem.Type.BOOTS, new Item.Properties())); } diff --git a/src/main/java/net/manmaed/cottonly/libs/LogHelper.java b/src/main/java/net/manmaed/cottonly/libs/LogHelper.java deleted file mode 100644 index a5ae442..0000000 --- a/src/main/java/net/manmaed/cottonly/libs/LogHelper.java +++ /dev/null @@ -1,33 +0,0 @@ -package net.manmaed.cottonly.libs; - -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -/** - * Created by manmaed on 16/05/2021. - */ -public class LogHelper { - private static final Logger LOGGER = LogManager.getLogger(); - public static final String LOG = ":[Cottonly]:"; - - private static void log(Level loglvl, Object object) { - LOGGER.log(loglvl, "[" + loglvl + "]:" + "-" + LOG + " " + object); - } - - public static void info(Object object) { - log(Level.INFO, object); - } - - public static void warn(Object object) { - log(Level.WARN, object); - } - - public static void fatal(Object object) { - log(Level.FATAL, object); - } - - public static void debug(Object object) { - log(Level.FATAL, object); - } -} diff --git a/src/main/java/net/manmaed/cottonly/loot/CLoots.java b/src/main/java/net/manmaed/cottonly/loot/CLoots.java index 5577134..ad2345c 100644 --- a/src/main/java/net/manmaed/cottonly/loot/CLoots.java +++ b/src/main/java/net/manmaed/cottonly/loot/CLoots.java @@ -2,20 +2,19 @@ import com.mojang.serialization.Codec; import net.manmaed.cottonly.Cottonly; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.common.loot.IGlobalLootModifier; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.RegistryObject; +import net.neoforged.neoforge.common.loot.IGlobalLootModifier; +import net.neoforged.neoforge.registries.DeferredHolder; +import net.neoforged.neoforge.registries.DeferredRegister; +import net.neoforged.neoforge.registries.NeoForgeRegistries; + /** * Created by manmaed on 04/12/2021. */ public class CLoots { - public static final DeferredRegister> LOOT_MODIFIERS = DeferredRegister.create(ForgeRegistries.Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS, Cottonly.MOD_ID); - - public static final RegistryObject> COTTON_FROM_GRASS = LOOT_MODIFIERS.register("cotton_from_grass", () -> GrassSeedModifier.CODEC); - public static final RegistryObject> COTTON_FROM_FERN = LOOT_MODIFIERS.register("cotton_from_fern", () -> GrassSeedModifier2.CODEC); - public static final RegistryObject> COTTON_FROM_TALL_GRASS = LOOT_MODIFIERS.register("cotton_from_tall_grass", () -> GrassSeedModifier3.CODEC); - public static final RegistryObject> COTTON_FROM_LARGE_FERN = LOOT_MODIFIERS.register("cotton_from_large_fern", () -> GrassSeedModifier4.CODEC); + public static final DeferredRegister> LOOT_MODIFIERS = DeferredRegister.create(NeoForgeRegistries.Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS, Cottonly.MOD_ID); + public static final DeferredHolder, Codec> COTTON_FROM_SHORT_GRASS = LOOT_MODIFIERS.register("cotton_from_short_grass", () -> GrassSeedModifier.CODEC); + public static final DeferredHolder, Codec> COTTON_FROM_FERN = LOOT_MODIFIERS.register("cotton_from_fern", () -> GrassSeedModifier2.CODEC); + public static final DeferredHolder, Codec> COTTON_FROM_TALL_GRASS = LOOT_MODIFIERS.register("cotton_from_tall_grass", () -> GrassSeedModifier3.CODEC); + public static final DeferredHolder, Codec> COTTON_FROM_LARGE_FERN = LOOT_MODIFIERS.register("cotton_from_large_fern", () -> GrassSeedModifier4.CODEC); } diff --git a/src/main/java/net/manmaed/cottonly/loot/GrassSeedModifier.java b/src/main/java/net/manmaed/cottonly/loot/GrassSeedModifier.java index 6abd7dc..01b4401 100644 --- a/src/main/java/net/manmaed/cottonly/loot/GrassSeedModifier.java +++ b/src/main/java/net/manmaed/cottonly/loot/GrassSeedModifier.java @@ -4,12 +4,11 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import it.unimi.dsi.fastutil.objects.ObjectArrayList; -import net.manmaed.cottonly.items.CItems; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; -import net.minecraftforge.common.loot.IGlobalLootModifier; -import net.minecraftforge.common.loot.LootModifier; +import net.neoforged.neoforge.common.loot.IGlobalLootModifier; +import net.neoforged.neoforge.common.loot.LootModifier; import org.jetbrains.annotations.NotNull; /** diff --git a/src/main/java/net/manmaed/cottonly/loot/GrassSeedModifier2.java b/src/main/java/net/manmaed/cottonly/loot/GrassSeedModifier2.java index 56cea73..5ba703f 100644 --- a/src/main/java/net/manmaed/cottonly/loot/GrassSeedModifier2.java +++ b/src/main/java/net/manmaed/cottonly/loot/GrassSeedModifier2.java @@ -1,14 +1,13 @@ package net.manmaed.cottonly.loot; - import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; -import net.minecraftforge.common.loot.IGlobalLootModifier; -import net.minecraftforge.common.loot.LootModifier; +import net.neoforged.neoforge.common.loot.IGlobalLootModifier; +import net.neoforged.neoforge.common.loot.LootModifier; import org.jetbrains.annotations.NotNull; /** diff --git a/src/main/java/net/manmaed/cottonly/loot/GrassSeedModifier3.java b/src/main/java/net/manmaed/cottonly/loot/GrassSeedModifier3.java index e75cc74..fbbc7a6 100644 --- a/src/main/java/net/manmaed/cottonly/loot/GrassSeedModifier3.java +++ b/src/main/java/net/manmaed/cottonly/loot/GrassSeedModifier3.java @@ -7,8 +7,8 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; -import net.minecraftforge.common.loot.IGlobalLootModifier; -import net.minecraftforge.common.loot.LootModifier; +import net.neoforged.neoforge.common.loot.IGlobalLootModifier; +import net.neoforged.neoforge.common.loot.LootModifier; import org.jetbrains.annotations.NotNull; /** diff --git a/src/main/java/net/manmaed/cottonly/loot/GrassSeedModifier4.java b/src/main/java/net/manmaed/cottonly/loot/GrassSeedModifier4.java index 7515b17..d6d1224 100644 --- a/src/main/java/net/manmaed/cottonly/loot/GrassSeedModifier4.java +++ b/src/main/java/net/manmaed/cottonly/loot/GrassSeedModifier4.java @@ -7,8 +7,8 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; -import net.minecraftforge.common.loot.IGlobalLootModifier; -import net.minecraftforge.common.loot.LootModifier; +import net.neoforged.neoforge.common.loot.IGlobalLootModifier; +import net.neoforged.neoforge.common.loot.LootModifier; import org.jetbrains.annotations.NotNull; /** diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index fad9ef4..8bbbae8 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -1,19 +1,18 @@ -modLoader = "javafml" #mandatory -loaderVersion = "[44,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. +modLoader = "javafml" +loaderVersion = "[1,)" license = "All rights reserved" -issueTrackerURL = "https://github.com/manmaed/cottonly/issues" #optional -[[mods]] #mandatory -modId = "cottonly" #mandatory -version = "${file.jarVersion}" #mandatory -displayName = "Cottonly" #mandatory -updateJSONURL = "https://raw.githubusercontent.com/manmaed/cottonly/main/update.json" -authors = "manmaed" #optional +issueTrackerURL = "https://github.com/manmaed/cottonly/issues" +[[mods]] +modId = "cottonly" +version="${version}" +displayName = "Cottonly" +updateJSONURL = "https://raw.githubusercontent.com/manmaed/cottonly/main/neo-update.json" +authors = "manmaed" logoFile = "cotton_logo.png" -description = ''' -Cotton Plant''' +description = '''Cotton Plant''' [[dependencies.cottonly]] -modId="forge" +modId="neoforge" mandatory=true -versionRange="[44.0.18,)" +versionRange="[20.4.3-beta,)" ordering="NONE" side="BOTH" \ No newline at end of file diff --git a/src/main/resources/data/cottonly/loot_modifiers/cotton_from_grass.json b/src/main/resources/data/cottonly/loot_modifiers/cotton_from_short_grass.json similarity index 83% rename from src/main/resources/data/cottonly/loot_modifiers/cotton_from_grass.json rename to src/main/resources/data/cottonly/loot_modifiers/cotton_from_short_grass.json index a76dde5..2ed0a2d 100644 --- a/src/main/resources/data/cottonly/loot_modifiers/cotton_from_grass.json +++ b/src/main/resources/data/cottonly/loot_modifiers/cotton_from_short_grass.json @@ -7,7 +7,7 @@ }, { "condition": "forge:loot_table_id", - "loot_table_id": "minecraft:blocks/grass" + "loot_table_id": "minecraft:blocks/short_grass" } ], "stack": { diff --git a/src/main/resources/data/forge/loot_modifiers/global_loot_modifiers.json b/src/main/resources/data/neoforge/loot_modifiers/global_loot_modifiers.json similarity index 79% rename from src/main/resources/data/forge/loot_modifiers/global_loot_modifiers.json rename to src/main/resources/data/neoforge/loot_modifiers/global_loot_modifiers.json index 73c01bc..4088ce0 100644 --- a/src/main/resources/data/forge/loot_modifiers/global_loot_modifiers.json +++ b/src/main/resources/data/neoforge/loot_modifiers/global_loot_modifiers.json @@ -1,7 +1,7 @@ { "replace": false, "entries": [ - "cottonly:cotton_from_grass", + "cottonly:cotton_from_short_grass", "cottonly:cotton_from_tall_grass", "cottonly:cotton_from_fern", "cottonly:cotton_from_large_fern" diff --git a/src/main/resources/data/forge/tags/items/crops.json b/src/main/resources/data/neoforge/tags/items/crops.json similarity index 100% rename from src/main/resources/data/forge/tags/items/crops.json rename to src/main/resources/data/neoforge/tags/items/crops.json diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta index dcbac02..d9f6ffd 100644 --- a/src/main/resources/pack.mcmeta +++ b/src/main/resources/pack.mcmeta @@ -1,8 +1,8 @@ { - "pack": { - "description": "cottonly resources", - "pack_format": 12, - "forge:resource_pack_format": 12, - "forge:data_pack_format": 10 + "pack": { + "description": { + "text": "cottonly resources" + }, + "pack_format": 18 } -} +} \ No newline at end of file