Jump to content

my Tickhandler make my blocks unable to get in-game


dark2222

Recommended Posts

hello

i found out why my blocks not will get in game but i don't now how to fix it

the problem is in my tickhandler i don't now why but it is

here's how i start my tickhandler

TickRegistry.registerTickHandler(new ServerTickHandler(), Side.SERVER);

 

and here is my tickhandler

package com.dark2222.core.handlers;

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 com.dark2222.itempack.armor.ModArmor;
import com.dark2222.itempack.config.ModConfigCore;
import com.dark2222.itempack.lib.Reference;
import com.dark2222.itempack.lib.Strings;

import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.server.FMLServerHandler;

public class ServerTickHandler implements ITickHandler{
    private static boolean initializedserver = false;
    private static boolean initialized = false;
    
    private void onPlayerTick(EntityPlayer player){
        if (player.getCurrentItemOrArmor(3) != null && player.getCurrentItemOrArmor(1) != null){
          ItemStack Ochestplate = player.getCurrentItemOrArmor(3);
          ItemStack OBoots = player.getCurrentItemOrArmor(1);
          
          if (Ochestplate.getItem() == ModArmor.ObsidianChestPalte && OBoots.getItem() == ModArmor.ObsidianBoots ){
              player.addPotionEffect(new PotionEffect(Potion.resistance.getId(), 19, 2));
          }
        }
    }

    @Override
    public void tickStart(EnumSet<TickType> type, Object... tickData) {
        if(type.equals(EnumSet.of(TickType.PLAYER, TickType.SERVER)))
        {
                onPlayerTick((EntityPlayer) tickData[0]);
        }
    }

    @Override
    public void tickEnd(EnumSet<TickType> type, Object... tickData) {
        if(!initializedserver) {
            for (TickType ticktype : type) {
                if (ticktype == TickType.SERVER){
                    if (FMLServerHandler.instance().getServer() != null) {
                        if(ModConfigCore.ConfigLoadFail != false || ModConfigCore.ConfigLoadFailArmor != false){
                            initializedserver = true;
                            
                            if(ModConfigCore.ConfigLoadFail == true || ModConfigCore.ConfigLoadFailArmor == true){
                                FMLServerHandler.instance().getServer().logWarning(Strings.CONFIG_DIFFICULTY_INGAME_CHAT);
                            }
                        }
                    }
                }
            }
        }
        
        if(!initialized) {
            for (TickType ticktype : type) {
                if (ticktype == TickType.CLIENT){
                    if (FMLClientHandler.instance().getClient().currentScreen == null) {
                        if(ModConfigCore.ConfigLoadFail != false || ModConfigCore.ConfigLoadFailArmor != false){
                            initialized = true;
                            
                            if(ModConfigCore.ConfigLoadFail == true || ModConfigCore.ConfigLoadFailArmor == true){
                                FMLClientHandler.instance().getClient().ingameGUI.getChatGUI().printChatMessage(Strings.CONFIG_DIFFICULTY_INGAME_CHAT);
                                System.out.println("Something is wrong!");
                            }
                        }
                    }
                }
            }
        }
    }

    @Override
    public EnumSet<TickType> ticks() {
        return EnumSet.of(TickType.PLAYER, TickType.SERVER, TickType.WORLD);
    }

    @Override
    public String getLabel() {
        return Reference.MOD_NAME + ": " + this.getClass().getSimpleName();
    }

}

fell free too look in my github too see other stuff but it is not 100% up-to-date (maby 5 days old)

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.