Initial mod implementation and first block #2

Merged
BlakeRain merged 2 commits from BlakeRain/utamacraft:main into main 2023-11-26 11:15:11 +00:00
18 changed files with 317 additions and 163 deletions
Showing only changes of commit 0ea1beb437 - Show all commits

1
.gitignore vendored
View File

@ -68,6 +68,7 @@ out
# Gradle
build
.gradle
run
# Whitelist the gradle wrapper
!gradle-wrapper.jar

View File

@ -2,11 +2,10 @@ plugins {
id 'eclipse'
id 'maven-publish'
id 'net.minecraftforge.gradle' version '5.1.+'
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
}
version = '0.0.1-1.19.2'
group = 'com.banutama.utamacraft' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
version = '0.0.1-1.19'
group = 'net.banutama.utamacraft' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'utamacraft'
// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
@ -27,9 +26,9 @@ 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: 'parchment', version: '2022.12.18-1.19.3'
mappings channel: 'official', version: '1.19'
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default.
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default.
// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
@ -117,40 +116,20 @@ minecraft {
sourceSets.main.resources { srcDir 'src/generated/resources' }
repositories {
maven {
// location of the maven that hosts JEI files
name = "Progwml6 maven"
url = "https://dvs1.progwml6.com/files/maven/"
}
maven {
// location of a maven mirror for JEI files, as a fallback
name = "ModMaven"
url = "https://modmaven.dev"
}
maven {
url "https://cursemaven.com"
content {
includeGroup "curse.maven"
}
}
maven { url 'https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/' }
// Put repositories for dependencies here
// ForgeGradle automatically adds the Forge maven and Maven Central for you
// If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
// flatDir {
// dir 'libs'
// }
}
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.19.3-44.1.5'
// compile against the JEI API but do not include it at runtime
// compileOnly(fg.deobf("mezz.jei:jei-${mc_version}-common-api:${jei_version}"))
// compileOnly(fg.deobf("mezz.jei:jei-${mc_version}-forge-api:${jei_version}"))
// at runtime, use the full JEI jar for Forge
// runtimeOnly(fg.deobf("mezz.jei:jei-${mc_version}-forge:${jei_version}"))
// runtimeOnly fg.deobf("curse.maven:mekanism-268560:3922056")
implementation fg.deobf('software.bernie.geckolib:geckolib-forge-1.19.3:4.0.3')
minecraft 'net.minecraftforge:forge:1.19.2-43.3.5'
// 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
@ -170,11 +149,11 @@ jar {
manifest {
attributes([
"Specification-Title" : "utamacraft",
"Specification-Vendor" : "Utamacraft Developers",
"Specification-Vendor" : "BanUtama",
"Specification-Version" : "1", // We are version 1 of ourselves
"Implementation-Title" : project.name,
"Implementation-Version" : project.jar.archiveVersion,
"Implementation-Vendor" : "Utamacraft Developers",
"Implementation-Vendor" : "BanUtama",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
@ -201,4 +180,4 @@ publishing {
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}
}

View File

@ -1,7 +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
mc_version=1.19.2
jei_version=11.2.0.247
org.gradle.daemon=false

Binary file not shown.

View File

@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStorePath=wrapper/dists

2
gradlew vendored
View File

@ -231,4 +231,4 @@ eval "set -- $(
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
exec "$JAVACMD" "$@"

89
gradlew.bat vendored Normal file
View File

@ -0,0 +1,89 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "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.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
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.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@ -2,6 +2,5 @@ pluginManagement {
repositories {
gradlePluginPortal()
maven { url = 'https://maven.minecraftforge.net/' }
maven { url = 'https://maven.parchmentmc.org' }
}
}

View File

@ -1,52 +1,45 @@
package net.banutama.utamacraft;
import java.util.function.Supplier;
import com.mojang.logging.LogUtils;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import net.banutama.utamacraft.item.ModItems;
import net.banutama.utamacraft.block.ModBlocks;
import net.banutama.utamacraft.block.EtherealGlass;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
/**
* Main mod class.
*/
@Mod(Utamacraft.ID)
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, modid = Utamacraft.ID)
import org.slf4j.Logger;
// The value here should match an entry in the META-INF/mods.toml file
@Mod(Utamacraft.MOD_ID)
public class Utamacraft {
public static final String ID = "utamacraft";
public static final Logger LOGGER = LogManager.getLogger(ID);
public static final String MOD_ID = "utamacraft";
private static final Logger LOGGER = LogUtils.getLogger();
public Utamacraft() {
LOGGER.log(Level.INFO, "Utamacraft initialising");
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
ITEMS.register(bus);
BLOCKS.register(bus);
}
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, ID);
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ID);
// Very Important Comment
public Utamacraft() {
LOGGER.info("Utamacraft initializing");
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
static {
registerBlock("ethereal_glass", EtherealGlass::new);
}
ModItems.register(bus);
ModBlocks.register(bus);
private static <T extends Block> void registerBlock(String name, Supplier<T> block) {
RegistryObject<T> registered_block = BLOCKS.register(name, block);
registerBlockItem(name, registered_block);
}
bus.addListener(this::commonSetup);
MinecraftForge.EVENT_BUS.register(this);
}
private static <T extends Block> void registerBlockItem(String name, RegistryObject<T> block) {
ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties()));
}
private void commonSetup(final FMLCommonSetupEvent event) {
}
@Mod.EventBusSubscriber(modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public static class ClientModEvents {
@SubscribeEvent
public static void onClientSetup(FMLClientSetupEvent event) {
}
}
}

View File

@ -1,16 +1,8 @@
package net.banutama.utamacraft.block;
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
@ -25,39 +17,32 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import org.jetbrains.annotations.NotNull;
public class EtherealGlass extends GlassBlock {
public EtherealGlass() {
super(buildProperties());
}
private static Block.Properties buildProperties() {
return Block.Properties.copy(Blocks.GLASS)
.isValidSpawn(EtherealGlass::neverAllowSpawn)
.isRedstoneConductor(EtherealGlass::notSolid)
.isSuffocating(EtherealGlass::notSolid)
.isViewBlocking(EtherealGlass::notSolid);
}
private static Boolean neverAllowSpawn(BlockState state, BlockGetter reader, BlockPos pos, EntityType<?> entity) {
return false;
}
private static Boolean notSolid(BlockState state, BlockGetter getter, BlockPos pos) {
return false;
}
@Override
public @NotNull VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
if (context instanceof EntityCollisionContext && ((EntityCollisionContext)context).getEntity() instanceof Player) {
return Shapes.empty();
} else {
return state.getShape(world, pos);
public EtherealGlass() {
super(getProperties());
}
}
@Override
@OnlyIn(Dist.CLIENT)
public void appendHoverText(ItemStack stack, @Nullable BlockGetter worldIn, List<Component> tooltip, TooltipFlag flagIn) {
super.appendHoverText(stack, worldIn, tooltip, flagIn);
tooltip.add(Component.translatable("tooltip.utamacraft.ethereal_glass").withStyle(ChatFormatting.GRAY));
}
private static Block.Properties getProperties() {
return Block.Properties.copy(Blocks.GLASS)
.isValidSpawn(EtherealGlass::blockSpawning)
.isRedstoneConductor(EtherealGlass::notSolid)
.isSuffocating(EtherealGlass::notSolid)
.isViewBlocking(EtherealGlass::notSolid);
}
@Override
public @NotNull VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
if (context instanceof EntityCollisionContext && ((EntityCollisionContext)context).getEntity() instanceof Player) {
return Shapes.empty();
} else {
return state.getShape(world, pos);
}
}
private static Boolean blockSpawning(BlockState state, BlockGetter reader, BlockPos pos, EntityType<?> entity) {
return false;
}
private static Boolean notSolid(BlockState state, BlockGetter reader, BlockPos pos) {
return false;
}
}

View File

@ -0,0 +1,36 @@
package net.banutama.utamacraft.block;
import java.util.function.Supplier;
import net.banutama.utamacraft.Utamacraft;
import net.banutama.utamacraft.item.ModItems;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
public class ModBlocks {
public static final DeferredRegister<Block> BLOCKS =
DeferredRegister.create(ForgeRegistries.BLOCKS, Utamacraft.MOD_ID);
public static final RegistryObject<Block> ETHEREAL_GLASS =
registerBlock("ethereal_glass", () -> new EtherealGlass());
private static <T extends Block> RegistryObject<T> registerBlock(String name, Supplier<T> block) {
RegistryObject<T> registered_block = BLOCKS.register(name, block);
registerBlockItem(name, registered_block);
return registered_block;
}
private static <T extends Block> void registerBlockItem(String name, RegistryObject<T> block) {
ModItems.ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties()));
}
public static void register(IEventBus bus) {
BLOCKS.register(bus);
}
}

View File

@ -0,0 +1,14 @@
package net.banutama.utamacraft.item;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.NotNull;
public class ModCreativeModeTab {
// public static final CreativeModeTab TUTORIAL_TAB = new CreativeModeTab("tutorialtab") {
// @Override
// public @NotNull ItemStack makeIcon() {
// return new ItemStack(ModItems.ZIRCON.get());
// }
// };
}

View File

@ -0,0 +1,17 @@
package net.banutama.utamacraft.item;
import net.banutama.utamacraft.Utamacraft;
import net.minecraft.world.item.Item;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
public class ModItems {
public static final DeferredRegister<Item> ITEMS =
DeferredRegister.create(ForgeRegistries.ITEMS, Utamacraft.MOD_ID);
public static void register(IEventBus eventBus) {
ITEMS.register(eventBus);
}
}

View File

@ -0,0 +1,70 @@
# This is an example mods.toml file. It contains the data relating to the loading mods.
# There are several mandatory fields (#mandatory), and many more that are optional (#optional).
# The overall format is standard TOML format, v0.5.0.
# Note that there are a couple of TOML lists in this file.
# Find more information on toml format here: https://github.com/toml-lang/toml
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
modLoader="javafml" #mandatory
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
loaderVersion="[41,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
license="MIT License"
# A URL to refer people to when problems occur with this mod
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
# A list of mods - how many allowed here is determined by the individual mod loader
[[mods]] #mandatory
# The modid of the mod
modId="utamacraft" #mandatory
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
# ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata
# see the associated build.gradle script for how to populate this completely automatically during a build
version="0.0.1-1.19" #mandatory
# A display name for the mod
displayName="Utamacraft Mod" #mandatory
# A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional
# A URL for the "homepage" for this mod, displayed in the mod UI
#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional
# A file name (in the root of the mod JAR) containing a logo for display
logoFile="utamacraft.png" #optional
# A text field displayed in the mod UI
credits="Thanks for this example mod goes to Java" #optional
# A text field displayed in the mod UI
authors="Kaupenjoe" #optional
# Display Test controls the display for your mod in the server connection screen
# MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod.
# IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod.
# IGNORE_ALL_VERSION means that your mod will not cause a red X if it's present on the client or the server. This is a special case and should only be used if your mod has no server component.
# NONE means that no display test is set on your mod. You need to do this yourself, see IExtensionPoint.DisplayTest for more information. You can define any scheme you wish with this value.
# IMPORTANT NOTE: this is NOT an instruction as to which environments (CLIENT or DEDICATED SERVER) your mod loads on. Your mod should load (and maybe do nothing!) whereever it finds itself.
#displayTest="MATCH_VERSION" # MATCH_VERSION is the default if nothing is specified (#optional)
# The description text for the mod (multi line!) (#mandatory)
description='''
This is a long form description of the mod. You can write whatever you want here
Have some lorem ipsum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed mollis lacinia magna. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed sagittis luctus odio eu tempus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Pellentesque volutpat ligula eget lacus auctor sagittis. In hac habitasse platea dictumst. Nunc gravida elit vitae sem vehicula efficitur. Donec mattis ipsum et arcu lobortis, eleifend sagittis sem rutrum. Cras pharetra quam eget posuere fermentum. Sed id tincidunt justo. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
'''
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
[[dependencies.utamacraft]] #optional
# the modid of the dependency
modId="forge" #mandatory
# Does this dependency have to exist - if not, ordering below must be specified
mandatory=true #mandatory
# The version range of the dependency
versionRange="[41,)" #mandatory
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
ordering="NONE"
# Side this dependency is applied on - BOTH, CLIENT or SERVER
side="BOTH"
# Here's another dependency
[[dependencies.utamacraft]]
modId="minecraft"
mandatory=true
# This version range declares a minimum of the current minecraft version up to but not including the next major version
versionRange="[1.19,1.20)"
ordering="NONE"
side="BOTH"

View File

@ -1,30 +0,0 @@
# Make sure this is set to "kotlinforforge"
modLoader="kotlinforforge"
# Make sure this is set to the appropriate version range
loaderVersion="[3,)" # Require at least 3.x
# License is REQUIRED after 1.16
license='BSD-3-Clause'
[[mods]]
modId="utamacraft"
version="${file.jarVersion}"
displayName="Utamacraft"
credits="The Utamacraft contributors"
authors="Blake Rain <blake.rain@blakerain.com>"
description='''
Mod for Ban's Minecraft Server
'''
[[dependencies.utamacraft]]
modId="forge"
mandatory=true
versionRange="[41,)"
ordering="NONE"
side="BOTH"
[[dependencies.utamacraft]]
modId="minecraft"
mandatory=true
versionRange="[1.19,1.20)"
ordering="NONE"
side="BOTH"

View File

@ -2,6 +2,6 @@
"parent": "block/cube_all",
"render_type": "translucent",
"textures": {
"all": "utamacraft:block/glass_ethereal"
"all": "utamacraft:block/ethereal_glass"
}
}

View File

@ -1,15 +1,20 @@
{
"type": "minecraft:crafting_shapeless",
"group": "utamacraft_ethereal_glass",
"ingredients": [
{ "item": "minecraft:glass" },
{ "item": "minecraft:glass" },
{ "item": "minecraft:glass" },
{ "item": "minecraft:glass" },
{ "item": "minecraft.blaze_powder" }
"type": "minecraft:crafting_shaped",
"pattern": [
"###",
"#.#",
"###"
],
"key": {
"#": {
"item": "minecraft:glass"
},
".": {
"item": "minecraft:blaze_powder"
}
},
"result": {
"item": "utamacraft:ethereal_glass",
"count": 4
"count": 8
}
}

View File

@ -6,4 +6,3 @@
"forge:data_pack_format": 10
}
}