Jump to content

than00ber1

Members
  • Posts

    34
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by than00ber1

  1.  Hi there

    I am attempting to make a gui where the player will be able to click whatever block is in front of them.

    I've tried a few approaches and none of them have worked. (Bare with me as I have absolutely zero knowledge in 3D rendering.)

     

    I've looked online for a bit and found this on stackoverflow using OpenGL.

    Here is my 1:1 attempt in Java on my container screen:

        @Override
        public void render(@NotNull PoseStack pose, int mouseX, int mouseY, float partialTick) {
            // https://stackoverflow.com/a/7702895/13844398
            // STEP 1: get mouse coords. (mouseX, mouseY)
            
            // STEP 2
            Matrix4f modelviewMatrix = RenderSystem.getModelViewMatrix();
            Matrix4f projectionMatrix = RenderSystem.getProjectionMatrix();
    
            // STEP 3
            modelviewMatrix.multiply(projectionMatrix);
    
            // STEP 4
            modelviewMatrix.invert();
    
            // STEP 5
            float x = Mth.clampedMap(mouseX, 0.0F, width, -1.0F, 1.0F);
            float y = Mth.clampedMap(mouseY, 0.0F, height, -1.0F, 1.0F);
            float z = 1.0F; // the depth value ?
            float w = 1.0F;
    
            Vector4f vector4f = new Vector4f(x, y, z, w);
    
            // STEP 6
            vector4f.transform(modelviewMatrix);
    
            // STEP 7
            vector4f.mul(1 / vector4f.w());
    
            // presumably results in a direction vector ??
            Vec3 vec3 = new Vec3(vector4f.x(), vector4f.y(), vector4f.z());
    
            getMinecraft().font.draw(pose, vec3.toString(), 10.0F, 10.0F, 14737632);
        }

    My screen prints something that resembles this: (239.75..., 126.00..., -2003000.125). Which simply looks like my cursor's coordinates (with an extra`z` value) on screen an nothing more.

     

    Am I heading towards the right direction? Is there an easier way?

  2. I downloaded forge's 1.18.1 MDK (39.1.0) and let IntelliJ handle all the preliminary steps needed before running runClient (like I usually do) but get greeted by this error:

    java.lang.reflect.InvocationTargetException

    followed by:

    Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.mojang.blaze3d.systems.RenderSystem

     

    I am not sure what causes this. I have also tried the latest 1.18.1 MDK release (39.1.2) and get the same problem.

     

    Not sure if this info is needed but the project's SDK (and the gradle JVM) is set to Java 17.0.2.

     

    Heres the full log:

    ...
    Copying local object: ee/eed3b961158ebeae781e6c737ee55a1f5e8f6c9d Asset: realms/textures/gui/images/5.png
    Copying local object: a4/a449a2395b194c67b17ce2cba15b1e2958130f11 Asset: realms/textures/gui/images/8.png
    
    > Task :downloadAssets
    Downloading: https://launchermeta.mojang.com/v1/packages/7fcda714d4a391a711ce434fa1dbbebe73ecf179/1.18.json
    
    > Task :extractNatives
    Downloading: https://libraries.minecraft.net/org/lwjgl/lwjgl/3.2.1/lwjgl-3.2.1-natives-macos.jar
    Downloading: https://libraries.minecraft.net/org/lwjgl/lwjgl-jemalloc/3.2.1/lwjgl-jemalloc-3.2.1-natives-macos.jar
    Downloading: https://libraries.minecraft.net/org/lwjgl/lwjgl-openal/3.2.1/lwjgl-openal-3.2.1-natives-macos.jar
    Downloading: https://libraries.minecraft.net/org/lwjgl/lwjgl-opengl/3.2.1/lwjgl-opengl-3.2.1-natives-macos.jar
    Downloading: https://libraries.minecraft.net/org/lwjgl/lwjgl-glfw/3.2.1/lwjgl-glfw-3.2.1-natives-macos.jar
    Downloading: https://libraries.minecraft.net/org/lwjgl/lwjgl-stb/3.2.1/lwjgl-stb-3.2.1-natives-macos.jar
    Downloading: https://libraries.minecraft.net/org/lwjgl/lwjgl-tinyfd/3.2.1/lwjgl-tinyfd-3.2.1-natives-macos.jar
    Downloading: https://libraries.minecraft.net/ca/weblite/java-objc-bridge/1.0.0/java-objc-bridge-1.0.0-natives-osx.jar
    
    > Task :makeSrcDirs
    > Task :prepareRuns
    > Task :prepareRunClient
    
    > Task :runClient
    2022-04-19 23:18:08,806 main WARN Advanced terminal features are not available in this environment
    [23:18:08] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher running: args [--launchTarget, forgeclientuserdev, --version, MOD_DEV, --assetIndex, 1.18, --assetsDir, /Users/noahgreff/.gradle/caches/forge_gradle/assets, --gameDir, ., --fml.forgeVersion, 39.1.2, --fml.mcVersion, 1.18.1, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20211210.034407]
    [23:18:08] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher 9.1.3+9.1.3+main.9b69c82a starting: java version 17.0.2 by Oracle Corporation
    [23:18:08] [main/DEBUG] [cp.mo.mo.LaunchServiceHandler/MODLAUNCHER]: Found launch services [fmlclientdev,forgeclient,minecraft,forgegametestserverdev,fmlserveruserdev,fmlclient,fmldatauserdev,forgeserverdev,forgeserveruserdev,forgeclientdev,forgeclientuserdev,forgeserver,forgedatadev,fmlserver,fmlclientuserdev,fmlserverdev,forgedatauserdev,testharness,forgegametestserveruserdev]
    [23:18:08] [main/DEBUG] [cp.mo.mo.NameMappingServiceHandler/MODLAUNCHER]: Found naming services : [srgtomcp]
    [23:18:08] [main/DEBUG] [cp.mo.mo.LaunchPluginHandler/MODLAUNCHER]: Found launch plugins: [mixin,eventbus,object_holder_definalize,runtime_enum_extender,capability_token_subclass,accesstransformer,runtimedistcleaner]
    [23:18:08] [main/DEBUG] [cp.mo.mo.TransformationServicesHandler/MODLAUNCHER]: Discovering transformation services
    [23:18:08] [main/DEBUG] [cp.mo.mo.TransformationServicesHandler/MODLAUNCHER]: Found additional transformation services from discovery services: java.util.stream.ReferencePipeline$3@241e8ea6
    [23:18:08] [main/DEBUG] [cp.mo.mo.TransformationServicesHandler/MODLAUNCHER]: Found transformer services : [mixin,fml]
    [23:18:08] [main/DEBUG] [cp.mo.mo.TransformationServicesHandler/MODLAUNCHER]: Transformation services loading
    [23:18:08] [main/DEBUG] [cp.mo.mo.TransformationServiceDecorator/MODLAUNCHER]: Loading service mixin
    [23:18:08] [main/DEBUG] [cp.mo.mo.TransformationServiceDecorator/MODLAUNCHER]: Loaded service mixin
    [23:18:08] [main/DEBUG] [cp.mo.mo.TransformationServiceDecorator/MODLAUNCHER]: Loading service fml
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.LauncherVersion/CORE]: Found FMLLauncher version 1.0
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.FMLLoader/CORE]: FML 1.0 loading
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.FMLLoader/CORE]: FML found ModLauncher version : 9.1.3+9.1.3+main.9b69c82a
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.FMLLoader/CORE]: FML found AccessTransformer version : 8.0.4+66+master.c09db6d7
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.FMLLoader/CORE]: FML found EventBus version : 5.0.7+5.0.7+master.6d3407cc
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.FMLLoader/CORE]: Found Runtime Dist Cleaner
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.FMLLoader/CORE]: FML found CoreMod version : 5.0.2+5.0.2+master.303343f8
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.FMLLoader/CORE]: Found ForgeSPI package implementation version 4.0.11+4.0.11+master.ce88bbba
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.FMLLoader/CORE]: Found ForgeSPI package specification 4
    [23:18:08] [main/DEBUG] [cp.mo.mo.TransformationServiceDecorator/MODLAUNCHER]: Loaded service fml
    [23:18:08] [main/DEBUG] [cp.mo.mo.TransformationServicesHandler/MODLAUNCHER]: Configuring option handling for services
    [23:18:08] [main/DEBUG] [cp.mo.mo.TransformationServicesHandler/MODLAUNCHER]: Transformation services initializing
    [23:18:08] [main/DEBUG] [cp.mo.mo.TransformationServiceDecorator/MODLAUNCHER]: Initializing transformation service mixin
    [23:18:08] [main/DEBUG] [mixin/]: MixinService [ModLauncher] was successfully booted in cpw.mods.cl.ModuleClassLoader@e720b71
    [23:18:08] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.5 Source=union:/Users/noahgreff/.gradle/caches/modules-2/files-2.1/org.spongepowered/mixin/0.8.5/9d1c0c3a304ae6697ecd477218fa61b850bf57fc/mixin-0.8.5.jar%2327!/ Service=ModLauncher Env=CLIENT
    [23:18:08] [main/DEBUG] [mixin/]: Initialising Mixin Platform Manager
    [23:18:08] [main/DEBUG] [mixin/]: Adding mixin platform agents for container ModLauncher Root Container(ModLauncher:4f56a0a2)
    [23:18:08] [main/DEBUG] [mixin/]: Instancing new MixinPlatformAgentMinecraftForge for ModLauncher Root Container(ModLauncher:4f56a0a2)
    [23:18:08] [main/DEBUG] [mixin/]: MixinPlatformAgentMinecraftForge rejected container ModLauncher Root Container(ModLauncher:4f56a0a2)
    [23:18:08] [main/DEBUG] [mixin/]: Instancing new MixinPlatformAgentDefault for ModLauncher Root Container(ModLauncher:4f56a0a2)
    [23:18:08] [main/DEBUG] [mixin/]: MixinPlatformAgentDefault accepted container ModLauncher Root Container(ModLauncher:4f56a0a2)
    [23:18:08] [main/DEBUG] [cp.mo.mo.TransformationServiceDecorator/MODLAUNCHER]: Initialized transformation service mixin
    [23:18:08] [main/DEBUG] [cp.mo.mo.TransformationServiceDecorator/MODLAUNCHER]: Initializing transformation service fml
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.FMLServiceProvider/CORE]: Setting up basic FML game directories
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.FileUtils/CORE]: Found existing GAMEDIR directory : /Users/noahgreff/Desktop/forge-1.18.1-39.1.2-mdk/run
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.FMLPaths/CORE]: Path GAMEDIR is /Users/noahgreff/Desktop/forge-1.18.1-39.1.2-mdk/run
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.FileUtils/CORE]: Making MODSDIR directory : /Users/noahgreff/Desktop/forge-1.18.1-39.1.2-mdk/run/mods
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.FileUtils/CORE]: Created MODSDIR directory : /Users/noahgreff/Desktop/forge-1.18.1-39.1.2-mdk/run/mods
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.FMLPaths/CORE]: Path MODSDIR is /Users/noahgreff/Desktop/forge-1.18.1-39.1.2-mdk/run/mods
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.FileUtils/CORE]: Making CONFIGDIR directory : /Users/noahgreff/Desktop/forge-1.18.1-39.1.2-mdk/run/config
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.FileUtils/CORE]: Created CONFIGDIR directory : /Users/noahgreff/Desktop/forge-1.18.1-39.1.2-mdk/run/config
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.FMLPaths/CORE]: Path CONFIGDIR is /Users/noahgreff/Desktop/forge-1.18.1-39.1.2-mdk/run/config
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.FMLPaths/CORE]: Path FMLCONFIG is /Users/noahgreff/Desktop/forge-1.18.1-39.1.2-mdk/run/config/fml.toml
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.FMLServiceProvider/CORE]: Loading configuration
    [23:18:08] [main/WARN] [ne.mi.fm.lo.FMLConfig/CORE]: Configuration file /Users/noahgreff/Desktop/forge-1.18.1-39.1.2-mdk/run/config/fml.toml is not correct. Correcting
    [23:18:08] [main/WARN] [ne.mi.fm.lo.FMLConfig/CORE]: Incorrect key [defaultConfigPath] was corrected from null to defaultconfigs
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.FileUtils/CORE]: Making default config directory directory : /Users/noahgreff/Desktop/forge-1.18.1-39.1.2-mdk/run/defaultconfigs
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.FileUtils/CORE]: Created default config directory directory : /Users/noahgreff/Desktop/forge-1.18.1-39.1.2-mdk/run/defaultconfigs
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.FMLServiceProvider/CORE]: Preparing ModFile
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.FMLServiceProvider/CORE]: Preparing launch handler
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.FMLLoader/CORE]: Using forgeclientuserdev as launch service
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.FMLLoader/CORE]: Received command line version data  : VersionInfo[forgeVersion=39.1.2, mcVersion=1.18.1, mcpVersion=20211210.034407, forgeGroup=net.minecraftforge]
    [23:18:08] [main/DEBUG] [cp.mo.mo.TransformationServiceDecorator/MODLAUNCHER]: Initialized transformation service fml
    [23:18:08] [main/DEBUG] [cp.mo.mo.NameMappingServiceHandler/MODLAUNCHER]: Current naming domain is 'mcp'
    [23:18:08] [main/DEBUG] [cp.mo.mo.NameMappingServiceHandler/MODLAUNCHER]: Identified name mapping providers {srg=srgtomcp:1234}
    [23:18:08] [main/DEBUG] [cp.mo.mo.TransformationServicesHandler/MODLAUNCHER]: Transformation services begin scanning
    [23:18:08] [main/DEBUG] [cp.mo.mo.TransformationServiceDecorator/MODLAUNCHER]: Beginning scan trigger - transformation service mixin
    [23:18:08] [main/DEBUG] [cp.mo.mo.TransformationServiceDecorator/MODLAUNCHER]: End scan trigger - transformation service mixin
    [23:18:08] [main/DEBUG] [cp.mo.mo.TransformationServiceDecorator/MODLAUNCHER]: Beginning scan trigger - transformation service fml
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.FMLServiceProvider/CORE]: Initiating mod scan
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.mo.ModListHandler/CORE]: Found mod coordinates from lists: []
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.mo.ModDiscoverer/CORE]: Found Mod Locators : (mods folder:null),(maven libs:null),(exploded directory:null),(minecraft:null),(userdev classpath:null)
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.ta.CommonLaunchHandler/CORE]: Got mod coordinates examplemod%%/Users/noahgreff/Desktop/forge-1.18.1-39.1.2-mdk/build/resources/main:examplemod%%/Users/noahgreff/Desktop/forge-1.18.1-39.1.2-mdk/build/classes/java/main from env
    [23:18:08] [main/DEBUG] [ne.mi.fm.lo.ta.CommonLaunchHandler/CORE]: Found supplied mod coordinates [{examplemod=[/Users/noahgreff/Desktop/forge-1.18.1-39.1.2-mdk/build/resources/main, /Users/noahgreff/Desktop/forge-1.18.1-39.1.2-mdk/build/classes/java/main]}]
    [23:18:09] [main/DEBUG] [ne.mi.fm.lo.mo.ModFileInfo/LOADING]: Found valid mod file forge-1.18.1-39.1.2_mapped_official_1.18.1-recomp.jar with {minecraft} mods - versions {1.18.1}
    [23:18:09] [main/DEBUG] [ne.mi.fm.lo.mo.ModFile/LOADING]: Loading mod file /Users/noahgreff/.gradle/caches/forge_gradle/minecraft_user_repo/net/minecraftforge/forge/1.18.1-39.1.2_mapped_official_1.18.1/forge-1.18.1-39.1.2_mapped_official_1.18.1-recomp.jar with languages [LanguageSpec[languageName=minecraft, acceptedVersions=1]]
    [23:18:09] [main/DEBUG] [ne.mi.fm.lo.mo.ModFileParser/LOADING]: Considering mod file candidate /Users/noahgreff/Desktop/forge-1.18.1-39.1.2-mdk/build/resources/main
    [23:18:09] [main/DEBUG] [ne.mi.fm.lo.mo.ModFileInfo/LOADING]: Found valid mod file main with {examplemod} mods - versions {0.0NONE}
    [23:18:09] [main/DEBUG] [ne.mi.fm.lo.mo.ModFile/LOADING]: Loading mod file /Users/noahgreff/Desktop/forge-1.18.1-39.1.2-mdk/build/resources/main with languages [LanguageSpec[languageName=javafml, acceptedVersions=[39,)]]
    [23:18:09] [main/DEBUG] [ne.mi.fm.lo.mo.ModFileParser/LOADING]: Considering mod file candidate /
    [23:18:09] [main/DEBUG] [ne.mi.fm.lo.mo.ModFileInfo/LOADING]: Found valid mod file  with {forge} mods - versions {39.1.2}
    [23:18:09] [main/DEBUG] [ne.mi.fm.lo.mo.ModFile/LOADING]: Loading mod file / with languages [LanguageSpec[languageName=javafml, acceptedVersions=[24,]]]
    [23:18:09] [main/DEBUG] [ne.mi.fm.lo.mo.ModFileParser/LOADING]: Found coremod field_to_method with Javascript path coremods/field_to_method.js
    [23:18:09] [main/DEBUG] [ne.mi.fm.lo.mo.ModFileParser/LOADING]: Found coremod field_to_instanceof with Javascript path coremods/field_to_instanceof.js
    [23:18:09] [main/DEBUG] [ne.mi.fm.lo.mo.ModFileParser/LOADING]: Found coremod add_bouncer_method with Javascript path coremods/add_bouncer_method.js
    [23:18:09] [main/DEBUG] [ne.mi.fm.lo.mo.ModFile/LOADING]: Found coremod coremods/field_to_method.js
    [23:18:09] [main/DEBUG] [ne.mi.fm.lo.mo.ModFile/LOADING]: Found coremod coremods/field_to_instanceof.js
    [23:18:09] [main/DEBUG] [ne.mi.fm.lo.mo.ModFile/LOADING]: Found coremod coremods/add_bouncer_method.js
    [23:18:09] [main/DEBUG] [cp.mo.mo.TransformationServiceDecorator/MODLAUNCHER]: End scan trigger - transformation service fml
    [23:18:09] [main/DEBUG] [ne.mi.fm.lo.LanguageLoadingProvider/CORE]: Found 2 language providers
    [23:18:09] [main/DEBUG] [ne.mi.fm.lo.LanguageLoadingProvider/CORE]: Found language provider minecraft, version 1.0
    [23:18:09] [main/DEBUG] [ne.mi.fm.lo.LanguageLoadingProvider/CORE]: Found language provider javafml, version 39
    [23:18:09] [main/DEBUG] [ne.mi.fm.lo.ModSorter/LOADING]: Found 2 mod requirements (2 mandatory, 0 optional)
    [23:18:09] [main/DEBUG] [ne.mi.fm.lo.ModSorter/LOADING]: Found 0 mod requirements missing (0 mandatory, 0 optional)
    [23:18:09] [main/DEBUG] [ne.mi.fm.lo.MCPNamingService/CORE]: Loaded 27879 method mappings from methods.csv
    [23:18:09] [main/DEBUG] [ne.mi.fm.lo.MCPNamingService/CORE]: Loaded 26641 field mappings from fields.csv
    [23:18:09] [main/DEBUG] [cp.mo.mo.TransformationServicesHandler/MODLAUNCHER]: Transformation services loading transformers
    [23:18:09] [main/DEBUG] [cp.mo.mo.TransformationServiceDecorator/MODLAUNCHER]: Initializing transformers for transformation service mixin
    [23:18:09] [main/DEBUG] [cp.mo.mo.TransformationServiceDecorator/MODLAUNCHER]: Initialized transformers for transformation service mixin
    [23:18:09] [main/DEBUG] [cp.mo.mo.TransformationServiceDecorator/MODLAUNCHER]: Initializing transformers for transformation service fml
    [23:18:09] [main/DEBUG] [ne.mi.fm.lo.FMLServiceProvider/CORE]: Loading coremod transformers
    [23:18:09] [main/DEBUG] [ne.mi.co.CoreModEngine/COREMOD]: Loading CoreMod from coremods/field_to_method.js
    [23:18:09] [main/DEBUG] [ne.mi.co.CoreModEngine/COREMOD]: CoreMod loaded successfully
    [23:18:09] [main/DEBUG] [ne.mi.co.CoreModEngine/COREMOD]: Loading CoreMod from coremods/field_to_instanceof.js
    [23:18:09] [main/DEBUG] [ne.mi.co.CoreModEngine/COREMOD]: CoreMod loaded successfully
    [23:18:09] [main/DEBUG] [ne.mi.co.CoreModEngine/COREMOD]: Loading CoreMod from coremods/add_bouncer_method.js
    [23:18:09] [main/DEBUG] [ne.mi.co.CoreModEngine/COREMOD]: CoreMod loaded successfully
    [23:18:09] [main/DEBUG] [cp.mo.mo.TransformStore/MODLAUNCHER]: Adding transformer net.minecraftforge.coremod.transformer.CoreModClassTransformer@53ed09e8 to Target : CLASS {Lnet/minecraft/world/effect/MobEffectInstance;} {} {V}
    [23:18:09] [main/DEBUG] [cp.mo.mo.TransformStore/MODLAUNCHER]: Adding transformer net.minecraftforge.coremod.transformer.CoreModClassTransformer@10bea4 to Target : CLASS {Lnet/minecraft/world/level/block/LiquidBlock;} {} {V}
    [23:18:09] [main/DEBUG] [cp.mo.mo.TransformStore/MODLAUNCHER]: Adding transformer net.minecraftforge.coremod.transformer.CoreModClassTransformer@7e2c64 to Target : CLASS {Lnet/minecraft/world/item/BucketItem;} {} {V}
    [23:18:09] [main/DEBUG] [cp.mo.mo.TransformStore/MODLAUNCHER]: Adding transformer net.minecraftforge.coremod.transformer.CoreModClassTransformer@7c1e32c9 to Target : CLASS {Lnet/minecraft/world/level/block/StairBlock;} {} {V}
    [23:18:09] [main/DEBUG] [cp.mo.mo.TransformStore/MODLAUNCHER]: Adding transformer net.minecraftforge.coremod.transformer.CoreModClassTransformer@383864d5 to Target : CLASS {Lnet/minecraft/world/level/block/FlowerPotBlock;} {} {V}
    [23:18:09] [main/DEBUG] [cp.mo.mo.TransformStore/MODLAUNCHER]: Adding transformer net.minecraftforge.coremod.transformer.CoreModClassTransformer@3dd818e8 to Target : CLASS {Lnet/minecraft/world/item/ItemStack;} {} {V}
    [23:18:09] [main/DEBUG] [cp.mo.mo.TransformStore/MODLAUNCHER]: Adding transformer net.minecraftforge.coremod.transformer.CoreModClassTransformer@4cb40e3b to Target : CLASS {Lnet/minecraft/network/play/client/CClientSettingsPacket;} {} {V}
    [23:18:09] [main/DEBUG] [cp.mo.mo.TransformationServiceDecorator/MODLAUNCHER]: Initialized transformers for transformation service fml
    [23:18:09] [main/DEBUG] [mixin/]: Processing prepare() for PlatformAgent[MixinPlatformAgentDefault:ModLauncher Root Container(ModLauncher:4f56a0a2)]
    [23:18:09] [main/DEBUG] [mixin/]: Processing launch tasks for PlatformAgent[MixinPlatformAgentDefault:ModLauncher Root Container(ModLauncher:4f56a0a2)]
    [23:18:09] [main/DEBUG] [mixin/]: Adding mixin platform agents for container SecureJarResource(minecraft)
    [23:18:09] [main/DEBUG] [mixin/]: Instancing new MixinPlatformAgentMinecraftForge for SecureJarResource(minecraft)
    [23:18:09] [main/DEBUG] [mixin/]: MixinPlatformAgentMinecraftForge rejected container SecureJarResource(minecraft)
    [23:18:09] [main/DEBUG] [mixin/]: Instancing new MixinPlatformAgentDefault for SecureJarResource(minecraft)
    [23:18:09] [main/DEBUG] [mixin/]: MixinPlatformAgentDefault accepted container SecureJarResource(minecraft)
    [23:18:09] [main/DEBUG] [mixin/]: Processing prepare() for PlatformAgent[MixinPlatformAgentDefault:SecureJarResource(minecraft)]
    [23:18:09] [main/DEBUG] [mixin/]: Adding mixin platform agents for container SecureJarResource(examplemod)
    [23:18:09] [main/DEBUG] [mixin/]: Instancing new MixinPlatformAgentMinecraftForge for SecureJarResource(examplemod)
    [23:18:09] [main/DEBUG] [mixin/]: MixinPlatformAgentMinecraftForge rejected container SecureJarResource(examplemod)
    [23:18:09] [main/DEBUG] [mixin/]: Instancing new MixinPlatformAgentDefault for SecureJarResource(examplemod)
    [23:18:09] [main/DEBUG] [mixin/]: MixinPlatformAgentDefault accepted container SecureJarResource(examplemod)
    [23:18:09] [main/DEBUG] [mixin/]: Processing prepare() for PlatformAgent[MixinPlatformAgentDefault:SecureJarResource(examplemod)]
    [23:18:09] [main/DEBUG] [mixin/]: Adding mixin platform agents for container SecureJarResource(forge)
    [23:18:09] [main/DEBUG] [mixin/]: Instancing new MixinPlatformAgentMinecraftForge for SecureJarResource(forge)
    [23:18:09] [main/DEBUG] [mixin/]: MixinPlatformAgentMinecraftForge rejected container SecureJarResource(forge)
    [23:18:09] [main/DEBUG] [mixin/]: Instancing new MixinPlatformAgentDefault for SecureJarResource(forge)
    [23:18:09] [main/DEBUG] [mixin/]: MixinPlatformAgentDefault accepted container SecureJarResource(forge)
    [23:18:09] [main/DEBUG] [mixin/]: Processing prepare() for PlatformAgent[MixinPlatformAgentDefault:SecureJarResource(forge)]
    [23:18:09] [main/DEBUG] [mixin/]: inject() running with 4 agents
    [23:18:09] [main/DEBUG] [mixin/]: Processing inject() for PlatformAgent[MixinPlatformAgentDefault:ModLauncher Root Container(ModLauncher:4f56a0a2)]
    [23:18:09] [main/DEBUG] [mixin/]: Processing inject() for PlatformAgent[MixinPlatformAgentDefault:SecureJarResource(minecraft)]
    [23:18:09] [main/DEBUG] [mixin/]: Processing inject() for PlatformAgent[MixinPlatformAgentDefault:SecureJarResource(examplemod)]
    [23:18:09] [main/DEBUG] [mixin/]: Processing inject() for PlatformAgent[MixinPlatformAgentDefault:SecureJarResource(forge)]
    [23:18:09] [main/INFO] [cp.mo.mo.LaunchServiceHandler/MODLAUNCHER]: Launching target 'forgeclientuserdev' with arguments [--version, MOD_DEV, --gameDir, ., --assetsDir, /Users/noahgreff/.gradle/caches/forge_gradle/assets, --assetIndex, 1.18]
    [23:18:09] [main/DEBUG] [mixin/]: Error cleaning class output directory: .mixin.out
    [23:18:09] [main/DEBUG] [mixin/]: Preparing mixins for MixinEnvironment[DEFAULT]
    [23:18:09] [main/DEBUG] [io.ne.ut.in.lo.InternalLoggerFactory/]: Using Log4J2 as the default logging framework
    [23:18:09] [main/DEBUG] [io.ne.ut.ResourceLeakDetector/]: -Dio.netty.leakDetection.level: simple
    [23:18:09] [main/DEBUG] [io.ne.ut.ResourceLeakDetector/]: -Dio.netty.leakDetection.targetRecords: 4
    SLF4J: No SLF4J providers were found.
    SLF4J: Defaulting to no-operation (NOP) logger implementation
    SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details.
    [23:18:10] [pool-3-thread-1/DEBUG] [ne.mi.co.tr.CoreModBaseTransformer/COREMOD]: Transforming net/minecraft/world/level/block/LiquidBlock
    [23:18:10] [pool-3-thread-1/DEBUG] [ne.mi.co.tr.CoreModBaseTransformer/COREMOD]: Transforming net/minecraft/world/level/block/StairBlock
    [23:18:10] [pool-3-thread-1/DEBUG] [ne.mi.co.tr.CoreModBaseTransformer/COREMOD]: Transforming net/minecraft/world/level/block/FlowerPotBlock
    [23:18:10] [pool-3-thread-1/DEBUG] [ne.mi.co.tr.CoreModBaseTransformer/COREMOD]: Transforming net/minecraft/world/item/ItemStack
    [23:18:12] [pool-3-thread-1/DEBUG] [ne.mi.co.tr.CoreModBaseTransformer/COREMOD]: Transforming net/minecraft/world/item/BucketItem
    [23:18:12] [pool-3-thread-1/DEBUG] [ne.mi.co.tr.CoreModBaseTransformer/COREMOD]: Transforming net/minecraft/world/effect/MobEffectInstance
    Exception in thread "Render thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    	at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:39)
    	at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53)
    	at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71)
    	at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.Launcher.run(Launcher.java:106)
    	at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.Launcher.main(Launcher.java:77)
    	at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26)
    	at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23)
    	at cpw.mods.bootstraplauncher@1.0.0/cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:149)
    Caused by: java.lang.reflect.InvocationTargetException
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    	at MC-BOOTSTRAP/fmlloader@1.18.1-39.1.2/net.minecraftforge.fml.loading.targets.ForgeClientUserdevLaunchHandler.lambda$launchService$0(ForgeClientUserdevLaunchHandler.java:38)
    	at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37)
    	... 7 more
    Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.mojang.blaze3d.systems.RenderSystem
    	at TRANSFORMER/minecraft@1.18.1/net.minecraft.SystemReport.setDetail(SystemReport.java:62)
    	at TRANSFORMER/minecraft@1.18.1/net.minecraft.client.Minecraft.fillSystemReport(Minecraft.java:2269)
    	at TRANSFORMER/minecraft@1.18.1/net.minecraft.client.Minecraft.fillReport(Minecraft.java:2262)
    	at TRANSFORMER/minecraft@1.18.1/net.minecraft.client.main.Main.main(Main.java:178)
    	... 13 more
    
    > Task :runClient FAILED
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':runClient'.
    > Process 'command '/Library/Java/JavaVirtualMachines/jdk-17.0.2.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
    
    * Try:
    > Run with --stacktrace option to get the stack trace.
    > Run with --info or --debug option to get more log output.
    > Run with --scan to get full insights.
    
    * Get more help at https://help.gradle.org
    
    BUILD FAILED in 15s
    
    Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
    
    You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
    
    See https://docs.gradle.org/7.3/userguide/command_line_interface.html#sec:command_line_warnings
    10 actionable tasks: 9 executed, 1 up-to-date
    23:18:12: Execution finished 'runClient'.

     

  3. Alright. the FMLClientSetupEvent is not the corret event to listen to (at all).

    You will need to listen for the PlayerTickEvent event.

    public class PlayerTickHandler {
    
        @SubscribeEvent
        public void onPlayerTick(TickEvent.PlayerTickEvent event) {
            PlayerEntity player = event.player;
            if (player.getHealth() < 7) {
                player.addPotionEffect(new EffectInstance(Effects.SLOWNESS, 60));
            }
        }
    }

    And register it for Forge event bus inside your mod's construcor like this: 

    MinecraftForge.EVENT_BUS.register(new PlayerTickHandler());

    Note the @SubscribeEvent, this essentially tells forge that the methods is listening for an event.

  4. 37 minutes ago, Luis_ST said:

    try to use a Logger#info instead of System.out

     

    the OnlyIn annotation is only for vanilla

    Noted.

     

    24 minutes ago, diesieben07 said:

    What do you need ModelBakeEvent for? You should use a custom model loader instead.

    I am trying to fetch Fence blocks and add an overlay to it.

     

    By 

    Quote

    custom model loader

    you mean ICustomModelLoader?

     

  5. I am susbsribing to the ModelBakeEvent event but it seems to be skipped while the game loads.

    Here's how I subscribe to the event:

    public class ModelBakeHandler {
    
    //    @OnlyIn(Dist.CLIENT)
        @SubscribeEvent
        public void onModelBakeEvent(ModelBakeEvent event) {
            System.out.println("_______________");
        }
    }

    and register the event in my main class:

            MinecraftForge.EVENT_BUS.register(new ModelBakeHandler());

     

    This is the event logs when the event gets triggered:

    [17:38:18] [Render thread/DEBUG] [ne.mi.fm.ja.FMLModContainer/LOADING]: Firing event for modid siltblocks : net.minecraftforge.client.event.ModelBakeEvent@4d98e41b
    [17:38:18] [Render thread/DEBUG] [ne.mi.fm.ja.FMLModContainer/LOADING]: Fired event for modid siltblocks : net.minecraftforge.client.event.ModelBakeEvent@4d98e41b
    [17:38:18] [Render thread/DEBUG] [ne.mi.fm.ja.FMLModContainer/LOADING]: Firing event for modid forge : net.minecraftforge.client.event.ModelBakeEvent@4d98e41b
    [17:38:18] [Render thread/DEBUG] [ne.mi.fm.ja.FMLModContainer/LOADING]: Fired event for modid forge : net.minecraftforge.client.event.ModelBakeEvent@4d98e41b

     

    My "_______________" is not logged here (or ever). Any ideas why?

     

    Edit: Should I ever the "OnlyIn" decorator as a modder?

  6. Ok, found the issue.

     

    Within ModelBuilder, there are a few different method signatures for texture. Of which:

    public T texture(String key, String texture) : T

    and

    public T texture(String key, ResourceLocation texture) : T

     

    Method 1 uses <key> as the JSON key and <texture> as the asset path while in Method 2 <key> as the asset path and <texture> as the JSON key.

     

    Since I used the first method before and it my code worked, I assumed it was the same for the second method.

     

    Their paramaters are effectively swapped and this confused the hell out of me. In hindsight, I should read the comments more...

  7. I am trying to generate my block models with Data Generators which I incounter this error: Invalid ResourceLocation block/minecraft:sand

     

    It's easy to spot why this error occurs ("block/minecraft:sand", ':' triggers the error) but I don't understand where this error could come from by looking at my code.

     

    Since I have a few variants of the same block, I've replicated Minecraft's way by defining a template JSON for my variant and simply have my block use it as a parent and add a texture.

    Heres what I have:

        private void generateSiltBlockFenceGateFromTemplate(SiltFenceGateBlock gate) {
            String texture = Objects.requireNonNull(gate.getParentBlock().getRegistryName()).toString();
    
            getVariantBuilder(gate).forAllStatesExcept(state -> {
                    String base = "silt_fence_gate" + (state.get(OPEN) ? "_open_" : "_close_") + state.get(AbstractSiltBarrierBlock.LAYER);
                    if (state.get(IN_WALL)) base = base + "_in_wall"; 
                    // <base> would look like "silt_fence_gate_close_1"
    
                    ModelBuilder<?> model = models()
                            .withExistingParent(texture + "_" + base, modLoc("block/template_" + base))
                            .texture("texture", mcLoc("block/" + texture)) // <--- stacktrace points here
                            .element().end();
    
                    int rotation = (int) state.get(HORIZONTAL_FACING).getHorizontalAngle();
                    return ConfiguredModel.builder().modelFile(model).uvLock(true).rotationY(rotation).build();
                },
                WATERLOGGED
            );
        }

     

    I've also tried to feed it a texture as a string directly but to no avail:

                            .texture("texture", "block/" + texture) // <--- stacktrace points here

     

    What I expect is sand_silt_fence_gate_close_1.json:

    {
      "parent": "siltsand:block/template_silt_fence_gate_close_1"
      "textures": {
      	"texture": "sand"
      }
    }

     

    Here's my template JSON: template_silt_fence_gate_close_1.json:

    {
      "parent": "block/block",
      "textures": {
        "particle": "#texture"
      },
      "elements": [
        {
          "from": [ 14, 0, 7 ],
          "to": [ 16, 1, 9 ],
          "faces": {
            "north": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" },
            "east":  { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" },
            "south": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" },
            "west":  { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" },
            "up":    { "uv": [ 0, 0, 2, 2 ], "texture": "#texture" }
          }
        },
        {
          "from": [ 0, 0, 7 ],
          "to": [ 2, 1, 9 ],
          "faces": {
            "north": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" },
            "east":  { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" },
            "south": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" },
            "west":  { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" },
            "up":    { "uv": [ 0, 0, 2, 2 ], "texture": "#texture" }
          }
        },
        {
          "from": [ 2, -1, 7 ],
          "to": [ 14, 0, 9 ],
          "faces": {
            "up":    { "uv": [ 0, 0, 12, 2 ], "texture": "#texture" },
            "north": { "uv": [ 0, 0, 12, 1 ], "texture": "#texture" },
            "south": { "uv": [ 0, 0, 12, 1 ], "texture": "#texture" },
            "west":  { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" },
            "east":  { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }
          }
        },
        {
          "from": [ 10, -7, 7 ],
          "to": [ 14, -6, 9 ],
          "faces": {
            "up":    { "uv": [ 0, 0, 4, 2 ], "texture": "#texture" },
            "north": { "uv": [ 0, 0, 4, 1 ], "texture": "#texture" },
            "south": { "uv": [ 0, 0, 4, 1 ], "texture": "#texture" },
            "west":  { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" },
            "east":  { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }
          }
        },
        {
          "from": [ 2, -7, 7 ],
          "to": [ 6, -6, 9 ],
          "faces": {
            "up":    { "uv": [ 0, 0, 4, 2 ], "texture": "#texture" },
            "north": { "uv": [ 0, 0, 4, 1 ], "texture": "#texture" },
            "south": { "uv": [ 0, 0, 4, 1 ], "texture": "#texture" },
            "west":  { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" },
            "east":  { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }
          }
        }
      ]
    }

    I have read that maybe this might be caused by invalid JSON but that has been checked too.

     

    Any idea why this happens? 

     

    PS: I am new to Data Gens so it is very likely that I using the builder wrong.

    PPS: Posted my issue in the wrong topic section

  8. I am trying to generate my block models with Data Generators which I incounter this error.

     

    It's easy to spot why this error occurs ("block/minecraft:sand", ':' triggers the error) but I don't understand where this error could come from by looking at my code.

     

    Since I have a few variants of the same block, I've replicated Minecraft's way by defining a template JSON for my variant and simply have my block use it as a parent and add a texture.

    Heres what I have:

        private void generateSiltBlockFenceGateFromTemplate(SiltFenceGateBlock gate) {
            String texture = Objects.requireNonNull(gate.getParentBlock().getRegistryName()).toString();
    
            getVariantBuilder(gate).forAllStatesExcept(state -> {
                    String base = "silt_fence_gate" + (state.get(OPEN) ? "_open_" : "_close_") + state.get(AbstractSiltBarrierBlock.LAYER);
                    if (state.get(IN_WALL)) base = base + "_in_wall"; 
                    // <base> would look like "silt_fence_gate_close_1"
    
                    ModelBuilder<?> model = models()
                            .withExistingParent(texture + "_" + base, modLoc("block/template_" + base))
                            .texture("texture", mcLoc("block/" + texture)) // <--- stacktrace points here
                            .element().end();
    
                    int rotation = (int) state.get(HORIZONTAL_FACING).getHorizontalAngle();
                    return ConfiguredModel.builder().modelFile(model).uvLock(true).rotationY(rotation).build();
                },
                WATERLOGGED
            );
        }

     

    I've also tried to feed it a texture as a string directly but to no avail:

                            .texture("texture", "block/" + texture) // <--- stacktrace points here

     

    What I expect is sand_silt_fence_gate_close_1.json:

    {
      "parent": "siltsand:block/template_silt_fence_gate_close_1"
      "textures": {
      	"texture": "sand"
      }
    }

     

    Here's my template JSON: template_silt_fence_gate_close_1.json:

    {
      "parent": "block/block",
      "textures": {
        "particle": "#texture"
      },
      "elements": [
        {
          "from": [ 14, 0, 7 ],
          "to": [ 16, 1, 9 ],
          "faces": {
            "north": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" },
            "east":  { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" },
            "south": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" },
            "west":  { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" },
            "up":    { "uv": [ 0, 0, 2, 2 ], "texture": "#texture" }
          }
        },
        {
          "from": [ 0, 0, 7 ],
          "to": [ 2, 1, 9 ],
          "faces": {
            "north": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" },
            "east":  { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" },
            "south": { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" },
            "west":  { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" },
            "up":    { "uv": [ 0, 0, 2, 2 ], "texture": "#texture" }
          }
        },
        {
          "from": [ 2, -1, 7 ],
          "to": [ 14, 0, 9 ],
          "faces": {
            "up":    { "uv": [ 0, 0, 12, 2 ], "texture": "#texture" },
            "north": { "uv": [ 0, 0, 12, 1 ], "texture": "#texture" },
            "south": { "uv": [ 0, 0, 12, 1 ], "texture": "#texture" },
            "west":  { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" },
            "east":  { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }
          }
        },
        {
          "from": [ 10, -7, 7 ],
          "to": [ 14, -6, 9 ],
          "faces": {
            "up":    { "uv": [ 0, 0, 4, 2 ], "texture": "#texture" },
            "north": { "uv": [ 0, 0, 4, 1 ], "texture": "#texture" },
            "south": { "uv": [ 0, 0, 4, 1 ], "texture": "#texture" },
            "west":  { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" },
            "east":  { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }
          }
        },
        {
          "from": [ 2, -7, 7 ],
          "to": [ 6, -6, 9 ],
          "faces": {
            "up":    { "uv": [ 0, 0, 4, 2 ], "texture": "#texture" },
            "north": { "uv": [ 0, 0, 4, 1 ], "texture": "#texture" },
            "south": { "uv": [ 0, 0, 4, 1 ], "texture": "#texture" },
            "west":  { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" },
            "east":  { "uv": [ 0, 0, 2, 1 ], "texture": "#texture" }
          }
        }
      ]
    }

    I have read that maybe this might be caused by invalid JSON but that has been checked too.

     

    Any idea why this happens? 

     

    PS: I am new to Data Gens so it is very likely that I using the builder wrong.

  9. I am trying to set my entity's EntitySize fixed. I can set the entity's size with EntityType.Builder::size(float, float) which this calls EntitySize::flexible(float, float) but the builder does not seem to have a method with EntitySize::fixed(float, float) for setting fixed entity sizes. I figured I could make my own entity builder but that seems overkill just for  this. Is there a better way to set an entity's size as fixed?  

  10. Alright it works now, heres what I did to make it work.

    On the entity's side I call open the container like this:

        @Override
        public ActionResultType processInitialInteract(PlayerEntity player, Hand hand) {
    
            if (!player.world.isRemote()) {
                NetworkHooks.openGui((ServerPlayerEntity) player, this, b -> b.writeInt(this.getEntityId()));
            }
    
            return ActionResultType.SUCCESS;
        }
    
        @Override
        public Container createMenu(int id, PlayerInventory inventory, PlayerEntity player) {
            PacketBuffer buffer = new PacketBuffer(Unpooled.buffer());
            buffer.writeInt(this.getEntityId());
            return new ContainerModuleCartMiner(id, playerInventory, buffer);
        }

    Where I assign the entity's id to a buffer and in the container:

        public ContainerModuleCartMiner(int id, PlayerInventory playerInventory, PacketBuffer buffer) {
            super(ContainerRegistry.MINER_CART_CONTAINER.get(), id);
    
            Entity entity = playerInventory.player.world.getEntityByID(buffer.readInt());
    
            if (entity instanceof EntityModuleCartMiner)
                System.out.println(playerInventory.player.world.isRemote()); // outputs both 'ture' & 'false', meaning both client and server managed to get the entity from the buffer int
        }

     

    Edit: Is it ever possible for the packetbuffer to be null? 

  11. I am trying to pass down my cart entity instance down to my container. I've tried a few different things which worked but never with the correct constructor paramaters (with my entity class).

    Heres how register my container,

        public static final RegistryObject<ContainerType<ContainerModuleCartMiner>> MINER_CART_CONTAINER = CONTAINERS.register("miner_module_cart",
                () -> new ContainerType(ContainerModuleCartMiner::new));

    and call it like this within my entity class:

        // Entity class implements `IInventory` and `INamedContainerProvider`
    
    	// server side?
        @Override
        public ActionResultType processInitialInteract(PlayerEntity player, Hand hand) {
            if (!player.world.isRemote()) NetworkHooks.openGui((ServerPlayerEntity) player, this);
            return ActionResultType.SUCCESS;
        }
    	
    	// client side?
        @Override
        public Container createMenu(int id, PlayerInventory inventory, PlayerEntity player) {
            return new ContainerModuleCartMiner(id, playerInventory, this);
        }

    And my container looks like this:

        // constr. 1 
    	public ContainerModuleCartMiner(int id, PlayerInventory playerInventory) {
            this(id, playerInventory, new Inventory(0));
        }
    
    	// constr. 2
        public ContainerModuleCartMiner(int id, PlayerInventory playerInventory, IInventory inventory) {
            super(ContainerRegistry.MINER_CART_CONTAINER.get(), id);
    
    		if (inventory instanceof EntityModuleCartMiner)
    			System.out.println(playerInventory.player.world.isRemote) // outputs: false, client only
    
            this.loadPlayerInventory(playerInventory, ScreenModuleCartMiner.SIZE_X, ScreenModuleCartMiner.SIZE_Y);
        }

    The first constructor gets called on the server side which subsequently calls the second constructor with an empty inventory, only on the client side does the second constructor get called (from my understanding).

    Checking whether `inventory` is an instance of my entity only works in the client and not on the server.

    Is there a way to call the same constructor on both the client/server side with params `int`, `PlayerInventory` and `Entity` instead of `IInventory`directly?

     

    Also, I've tried calling the constructor with `int`, `PlayerInventory` and `PacketBuffer` and pass int the Entity's id along and retreive it on the other end with `world.getEntityById(buffer.readInt())` but it always seem to be null.

  12. I've been trying to register my cart entity to `RenderingRegistry`but I have been receiving errors I am having a hard time understanding.

     

    I register my entity renderer like this:

        public static void registerRenderers(final FMLClientSetupEvent event) {
            RenderingRegistry.registerEntityRenderingHandler(AllEntities.MINER_CART_ENTITY.get(), MinerModuleCartRenderer::new);
        }

    and this is my MinerModuleCartRenderer:

    @OnlyIn(Dist.CLIENT)
    public class MinerModuleCartRenderer<T extends AbstractMinecartEntity> extends EntityRenderer<T> {
    
        private static final ResourceLocation MINER_TEXTURE = new ResourceLocation(MODID + ":textures/entity/miner_cart_module.png");
        private final EntityModel<T> modelCartModule = new MinerCartModuleModel<>();
    
        public MinerModuleCartRenderer(EntityRendererManager renderManager) {
            super(renderManager);
        }
    
        public void render(T entity, float entityYaw, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int packedLight) {
      	// [...] long code copied from MinecartRenderer directly
        }
    
        public ResourceLocation getEntityTexture(T entity) {
            return MINER_TEXTURE;
        }
    
        protected void renderBlockState(T entity, float partialTicks, BlockState state, MatrixStack matrixStack, IRenderTypeBuffer buffer, int packedLight) {
            Minecraft.getInstance().getBlockRendererDispatcher().renderBlock(state, matrixStack, buffer, packedLight, OverlayTexture.NO_OVERLAY);
        }
    }

    but I get this error:

    Bad return type in method reference: cannot convert com.than00ber.gameoflife.client.renderer.entity.MinerModuleCartRenderer<T> to net.minecraft.client.renderer.entity.EntityRenderer<? super ?>

    (I get the same error when trying to register Minecraft's `MinercartRenderer` like this)

     

    I've looked into Minecraft 's source code and noticed that it registers its entity renderers like this:

       public <T extends Entity> void register(EntityType<T> entityTypeIn, EntityRenderer<? super T> entityRendererIn) {
          this.renderers.put(entityTypeIn, entityRendererIn);
       }

    but Forge with `IRenderFactory`:

        public static <T extends Entity> void registerEntityRenderingHandler(EntityType<T> entityClass, IRenderFactory<? super T> renderFactory)
        {
            INSTANCE.entityRenderers.put(entityClass, renderFactory);
        }

    so I implemented `IRenderFactorty` in `MinerModuleCartRenderer` to see if it makes a difference but to no avail; the error stays the same.

     

    Any idea why that is and how can I solve this?

     

    Now I know this is more of Java error but I figured I'll get a better shot here since people have prior knowledge. 

  13. Ah I managed to do this. The problem was really dumb, I didn't register the actual item itself.

     

    For any in the future that want to know how to it, this how I did it:

    Create the item:

    public class MinerCartItem extends MinecartItem {
    
        public MinerCartItem() {
            super(AbstractMinecartEntity.Type.RIDEABLE, (new Item.Properties()).maxStackSize(1).group(ItemGroup.FOOD));
        }
    }

    and then register it the same way you would do for other registries:

        public static final RegistryObject<Item> MINER_ITEM = ITEMS.register("miner_item", MinerCartItem::new);

     

  14. I am trying to register a simple minecart entity but it does not seem to appear in-game. No errors are thrown either.

     

    Here is my Minecart entity class:

    public class MinerCartEntity extends AbstractMinecartEntity {
    
        public MinerCartEntity(EntityType<?> type, World worldIn) {
            super(type, worldIn);
        }
    
        @Override
        public Type getMinecartType() {
            return Type.CHEST;
        }
    }

     

    Here is how I register it,

    public class AllEntities {
    
        public static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITIES, MODID);
    
        private static <T extends EntityType<?>> RegistryObject<EntityType<?>> register(String name, Supplier<T> entity) {
            System.out.println("REGISTERING MOD ENTITY: " + name);
            return ENTITIES.register(name, entity);
        }
    
        public static final RegistryObject<EntityType<?>> MINER_MINECART = register("miner_minecart",
                () -> EntityType.Builder.<AbstractMinecartEntity>create(MinerCartEntity::new, EntityClassification.MISC)
                .size(0.98F, 0.7F).trackingRange(8)
                .build(new ResourceLocation(MODID, "miner_minecart").toString()));
    }

    and in the main file simply:

            IEventBus fmlContext = FMLJavaModLoadingContext.get().getModEventBus();
            AllBlocks.BLOCKS.register(fmlContext);
            AllTileEntities.TILE_ENTITIES.register(fmlContext);
            AllItems.ITEMS.register(fmlContext);
            AllEntities.ENTITIES.register(fmlContext);	// <------ over here

     

    My first guess was to follow the same way to register entities as blocks or items while using the entity builder shown in Minecraft's source code.

    Any guess as to why it does not load in-game or not throwing errors? Is this even the right way?

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.