Topic category: Advanced modding
Hey, so I want my armor to allow the player to float down to the ground like a chicken. This is my code:
@SubscribeEvent
public void onPlayerTickEvent(PlayerTickEvent event)
{
if (event.entityLiving instanceof EntityPlayer && ((EntityPlayer)event.entityLiving).inventory.armorItemInSlot(3) != null && ((EntityPlayer)event.entityLiving).inventory.armorItemInSlot(3).getItem() == mcreator_stevenUniverseArmor.helmet){
}
if (!player.isAirBorne || !player.isSneaking()) {
return;
}
player.motionY = -0.05;
}
@SuscribeEvent
public void onLivingFallEvent(LivingFallEvent event) {
if (!(event.entity instanceof EntityPlayer)) {
return;
}
EntityPlayer player = (EntityPlayer) event.entity;
if (!player.isSneaking()) {
return;
}
event.setCancled(true);
}
}
public mcreator_stevenFloatandFall(){}
but it gives me this errors:
/Applications/MCreator 1.5.9 [1.7.10] Mac-Linux/forge/build/sources/java/mod/mcreator/mcreator_stevenFloatandFall.java:116: error: cannot find symbol
>public void onPlayerTickEvent(PlayerTickEvent event)
> ^
> symbol: class PlayerTickEvent
> location: class GUIRenderEventClass
>/Applications/MCreator 1.5.9 [1.7.10] Mac-Linux/forge/build/sources/java/mod/mcreator/mcreator_stevenFloatandFall.java:127: error: cannot find symbol
>@SuscribeEvent
> ^
> symbol: class SuscribeEvent
> location: class GUIRenderEventClass
>/Applications/MCreator 1.5.9 [1.7.10] Mac-Linux/forge/build/sources/java/mod/mcreator/mcreator_stevenFloatandFall.java:120: error: cannot find symbol
> if (!player.isAirBorne || !player.isSneaking()) {
> ^
> symbol: variable player
> location: class GUIRenderEventClass
>/Applications/MCreator 1.5.9 [1.7.10] Mac-Linux/forge/build/sources/java/mod/mcreator/mcreator_stevenFloatandFall.java:120: error: cannot find symbol
> if (!player.isAirBorne || !player.isSneaking()) {
> ^
> symbol: variable player
> location: class GUIRenderEventClass
>/Applications/MCreator 1.5.9 [1.7.10] Mac-Linux/forge/build/sources/java/mod/mcreator/mcreator_stevenFloatandFall.java:124: error: cannot find symbol
> player.motionY = -0.05;
> ^
> symbol: variable player
> location: class GUIRenderEventClass
>/Applications/MCreator 1.5.9 [1.7.10] Mac-Linux/forge/build/sources/java/mod/mcreator/mcreator_stevenFloatandFall.java:140: error: cannot find symbol
> event.setCancled(true);
> ^
> symbol: method setCancled(boolean)
> location: variable event of type LivingFallEvent
>6 errors
>:compileJava FAILED
Can anyone help?
I think nuparu00 could help
heres something that may help but it may only be until the next update but i guess you could just use it for ver 1.11 when the next version of this program comes out, the levitation command is bugged and if you put it too high it actually makes you fall slowly heres a video of a guy doing it: https://www.youtube.com/watch?v=Tnm7uU-eBDo you could set the armour to have this ability while equiped but yea unfortunatly you would have to wait i think? as that command only came into play in 1.11 i think? but yea if I'm wrong someone correct me and that would mean you could use it in an execute command? keep in mind it is a glitch so it might bug out on you?
@#2 I'm using 1.7.10 so it won't work for me.
Nuparu00 (big thank you to him) gave me code, so I added It, but it doesn't affect the speed of my fall. Maybe I didn't add it in correctly?
static{
ItemArmor.ArmorMaterial enuma = EnumHelper.addArmorMaterial("STEVENUNIVERSEARMOR", 33, new int[] {20, 8, 6, 3}, 10);
int armorPreffix = 0;if(FMLCommonHandler.instance().getEffectiveSide()==Side.CLIENT) armorPreffix = RenderingRegistry.addNewArmourRendererPrefix("steven");
helmet = (new ItemArmor(enuma, armorPreffix, 0){
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
if(player.isAirBorne || !player.isSneaking()){
return;
}
player.motionY = -0.01;
}
}).setUnlocalizedName("Steven").setTextureName("Steven");helmet.setMaxStackSize(1);
body = (new ItemArmor(enuma, armorPreffix, 1){public void onArmorTick(World world, EntityPlayer entity, ItemStack itemStack){
int i = (int)entity.posX;
int j = (int)entity.posY;
int k = (int)entity.posZ;
}
}).setUnlocalizedName("0").setTextureName("0");body.setMaxStackSize(1);
legs = (new ItemArmor(enuma, armorPreffix, 2){public void onArmorTick(World world, EntityPlayer entity, ItemStack itemStack){
int i = (int)entity.posX;
int j = (int)entity.posY;
int k = (int)entity.posZ;
}
}).setUnlocalizedName("0").setTextureName("0");legs.setMaxStackSize(1);
boots = (new ItemArmor(enuma, armorPreffix, 3){public void onArmorTick(World world, EntityPlayer entity, ItemStack itemStack){
int i = (int)entity.posX;
int j = (int)entity.posY;
int k = (int)entity.posZ;
}
}).setUnlocalizedName("0").setTextureName("0");boots.setMaxStackSize(1);
Item.itemRegistry.addObject(690, "Steven", helmet);
}
}