Jump to content

simple right-click on item event


FlugRost

Recommended Posts

Hey,

 

Can you tell me how to get the event when right-clicking on an vanilla item. Not a custom one. I don't want to create a new item, I only want to add a feature to the old one.

 

I tried to create this class. But I don't know how to register/add this feature to the normal/old compass.

public class Compass extends ItemCompass {

    public CompassTeleporter() {
        super();
    }

    @Override
    public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
        System.out.println("Test");
    }
}

Link to comment
Share on other sites

That code should be throwing giant red errors at you and shouldn't compile.

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

Well it doesn't compile because your method needs a return value, which you're not doing.

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 mean this: return super.onItemRightClick(itemStackIn, worldIn, playerIn, hand); right?

 

Please ignore my code example :) I only want to show want I had made, I don't think that this is the right way.

Or how to register my class for the normal compass?

Link to comment
Share on other sites

Oh, I misunderstood your original question.

 

You want to add this method to the vanilla compass.

 

Ha. Good luck.

 

Forge is supposed to have a thing called "addSubstitutionAlias" (e.g.

GameRegistry.addSubstitutionAlias("minecraft:stick", GameRegistry.Type.ITEM, itemStickReplacement);

), but as far as anyone has tried, it doesn't work correctly.

 

See: http://www.minecraftforge.net/forum/index.php/topic,35899.msg191091.html#msg191091

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

Oh, I misunderstood your original question.

 

You want to add this method to the vanilla compass.

 

Ha. Good luck.

 

Forge is supposed to have a thing called "addSubstitutionAlias" (e.g.

GameRegistry.addSubstitutionAlias("minecraft:stick", GameRegistry.Type.ITEM, itemStickReplacement);

), but as far as anyone has tried, it doesn't work correctly.

 

See: http://www.minecraftforge.net/forum/index.php/topic,35899.msg191091.html#msg191091

 

Substitution aliases should be fixed now (see this issue), though I still haven't managed to get them working myself. I need to verify this and file a proper bug report at some point.

 

Edit: Reported here.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Froge is to hard for me :D

 

I get an NullPointer when I try to register a command.

 

What I'am doing wrong?

 

    @EventHandler

    public void serverLoad(FMLServerStartingEvent e){

        e.registerServerCommand(new ServerCommand());

    }

 

public class ServerCommand implements ICommand {

 

    @Override

    public String getCommandName() {

        return "compass";

    }

 

    @Override

    public String getCommandUsage(ICommandSender sender) {

        return "/compass";

    }

 

    @Override

    public List<String> getCommandAliases() {

        return null;

    }

 

    @Override

    public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {

        Minecraft.getMinecraft().displayGuiScreen(new GuiServer());

    }

 

    @Override

    public boolean checkPermission(MinecraftServer server, ICommandSender sender) {

        if(sender instanceof EntityPlayer)return true;

        return false;

    }

 

    @Override

    public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos) {

        return null;

    }

 

    @Override

    public boolean isUsernameIndex(String[] args, int index) {

        return false;

    }

 

    @Override

    public int compareTo(ICommand o) {

        return 0;

    }

}

 

[21:28:43] [server thread/ERROR] [FML]: Fatal errors were detected during the transition from SERVER_ABOUT_TO_START to SERVER_STARTING. Loading cannot continue

[21:28:43] [server thread/ERROR] [FML]:

States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

UCHIJAAA mcp{9.19} [Minecraft Coder Pack] (minecraft.jar)

UCHIJAAA FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.10.2-12.18.1.2011.jar)

UCHIJAAA Forge{12.18.1.2011} [Minecraft Forge] (forgeSrc-1.10.2-12.18.1.2011.jar)

UCHIJAAE teleporter{0.1} [teleporter] (frogetele_main)

[21:28:43] [server thread/ERROR] [FML]: The following problems were captured during this phase

[21:28:43] [server thread/ERROR] [FML]: Caught exception from teleporter

java.lang.NullPointerException

at net.minecraft.command.CommandHandler.registerCommand(CommandHandler.java:144) ~[forgeSrc-1.10.2-12.18.1.2011.jar:?]

at net.minecraftforge.fml.common.event.FMLServerStartingEvent.registerServerCommand(FMLServerStartingEvent.java:59) ~[forgeSrc-1.10.2-12.18.1.2011.jar:?]

at de.sambohl.Teleporter.serverLoad(Teleporter.java:28) ~[frogetele_main/:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91]

at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91]

at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:579) ~[forgeSrc-1.10.2-12.18.1.2011.jar:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91]

at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91]

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:235) ~[forgeSrc-1.10.2-12.18.1.2011.jar:?]

at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:213) ~[forgeSrc-1.10.2-12.18.1.2011.jar:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91]

at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91]

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:142) [LoadController.class:?]

at net.minecraftforge.fml.common.Loader.serverStarting(Loader.java:824) [Loader.class:?]

at net.minecraftforge.fml.common.FMLCommonHandler.handleServerStarting(FMLCommonHandler.java:292) [FMLCommonHandler.class:?]

at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:126) [integratedServer.class:?]

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:496) [MinecraftServer.class:?]

at java.lang.Thread.run(Thread.java:745) [?:1.8.0_91]

Link to comment
Share on other sites

Fix #3126 - duplicate stat id error - don't use the "universal iterat…  …

…ors" in statbuilding, use the one without the duplicate entries. (The duplicate entry one is for rendering setup)

 

Do you know what he means?

Is it fixed now?

Link to comment
Share on other sites

Fix #3126 - duplicate stat id error - don't use the "universal iterat…  …

…ors" in statbuilding, use the one without the duplicate entries. (The duplicate entry one is for rendering setup)

 

Do you know what he means?

Is it fixed now?

 

That particular error is fixed, but I've found a new one and reported it here.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

If he just wants to override the right clicking of a vanilla item, not replacing it couldn't he just use events. More specifically the PlayerInteractEvent.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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

    • LINK DAFTAR : KLIK DISINI LINK DAFTAR : KLIK DISINI   Slot deposit bank bsi merupakan salah satu situs slot gacor deposit bank bsi 24 jam mudah maxwin tanpa batas. hari ini slot deposit bank bsi menawarkan bonus terbesar untuk player yang sudah bergabung di situs slot bank bsi ini, dengan ada nya slot bank bsi sanget mempermudah player untuk melakukan transaksi deposit dengan bank bsi. Sebagai Situs Slot Deposit Bank Bsi meyediakan banyak permainan seperti slot online, live casino, sabung ayam, tembak ikan, sportbook semua game tersebuat sangat aman dan terpercaya. Beramin slot bank bsi sangat mudah hanya dengan niminal deposit 5000 ribu saja anda sudah bisa bermain di semua game yang sudah di sediakan oleh situs slot bank bsi. Slot bank bsi adalah saranan untuk Pemain yang mencari pengalaman bermain slot gacor sekarang dapat menemukan metode pembayaran beragam di berbagai situs slot gacor yang tersebar luas di seluruh negeri. Munculnya situs Slot Bank BSI, kini para pemain dapat menikmati kemudahan dan kenyamanan dalam melakukan transaksi pembayaran. Bahkan memungkinkan pemain untuk fokus sepenuhnya pada permainan yang mereka nikmati sepanjang waktu. Ini adalah langkah penting dalam memperluas aksesibilitas judi slot online di Indonesia dan memberikan pengalaman bermain yang lebih baik kepada para pecinta slot gacor.    
    • Sometimes love could be the worst experience. you get to love and trust your partner only to feel regret over it. i have been married for 7 years now and i found some sudden change in my partner attitude, i tried talking about it but he complains i'm nagging a lot . i tried to ignore his attitude but it became unbearable so i was advised to hire a hacker to help me gain access to his phone so i had know if he is cheating or not so i was introduced to [ Remote spy hacker @ g m ail . c o m ] and this expert helped me gain access to his phone without his notice. i got to see his messages, photos, call recordings and many more . Now i can see his cheating and that's the reason for the attitude all along.
    • hola thanks for answering  i set some system outs to test and see whats going on      @Override     protected void saveAdditional( CompoundTag nbt ){                  nbt.put("itemhandler", itemhandler.serializeNBT() );         nbt.putInt("progress", this.progress );         System.out.println("saveAdditional(nbt)");                 System.out.println(NbtUtils.prettyPrint(nbt)); //<-- this is whats getting saved         super.saveAdditional( nbt );     }     @Override     public void load( CompoundTag nbt ){         itemhandler.deserializeNBT( nbt.getCompound("itemhandler") );         this.progress = nbt.getInt("progress" );         System.out.println(NbtUtils.prettyPrint(nbt)); //<-- this is whats minecraft is giving back to the entity          System.out.println("load(nbt)");         super.load( nbt );     }   This dead adventurer body  has two parts a block and a block Item  both has their own item-handlers and their own menus all of that seems fine  Testing remarks : *when i change some element inside the gui  it triggers the saveAdditional(nbt) system out and shows a pretty print of the data being saved  *when the world map loads it triggers the load(nbt) system out and shows a pretty print of the data minecraft is giving to this Block Entity For the testing i gonna set mi BlockEntityBodyBlock, save something in it, close minecraft, fireup the game again and check if the items remain      ################ first try set the block entity (dead adventurer body like shaped) and left only a weath seed  in the slot 10 the console says its all right    close minecraft, launch it again i see the system out whit the data returned to the entity and its look good theres is only a weed seed  ################ Second try, now i gonna change the seed for two arrows  the console says its all right the two arrows are being saved    ######### Now close and run again bam Error  minecraft returns the original data whit only a wheat seed the two arrows has been loss   ########## try again now i gonna put 3 wheat seeds Console system out says it gets it and is saving the data   ############## but after close fire again  wheat seed,  data losed once more time  and it just throw the original   ####################################################################################### sorry for the long post and the crappy video  this is the reason why i say its saving the Block Entity data only when it feels like  coze its saves data when it feels like  ¿ its something wrong whit mi BlockEntity.saveAdditional()  if  i keep trying eventually it updates and the data chages      i alredy try to  level.removeBlockEntity(pos); level.setBlockEntity(pos, bebb);     BlockEntityBodyBlock.class   BlockEntityInit.class     body_blockitem.class                  
    • Yesterday I buy a minecraft server to play with my friends you know... One of my friends send me the list of mods to add and then i start to dowload them, when i add them to the server it start crashing but i don't know about this things because it's my first time buying a minecraft server This is the error: https://paste.ee/p/sJf7B
    • Discovering that a trusted colleague had accessed my Bitcoin account and transferred $30,000 worth of bitcoins was a devastating blow. It shattered the trust I had placed in them and left me feeling vulnerable and betrayed. However, in the face of adversity, I turned to MUYERN TRUST HACKER for assistance in reclaiming control over my finances and holding the perpetrators accountable for their actions. One of the standout features of MUYERN TRUST HACKER was its ability to provide real-time alerts and notifications, keeping me informed every step of the way. With the support of MUYERN TRUST HACKER, I was able to gather irrefutable evidence of the perpetrator's actions and hold them accountable for their crimes. Armed with the information provided by the platform, I pursued legal recourse and ensured that justice was served. The perpetrator faced severe consequences for their actions, including legal penalties and financial restitution. Beyond its role in facilitating the recovery process, MUYERN TRUST HACKER provided me with a sense of empowerment and resilience in the face of adversity. While the experience was undoubtedly challenging, it ultimately served as a testament to the importance of vigilance and the power of technology in safeguarding our digital assets. Thanks to MUYERN TRUST HACKER, I emerged stronger and more resilient, ready to face whatever challenges the future may hold. Mail; muyerntrusted[At] mail-me .c o m
  • Topics

×
×
  • Create New...

Important Information

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