Jump to content

[1.7.10] Is there a way to register an item as acceptable in a beacon slot?


Recommended Posts

Posted

I am working on a mod called "MINERSCROLLS - Reloading Minecraft (MSRM)" by Karrotsmuthi, and I am currently adding new ingots and blocks to the mod. However, I am having trouble with beacon blocks. I found out how to add blocks to the base of the beacon and have then be accepted by the beacon(thus 'lighting' the beacon), but now I need a way to add items to the acceptable item list for the beacon slot(the slot that you put emeralds, iron, gold, diamond, etc in). Does anyone know how to do this, or can it be done yet? Thanks for reading,

 

-Brian_Entei

Posted

Yeah, I was afraid of that, it's also hard coded in TileEntityBeacon.class as well...

 

What if forge added a hook for adding items to the hard coded list? It would go something like this:

 

 

 

    private ArrayList<Item> validItems = new ArrayList<Item>();

    public TileEntityBeacon registerBeaconSlotItem(Item item)

    {

        this.validItems.add(item);

        return this;

    }

 

    public TileEntityBeacon unregisterBeaconSlotItem(Item item)

    {

        this.validItems.remove(item);

        return this;

    }

    public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_)

    {

        for (Item item : this.validItems)

        {

            if (p_94041_2_.getItem() == item)

            {

                return true;

            }

        }

        return p_94041_2_.getItem() == Items.emerald || p_94041_2_.getItem() == Items.diamond || p_94041_2_.getItem() == Items.gold_ingot || p_94041_2_.getItem() == Items.iron_ingot;

    }

 

 

Posted

what if those items that could be used if list is > then default size cycle through the list of icons to display.

 

//The four vanilla defaults

0 = emerald, 1 = diamond, 2 = gold ingot, 3 = iron ingot.

4 = custom ingot, 5 = custom gem, 6 = custom nugget

 

Displays like this:

0,1,2,3

advance the list by one every few seconds , bot too fast

1,2,3,4

2,3,4,5

3,4,5,6

4,5,6,0

5,6,0,1

and then over and over, just keep cycling thought the list of what can be used.

 

EDIT:

hope my suggestion has not angered anyone with me butting in.

Posted

oh, I just thought you were referring to only the displays and somewhere in the back there was a list of "what is allowed in this slot, and be used" so modders would just need to add somewhere "beaconBase.getItemUseList.add(mycustomItem/new ItemStack(myCustomItem,1,0))" or what have you

 

So apologies I thought the GUI was just displaying an IIcon from the list of accepted items.

Posted

Hmm... I hadn't thought about the gui. What if it were a sort of list like hugo suggested, but instead of scrolling through the list automatically, the player can click on left and right arrows that are the same as the ones that are used in the villager trading gui? And instead of having a list in the beacon/tileEntityBeacon classes you could create two boolean methods in the Item class called "public boolean isBeaconItem() {return false;(default)}" and "public Item setIsBeaconItem(boolean isBeaconItem) {this.isBeaconItem = isBeaconItem;}" (or something of the like). That way users could make new items and call "this.customItem = (new CustomItem()).setIsBeaconItem(true).setCreativeTab(... etc" or whatever they would need to do. But if it were done that way, there would be no 'list' of valid items, just a lot of potential item candidates... hmmm. Thoughts?

Posted

Yea, I see.. hrrmm. Okay, so what if we go ahead and add in the code for accepting the items while we come up with ideas for the gui? Or are you maybe wanting to do it all at once? If so, that's fine too, I'm still going to be looking into the gui issue either way.

 

Hey... Just a thought. What if we remove the items from the beacon gui, but in their place leave a button that would open a different gui that could better fit said hypothetical list of items? I don't think that would fix the list issue, but it would be better than having an incomplete assortment of item iicons being rendered on the beacon gui container. May have to sleep on this one.

Posted

OR! What if the items are only added to the list after you've tried them in the beacon slot! Item crafting/used stat style, you know, once you come into contact with the item, it shows up in the statistics page? What if something similar were done with the beacon? And the default iron, gold, diamond, emerald, etc items would already be in the beacon gui(or beacon gui's new window or what have you) since everyone knows that you can use those.

Posted

Ohh, okay. So forget the list, keep the boolean methods? I just think that there should be a way to register an itemstack as valid payment for the beacon. Maybe like you said it would be okay to leave the beacon gui alone since I guess there's not really a way to add a bunch of item icons to it without changing the "vanilla"-ness of it. As for metadata, wouldn't checking the itemstack's metadata work? Then you could just have a method to add a specific itemstack with metadata and then the beacon code would check that?

 

P.S. Not sure if I'm reading your code right, but shouldn't the Item.isBeaconPayment() be returning a private boolean instead of another hard coded list? That way you could do CustomItem.setIsBeaconPayment(true) etc etc. Or maybe it would be better if it were "Item.isBeaconPayment(int metadata) {return false;(default, can be overridden by modders)}" ?

Posted

Sure, I could just make a list of ItemStacks somewhere and check that. But that would a) be messier and more error prone b) not cover all use cases and c) be far less performant than the current solution.

 

Okay, so forgive me, but I am rather confused. What is the current solution, and can we just use that instead then?

 

The point is for you to override that method in your Items and decide whether or not you want to return true. The current version is for the vanilla Items and is coded this way so that we only have one patch and not one patch in every vanilla Item that is allowed.

 

Yes! That is exactly what I was thinking. A modder would just override a function in their items' class just like with the blocks and the beacon base method. Okay, so I get that part now :)

Posted

I guess if there is too many to render and such. why not have a green checkmark and a red x for "this item is not accepted" and since people know you need valueables hopefully they can guess that mods that have "gems" and "precious metals" will make those items as beacon tribute. If not they can toss items in willy nilly and see what works.

Posted

I guess if there is too many to render and such. why not have a green checkmark and a red x for "this item is not accepted" and since people know you need valueables hopefully they can guess that mods that have "gems" and "precious metals" will make those items as beacon tribute. If not they can toss items in willy nilly and see what works.

 

That sounds like a good idea, but then would the fact that the item CAN go into the slot have to change? Vanilla behaviour is: pick up itemstack and attempt to place it in the beacon slot. If minecraft lets the itemstack in(similar to armor slots), then it's accepted, but if the item isn't accepted, then nothing happens. So if it were to be that a red x sould show up, the code that prevents any non-valid items would have to be changed. If that's not too much, then I think that could work.

Posted

Well, the whole adding items to the gui seems to not make any sense, so why don't we just leave the gui as-is and only focus on the slot? There really should be a way to add beacon payment items in forge. The only other way would be to manually edit the source code of minecraft via mcp, and I could do that, but then the mod I'm working on wouldn't be very compatable with other mods... So why edit the gui then? Why not just add functionality for registering itemstacks to the slot like I proposed in the op?

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



×
×
  • Create New...

Important Information

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