Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

RBHB16

Members
  • Joined

  • Last visited

Everything posted by RBHB16

  1. I've moved onto adding more code and I am stuck again... I am thinking about making a GUI for the cell phone when the player holds the item and right clicks. I think everything works up until I try to check to see if the player right clicked. I am going to add another event to check if the player right clicked the item while looking at a block, since I am limited to either checking to see if the player right clicked in the air or right clicked looking at a block. This is what I have so far: Also, any help is appreciated
  2. Hmmm. Well I tried that and ran a debug. It seems that when I hold the cell phone, the event is registered, but once it gets to that if(hand != null), the result is always null and doesn't move on to the other if statements even if I am holding the cell phone. Not sure what is causing this to happen.. could it be because its a custom item?
  3. I do know what a static reference is. Basically having something as static lets you use it all over without instantiating it. Update: I was able to create an if statement, but I get an error when holding the "cell phone" The code: The error:
  4. Don't worry about that, it was from when I first started working on the event. I used to have a class called phones but got rid of it and made an events class instead and never removed it.
  5. Thanks for the response. I changed up the code a little, but now the problem is it is saying I cannot make a static reference to a non-static method, so what I did was make an instance of my items class so I can call cell phone into the if statement. I still am getting the error, so does that mean I need to fix up my items class to make cell_phone non static? package me.redstery11.dm; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class Events { public _Items c = new _Items(); @SubscribeEvent public void onRightClick(PlayerInteractEvent e) { EntityPlayer p = e.getEntityPlayer(); if(p.inventory.getCurrentItem() != null) { if(EntityItem.getEntityItem().getItem().equals(c.cell_phone)) { p.setFire(5); } } } }
  6. Hey guys, I am trying to make an event as a test to see if I am properly firing events. I am new to forge so it is throwing me off a little. I am not sure if I am just using the wrong event (playerinteractevent) and I should use a different one, or I just didn't do something in initializing my event or whatever it would be. If someone could help, that'd be great. CommonProxy class(I link it with my main, so the info is in proxies but is called by the main): package me.redstery11.dm.proxy; import me.redstery11.dm.Events; import me.redstery11.dm.Recipies; import me.redstery11.dm._Items; import me.redstery11.dm.theItems.Phone; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; public class CommonProxy { Events handler = new Events(); @EventHandler public void preInit(FMLPreInitializationEvent e) { MinecraftForge.EVENT_BUS.register(handler); _Items.preinit(); } @EventHandler public void Init(FMLInitializationEvent e) { Recipies.init(); MinecraftForge.EVENT_BUS.register(new Phone()); } @EventHandler public void postInit(FMLPostInitializationEvent e){ } } The events class: The first problem I came up with was that an Itemstack cannot be compared to an item, so I went around it, but I am not sure if that worked. package me.redstery11.dm; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class Events { @SubscribeEvent public void onRightClick(PlayerInteractEvent e) { EntityPlayer p = e.getEntityPlayer(); if(p.inventory.getCurrentItem() != null) { if(p.inventory.getCurrentItem() == new ItemStack(_Items.cell_phone)) { p.setFire(5); } } } }

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.