Jump to content

WilliHay

Members
  • Posts

    5
  • Joined

  • Last visited

Recent Profile Visitors

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

WilliHay's Achievements

Tree Puncher

Tree Puncher (2/8)

1

Reputation

  1. I would like to be able to dynamically change one of the ingredients in one of my shaped recipes while the client is running, in response to a mod configuration change (e.g. when difficulty is set to "HARD", use an ender eye instead of an ender pearl in the crafting of a wand). Do I have to go through the trouble of creating a dynamic recipe factory (i.e. implementing IRecipe and an IRecipeFactory, creating _factories.json, etc.) just to swap out one ingredient? Or is there an easier way to accomplish this from the ConfigChangedEvent.OnConfigChangedEvent?
  2. At the least, you're going to need the fully qualified package name in your json. You left off the "main.java." part. I know you said you already tried that, but perhaps when you did, either it still wasn't fully correct, or maybe a different exception was thrown. Try it again and see what the crash log says. If that doesn't fix the problem fully, then you might check out Draco's example: https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/resources/assets/hardlib/recipes/_factories.json Perhaps Forge needs this to be a static class, too.
  3. The mappings do indeed matter here. That function changed to setTranslationKey() in stable_39. Another name that changed in that mapping was in CreativeTabs, which many tutorials cover. getTabIconItem(), which returns an ItemStack, is now createIcon().
  4. Here's the solution I eventually came up with, in case it helps anyone in the future. The strategy centers on creating a new Item for a new Dispense Behavior, which I think is the right approach in this case. Create a new ItemTeleportationSplashPotion that extends Item (not ItemPotion, for reasons below). Create a corresponding EntityTeleportationSplashPotion that extends EntityThrowable. (Registered it using an EntityEntry created from EntityEntryBuilder.) Create a simple item renderer for this entity that extends RenderSnowball. Register a brewing recipe that creates the "splash potion" item (with an Empty PotionType) so I can still use the brewing stand. Then I was able to register a new dispense behavior for the new item in BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject, based on BehaviorProjectileDispense, which is able to create my custom EntityTeleportationSplashPotion using the parameters I need to transfer important information about the dispenser that was missing from the vanilla splash potion dispense behavior. Namely: the constructor for this potion entity stores the IBlockSource that identifies the specific dispenser that threw my potion. On impact, I now have the information I need to perform the teleportation on all nearby entities, using the capability I added to the vanilla dispenser to read the teleport destination data that's stored there. I tried first simply extending ItemSplashPotion while using a custom TELEPORTATION PotionType but that meant I'd have to deal with all the vanilla potions of teleportation that get automatically created when you do that. Then I realized - I really only needed the splash potion. The regular and lingering versions didn't really add anything to my mod, especially since I already have a Wand of Teleportation for teleporting yourself. So my custom throwable item was the end result. It's a lot of fun now to create teleportation traps for unsuspecting mobs (and players), sending them to all kinds of creative places.
  5. So, here's the situation: I have injected a capability into a TileEntityDispenser so that I can store some data there, for example a BlockPos. When the dispenser fires a splash potion or tipped arrow that has a custom potion effect of mine, I want to pass this BlockPos data over to these projectiles. (For context, the potion effect is "teleportation" and the BlockPos data that is being transferred are the coordinates where a target that's hit by the projectile should be teleported.) My two-part question is: 1) How do I transfer this data to the potion or tipped arrow when the dispenser fires it? I looked at using BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY#putObject, but this would seem to require me to register a new Item, and I didn't have to create a new Item for the potion or arrow. I only created a new potion and potion effect. 2) Let's say I figure the first part out and I'm able to store the BlockPos data in the EntityPotion and EntityTippedArrow as capability data. When the potion or arrow hits a living target, how/when do I call my teleport method? Normally the way I do this, when it's a player who throws the potion or shoots the arrow, is call my teleport method from the #affectEntity or #performEffect method in my potion class which extends PotionBase. Those methods allow me to get the player who threw the potion or fired the arrow and read the teleport destination data using a custom capability I injected into EntityPlayer. But in this case when the dispenser throws these projectiles, the dispenser that fired them is not available in those potion methods, i.e. the "attacking entity" is null. So I think I need another way to call my teleport method with the BlockPos data stored in the potion or arrow, but how?
×
×
  • Create New...

Important Information

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