Jump to content

Support for invisible armour


Alpvax

Recommended Posts

Within World.getClosestVunerablePlayer there is an invisibility check (if mobs can't see you they won't attack) which also calls EntityPlayer.getArmourVisibility:

    /**
     * When searching for vulnerable players, if a player is invisible, the return value of this is the chance of seeing
     * them anyway.
     */
    public float getArmorVisibility()
    {
        int i = 0;
        ItemStack[] aitemstack = this.inventory.armorInventory;
        int j = aitemstack.length;

        for (int k = 0; k < j; ++k)
        {
            ItemStack itemstack = aitemstack[k];

            if (itemstack != null)
            {
                ++i;
            }
        }

        return (float)i / (float)this.inventory.armorInventory.length;
    }

I think there should be some check for the armour being invisible (mmmPowersuits comes to mind), or semi-visible.

 

    /**
     * When searching for vulnerable players, if a player is invisible, the return value of this is the chance of seeing
     * them anyway.
     */
    public float getArmorVisibility()
    {
        float f = 0;
        ItemStack[] aitemstack = this.inventory.armorInventory;
        int j = aitemstack.length;

        for (int k = 0; k < j; ++k)
        {
            ItemStack itemstack = aitemstack[k];

            if (itemstack != null)
            {
                 //new function that returns the opacity of the ItemStack. default implementation would return 1.0F (i.e. fully opaque).
                f += itemstack.getItem().getVisibility(itemstack);
            }
        }

        return f / (float)this.inventory.armorInventory.length;
    }

I would have suggested adding this check to ItemArmor, but due to the fact that any item can be armour, it would have to be a general method.

Alternatively it could be part of a new interface IArmor, and the isValidArmor method would return if the item was an instanceof IArmor

public interface IArmor
{
public ItemArmor.ArmorMaterial getArmorMaterial(); //various other armor-related methods could be moved across
public float getArmorOpacity(ItemStack stack);
}

and the check would become:

Item item = itemstack.getItem();
f += item instanceof IArmor ? ((IArmor)item).getArmorOpacity(itemstack) : 1.0F;

Link to comment
Share on other sites

I have not checked this recently, but it would be sensible to also check the held item being in the hand (I imagine many mobs could see a floating sword or battale axe pretty well). An empty hand would add no visibility, whereas a full opaque sword would or hammer would.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • What is that in my files?
    • Hi! I tried the above method, but it did not work. There's my function. The message appears in the chat, but the item is not added to the inventory. I can’t figure out what the problem is, so please help. @SubscribeEvent public void onJoin(EntityJoinLevelEvent event) { if (event.getEntity() instanceof Player && event.getEntity().getCommandSenderWorld().isClientSide) { Minecraft.getInstance().player.getInventory().add(new ItemStack(Items.CARROT)); Entity playerEntity = event.getEntity(); playerEntity.sendSystemMessage(Component.nullToEmpty("Hello!")); } }  
    • Hi guys ! New around here.So my problem is,I'm trying to play modded minecraft with my gf.We played on lan perfectly.But when we try to make a server for hamachi,It displays an error message.   [08Haz2023 18:30:33.491] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--launchTarget, forgeserver, --fml.forgeVersion, 43.2.8, --fml.mcVersion, 1.19.2, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20220805.130853] [08Haz2023 18:30:33.497] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 10.0.8+10.0.8+main.0ef7e830 starting: java version 19.0.1 by Oracle Corporation; OS Windows 10 arch amd64 version 10.0 [08Haz2023 18:30:33.798] [main/INFO] [optifine.OptiFineTransformationService/]: OptiFineTransformationService.onLoad [08Haz2023 18:30:33.799] [main/INFO] [optifine.OptiFineTransformationService/]: OptiFine ZIP file URL: union:/C:/Users/user/Desktop/Yeni%20klasör/mods/OptiFine-OptiFine-1.19.2_HD_U_I1.jar%23118!/ [08Haz2023 18:30:33.848] [main/INFO] [optifine.OptiFineTransformationService/]: OptiFine ZIP file: C:\Users\user\Desktop\Yeni klasör\mods\OptiFine-OptiFine-1.19.2_HD_U_I1.jar [08Haz2023 18:30:33.850] [main/INFO] [optifine.OptiFineTransformer/]: Target.PRE_CLASS is available [08Haz2023 18:30:33.916] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.5 Source=union:/C:/Users/user/Desktop/Yeni%20klasör/libraries/org/spongepowered/mixin/0.8.5/mixin-0.8.5.jar%2363!/ Service=ModLauncher Env=SERVER [08Haz2023 18:30:33.927] [main/INFO] [optifine.OptiFineTransformationService/]: OptiFineTransformationService.initialize [08Haz2023 18:30:34.282] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\user\Desktop\Yeni klasör\libraries\net\minecraftforge\fmlcore\1.19.2-43.2.8\fmlcore-1.19.2-43.2.8.jar is missing mods.toml file [08Haz2023 18:30:34.287] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\user\Desktop\Yeni klasör\libraries\net\minecraftforge\javafmllanguage\1.19.2-43.2.8\javafmllanguage-1.19.2-43.2.8.jar is missing mods.toml file [08Haz2023 18:30:34.291] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\user\Desktop\Yeni klasör\libraries\net\minecraftforge\lowcodelanguage\1.19.2-43.2.8\lowcodelanguage-1.19.2-43.2.8.jar is missing mods.toml file [08Haz2023 18:30:34.296] [main/WARN] [net.minecraftforge.fml.loading.moddiscovery.ModFileParser/LOADING]: Mod file C:\Users\user\Desktop\Yeni klasör\libraries\net\minecraftforge\mclanguage\1.19.2-43.2.8\mclanguage-1.19.2-43.2.8.jar is missing mods.toml file [08Haz2023 18:30:34.386] [main/INFO] [net.minecraftforge.fml.loading.moddiscovery.JarInJarDependencyLocator/]: No dependencies to load found. Skipping! [08Haz2023 18:30:35.056] [main/INFO] [optifine.OptiFineTransformationService/]: OptiFineTransformationService.transformers [08Haz2023 18:30:35.063] [main/INFO] [optifine.OptiFineTransformer/]: Targets: 386 [08Haz2023 18:30:35.557] [main/INFO] [optifine.OptiFineTransformationService/]: additionalClassesLocator: [optifine., net.optifine.] [08Haz2023 18:30:35.906] [main/INFO] [mixin/]: Compatibility level set to JAVA_17 [08Haz2023 18:30:35.953] [main/ERROR] [mixin/]: Mixin config rottencreatures-common.mixins.json does not specify "minVersion" property [08Haz2023 18:30:35.957] [main/ERROR] [mixin/]: Mixin config rottencreatures.mixins.json does not specify "minVersion" property [08Haz2023 18:30:36.099] [main/INFO] [mixin/]: Successfully loaded Mixin Connector [org.tlauncher.MixinConnector] [08Haz2023 18:30:36.101] [main/INFO] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Launching target 'forgeserver' with arguments [] [08Haz2023 18:30:36.122] [main/WARN] [mixin/]: Reference map '${refmap_target}refmap.json' for corgilib.forge.mixins.json could not be read. If this is a development environment you can ignore this message [08Haz2023 18:30:36.139] [main/WARN] [mixin/]: Reference map 'rottencreatures-forge-refmap.json' for rottencreatures.mixins.json could not be read. If this is a development environment you can ignore this message [08Haz2023 18:30:36.565] [main/ERROR] [net.minecraftforge.fml.loading.RuntimeDistCleaner/DISTXFORM]: Attempted to load class net/minecraft/client/gui/screens/Screen for invalid dist DEDICATED_SERVER [08Haz2023 18:30:36.566] [main/WARN] [mixin/]: Error loading class: net/minecraft/client/gui/screens/TitleScreen (java.lang.RuntimeException: Attempted to load class net/minecraft/client/gui/screens/Screen for invalid dist DEDICATED_SERVER) [08Haz2023 18:30:36.566] [main/WARN] [mixin/]: @Mixin target net.minecraft.client.gui.screens.TitleScreen was not found tlskincape-mixins.json:MixinMainMenu [08Haz2023 18:30:36.581] [main/WARN] [mixin/]: Error loading class: net/minecraft/client/model/PlayerModel (java.lang.ClassNotFoundException: net.minecraft.client.model.PlayerModel) [08Haz2023 18:30:36.582] [main/WARN] [mixin/]: @Mixin target net.minecraft.client.model.PlayerModel was not found tlskincape-mixins.json:MixinPlayerModel   that's from logs folder.
    • LivingAttackEvent is called inside the hurt function of LivingEntity. this means that whenever a living entity is attacked, forge will create an instance of new LivingAttackEvent and hand it to all subscribed functions 
    • ok after quitting and restarting I now get this crash report  
  • Topics

×
×
  • Create New...

Important Information

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