Hi!
I'm new in Minecraft modding and currently trying to make my first mod.
So, the server sends to players some random numbers from 1 to 7 to their title bar. If there's currently "6" or "7" at the player's screen, the mod should simulate right-clicking at the held thing in the player's hand. I've tried to write some lines of code but the mod does nothing. There are the lines of my code:
public static String getCurrentTitle(FML) {
try {
String title = (String) ReflectionHelper.findField(GuiIngame.class, "displayedTitle", "field_175201_x").get(Minecraft.getMinecraft().ingameGUI);
return title;
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return null;
}
public static void rightClick(World worldIn, EntityPlayer player, EnumHand handIn){
if (getCurrentTitle() == "7" || getCurrentTitle() == "6") {
ItemStack I = player.getHeldItem(handIn);
I.useItemRightClick(worldIn, player, handIn);
}
}
The first function I just copypasted from web, the other one I've written by myself. I'm new at this and honestly don't understand how it should be. So I need some help.
The version is 1.12.2 if it makes a difference.
Thankfully,
- axyqu.