Jump to content

Recommended Posts

Posted

I have an item that applies a passive effect to the player that's carrying it, and I can remove this effect when the item is dropped, but I can't seem to find a spot that will let me know that the item was removed from the player's inventory and placed into another object's inventory.

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.

Posted

I know 2 ways to check if an special Item is inside of the Players Inventory.

 

First way is from the item itself (onUpdate() function).

 

Second way is from an entityliving update handler. with that you should can scan the inventory of the player.

 

I think this shoud be what you are asking. If not explain it in more detail.

 

 

Posted

I want to know when it's NOT in the player's inventory.

 

And scanning every inventory of every player on a server ever tick is not a viable solution.

 

I only need the function called once (the frame that it leaves the player's inventory) but I need something.

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.

Posted

yeah that checking is not a solution. And what is when you add a varibale to a player has The item in the inventory and then the living handler search only at these players who have this variable. Would that be a way?

Posted

I'm not sure that's all that viable either, as these effects are unique (each has a separate UUID for the SharedMonsterAttribute system, so that they stack), so I need to remove exactly the one that was placed into the chest.

 

I'd have to add several flags to every player. :\  If they have any, then I need to loop through their entire inventory and verify each one.

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.

Posted

Whenever one of these items is added to a player's inventory, store its UUID in a Map in IExtendedEntityProperties or someplace. Then, either find a way to inject code (ASM?) or edit base classes so that the InventoryPlayer checks for your Item onInventoryChanged, decrStackSize etc. and before setting the itemstack to null, remove its UUID from the map. That's the only way I can think of that wouldn't require doing lots of checks every tick.  :-\

Posted

Moritz and I found a solution that works well enough:

 

onUpdate, if the player has an inventory open, remove effect.  So the effect is suppressed while they're looking in a chest.

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.

Posted

I got another problem for you. What happends when the player (standart keybinding) is Pressing Q? (Means drop a item in your hand)

 

It gets tossed into the world as an EntityItem, and because THAT receives updates, it's easy to go "oh, hey, I've been dropped.  Hey NBT, what was the player's entity ID?"

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.

Posted

You can also use the ItemTossEvent.

 

Because of the way my items are built, I'm already using the EntityItemUpdate function (as there are effects which use it) so tying into that isn't difficult and keeps everything inside my Item class.

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.

Posted
.  Putting items into item frames doesn't trigger any kind of function either!  And doing that doesn't require opening a GUI!

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.

Posted

That will be triggered before the block trigger the putItemin function^^"

 

Actually, it's not.  I checked.

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.

Posted

Well if it's triggered after, you could check if the block being right clicked on is an Item Frame (or were Item Frame entities?), and then get the stored item from its TileEntity.

 

But even if this works, you still have the problem that this is not very reliable. You might have missed other vanilla features or other mods could easily add other features that take an item from your inventory by right clicking on something.

Author of PneumaticCraft, MineChess, Minesweeper Mod and Sokoban Mod. Visit www.minemaarten.com to take a look at them.

Posted

I think the problem is how you are doing your effect on the item.

It is bringing a lot of stupid issues because of this.

 

Edit: You could use the EntityInteractEvent and check for EntityItemFrame.

Posted

Well if it's triggered after, you could check if the block being right clicked on is an Item Frame (or were Item Frame entities?), and then get the stored item from its TileEntity.

 

It's not triggered before OR after, none of the item's functions are called.

 

I think the problem is how you are doing your effect on the item.

It is bringing a lot of stupid issues because of this.

 

How would you make an item that gives the player bonus health while they are carrying it?

 

Edit: You could use the EntityInteractEvent and check for EntityItemFrame.

 

I am trying to do this without events, but if I have to for this case I will.

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.

Posted

Hi.

 

Just a suggestion - if it's too expensive to check the inventory every tick, why not check (say) every 20 ticks.  A delay of 1 second will probably be unnoticeable to the player I imagine, depending on what "effect" you are applying.  Even if it is noticeable, perhaps you can turn it into a feature (eg - "the unholy aura effect lasts for 10 seconds after you throw away the skull of putrescence", or similar).

 

And to be honest I doubt it really takes that much extra time to check a player's inventory slots for a particular item ID.  You could try it with a profiler and see if it is a significant slowdown or not.

 

All the other solutions sound a bit fragile to me.

 

Cheers

  TGG

 

Posted
And to be honest I doubt it really takes that much extra time to check a player's inventory slots for a particular item ID

 

And then read that item's NBT data. :|

This isn't "oh, Item ID 1322 increases your health" it "Item ID 1322 {["onOwned":"increaseHealth"}]" vs. "Item ID 1322 {["onOwned":"increaseSpeed"}]" vs. "Item ID 1322 {["onUpdate":"heal1"}]" vs. "Item ID 1322 {["onRightClick":"causeLightning"}]" vs....

 

Anyway, if we're going to call things features, I think it would be a more interesting "feature" that items in frames are permanent boosts. :P

It's like a litch's phylactery!

 

It just isn't meaningful in SSP: no one can try and sneak into your base and "destroy" your powerbase.

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.

Posted

Now there's an idea for a mod :)

 

You mean the one I'm working on?

 

At last check I have over 67 million different items which may or may not have enchantments.

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.

Posted

Lol draco, I'm giving you cred++; just for the signature you have on MCF there, nice one :)

 

My signature arose from the fact that I tried to kindly remind someone that they shouldn't post in mod threads about updates.  I was all "hey, I just found out myself, but your post is technically against the TOS, didn't want to get you in trouble, just thought I'd let you know."

Someone decided I was being a total asshat.

Flames ensued.

 

I ended up reporting my own post to the mods for calling myself an asshole.

 

So I created my signature in an effort to deter such events in the future.

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.

Posted

Did you solve the problem with the itemframe alread? If not there should be a function which is called onInteractWithEntity(ItemStack par1, EntityPlayer player, EntityLivingBase par3)

{}

 

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

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

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