Jump to content

Daeruin

Members
  • Posts

    424
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • URL
    http://www.benjaminrose.com

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Daeruin's Achievements

Diamond Finder

Diamond Finder (5/8)

26

Reputation

  1. I'm aware. There are lots of ways for items to end up in a given slot. It's all stuff I handled in 1.12, just struggling to figure out how to do the same thing in 1.18. If I could modify the vanilla inventories or slots to override what items they allow, it would be much easier. Like if there were an event that hooked into Slot#mayPlace, I would be ecstatic. I think I actually figured it out just now. Apparently there's a MouseReleasedEvent now, and I had to use that instead. I guess it's the release of the button that actually triggers the item going into the slot.
  2. I'm trying to prevent my block from being placed in certain vanilla inventories. I'm using MouseClickedEvent.Pre. By canceling the event, I can prevent items from being picked up by the mouse cursor, but for some reason canceling the event doesn't prevent items from being placed into a slot. If there's a better way other than listening for mouse clicks, I'm all ears. Here's my code - the full logic isn't in place, I'm just trying to successfully prevent the block from being placed in any inventory to start off with.
  3. I don't see an event like that in 1.18.2. Looks like I'm stuck with the RenderTooltipEvents. Thanks!
  4. I have a custom block, and I'd like to add an image into its tooltip. I have created a class that implements ClientToolTipComponent and TooltipComponent so I can draw the image. I have overridden appendHoverText on my custom block, but there doesn't appear to be any way to add my custom component or any image that I can see. It looks like I can only add text-based components. Do I have to use the GatherComponents tooltip event?
  5. Well, I figured out the problem. Basically I was being a doofus and I had two copies of the inventory in my capability provider—one inside a LazyOptional, like I should have, and a second one not inside a LazyOptional. The second one was old code from before I understood how to use the LazyOptional. The second inventory was always empty for obvious reasons but I was still using it to serialize/deserialize. So it's now working solely with a capability, and I'm not using BlockEntity#saveToItem at all. I'm writing the BlockEntity's capability data to the ItemStack in playerWillDestroy when the block is broken, and writing the ItemStack's capability data back to the BlockEntity in setPlacedBy when the block is placed.
  6. I lied, the capability is not persisting. If I use the vanilla BlockEntity#saveToItem, then the inventory persists from breaking the block to placing it back down again. It's basically how the shulker box does it. But the capability disappears at some point after spawning the ItemEntity and picking it up in my inventory. It's baffling to me because I'm basically doing everything I used to do in 1.12.
  7. The shulker box does it in playerWillDestroy. I just looked it up. Anyway that's kinda beside the point. As I mentioned in my previous post, I'm successfully saving the capability on the ItemStack when the block is broken (during playerWillDestroy), and it gets restored when I place the block again. I just can't find it when I'm holding the ItemStack and need to view the inventory.
  8. It tried this, but by the time spawnAfterBreak occurs, the BlockEntity has already been deleted, so I can't get the inventory from it. So I tried it in playerWillDestroy, and it appears as though the inventory is being saved to the ItemStack that's part of the ItemEntity that I'm spawning. Yet when the BlockItem's use method occurs, the item no longer seems to have a capability attached to it. I am supplying my capability provider during initCapabilities. If I use BlockEntity#saveToItem during playerWillDestroy, the inventory data gets saved to a BlockEntityTag NBT, which persists all the way through breaking the block, picking it up, and placing it back down. Block#playerWillDestroy: BlockItem#initCapabilities: BlockItem#use:
  9. I'm converting my old mod from 1.12 to 1.18. It's basically a backpack mod except it's wicker baskets. You can place them as a block or hold them as an item and view the inventory while holding it. I have most everything working except the inventory doesn't sync between the block and the item. If I put something in the block inventory, then break the block, pick it up, and try to view the inventory from my hand, the basket is empty. And vice versa - if I put something in the basket inventory while holding it as an item, then place it as a block, the block inventory is empty. It seems the way I used to do it in 1.12 doesn't work anymore and I can't figure out what to do. I couldn't find any other backpack mods for 1.18 that actually use capabilities. Help would be much appreciated. Full repo is here. Or some direct links: Basket Block Basket Block Entity Basket Block Item Capability Provider ItemStackHandler implementation Basket Menu
  10. Sigh. I was being silly. I was using IntelliJ 2017. Once I opened my project in IntelliJ 2022, it worked fine.
  11. I was able to reproduce the error using the gradle buildscript provided by the Forge MDK, version 1.18.2-40.1.0. I think this something wrong with my environment or IntelliJ settings. Here's the full error:
  12. After a few months off, I'm trying to hurry and finish upgrading my mod to 1.18 before 1.20 comes out. I fired up IntelliJ and got this error: Unable to load class 'org.gradle.api.internal.plugins.DefaultConvention'. The only thing that's changed since last time I worked on my mod was updating to macOS Monterey. A little research seems to indicate the problem is with something trying to reference a class that's not available in the version of Gradle I'm using. My `gradle-wrapper.properties` is set to: distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip My project is set up to use the default Gradle wrapper and Java 17. I can see Gradle 7.4 in my /Users/<me>/.gradle folder. I also tried starting up a brand new mod project with the 1.18 Forge MDK and got the same error. Any idea what is going on here?
  13. Thank you, that worked!. It took me a minute to figure out how to use an ExistingModelFile. For future readers, you can get one through models().getExistingFile and passing in the resource location of the block model.
  14. I'm trying to use data generation to create blockstates and block models. I'm a little stuck on generating my block's item model. I'm trying to make it inherit from the block model, but the data generator seems to be assuming it should instead inherit from an item model. This essentially results in the item model inheriting from itself instead of from the corresponding block model. Here's my BlockStateProvider and the resulting item model. What am I missing?
  15. I said it in my initial post. I'm trying to generate loot modifiers for a bunch of items. All of the items have the same tag. It seemed like I should be able to just grab the tag, iterate over the items, and generate the loot modifier for each one that way.
×
×
  • Create New...

Important Information

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