Jump to content

Korall

Members
  • Posts

    13
  • Joined

  • Last visited

Everything posted by Korall

  1. I've recently gotten into modding again after a hiatus. Currently I'm experimenting with a mod that would allow users to create simple 'content packs' in plain-text form. These files are loaded on startup by the mod and it then registers items based off of this data via the registry events, which works fine (though I'm not yet sure what would happen if there's a mismatch between the server and client content packs). However I would like to be able to automatically load & register resources and data for these items, based off of the loaded data; E.G item textures & models, and crafting recipes (dynamically registering recipes used to be quite straightforward last time I did any modding) I have yet to find anything on this that is up to date, though I did find a solution that would probably work, that essentially relied on handling all the rendering on its own. Is there any reasonable way to do this, short of requiring the user to also install a resource pack and data pack for every content pack?
  2. I'm suprised at how simple this was. Though it was a bit tricky in some ways, mostly since I don't know much about how the JSON models work. But it seems to make the generated item icons very dark; I figure its some kind of lighting thing. So I'm guessing I cant straight up use the standard item/generated for the replacement model. EDIT: From my experimentation, it is definitely a lighting issue. It shades the item model in the same way it shades the block and 3d item models, which makes it appear dark, since the face is rotated 45 degrees from the light direction. And overriding elements' "shade" property or the "gui_light" property also dosen't seem to have any effect on the shading. EDIT again: Nevermind, overriding "gui_light":"front" does work, but you need to do it outside of the actual base model or perspective definitions
  3. (I'm working in 1.16.5) Hello. So what I am trying to do is render an item in 3D when held, but as a regular 2D item when looking at it in the GUI (Like the trident). I have so far been unable to find anything about it really. Looking at the json models of the trident shows that there are two seperate models for it, one for 2d and one for 3d (And another rotated 3d one for when its raised in the air when aiming with it). Looking into the trident item code (or the trident entity renderer) also didn't really yield anything, so I'm assuming something more complex is at play; some kind of custom renderer that is hardcoded for the trident? From what I've been able to find it seems like I should use ItemStackTileEntityRenderer though I'm not sure if I'm on the right path or not with that one, and the documentation on it isn't exactly comprehensive. And I'm not familair at all with renderers and whatnot. I am aware that there are some "tricks" one could use to achive something similair with just a standard JSON model, but it doesn't seem like an optimal solution.
  4. Nevermind. I figured it out. I just referenced the wrong class in iteration. Needed to be instanceof NewGunItem and not GunItem. Sorry, I'm just kind of tired haha
  5. I have this piece of code that gets called with DefferedWorkQue.runLater and it works without issue ItemModelsProperties.func_239418_a_(ModItems.FLINTLOCK_MUSKET.get(), new ResourceLocation(MatchlockGuns.modID, "is_loading"), (stack, world, entity) -> { if(stack.getTag().getBoolean("is_loading")) { return 1f; } return 0f; } ); However, I want this property to apply to all of my items of a certain type, but when I try to iterate on this, it doesn't seem to work anymore and does nothing, no errors. ModItems.ITEMS.getEntries().forEach( (itemRegister) -> { if(itemRegister.get() instanceof GunItem) ItemModelsProperties.func_239418_a_(itemRegister.get(), new ResourceLocation(MatchlockGuns.modID, "is_loading"), (stack, world, entity) -> { if(stack.getTag().getBoolean("is_loading")) { return 1f; } return 0f; } ); } ); I've also tried some other forms of iteration, but none of them seem to work. What is the issue here? And is there any way to add a model property to all items of a certain type without having to manually add it for each of them? Another thing I've tried is to call the runLater function for each item inside the Item class constructor, but this again does nothing
  6. Thank you so much. This solved the issue. Just goes to show my lack of knowledge of the .json models and such.
  7. For context. This is what i've tried: baseModel.json { "parent": "item/handheld", "display": { "thirdperson_righthand": { "rotation": [ 0, -90, 55 ], "translation": [ 0, 1, 0.5 ], "scale": [ 0.85, 0.85, 0.85 ] }, "thirdperson_lefthand": { "rotation": [ 0, 90, -55 ], "translation": [ 0, 1, 0.5 ], "scale": [ 0.85, 0.85, 0.85 ] }, "firstperson_righthand": { "rotation": [ 0, -90, 25 ], "translation": [ 1.13, 3.2, 1.13 ], "scale": [ 0.68, 0.68, 0.68 ] }, "firstperson_lefthand": { "rotation": [ 0, 90, -25 ], "translation": [ 1.13, 3.2, 1.13 ], "scale": [ 0.68, 0.68, 0.68 ] } } } othermodel.json { "parent": "matchlockguns:item/baseModel", "textures": { "layer0": "matchlockguns:items/flintlock_musket" } }
  8. Sorry, I'm kind of dreadful at .json, so please bear with me. So, I have it so I need to move the position of the item model, but otherwise its a regular item model. { "parent": "item/handheld", "textures": { "layer0": "matchlockguns:items/matchlock_gun" }, "display": { "thirdperson_righthand": { "rotation": [ 0, -90, 55 ], "translation": [ 0, 1, 0.5 ], "scale": [ 0.85, 0.85, 0.85 ] }, "thirdperson_lefthand": { "rotation": [ 0, 90, -55 ], "translation": [ 0, 1, 0.5 ], "scale": [ 0.85, 0.85, 0.85 ] }, "firstperson_righthand": { "rotation": [ 0, -90, 25 ], "translation": [ 1.13, 3.2, 1.13 ], "scale": [ 0.68, 0.68, 0.68 ] }, "firstperson_lefthand": { "rotation": [ 0, 90, -25 ], "translation": [ 1.13, 3.2, 1.13 ], "scale": [ 0.68, 0.68, 0.68 ] } } } However, basically all of my items use this configuration of transforms, so I was woundering how I would go about creating a basic .json model, and then have all my items use it as a substrate, only replacing the texture per for each model. I've tried things like having a model like that and then making the items use it as a parent, but it simply makes them null boxes. I've also been unable to find copies of the item/handheld or item/generated models.
  9. Oh my god. I feel like an absolute idiot now, haha... :< . It works in survival. Therefore the conclusion that can be made is that the onRightClick event resets the item damage if you are in creative, instead of stopping it from happening. Essentially, when right clicking this happens (in pseudo code): onPlayerRightClickEvent(PlayerEntity player) { int itemDamage = player.getItem().getDamage() player.getItem().performRightClickEvent() if(player.isInCreative()) player.getItem().setDamage(itemDamage) } I though there was just a check for being in creative mode in the attemptDamageItem event or damageItem event. Thanks!
  10. Without me overriding it to compensate for this effect, any changes made to the damage during the right click event are nullified
  11. Well, this code works... sort of. However to actually damage the item, i need to temporarily put the "gun_damage_tmp" and then in the damageItem function make sure that the inputed damage and the temporary damage match. This seems like a rather hacky soloution, so i figured there must be a better way to damage the item during the right click event. Any changes made to the itemStacks damage during the event will be reset. Also this is my damageItem override event @Override public void setDamage(ItemStack stack, int damage) { int tmpDmg = stack.getTag().getInt("gun_damage_tmp"); //int nDamage = stack.getTag().getInt("gun_damage") + damage; int nDamage = damage; if(Math.abs(tmpDmg - damage) < 2 && damage < tmpDmg) { nDamage = tmpDmg; if(nDamage == 1) nDamage = 0; } stack.getTag().putInt("gun_damage", nDamage); if(nDamage >= this.getMaxDamage(stack)) { stack.shrink(1); } if(nDamage < 0) stack.getTag().putInt("gun_damage", 0); stack.getTag().putInt("gun_damage_tmp", stack.getTag().getInt("gun_damage")); } And with that it works. But as previously stated, i find it weird that you cant damage an item during the right click event without it resetting
  12. Okay, well... lets see here... the relevant things should be public ActionResult<ItemStack> useItem(World worldIn, PlayerEntity playerIn, Hand handIn, boolean canRepeat) { if(handIn == Hand.MAIN_HAND) offhandStack = playerIn.getHeldItem(Hand.OFF_HAND); else offhandStack = playerIn.getHeldItem(Hand.MAIN_HAND); if (canUseGunItem(heldStack, offhandStack)) { ShotItem shotItem = getLoadedShot(heldStack); if ((canShoot(heldStack, offhandStack, playerIn, worldIn.isRemote()) && shotItem != null)) { float pwr = getGunProperties().getPower(); playerIn.addVelocity(mDir.x * 0.02 * pwr, 0.01f * pwr, mDir.z * 0.02 * pwr); if (!worldIn.isRemote()) { CompoundNBT tag = heldStack.getTag(); tag.putInt("rounds", tag.getInt("rounds") - 1); attemptDamageGun(heldStack, 1); if(tag.getInt("rounds") == 0) tag.putInt("shot_ID", -1); heldStack.setTag(tag); //Does some other stuff too, but its irrelevant for this post } return new ActionResult<>(ActionResultType.SUCCESS, heldStack); } return new ActionResult<>(ActionResultType.FAIL, heldStack); } And the attemptDamageGun function: public void attemptDamageGun(ItemStack stack, int damage) { CompoundNBT tag = stack.getTag(); double rand = Math.random(); Map<Enchantment, Integer> enchantments = EnchantmentHelper.getEnchantments(stack); tag.putInt("gun_damage", tag.getInt("gun_damage") + damage); tag.putInt("gun_damage_tmp", tag.getInt("gun_damage")); stack.setTag(tag); } Also the formatting is a bit odd.. il see if i can fix that Now, I am certain that the attemptDamageGun function actually fires, and it does indeed work, just not without that "gun_damage_tmp" fix to compensate
  13. I've come upon something I don't quite understand. I have a custom item where I use the onItemRightClick event. In the event, i modify the NBT tag values of the item, and this works without problem. However, whenever i try to change the items nbt value related to item damage (durability) or damage the item in some other way, it seems to be nullified. I was able to dance around this issue by assigning a damage value in another nbt value and then comparing the two in the setDamage function. So it seems to me like the onItemRightClick event records the damage value before being executed, and then sets it to the item afterwards, making the item have the same damage value regardless of what happened in the event. So, why does this happen, and what is the "correct" way to damage the used itemStack during the onItemRightClick event? I did try to see how the flint and steel item does it, but I couldn't really find anything, since it extends the Item class, and the item class extends... something?
×
×
  • Create New...

Important Information

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