Jump to content

Daeruin

Members
  • Posts

    424
  • Joined

  • Last visited

Everything posted by Daeruin

  1. Personally I tend to like long names because they are more descriptive. Sure, they can get unwieldy, but it's a fuzzy line. Only you can decide how long is too long. You're the one who will be looking at your code all the time.
  2. I did this by creating both a lit and unlit torch block. The lit torch block was a ticking tile entity that kept track of how long it had left before it burned out.
  3. I want to make some recipes that are only slight variations on each other. Specifically, they will require an axe, but it doesn't matter which kind. Is there any way to make the axe type variable? The other ingredient will be a log, which means 30 recipes: 5 axe types times 6 log types. (The log can't be variable, because the output will be specific to the type of log.) If I ever want to add modded axes or logs, the number of recipes will keep increasing at a ridiculous rate. Is there any way to make a recipe that takes any kind of axe?
  4. Did you ever find an answer to this? I'm running into the exact same problem. I have some custom logs that do not use metadata. They appear to be registered to the ore dictionary just fine, but they do not work in vanilla recipes. I'd rather not recreate a bunch of recipes if I don't have to.
  5. Looks like you were using InventoryPlayer#hasItemStack. That method calls ItemStack#isItemEqual, which compares the item's damage and requires it to be the same. I recently needed to do something very similar to you and ended up with a similar solution (iterating over the inventory to find the item in question). For what it's worth, hasItemStack iterates over the inventory anyway, so the main difference is you're now doing it yourself.
  6. Define "didn't work". Did you get an error in the console? What's going wrong?
  7. When every player enters the world for the first time? Or only for the first player to ever enter the world?
  8. I haven't used it before, but you know how to subscribe to and use events, yes? Your description isn't very precise, so it's a bit hard to give specific advice. GuiScreenEvent has several sub-types that can be used in various situations. If you're looking to display a menu when the player clicks Create New World, for example, it looks like subscribing to ActionPerformedEvent might work best. Get the list of buttons and swap out the Create New World button for a custom button that you create to load your new menu.
  9. I couldn't figure out how to make the slot-swapping idea work. I went back to the very first idea I had of using a PlayerTickEvent to search the player inventory. Based on a tip from an old Minecraftforum post, I found out that I can see what's loaded on the mouse cursor with InventoryPlayer#getItemStack. I just need to store that value, and anytime it changes, the player must have clicked on a slot. Only when it changes from my item to something else do I need to iterate over the inventory to check if my item has been put somewhere it shouldn't. I feel like it ended up being relatively elegant, and it works well, too. For the record: Final code here
  10. What did you mean by this? EntityPlayer#inventoryContainer? Because openContainer and inventoryContainer always seem to be identical as far as I can see. Silly me. It's been a while since I did anything client side. Haha. I checked, super method is not getting called unless the item is valid, in which case super is called and returns true. I haven't seen it return false. This is really strange because I have another Slot extension that has the exact same code, and it works just fine (in my custom inventory).
  11. How would you detect the slot under the cursor? The event doesn't seem to have access to the slots. If it did, I could see comparing the mouse x and y to the slot's x and y coordinates.
  12. Thank you for the reply! I originally didn't have that there. When things weren't working, I added it. Just throwing crap at the wall to see if it would help. I see what you are getting at, but GuiOpenEvent doesn't seem to have access to the EntityPlayer.
  13. I think I figured out how to identify the hot bar, but my custom Slot class isn't working. I think it's because PlayerContainerEvent only fires on the server. I'm swapping out the slots, but the client isn't being notified. So when putting stuff in my inventory, it looks like I can put the items in the slot, but they aren't actually there. Also, when I do the exact same thing in the EntityJoinWorldEvent on the player's inventory, the inventory slots that are swapped out for my custom ones can't be interacted with at all. EventHandler code
  14. I was thinking about other mods that might be doing their own crap to modify the slots. Since I can't sleep I decided to give this a try. I have no idea how to detect which slots are in the hot bar. The indices of the hot bar slots change depending on whether you're looking at the standard inventory, crafting table, furnace, etc... because the order in which the slots are added is different in each case. WTF. And InventoryPlayer seems to organize things completely different, with different lists of items for the main inventory, armor, etc., so the indices of the items in the inventory list don't match indices of the slots they belong in. At least, not as far as I can tell. WTF.
  15. Interesting ideas! I like the idea of trying the MouseEvent most. It would directly stop the player from putting the item in the hot bar while being not resource intensive and potentially more compatible with other mods. I might try that out tomorrow if I have time. Any other ideas are still welcome.
  16. Is there any way to control which slots of the vanilla inventory my custom item can go into? Specifically, I would like my item to only be allowed in the hot bar, not in the main inventory. I can't think of a way to do this without making a custom player inventory, and I'm not sure I want to go that far. Maybe a player tick event that searches the inventory for my item and moves it to the hot bar, or expels it otherwise? It seems like searching the entire inventory of every player every tick could lead to performance problems. I really wish there were some events that dealt with inventory interactions.
  17. Yes, that worked! Although it doesn't quite look the same as in the inventory. The lighting is a bit different. Anyway, thanks for the help. I'm in the dark with this rendering stuff. Should I be rendering this in the foreground or background layer? When I do it in the foreground, I can no longer see items when I pick them up with the mouse. When I do it in the background, the basket appears clear in the upper left corner of the screen, and all my foreground stuff disappears. I have no idea what's going on with that. Another weird thing is that now I'm noticing the front left wall of the basket is missing.
  18. I'm trying to render a block in my GUI, but it seems to have no lighting like it normally does in the inventory. Any idea what I need to do? Not sure why this image looks faded, but you can see the difference between the one in the inventory down at the bottom, and the one I'm trying to render up at the top. Also sorry for the extra image at the bottom. Apparently you can't delete an image once you've attached it to the post.
  19. IT WORKS. I'm so happy I could cry. I've been working on this stupid piece of functionality for WEEKS in what little free time I have. Thank you!
  20. And how should I do that? Does it even matter what format I use, or should I copy how ItemStackHandler does it? Maybe it would help if I understood how this is supposed to help solve my problem.
  21. That pretty much went over my head. If I use ICapabilitySerializable instead of ICapabilityProvider, won't I need to write my own serializeNBT and deserializeNBT methods? Where is getStorage() and how do I use it?
  22. Just for the heck of it, I created a copy of the ItemStack, right before spawning the EntityItem, and checked to see if the capability's inventory was preserved. It was not. ItemStack#copy looks like it's supposed to maintain capability information in the copy. Am I misreading? Or is my capability somehow set up wrong, so that it doesn't get carried over to the copy?
  23. How come I don't have buttons for spoilers or code in my little formatting bar when replying to messages? Here is the place where the capability's ItemStacks seem to get lost: public void onCollideWithPlayer(EntityPlayer entityIn) { if (!this.world.isRemote) { if (this.pickupDelay > 0) return; ItemStack itemstack = this.getItem(); Item item = itemstack.getItem(); int i = itemstack.getCount(); // The entity passed in here has the ItemStacks int hook = net.minecraftforge.event.ForgeEventFactory.onItemPickup(this, entityIn); if (hook < 0) return; ItemStack clone = itemstack.copy(); if (this.pickupDelay <= 0 && (this.owner == null || lifespan - this.age <= 200 || this.owner.equals(entityIn.getName())) && (hook == 1 || i <= 0 || entityIn.inventory.addItemStackToInventory(itemstack) || clone.getCount() > this.getItem().getCount())) { clone.setCount(clone.getCount() - this.getItem().getCount()); // The stack passed in here doesn't have the ItemStacks net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerItemPickupEvent(entityIn, this, clone); if (itemstack.isEmpty()) { entityIn.onItemPickup(this, i); this.setDead(); itemstack.setCount(i); } entityIn.addStat(StatList.getObjectsPickedUpStats(item), i); } } }
  24. I subscribed to several events to try to get snapshots of the block's inventory at various points. It appears that sometime between the player colliding with the EntityItem, and when the ItemStack gets put in their inventory, the capability's ItemStacks are lost. It happens in EntityItem#onCollideWithPlayer, in between ForgeEventFactory#onItemPickup and FML's firePlayerItemPickupEvent. The EntityItem that gets passed into ForgeEventFactory#onItemPickup has the capability's ItemStacks, but the ItemStack that gets passed into FML's firePlayerItemPickupEvent doesn't have the capability's ItemStacks. The ItemStack that gets passed into FML's firePlayerItemPickupEvent is a clone of the EntityItem's ItemStack. Theoretically, the capability should get passed along to the clone. Is it possible that the capability isn't getting serialize correctly during the clone operation? What else could be going wrong here?
×
×
  • Create New...

Important Information

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