in the server tick handler:
package SamTheBro1704.afterearthmod;
import java.util.EnumSet;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType;
public class ServerTickHandler implements ITickHandler {
public void onPlayerTick(EntityPlayer player) {
if(player.getCurrentItemOrArmor(3) != null) {
ItemStack Chestplate = player.getCurrentItemOrArmor(3);
if(Chestplate.getItem() == AfterEarthMod.TitaniumChestplate){
player.addPotionEffect((new PotionEffect(Potion.fireResistance.getId(), 20, 1)));
player.addPotionEffect((new PotionEffect(Potion.damageBoost.getId(), 20, 1)));
}
}
if(player.getCurrentItemOrArmor(1) != null) {
ItemStack Boots = player.getCurrentItemOrArmor(1);
if(Boots.getItem() == AfterEarthMod.TitaniumBoots){
player.addPotionEffect((new PotionEffect(Potion.fireResistance.getId(), 20, 1)));
}
}
if(player.getCurrentItemOrArmor(2) != null) {
ItemStack Leggings = player.getCurrentItemOrArmor(2);
if(Leggings.getItem() == AfterEarthMod.TitaniumLeggins){
player.addPotionEffect((new PotionEffect(Potion.fireResistance.getId(), 20, 1)));
}
}
if(player.getCurrentItemOrArmor(4) != null) {
ItemStack Helmet = player.getCurrentItemOrArmor(4);
if(Helmet.getItem() == AfterEarthMod.TitaniumHelmet){
player.addPotionEffect((new PotionEffect(Potion.fireResistance.getId(), 20, 1)));
}
}
if(player.getCurrentItemOrArmor(1) != null) {
ItemStack Boots = player.getCurrentItemOrArmor(1);
if(Boots.getItem() == AfterEarthMod.EnergyBoots){
player.addPotionEffect((new PotionEffect(Potion.moveSpeed.getId(), 20, 1)));
}
}
if(player.getCurrentItemOrArmor(3) != null) {
ItemStack Chestplate = player.getCurrentItemOrArmor(3);
if(Chestplate.getItem() == AfterEarthMod.EnergyChestplate){
player.addPotionEffect((new PotionEffect(Potion.heal.getId(), 20, 0)));
player.addPotionEffect((new PotionEffect(Potion.moveSpeed.getId(), 20, 1)));
}
}
if(player.getCurrentItemOrArmor(2) != null) {
ItemStack Leggings = player.getCurrentItemOrArmor(2);
if(Leggings.getItem() == AfterEarthMod.EnergyLeggins){
player.addPotionEffect((new PotionEffect(Potion.moveSpeed.getId(), 20, 1)));
}
}
if(player.getCurrentItemOrArmor(4) != null) {
ItemStack Helmet = player.getCurrentItemOrArmor(4);
if(Helmet.getItem() == AfterEarthMod.EnergyHelmet){
player.addPotionEffect((new PotionEffect(Potion.moveSpeed.getId(), 20, 1)));
}
}
}
@Override
public void tickStart(EnumSet<TickType> type, Object... tickData) {
if(type.equals(EnumSet.of(TickType.PLAYER)))
{
onPlayerTick((EntityPlayer) tickData[0]);
}
// TODO Auto-generated method stub
}
@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
// TODO Auto-generated method stub
}
@Override
public EnumSet<TickType> ticks() {
// TODO Auto-generated method stub
return EnumSet.of(TickType.PLAYER, TickType.SERVER);
}
@Override
public String getLabel() {
// TODO Auto-generated method stub
return null;
}
}
I made a common proxy then eclipse says, that i must create a methode in the ClientProxy class.
Since then it did not work.
In the main mod class:
@EventHandler
public void load(FMLInitializationEvent event) {
proxy.registerRenderThings();
proxy.registerServerTickHandler();
}
and:
public static ClientProxy proxy;
in the ClientProxy class is also a methode:
public void registerServerTickHandler() {
// TODO Auto-generated method stub
}