gabrielbl
-
Posts
16 -
Joined
-
Last visited
Posts posted by gabrielbl
-
-
Thank you
-
Just a quick question about other AttributeModifier. I'm able to add Knockack resistance to an armor like this:
@Override public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) { final Multimap<String, AttributeModifier> modifiers = super.getAttributeModifiers(slot, stack); if (slot == EQUIPMENT_SLOT) { modifiers.put(SharedMonsterAttributes.KNOCKBACK_RESISTANCE.getAttributeUnlocalizedName(), new AttributeModifier(SharedMonsterAttributes.KNOCKBACK_RESISTANCE.getAttributeUnlocalizedName(), (double)20, 0)); } return modifiers; }
Is this the best way to do it? I couldn't find the UUID either know what modifiers are those at ItemArmor
private static final UUID[] ARMOR_MODIFIERS = new UUID[] {UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"), UUID.fromString("D8499B04-0E66-4726-AB29-64469D734E0D"), UUID.fromString("9F3D476D-C118-4544-8365-64846904B48E"), UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150")};
-
Thank you, it worked here but i had to reimplemented like this since i was recieving errors from the java lambda expression not being supported.
private void replaceModifier(Multimap<String, AttributeModifier> modifierMultimap, IAttribute attribute, UUID id, double multiplier) { // Get the modifiers for the specified attribute final Collection<AttributeModifier> modifiers = modifierMultimap.get(attribute.getAttributeUnlocalizedName()); AttributeModifier selectedModifier = null; for (AttributeModifier modifier: modifiers) { if (modifier.getID().equals(id)) { selectedModifier = modifier; break; } } if (selectedModifier != null) { modifiers.remove(selectedModifier); modifiers.add(new AttributeModifier(selectedModifier.getID(), selectedModifier.getName(), selectedModifier.getAmount() * multiplier, selectedModifier.getOperation())); } }
Previous error: “lambda expressions not supported at this language level”
-
Manage to find a way out but isn't perfect since if i get the item from creative menu it wont came with the Attribute Modifier.
ItemStack swordStack = new ItemStack(TutorialItems.super_cheaty_sword); swordStack.setStackDisplayName("Not a cheaty sword"); final UUID ATTACK_DAMAGE_MODIFIER = UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF"); final UUID ATTACK_SPEED_MODIFIER = UUID.fromString("FA233E1C-4180-4865-B01B-BCCE9785ACA3"); swordStack.addAttributeModifier(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", (double)40, 0), EntityEquipmentSlot.MAINHAND); swordStack.addAttributeModifier(SharedMonsterAttributes.ATTACK_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", (double)10, 0), EntityEquipmentSlot.MAINHAND); String[] cheatySwordCraft = {"CCC", "CDC", "CCC"}; GameRegistry.addShapedRecipe(swordStack, cheatySwordCraft[0], cheatySwordCraft[1], cheatySwordCraft[2], 'C', TutorialItems.custom_item, 'D', Items.DIAMOND_SWORD);
Can someone help me with the creative tab issue?
Source:
-
Can someone give some guidance on how to edit items attributes? I'm cheking this link (http://minecraft.gamepedia.com/Attribute#Modifiers) but yet i haven't found a way to do it on a modded item.
Thank you in advance.
-
Sry i didn't saw the edit but thank you anyway
-
Thank you for the help but i've managed to figure out the issue. The problem was within my material definition.
addArmorMaterial(String name, String textureName, int durability, int[] reductionAmounts, int enchantability, SoundEvent soundOnEquip, float toughness)
at textureName i should had added MODID:texturename instead of only the texturename. It ended it up like this
cheaty_armor_material = EnumHelper.addArmorMaterial("cheaty_armor_material", Reference.MODID + ":cheaty_armor_material", 1000, new int[]{30, 60, 80, 30}, 0, SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 20.0f);
Source: *edit
[1] Animefan8888
[2] http://bedrockminer.jimdo.com/modding-tutorials/basic-modding-1-8/custom-armor/
-
Shure it is but at ItemArmor that isn't any implementation of getArmorTexture(...) and at Item it simplly returns a null which results in a NullPointerException
EDIT: i'll try to hard code it (the path) latter. it seens to be the way but it is awkward how the path is generated since i can't find it anywhere
-
Hmm shure..let me rephrase it. Which method should i override to do somthing like this:
String generatedPath = super().substring(; return Reference.MODID + generatedPath;
-
BTW if a have the getArmorTexture not overrided somehow minecraft is able to build the following material layer.
[21:22:10] [Client thread/WARN]: Failed to load texture: minecraft:textures/models/armor/cheaty_armor_material_layer_2.png java.io.FileNotFoundException: minecraft:textures/models/armor/cheaty_armor_material_layer_2.png
I understend the problem is with the minecraft prefix on the .png file but i'm not shure how minecraft is able to build that path yet
-
I've just implemented a piece of armor here is the working code (in exception of the texture renderer that i'm still trying to figure it out)
Add this somewhere in your code
public static ItemArmor.ArmorMaterial cheaty_armor_material;
and this to create the armor material
cheaty_armor_material = EnumHelper.addArmorMaterial("cheaty_armor_material", "cheaty_armor_material", 1000, new int[]{30, 60, 80, 30}, 0, SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 20.0f);
And i'm using this as my legging class
package keg.examplemod.items.armor; import keg.examplemod.init.TutorialItems; import net.minecraft.entity.Entity; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; public class SuperCheatyLeggings extends ItemArmor { public SuperCheatyLeggings() { super(TutorialItems.cheaty_armor_material, 0, EntityEquipmentSlot.LEGS); this.setUnlocalizedName("super_cheaty_leggings"); this.setRegistryName("super_cheaty_leggings"); } @Override public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) { // This part is not working yet // Here was some code that wasn't working return null; } }
-
Thank you, I didn't notice the other constructor. It is working like charm!
-
I've already implemented a modded Pickaxe, Shovel, Hoe and Sword with basically the same code (changing the inherit class and a few attributes) but the same implementation doesn't work for an Axe since it is giving me an ArrayIndexOutOfBoundsException as shown bellow
java.lang.ArrayIndexOutOfBoundsException: 5 at net.minecraft.item.ItemAxe.<init>(ItemAxe.java:19) ~[forgeSrc-1.10.2-12.18.1.2011.jar:?] etc etc
in the following line of code at ItemAxe
this.damageVsEntity = ATTACK_DAMAGES[material.ordinal()];
where ATTACK_DAMAGES represents
private static final float[] ATTACK_DAMAGES = new float[] {6.0F, 8.0F, 8.0F, 8.0F, 6.0F};
i undertand the problem but can't find a solution. The same problem will occur with ATTACK_SPEEDS but the fix should be the same. Thank you in advance.
-
Thank you, it worked perfectly here.
-
I'm learning modding minecraft with a "Super cheaty block" hehe. Basically what this block does is when right clicked with a dirt it should give a diamond or spawn it on the player's feet.
I've already managed to add the block, spawn it with the /give command and give the diamond to the inventory if otherwise i'm spawning the diamond on the floor (code bellow) but it shows 2 diamonds on the floor and if relog or open a free slot it only show one diamond.
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack reward = new ItemStack(Items.DIAMOND, 1); Item dirtItem = ItemBlock.getItemFromBlock(Blocks.DIRT); if (playerIn != null) { heldItem = playerIn.getHeldItem(EnumHand.MAIN_HAND); if (heldItem != null && dirtItem.equals(heldItem.getItem())) { heldItem.stackSize -= 1; if (!playerIn.inventory.addItemStackToInventory(reward)) { worldIn.spawnEntityInWorld(new EntityItem(worldIn, playerIn.posX, playerIn.posY, playerIn.posZ, reward)); } } } return true; }
[1.8.9] Armor Equipted shows no Texture ... -_-(path finding is wrong)
in Modder Support
Posted
Check this post: http://www.minecraftforge.net/forum/index.php?topic=42141.0