Jump to content

Search the Community

Showing results for tags 'items'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Minecraft Forge
    • Releases
    • Support & Bug Reports
    • Suggestions
    • General Discussion
  • Mod Developer Central
    • Modder Support
    • User Submitted Tutorials
  • Non-Forge
    • Site News (non-forge)
    • Minecraft General
    • Off-topic
  • Forge Mods
    • Mods

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start









Yahoo IM

MSN Messenger

Personal Text

Found 13 results

  1. Hello, My mod quite heavily relies on the NBT data of an item. Before 1.20.4, this data could be retrieved using ItemStack.getTag(), however this seems to have changed in 1.20.4. Is there any documentation on this change, or does anyone know if the getTag() function could be replaced by something else? I think stack.get(DataComponents.CUSTOM_DATA) does the job. Thanks for the help, Greetings, Podloot.
  2. I have been working on my mod for some time now and I am wanting to add a drink item, I am new to modding and am currently self teaching myself java as I follow tutorials. I am hoping that the code would not need a massive reworking. public static final FoodProperties LEMON_JUICE = new FoodProperties.Builder().nutrition(3) .saturationMod(0.25f).effect(() -> new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 1500),0.01f) .effect(() -> new MobEffectInstance(MobEffects.CONFUSION,200),1).build(); In game the lemon juice acts like a food, making eating audio and creating particles. For the audio I would like to use the honey drinking sound. How would I get this to work as I am wanting it to?
  3. In 1.20.6 any potion brewed in the brewing stand disappears upon completion.
  4. Hi, I'm making a necklace that stores relics with Curios mod integration. Right-clicking on a diamond currently opens the GUI, but I don't know how to store the items within it. Can anyone help me with this? (minecraft 1.20.1) -> My mod Gith https://github.com/Susakushii/SusakushiMods
  5. I'm trying to apply effects to the emerald armor but it doesn't work, I read that the onArmorTick() method doesn't work anymore, but I tried with inventoryTick, onInventoryTick and onArmorTick but they don't apply the effect either, I don't know if I'm writing it wrong, so I need help to fix it. This is the code in question: public class ModArmorItem extends ArmorItem{ private static final Map<ArmorMaterial, MobEffectInstance> MATERIAL_TO_EFFECT_MAP = (new ImmutableMap.Builder<ArmorMaterial, MobEffectInstance>()) .put(ModArmorMaterials.EMERALD, new MobEffectInstance( MobEffects.HERO_OF_THE_VILLAGE, 200, 1, false, false, true)) .build(); public ModArmorItem(ArmorMaterial pMaterial, Type pType, Properties pProperties) { super(pMaterial, pType, pProperties); } @Override public void onArmorTick(ItemStack stack, Level world, Player player){ if (!world.isClientSide()) { if (hasFullSuitOfArmorOn(player)) { evaluateArmorEffects(player); } } } private void evaluateArmorEffects(Player player) { for (Map.Entry<ArmorMaterial,MobEffectInstance> entry : MATERIAL_TO_EFFECT_MAP.entrySet()){ ArmorMaterial mapArmorMaterial = entry.getKey(); MobEffectInstance mapStatusEffect = entry.getValue(); if (hasCorrectArmorOn(mapArmorMaterial, player)) { addStatusEffectForMaterial(player, mapArmorMaterial, mapStatusEffect); } } } private void addStatusEffectForMaterial(Player player, ArmorMaterial mapArmorMaterial, MobEffectInstance mapStatusEffect) { boolean hasPlayerEffect = player.hasEffect(mapStatusEffect.getEffect()); if (hasCorrectArmorOn(mapArmorMaterial, player) && !hasPlayerEffect) { player.addEffect(new MobEffectInstance(mapStatusEffect)); } } private boolean hasCorrectArmorOn(ArmorMaterial material, Player player) { for (ItemStack armorStack : player.getInventory().armor){ if (!(armorStack.getItem() instanceof ArmorItem)) { return false; } } ArmorItem helmet = ((ArmorItem)player.getInventory().getArmor(3).getItem()); ArmorItem brestplace = ((ArmorItem)player.getInventory().getArmor(2).getItem()); ArmorItem leggins = ((ArmorItem)player.getInventory().getArmor(1).getItem()); ArmorItem boots = ((ArmorItem)player.getInventory().getArmor(0).getItem()); return helmet.getMaterial() == material && brestplace.getMaterial() == material && leggins.getMaterial() == material && boots.getMaterial() == material; } private boolean hasFullSuitOfArmorOn(Player player){ ItemStack helmet = player.getInventory().getArmor(3); ItemStack breastplace = player.getInventory().getArmor(2); ItemStack leggins = player.getInventory().getArmor(1); ItemStack boots = player.getInventory().getArmor(0); return !helmet.isEmpty() && !breastplace.isEmpty() && !leggins.isEmpty() && boots.isEmpty(); } } And here is the armor public static final RegistryObject<Item> EMERALD_HELMET = ITEMS.register( "emerald_helmet", () -> new ModArmorItem(ModArmorMaterials.EMERALD, ArmorItem.Type.HELMET, new Item.Properties()) ); public static final RegistryObject<Item> EMERALD_CHESTPLATE = ITEMS.register( "emerald_chestplate", () -> new ModArmorItem(ModArmorMaterials.EMERALD, ArmorItem.Type.CHESTPLATE, new Item.Properties()) ); public static final RegistryObject<Item> EMERALD_LEGGINS = ITEMS.register( "emerald_leggins", () -> new ModArmorItem(ModArmorMaterials.EMERALD, ArmorItem.Type.LEGGINGS, new Item.Properties()) ); public static final RegistryObject<Item> EMERALD_BOOTS = ITEMS.register( "emerald_boots", () -> new ModArmorItem(ModArmorMaterials.EMERALD, ArmorItem.Type.BOOTS, new Item.Properties()) ); I hope you can help me. Thanks.
  6. As well all know in minecraft inventory items (that can have more then 1 item amount) show a number once there amount goes above 1 (3 for the acacia plank for example) as shown below: now im trying to not render the item amount I found the following way I could maybe do that: public class CustomItemRenderer extends ItemRenderer{ public CustomItemRenderer(TextureManager textureManagerIn, ModelManager modelManagerIn, ItemColors itemColorsIn) { super(textureManagerIn, modelManagerIn, itemColorsIn); } @Override public void renderItemOverlayIntoGUI(FontRenderer fr, ItemStack stack, int xPosition, int yPosition, @Nullable String text) { if (stack.getCount() > 1) { return; } super.renderItemOverlayIntoGUI(fr, stack, xPosition, yPosition, text); } } when I hover over renderItemOverlayIntoGUI I get the following tooltip in intelij: public void renderItemOverlayIntoGUI( Font Renderer fr, @NotNull » ItemStack stack, int position, int position, @Nullable String text From class: ItemRenderer Renders the stack size and/or damage bar for the given ItemStack. which shows me what I want, to to not render the stack size. but I have no clue how to register this class since it has a super as follows: public CustomItemRenderer(TextureManager textureManagerIn, ModelManager modelManagerIn, ItemColors itemColorsIn) { super(textureManagerIn, modelManagerIn, itemColorsIn); }
  7. Let's say I have created an item, after I use it, it will do a certain action, for example, spawning particles on the player's position over the span of 20 ticks, without the use button being held down by the player. How would that be done?
  8. My issue is as simple and probably stupid as the title. So, I make add-on for mod missing loot table. I found wiki for dependencies and in an effort to use less effort wondered if it was necessary to make an extra convoluted dependency structure to simply call to some items. I will continue to use my circa 2006 google skills make it simpler for me to grasp. I no good at modding( Obviously), but me learn good. I will probably figure this out before I get a response. TLDR; is there a difference in structure between add-on and mod? Ty for reading this far. Enjoy the brain rot from my nooby question ❤️ Eternally Noob, The Noob *edit-1.0.0* I have the loot tables ready to shoot I just need to properly wrap me head around calling to another mod without doubling the files necessary. Currently there are no direct calls to bring data into my add-on/mod/failure just the ?standard? "mod_id:item" calls in loot table pools. I.E. { "type": "minecraft:chest", "pools": [ { "rolls": { "min": 0, "max": 1 }, "bonus_rolls": { "min": 1, "max": 2 }, "entries":[ { "type": "item", "weight": 2, "name": "other_mod_id:item", "quality": 1 }, ] }, { "rolls": 1 } ] } If possible I would love to just call to the "other_mod" from this. If this is enough then I will forehead wall for a while....
  9. I have an item class "PavlovaCake", and I want to switch the model based on the status of the integer "stage". Say, when stage == 1, it will load model "item/pavlova/1", when stage == 2, it loads "item/pavlova/2" Can anyone tell me how I can achieve this? Thanks
  10. I'm trying to render an obj file as an item and it works great but the thing is I also want to disable its shading! I don't have any clue how to do that 1.18.2 forge
  11. What is my goal: Create an item with forge energy support. It is supposed to switch between an active and inactive state. It should drain energy while active and inside the inventory of an entity. What I am currently doing to archieve this: I have an override of inventoryTick() in my item class which currently looks like this: @Override public void inventoryTick(ItemStack stack, Level level, Entity entity, int i, boolean bl) { if(!level.isClientSide) { if(updateActive(stack, level, entity)) { // checks state of the 'active' boolean tag for(var stackInHand : entity.getHandSlots()) { if(stackInHand == stack) { updateLight(level, entity); // might cause some lag (places light blocks) break; } } // extractEnergy(stack, 1); stack.getOrCreateTag().putInt("energy", 1000 + (int)(1000*Math.random())); // for testing } } } Apart from that I have defined an ICapabilityProvider which provides an instance of my custom IEnergyStorage implementation (stores current energy of an ItemStack in the 'energy' tag). As can be seen in the snippet above I have disabled the the extractEnergy() call and modified the energy tag directly to ensure nothing is wrong with my IEnergyStorage implementation. What's the issue: It appears that sometimes when I drop an 'active' item into the world the entity is dropped but a ghost item stays in the slot of the player inventory. I could confirm with debug outputs that inventoryTick() is only called on the client side from that point on (checking the inventory slot with the data command also reports that no item exist in that slot). As soon as I open the inventory the ghost item becomes an actual item (i.e. it is beeing updated on the server side again) effectively duping the item. I have observed this behaviour only when dropping the item while the game is lagging (sometimes). Though even a minor lag spike could be enough I guess. In my case this can be caused by the updateLight() call (depending on the mod settings and the spec of the machine) since it places light blocks in the world causing some light updates. I use this call with high settings (i.e. placing many light blocks) to forcefully cause some lag to be able to somewhat consistently replicate this issue. I guess the information that the item was dropped does not reach the client. This is somewhat surprising to me since from my understanding this could happen to any item?! Though I have never observed this kind of bug with any other modded (or vanilla) item from what I can recall. Whats interesting is that if I remove the randomness from the tag value (e.g. stack.getOrCreateTag().putInt("energy", 1000)) the issue seems to be gone. Hence I came to the conclusion this might be tied to the tag values getting out of sync between the server and client. But I have no idea what to do about this. Minimal example: I have set up a project with a minimal example showcasing the bug. The repository can be found here: https://gitlab.com/hd-mc-mods/examples/item-tick-bug So this makes me wonder: Am I not supposed to change tag values in inventoryTick()? Is there a way to check on the client side if an item stack does not exist anymore on the server side (i.e. remove ghost items)? Is it wrong to put to much load on the server inside inventoryTick() (e.g. updateLight())? What would be alternatives? Am I doing something obviously wrong that is out of my grasp? I hope somebody with a little more insight can help me with this or point me to good examples matching my usecase.
  12. I'm trying to add a custom enchantment that is only compatible with a new type of tiered weapon I made. I am using 1.19.3, forge version 44.0.1. I tried using EnchantmentCategory#create(), but it doesn't work. Here is the enchantment class: package everyblu.extendedarmory.common.enchantments; import everyblu.extendedarmory.common.item.LongswordItem; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.item.enchantment.EnchantmentCategory; import org.jetbrains.annotations.NotNull; public class ThrustingEnchantment extends Enchantment { static EnchantmentCategory LONGSWORD_TYPE = EnchantmentCategory.create("thrusting", item -> item instanceof LongswordItem); public ThrustingEnchantment() { super(Rarity.RARE, LONGSWORD_TYPE, new EquipmentSlot[]{EquipmentSlot.MAINHAND, EquipmentSlot.OFFHAND}); } @Override public int getMaxLevel() { return 3; } @Override public void doPostAttack(@NotNull LivingEntity attacker, @NotNull Entity target, int tier) { if (attacker.getLevel().isClientSide()) { ClientLevel level = ((ClientLevel) attacker.getLevel()); if (tier >= 1) level.addParticle(ParticleTypes.SONIC_BOOM, target.position().x,target.position().y, target.position().z, 0, 0, 0); //This part is not finished. } } } Here is my enchants init class: package everyblu.extendedarmory.common.register; import everyblu.extendedarmory.ExtendedArmory; import everyblu.extendedarmory.common.enchantments.CutlassLuckEnchantment; import everyblu.extendedarmory.common.enchantments.ThrustingEnchantment; import net.minecraft.world.item.enchantment.Enchantment; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; public class ModEnchants { public static final DeferredRegister<Enchantment> ENCHANTMENTS = DeferredRegister.create(ForgeRegistries.ENCHANTMENTS, ExtendedArmory.MODID); public static RegistryObject<Enchantment> Thrusting = ENCHANTMENTS.register("thrusting", ThrustingEnchantment::new); public static RegistryObject<Enchantment> CutlassLuck = ENCHANTMENTS.register("cutlassluck", CutlassLuckEnchantment::new); public static void register(IEventBus eventBus) { ENCHANTMENTS.register(eventBus); } }
  • Create New...

Important Information

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