dude22072 Posted April 24, 2014 Posted April 24, 2014 Back in 1.6.4 i had this code: package dudesmods.lozmod2.proxy; import java.util.EnumSet; import javax.activation.CommandMap; import net.minecraft.client.Minecraft; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandHandler; import net.minecraft.command.CommandServerOp; import net.minecraft.command.ICommandSender; import net.minecraft.command.ServerCommand; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.server.MinecraftServer; import net.minecraft.server.integrated.IntegratedServer; import net.minecraft.world.WorldSettings; import net.minecraftforge.event.CommandEvent; import cpw.mods.fml.common.ITickHandler; import cpw.mods.fml.common.TickType; import dudesmods.lozmod2.LOZmod; import dudesmods.lozmod2.LOZmodTCAPI; public class CommonTickHandler implements ITickHandler { public void onPlayerTick(EntityPlayer player) { if(player.getCurrentItemOrArmor(0) != null && player.getHealth() < 19) { ItemStack hand = player.getCurrentItemOrArmor(0); if(hand.getItem() == LOZmod.healingStone && hand.getItemDamage() > 0 && hand.getItemDamage() < 500){ hand.damageItem(1, player); player.heal(2.0F); } } } @Override public void tickStart(EnumSet<TickType> type, Object... tickData) { if(type.equals(EnumSet.of(TickType.PLAYER))){ onPlayerTick((EntityPlayer) tickData[0]); } } @Override public void tickEnd(EnumSet<TickType> type, Object... tickData) { } @Override public EnumSet<TickType> ticks() { return EnumSet.of(TickType.PLAYER, TickType.SERVER); } @Override public String getLabel() { return null; } } What would the replacement for this be in 1.7.2??? Quote Legend of Zelda Mod[updated September 20th to 3.1.1] Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0] Fancy Cheeses[updated May 8th to 0.5.0]
chimera27 Posted April 24, 2014 Posted April 24, 2014 Get rid of the @ForgeSubscibe and replace it with @SubscribeEvent, and register it with this in your preinit: FMLCommonHandler.instance().bus().register(new CommonTickHandler()); instead of the old way. Also change onPlayerTick(tickevent event) into onPlayerTick(TickEvent.PlayerTickEvent event){ } Hope this helps!! Quote Creator of Metroid Cubed! Power Suits, Beams, Hypermode and more! http://i.imgur.com/ghgWmA3.jpg[/img]
coolAlias Posted April 24, 2014 Posted April 24, 2014 Better yet, remove your tick event / handler altogether and use the Item onArmorTick method, which is called every tick for custom armor while worn. @Override public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { if (this == LOZmod.healingStone && stack.getItemDamage() > 0 etc.) { // heal } } Quote http://i.imgur.com/NdrFdld.png[/img]
Recommended Posts
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.