project port to 1.21 (this finally launches)

This commit is contained in:
Jonas_Jones 2024-10-04 15:25:09 +02:00
parent bd6878b109
commit 64e2b5ea1e
53 changed files with 319 additions and 250 deletions

11
.gitattributes vendored
View file

@ -1,2 +1,9 @@
# Auto detect text files and perform LF normalization
* text=auto
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf
# These are Windows script files and should use crlf
*.bat text eol=crlf

View file

@ -12,29 +12,26 @@ jobs:
matrix:
# Use these Java versions
java: [
17, # Current Java LTS & minimum supported by Minecraft
21, # Current Java LTS
]
# and run on both Linux and Windows
os: [ubuntu-22.04, windows-2022]
runs-on: ${{ matrix.os }}
runs-on: ubuntu-22.04
steps:
- name: checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v1
uses: gradle/wrapper-validation-action@v2
- name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'microsoft'
- name: make gradle wrapper executable
if: ${{ runner.os != 'Windows' }}
run: chmod +x ./gradlew
- name: build
run: ./gradlew build
- name: capture build artifacts
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v3
if: ${{ matrix.java == '21' }} # Only upload artifacts built from latest java
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: build/libs/
path: build/libs/

View file

@ -1,11 +1,15 @@
plugins {
id 'fabric-loom' version '1.1-SNAPSHOT'
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'maven-publish'
}
version = project.mod_version
group = project.maven_group
base {
archivesName = project.archives_base_name
}
repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
@ -14,29 +18,27 @@ repositories {
// for more information about repositories.
}
loom {
splitEnvironmentSourceSets()
mods {
"modid" {
sourceSet sourceSets.main
sourceSet sourceSets.client
}
}
}
dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
//mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
mappings loom.layered {
//it.parchment("org.parchmentmc.data:parchment-1.19.3:2022.12.18@zip")
it.officialMojangMappings {
setNameSyntheticMembers(false)
}
}
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// Uncomment the following line to enable the deprecated Fabric API modules.
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.
// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
}
base {
archivesName = project.archives_base_name
}
processResources {
@ -48,8 +50,7 @@ processResources {
}
tasks.withType(JavaCompile).configureEach {
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
it.options.release = 21
}
java {
@ -58,20 +59,21 @@ java {
// If you remove this line, sources will not be generated.
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
jar {
from("LICENSE") {
rename { "${it}_${base.archivesName.get()}"}
rename { "${it}_${project.base.archivesName.get()}"}
}
}
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
create("mavenJava", MavenPublication) {
artifactId = project.archives_base_name
from components.java
}
}
@ -84,3 +86,7 @@ publishing {
// retrieving dependencies.
}
}
fabricApi {
configureDataGeneration()
}

View file

@ -4,14 +4,14 @@ org.gradle.parallel=true
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.2
loader_version=0.15.1
minecraft_version=1.21.1
yarn_mappings=1.21.1+build.3
loader_version=0.16.2
# Mod Properties
mod_version = 0.2.1-1.20.x
maven_group = me.jonasjones
archives_base_name = not-enough-cursedness
mod_version=0.2.1-1.21.x
maven_group=me.jonasjones
archives_base_name=not-enough-cursedness
# Dependencies
fabric_version=0.91.2+1.20.4
fabric_version=0.102.1+1.21.1

Binary file not shown.

View file

@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

34
gradlew vendored
View file

@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@ -83,10 +85,9 @@ done
# 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"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@ -133,10 +134,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
@ -144,7 +148,7 @@ 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
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@ -152,7 +156,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@ -197,11 +201,15 @@ if "$cygwin" || "$msys" ; then
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# 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"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \

22
gradlew.bat vendored
View file

@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail

View file

@ -1,10 +1,10 @@
pluginManagement {
repositories {
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
mavenCentral()
gradlePluginPortal()
}
}
repositories {
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
mavenCentral()
gradlePluginPortal()
}
}

View file

@ -4,25 +4,9 @@ import me.jonasjones.nec.block.ModBlocks;
import me.jonasjones.nec.item.ModItems;
import me.jonasjones.nec.util.ModRegistries;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.fabricmc.fabric.impl.itemgroup.FabricItemGroupBuilderImpl;
import net.minecraft.Util;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.Util.*;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.ItemStack;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin.register;
public class NotEnoughCursedness implements ModInitializer {
// This logger is used to write text to the console and the log file.
// It is considered best practice to use your mod id as the logger's name.

View file

@ -1,19 +1,22 @@
package me.jonasjones.nec.block;
import me.jonasjones.nec.util.ModRegistries;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.level.block.*;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.PillarBlock;
import net.minecraft.block.StairsBlock;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
import static me.jonasjones.nec.NotEnoughCursedness.MOD_ID;
import static net.minecraft.core.registries.BuiltInRegistries.BLOCK;
import static net.minecraft.core.registries.BuiltInRegistries.ITEM;
import static net.minecraft.registry.Registries.BLOCK;
import static net.minecraft.registry.Registries.ITEM;
public class ModBlocks {
public static final Block GREEN_BIRCH_LOG = new RotatedPillarBlock(FabricBlockSettings.copyOf(Blocks.BIRCH_LOG).strength(4.0f));
public static final Block GREEN_BIRCH_LOG = new PillarBlock(FabricBlockSettings.copyOf(Blocks.BIRCH_LOG).strength(4.0f));
public static final Block BLAZE_BLOCK = new Block(FabricBlockSettings.copyOf(Blocks.DIAMOND_BLOCK).strength(4.0F));
public static final Block GUN_BLOCK = new Block(FabricBlockSettings.copyOf(Blocks.DIAMOND_BLOCK).strength(4.0F));
public static final Block DIAMOND_ORE_ORE = new Block(FabricBlockSettings.copyOf(Blocks.DIAMOND_ORE).strength(4.0F));
@ -42,37 +45,37 @@ public class ModBlocks {
//public static final Block STRIPPED_GREEN_BIRCH_WOOD = new PillarBlock(FabricBlockSettings.of(Material.WOOD).strength(4.0f));
public static void register() {
BLAZE_BLOCK_BLOCK = Registry.register(BLOCK, new ResourceLocation(MOD_ID, "blaze_block"), BLAZE_BLOCK);
BLAZE_BLOCK_ITEM = Registry.register(ITEM, new ResourceLocation(MOD_ID, "blaze_block"), new BlockItem(BLAZE_BLOCK, new FabricItemSettings()));
BLAZE_BLOCK_BLOCK = Registry.register(BLOCK, Identifier.of(MOD_ID, "blaze_block"), BLAZE_BLOCK);
BLAZE_BLOCK_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "blaze_block"), new BlockItem(BLAZE_BLOCK, new Item.Settings()));
ModRegistries.register_item(BLAZE_BLOCK_ITEM);
GREEEN_BIRCH_LOG_BLOCK = Registry.register(BLOCK, new ResourceLocation(MOD_ID, "green_birch_log"), GREEN_BIRCH_LOG);
GREEN_BIRCH_LOG_ITEM = Registry.register(ITEM, new ResourceLocation(MOD_ID, "green_birch_log"), new BlockItem(GREEN_BIRCH_LOG, new FabricItemSettings()));
GREEEN_BIRCH_LOG_BLOCK = Registry.register(BLOCK, Identifier.of(MOD_ID, "green_birch_log"), GREEN_BIRCH_LOG);
GREEN_BIRCH_LOG_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "green_birch_log"), new BlockItem(GREEN_BIRCH_LOG, new Item.Settings()));
ModRegistries.register_item(GREEN_BIRCH_LOG_ITEM);
GUN_BLOCK_BLOCK = Registry.register(BLOCK, new ResourceLocation(MOD_ID, "gun_block"), GUN_BLOCK);
GUN_BLOCK_ITEM = Registry.register(ITEM, new ResourceLocation(MOD_ID, "gun_block"), new BlockItem(GUN_BLOCK, new FabricItemSettings()));
GUN_BLOCK_BLOCK = Registry.register(BLOCK, Identifier.of(MOD_ID, "gun_block"), GUN_BLOCK);
GUN_BLOCK_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "gun_block"), new BlockItem(GUN_BLOCK, new Item.Settings()));
ModRegistries.register_item(GUN_BLOCK_ITEM);
DIAMOND_ORE_ORE_BLOCK = Registry.register(BLOCK, new ResourceLocation(MOD_ID, "diamond_ore_ore"), DIAMOND_ORE_ORE);
DIAMOND_ORE_ORE_ITEM = Registry.register(ITEM, new ResourceLocation(MOD_ID, "diamond_ore_ore"), new BlockItem(DIAMOND_ORE_ORE, new FabricItemSettings()));
DIAMOND_ORE_ORE_BLOCK = Registry.register(BLOCK, Identifier.of(MOD_ID, "diamond_ore_ore"), DIAMOND_ORE_ORE);
DIAMOND_ORE_ORE_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "diamond_ore_ore"), new BlockItem(DIAMOND_ORE_ORE, new Item.Settings()));
ModRegistries.register_item(DIAMOND_ORE_ORE_ITEM);
DEEPSLATE_DIAMOND_ORE_ORE_BLOCK = Registry.register(BLOCK, new ResourceLocation(MOD_ID, "deepslate_diamond_ore_ore"), DEEPSLATE_DIAMOND_ORE_ORE);
DEEPSLATE_DIAMOND_ORE_ORE_ITEM = Registry.register(ITEM, new ResourceLocation(MOD_ID, "deepslate_diamond_ore_ore"), new BlockItem(DEEPSLATE_DIAMOND_ORE_ORE, new FabricItemSettings()));
DEEPSLATE_DIAMOND_ORE_ORE_BLOCK = Registry.register(BLOCK, Identifier.of(MOD_ID, "deepslate_diamond_ore_ore"), DEEPSLATE_DIAMOND_ORE_ORE);
DEEPSLATE_DIAMOND_ORE_ORE_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "deepslate_diamond_ore_ore"), new BlockItem(DEEPSLATE_DIAMOND_ORE_ORE, new Item.Settings()));
ModRegistries.register_item(DEEPSLATE_DIAMOND_ORE_ORE_ITEM);
JAVA_BLOCK_BLOCK = Registry.register(BLOCK, new ResourceLocation(MOD_ID, "java_block"), JAVA_BLOCK);
JAVA_BLOCK_ITEM = Registry.register(ITEM, new ResourceLocation(MOD_ID, "java_block"), new BlockItem(JAVA_BLOCK, new FabricItemSettings()));
JAVA_BLOCK_BLOCK = Registry.register(BLOCK, Identifier.of(MOD_ID, "java_block"), JAVA_BLOCK);
JAVA_BLOCK_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "java_block"), new BlockItem(JAVA_BLOCK, new Item.Settings()));
ModRegistries.register_item(JAVA_BLOCK_ITEM);
POCKET_BLOCK_BLOCK = Registry.register(BLOCK, new ResourceLocation(MOD_ID, "pocket_block"), POCKET_BLOCK);
POCKET_BLOCK_ITEM = Registry.register(ITEM, new ResourceLocation(MOD_ID, "pocket_block"), new BlockItem(POCKET_BLOCK, new FabricItemSettings()));
POCKET_BLOCK_BLOCK = Registry.register(BLOCK, Identifier.of(MOD_ID, "pocket_block"), POCKET_BLOCK);
POCKET_BLOCK_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "pocket_block"), new BlockItem(POCKET_BLOCK, new Item.Settings()));
ModRegistries.register_item(POCKET_BLOCK_ITEM);
FLETCHING_STAIRS_BLOCK = new StairBlock(GREEEN_BIRCH_LOG_BLOCK.defaultBlockState(), FabricBlockSettings.copyOf(Blocks.OAK_STAIRS).strength(1.0F));
FLETCHING_STAIRS_BLOCK_BLOCK = Registry.register(BLOCK, new ResourceLocation(MOD_ID, "fletching_stairs"), FLETCHING_STAIRS_BLOCK);
FLETCHING_STAIRS_TIEM = Registry.register(ITEM, new ResourceLocation(MOD_ID, "fletching_stairs"), new BlockItem(FLETCHING_STAIRS_BLOCK, new FabricItemSettings()));
FLETCHING_STAIRS_BLOCK = new StairsBlock(GREEEN_BIRCH_LOG_BLOCK.getDefaultState(), FabricBlockSettings.copyOf(Blocks.OAK_STAIRS).strength(1.0F));
FLETCHING_STAIRS_BLOCK_BLOCK = Registry.register(BLOCK, Identifier.of(MOD_ID, "fletching_stairs"), FLETCHING_STAIRS_BLOCK);
FLETCHING_STAIRS_TIEM = Registry.register(ITEM, Identifier.of(MOD_ID, "fletching_stairs"), new BlockItem(FLETCHING_STAIRS_BLOCK, new Item.Settings()));
ModRegistries.register_item(FLETCHING_STAIRS_TIEM);
}
}

View file

@ -0,0 +1,79 @@
package me.jonasjones.nec.datagen;
import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricAdvancementProvider;
import net.minecraft.advancement.*;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
import net.minecraft.advancement.criterion.ConsumeItemCriterion;
import net.minecraft.advancement.criterion.InventoryChangedCriterion;
import net.minecraft.item.Items;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
public class NecDataGen implements DataGeneratorEntrypoint {
@Override
public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
FabricDataGenerator.Pack pack = fabricDataGenerator.createPack();
pack.addProvider(AdvancementsProvider::new);
}
static class AdvancementsProvider extends FabricAdvancementProvider {
protected AdvancementsProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registryLookup) {
super(output, registryLookup);
}
@Override
public void generateAdvancement(RegistryWrapper.WrapperLookup registryLookup, Consumer<AdvancementEntry> consumer) {
AdvancementEntry rootAdvancement = Advancement.Builder.create()
.display(
Items.DIRT, // The display icon
Text.literal("Your First Dirt Block"), // The title
Text.literal("Now make a three by three"), // The description
new Identifier("textures/gui/advancements/backgrounds/adventure.png"), // Background image used
AdvancementFrame.TASK, // Options: TASK, CHALLENGE, GOAL
true, // Show toast top right
true, // Announce to chat
false // Hidden in the advancement tab
)
// The first string used in criterion is the name referenced by other advancements when they want to have 'requirements'
.criterion("got_dirt", InventoryChangedCriterion.Conditions.items(Items.DIRT))
.build(consumer, "your_mod_id_please_change_me" + "/root");
AdvancementEntry gotOakAdvancement = Advancement.Builder.create().parent(rootAdvancement)
.display(
Items.OAK_LOG,
Text.literal("Your First Log"),
Text.literal("Bare fisted"),
null, // children to parent advancements don't need a background set
AdvancementFrame.TASK,
true,
true,
false
)
.rewards(AdvancementRewards.Builder.experience(1000))
.criterion("got_wood", InventoryChangedCriterion.Conditions.items(Items.OAK_LOG))
.build(consumer, "your_mod_id_please_change_me" + "/got_wood");
AdvancementEntry eatAppleAdvancement = Advancement.Builder.create().parent(rootAdvancement)
.display(
Items.APPLE,
Text.literal("Apple and Beef"),
Text.literal("Ate an apple and beef"),
null, // children to parent advancements don't need a background set
AdvancementFrame.CHALLENGE,
true,
true,
false
)
.criterion("ate_apple", ConsumeItemCriterion.Conditions.item(Items.APPLE))
.criterion("ate_cooked_beef", ConsumeItemCriterion.Conditions.item(Items.COOKED_BEEF))
.build(consumer, "your_mod_id_please_change_me" + "/ate_apple_and_beef");
}
}
}

View file

@ -2,19 +2,17 @@ package me.jonasjones.nec.item;
import me.jonasjones.nec.item.materials.DirtToolMaterial;
import me.jonasjones.nec.util.ModRegistries;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.SwordItem;
import net.minecraft.world.item.TieredItem;
import static net.minecraft.core.registries.BuiltInRegistries.ITEM;
import net.minecraft.item.Item;
import net.minecraft.item.SwordItem;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
import static me.jonasjones.nec.NotEnoughCursedness.MOD_ID;
import static net.minecraft.registry.Registries.ITEM;
public class ModItems {
public static Item STEEL_ITEM;
public static TieredItem DIRT_SWORD_ITEM;
public static SwordItem DIRT_SWORD_ITEM;
public static Item NEGATIVE_FLINT_ITEM;
public static Item LETTER_ITEM;
public static Item CHAINMAIL_ITEM;
@ -22,32 +20,32 @@ public class ModItems {
public static Item HELMET_ON_A_STICK_ITEM;
public static void register() {
TieredItem DIRT_SWORD = new SwordItem(DirtToolMaterial.INSTANCE, 1, -3.0F, new Item.Properties());
DIRT_SWORD_ITEM = Registry.register(ITEM, new ResourceLocation(MOD_ID, "dirt_sword"), DIRT_SWORD);
ModRegistries.register_item(DIRT_SWORD_ITEM);
SwordItem DIRT_SWORD = new SwordItem(DirtToolMaterial.INSTANCE, new Item.Settings());
DIRT_SWORD_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "dirt_sword"), DIRT_SWORD);
//ModRegistries.register_item(DIRT_SWORD_ITEM);
Item STEEL = new Item(new FabricItemSettings());
STEEL_ITEM = Registry.register(ITEM, new ResourceLocation(MOD_ID, "steel"), STEEL);
ModRegistries.register_item(STEEL_ITEM);
Item STEEL = new Item(new Item.Settings());
STEEL_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "steel"), STEEL);
//ModRegistries.register_item(STEEL_ITEM);
Item NEGATIVE_FLINT = new Item(new FabricItemSettings());
NEGATIVE_FLINT_ITEM = Registry.register(ITEM, new ResourceLocation(MOD_ID, "negative_flint"), NEGATIVE_FLINT);
ModRegistries.register_item(NEGATIVE_FLINT_ITEM);
Item NEGATIVE_FLINT = new Item(new Item.Settings());
NEGATIVE_FLINT_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "negative_flint"), NEGATIVE_FLINT);
//ModRegistries.register_item(NEGATIVE_FLINT_ITEM);
Item LETTER = new Item(new FabricItemSettings());
LETTER_ITEM = Registry.register(ITEM, new ResourceLocation(MOD_ID, "letter"), LETTER);
ModRegistries.register_item(LETTER_ITEM);
Item LETTER = new Item(new Item.Settings());
LETTER_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "letter"), LETTER);
//ModRegistries.register_item(LETTER_ITEM);
Item CHAINMAIL = new Item(new FabricItemSettings());
CHAINMAIL_ITEM = Registry.register(ITEM, new ResourceLocation(MOD_ID, "chainmail"), CHAINMAIL);
ModRegistries.register_item(CHAINMAIL_ITEM);
Item CHAINMAIL = new Item(new Item.Settings());
CHAINMAIL_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "chainmail"), CHAINMAIL);
//ModRegistries.register_item(CHAINMAIL_ITEM);
Item AK47 = new Item(new FabricItemSettings());
AK47_ITEM = Registry.register(ITEM, new ResourceLocation(MOD_ID, "ak_47"), AK47);
ModRegistries.register_item(AK47_ITEM);
Item AK47 = new Item(new Item.Settings());
AK47_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "ak_47"), AK47);
//ModRegistries.register_item(AK47_ITEM);
Item HELMET_ON_A_STICK = new Item(new FabricItemSettings());
HELMET_ON_A_STICK_ITEM = Registry.register(ITEM, new ResourceLocation(MOD_ID, "helmet_on_a_stick"), HELMET_ON_A_STICK);
ModRegistries.register_item(HELMET_ON_A_STICK_ITEM);
Item HELMET_ON_A_STICK = new Item(new Item.Settings());
HELMET_ON_A_STICK_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "helmet_on_a_stick"), HELMET_ON_A_STICK);
//ModRegistries.register_item(HELMET_ON_A_STICK_ITEM);
}
}

View file

@ -1,41 +1,43 @@
package me.jonasjones.nec.item.materials;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.Tier;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.block.Block;
import net.minecraft.item.Items;
import net.minecraft.item.ToolMaterial;
import net.minecraft.recipe.Ingredient;
import net.minecraft.registry.tag.TagKey;
public class DirtToolMaterial implements Tier {
public class DirtToolMaterial implements ToolMaterial {
public static final DirtToolMaterial INSTANCE = new DirtToolMaterial();
@Override
public int getUses() {
public int getDurability() {
return 5;
}
@Override
public float getSpeed() {
public float getMiningSpeedMultiplier() {
return 1;
}
@Override
public float getAttackDamageBonus() {
public float getAttackDamage() {
return 2;
}
@Override
public int getLevel() {
return 0;
public TagKey<Block> getInverseTag() {
return null;
}
@Override
public int getEnchantmentValue() {
public int getEnchantability() {
return 100;
}
@Override
public Ingredient getRepairIngredient() {
return Ingredient.of(Items.DIRT, Items.COARSE_DIRT, Items.DIRT_PATH, Items.ROOTED_DIRT);
return Ingredient.ofItems(Items.DIRT, Items.COARSE_DIRT, Items.DIRT_PATH, Items.ROOTED_DIRT);
}
}

View file

@ -1,16 +0,0 @@
package me.jonasjones.nec.mixin;
import me.jonasjones.nec.NotEnoughCursedness;
import net.minecraft.client.gui.screens.TitleScreen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(TitleScreen.class)
public class ExampleMixin {
@Inject(at = @At("HEAD"), method = "init()V")
private void init(CallbackInfo info) {
//NotEnoughCursedness.LOGGER.info("This line is printed by an example mod mixin!");
}
}

View file

@ -3,24 +3,21 @@ package me.jonasjones.nec.util;
import me.jonasjones.nec.block.ModBlocks;
import me.jonasjones.nec.item.ModItems;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.fabricmc.fabric.api.registry.StrippableBlockRegistry;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import static me.jonasjones.nec.NotEnoughCursedness.MOD_ID;
public class ModRegistries {
public static CreativeModeTab ITEM_GROUP = FabricItemGroup.builder().title(Component.translatable("itemGroup.nec.not_enough_cursedness")).icon(() -> new ItemStack(ModBlocks.GREEN_BIRCH_LOG_ITEM)).build();
public static ItemGroup NEC_GROUP = null;
public static void registerModStuffs() {
registerFuels();
@ -57,38 +54,37 @@ public class ModRegistries {
//ServerPlayerEvents.COPY_FROM.register(new ModPlayerEventCopyFrom());
}
public static void register_item(Item CUSTOM_ITEM) {
public static void register_item(BlockItem CUSTOM_ITEM) {
//ItemGroupEvents.modifyEntriesEvent(ITEM_GROUP).register(content -> {
// content.add(CUSTOM_ITEM);
//});
}
public static void register_itemGroup() {
NEC_GROUP = FabricItemGroup.builder()
.icon(() -> new ItemStack(ModItems.DIRT_SWORD_ITEM))
.displayName(Text.translatable("itemGroup.nec.not_enough_cursedness"))
.entries(((displayContext, entries) -> {
entries.add(new ItemStack(ModBlocks.GREEN_BIRCH_LOG_ITEM));
entries.add(new ItemStack(ModBlocks.BLAZE_BLOCK));
entries.add(new ItemStack(ModBlocks.GUN_BLOCK));
entries.add(new ItemStack(ModBlocks.DIAMOND_ORE_ORE));
entries.add(new ItemStack(ModBlocks.DEEPSLATE_DIAMOND_ORE_ORE));
entries.add(new ItemStack(ModBlocks.JAVA_BLOCK));
entries.add(new ItemStack(ModBlocks.POCKET_BLOCK));
entries.add(new ItemStack(ModBlocks.FLETCHING_STAIRS_BLOCK));
ItemGroupEvents.modifyEntriesEvent(CreativeModeTabs.BUILDING_BLOCKS).register(content -> {
content.accept(new ItemStack(ModBlocks.GREEN_BIRCH_LOG_ITEM));
content.accept(new ItemStack(ModBlocks.BLAZE_BLOCK));
content.accept(new ItemStack(ModBlocks.GUN_BLOCK));
content.accept(new ItemStack(ModBlocks.DIAMOND_ORE_ORE));
content.accept(new ItemStack(ModBlocks.DEEPSLATE_DIAMOND_ORE_ORE));
content.accept(new ItemStack(ModBlocks.JAVA_BLOCK));
content.accept(new ItemStack(ModBlocks.POCKET_BLOCK));
content.accept(new ItemStack(ModBlocks.FLETCHING_STAIRS_BLOCK));
});
entries.add(new ItemStack(ModItems.STEEL_ITEM));
entries.add(new ItemStack(ModItems.NEGATIVE_FLINT_ITEM));
entries.add(new ItemStack(ModItems.LETTER_ITEM));
entries.add(new ItemStack(ModItems.CHAINMAIL_ITEM));
ItemGroupEvents.modifyEntriesEvent(CreativeModeTabs.INGREDIENTS).register(content -> {
content.accept(new ItemStack(ModItems.STEEL_ITEM));
content.accept(new ItemStack(ModItems.NEGATIVE_FLINT_ITEM));
content.accept(new ItemStack(ModItems.LETTER_ITEM));
content.accept(new ItemStack(ModItems.CHAINMAIL_ITEM));
});
entries.add(new ItemStack(ModItems.DIRT_SWORD_ITEM));
entries.add(new ItemStack(ModItems.AK47_ITEM));
entries.add(new ItemStack(ModItems.HELMET_ON_A_STICK_ITEM));
}))
.build();
ItemGroupEvents.modifyEntriesEvent(CreativeModeTabs.COMBAT).register(content -> {
content.accept(new ItemStack(ModItems.DIRT_SWORD_ITEM));
content.accept(new ItemStack(ModItems.AK47_ITEM));
content.accept(new ItemStack(ModItems.HELMET_ON_A_STICK_ITEM));
});
ITEM_GROUP = Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, new ResourceLocation(MOD_ID, "nec"), ITEM_GROUP);
Registry.register(Registries.ITEM_GROUP, Identifier.of(MOD_ID, "nec"), NEC_GROUP);
}
}

View file

@ -0,0 +1,14 @@
{
"type": "minecraft:crafting_shapeless",
"ingredients": [
{
"item": "minecraft:bow"
},
{
"item": "minecraft:iron_ingot"
}
],
"result": {
"id": "nec:ak_47"
}
}

View file

@ -9,6 +9,6 @@
}
],
"result": {
"item": "minecraft:bedrock"
"id": "minecraft:bedrock"
}
}

View file

@ -12,7 +12,7 @@
"###"
],
"result": {
"item": "nec:blaze_block"
"id": "nec:blaze_block"
},
"show_notification": true
}

View file

@ -6,7 +6,7 @@
}
],
"result": {
"item": "minecraft:blaze_powder",
"id": "minecraft:blaze_powder",
"count": 9
}
}

View file

@ -9,7 +9,7 @@
}
],
"result": {
"item": "nec:chainmail",
"id": "nec:chainmail",
"count": 1
}
}

View file

@ -11,6 +11,6 @@
}
},
"result": {
"item": "minecraft:chainmail_boots"
"id": "minecraft:chainmail_boots"
}
}

View file

@ -11,6 +11,6 @@
}
},
"result": {
"item": "minecraft:chainmail_chestplate"
"id": "minecraft:chainmail_chestplate"
}
}

View file

@ -11,6 +11,6 @@
}
},
"result": {
"item": "minecraft:chainmail_helmet"
"id": "minecraft:chainmail_helmet"
}
}

View file

@ -11,6 +11,6 @@
}
},
"result": {
"item": "minecraft:chainmail_leggings"
"id": "minecraft:chainmail_leggings"
}
}

View file

@ -17,6 +17,6 @@
}
},
"result": {
"item": "minecraft:crossbow"
"id": "minecraft:crossbow"
}
}

View file

@ -14,6 +14,6 @@
}
},
"result": {
"item": "nec:deepslate_diamond_ore_ore"
"id": "nec:deepslate_diamond_ore_ore"
}
}

View file

@ -14,6 +14,6 @@
}
},
"result": {
"item": "minecraft:diamond_ore"
"id": "minecraft:diamond_ore"
}
}

View file

@ -14,6 +14,6 @@
}
},
"result": {
"item": "nec:diamond_ore_ore"
"id": "nec:diamond_ore_ore"
}
}

View file

@ -14,6 +14,6 @@
}
},
"result": {
"item": "nec:dirt_sword"
"id": "nec:dirt_sword"
}
}

View file

@ -11,7 +11,7 @@
}
},
"result": {
"item": "nec:fletching_stairs",
"id": "nec:fletching_stairs",
"count": 4
}
}

View file

@ -7,6 +7,6 @@
"item": "minecraft:gold_ingot"
},
"result": {
"item": "minecraft:golden_sword"
"id": "minecraft:golden_sword"
}
}

View file

@ -9,6 +9,6 @@
}
],
"result": {
"item": "nec:green_birch_log"
"id": "nec:green_birch_log"
}
}

View file

@ -12,7 +12,7 @@
"###"
],
"result": {
"item": "nec:gun_block"
"id": "nec:gun_block"
},
"show_notification": true
}

View file

@ -6,7 +6,7 @@
}
],
"result": {
"item": "minecraft:gunpowder",
"id": "minecraft:gunpowder",
"count": 9
}
}

View file

@ -7,7 +7,7 @@
}
],
"result": {
"item": "nec:java_block"
"id": "nec:java_block"
},
"show_notification": true
}

View file

@ -14,7 +14,7 @@
}
},
"result": {
"item": "nec:letter",
"id": "nec:letter",
"count": 8
}
}

View file

@ -15,7 +15,7 @@
"222"
],
"result": {
"item": "minecraft:netherite_chestplate"
"id": "minecraft:netherite_chestplate"
},
"show_notification": true
}

View file

@ -7,7 +7,7 @@
}
],
"result": {
"item": "nec:pocket_block"
"id": "nec:pocket_block"
},
"show_notification": true
}

View file

@ -9,6 +9,6 @@
}
],
"result": {
"item": "minecraft:skeleton_skull"
"id": "minecraft:skeleton_skull"
}
}

View file

@ -9,6 +9,6 @@
}
],
"result": {
"item": "nec:steel"
"id": "nec:steel"
}
}

View file

@ -17,6 +17,6 @@
}
},
"result": {
"item": "minecraft:stone_sword"
"id": "minecraft:stone_sword"
}
}

View file

@ -9,6 +9,6 @@
}
],
"result": {
"item": "minecraft:zombie_spawn_egg"
"id": "minecraft:zombie_spawn_egg"
}
}

View file

@ -1,12 +0,0 @@
{
"type": "minecraft:smithing",
"base": {
"item": "minecraft:bow"
},
"addition": {
"item": "minecraft:iron_ingot"
},
"result": {
"item": "nec:ak_47"
}
}

View file

@ -19,6 +19,9 @@
"environment": "*",
"entrypoints": {
"fabric-datagen": [
"me.jonasjones.nec.datagen.NecDataGen"
],
"main": [
"me.jonasjones.nec.NotEnoughCursedness"
]

View file

@ -2,12 +2,9 @@
"required": true,
"minVersion": "0.8",
"package": "me.jonasjones.nec.mixin",
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "JAVA_21",
"mixins": [
],
"client": [
"ExampleMixin"
],
"injectors": {
"defaultRequire": 1
}