-
Posts
884 -
Joined
-
Last visited
-
Days Won
9
Everything posted by Jay Avery
-
[Solved]Crafting recipe with ItemStack inputs
Jay Avery replied to Jay Avery's topic in Modder Support
I know that's what I need to do, I'm looking for advice on how to do it! -
[Solved]Crafting recipe with ItemStack inputs
Jay Avery replied to Jay Avery's topic in Modder Support
So it can't be done using the vanilla InventoryCrafting class, you mean? I'm using my own CraftingManager , but with vanilla InventoryCrafting classes for the crafting grids. I forgot about github but all my code is there (link). Here is my CraftingManager class, and here is one of my containers which uses it. -
[Solved]Crafting recipe with ItemStack inputs
Jay Avery replied to Jay Avery's topic in Modder Support
Oh I should have said, I'm not using the vanilla crafting table. I've got custom crafting blocks as well as a custom inventory container with a crafting grid. Is it possible to do non-one stack size inputs with that? -
I want to make crafting recipes that require some of the input ItemStacks to have a stack size of greater than 1. I've worked out how to check the stack sizes when checking if the craft matrix matches the recipe, but I have no idea what to do with getRemainingItems . Looking at the forge vanilla code, I can't figure out what the ForgeHooks.getContainerItem method does, or how to adjust it so that the remaining items have the required stack size subtracted. I'm sure I've seen someone write about making crafting recipes with non-one stack sizes before but I can't find anything now. Can anyone advise and/or link me to somewhere it's been done? My custom recipe class is here. It correctly detects whether the input ItemStacks are large enough (the output slot only shows the output when they are), but when I click on the output the crafting grid slots don't seem to change correctly. Edit: I think I've solved this, although I don't know if it's the best way I could have done it (I suspect it's very much not). I made a new method in my custom recipe class that returns an array of ints representing how many items from each input stack should be used up. (The code is more or less the same as the way it checks for a matching recipe in the first place, because it has to find the recipe's position in the grid and then check each slot individually). Then I call that in my custom crafting slot's onPickupFromSlot (the same place where getRemainingItems is called) and use it to decrease the crafting grid stack sizes. Here is the code of my new method: Like I said I have no idea if this is a good way to do it. It seems to work, but although it seems really messy I can't think of a better way at the moment. If anyone has any ideas please let me know.
-
[SOLVED] Render partially transparent block
Jay Avery replied to Jay Avery's topic in Modder Support
Ahh, thank you so much - that looks like exactly what I need. -
I have a block with a model which is supposed to look like a water block (partially transparent) with a crop (opaque) inside it. But I can't get it to render how I want it to. When I use the CUTOUT BlockRenderLayer , it looks as expected with the water element fully opaque, obviously: When I use the TRANSPARENT layer, some weird things happen with the different faces of the opaque and transparent elements. The crop is glitched so it doesn't look like it's sticking out of the water the correct amount (which you can see in the opaque render above). The glitch varies depending on what angle you view the block from. Here is the json file for the model in case that's useful: Is there anything I can do to fix this, or is it just a limitation of Minecraft's rendering process? Edit: Solved using a forge:multi-layer model as Choonster suggested. In case it helps anyone else, my blockstates file: And the two model files, the crop (rendered on the mipped cutout layer): The water (rendered on the translucent layer):
-
[solved] Change vanilla block textures without resource pack
Jay Avery replied to Jay Avery's topic in Modder Support
I guess I didn't mean strictly in code, but just without the hassle of needing to separately add a resource pack to make the mod fully functional. I did not know I could override things putting them in a minecraft package within my mod, so that's the answer I was looking for - thank you. -
[solved] Change vanilla block textures without resource pack
Jay Avery replied to Jay Avery's topic in Modder Support
But it still requires the faff of *adding* a whole resource pack, whether that pack contains one texture or a hundred. If there's a way I can do it with just Forge code it'll be much simpler. -
I want to change just the texture or model of some vanilla blocks. I know the simplest way to do this is with a texture pack - but there's only a couple I want to change and it seems excessive to require a whole resource pack to go with a mod that only changes a few textures. Is there any way to do this via code instead of using a resource pack?
-
Thanks. Yeah I realise that 4x4 will fit in metadata, but I'm going to be using the same method for other larger structures too so I still want to know about it. Can you give any more guidance about how to use the TileEntity for the block's extended state? Or direct me to a tutorial maybe?
-
I've created a multi-block structure - when the item is used, it places four blocks (and when one is destroyed they all break). Each block in the structure stores its state in a TileEntity - one int defining which part of the structure it is, and one int representing the horizontal direction it's facing. I want each part of the structure to have a different json model - not a TE special renderer. Is it possible to do this with the blockstates json file somehow?
-
Thank you! Now I'm trying to work out what to do about IStorage and NBT. There are NBT-related methods in a bunch of different classes - in my default implementation (via ItemStackHandler ), in InventoryProvider , and in InventoryStorage . Do some of those need to cross-reference each other, and if so how? Also, do I need to actually manually call any of those methods, like in my EventHandler , or will they be called by Forge automatically anyway?
-
Okay, I've done some rearranging. For testing purposes, I'm trying to get the Capability to store a string that it gets from the name of the last item picked up by the player. I made a new class to store the Capability instance and ID, as you recommended: My ICUstomInventoryCap , I've just added a method to get the stored string. The default implementation, again the only change is simple methods to save and retrieve the test string: The InventoryProvider now stores an instance of ICustomInventoryCap which it takes as an argument in its constructor, and returns that for getCapability : In my EventHandler , the addCapability now supplies a new instance of the default implementation as the argument to the InventoryProvider constructor. Plus a call to the Capability's insertItem in ItemPickupEvent to save the string. It's still not crashing, which is good news! And when I call the getItem method from another arbitrary event, it seems to be correctly returning the last item picked up. Have I made any more glaring mistakes yet? Next step, figuring out the IStorage ...
-
I'm confused again. I tried to use getCapability on the Player and I'm getting a crash with this error: java.lang.ClassCastException: net.minecraftforge.common.capabilities.Capability cannot be cast to com.jj.jjmod.inventory.player.ICustomInventoryCap . I don't get why it's crashing because getCapability is supposed to be returning a ICustomInventoryCap so there should be no casting involved. What am I missing?
-
There's already an IItemHandler cap. And you don't need to extend it at all. net.minecraftforge.items.ItemStackHandler https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/java/com/draco18s/ores/entities/TileEntitySifter.java#L33 Mind, I did, in order to have "slots" that could only take certain items: https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/java/com/draco18s/ores/item/SiftableItemsHandler.java But it's definitely not necessary. Ohh, I misinterpreted when Choonster said you can't attach CapabilityItemHandler.ITEM_HANDLER_CAPABILITY , and thought that meant you couldn't attach anything that directly implemented IItemHandler . In any case, I plan to have custom slots and various other things going on, so it's probably best to make my own.
-
Thanks for the advice. I've made a start, maybe you could tell me whether or not I'm on the right track so far? None of my classes/methods have any actual content yet, first I just want to make sure I'm getting the structure of the interfaces/inheritance/etc right. My capability interface: My IStorage : My ICapabilitySerializable : And my default implementation: I register it with this line in CommonProxy : CapabilityManager.INSTANCE.register( ICustomInventoryCap.class , new InventoryStorage() , CustomInventoryDef.class ) ; And attach it with this event in my EventHandler : @SubscribeEvent public void attachEntityCapabilities( AttachCapabilitiesEvent.Entity event ) { if ( !( event.getEntity() instanceof EntityPlayer ) ) { return ; } event.addCapability( CustomInventoryDef.ID , new InventoryProvider() ) ; } I've tested it and it runs with no crashes, so I'm tentatively positive..?
-
I've read that, a lot. Most of the tutorials and information I can find seems to be about creating custom Capabilities, and brushes off the inbuilt ones as easy - but I can't figure it out! I'm pretty sure I need to use the addCapability method from AttachCapabilityEvent.Entity . So I need something like: event.addCapability( ResourceLocation , ICapabilityProvider ) ; But I don't know what those arguments should be. The first one is just like a name, right? So something like new ResourceLocation( Main.MODID , "invcap" ) I'm guessing. But I have no idea what ICapabilityProvider argument I need. I read that Entities themselves are ICapabilityProvider s. Does that mean I can just pass the player from the event as the second argument, like this? event.addCapability( new ResourceLocation( Main.MODID , "invcap" ) , event.getEntity() ) ; But this doesn't allow anywhere to actually define the Capability , like to specify that I want it to be an IItemHandler or say how many slots it should contain. What am I missing?
-
I want to edit the vanilla player inventory - essentially, change the number of ItemStacks the player can carry. My plan to achieve this is to use a Capability to store my custom inventory in the player entity, then use events to make sure that items only go into my custom inventory (not the vanilla one), as well as to make sure the right inventory is used for the GUI. I've found lots of information about Capabilities but it all seems to assume a level of knowledge I just don't have. I've read through the code in detail but I'm just really confused about the various different but similar classes and interfaces. I've never used the old IExtendedEntityProperties system so I don't have anything to learn from. Can anyone give me a really basic from-scratch guide to adding a Capability to EntityPlayer to store an inventory of ItemStacks? Exactly what classes do I need to make, and what methods do I need to call where? Or alternatively, tell me if (and why) my plan to use a Capability for this won't work - and advise on a different/better way to do it?
-
That will change the GUI but it won't allow me to edit the actual itemstacks the player can carry, will it?
-
I want to edit the standard player inventory (to change the crafting grid size and reduce the amount of item stacks the player can carry). Is it possible to do this using forge? I know it's difficult to alter vanilla things, but is there any way? If it makes things easier, I'm not worried about compatibility with other mods, because mine will only be used by itself.
-
Projectile entity floats in the air when it hits a block
Jay Avery replied to Jay Avery's topic in Modder Support
I gave that a try, but it didn't make a difference. I don't think it's an inherent problem with the render, but something that's going wrong after it lands for some reason - because it sometimes *does* render correctly at first. I've also noticed that if I save and reload the world, then the entity renders correctly even if it was doing the floating thing before I exited the world. Something to do with NBT maybe? -
I'm making a throwing spear entity, and having a weird bug that I can't figure out. When the spear lands in a block, it renders as if it's floating in the air about a block away from the place it lands. I'm pretty sure the entity's actual location is still in the block it's supposed to be in, based on when/where it's able to be picked up by the player. Sometimes the entity *does* appear to stick in the block as it's supposed to, but then after a second or two it pops back to a mid-air floating position. Here's a screenshot of what the entity looks like once it's 'landed' on the wall to the right (note that I'm using the arrow texture as a temporary stand-in to render it): I'm mostly using code from the Arrow and Throwable classes with only some minor tweaks. Here's my abstract EntityThrowable class: My EntitySpear class which extends the above: The EntitySpear class is abstract, the subclasses only change the item dropped and the onImpact method, like so: Here is my abstract RenderSpear class: The subclasses just define the texture that will be used for the render, at the moment I'm just using the vanilla arrow texture: The entities and renders are registered in these methods: Which are called in the ClientProxy in preInit(). I cannot figure out why it's rendering in the wrong place , or how the render position abruptly moves a few moments after landing. Can anyone advise?
-
Seeking a tutorial on rendering entities for 1.9+
Jay Avery replied to Jay Avery's topic in Modder Support
Bump - any other recommendations?