Posted December 23, 201212 yr i am trying to make afree flight jetpack but on landong i get fall damage why? package enderCraft; import java.util.EnumSet; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import org.lwjgl.input.Keyboard; import cpw.mods.fml.common.ITickHandler; import cpw.mods.fml.common.TickType; public class Tickjetpack implements ITickHandler{ public int tickpnumber = 0; public int isjactive = 0; public int isfull = 0; @Override public void tickStart(EnumSet<TickType> type, Object... tickData) { } @Override public void tickEnd(EnumSet<TickType> type, Object... tickData) { if(type.equals(EnumSet.of(TickType.RENDER))) { onRenderTick(); } else if(type.equals(EnumSet.of(TickType.CLIENT))) { Minecraft mc = Minecraft.getMinecraft(); GuiScreen gui = mc.currentScreen; if(gui != null) { onTickInGui(mc, gui); } else { onTickInGame(mc); } } } private void onTickInGame(Minecraft minecraft) { tickpnumber++; if (minecraft.thePlayer.inventory.armorItemInSlot(2) != null) { System.out.println("Armor ON"); System.out.println(tickpnumber); minecraft.thePlayer.fallDistance = 0.0F; ItemStack itemstack = minecraft.thePlayer.inventory.armorItemInSlot(2); if (itemstack.itemID == Main.enderjetpack.shiftedIndex) { isjactive = tickpnumber; if(minecraft.thePlayer.inventory.hasItem(Item.coal.shiftedIndex)){ if(minecraft.theWorld.isRemote){ if(isjactive == 200 && isfull == 0){ minecraft.thePlayer.addChatMessage("Jetpack at full power"); isfull++; } } if(isjactive == 200 && minecraft.thePlayer.capabilities.allowFlying == false){ minecraft.thePlayer.capabilities.allowFlying = true; minecraft.thePlayer.capabilities.isFlying = true; tickpnumber = 0; } }else{ if(tickpnumber == 200){ if(minecraft.theWorld.isRemote){ minecraft.thePlayer.addChatMessage("Unexpected error!!Do you have fuel?"); } } minecraft.thePlayer.capabilities.allowFlying = false; minecraft.thePlayer.capabilities.isFlying = false; if(isjactive == 400){ isjactive = 0; tickpnumber = 0; } } }else{ if(minecraft.theWorld.isRemote && tickpnumber == 160){ minecraft.thePlayer.addChatMessage("You took off your jetpack"); } minecraft.thePlayer.capabilities.allowFlying = false; minecraft.thePlayer.capabilities.isFlying = false; tickpnumber = 0; } } } private void onTickInGui(Minecraft minecraft, GuiScreen gui) { } private void onRenderTick() { } @Override public EnumSet<TickType> ticks() { return EnumSet.of(TickType.CLIENT, TickType.RENDER); } @Override public String getLabel() { return "TickHandler.CLIENT"; } }
December 24, 201212 yr I am new at moding but maybe you could make your Jetpack add feather falling to the player.
December 24, 201212 yr @ForgeSubscribe public void onEntityDammage(LivingHurtEvent event) { if (event.entity instanceof EntityPlayer && event.source == DamageSource.fall && event.isCancelable()) { if(((EntityPlayer)event.entity).inventory.armorInventory[1] instanceof YourJetpack) { if(((YourJetpack)((EntityPlayer)event.entity).inventory.armorInventory[1]).getIsOn()) { event.setCanceled(true) } } } } this assumes that the jetpack is worn on the chest, that the Class<? extends Item> has a method called getIsOn() that returns true if the jetpack is on, and that the Class<? extends Item>.class== YourJetpack.class Edit: Chibill: FeatherFall only goes on boots
December 25, 201212 yr Author @ForgeSubscribe public void onEntityDammage(LivingHurtEvent event) { if (event.entity instanceof EntityPlayer && event.source == DamageSource.fall && event.isCancelable()) { if(((EntityPlayer)event.entity).inventory.armorInventory[1] instanceof YourJetpack) { if(((YourJetpack)((EntityPlayer)event.entity).inventory.armorInventory[1]).getIsOn()) { event.setCanceled(true) } } } } this assumes that the jetpack is worn on the chest, that the Class<? extends Item> has a method called getIsOn() that returns true if the jetpack is on, and that the Class<? extends Item>.class== YourJetpack.class in which class do i put this in the tick handler or in a new class?
December 27, 201212 yr a simple way would be to add a crafting manager and when the jetpack is crafted it is given the enchant featherfalling X The Korecraft Mod
December 27, 201212 yr or you could do while(ForgeHooks.onLivingUpdate(player)){ player.fallDistance=0; } The Korecraft Mod
December 28, 201212 yr Author The @Mod is where I put all of the @ForgeSubscribe methods i did it but i cant get rid of teh eclipse errors
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.