Jump to content

[1.7.10] ISpecialArmor Issues


Izzy Axel

Recommended Posts

I just merged my armor (which implements ISpecialArmor) from 4 classes to 1, and I'm having 3 issues with it now.

 

 

First, I can't figure out what I need to change to alter the armor points it gives you; when it was 4 classes, it didn't give you any, and now it gives you 3 full icons for some reason, but nothing I change affects the points.

 

 

Second, I set it up to spawn particles when the wearer is hit at night, and merging it into 1 class broke this.  No clue why.

 

 

Third, I added step-up capabilities to the armor when the full set is worn, but even though player.stepHeight is being set correctly every time in every situation, I get no step-up capability.

 

 

PS, related to #2, the only vanilla particles that will show up for me when I try to spawn particles myself are the explosion varieties, why is this?

 

 

Armor

public class ItemMithrilArmor extends ItemArmor implements ISpecialArmor
{
   private String texturePath = Reference.MODID + ":" + "textures/models/armor/";
   public ItemMithrilArmor(String name, ArmorMaterial armormat, int renderIndex, int slot)
   {
      super(armormat, renderIndex, slot);
      setUnlocalizedName(name);
      setTextureName(Reference.MODID + ":" + getUnlocalizedName().substring(5));
      setMaxStackSize(1);
      setCreativeTab(AACreativeTab.aaTab);
      MinecraftForge.EVENT_BUS.register(this);
   }
   
   @Override
   public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
   {
      return slot == 2 ? Reference.MODID + ":textures/models/armor/mithrilArmor_layer_2.png" : Reference.MODID +  ":textures/models/armor/mithrilArmor_layer_1.png";
   }
   
   @Override
   public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot)
   {
      this.setDamage(stack, this.getDamage(stack) + damage);
   }
   
   @Override
   public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot)
   {
      WorldServer overworldInst = null;
      if(!player.worldObj.isRemote)
      {
         overworldInst = MinecraftServer.getServer().worldServers[0];
      }
      ArmorProperties mithArmor = null;
      if(overworldInst != null)
      {
         switch(slot)
         {
         case 0:
            mithArmor = new ArmorProperties(1, 1D, 2);
            if(!overworldInst.isDaytime())
            {
               mithArmor.AbsorbMax = 8;
            }
            else
            {
               mithArmor.AbsorbMax = 2;
            }
            return mithArmor;
         case 1:
            mithArmor = new ArmorProperties(4, 1D, 4);
            if(!overworldInst.isDaytime())
            {
               mithArmor.AbsorbMax = 16;
            }
            else
            {
               mithArmor.AbsorbMax = 4;
            }
            return mithArmor;
         case 2:
            mithArmor = new ArmorProperties(3, 1D, 3);
            if(!overworldInst.isDaytime())
            {
               mithArmor.AbsorbMax = 12;
            }
            else
            {
               mithArmor.AbsorbMax = 3;
            }
            return mithArmor;
         case 3:
            mithArmor = new ArmorProperties(2, 1D, 2);
            if(!overworldInst.isDaytime())
            {
               mithArmor.AbsorbMax = 8;
            }
            else
            {
               mithArmor.AbsorbMax = 2;
            }
            return mithArmor;
         default:
            mithArmor = new ArmorProperties(0, 0, 0);
         }
      }
      return mithArmor;
   }


   @Override
   public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot)
   {
      return slot;
   }
   
   @Override
   public void onArmorTick(World world, EntityPlayer player, ItemStack stack)
   {
      if(player.getEquipmentInSlot(1) != null && player.getEquipmentInSlot(2) != null && player.getEquipmentInSlot(3) != null && player.getEquipmentInSlot(4) != null)
      {
         if(player.getEquipmentInSlot(1).getItem() instanceof ItemMithrilArmor && player.getEquipmentInSlot(2).getItem() instanceof ItemMithrilArmor && player.getEquipmentInSlot(3).getItem() instanceof ItemMithrilArmor && player.getEquipmentInSlot(4).getItem() instanceof ItemMithrilArmor)
         {
            if(!world.isDaytime())
            {
               player.addPotionEffect(new PotionEffect(Potion.moveSpeed.getId(), 0, 1));
               player.addPotionEffect(new PotionEffect(Potion.jump.getId(), 0, 1));
               if(!player.isSneaking())
               {
                  if(player.stepHeight == 0.5F)
                  {
                     player.stepHeight = 1F;
                     System.out.println(player.stepHeight);
                  }
               }
               else
               {
                  if(player.stepHeight == 1F)
                  {
                     player.stepHeight = 0.5F;
                     System.out.println(player.stepHeight);
                  }
               }
            }
            else
            {
               if(player.stepHeight == 1F)
               {
                  player.stepHeight = 0.5F;
                  System.out.println(player.stepHeight);
               }
            }
         }
         else
         {
            if(player.stepHeight == 1F)
            {
               player.stepHeight = 0.5F;
               System.out.println(player.stepHeight);
            }
         }
      }
      else
      {
         if(player.stepHeight == 1F)
         {
            player.stepHeight = 0.5F;
            System.out.println(player.stepHeight);
         }
      }
   }
   
   @SubscribeEvent(receiveCanceled = true)
   public void reduceDurability(LivingHurtEvent event)
   {
      EntityLivingBase player = event.entityLiving;
      if(player instanceof EntityPlayer)
      {
         for (int i = 1; i < 5; ++i)
         {
            if(player.getEquipmentInSlot(i) != null)
            {
               Item entArmor = player.getEquipmentInSlot(i).getItem();
               ItemStack entArmorStack = player.getEquipmentInSlot(i);
               if(entArmor instanceof ItemMithrilArmor)
               {
                  if(player.dimension == 0 && !event.entityLiving.worldObj.isDaytime())
                  {
                     ArcaneArtificing.snw.sendToAllAround(new MessageMithrilArmorParticles(i - 1, player.getEntityId()), new TargetPoint(player.dimension, player.posX, player.posY, player.posZ, 40));
                     ArcaneArtificing.snw.sendTo(new MessageMithrilArmorParticles(i - 1, player.getEntityId()), (EntityPlayerMP)player);
                  }
                  damageArmor(player, entArmorStack, event.source, (int)event.ammount, i);
               }
            }
         }
      }
   }
}

 

Creation of Armor

        public static ArmorMaterial mithrilAM = EnumHelper.addArmorMaterial("MithrilAM", 2456, new int[]{4, 8, 6, 4}, -1);



   public static Item mithrilHelmet;
   public static Item mithrilChestplate;
   public static Item mithrilLeggings;
   public static Item mithrilBoots;



   mithrilHelmet = new ItemMithrilArmor("mithrilHelmet", mithrilAM, 0, 0);
        RegisterHelper.registerItem(mithrilHelmet);
      
        mithrilChestplate = new ItemMithrilArmor("mithrilChestplate", mithrilAM, 0, 1);
        RegisterHelper.registerItem(mithrilChestplate);
      
        mithrilLeggings = new ItemMithrilArmor("mithrilLeggings", mithrilAM, 0, 2);
        RegisterHelper.registerItem(mithrilLeggings);
       
        mithrilBoots = new ItemMithrilArmor("mithrilBoots", mithrilAM, 0, 3);
        RegisterHelper.registerItem(mithrilBoots);

 

Message/Handler

public class MessageMithrilArmorParticles implements IMessage
{
   public static int armorID;
   public static int playerID;
   public MessageMithrilArmorParticles(){}
   public MessageMithrilArmorParticles(int i, int p)
   {
      this.armorID = i;
      this.playerID = p;
   }
   
   @Override
   public void fromBytes(ByteBuf buf)
   {
      this.armorID = buf.readInt();
      this.playerID = buf.readInt();
   }
   @Override
   public void toBytes(ByteBuf buf)
   {
      buf.writeInt(armorID);
      buf.writeInt(playerID);
   }
   
   public static class MessageMithrilArmorParticlesHandler implements IMessageHandler<MessageMithrilArmorParticles, IMessage>
   {
      @Override
      public IMessage onMessage(MessageMithrilArmorParticles message, MessageContext ctx)
      {
         ArcaneArtificing.proxy.doMithrilArmorParticles(message.armorID, message.playerID);
         return null;
      }
   }
}

 

 

ClientProxy

@Override
   public void doMithrilArmorParticles(int armorID, int playerID)
   {
      if(Minecraft.getMinecraft().theWorld.getEntityByID(playerID) != null && Minecraft.getMinecraft().theWorld.getEntityByID(playerID) instanceof EntityPlayer)
      {
         EntityPlayer player = (EntityPlayer)Minecraft.getMinecraft().theWorld.getEntityByID(playerID);
         switch(armorID)
         {
         case 0:
            player.worldObj.spawnParticle("largeexplode", player.posX, player.posY + 1, player.posZ, 2D, 2D, 2D);
            break;
         case 1:
            player.worldObj.spawnParticle("largeexplode", player.posX, player.posY + 1, player.posZ, 2D, 2D, 2D);
            break;
         case 2:
            player.worldObj.spawnParticle("largeexplode", player.posX, player.posY + 1, player.posZ, 2D, 2D, 2D);
            break;
         case 3:
            player.worldObj.spawnParticle("largeexplode", player.posX, player.posY + 1, player.posZ, 2D, 2D, 2D);
            break;
         }
      }
   }

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • The version of what? I just imported the MDK into Eclipse. I haven't made any edits to the Java code in it or even any other files. I haven't even gotten to changing the modid from "examplemod" yet.
    • Captain WebGenesis is a Cyber skilled hacker with special abilities and skills that enact penetration to help victims of Crypto Fraudulent activities who are faced with cyber challenges get back their lost funds. Simply file your complaint through the website (https://captainwebgenesis. com) and have all your crypto recovered back.
    • The crash log keeps saying something about the tick rate. Can someone please help me fix?   ---- Minecraft Crash Report ---- // Everything's going to plan. No, really, that was supposed to happen. Time: 2024-06-21 16:24:55 Description: Exception in server tick loop java.lang.NullPointerException: Cannot invoke "com.cobblemon.mod.common.api.conditional.RegistryLikeCondition.fits(Object, net.minecraft.core.Registry)" because "condition" is null at com.cobblemon.mod.common.api.spawning.condition.SpawningCondition.fits(SpawningCondition.java:85) ~[Cobblemon-forge-1.5.2+1.20.1.jar%23121!/:?] {re:classloading} at com.cobblemon.mod.common.api.spawning.condition.AreaTypeSpawningCondition.fits(AreaTypeSpawningCondition.java:30) ~[Cobblemon-forge-1.5.2+1.20.1.jar%23121!/:?] {re:classloading} at com.cobblemon.mod.common.api.spawning.condition.GroundedTypeSpawningCondition.fits(GroundedTypeSpawningCondition.java:28) ~[Cobblemon-forge-1.5.2+1.20.1.jar%23121!/:?] {re:classloading} at com.cobblemon.mod.common.api.spawning.condition.GroundedTypeSpawningCondition.fits(GroundedTypeSpawningCondition.java:24) ~[Cobblemon-forge-1.5.2+1.20.1.jar%23121!/:?] {re:classloading} at com.cobblemon.mod.common.api.spawning.condition.SpawningCondition.isSatisfiedBy(SpawningCondition.java:68) ~[Cobblemon-forge-1.5.2+1.20.1.jar%23121!/:?] {re:classloading} at com.cobblemon.mod.common.api.spawning.detail.SpawnDetail.isSatisfiedBy(SpawnDetail.java:78) ~[Cobblemon-forge-1.5.2+1.20.1.jar%23121!/:?] {re:classloading} at com.cobblemon.mod.common.api.spawning.spawner.Spawner$DefaultImpls.getMatchingSpawns(Spawner.java:42) ~[Cobblemon-forge-1.5.2+1.20.1.jar%23121!/:?] {re:classloading} at com.cobblemon.mod.common.api.spawning.spawner.TickingSpawner.getMatchingSpawns(TickingSpawner.java:31) ~[Cobblemon-forge-1.5.2+1.20.1.jar%23121!/:?] {re:classloading} at com.cobblemon.mod.common.api.spawning.selection.FlatContextWeightedSelector.getSelectionData(FlatContextWeightedSelector.java:79) ~[Cobblemon-forge-1.5.2+1.20.1.jar%23121!/:?] {re:classloading} at com.cobblemon.mod.common.api.spawning.selection.FlatContextWeightedSelector.select(FlatContextWeightedSelector.java:106) ~[Cobblemon-forge-1.5.2+1.20.1.jar%23121!/:?] {re:classloading} at com.cobblemon.mod.common.api.spawning.spawner.AreaSpawner.run(AreaSpawner.java:94) ~[Cobblemon-forge-1.5.2+1.20.1.jar%23121!/:?] {re:classloading} at com.cobblemon.mod.common.api.spawning.spawner.TickingSpawner.tick(TickingSpawner.java:71) ~[Cobblemon-forge-1.5.2+1.20.1.jar%23121!/:?] {re:classloading} at com.cobblemon.mod.common.api.spawning.SpawnerManager.onServerTick(SpawnerManager.java:58) ~[Cobblemon-forge-1.5.2+1.20.1.jar%23121!/:?] {re:classloading} at com.cobblemon.mod.common.events.ServerTickHandler.onTick(ServerTickHandler.java:20) ~[Cobblemon-forge-1.5.2+1.20.1.jar%23121!/:?] {re:classloading} at com.cobblemon.mod.common.Cobblemon$initialize$7.invoke(Cobblemon.java:368) ~[Cobblemon-forge-1.5.2+1.20.1.jar%23121!/:?] {re:classloading} at com.cobblemon.mod.common.Cobblemon$initialize$7.invoke(Cobblemon.java:368) ~[Cobblemon-forge-1.5.2+1.20.1.jar%23121!/:?] {re:classloading} at com.cobblemon.mod.common.api.reactive.ObservableSubscription.handle(ObservableSubscription.java:16) ~[Cobblemon-forge-1.5.2+1.20.1.jar%23121!/:?] {re:classloading} at com.cobblemon.mod.common.api.reactive.SimpleObservable.emit(SimpleObservable.java:39) ~[Cobblemon-forge-1.5.2+1.20.1.jar%23121!/:?] {re:classloading} at com.cobblemon.mod.forge.event.ForgePlatformEventHandler.onTick(ForgePlatformEventHandler.kt:172) ~[Cobblemon-forge-1.5.2+1.20.1.jar%23121!/:?] {re:classloading} at com.cobblemon.mod.forge.event.__ForgePlatformEventHandler_onTick_ServerTickEvent.invoke(.dynamic) ~[Cobblemon-forge-1.5.2+1.20.1.jar%23121!/:?] {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.event.ForgeEventFactory.onPostServerTick(ForgeEventFactory.java:950) ~[forge-1.20.1-47.2.17-universal.jar%23138!/:?] {re:classloading} at net.minecraft.server.MinecraftServer.m_5705_(MinecraftServer.java:835) ~[server-1.20.1-20230612.114412-srg.jar%23133!/:?] {re:computing_frames,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,re:mixin,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.m_130011_(MinecraftServer.java:661) ~[server-1.20.1-20230612.114412-srg.jar%23133!/:?] {re:computing_frames,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,re:mixin,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.m_206580_(MinecraftServer.java:251) ~[server-1.20.1-20230612.114412-srg.jar%23133!/:?] {re:computing_frames,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,re:mixin,pl:accesstransformer:B} at java.lang.Thread.run(Thread.java:840) ~[?:?] {re:mixin}
    • okay i've managed to fix it. looks like i made the stupidest error known to man. i hadn't installed forge to the client, which i assumed only affected the launcher which wouldn't affect me because i used a third party one. evidently not. the more you know
    • tried a fresh install of above and beyond with java 8 installed. got a popup that says "Error: Unable to access jarfile forge-1.16.5-36.2.8.jar". every good programmer knows getting a different error means you've made progress!
  • Topics

×
×
  • Create New...

Important Information

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