Jump to content

Get Current Minecraft Player


Nicba1010

Recommended Posts

I am trying to make a level system. I have succseeded in some places but in other not. The main problem is: how to get current minecraft player, like i mean EntityPlayer.

Here is the error log: http://pastebin.com/ZMVjyjD6

This is the Gui class code:http://pastebin.com/LkVbuNQB

Before i have had

EntityPlayer p = mc.theplayer;

but this doesn't work.

 

Example where it works:

I the Block On Activated method:

public boolean onBlockActivated(World world, int x, int y, int z,EntityPlayer p, int a, float f, float b, float c){
	nbt=p.getEntityData();
	nbt.setInteger("level", getLevel()+1);
	return true;
	}
public int getLevel() {
	return nbt.getInteger("level");
}

because here i have the EntityPlayer supplied.

Chemistryzation.java(main class):http://pastebin.com/aNg5VYCq

 

Please help!

For any useful info you will be credited!

Link to comment
Share on other sites

It doesn't work because of the client-server architecture.

 

A SSP game and a SMP game with one connected user are indistinguishable.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

You can, you just have to approach it differently.

 

You are going to need an event hook to listen for players joining the server, then save data into the player that way.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

if you use a

spoiler

maybe, because my current network blocks pastebin

 

btw if you wanna check which side your on use:

 

FMLCo[ac].instance().getEffectiveSide().isClient()  ( the [ac] is auto complete, i dont remember the class name exactly)

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

 

package nicba1010.chemistryzation.common;

 

 

 

import net.minecraft.client.Minecraft;

 

import net.minecraft.client.gui.FontRenderer;

 

import net.minecraft.client.gui.Gui;

 

import net.minecraft.entity.player.EntityPlayer;

 

import net.minecraft.nbt.NBTTagCompound;

 

import net.minecraftforge.client.event.RenderGameOverlayEvent;

 

import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;

 

import net.minecraftforge.event.EventPriority;

 

import net.minecraftforge.event.ForgeSubscribe;

 

 

 

//

 

// GuiBuffBar implements a simple status bar at the top of the screen which

 

// shows the current buffs/debuffs applied to the character.

 

//

 

public class GuiChemistryLevel extends Gui {

 

        private Minecraft mc;

 

        FontRenderer fontrenderer;

 

        EntityPlayer p;

 

        NBTTagCompound nbt;

 

 

 

        public GuiChemistryLevel(Minecraft mc) {

 

                super();

 

                fontrenderer = mc.fontRenderer;

 

                // We need this to invoke the render engine.

 

                this.mc = mc;

 

                nbt = p.getEntityData();

 

        }

 

 

 

        @ForgeSubscribe(priority = EventPriority.NORMAL)

 

        public void onRenderExperienceBar(RenderGameOverlayEvent event) {

 

                if (event.isCancelable() || event.type != ElementType.EXPERIENCE) {

 

                        return;

 

                }

 

                int level;

 

                level = nbt.getInteger("level");

 

                if (level == 0) {

 

                        nbt.setInteger("level", 1);

 

                        level = nbt.getInteger("level");

 

                        fontrenderer.drawString("Level " + level, 1, 1, 0xffffffff);

 

                } else {

 

                        fontrenderer.drawString("Level " + level, 1, 1, 0xffffffff);

 

                }

 

 

 

                this.mc.renderEngine.bindTexture("/gui/inventory.png");

 

        }

 

}

 

Link to comment
Share on other sites

heu ... yeah no shit you're having a NPE

 

 

 

package nicba1010.chemistryzation.common;

 

 

 

import net.minecraft.client.Minecraft;

 

import net.minecraft.client.gui.FontRenderer;

 

import net.minecraft.client.gui.Gui;

 

import net.minecraft.entity.player.EntityPlayer;

 

import net.minecraft.nbt.NBTTagCompound;

 

import net.minecraftforge.client.event.RenderGameOverlayEvent;

 

import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;

 

import net.minecraftforge.event.EventPriority;

 

import net.minecraftforge.event.ForgeSubscribe;

 

 

 

//

 

// GuiBuffBar implements a simple status bar at the top of the screen which

 

// shows the current buffs/debuffs applied to the character.

 

//

 

public class GuiChemistryLevel extends Gui {

 

        private Minecraft mc;

 

        FontRenderer fontrenderer;

 

        EntityPlayer p;

 

        NBTTagCompound nbt;

 

 

 

        public GuiChemistryLevel(Minecraft mc) {

 

                super();

 

                fontrenderer = mc.fontRenderer;

 

                // We need this to invoke the render engine.

 

                this.mc = mc;

 

                nbt = p.getEntityData();

 

        }

 

 

 

        @ForgeSubscribe(priority = EventPriority.NORMAL)

 

        public void onRenderExperienceBar(RenderGameOverlayEvent event) {

 

                if (event.isCancelable() || event.type != ElementType.EXPERIENCE) {

 

                        return;

 

                }

 

                int level;

 

                level = nbt.getInteger("level");

 

                if (level == 0) {

 

                        nbt.setInteger("level", 1);

 

                        level = nbt.getInteger("level");

 

                        fontrenderer.drawString("Level " + level, 1, 1, 0xffffffff);

 

                } else {

 

                        fontrenderer.drawString("Level " + level, 1, 1, 0xffffffff);

 

                }

 

 

 

                this.mc.renderEngine.bindTexture("/gui/inventory.png");

 

        }

 

}

 

 

 

the EntityPlayer is never initialized

 

 

 

 

package nicba1010.chemistryzation.common;

 

 

 

import net.minecraft.client.Minecraft;

 

import net.minecraft.client.gui.FontRenderer;

 

import net.minecraft.client.gui.Gui;

 

import net.minecraft.entity.player.EntityPlayer;

 

import net.minecraft.nbt.NBTTagCompound;

 

import net.minecraftforge.client.event.RenderGameOverlayEvent;

 

import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;

 

import net.minecraftforge.event.EventPriority;

 

import net.minecraftforge.event.ForgeSubscribe;

 

 

 

//

 

// GuiBuffBar implements a simple status bar at the top of the screen which

 

// shows the current buffs/debuffs applied to the character.

 

//

 

public class GuiChemistryLevel extends Gui {

 

        private Minecraft mc;

 

        FontRenderer fontrenderer;

 

        EntityPlayer p;

        //this should probably be a

        EntityClientPlayerMP player;

 

        NBTTagCompound nbt;

 

 

 

        public GuiChemistryLevel(Minecraft mc) {

 

                super();

 

                fontrenderer = mc.fontRenderer;

 

                // We need this to invoke the render engine.

 

                this.mc = mc;

                //now like i said earlier

                p = Minecraft.getMinecraft().thePlayer;

                //or

                p = mc.thePlayer;

                //since mc is a reference to the current Minecraft

 

                nbt = p.getEntityData();

 

        }

 

 

 

        @ForgeSubscribe(priority = EventPriority.NORMAL)

 

        public void onRenderExperienceBar(RenderGameOverlayEvent event) {

 

                if (event.isCancelable() || event.type != ElementType.EXPERIENCE) {

 

                        return;

 

                }

 

                int level;

 

                level = nbt.getInteger("level");

 

                if (level == 0) {

 

                        nbt.setInteger("level", 1);

 

                        level = nbt.getInteger("level");

 

                        fontrenderer.drawString("Level " + level, 1, 1, 0xffffffff);

 

                } else {

 

                        fontrenderer.drawString("Level " + level, 1, 1, 0xffffffff);

 

                }

 

 

 

                this.mc.renderEngine.bindTexture("/gui/inventory.png");

 

        }

 

}

 

 

 

btw not to be mean but i suggest you attack smaller mods. This is a pretty obvious error.

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

BTW STILL Caught exception from chemistryzation

java.lang.NullPointerException

at nicba1010.chemistryzation.common.GuiChemistryLevel.<init>(GuiChemistryLevel.java:49)

at nicba1010.chemistryzation.common.Chemistryzation.postInit(Chemistryzation.java:76)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:494)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)

at com.google.common.eventbus.EventBus.post(EventBus.java:267)

at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:165)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)

at com.google.common.eventbus.EventBus.post(EventBus.java:267)

at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:98)

at cpw.mods.fml.common.Loader.initializeMods(Loader.java:695)

at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:206)

at net.minecraft.client.Minecraft.startGame(Minecraft.java:447)

at net.minecraft.client.MinecraftAppletImpl.startGame(MinecraftAppletImpl.java:44)

at net.minecraft.client.Minecraft.run(Minecraft.java:732)

at java.lang.Thread.run(Unknown Source)

2013-06-27 16:23:32 [iNFO] [sTDERR] java.lang.NullPointerException

2013-06-27 16:23:32 [iNFO] [sTDERR] at nicba1010.chemistryzation.common.GuiChemistryLevel.<init>(GuiChemistryLevel.java:49)

2013-06-27 16:23:32 [iNFO] [sTDERR] at nicba1010.chemistryzation.common.Chemistryzation.postInit(Chemistryzation.java:76)

2013-06-27 16:23:32 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

2013-06-27 16:23:32 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

2013-06-27 16:23:32 [iNFO] [sTDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

2013-06-27 16:23:32 [iNFO] [sTDERR] at java.lang.reflect.Method.invoke(Unknown Source)

2013-06-27 16:23:32 [iNFO] [sTDERR] at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:494)

2013-06-27 16:23:32 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

2013-06-27 16:23:32 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

2013-06-27 16:23:32 [iNFO] [sTDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

2013-06-27 16:23:32 [iNFO] [sTDERR] at java.lang.reflect.Method.invoke(Unknown Source)

2013-06-27 16:23:32 [iNFO] [sTDERR] at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

2013-06-27 16:23:32 [iNFO] [sTDERR] at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)

2013-06-27 16:23:32 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)

2013-06-27 16:23:32 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)

2013-06-27 16:23:32 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.post(EventBus.java:267)

2013-06-27 16:23:32 [iNFO] [sTDERR] at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:165)

2013-06-27 16:23:32 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

2013-06-27 16:23:32 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

2013-06-27 16:23:32 [iNFO] [sTDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

2013-06-27 16:23:32 [iNFO] [sTDERR] at java.lang.reflect.Method.invoke(Unknown Source)

2013-06-27 16:23:32 [iNFO] [sTDERR] at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

2013-06-27 16:23:32 [iNFO] [sTDERR] at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)

2013-06-27 16:23:32 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)

2013-06-27 16:23:32 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)

2013-06-27 16:23:32 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.post(EventBus.java:267)

2013-06-27 16:23:32 [iNFO] [sTDERR] at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:98)

2013-06-27 16:23:32 [iNFO] [sTDERR] at cpw.mods.fml.common.Loader.initializeMods(Loader.java:695)

2013-06-27 16:23:32 [iNFO] [sTDERR] at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:206)

2013-06-27 16:23:32 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.startGame(Minecraft.java:447)

2013-06-27 16:23:32 [iNFO] [sTDERR] at net.minecraft.client.MinecraftAppletImpl.startGame(MinecraftAppletImpl.java:44)

2013-06-27 16:23:32 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.run(Minecraft.java:732)

2013-06-27 16:23:32 [iNFO] [sTDERR] at java.lang.Thread.run(Unknown Source)

 

Link to comment
Share on other sites

can we see the class "Chemistryzation". why are you calling a gui from there ? Even worst, why is it from a method called postInit ?

 

 

at nicba1010.chemistryzation.common.GuiChemistryLevel.<init>(GuiChemistryLevel.java:49)

at nicba1010.chemistryzation.common.Chemistryzation.postInit(Chemistryzation.java:76)

 

 

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

package nicba1010.chemistryzation.common;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.client.Minecraft;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.item.crafting.FurnaceRecipes;

import net.minecraftforge.common.MinecraftForge;

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.Init;

import cpw.mods.fml.common.Mod.PostInit;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.event.FMLPostInitializationEvent;

import cpw.mods.fml.common.network.NetworkMod;

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

 

@Mod(modid = Chemistryzation.modid, name = "chemistryzation", version = "0")

@NetworkMod(clientSideRequired = true, serverSideRequired = false)

public class Chemistryzation {

        public static final String modid = "chemistryzation";

        public static Block NaClBlock;

        public static Item NaClItem, NaClInBucketSolid, NaClInBucketMelted,

                        TestTube, NaClInTestTubeSolid;

 

        @Init

        public void load(FMLInitializationEvent event) {

                NaClBlock = new BlockNaClBlock(500, Material.rock)

                                .setUnlocalizedName("NaClBlock");

                GameRegistry.registerBlock(NaClBlock,

                                modid + "NaClBlock");

                LanguageRegistry.addName(NaClBlock, "Salt");

 

                NaClItem = new ItemNaClItem(5000).setUnlocalizedName("NaClItem");

                LanguageRegistry.addName(NaClItem, "NaCl");

 

                NaClInBucketSolid = new NaClInBucketSolid(5001)

                                .setUnlocalizedName("NaClInBucketSolid");

                LanguageRegistry.addName(NaClInBucketSolid, "NaCl");

 

                NaClInBucketMelted = new NaClInBucketMelted(5002)

                                .setUnlocalizedName("NaClInBucketMelted");

                LanguageRegistry.addName(NaClInBucketMelted, "NaCl");

 

                TestTube = new TestTube(5003).setUnlocalizedName("TestTube");

                LanguageRegistry.addName(TestTube, "Test Tube");

 

                NaClInTestTubeSolid = new NaClInTestTubeSolid(5004)

                                .setUnlocalizedName("NaClInTestTubeSolid");

                LanguageRegistry.addName(NaClInTestTubeSolid, "NaCl");

 

                GameRegistry.addRecipe(new ItemStack(Chemistryzation.TestTube, 8),

                                "XYX", "X X", " X ", Character.valueOf('X'), new ItemStack(

                                                Block.glass), Character.valueOf('Y'), Item.slimeBall);

 

                ItemStack NaClItemStack = new ItemStack(Chemistryzation.NaClItem);

                GameRegistry.addShapelessRecipe(new ItemStack(NaClInBucketSolid),

                                new Object[] { NaClItemStack, NaClItemStack, NaClItemStack,

                                                NaClItemStack, NaClItemStack, NaClItemStack,

                                                NaClItemStack, NaClItemStack,

                                                new ItemStack(Item.bucketEmpty) });

                GameRegistry

                                .addShapelessRecipe(new ItemStack(NaClInTestTubeSolid),

                                                new Object[] { NaClItemStack, NaClItemStack,

                                                                NaClItemStack, NaClItemStack,

                                                                new ItemStack(Chemistryzation.TestTube) });

                FurnaceRecipes.smelting().addSmelting(

                                Chemistryzation.NaClInBucketSolid.itemID, 0,

                                new ItemStack(Chemistryzation.NaClInBucketMelted), 0.1F);

        }

 

        @PostInit

        public void postInit(FMLPostInitializationEvent event) {

                MinecraftForge.EVENT_BUS.register(new GuiChemistryLevel(Minecraft

                                .getMinecraft()));

        }

}

Link to comment
Share on other sites

1 please use spoilers,

 

2 ..................

 

 

 

 

what you are saying to the mod right now is

"oh you're initializing the server? OPEN A GUI NOW NOW NOW" which cant happen server side

 

1 make a class that implements IGuiHandler

2 register this class like this

NetworkRegistry.instance().registerGuiHandler(this, new GuiHandler());

3 make GuiChemistryLevel  extends GuiScreen instead

4 call the gui from any method (either right click a block or bind it to a key)

5 look at the wiki and tutorials.

 

 

 

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

use something liek thsi

 

 

 

package nicba1010.chemistryzation.common;

 

 

 

import net.minecraft.client.Minecraft;

 

import net.minecraft.client.gui.FontRenderer;

 

import net.minecraft.client.gui.Gui;

 

import net.minecraft.entity.player.EntityPlayer;

 

import net.minecraft.nbt.NBTTagCompound;

 

import net.minecraftforge.client.event.RenderGameOverlayEvent;

 

import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;

 

import net.minecraftforge.event.EventPriority;

 

import net.minecraftforge.event.ForgeSubscribe;

 

 

 

//

 

// GuiBuffBar implements a simple status bar at the top of the screen which

 

// shows the current buffs/debuffs applied to the character.

 

//

 

public class GuiChemistryLevel extends Gui {

 

        private Minecraft mc;

 

        FontRenderer fontrenderer;

 

        EntityPlayer p;

 

        NBTTagCompound nbt;

 

 

 

        public GuiChemistryLevel(Minecraft mc) {

 

                super();

 

                fontrenderer = mc.fontRenderer;

 

                // We need this to invoke the render engine.

 

                this.mc = mc;

 

        }

 

 

 

        @ForgeSubscribe(priority = EventPriority.NORMAL)

 

        public void onRenderExperienceBar(RenderGameOverlayEvent event) {

             

 

              p = mc.thePlayer;

              nbt = p.getEntityData();

 

                 

                if (event.isCancelable() || event.type != ElementType.EXPERIENCE) {

 

                        return;

 

                }

 

                int level;

 

                level = nbt.getInteger("level");

 

                if (level == 0) {

 

                        nbt.setInteger("level", 1);

 

                        level = nbt.getInteger("level");

 

                        fontrenderer.drawString("Level " + level, 1, 1, 0xffffffff);

 

                } else {

 

                        fontrenderer.drawString("Level " + level, 1, 1, 0xffffffff);

 

                }

 

 

 

                this.mc.renderEngine.bindTexture("/gui/inventory.png");

 

        }

 

}

 

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • tried it, it worked! Thank you kind stranger. Still a weird bug with that version of forge, but everything works now so it's fine.
    • nosenosenose
    • New to forge modding, I'm currently trying to make a client side only mod that basically just reproduces the numbers for entities in FOV and total entity count shown in the F3 toggle (E: # in fov/# total). Basically just trying to take these numbers and display them in the center of the screen (without having F3 open) so they can be seen constantly.Been primarily learning forge using ChatGPT but it seems to spew out incorrect code over and over again when I ask it how it would do something like this (probably confusing versions and such). Not sure if these numbers can be directly accessed or not or if its more complicated than that.   This is my current code I basically just need to implement the 2 methods at the bottom. Any info/help is appreciated. import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; import net.minecraft.client.Camera; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.culling.Frustum; import net.minecraft.world.entity.Entity; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.RenderGuiOverlayEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraft.world.entity.Entity; import net.minecraft.client.multiplayer.ClientLevel; @Mod.EventBusSubscriber(modid = "myforgehudmod", value = Dist.CLIENT) public class MyCustomHUD { @SubscribeEvent public static void onRenderHUD(RenderGuiOverlayEvent.Post event) { Minecraft minecraft = Minecraft.getInstance(); GuiGraphics guiGraphics = event.getGuiGraphics(); int screenWidth = minecraft.getWindow().getGuiScaledWidth(); int screenHeight = minecraft.getWindow().getGuiScaledHeight(); int totalEntities = countTotalEntities(minecraft); int entitiesInFOV = countEntitiesInFOV(minecraft); String hudText = entitiesInFOV + " / " + totalEntities; int textWidth = minecraft.font.width(hudText); int x = (screenWidth / 2) - (textWidth / 2); int y = screenHeight / 2; y = y + 10; // x,y is directly below crosshair by 10 pixels with centered text guiGraphics.drawString(minecraft.font, hudText, x, y, 0xFFFFFF); } private static int countTotalEntities(Minecraft minecraft) { return 0; } private static int countEntitiesInFOV(Minecraft minecraft) { return 0; } }  
    • Please let me know if there is a good solution: Hey Y'all, sorry to bother you, but I believe I'm getting an error between jurassicworld reborn and jurassicraft when I'm attempting to open my world. The world used to work with both mods active, and so I'm posting here to see why it doesn't work anymore, and if there is a solution to fix it that doesn't include taking out either, as doing that will take out a big part/amount of blocks out of my world. If not, then please let me know. Also, please let me know if more info is needed, as this was all of the crash report that would fit. Thanks for the help, look forward to hearing from you! Crash report Link: https://pastebin.com/K1H0qsmW
    • The game crashed whilst initializing game Error: java.lang.IllegalAccessError: class net.minecraft.client.Options tried to access private field net.minecraft.client.Minecraft.f_91036_ (net.minecraft.client.Options and net.minecraft.client.Minecraft are in module [email protected] of loader 'TRANSFORMER' @4232b34a)    wasnt allowed to put up the whole crash report but i rly want help
  • Topics

×
×
  • Create New...

Important Information

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