Sounds like you are using a tutorial. There is a tutorial in the Tutorial section about how to add an invisibility potion or some other potion with a custom armor. Unfortunately, the tutorial has "bugs" in it. Every week or so, someone tries to follow it and asks a bunch of questions about why their code isn't working.
At this point, you can post more of your code or practice with other tutorials that do actually work. Once you get the fundamentals down on how to mod, you might come back to this, because as far as I know, there is no "complete" tutorial on what you are trying to do, but if you can do a Google search, you should find posts where people did finally get this to work (don't try a forum search, it sucks
public class InvisibilityArmor extends ItemArmor {
public InvisibilityArmor(ArmorMaterial material, int id, int placement) {
super(material, id, placement);
setCreativeTab(MainClass.MythicalBlacksmiths);
if (placement == 0) {
this.setTextureName(MainClass.MODID + ":icloak");
}
}
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
if (stack.getItem() == MainClass.InvisibilityCloak){
return MainClass.MODID + ":textures/models/armor/icloak.png";
} else{
return null;
}
this is my code for the invisibility armor I know it works it has turned me invisible before the issue that I am running into is that even if I am using a potion, it still won't turn the armors invisible (excluding this armor). Also just so you know I am in 1.7.10
Yes, that looks like the code from the tutorial, which has a serious flaw.
The onArmorTick is only called if the player is wearing armor, but since you are using a potion, it will just wear off when the armor is removed (other posters have tired to use this to add something and then remove it when not being worn).
The last parameter in the PotionEffect that you are setting to 0, is the level. Level 0 is essentially a potion added, but does nothing or is very weak, not sure which. You need to set that to at least a 1. If you look in the wiki, it lists the levels for invisibility. I think you use Level - 1 for the value.
So, right, a potion of invisibility does not work on armor, so that is why the code I gave you to not render the armor.
The Meaning of Life, the Universe, and Everything.
Join Date:
5/22/2015
Posts:
99
Member Details
Right I know about potion levels but what I am trying to figure out is when the player has that specific potion effect on, can I make the other armor they wear invisible. Also, I want the potion effect to wear off when they remove the armor and level 0 is actually the level that is considered 1, if I were to put a 1 in instead of a 0 it would be called invisibility 2 and setting the value to zero still gives the invisibility potion effect. I realize that the code you gave me is supposed to stop the armor from rendering but from what I can tell it isn't stopping it at all. Also, I tried setting the value to -1 with no difference and same with setting the value to 1
I'm pretty sure my code works, as I use it in my own mod. So you might want to post more code or share some a link to it. My mod is open source, and you can look at the code, but there is a lot of it, so that wouldn't be easy to find stuff in it
I never actually use the println, I use a LogHelper class, but here is what I saw someone else use:
System.out.println("whatever");
You will need to learn how to debug a program if you do anything other than the simplest of mods. Find a tutorial on that for Eclipse, it is a skill you will need many times
So your "debugging" of you code tells you, that since the "whatever" wasn't printed, the event is not firing.
The most common cause of this is that the event is not registered. That code I think should be in your Main mod file. I don't recall if you've shown the source for that.
You have an extra "{" in there. That should be causing an error for that file.
@EventHandler
public void preInit(FMLPreInitializationEvent event){
MinecraftForge.EVENT_BUS.register(new ArmorHandler());{ // Right here, is an extra {
}
So the default when used by the blaze is 3.0F, but set it to 10.0F or whatever you want. You can also remove the if statement about check for a EntityBlaze.
You will also need to create a new SnowBall class that uses the EntitySnowBall you extended.
Take a look at these two classes I made for a Rock:
The Meaning of Life, the Universe, and Everything.
Join Date:
5/22/2015
Posts:
99
Member Details
So I've been going over your code and I noticed you registered your Armor Handler thingy in your CommonProxy like
public void registerSubscriptions() {
MinecraftForge.EVENT_BUS.register(new DragonPlayerEventHandler());
DragonPlayerEventHandler being where you have the whole isInvisible thing set up of course and then in your core you have set up DracoProxy.registerSubscriptions(); under FMLInitializationEvent not under FMLPreInitializationEvent I tried duplicating what you did but I ended up crashing but when I tried to put the registration under FMLInitializationEvent, the armor remained visible
Some things works best if you have a proxy class. The proxy is just a way to run some code on either the client, the server, or both. Yours crashed because there is also a special way to register the proxy, that if not done right will crash your mod.
Honestly I don't understand exactly why some stuff is where it is, just that I've seen others do it and it works for me too
As far as I know, registering the handler in the FMLInitializationEvent should work fine.
Sounds like you are using a tutorial. There is a tutorial in the Tutorial section about how to add an invisibility potion or some other potion with a custom armor. Unfortunately, the tutorial has "bugs" in it. Every week or so, someone tries to follow it and asks a bunch of questions about why their code isn't working.
At this point, you can post more of your code or practice with other tutorials that do actually work. Once you get the fundamentals down on how to mod, you might come back to this, because as far as I know, there is no "complete" tutorial on what you are trying to do, but if you can do a Google search, you should find posts where people did finally get this to work (don't try a forum search, it sucks
[url=2482915-wip-arkcraft-survival-evolved-dinos-taming]
package com.MythicalBlacksmith.armor;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import com.MythicalBlacksmith.MainClass;
public class InvisibilityArmor extends ItemArmor {
public InvisibilityArmor(ArmorMaterial material, int id, int placement) {
super(material, id, placement);
setCreativeTab(MainClass.MythicalBlacksmiths);
if (placement == 0) {
this.setTextureName(MainClass.MODID + ":icloak");
}
}
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
if (stack.getItem() == MainClass.InvisibilityCloak){
return MainClass.MODID + ":textures/models/armor/icloak.png";
} else{
return null;
}
}
public void onArmorTick(World world, EntityPlayer player, ItemStack itemstack)
{
if(player.getCurrentArmor(3) != null) {
ItemStack chestplate = player.getCurrentArmor(3);
if (chestplate.getItem() == MainClass.InvisibilityCloak) {
player.addPotionEffect(new PotionEffect(Potion.invisibility.id, 10, 0));
}
}
}
}
this is my code for the invisibility armor I know it works it has turned me invisible before the issue that I am running into is that even if I am using a potion, it still won't turn the armors invisible (excluding this armor). Also just so you know I am in 1.7.10
Yes, that looks like the code from the tutorial, which has a serious flaw.
The onArmorTick is only called if the player is wearing armor, but since you are using a potion, it will just wear off when the armor is removed (other posters have tired to use this to add something and then remove it when not being worn).
The last parameter in the PotionEffect that you are setting to 0, is the level. Level 0 is essentially a potion added, but does nothing or is very weak, not sure which. You need to set that to at least a 1. If you look in the wiki, it lists the levels for invisibility. I think you use Level - 1 for the value.
So, right, a potion of invisibility does not work on armor, so that is why the code I gave you to not render the armor.
[url=2482915-wip-arkcraft-survival-evolved-dinos-taming]
Right I know about potion levels but what I am trying to figure out is when the player has that specific potion effect on, can I make the other armor they wear invisible. Also, I want the potion effect to wear off when they remove the armor and level 0 is actually the level that is considered 1, if I were to put a 1 in instead of a 0 it would be called invisibility 2 and setting the value to zero still gives the invisibility potion effect. I realize that the code you gave me is supposed to stop the armor from rendering but from what I can tell it isn't stopping it at all. Also, I tried setting the value to -1 with no difference and same with setting the value to 1
I'm pretty sure my code works, as I use it in my own mod. So you might want to post more code or share some a link to it. My mod is open source, and you can look at the code, but there is a lot of it, so that wouldn't be easy to find stuff in it
[url=2482915-wip-arkcraft-survival-evolved-dinos-taming]
It says system.printIn is invalid, and I don't know what a break point is.
Also, I cant seem to make a package in that area, it always moves it to src
I never actually use the println, I use a LogHelper class, but here is what I saw someone else use:
[url=2482915-wip-arkcraft-survival-evolved-dinos-taming]
I put it in the ArmorHandler and "whatever" is not appearing in the console
Here is my code:
package handlers1;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.client.event.RenderPlayerEvent.SetArmorModel;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
public class ArmorHandler {
@EventHandler
public void onArmorEvent(SetArmorModel event) {
if (!event.entity.worldObj.isRemote && event.entity instanceof EntityPlayer) {
System.out.println("whatever");
if (((EntityPlayer) event.entity).isInvisible())
event.result = -1;
}
}
}
So your "debugging" of you code tells you, that since the "whatever" wasn't printed, the event is not firing.
The most common cause of this is that the event is not registered. That code I think should be in your Main mod file. I don't recall if you've shown the source for that.
[url=2482915-wip-arkcraft-survival-evolved-dinos-taming]
Here is what is in my Main Mod file:
@EventHandler
public void preInit(FMLPreInitializationEvent event){
MinecraftForge.EVENT_BUS.register(new ArmorHandler());{
}
You have an extra "{" in there. That should be causing an error for that file.
@EventHandler
public void preInit(FMLPreInitializationEvent event){
MinecraftForge.EVENT_BUS.register(new ArmorHandler());{ // Right here, is an extra {
}
[url=2482915-wip-arkcraft-survival-evolved-dinos-taming]
Removed it and it still doesn't work
Completely unrelated, do you know how to change the damage of a snowball?
You can extend the EntitySnowBall. You override the onImpact method (just copy it completely, but change this line:
p_70184_1_.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)b0);
to:
p_70184_1_.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 10.0F);
So the default when used by the blaze is 3.0F, but set it to 10.0F or whatever you want. You can also remove the if statement about check for a EntityBlaze.
You will also need to create a new SnowBall class that uses the EntitySnowBall you extended.
Take a look at these two classes I made for a Rock:
https://github.com/DracoAnimus/Coding/blob/master/src/main/java/net/wildbill22/draco/entities/EntityMyRock.java
https://github.com/DracoAnimus/Coding/blob/master/src/main/java/net/wildbill22/draco/items/ItemMyRock.java
There are other ways to do it, but this is how I did it.
[url=2482915-wip-arkcraft-survival-evolved-dinos-taming]
Same here, I didn't even have the extra curly brace and I still am having the same issue.
So I've been going over your code and I noticed you registered your Armor Handler thingy in your CommonProxy like
public void registerSubscriptions() {
MinecraftForge.EVENT_BUS.register(new DragonPlayerEventHandler());
DragonPlayerEventHandler being where you have the whole isInvisible thing set up of course and then in your core you have set up DracoProxy.registerSubscriptions(); under FMLInitializationEvent not under FMLPreInitializationEvent I tried duplicating what you did but I ended up crashing but when I tried to put the registration under FMLInitializationEvent, the armor remained visible
Some things works best if you have a proxy class. The proxy is just a way to run some code on either the client, the server, or both. Yours crashed because there is also a special way to register the proxy, that if not done right will crash your mod.
Honestly I don't understand exactly why some stuff is where it is, just that I've seen others do it and it works for me too
As far as I know, registering the handler in the FMLInitializationEvent should work fine.
[url=2482915-wip-arkcraft-survival-evolved-dinos-taming]