So, I am making a 1.8 PvP mod, and I am trying to make 2 overlays. The first, simplest one is a number showing the amount of health pots you have. I am trying to make the overlay say "Hello World!" and in the center of the screen, just to get it working, and it doesn't seem to render correctly. I don't know if there is something i'm missing with rendering, as I was following a 1.7 tutorial, and there was an outdated method, or something with it changed (getNotif(minecraft.Minecraft))
My Main class:
package PvPHelper;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
@Mod(name="PvPHelper", modid="pvphelper", version="1.0", acceptedMinecraftVersions="[1.8, 1.8.8, 1.8.9]")
public class PvPHelper {
@Instance
public static PvPHelper instance = new PvPHelper();
@Mod.EventHandler
public void preinit(FMLPreInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(new PotionCounterRender());
}
}
Gui Overlay Class:
package PvPHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
public class PotionCounter extends Gui {
public PotionCounter(Minecraft mc)
{
String text = "Hello world!";
ScaledResolution scaled = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
int width = scaled.getScaledWidth();
int height = scaled.getScaledHeight();
drawCenteredString(mc.fontRendererObj, text, width / 2, (height / 2) - 4, Integer.parseInt("FFAA00", 16));
}
}
I have a renderer class in it, but there is no code in it because I couldn't find a method for it. Any help appreciated!
Thanks for responding, I forgot to put those in my post but thanks for telling me to subscribe to RenderGameOverlayyEvent, thats what I need. Yes it wasn't rendering at all, but now its working. Follow up question, how do I count the amount of potions a player has? I was checking out some other mods and found this:
public static int getPotionsFromInventory()
{
int count = 0;
ItemStack is; for (int i = 1; i < 45; i++) {
Slot slot = func_71410_xfield_71439_g.field_71069_bz.func_75139_a(i);
if ((slot.func_75216_d()) && ((slot.func_75211_c().func_77973_b() instanceof ItemPotion)))
{
is = slot.func_75211_c();
ItemPotion potion = (ItemPotion)is.func_77973_b();
if (potion.func_77832_l(is) != null)
{
for (net.minecraft.potion.PotionEffect effect : potion.func_77832_l(is))
if ((effect.func_76456_a() == field_76432_hfield_76415_H) &&
(ItemPotion.func_77831_g(is.func_77960_j())))
{
count++; } }
}
}
return count;
}
public static String getText() {
int pots = getPotionsFromInventory();
return pots + " §cpot" + (pots != 1 ? "s" : "");
}
But it seems that there are no functions called func_71410_x, func_75216_d, etc...
So, first of all, thanks for the help, I really appreciate it. So I have been working on it, and think I have returned the player's inventory, but for some reason
Item.ItemPotion
Won't work :,( It says ItemPotion can't be resolved or isn't a field.
Also, is my code for running through the inventory correct, at this point it's kinda turning into gibberish.
package PvPHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class PotionCount {
public static int getPotionsFromInventory(EntityPlayer player, ItemStack itemStack, InventoryPlayer inventory, Item item)
{
int count = 0;
for (int i; i < 36; ++i)
{
ItemStack stack = player.inventory.mainInventory[i];
if (stack != null && stack.getItem() == Item.ItemPotion) count += stack.stackSize;
}
}
}
Personally, I am pretty new and would like to know like the methods for doing this. There are just 2 things I am confused about, how to get the item in a certain slot, like I saw this: if(mc.thePlayer.inventory.getStackInSlot(i) == ItemPotion), but it is for an older version, how could I do that in 1.8? Also, how would I cycle through the slots, like a loop? Sorry if it seems like I am kinda not doing any of the code, but I am new and clueless xD
These are obfuscated names of some methods. You can search their name for the version you are using manually in mappings, or you can use the mcpbot.
Simply, you should iterate through the player's inventory. You could get InventoryPlayer from EntityPlayer and then iterate through the mainInventory. Ten you would check if the ItemStack is not null and if the item is an instance of ItemPotion and if so you can iterate through effects the ItemStack has , and do any actions you need.
How would I do this? that's my question.(Hate to bump this, but I'm about to go to sleep and would like to make some leeway. I have been working on it a bit but no luck.) Also, the mcpbot isn't working, so. yeah.
Also still can't get the Item.Itempotion to work, here is my new code:
package PvPHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class PotionCount {
public static int getPotionsFromInventory(EntityPlayer player, ItemStack itemStack, InventoryPlayer inventory, Item item)
{
int count = 0;
for (int i; i < 36; ++i)
{
ItemStack stack = player.inventory.mainInventory[i];
if (stack != null && stack.getItem() == Item.ItemPotion) count += stack.stackSize;
}
}
}
I tried using net.minecraft.init.items but still the same error :/ also this is meant to be used on servers like hypixel and not in like modpacks so I doubt that there would be any noticeable compatibility conflicts with this, I am only concerned in like not making it kill my FPS or ping xD. Also, how would I use instanceof? would it go into the If, or somewhere else? also what syntax would I use with it? sorry i'm a bit clueless. Also 44 minutes after I posted xD
So, I think i've accomplished what I wanted to do, but now the potion counter isn't rendering(it is not showing on the screen at all). I believe the problem is the potion counter is never returning anything, because regular strings work. Here is some of my code:
Main class:
package PvPHelper;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
@Mod(name="PvPHelper", modid="pvphelper", version="1.0", acceptedMinecraftVersions="[1.8, 1.8.8, 1.8.9]")
public class PvPHelper {
@Instance
public static PvPHelper instance = new PvPHelper();
@Mod.EventHandler
public void preinit(FMLPreInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(new PotionCounterRender());
}
}
The Potion Counter class:
package PvPHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class PotionCounter extends Gui {
public PotionCounter(Minecraft mc, EntityPlayer player, ItemStack itemStack, InventoryPlayer inventory, Item item)
{
String text = PotionCount.getText(player, itemStack, inventory, item);
ScaledResolution scaled = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
int width = scaled.getScaledWidth();
int height = scaled.getScaledHeight();
drawCenteredString(mc.fontRendererObj, text, width / 2, (height / 2) - 4, Integer.parseInt("FFAA00", 16));
}
public PotionCounter(Minecraft minecraft) {
}
}
Potion Counter Renderer:
package PvPHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
public class PotionCounterRender extends GuiScreen {
@SubscribeEvent
public void onRenderGui(RenderGameOverlayEvent.Post event) {
if (event.type != ElementType.EXPERIENCE) return;
new PotionCounter(Minecraft.getMinecraft());
}
}
The main class for the overlay:
package PvPHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class PotionCounter extends Gui {
public PotionCounter(Minecraft mc, EntityPlayer player, ItemStack itemStack, InventoryPlayer inventory, Item item)
{
String text = PotionCount.getText(player, itemStack, inventory, item);
ScaledResolution scaled = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
int width = scaled.getScaledWidth();
int height = scaled.getScaledHeight();
drawCenteredString(mc.fontRendererObj, text, width / 2, (height / 2) - 4, Integer.parseInt("FFAA00", 16));
}
public PotionCounter(Minecraft minecraft) {
}
}
Great idea, can't believe I didn't think of it, trying it now.
I put it in the PotionCounter in the for loop, right before the register overlay event, and one after the count string to return count. None of them outputted to the eclipse console for some reason .-.
You have any idea what's wrong? I did System.out.println("Test1"); and I changed the string from PotionCount.getText to PotionCount.getText + "hi" so it would have a word no matter what, meaning its just not rendering.
EDIT: I tried adding the parameters to the New PotionCounter, and now it crashes.
Crash Report:
[16:09:24] [Client thread/INFO] [FML]: Injecting itemstacks
[16:09:24] [Client thread/INFO] [FML]: Itemstack injection complete
[16:09:24] [Client thread/ERROR] [FML]: Fatal errors were detected during the transition from PREINITIALIZATION to INITIALIZATION. Loading cannot continue
[16:09:24] [Client thread/ERROR] [FML]:
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
UCH mcp{9.05} [Minecraft Coder Pack] (minecraft.jar)
UCH FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8-11.14.4.1563.jar)
UCH Forge{11.14.4.1563} [Minecraft Forge] (forgeSrc-1.8-11.14.4.1563.jar)
UCE pvphelper{1.0} [PvPHelper] (bin)
[16:09:24] [Client thread/ERROR] [FML]: The following problems were captured during this phase
[16:09:24] [Client thread/ERROR] [FML]: Caught exception from pvphelper
java.lang.IllegalArgumentException: Method public void PvPHelper.PotionCounterRender.onRenderGui(net.minecraftforge.client.event.RenderGameOverlayEvent$Post,net.minecraft.entity.player.EntityPlayer,net.minecraft.item.ItemStack,net.minecraft.entity.player.InventoryPlayer,net.minecraft.item.Item) has @SubscribeEvent annotation, but requires 5 arguments. Event handler methods must require a single argument.
at net.minecraftforge.fml.common.eventhandler.EventBus.register(EventBus.java:72) ~[forgeSrc-1.8-11.14.4.1563.jar:?]
at PvPHelper.PvPHelper.preinit(PvPHelper.java:16) ~[bin/:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131]
at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:553) ~[forgeSrc-1.8-11.14.4.1563.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131]
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?]
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) ~[forgeSrc-1.8-11.14.4.1563.jar:?]
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190) ~[forgeSrc-1.8-11.14.4.1563.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131]
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?]
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:119) [LoadController.class:?]
at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:550) [Loader.class:?]
at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:249) [FMLClientHandler.class:?]
at net.minecraft.client.Minecraft.startGame(Minecraft.java:446) [Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:356) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131]
at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]
at GradleStart.main(Unknown Source) [start/:?]
[16:09:24] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:663]: ---- Minecraft Crash Report ----
// Surprise! Haha. Well, this is awkward.
Time: 9/24/17 4:09 PM
Description: Initializing game
java.lang.IllegalArgumentException: Method public void PvPHelper.PotionCounterRender.onRenderGui(net.minecraftforge.client.event.RenderGameOverlayEvent$Post,net.minecraft.entity.player.EntityPlayer,net.minecraft.item.ItemStack,net.minecraft.entity.player.InventoryPlayer,net.minecraft.item.Item) has @SubscribeEvent annotation, but requires 5 arguments. Event handler methods must require a single argument.
at net.minecraftforge.fml.common.eventhandler.EventBus.register(EventBus.java:72)
at PvPHelper.PvPHelper.preinit(PvPHelper.java:16)
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 net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:553)
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.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190)
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.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:119)
at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:550)
at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:249)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:446)
at net.minecraft.client.Minecraft.run(Minecraft.java:356)
at net.minecraft.client.main.Main.main(Main.java:117)
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 net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
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 net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
at GradleStart.main(Unknown Source)
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
-- Head --
Stacktrace:
at net.minecraftforge.fml.common.eventhandler.EventBus.register(EventBus.java:72)
at PvPHelper.PvPHelper.preinit(PvPHelper.java:16)
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 net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:553)
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.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190)
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.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:119)
at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:550)
at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:249)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:446)
-- Initialization --
Details:
Stacktrace:
at net.minecraft.client.Minecraft.run(Minecraft.java:356)
at net.minecraft.client.main.Main.main(Main.java:117)
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 net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
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 net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
at GradleStart.main(Unknown Source)
-- System Details --
Details:
Minecraft Version: 1.8
Operating System: Windows 10 (amd64) version 10.0
Java Version: 1.8.0_131, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 751293792 bytes (716 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v9.10 FML v8.0.99.99 Minecraft Forge 11.14.4.1563 4 mods loaded, 4 mods active
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
UCH mcp{9.05} [Minecraft Coder Pack] (minecraft.jar)
UCH FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8-11.14.4.1563.jar)
UCH Forge{11.14.4.1563} [Minecraft Forge] (forgeSrc-1.8-11.14.4.1563.jar)
UCE pvphelper{1.0} [PvPHelper] (bin)
Loaded coremods (and transformers):
GL info: ' Vendor: 'Intel' Version: '4.4.0 - Build 20.19.15.4463' Renderer: 'Intel(R) HD Graphics 5500'
Launched Version: 1.8
LWJGL: 2.9.1
OpenGL: Intel(R) HD Graphics 5500 GL version 4.4.0 - Build 20.19.15.4463, Intel
GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.
Using VBOs: No
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Packs: []
Current Language: English (US)
Profiler Position: N/A (disabled)
[16:09:25] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:663]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\Me\Desktop\1.8 Modding\run\.\crash-reports\crash-2017-09-24_16.09.24-client.txt
Ok so my referenced libraries got messed up somehow and now it can't find InventoryPlayer or inventory. It also can't find ElementType.EXPERIENCE(Fixed the ElementType, wrong import)
It says that it cannot make a Static reference to a non-static field, also I did
public static int getPotionsFromInventory(Minecraft.getMinecraft) {
For no reason, and it said that I need a variableDeclaratorld to complete FormalPerimeterList, and
public static int getPotionsFromInventory(Minecraft.getMinecraft()) {
gives me syntax error on token(s), misplaced construct(s)
I also cannot put in like (InventoryPlayer inventory) because it's marked to a method subscribing to an event.
I tried inventory instead of InventoryPlayer, but no luck with getting it to work. It is a package so I tried IInventory and PlayerInventory but Idk how to use i with them. I probably need to use them though, so any help with them would be appreciated.
Ok, I get what you mean, I knew I needed one, but how would I add one in. Sorry if I am just derping on Java, but like give me an example of how I would do it? would I do this:
public class PotionCount {
public static int getPotionsFromInventory() {
int count = 0;
for (int i = 0; i < 36; ++i)
{
public void Variable(EntityPlayer player, InventoryPlayer inventory) {
ItemStack stack = player.inventory.mainInventory<em>;
if (stack != null && stack.getItem() == Items.potionitem) count += stack.stackSize;
System.out.println("Test1");
}
}
return count;
}
public static String getText() {
int pots = getPotionsFromInventory();
return pots + " §cpot" + (pots != 1 ? "s" : "");
}
}</em>
Sorry for bad spacing and like bad organization but I don't really know how, I just wanted to post this, hope you understand I know I won't actually use
So, I am making a 1.8 PvP mod, and I am trying to make 2 overlays. The first, simplest one is a number showing the amount of health pots you have. I am trying to make the overlay say "Hello World!" and in the center of the screen, just to get it working, and it doesn't seem to render correctly. I don't know if there is something i'm missing with rendering, as I was following a 1.7 tutorial, and there was an outdated method, or something with it changed (getNotif(minecraft.Minecraft))
My Main class:
Gui Overlay Class:
I have a renderer class in it, but there is no code in it because I couldn't find a method for it. Any help appreciated!
Thanks for responding, I forgot to put those in my post but thanks for telling me to subscribe to RenderGameOverlayyEvent, thats what I need. Yes it wasn't rendering at all, but now its working. Follow up question, how do I count the amount of potions a player has? I was checking out some other mods and found this:
But it seems that there are no functions called func_71410_x, func_75216_d, etc...
So, first of all, thanks for the help, I really appreciate it. So I have been working on it, and think I have returned the player's inventory, but for some reason
Item.ItemPotion
Won't work :,( It says ItemPotion can't be resolved or isn't a field.
Also, is my code for running through the inventory correct, at this point it's kinda turning into gibberish.
Personally, I am pretty new and would like to know like the methods for doing this. There are just 2 things I am confused about, how to get the item in a certain slot, like I saw this: if(mc.thePlayer.inventory.getStackInSlot(i) == ItemPotion), but it is for an older version, how could I do that in 1.8? Also, how would I cycle through the slots, like a loop? Sorry if it seems like I am kinda not doing any of the code, but I am new and clueless xD
How would I do this? that's my question.(Hate to bump this, but I'm about to go to sleep and would like to make some leeway. I have been working on it a bit but no luck.) Also, the mcpbot isn't working, so. yeah.
Also still can't get the Item.Itempotion to work, here is my new code:
I tried using net.minecraft.init.items but still the same error :/ also this is meant to be used on servers like hypixel and not in like modpacks so I doubt that there would be any noticeable compatibility conflicts with this, I am only concerned in like not making it kill my FPS or ping xD. Also, how would I use instanceof? would it go into the If, or somewhere else? also what syntax would I use with it? sorry i'm a bit clueless. Also 44 minutes after I posted xD
So, I think i've accomplished what I wanted to do, but now the potion counter isn't rendering(it is not showing on the screen at all). I believe the problem is the potion counter is never returning anything, because regular strings work. Here is some of my code:
Main class:
The Potion Counter class:
Potion Counter Renderer:
The main class for the overlay:
Great idea, can't believe I didn't think of it, trying it now.
I put it in the PotionCounter in the for loop, right before the register overlay event, and one after the count string to return count. None of them outputted to the eclipse console for some reason .-.
You have any idea what's wrong? I did System.out.println("Test1"); and I changed the string from PotionCount.getText to PotionCount.getText + "hi" so it would have a word no matter what, meaning its just not rendering.
So, how would I fix this?
EDIT: I tried adding the parameters to the New PotionCounter, and now it crashes.
Crash Report:
Yeah it was stupid to add in params, I knew it crashed from them, but now I almost got everything working, except one line
This is from my potion count class:
It can't find InventoryPlayer from EntityPlayer.InventoryPlayer.mainInventory[i];
it says it cant be resolved or is not a field. Here is the rest of my code:
Main Class (Idk why not):
PotionCounterRenderer:
The Overlay's class (PotionCounter):
Hope you know whats wrong.
Ok so my referenced libraries got messed up somehow and now it can't find InventoryPlayer or inventory. It also can't find ElementType.EXPERIENCE(Fixed the ElementType, wrong import)
For some reason when I put
GetPotionsFromInventory(EntityPlayer player, InventoryPlayer inventory) {
It seems to work with
ItemStack stack = player.inventory.mainInventory[i][i];[/i]
but with
GetPotionsFromInventory() {
and
ItemStack stack = EntityPlayer.InventoryPlayer.mainInventory[i][i];[/i]
It can't find InventoryPlayer, I tried doing
GetPotionsFromInventory(InventoryPlayer inventory) {
And
ItemStack stack = EntityPlayer.inventory.mainInventory[i];
It says that it cannot make a Static reference to a non-static field, also I did
public static int getPotionsFromInventory(Minecraft.getMinecraft) {
For no reason, and it said that I need a variableDeclaratorld to complete FormalPerimeterList, and
public static int getPotionsFromInventory(Minecraft.getMinecraft()) {
gives me syntax error on token(s), misplaced construct(s)
I also cannot put in like (InventoryPlayer inventory) because it's marked to a method subscribing to an event.
I tried inventory instead of InventoryPlayer, but no luck with getting it to work. It is a package so I tried IInventory and PlayerInventory but Idk how to use i with them. I probably need to use them though, so any help with them would be appreciated.
Ok, I get what you mean, I knew I needed one, but how would I add one in. Sorry if I am just derping on Java, but like give me an example of how I would do it? would I do this:
Sorry for bad spacing and like bad organization but I don't really know how, I just wanted to post this, hope you understand I know I won't actually use
public void variable() {
it will be something else but I don't know.
Oh yeah, GitHub: https://github.com/BigBadE/PvPHelper/tree/master/PvPHelper
Thanks! It wat the Minecraft.getMinecraft().thePlayer that I needed, I didn't know that EntityPlayer worked with that! now its working like a charm
Follow up, I want this to be called every time the inventory is updated, what would I use?
How do I get the potions icon in the inventory?