Jump to content
  • Home
  • Files
  • Docs
Status Updates
  • All Content

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Korall

Korall

Members
 View Profile  See their activity
  • Content Count

    10
  • Joined

    October 27, 2020
  • Last visited

    November 24, 2020

 Content Type 

  • All Activity

Profiles

  • Status Updates
  • Status Replies

Forums

  • Topics
  • Posts

Calendar

  • Events

Everything posted by Korall

  1. Korall

    [SOLVED] ItemModelProperties override not working when iterating

    Korall replied to Korall's topic in Modder Support

    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
    • November 7, 2020
    • 2 replies
  2. Korall

    [SOLVED] ItemModelProperties override not working when iterating

    Korall posted a topic in Modder Support

    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
    • November 7, 2020
    • 2 replies
  3. Korall

    How to create a base model for use with multiple different models?

    Korall replied to Korall's topic in Modder Support

    Thank you so much. This solved the issue. Just goes to show my lack of knowledge of the .json models and such.
    • November 5, 2020
    • 3 replies
  4. Korall

    How to create a base model for use with multiple different models?

    Korall replied to Korall's topic in Modder Support

    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" } }
    • November 5, 2020
    • 3 replies
  5. Korall

    How to create a base model for use with multiple different models?

    Korall posted a topic in Modder Support

    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.
    • November 5, 2020
    • 3 replies
  6. Korall

    Weird behaviour when trying to damage item on right click

    Korall replied to Korall's topic in Modder Support

    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!
    • October 27, 2020
    • 9 replies
  7. Korall

    Weird behaviour when trying to damage item on right click

    Korall replied to Korall's topic in Modder Support

    Without me overriding it to compensate for this effect, any changes made to the damage during the right click event are nullified
    • October 27, 2020
    • 9 replies
  8. Korall

    Weird behaviour when trying to damage item on right click

    Korall replied to Korall's topic in Modder Support

    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
    • October 27, 2020
    • 9 replies
  9. Korall

    Weird behaviour when trying to damage item on right click

    Korall replied to Korall's topic in Modder Support

    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
    • October 27, 2020
    • 9 replies
  10. Korall

    Weird behaviour when trying to damage item on right click

    Korall posted a topic in Modder Support

    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?
    • October 27, 2020
    • 9 replies
  • All Activity
  • Home
  • Korall
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community