Jump to content

[1.6.4][SOLVED]Armor not giving player wearing it potion effects


Recommended Posts

Posted

When I equip the armor, it doesn't apply potion effects. I know it is probably being caused by something simple, but I can't figure out what. Here's my code:

Armor File:

 

package firearmor.armor;

import java.io.Console;

import firearmor.FireArmorBaseFile;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;

public class FireArmor extends ItemArmor
{
    public FireArmor(int par1, EnumArmorMaterial par2EnumArmorMaterial,
                     int par3, int par4, String armornamePrefix)
    {
        super(par1, par2EnumArmorMaterial, par3, par4);
        this.material = par2EnumArmorMaterial;
        par2EnumArmorMaterial.getDamageReductionAmount(par4);
        this.setMaxDamage(par2EnumArmorMaterial.getDurability(par4));
        this.maxStackSize = 1;
        armorNamePrefix = armornamePrefix;
    }
    public String armorNamePrefix;
    public EnumArmorMaterial material;
    @Override
    public boolean getIsRepairable(ItemStack tool, ItemStack material) {
    	return material.itemID == FireArmorBaseFile.fireCore.itemID;
    }
    public String getArmorTexture(ItemStack stack, Entity entity, int slot, int layer)
    {
        if (stack.toString().contains("leggings"))
        {
            return "firearmor:textures/models/armor/fire2.png";
        }

        if (stack.toString().contains("Leggings")) if (itemID == FireArmorBaseFile.FireLeggings.itemID)
            {
                return "firearmor:textures/models/armor/fire2.png";
            }

        return "firearmor:textures/models/armor/fire1.png";
    }
    public void registerIcons(IconRegister par1iconRegister)
    {
        if (itemID == FireArmorBaseFile.FireHelmet.itemID)
        {
            itemIcon = par1iconRegister.registerIcon("firearmor:FireHelmet");
        }

        if (itemID == FireArmorBaseFile.FireChestplate.itemID)
        {
            itemIcon = par1iconRegister.registerIcon("firearmor:FireChestplate");
        }

        if (itemID == FireArmorBaseFile.FireLeggings.itemID)
        {
            itemIcon = par1iconRegister.registerIcon("firearmor:FireLeggings");
        }

        if (itemID == FireArmorBaseFile.FireBoots.itemID)
        {
            itemIcon = par1iconRegister.registerIcon("firearmor:FireBoots");
        }
    }
    @Override
    public void onArmorTickUpdate(World world, EntityPlayer player, ItemStack itemStack) {
    	if (player.getCurrentArmor(0) != null && player.getCurrentArmor(1) != null && player.getCurrentArmor(2) != null && player.getCurrentArmor(3) != null) {
		ItemStack helmet = player.getCurrentArmor(0);
		ItemStack plate = player.getCurrentArmor(1);
		ItemStack legs = player.getCurrentArmor(2);
		ItemStack boots = player.getCurrentArmor(3); 

		if (helmet.getItem() == FireArmorBaseFile.FireHelmet && plate.getItem() == FireArmorBaseFile.FireChestplate && legs.getItem() == FireArmorBaseFile.FireLeggings && boots.getItem() == FireArmorBaseFile.FireBoots) {
			player.addPotionEffect((new PotionEffect(Potion.fireResistance.getId(), 400, 0)));
		}
		if (helmet.getItem() == FireArmorBaseFile.FireHelmet) {
			player.addPotionEffect((new PotionEffect(Potion.nightVision.getId(), 400, 0)));
		}
		if (legs.getItem() == FireArmorBaseFile.FireLeggings) {
			player.addPotionEffect((new PotionEffect(Potion.moveSpeed.getId(), 400, 0)));
		}
	}
    }

}

 

Base File:

 

package firearmor;

import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.EnumHelper;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import firearmor.util.CommonProxy;
import firearmor.items.*;
import firearmor.armor.*;
import firearmor.tabs.TabFireArmor;

@Mod(modid="firearmor", name="Fire's Armors", version="0.1.0")
@NetworkMod(clientSideRequired=true)
public class FireArmorBaseFile {

        @Instance(value = "firearmor")
        public static FireArmorBaseFile instance;
        //Creative Tab Registry
        public static CreativeTabs TabFireArmor = new TabFireArmor(CreativeTabs.getNextID(), "Fire's Armors");
        //Armor Materials
        public static EnumArmorMaterial armorFire = EnumHelper.addArmorMaterial("FIRE", 15, new int[]{3, 7, 5, 3}, 45);
        //Item Registry
        public static Item fireCore = new fireCore(11255).setCreativeTab(TabFireArmor).setUnlocalizedName("fireCore").setCreativeTab(TabFireArmor);
        public static Item FireHelmet = new FireArmor(11256, armorFire, 0, 0, "FIRE").setUnlocalizedName("FireHelmet").setCreativeTab(TabFireArmor);
        public static Item FireChestplate = new FireArmor(11257, armorFire, 0, 1, "FIRE").setUnlocalizedName("FireChestplate").setCreativeTab(TabFireArmor);
        public static Item FireLeggings = new FireArmor(11258, armorFire, 0, 2, "FIRE").setUnlocalizedName("FireLeggings").setCreativeTab(TabFireArmor);
        public static Item FireBoots = new FireArmor(11259, armorFire, 0, 3, "FIRE").setUnlocalizedName("FireBoots").setCreativeTab(TabFireArmor);
        
        @SidedProxy(clientSide="firearmor.util.ClientProxy", serverSide="firearmor.util.CommonProxy")
        public static CommonProxy proxy;
        
        @EventHandler
        public void preInit(FMLPreInitializationEvent event) {
        }
        
        @EventHandler
        public void load(FMLInitializationEvent event) {
                proxy.registerRenderers();
                //Visible Name Registry
                LanguageRegistry.addName(FireHelmet, "The_Fireplace Helmet");
                LanguageRegistry.addName(FireChestplate, "The_Fireplace Chestplate");
                LanguageRegistry.addName(FireLeggings, "The_Fireplace Greaves");
                LanguageRegistry.addName(FireBoots, "The_Fireplace Boots");
                LanguageRegistry.addName(fireCore, "The_Fireplace Core");
                //ItemStacks
                ItemStack fireCoreStack = new ItemStack(fireCore);
                ItemStack enderPearlStack = new ItemStack(Item.enderPearl);
                ItemStack lavaStack = new ItemStack(Item.bucketLava);
                ItemStack blazePowderStack = new ItemStack(Item.blazePowder);
                ItemStack orangeDyeStack = new ItemStack(Item.dyePowder, 1, 14);
                ItemStack fireHelmStack = new ItemStack(FireHelmet);
                ItemStack fireChestStack = new ItemStack(FireChestplate);
                ItemStack fireBootsStack = new ItemStack(FireBoots);
                ItemStack fireLegsStack = new ItemStack(FireLeggings);
                ItemStack ObsidianStack = new ItemStack(Block.obsidian);
                ItemStack NetherrackStack = new ItemStack(Block.netherrack);
                ItemStack GlowstoneStack = new ItemStack(Block.glowStone);
                //Recipes
                GameRegistry.addRecipe(fireCoreStack, "xyx", "yzy", "xyx",
                		'x', lavaStack, 'y', blazePowderStack, 'z', enderPearlStack);
                GameRegistry.addRecipe(fireHelmStack, "ooo", "oco", "nen",
                		'o', ObsidianStack, 'c', fireCoreStack, 'n', GlowstoneStack, 'e', enderPearlStack);
                GameRegistry.addRecipe(fireChestStack, "oeo", "ncn", "oeo",
                		'o', ObsidianStack, 'c', fireCoreStack, 'n', GlowstoneStack, 'e', enderPearlStack);
                GameRegistry.addRecipe(fireLegsStack, "oeo", "n n", "e e",
                		'o', ObsidianStack, 'c', fireCoreStack, 'n', GlowstoneStack, 'e', enderPearlStack);
                GameRegistry.addRecipe(fireBootsStack, "d d", "oeo", "n n",
                		'o', ObsidianStack, 'd', orangeDyeStack, 'n', GlowstoneStack, 'e', enderPearlStack);
        }
        
        @EventHandler
        public void postInit(FMLPostInitializationEvent event) {
        }
}

 

Let me know if I left anything out of the post, and I will edit it in.

If I helped please press the Thank You button.

 

Check out my mods at http://www.curse.com/users/The_Fireplace/projects

Posted

UPDATE:

I have narrowed it down to the following section of code:

 

if (helmet.getItem() == FireArmorBaseFile.FireHelmet && plate.getItem() == FireArmorBaseFile.FireChestplate && legs.getItem() == FireArmorBaseFile.FireLeggings && boots.getItem() == FireArmorBaseFile.FireBoots) {
player.addPotionEffect((new PotionEffect(Potion.fireResistance.getId(), 400, 0)));
}
if (helmet.getItem() == FireArmorBaseFile.FireHelmet) {
player.addPotionEffect((new PotionEffect(Potion.nightVision.getId(), 400, 0)));
}
if (legs.getItem() == FireArmorBaseFile.FireLeggings) {
player.addPotionEffect((new PotionEffect(Potion.moveSpeed.getId(), 400, 0)));
}

 

If I helped please press the Thank You button.

 

Check out my mods at http://www.curse.com/users/The_Fireplace/projects

Posted

And this is where we do things like

 

System.out.println(helmet.getItem() == FireArmorBaseFile.FireHelmet)

 

And see what its doing.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Ok, but that doesn't tell us what's failing.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Hi

 

if (helmet.getItem() == FireArmorBaseFile.FireHelmet) {
  player.addPotionEffect((new PotionEffect(Potion.nightVision.getId(), 400, 0)));
}

 

So you say that this line is being executed

if (helmet.getItem() == FireArmorBaseFile.FireHelmet

but it is never true, even when you think the helmet is being worn

 

Depending on how you've coded FireHelmet, this might work instead

if (helmet.getItem().itemID == FireArmorBaseFile.FireHelmet.itemID)

 

BTW that should probably be FireArmorBaseFile.fireHelmet ?

 

If that doesn't work, show us your FireArmorBaseFile.java?

 

-TGG

 

 

Posted

So just to clarify, what do the if statements return that are checking whether or not the player is wearing the armor? We really don't know what the exact problem is...

If you really want help, give that modder a thank you.

 

Modders LOVE thank yous.

Posted

I'm pretty sure you've got the armor slots backwards; the vanilla java docs on this are very confusing, but this is what I've come up with after testing quite a bit:

 

// this is what the java docs will tell you, but it's for rendering position only:

Armor types as used in armor class: 0 helm, 1 chest, 2 legs, 3 boots

 

// this is what is actually used for storing the positions in the player inventory:

Armor types as used on player: 0 boots, 1 legs, 2 chest, 3 helm

 

Use the second set of values with getCurrentArmor or add one for getCurrentItemOrArmor

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • When i try to join my friends server with mods it just says failed to log in: the authentication servers are currently not reachable. I've been having this issue for a while now and no method I've tried to fix it works. I've seen a lot of people fixing it by modifying the host.txt file and removing anything related to Mojang but when I open mine there's nothing related to Mojang there. I also tried flushing DNS cache, and changing my IPV6 to 8888, but nothing works.  It only happens when the mods are on too. When I join my friends server on vanilla it works, but not with mods. I can join multiplayer servers like hypixel. I can also play singleplayer with the mods and it works perfectly. The mods are up to date with the versions and the servers, but it just never gets past "Logging in" when i try to join their server. I use Curseforge to launch my mods, so that could maybe have something to do with it because it's technically a third party server, but it hasn't given me any trouble besides this one issue. I do not have MCLeaks and don't know what that is, but how can i search for it anyway to make sure? I have uninstalled minecraft launcher, updated my microsoft and my videocard drivers, reset my wifi and checked my parental settings (I am the owner on my computer), flushed my dns, modifying my host file to delete mojang but there's nothing with mojang on there, disabled my firewall, changed my IPV6 domain to 8888, restarted my router, and none of that works. I have researched this issue thoroughly and tried every solution I have came across and nothing is fixing the problem so i have come here as a last ditch effort. All i want to do is play mods with my friend. My friend has no issues with the server or mods and he has it through curseforge too. I would like further assistance in any way you think could help or even refer me to another forum that could help with this. Genuinely I cannot figure out why it doesn't work I would love any sort of further help.  
    • been getting this error and followed the old tick loop post however i cant figure out what file to delete Description: Exception in server tick loop java.lang.NullPointerException: Cannot invoke "net.minecraft.world.level.LevelAccessor.m_7654_()" because the return value of "net.minecraftforge.event.level.LevelEvent$Unload.getLevel()" is null     at com.lion.graveyard.platform.forge.HordeSpawner.onWorldUnload(HordeSpawner.java:41) ~[The_Graveyard_3.1_(FORGE)_for_1.20.1.jar%23196!/:?] {re:classloading}     at com.lion.graveyard.platform.forge.__HordeSpawner_onWorldUnload_Unload.invoke(.dynamic) ~[The_Graveyard_3.1_(FORGE)_for_1.20.1.jar%23196!/:?] {re:classloading,pl:eventbus:B}     at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.mehvahdjukaar.moonlight.api.platform.forge.PlatHelperImpl.invokeLevelUnload(PlatHelperImpl.java:279) ~[moonlight-1.20-2.13.66-forge.jar%23185!/:?] {re:classloading}     at net.mehvahdjukaar.moonlight.api.platform.PlatHelper.invokeLevelUnload(PlatHelper.java) ~[moonlight-1.20-2.13.66-forge.jar%23185!/:?] {re:mixin,re:classloading}     at net.mehvahdjukaar.moonlight.core.misc.FakeLevelManager.invalidate(FakeLevelManager.java:29) ~[moonlight-1.20-2.13.66-forge.jar%23185!/:?] {re:classloading}     at net.mehvahdjukaar.supplementaries.common.utils.fake_level.BlockTestLevel.invalidate(BlockTestLevel.java:34) ~[supplementaries-1.20-3.1.13.jar%23192!/:?] {re:classloading}     at net.mehvahdjukaar.supplementaries.common.block.faucet.FaucetBehaviorsManager.onReloadWithLevel(FaucetBehaviorsManager.java:129) ~[supplementaries-1.20-3.1.13.jar%23192!/:?] {re:classloading}     at net.mehvahdjukaar.supplementaries.common.events.ServerEvents.onServerStart(ServerEvents.java:160) ~[supplementaries-1.20-3.1.13.jar%23192!/:?] {re:mixin,re:classloading}     at net.mehvahdjukaar.supplementaries.common.events.forge.ServerEventsForge.onServerStart(ServerEventsForge.java:119) ~[supplementaries-1.20-3.1.13.jar%23192!/:?] {re:classloading}     at net.mehvahdjukaar.supplementaries.common.events.forge.__ServerEventsForge_onServerStart_ServerStartedEvent.invoke(.dynamic) ~[supplementaries-1.20-3.1.13.jar%23192!/:?] {re:classloading,pl:eventbus:B}     at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.server.ServerLifecycleHooks.handleServerStarted(ServerLifecycleHooks.java:115) ~[forge-1.20.1-47.3.29-universal.jar%23212!/:?] {re:classloading}     at net.minecraft.server.MinecraftServer.m_130011_(MinecraftServer.java:638) ~[server-1.20.1-20230612.114412-srg.jar%23207!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraftserver,xf:fml:xaerominimap:xaero_minecraftserver,re:classloading,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraftserver,xf:fml:xaerominimap:xaero_minecraftserver,pl:mixin:APP:unionlib.mixins.json:MinecraftServerMixin,pl:mixin:APP:citadel.mixins.json:MinecraftServerMixin,pl:mixin:APP:balm.mixins.json:MinecraftServerMixin,pl:mixin:A}     at net.minecraft.server.MinecraftServer.m_206580_(MinecraftServer.java:251) ~[server-1.20.1-20230612.114412-srg.jar%23207!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraftserver,xf:fml:xaerominimap:xaero_minecraftserver,re:classloading,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraftserver,xf:fml:xaerominimap:xaero_minecraftserver,pl:mixin:APP:unionlib.mixins.json:MinecraftServerMixin,pl:mixin:APP:citadel.mixins.json:MinecraftServerMixin,pl:mixin:APP:balm.mixins.json:MinecraftServerMixin,pl:mixin:A}     at java.lang.Thread.run(Thread.java:833) ~[?:?] {}  
    • Online forums in general seem to be declining in popularity imo. There’s still value here for certain types of content, such as written tutorials and blog posts which would otherwise get lost in the chat history fairly quickly on Discord. Also for those that prefer the forums format ofc. But for faster support related topics, I agree that the Discord is probably your best bet at the moment. The speed of responses is also down to the ratio of volunteers - the player support forum still seems pretty active, but the coding ones much less so. Once you’re feeling more confident in your modding skills, be the change you want to see
    • try the same link, i swapped logs after sitting in the world for a few minutes then leaving. Lmk if it keeps happening then ill just send a video of the live log on modrinth
    • It is an issue with chimes
  • Topics

×
×
  • Create New...

Important Information

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