-
1.8 - How to update a count based on the amount of an item in inv
Alright, I've to some degree started from scratch. I realized that I was off to a bad start, and hope I've started to get back on track... I didn't have Client/Common proxy classes before :l I made a new class, which basically does the same thing as the last, and I THINK should work (or with a small amount of bug fixing), however for some reason event.entity isn't being recognized, and I don't know why. Here is my new class (with imports just to clarify it dosen't have anything to do with that): import highrez.rezhigh.lib.Constants; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import static net.minecraft.init.Items.diamond; @SideOnly(Side.CLIENT) public class RenderTickHandler extends Gui{ /** Stores an instance of Minecraft for easy access */ private Minecraft mc; String text; // create a constructor that takes a Minecraft argument; now we have it whenever we need it public RenderTickHandler(Minecraft mc) { this.mc = mc; } @SubscribeEvent public void onRenderTick(TickEvent.RenderTickEvent event) { //Creates needed stuff ScaledResolution scaled = new ScaledResolution(mc); int width = scaled.getScaledWidth(); int height = scaled.getScaledHeight(); //Writes at the top left to start a list of sorts drawCenteredString(mc.fontRendererObj, "Needed:", width - 40, 10, Integer.parseInt("c40600", 16)); //For loop to print the diffrent list elements for (int i = 0; i <= Constants.LISTLENGTH-1; i++) { text = "(0/" + Constants.AMMOUNT.get(i) + ") " + Constants.ITEMS.get(i); drawCenteredString(mc.fontRendererObj, text, width - 40, 10*i+20, Integer.parseInt("FFFFFF", 16)); } } @SubscribeEvent public void PlayerTickeEvent(TickEvent.PlayerTickEvent event) { if (event.entity instanceof EntityPlayerMP) { EntityPlayerMP player = (EntityPlayerMP) event.entity; InventoryPlayer inventory = player.inventory; if (inventory.hasItem(diamond)) { for (int i = 0; i <= Constants.LISTLENGTH-1; i++) { text = "(1/" + Constants.AMMOUNT.get(i) + ") " + Constants.ITEMS.get(i); } } } } } Thanks for your help.
-
1.8 - How to update a count based on the amount of an item in inv
Thank you for your time and help. 1. Only piece of your advice I'm rejecting Not happening. I want this for 1.8.9, it's not otherwise useful to me.'' 2. Thanks! Trying to get this to work, will update if it doesn't. 3. Oof, yes I started writing something that changed the color of the text earlier, and realized this but didn't update it here. Thanks for the reminder! 4. Oops, thank you. To be honest I don't totally understand this idea/proxy's in mods, but I'm sure I can figure it out. Thanks again. 5. Thanks one last time! I haven't used constructors much, and don't know there proper use really, I'll make sure to do this.
-
1.8 - How to update a count based on the amount of an item in inv
Hello! I've recently started modding, and am running into a problem. I'm trying to make a mod that basically sets a goal for an item, and displays the amount currently in the inventory of the player. This is what my code looks like right now: String text; @SubscribeEvent public void LivingUpdateEvent(LivingEvent.LivingUpdateEvent event) { if (event.entity instanceof EntityPlayerMP) { EntityPlayerMP player = (EntityPlayerMP) event.entity; InventoryPlayer inventory = player.inventory; if (inventory.hasItem(diamond)) { for (int i = 0; i <= Constants.LISTLENGTH-1; i++) { text = "(1/" + Constants.AMMOUNT.get(i) + ") " + Constants.ITEMS.get(i); } } } } public GuiNotif(Minecraft mc) { //Creates needed stuff ScaledResolution scaled = new ScaledResolution(mc); int width = scaled.getScaledWidth(); int height = scaled.getScaledHeight(); //Writes at the top left to start a list of sorts drawCenteredString(mc.fontRendererObj, "Needed:", width - 40, 10, Integer.parseInt("c40600", 16)); //For loop to print the diffrent list elements for (int i = 0; i <= Constants.LISTLENGTH-1; i++) { text = "(0/" + Constants.AMMOUNT.get(i) + ") " + Constants.ITEMS.get(i); drawCenteredString(mc.fontRendererObj, text, width - 40, 10*i+20, Integer.parseInt("FFFFFF", 16)); } } This isn't working/is incorrect. I'm assuming that the problem lays in the if inventory has diamond line, but I don't fully understand what isn't working here. On top of this, this was just a start - I also need to make it so that if there is more than one diamond in the inventory (in a stack/or not) that is added to the count, and would appreciate help on that aswell if anyone is willing. Thanks! -Rez
IPS spam blocked by CleanTalk.