Jump to content

trexxet

Members
  • Posts

    4
  • Joined

  • Last visited

Converted

  • Gender
    Male

Recent Profile Visitors

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

trexxet's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Oh, nevermind. This is correct: public static float getPropertyEmpty (ItemStack stack, @Nullable EntityLivingBase entityIn) { if (entityIn == null) return 0.f; if (!stack.isEmpty() && stack.getItem() instanceof ItemRifle) return ItemRifle.hasMagazine(stack) ? 0.f : 1.f; // 0 - not empty return 0.f; }
  2. I'm trying to implement a rifle, which model depends on if it has a magazine inserted or no. So, I'm doing the following: Rifle class: private static final String MAGAZINE_KEY = "has_magazine"; public ItemRifle () { super("rifle"); setMaxStackSize(1); addPropertyOverride(new ResourceLocation(Reference.MODID, "empty"), new IItemPropertyGetter() { @Override public float apply (ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) { return ItemRifle.getPropertyEmpty (stack, entityIn); } }); } public static float getPropertyEmpty (ItemStack stack, @Nullable EntityLivingBase entityIn) { if (entityIn == null) return 0.f; ItemStack activeItemStack = entityIn.getActiveItemStack(); if (!activeItemStack.isEmpty() && activeItemStack.getItem() instanceof ItemRifle) return ItemRifle.hasMagazine(stack) ? 0.f : 1.f; // 0 - not empty return 0.f; } public static boolean hasMagazine (ItemStack stack) { if (stack.hasTagCompound()) { NBTTagCompound nbt = stack.getTagCompound(); return nbt.hasKey(MAGAZINE_KEY) && nbt.getBoolean(MAGAZINE_KEY); } return false; } Model of a rifle with magazine (model/item/rifle.json): { "parent": "item/handheld", "textures": {"layer0": "ic2guns:items/rifle"}, "overrides": [ {"predicate": {"ic2guns:empty": 1}, "model": "ic2guns:item/rifle_empty"} ] } Model of an empty rifle (model/item/rifle_empty.json): { "parent": "ic2guns:item/rifle", "textures": { "layer0": "ic2guns:items/rifle_empty" } } At this moment I literally have no code which would set any NBT tag to rifle, so it should use the texture of an empty rifle. However, the base one (rifle with magazine) is rendered. Have I forgotten to register anything, or I'm doing it in a totally wrong way?
  3. Seems that I need more sleep. Thanks. I don't think that it worth adding recipe factories for a couple of machine recipes in addon. If the IC2 team would provide API for JSON machine recipes, I'll use them.
  4. I'm making an IC2 addon, so I want to add recipes for IC2 machines via it's API in Java code, not JSON. However, I can't get any OreDict items, even vanilla ones. I run this at post-init: public static void recipeInit () { IC2GunsMod.logger.info("Getting ores"); for (ItemStack s : OreDictionary.getOres("ignotIron")) { IC2GunsMod.logger.info("Found ore:" + s.getDisplayName()); //addCraftingRecipe(new ItemStack(Items.GUNPOWDER), "iii", "i i", "iii", // 'i', s); } for (ItemStack s : OreDictionary.getOres("ignotGold")) { IC2GunsMod.logger.info("Found ore:" + s.getDisplayName()); } } Only "Getting ores" is printed. getOres() returns empty list. I tried to check this with JEI, enabled OreDict search, but nothing is found for "$ignot" or "$ignotIron".
×
×
  • Create New...

Important Information

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