Jump to content

Recommended Posts

Posted

Hello,

 

I'm writing a RPG mod. and i'm currenty stuck at the part with how to add Xp if you mine a block and how to stop

breaking a block if you not have the required level.

 

yeah i know i'm not a good Java coder if you see my codes but I will become better.

 

i'm currently stuck at the part writing the eventHandler.

my first problem is how to let the XP gains works

and my second problem is how to cancel the BreakEvent when the required level is higher that your level.

and now if i mine a block with a Req lvl higher than my level. the block will break and turned into a ghost block. by re-entering the world the block will become normal again.

for me it looks like the block will be mined for the client. but not for the server.

 

here are my codes of my Main file and My EventHandler File and also For my XP problems the codes of my gui file where the xp codes are putted in:

MainRegistry.class:

 

 

package com.modMark.Main;

import com.modMark.lib.revStrings;

import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;

@Mod(modid = "mark13695", name = "Mark's Mod", version = "0.0.1")
public class MainRegistry {

@Mod.Instance("mark13695")
public static MainRegistry instance;

@SidedProxy(clientSide = "com.modMark.Main.ClientProxy", serverSide = "com.modMark.Main.ServerProxy" )
public static ServerProxy proxy;


@EventHandler
public static void PreLoad(FMLPreInitializationEvent PreEvent){
	proxy.registerRenderInfo();
	MinecraftForge.EVENT_BUS.register(new MarkKeyBindings());
        MarkKeyBindings.init();
        
}
@EventHandler
public static void Load(FMLInitializationEvent Event){

	NetworkRegistry.INSTANCE.registerGuiHandler(instance, new IGuiHandlerMark());
	MinecraftForge.EVENT_BUS.register(new EventHandlerMark());

}
@EventHandler
public static void PostLoad(FMLPostInitializationEvent PostEvent){

}
}

 

EventHandlerMark.class:

 

package com.modMark.Main;

import ibxm.Player;
import net.minecraft.block.Block;
import net.minecraft.block.BlockStone;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.event.world.BlockEvent.BreakEvent;
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import scala.reflect.internal.Trees.ThisSubstituter;

public class EventHandlerMark {

public static int ID;
public static int ReqLvl;
public static int getXp;



@SubscribeEvent
public static void BreakEvent(BreakEvent event)
{

	Block block = Block.getBlockById(ID);
	if (ID == 1){
		ReqLvl = 0;
		getXp = 8;
		}
	if (ID == 15){
		ReqLvl = 20;
		getXp = 15;
		}
	if (ID == 16){
		ReqLvl = 5;
		getXp = 12;
		}
	if (ID == 3){
		ReqLvl = 0;
		getXp = 5;
		}
if (ReqLvl > GuiStatlist.Level[8] && block.getMaterial() == Material.rock){
	event.setCanceled(true);

	}
else if
	(ReqLvl > GuiStatlist.Level[10] && block.getMaterial() == Material.sand){
	event.setCanceled(true);
}
else if( block.getMaterial() == Material.rock) {
	GuiStatlist.XP[8] += getXp;
}
else if( block.getMaterial() == Material.sand) {
	GuiStatlist.XP[10] += getXp;
}

}

 

 

 

 

 

And

GuiStatlist.class:

package com.modMark.Main;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.util.ResourceLocation;

public class GuiStatlist extends GuiScreen {

public GuiStatlist(){}


public static final int MainLock = 1;
public static final int XpLock1 = 0;
public static final int XpLock2 = 0;
public static final int XpLock3 = 0;
public static final int XpLock4 = 0;
public static final int XpLock5 = 0;
public static final int XpLock6 = 1;
public static final int XpLock7 = 0;


public static String[] Skill = new String[35];
public static int[] XP = new int[35];
public static double[] Level1 = new double[35];
public static int[] Level = new int[35];
public static double[] NextLevel0 = new double[35];
public static double[] NextLevel1 = new double[35];
public static int[] NextLevel = new int[35];
public static int[] XpNeed = new int[35];
public static double[] Degrees1 = new double[35];
public static double[] Degrees = new double[35];
public static int i;




 @Override
     public void drawScreen(int mouseX, int mouseY, float pticks) {
	 this.drawDefaultBackground();
	 ResourceLocation location = new ResourceLocation("mark13695", "textures/gui/skillList.png");
	 this.mc.getTextureManager().bindTexture(location);




	 /** Xp formule */


	for (i = 0; i < 35;i++) {

	 if (XP[i] == 2000000000){
			Level1[i] = 255;
		}
		else if (XP[i] >= 1720000000 && XP[i] <= 1999999999){
			Level1[i] = 254;
			}
		else if (XP[i] >= 1480000000 && XP[i] <= 1719999999){
			Level1[i] = 253;
		}
		else if (XP[i] >= 1280000000 && XP[i] <= 1479999999){
			Level1[i] = 252;
		}
		else if (XP[i] >= 1120000000 && XP[i] <= 1279999999){
			Level1[i] = 251;
		}
		else if (XP[i] >= 1000000000 && XP[i] <= 1119999999){
			Level1[i] = 250;
		}

		else if (XP[i] >= 954238196 && XP[i] <= 999999999){
			Level1[i] = 249;
		}

		else if (XP[i] >= 100005814 && XP[i] <= 954238195){
			Level1[i] = ((Math.log(XP[i] + 8287)/Math.log(8287))-1)*192+1;
		}

		else if (XP[i] >= 70404413 && XP[i] <= 100005813){
			Level1[i] = 200;
		}

		else if (XP[i] >= 701754 && XP[i] <= 70404412){
			Level1[i] = ((Math.log10(XP[i] + 7480)/Math.log10(7480))-1)*194+1;
		}
		else if (XP[i] >= 409286 && XP[i] <= 701753){
			Level1[i] = 99;
		}
		else if (XP[i] <= 409285){
			Level1[i] = ((Math.log10(XP[i] + 522)/Math.log10(522))-1)*92+1;
		}
		else {
			Level1[i] = 0;
		}

	 Level[i] = (int) Math.floor(Level1[i]); /** floors level down*/
		NextLevel0[i] = (int) (Level[i] + 1);  /** says Level + 1*/
		NextLevel[i] = (int) Math.ceil(NextLevel1[i]);
		XpNeed[i] = (int) (NextLevel[i] - XP[i]);

		if (Level[i] == 99 || Level[i] == 200 || Level[i] == 255) 
			{ Degrees[i] = 0; }
		 else {
		Degrees[i] = ((XP[i] - Math.ceil(Degrees1[i])) / (NextLevel[i] - Math.ceil(Degrees1[i]))) * 39;
	    }






		if (Level[i] < 99) {
			NextLevel1[i] = (Math.pow(522, (NextLevel0[i] - 1)/92 +1) - 522);
		}
		else if (Level[i] == 99) {
			NextLevel1[i] = 701754;
		}
		else if (Level[i] >= 100 && Level[i] < 200) {
			NextLevel1[i] = (Math.pow(7480, (NextLevel0[i] - 1)/194 +1) - 7480);
		}
		else if (Level[i] == 200) {
			NextLevel1[i] = 100005814;
		}
		else if (Level[i] >= 201 && Level[i] < 249) {
			NextLevel1[i] = (Math.pow(8287, (NextLevel0[i] - 1)/192 +1) - 8287);
		}
		else if (Level[i] == 249) {
			NextLevel1[i] = 1000000000;
		}
		else if (Level[i] == 250) {
			NextLevel1[i] = 1120000000;
		}
		else if (Level[i] == 251) {
			NextLevel1[i] = 1280000000;
		}
		else if (Level[i] == 252) {
			NextLevel1[i] = 1480000000;
		}
		else if (Level[i] == 253) {
			NextLevel1[i] = 1720000000;
		}
		else if (Level[i] == 254) {
			NextLevel1[i] = 2000000000;		
		}
		else {
			NextLevel1[i] = 0;
		}



		if (Level[i] <= 98) {
			Degrees1[i] = (Math.pow(522, (NextLevel0[i] - 2)/92 +1) - 522) ;
		}

		else if (Level[i] >= 100 && Level[i] <= 199) {
			Degrees1[i] = (Math.pow(7480, (NextLevel0[i] - 2)/194 +1) - 7480);
		}
		else if (Level[i] >= 201 && Level[i] <= 249) {
			Degrees1[i] = (Math.pow(8287, (NextLevel0[i] - 2)/192 +1) - 8287);
		}
		else if (Level[i] == 250) {
			Degrees1[i] = 1000000000;
		}
		else if (Level[i] == 251) {
			Degrees1[i] = 1120000000;
		}
		else if (Level[i] == 252) {
			Degrees1[i] = 1280000000;
		}
		else if (Level[i] == 253) {
			Degrees1[i] = 1480000000;
		}
		else if (Level[i] == 254) {
			Degrees1[i] = 1720000000;
		}

		else {
			Degrees1[i] = 0;
		}

	}	

	 /** Gui Texture loading*/


	 	float PoX = mouseX;
	 	float PoY = mouseY;
	 	int xSize = 235;
		int ySize = 211;
		int w = this.width;
		int h = this.height;
		int x = ((w - xSize)  / 2);
		int y = ((h - ySize) / 2);
		int z = 1;

		drawModalRectWithCustomSizedTexture(x, y, 0, 0, xSize, ySize, 235, 211);

		/** Progness Bars, sorry for dead codes. this are codes for when a skill is locked. will be worked on in the future */

		ResourceLocation location2 = new ResourceLocation("mark13695", "textures/gui/SkillBarL.png");
		 this.mc.getTextureManager().bindTexture(location2);

		 if (XpLock1 == 0) {
			 drawModalRectWithCustomSizedTexture(x + 181, y + 36, 0, 0, (int) 38 , 2,(int) 38 , 2);
		 }
		 if (XpLock2 == 0) {
			 drawModalRectWithCustomSizedTexture(x + 181, y + 63, 0, 0, (int) 38 , 2,(int) 38 , 2);
		 }
		 if (XpLock3 == 0) {
			 drawModalRectWithCustomSizedTexture(x + 181, y + 90, 0, 0, (int) 38 , 2,(int) 38 , 2);
		 }
		 if (XpLock4 == 0) {
			 drawModalRectWithCustomSizedTexture(x + 181, y + 117, 0, 0, (int) 38 , 2,(int) 38 , 2);
		 }
		 if (XpLock5 == 0) {
			 drawModalRectWithCustomSizedTexture(x + 181, y + 144, 0, 0, (int) 38 , 2,(int) 38 , 2);
		 }
		 if (XpLock6 == 0) {
			 drawModalRectWithCustomSizedTexture(x + 181, y + 171, 0, 0, (int) 38 , 2,(int) 38 , 2);
		 }
		 if (XpLock7 == 0) {
			 drawModalRectWithCustomSizedTexture(x + 181, y + 198, 0, 0, (int) 38 , 2,(int) 38 , 2);
		 }

		ResourceLocation location3 = new ResourceLocation("mark13695", "textures/gui/SkillBar.png");
		 this.mc.getTextureManager().bindTexture(location3);


		drawModalRectWithCustomSizedTexture(x + 9, y + 36, 0, 0, (int) Degrees[0] , 2,(int) Degrees[0] , 2);
		drawModalRectWithCustomSizedTexture(x + 9, y + 63, 0, 0, (int) Degrees[1] , 2,(int) Degrees[1] , 2);
		drawModalRectWithCustomSizedTexture(x + 9, y + 90, 0, 0, (int) Degrees[2] , 2,(int) Degrees[2] , 2);
		drawModalRectWithCustomSizedTexture(x + 9, y + 117, 0, 0, (int) Degrees[3] , 2,(int) Degrees[3] , 2);
		drawModalRectWithCustomSizedTexture(x + 9, y + 144, 0, 0, (int) Degrees[4] , 2,(int) Degrees[4] , 2);
		drawModalRectWithCustomSizedTexture(x + 9, y + 171, 0, 0, (int) Degrees[5] , 2,(int) Degrees[5] , 2);
		drawModalRectWithCustomSizedTexture(x + 9, y + 198, 0, 0, (int) Degrees[6] , 2,(int) Degrees[6] , 2);
		drawModalRectWithCustomSizedTexture(x + 52, y + 36, 0, 0, (int) Degrees[7] , 2,(int) Degrees[7] , 2);
		drawModalRectWithCustomSizedTexture(x + 52, y + 63, 0, 0, (int) Degrees[8] , 2,(int) Degrees[8] , 2);
		drawModalRectWithCustomSizedTexture(x + 52, y + 90, 0, 0, (int) Degrees[9] , 2,(int) Degrees[9] , 2);
		drawModalRectWithCustomSizedTexture(x + 52, y + 117, 0, 0, (int) Degrees[10] , 2,(int) Degrees[10] , 2);
		drawModalRectWithCustomSizedTexture(x + 52, y + 144, 0, 0, (int) Degrees[11] , 2,(int) Degrees[11] , 2);
		drawModalRectWithCustomSizedTexture(x + 52, y + 171, 0, 0, (int) Degrees[12] , 2,(int) Degrees[12] , 2);
		drawModalRectWithCustomSizedTexture(x + 52, y + 198, 0, 0, (int) Degrees[13] , 2,(int) Degrees[13] , 2);
		drawModalRectWithCustomSizedTexture(x + 95, y + 36, 0, 0, (int) Degrees[14] , 2,(int) Degrees[14] , 2);
		drawModalRectWithCustomSizedTexture(x + 95, y + 63, 0, 0, (int) Degrees[15] , 2,(int) Degrees[15] , 2);
		drawModalRectWithCustomSizedTexture(x + 95, y + 90, 0, 0, (int) Degrees[16] , 2,(int) Degrees[16] , 2);
		drawModalRectWithCustomSizedTexture(x + 95, y + 117, 0, 0, (int) Degrees[17] , 2,(int) Degrees[17] , 2);
		drawModalRectWithCustomSizedTexture(x + 95, y + 144, 0, 0, (int) Degrees[18] , 2,(int) Degrees[18] , 2);
		drawModalRectWithCustomSizedTexture(x + 95, y + 171, 0, 0, (int) Degrees[19] , 2,(int) Degrees[19] , 2);
		drawModalRectWithCustomSizedTexture(x + 95, y + 198, 0, 0, (int) Degrees[20] , 2,(int) Degrees[20] , 2);
		drawModalRectWithCustomSizedTexture(x + 138, y + 36, 0, 0, (int) Degrees[21] , 2,(int) Degrees[21] , 2);
		drawModalRectWithCustomSizedTexture(x + 138, y + 63, 0, 0, (int) Degrees[22] , 2,(int) Degrees[22] , 2);
		drawModalRectWithCustomSizedTexture(x + 138, y + 90, 0, 0, (int) Degrees[23] , 2,(int) Degrees[23] , 2);
		drawModalRectWithCustomSizedTexture(x + 138, y + 117, 0, 0, (int) Degrees[24] , 2,(int) Degrees[24] , 2);
		drawModalRectWithCustomSizedTexture(x + 138, y + 144, 0, 0, (int) Degrees[25] , 2,(int) Degrees[25] , 2);
		drawModalRectWithCustomSizedTexture(x + 138, y + 171, 0, 0, (int) Degrees[26] , 2,(int) Degrees[26] , 2);
		drawModalRectWithCustomSizedTexture(x + 138, y + 198, 0, 0, (int) Degrees[27] , 2,(int) Degrees[27] , 2);
		drawModalRectWithCustomSizedTexture(x + 181, y + 36, 0, 0, (int) Degrees[28] , 2,(int) Degrees[28] , 2);
		drawModalRectWithCustomSizedTexture(x + 181, y + 63, 0, 0, (int) Degrees[29] , 2,(int) Degrees[29] , 2);
		drawModalRectWithCustomSizedTexture(x + 181, y + 90, 0, 0, (int) Degrees[30] , 2,(int) Degrees[30] , 2);
		drawModalRectWithCustomSizedTexture(x + 181, y + 117, 0, 0, (int) Degrees[31] , 2,(int) Degrees[31] , 2);
		drawModalRectWithCustomSizedTexture(x + 181, y + 144, 0, 0, (int) Degrees[32] , 2,(int) Degrees[32] , 2);
		drawModalRectWithCustomSizedTexture(x + 181, y + 171, 0, 0, (int) Degrees[33] , 2,(int) Degrees[33] , 2);
		drawModalRectWithCustomSizedTexture(x + 181, y + 198, 0, 0, (int) Degrees[34] , 2,(int) Degrees[34] , 2);

		ResourceLocation location4 = new ResourceLocation("mark13695", "textures/gui/skillLock.png");
		 this.mc.getTextureManager().bindTexture(location4);
		 if (XpLock1 == 0){
		 drawModalRectWithCustomSizedTexture(x + 181, y + 17, 0, 0, 16, 16, 16, 16);
		 }
		 else{}
		 if (XpLock2 == 0){
		 drawModalRectWithCustomSizedTexture(x + 181, y + 44, 0, 0, 16, 16, 16, 16);
		 }
		 else{}
		 if (XpLock3 == 0){
		 drawModalRectWithCustomSizedTexture(x + 181, y + 71, 0, 0, 16, 16, 16, 16);
		 }
		 else{}
		 if (XpLock4 == 0){
		 drawModalRectWithCustomSizedTexture(x + 181, y + 98, 0, 0, 16, 16, 16, 16);
		 }
		 else{}
		 if (XpLock5 == 0){
		 drawModalRectWithCustomSizedTexture(x + 181, y + 125, 0, 0, 16, 16, 16, 16);
		 }
		 else{}
		 if (XpLock6 == 0){
		 drawModalRectWithCustomSizedTexture(x + 181, y + 152, 0, 0, 16, 16, 16, 16);
		 }
		 else{}
		 if (XpLock7 == 0){
		 drawModalRectWithCustomSizedTexture(x + 181, y + 179, 0, 0, 16, 16, 16, 16);
		 }
		 else{}


		 /** draws the levels */

		drawString (fontRendererObj , "" + Level[0] , x + 28, y + 21, 0x0000ff00);
		drawString (fontRendererObj , "" + Level[1] , x + 28, y + 48, 0x0000ff00);
		drawString (fontRendererObj , "" + Level[2] , x + 28, y + 75, 0x0000ff00);
		drawString (fontRendererObj , "" + Level[3] , x + 28, y + 102, 0x0000ff00);
		drawString (fontRendererObj , "" + Level[4] , x + 28, y + 129, 0x0000ff00);
		drawString (fontRendererObj , "" + Level[5] , x + 28, y + 156, 0x0000ff00);
		drawString (fontRendererObj , "" + Level[6] , x + 28, y + 183, 0x0000ff00);
		drawString (fontRendererObj , "" + Level[7] , x + 71, y + 21, 0x0000ff00);
		drawString (fontRendererObj , "" + Level[8] , x + 71, y + 48, 0x0000ff00);
		drawString (fontRendererObj , "" + Level[9] , x + 71, y + 75, 0x0000ff00);
		drawString (fontRendererObj , "" + Level[10] , x + 71, y + 102, 0x0000ff00);
		drawString (fontRendererObj , "" + Level[11] , x + 71, y + 129, 0x0000ff00);
		drawString (fontRendererObj , "" + Level[12] , x + 71, y + 156, 0x0000ff00);
		drawString (fontRendererObj , "" + Level[13] , x + 71, y + 183, 0x0000ff00);
		drawString (fontRendererObj , "" + Level[14] , x + 114, y + 21, 0x0000ff00);
		drawString (fontRendererObj , "" + Level[15] , x + 114, y + 48, 0x0000ff00);
		drawString (fontRendererObj , "" + Level[16] , x + 114, y + 75, 0x0000ff00);
		drawString (fontRendererObj , "" + Level[17] , x + 114, y + 102, 0x0000ff00);
		drawString (fontRendererObj , "" + Level[18] , x + 114, y + 129, 0x0000ff00);
		drawString (fontRendererObj , "" + Level[19] , x + 114, y + 156, 0x0000ff00);
		drawString (fontRendererObj , "" + Level[20] , x + 114, y + 183, 0x0000ff00);
		drawString (fontRendererObj , "" + Level[21] , x + 157, y + 21, 0x0000ff00);
		drawString (fontRendererObj , "" + Level[22] , x + 157, y + 48, 0x0000ff00);
		drawString (fontRendererObj , "" + Level[23] , x + 157, y + 75, 0x0000ff00);
		drawString (fontRendererObj , "" + Level[24] , x + 157, y + 102, 0x0000ff00);
		drawString (fontRendererObj , "" + Level[25] , x + 157, y + 129, 0x0000ff00);
		drawString (fontRendererObj , "" + Level[26] , x + 157, y + 156, 0x0000ff00);
		drawString (fontRendererObj , "" + Level[27] , x + 157, y + 183, 0x0000ff00);
		if (XpLock1 == 0){drawString (fontRendererObj , "" + Level[28] , x + 200, y + 21, 0x33333333);}
		else{
		drawString (fontRendererObj , "" + Level[28] , x + 200, y + 21, 0x0000ff00);}
		if (XpLock2 == 0){drawString (fontRendererObj , "" + Level[29] , x + 200, y + 48, 0x33333333);}
		else{
		drawString (fontRendererObj , "" + Level[29] , x + 200, y + 48, 0x0000ff00);}
		if (XpLock3 == 0){drawString (fontRendererObj , "" + Level[30] , x + 200, y + 75, 0x33333333);}
		else{
		drawString (fontRendererObj , "" + Level[30] , x + 200, y + 75, 0x0000ff00);}
		if (XpLock4 == 0){drawString (fontRendererObj , "" + Level[31] , x + 200, y + 102, 0x33333333);}
		else{
		drawString (fontRendererObj , "" + Level[31] , x + 200, y + 102, 0x0000ff00);}
		if (XpLock5 == 0){drawString (fontRendererObj , "" + Level[32] , x + 200, y + 129, 0x33333333);}
		else{
		drawString (fontRendererObj , "" + Level[32] , x + 200, y + 129, 0x0000ff00);}
		if (XpLock6 == 0){drawString (fontRendererObj , "" + Level[33] , x + 200, y + 156, 0x33333333);}
		else{
		drawString (fontRendererObj , "" + Level[33] , x + 200, y + 156, 0x0000ff00);}
		if (XpLock7 == 0){drawString (fontRendererObj , "" + Level[34] , x + 200, y + 183, 0x33333333);}
		else{
		drawString (fontRendererObj , "" + Level[34] , x + 200, y + 183, 0x0000ff00);}







		 if(mouseX >= x + 9 && mouseX <= x + 47 && mouseY >= y + 17 && mouseY <= y + 33){
			 List listHp = new ArrayList();
			 listHp.add(Skill[0] +": " + Level[0]);
			 listHp.add("XP: " + XP[0]);
			 if(Level[0] == 99 && MainLock == 1 ) {}
			 else if(Level[0] == 200 && MainLock == 2) {}
			 else if(Level[0] == 255){}
			 else{
			 listHp.add("Next Level: " + NextLevel[0]);
			 listHp.add("XP Needed: " + XpNeed[0]);
			 }

			 this.drawHoveringText(listHp, x + 236, y + 16, fontRendererObj);
		 }


		 if(mouseX >= x + 9 && mouseX <= x + 47 && mouseY >= y + 44 && mouseY <= y + 60) {
				 List listMl = new ArrayList();
				 listMl.add(Skill[1] +": " + Level[1]);
				 listMl.add("XP: " + XP[1]);
				 if(Level[1] == 99 && MainLock == 1 ) {}
				 else if(Level[1] == 200 && MainLock == 2) {}
				 else if(Level[1] == 255){}
				 else{
				 listMl.add("Next Level: " + NextLevel[1]);
				 listMl.add("XP Needed: " + XpNeed[1]);
				 }
				 this.drawHoveringText(listMl, x + 236, y + 16, fontRendererObj);
			}



			 if(mouseX >= x + 9 && mouseX <= x + 47 && mouseY >= y + 71 && mouseY <= y + 87) {
				 List listRn = new ArrayList();
				 listRn.add(Skill[2] +": " + Level[2]);
				 listRn.add("XP: " + XP[2]);
				 if(Level[2] == 99 && MainLock == 1 ) {}
				 else if(Level[2] == 200 && MainLock == 2) {}
				 else if(Level[2] == 255){}
				 else{
				 listRn.add("Next Level: " + NextLevel[2]);
				 listRn.add("XP Needed: " + XpNeed[2]);
				 }
				 this.drawHoveringText(listRn, x + 236, y + 16, fontRendererObj);
			}



			 if(mouseX >= x + 9 && mouseX <= x + 47 && mouseY >= y + 98 && mouseY <= y + 114) {
				 List listMg = new ArrayList();
				 listMg.add(Skill[3] +": " + Level[3]);
				 listMg.add("XP: " + XP[3]);
				 if(Level[3] == 99 && MainLock == 1 ) {}
				 else if(Level[3] == 200 && MainLock == 2) {}
				 else if(Level[3] == 255){}
				 else{
				 listMg.add("Next Level: " + NextLevel[3]);
				 listMg.add("XP Needed: " + XpNeed[3]);
				 }
				 this.drawHoveringText(listMg, x + 236, y + 16, fontRendererObj);
			}



			 if(mouseX >= x + 9 && mouseX <= x + 47 && mouseY >= y + 125 && mouseY <= y + 141) {
				 List listDf = new ArrayList();
				 listDf.add(Skill[4] +": " + Level[4]);
				 listDf.add("XP: " + XP[4]);
				 if(Level[4] == 99 && MainLock == 1 ) {}
				 else if(Level[4] == 200 && MainLock == 2) {}
				 else if(Level[4] == 255){}
				 else{
				 listDf.add("Next Level: " + NextLevel[4]);
				 listDf.add("XP Needed: " + XpNeed[4]);
				 }
				 this.drawHoveringText(listDf, x + 236, y + 16, fontRendererObj);
			}



			 if(mouseX >= x + 9 && mouseX <= x + 47 && mouseY >= y + 152 && mouseY <= y + 168) {
				 List listEn = new ArrayList();
				 listEn.add(Skill[5] +": " + Level[5]);
				 listEn.add("XP: " + XP[5]);
				 if(Level[5] == 99 && MainLock == 1 ) {}
				 else if(Level[5] == 200 && MainLock == 2) {}
				 else if(Level[5] == 255){}
				 else{
				 listEn.add("Next Level: " + NextLevel[5]);
				 listEn.add("XP Needed: " + XpNeed[5]);
				 }
				 this.drawHoveringText(listEn, x + 236, y + 16, fontRendererObj);
			}



			 if(mouseX >= x + 9 && mouseX <= x + 47 && mouseY >= y + 179 && mouseY <= y + 195) {
				 List listSl = new ArrayList();
				 listSl.add(Skill[6] +": " + Level[6]);
				 listSl.add("XP: " + XP[6]);
				 if(Level[6] == 99 && MainLock == 1 ) {}
				 else if(Level[6] == 200 && MainLock == 2) {}
				 else if(Level[6] == 255){}
				 else{
				 listSl.add("Next Level: " + NextLevel[6]);
				 listSl.add("XP Needed: " + XpNeed[6]);
				 }
				 this.drawHoveringText(listSl, x + 236, y + 16, fontRendererObj);
			}



			 if(mouseX >= x + 52 && mouseX <= x + 90 && mouseY >= y + 17 && mouseY <= y + 33) {
				 List listFr = new ArrayList();
				 listFr.add(Skill[7] +": " + Level[7]);
				 listFr.add("XP: " + XP[7]);
				 if(Level[7] == 99 && MainLock == 1 ) {}
				 else if(Level[7] == 200 && MainLock == 2) {}
				 else if(Level[7] == 255){}
				 else{
				 listFr.add("Next Level: " + NextLevel[7]);
				 listFr.add("XP Needed: " + XpNeed[7]);
				 }
				 this.drawHoveringText(listFr, x + 236, y + 16, fontRendererObj);
			}



			 if(mouseX >= x + 52 && mouseX <= x + 90 && mouseY >= y + 44 && mouseY <= y + 60) {
				 List listMn = new ArrayList();
				 listMn.add(Skill[8] +": " + Level[8]);
				 listMn.add("XP: " + XP[8]);
				 if(Level[8] == 99 && MainLock == 1 ) {}
				 else if(Level[8] == 200 && MainLock == 2) {}
				 else if(Level[8] == 255){}
				 else{
				 listMn.add("Next Level: " + NextLevel[8]);
				 listMn.add("XP Needed: " + XpNeed[8]);
				 }
				 this.drawHoveringText(listMn, x + 236, y + 16, fontRendererObj);
			}






			 if(mouseX >= x + 52 && mouseX <= x + 90 && mouseY >= y + 71 && mouseY <= y + 87) {
				 List listHu = new ArrayList();
				 listHu.add(Skill[9]+ ": " + Level[9]);
				 listHu.add("XP: " + XP[9]);
				 if(Level[9] == 99 && MainLock == 1 ) {}
				 else if(Level[9] == 200 && MainLock == 2) {}
				 else if(Level[9] == 255){}
				 else{
				 listHu.add("Next Level: " + NextLevel[9]);
				 listHu.add("XP Needed: " + XpNeed[9]);
				 }
				 this.drawHoveringText(listHu, x + 236, y + 16, fontRendererObj);
			}



			 if(mouseX >= x + 52 && mouseX <= x + 90 && mouseY >= y + 98 && mouseY <= y + 114) {
				 List listEx = new ArrayList();
				 listEx.add(Skill[10]+ ": " + Level[10]);
				 listEx.add("XP: " + XP[10]);
				 if(Level[10] == 99 && MainLock == 1 ) {}
				 else if(Level[10] == 200 && MainLock == 2) {}
				 else if(Level[10] == 255){}
				 else{
				 listEx.add("Next Level: " + NextLevel[10]);
				 listEx.add("XP Needed: " + XpNeed[10]);
				 }
				 this.drawHoveringText(listEx, x + 236, y + 16, fontRendererObj);
			}





			 if(mouseX >= x + 52 && mouseX <= x + 90 && mouseY >= y + 125 && mouseY <= y + 141) {
				 List listWc = new ArrayList();
				 listWc.add(Skill[11]+ ": " + Level[11]);
				 listWc.add("XP: " + XP[11]);
				 if(Level[11] == 99 && MainLock == 1 ) {}
				 else if(Level[11] == 200 && MainLock == 2) {}
				 else if(Level[11] == 255){}
				 else{
				 listWc.add("Next Level: " + NextLevel[11]);
				 listWc.add("XP Needed: " + XpNeed[11]);
				 }
				 this.drawHoveringText(listWc, x + 236, y + 16, fontRendererObj);
			}



			 if(mouseX >= x + 52 && mouseX <= x + 90 && mouseY >= y + 152 && mouseY <= y + 168) {
				 List listFs = new ArrayList();
				 listFs.add(Skill[12]+ ": " + Level[12]);
				 listFs.add("XP: " + XP[12]);
				 if(Level[12] == 99 && MainLock == 1 ) {}
				 else if(Level[12] == 200 && MainLock == 2) {}
				 else if(Level[12] == 255){}
				 else{
				 listFs.add("Next Level: " + NextLevel[12]);
				 listFs.add("XP Needed: " + XpNeed[12]);
				 }
				 this.drawHoveringText(listFs, x + 236, y + 16, fontRendererObj);
			}



			 if(mouseX >= x + 52 && mouseX <= x + 90 && mouseY >= y + 179 && mouseY <= y + 195) {
				 List listAr = new ArrayList();
				 listAr.add(Skill[13]+ ": " + Level[13]);
				 listAr.add("XP: " + XP[13]);
				 if(Level[13] == 99 && MainLock == 1 ) {}
				 else if(Level[13] == 200 && MainLock == 2) {}
				 else if(Level[13] == 255){}
				 else{
				 listAr.add("Next Level: " + NextLevel[13]);
				 listAr.add("XP Needed: " + XpNeed[13]);
				 }
				 this.drawHoveringText(listAr, x + 236, y + 16, fontRendererObj);
			}



			 if(mouseX >= x + 95 && mouseX <= x + 133 && mouseY >= y + 17 && mouseY <= y + 33) {
				 List listTa = new ArrayList();
				 listTa.add(Skill[14] +": " + Level[14]);
				 listTa.add("XP: " + XP[14]);
				 if(Level[14] == 99 && MainLock == 1 ) {}
				 else if(Level[14] == 200 && MainLock == 2) {}
				 else if(Level[14] == 255){}
				 else{
				 listTa.add("Next Level: " + NextLevel[14]);
				 listTa.add("XP Needed: " + XpNeed[14]);
				 }
				 this.drawHoveringText(listTa, x + 236, y + 16, fontRendererObj);
			}



			 if(mouseX >= x + 95 && mouseX <= x + 133 && mouseY >= y + 44 && mouseY <= y + 60) {
				 List listSm = new ArrayList();
				 listSm.add(Skill[15] +": " + Level[15]);
				 listSm.add("XP: " + XP[15]);
				 if(Level[15] == 99 && MainLock == 1 ) {}
				 else if(Level[15] == 200 && MainLock == 2) {}
				 else if(Level[15] == 255){}
				 else{
				 listSm.add("Next Level: " + NextLevel[15]);
				 listSm.add("XP Needed: " + XpNeed[15]);
				 }
				 this.drawHoveringText(listSm, x + 236, y + 16, fontRendererObj);
			}



			 if(mouseX >= x + 95 && mouseX <= x + 133 && mouseY >= y + 71 && mouseY <= y + 87) {
				 List listTn = new ArrayList();
				 listTn.add(Skill[16]+ ": " + Level[16]);
				 listTn.add("XP: " + XP[16]);
				 if(Level[16] == 99 && MainLock == 1 ) {}
				 else if(Level[16] == 200 && MainLock == 2) {}
				 else if(Level[16] == 255){}
				 else{
				 listTn.add("Next Level: " + NextLevel[16]);
				 listTn.add("XP Needed: " + XpNeed[16]);
				 }
				 this.drawHoveringText(listTn, x + 236, y + 16, fontRendererObj);
			}



			 if(mouseX >= x + 95 && mouseX <= x + 133 && mouseY >= y + 98 && mouseY <= y + 114) {
				 List listJe = new ArrayList();
				 listJe.add(Skill[17]+ ": " + Level[17]);
				 listJe.add("XP: " + XP[17]);
				 if(Level[17] == 99 && MainLock == 1 ) {}
				 else if(Level[17] == 200 && MainLock == 2) {}
				 else if(Level[17] == 255){}
				 else{
				 listJe.add("Next Level: " + NextLevel[17]);
				 listJe.add("XP Needed: " + XpNeed[17]);
				 }
				 this.drawHoveringText(listJe, x + 236, y + 16, fontRendererObj);
			}



			 if(mouseX >= x + 95 && mouseX <= x + 133 && mouseY >= y + 125 && mouseY <= y + 141) {
				 List listWc = new ArrayList();
				 listWc.add(Skill[18]+ ": " + Level[18]);
				 listWc.add("XP: " + XP[18]);
				 if(Level[18] == 99 && MainLock == 1 ) {}
				 else if(Level[18] == 200 && MainLock == 2) {}
				 else if(Level[18] == 255){}
				 else{
				 listWc.add("Next Level: " + NextLevel[18]);
				 listWc.add("XP Needed: " + XpNeed[18]);
				 }
				 this.drawHoveringText(listWc, x + 236, y + 16, fontRendererObj);
			}



			 if(mouseX >= x + 95 && mouseX <= x + 133 && mouseY >= y + 152 && mouseY <= y + 168) {
				 List listCo = new ArrayList();
				 listCo.add(Skill[19]+ ": " + Level[19]);
				 listCo.add("XP: " + XP[19]);
				 if(Level[19] == 99 && MainLock == 1 ) {}
				 else if(Level[19] == 200 && MainLock == 2) {}
				 else if(Level[19] == 255){}
				 else{
				 listCo.add("Next Level: " + NextLevel[19]);
				 listCo.add("XP Needed: " + XpNeed[19]);
				 }
				 this.drawHoveringText(listCo, x + 236, y + 16, fontRendererObj);
			}



			 if(mouseX >= x + 95 && mouseX <= x + 133 && mouseY >= y + 179 && mouseY <= y + 195) {
				 List listHr = new ArrayList();
				 listHr.add(Skill[20]+ ": " + Level[20]);
				 listHr.add("XP: " + XP[20]);
				 if(Level[20] == 99 && MainLock == 1 ) {}
				 else if(Level[20] == 200 && MainLock == 2) {}
				 else if(Level[20] == 255){}
				 else{
				 listHr.add("Next Level: " + NextLevel[20]);
				 listHr.add("XP Needed: " + XpNeed[20]);
				 }
				 this.drawHoveringText(listHr, x + 236, y + 16, fontRendererObj);
			}




			 if(mouseX >= x + 138 && mouseX <= x + 176 && mouseY >= y + 17 && mouseY <= y + 33) {
				 List listHn = new ArrayList();
				 listHn.add(Skill[21] +": " + Level[21]);
				 listHn.add("XP: " + XP[21]);
				 if(Level[21] == 99 && MainLock == 1 ) {}
				 else if(Level[21] == 200 && MainLock == 2) {}
				 else if(Level[21] == 255){}
				 else{
				 listHn.add("Next Level: " + NextLevel[21]);
				 listHn.add("XP Needed: " + XpNeed[21]);
				 }
				 this.drawHoveringText(listHn, x + 236, y + 16, fontRendererObj);
			}



			 if(mouseX >= x + 138 && mouseX <= x + 176 && mouseY >= y + 44 && mouseY <= y + 60) {
				 List listSm = new ArrayList();
				 listSm.add(Skill[22] +": " + Level[22]);
				 listSm.add("XP: " + XP[22]);
				 if(Level[22] == 99 && MainLock == 1 ) {}
				 else if(Level[22] == 200 && MainLock == 2) {}
				 else if(Level[22] == 255){}
				 else{
				 listSm.add("Next Level: " + NextLevel[22]);
				 listSm.add("XP Needed: " + XpNeed[22]);
				 }
				 this.drawHoveringText(listSm, x + 236, y + 16, fontRendererObj);
			}



			 if(mouseX >= x + 138 && mouseX <= x + 176 && mouseY >= y + 71 && mouseY <= y + 87) {
				 List listAg = new ArrayList();
				 listAg.add(Skill[23]+ ": " + Level[23]);
				 listAg.add("XP: " + XP[23]);
				 if(Level[23] == 99 && MainLock == 1 ) {}
				 else if(Level[23] == 200 && MainLock == 2) {}
				 else if(Level[23] == 255){}
				 else{
				 listAg.add("Next Level: " + NextLevel[23]);
				 listAg.add("XP Needed: " + XpNeed[23]);
				 }
				 this.drawHoveringText(listAg, x + 236, y + 16, fontRendererObj);
			}



			 if(mouseX >= x + 138 && mouseX <= x + 176 && mouseY >= y + 98 && mouseY <= y + 114) {
				 List listDu = new ArrayList();
				 listDu.add(Skill[24]+ ": " + Level[24]);
				 listDu.add("XP: " + XP[24]);
				 if(Level[24] == 99 && MainLock == 1 ) {}
				 else if(Level[24] == 200 && MainLock == 2) {}
				 else if(Level[24] == 255){}
				 else{
				 listDu.add("Next Level: " + NextLevel[24]);
				 listDu.add("XP Needed: " + XpNeed[24]);
				 }
				 this.drawHoveringText(listDu, x + 236, y + 16, fontRendererObj);
			}



			 if(mouseX >= x + 138 && mouseX <= x + 176 && mouseY >= y + 125 && mouseY <= y + 141) {
				 List listFm = new ArrayList();
				 listFm.add(Skill[25]+ ": " + Level[25]);
				 listFm.add("XP: " + XP[25]);
				 if(Level[25] == 99 && MainLock == 1 ) {}
				 else if(Level[25] == 200 && MainLock == 2) {}
				 else if(Level[25] == 255){}
				 else{
				 listFm.add("Next Level: " + NextLevel[25]);
				 listFm.add("XP Needed: " + XpNeed[25]);
				 }
				 this.drawHoveringText(listFm, x + 236, y + 16, fontRendererObj);
			}



			 if(mouseX >= x + 138 && mouseX <= x + 176 && mouseY >= y + 152 && mouseY <= y + 168) {
				 List listLs = new ArrayList();
				 listLs.add(Skill[26]+ ": " + Level[26]);
				 listLs.add("XP: " + XP[26]);
				 if(Level[26] == 99 && MainLock == 1 ) {}
				 else if(Level[26] == 200 && MainLock == 2) {}
				 else if(Level[26] == 255){}
				 else{
				 listLs.add("Next Level: " + NextLevel[26]);
				 listLs.add("XP Needed: " + XpNeed[26]);
				 }
				 this.drawHoveringText(listLs, x + 236, y + 16, fontRendererObj);
			}



			 if(mouseX >= x + 138 && mouseX <= x + 176 && mouseY >= y + 179 && mouseY <= y + 195) {
				 List listKn = new ArrayList();
				 listKn.add(Skill[27]+ ": " + Level[27]);
				 listKn.add("XP: " + XP[27]);
				 if(Level[27] == 99 && MainLock == 1 ) {}
				 else if(Level[27] == 200 && MainLock == 2) {}
				 else if(Level[27] == 255){}
				 else{
				 listKn.add("Next Level: " + NextLevel[27]);
				 listKn.add("XP Needed: " + XpNeed[27]);
				 }
				 this.drawHoveringText(listKn, x + 236, y + 16, fontRendererObj);
			}



			 if(mouseX >= x + 181 && mouseX <= x + 219 && mouseY >= y + 17 && mouseY <= y + 33) {
				 List listTc = new ArrayList();
				 if (XpLock1 == 0){
				 listTc.add("Locked");}
				 else{
				 listTc.add(Skill[28] +": " + Level[28]);
				 listTc.add("XP: " + XP[28]);
				 if(Level[21] == 99 && MainLock == 1 ) {}
				 else if(Level[28] == 200 && MainLock == 2) {}
				 else if(Level[28] == 255){}
				 else{
				 listTc.add("Next Level: " + NextLevel[28]);
				 listTc.add("XP Needed: " + XpNeed[28]);
				 }}
				 this.drawHoveringText(listTc, x + 236, y + 16, fontRendererObj);

			 }


			 if(mouseX >= x + 181 && mouseX <= x + 219 && mouseY >= y + 44 && mouseY <= y + 60) {
				 List listPe = new ArrayList();
				 if (XpLock2 == 0){
					 listPe.add("Locked");}
					 else{
				 listPe.add(Skill[29] +": " + Level[29]);
				 listPe.add("XP: " + XP[22]);
				 if(Level[29] == 99 && MainLock == 1 ) {}
				 else if(Level[29] == 200 && MainLock == 2) {}
				 else if(Level[29] == 255){}
				 else{
				 listPe.add("Next Level: " + NextLevel[29]);
				 listPe.add("XP Needed: " + XpNeed[29]);
				 }}
				 this.drawHoveringText(listPe, x + 236, y + 16, fontRendererObj);

			 }


			 if(mouseX >= x + 181 && mouseX <= x + 219 && mouseY >= y + 71 && mouseY <= y + 87) {
				 List listCh = new ArrayList();
				 if (XpLock3 == 0){
					 listCh.add("Locked");}
					 else{
				 listCh.add(Skill[30]+ ": " + Level[30]);
				 listCh.add("XP: " + XP[30]);
				 if(Level[30] == 99 && MainLock == 1 ) {}
				 else if(Level[30] == 200 && MainLock == 2) {}
				 else if(Level[30] == 255){}
				 else{
				 listCh.add("Next Level: " + NextLevel[30]);
				 listCh.add("XP Needed: " + XpNeed[30]);
				 }}
				 this.drawHoveringText(listCh, x + 236, y + 16, fontRendererObj);

			 }


			 if(mouseX >= x + 181 && mouseX <= x + 219 && mouseY >= y + 98 && mouseY <= y + 114) {
				 List listSp = new ArrayList();
				 if (XpLock4 == 0){
					 listSp.add("Locked");}
					 else{
				 listSp.add(Skill[31]+ ": " + Level[31]);
				 listSp.add("XP: " + XP[24]);
				 if(Level[31] == 99 && MainLock == 1 ) {}
				 else if(Level[31] == 200 && MainLock == 2) {}
				 else if(Level[31] == 255){}
				 else{
				 listSp.add("Next Level: " + NextLevel[31]);
				 listSp.add("XP Needed: " + XpNeed[31]);
				 }}
				 this.drawHoveringText(listSp, x + 236, y + 16, fontRendererObj);

			 }


			 if(mouseX >= x + 181 && mouseX <= x + 219 && mouseY >= y + 125 && mouseY <= y + 141) {
				 List listMu = new ArrayList();
				 if (XpLock5 == 0){
					 listMu.add("Locked");}
					 else{
				 listMu.add(Skill[32]+ ": " + Level[32]);
				 listMu.add("XP: " + XP[32]);
				 if(Level[32] == 99 && MainLock == 1 ) {}
				 else if(Level[32] == 200 && MainLock == 2) {}
				 else if(Level[32] == 255){}
				 else{
				 listMu.add("Next Level: " + NextLevel[32]);
				 listMu.add("XP Needed: " + XpNeed[32]);
				 }}
				 this.drawHoveringText(listMu, x + 236, y + 16, fontRendererObj);

			 }


			 if(mouseX >= x + 181 && mouseX <= x + 219 && mouseY >= y + 152 && mouseY <= y + 168) {
				 List listFi = new ArrayList();
				 if (XpLock6 == 0){
					 listFi.add("Locked");}
					 else{
				 listFi.add(Skill[33]+ ": " + Level[33]);
				 listFi.add("XP: " + XP[33]);
				 if(Level[33] == 99 && MainLock == 1 ) {}
				 else if(Level[33] == 200 && MainLock == 2) {}
				 else if(Level[33] == 255){}
				 else{
				 listFi.add("Next Level: " + NextLevel[33]);
				 listFi.add("XP Needed: " + XpNeed[33]);
				 }}
				 this.drawHoveringText(listFi, x + 236, y + 16, fontRendererObj);

			 }


			 if(mouseX >= x + 181 && mouseX <= x + 219 && mouseY >= y + 179 && mouseY <= y + 195) {
				 List listFu = new ArrayList();
				 if (XpLock7 == 0){
					 listFu.add("Locked");}
					 else{
				 listFu.add(Skill[34]+ ": " + Level[34]);
				 listFu.add("XP: " + XP[34]);
				 if(Level[34] == 99 && MainLock == 1 ) {}
				 else if(Level[34] == 200 && MainLock == 2) {}
				 else if(Level[34] == 255){}
				 else{
				 listFu.add("Next Level: " + NextLevel[34]);
				 listFu.add("XP Needed: " + XpNeed[34]);
				 }}
				 this.drawHoveringText(listFu, x + 236, y + 16, fontRendererObj);

			 }





		 }














 @Override
 public boolean doesGuiPauseGame() {
 return false;
                      
     }

 @Override
    public void initGui() {



 }






 @Override
     public void updateScreen() {
         super.updateScreen();
 }
}

 

 

Thanks for the help, :)

 

Mark136

my Mod: Extended RPG [W.I.P]

Posted

0) do not use getBlockById.  Just because the block ID is what you have in your code in your development environtment does not mean that that is what it will be when someone else loads your mod.  Just compare blocks. 

if(block == Blocks.stone)

 

1) don't cancel the block break event, you want to interrupt the EventPlayerBreakSpeed (If I am remembering its name correctly).

 

2) GuiStatlist is a client-side class, you can't just directly add xp to the gui.  That will crash the server.  You need a Capabilities object that will save the player's skills and exp so that it can be both network-safe and persistent.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Note that event handlers are not usually implemented as static methods, at least in my experience. I don't know if that will break anything, but there is no reason to make the method static, and certainly do NOT use static ID - what the heck is that for? The BreakEvent GIVES you the block that was broken - use it.

 

I'd also recommend making a lookup table for your xp charts, especially if you are going to include more block types or want a way for other mods to add their own blocks via some kind of API.

 

As a brief and incomplete example:

private static final HashMap<Block, Integer> xpChart = new HashMap<Block, Integer>();

public void setBlockXp(Block block, int xp) {
    xpChart.put(block, xp);
}

// then in your break event:
@SubscribeEvent
public void onBreak(BreakEvent event) {
   Integer xp = xpChart.get(event.block); // note that this may return NULL
   // etc.
}

Posted

ok i saw that i need 2 events, one for getting Xp if the block breaks and one for interrupting the breakspeed.

But i cant find a method that looks up for me what block i'm exactly mining.

 

*if(Block == Block.stone)* does'nt work for me

(event.block) gives error "block cannot be resolved or is not a field"

 

i also replaced my level and Xp and Calcs to an other classfile :P

i'm sorry for my bad java. im still need to learn a lot more of it. at least i can read it well  but can make some ugly mistakes if i write the code myself.

my Mod: Extended RPG [W.I.P]

Posted

why so Mad, Relax Man, everyone needs to start sometime with java. i already written my Gui myself, and then I come with some problems with finding the right field, but you say I could find that code by looking in the source. okay yeah a very stupit question but where can i find that source code? because i can't find that files man... if i find a method/field that i can use i mostly google it 20 times for what it exactly can do ect.

PS. oh nvm i found them... how can i be so stupid

 

my Mod: Extended RPG [W.I.P]

Posted

Right click, references, find in workspace.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

(which is also Ctrl-Shift-G, long live the keyboard).

 

I don't use it often enough to remember the keyboard shortcut.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

okay, it's working. maybe not the shortest way but it works. only problem now is that i want to let everyone on my server got his own skill levels and XP.

package com.modMark.Skill;

import com.modMark.Item_Block.MarkBlocks;

import akka.actor.FSM.State;
import ibxm.Player;
import net.minecraft.block.Block;
import net.minecraft.block.BlockCrops;
import net.minecraft.block.BlockStone;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.event.world.BlockEvent.BreakEvent;
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import scala.reflect.internal.Trees.ThisSubstituter;



public class EventHandlerMark {

public static Block ID;
public static int[] getXP = new int[35];
public static boolean notnull;
public static int ReqLvl;
public static EntityPlayer player;



@SubscribeEvent
public void Breakevent1(BreakSpeed event)
{
	//...
	EntityPlayer Player = player;


	Block block = event.state.getBlock();
	if (block == Blocks.stone || block == Blocks.cobblestone){
		ReqLvl = 0;
		}


	if (block == Blocks.wheat){
		ReqLvl = 0;
		}
	if (block == Blocks.carrots){
		ReqLvl = 5;
		}
	if (block == Blocks.potatoes){
		ReqLvl = 10;
		}



	if (block == Blocks.coal_ore){
		ReqLvl = 5;
		}
	if (block == Blocks.emerald_ore){
		ReqLvl = 10;
		}
	if (block == Blocks.iron_ore){
		ReqLvl = 20;
		}
	if (block == Blocks.lapis_ore){
		ReqLvl = 25;
		}
	if (block == Blocks.gold_ore){
		ReqLvl = 30;
		}
	if (block == Blocks.diamond_ore){
		ReqLvl = 40;
		}
	if (block == Blocks.redstone_ore || block == Blocks.lit_redstone_ore ||block == Blocks.redstone_block || block == Blocks.obsidian ){
		ReqLvl = 45;
		}
	if (block == Blocks.netherrack ||block == Blocks.nether_brick ){
		ReqLvl = 50;
		}
	if (block == MarkBlocks.OreNetherite){
		ReqLvl = 60;
		}
	if (block == Blocks.quartz_ore || block == Blocks.quartz_block){
		ReqLvl = 70;
		}
	if (block == MarkBlocks.NetherStone){
		ReqLvl = 75;
		}
	if (block == MarkBlocks.OreOther){
		ReqLvl = 80;
		}




	if (block == Blocks.dirt || block == Blocks.grass){
		ReqLvl = 0;
		}
	if (block == MarkBlocks.GemOpalOre){
		ReqLvl = 5;
		}
	if (block == Blocks.gravel){
		ReqLvl = 5;
		}
	if (block == MarkBlocks.GemSapphireOre){
		ReqLvl = 10;
		}
	if (block == Blocks.sand){
		ReqLvl = 10;
		}
	if (block == MarkBlocks.GemOlivineOre){
		ReqLvl = 15;
		}
	if (block == MarkBlocks.GemHyacinthOre){
		ReqLvl = 20;
		}
	if (block == MarkBlocks.GemTopazOre){
		ReqLvl = 25;
		}
	if (block == Blocks.mycelium){
		ReqLvl = 30;
		}
	if (block == MarkBlocks.GemAmethystOre){
		ReqLvl = 40;
		}
	if (block == Blocks.soul_sand){
		ReqLvl = 50;
		}
	if (block == MarkBlocks.GemSiamOre){
		ReqLvl = 60;
		}
	if (block == MarkBlocks.CrystSand){
		ReqLvl = 75;
		}
	if (block == MarkBlocks.GemAquamarineOre){
		ReqLvl = 80;
		}


	if (block == Blocks.log){
		ReqLvl = 0;
		}
	if (block == Blocks.cactus){
		ReqLvl = 10;
		}
	if (block == Blocks.log2){
		ReqLvl = 20;
		}
	if (block == MarkBlocks.LogYew){
		ReqLvl = 40;
		}
	if (block == MarkBlocks.LogNetherBranch){
		ReqLvl = 60;
		}
	if (block == MarkBlocks.LogNetherWood){
		ReqLvl = 80;
		}


if (ReqLvl > Skill.Level[8] && block.getMaterial() == Material.rock){
	event.setCanceled(true);
	FMLClientHandler.instance().getClient().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("You need " + ReqLvl + " Mining for this."));
	}
else if
	(ReqLvl > Skill.Level[10] && block.getMaterial() == Material.sand || ReqLvl > Skill.Level[10] && block.getMaterial() == Material.ground){
	event.setCanceled(true);
	FMLClientHandler.instance().getClient().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("You need " + ReqLvl + " Excavation for this."));
}
else if
	(ReqLvl > Skill.Level[7] && block.getMaterial() == Material.plants){
	event.setCanceled(true);
	FMLClientHandler.instance().getClient().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("You need " + ReqLvl + " Farming for this."));
}
else if
(ReqLvl > Skill.Level[11] && block.getMaterial() == Material.wood || ReqLvl > Skill.Level[11] && block.getMaterial() == Material.cactus){
event.setCanceled(true);
FMLClientHandler.instance().getClient().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("You need " + ReqLvl + " Woodcutting for this."));
}
else if (block.getMaterial() == Material.air){

}
else{}






	}



@SubscribeEvent
public void BreakBlock(BreakEvent event){

	Block block = event.state.getBlock();
	ID = event.state.getBlock();
	if (block != null || block != Blocks.air){
		this.notnull = true;
	}
	else{ this.notnull = false; }
	if (block == Blocks.stone || block == Blocks.cobblestone){	
		getXP[8] += 8;
		}
	//farming
	else if (block == Blocks.wheat){
		getXP[7] += 5;
		}
	else if (block == Blocks.carrots){
		getXP[7] += 7;
		}
	else if (block == Blocks.potatoes){
		getXP[7] += 9;
		}



	//mining
	else if (block == Blocks.coal_ore){
		getXP[8] += 12;
		}
	else if (block == Blocks.emerald_ore){
		getXP[8] += 16;
		}
	else if (block == Blocks.iron_ore){
		getXP[8] += 20;
		}
	else if (block == Blocks.lapis_ore){
		getXP[8] += 24;
		}
	else if (block == Blocks.gold_ore){
		getXP[8] += 28;
		}
	else if (block == Blocks.diamond_ore){
		getXP[8] += 32;
		}
	else if (block == Blocks.redstone_ore){
		getXP[8] += 33;
		}
	else if (block == Blocks.obsidian){
		getXP[8] += 34;
		}
	else if (block == Blocks.netherrack || block == Blocks.nether_brick){
		getXP[8] += 35;
		}
	else if (block == MarkBlocks.OreNetherite){
		getXP[10] += 40;
		}
	else if (block == Blocks.quartz_ore){
		getXP[8] += 42;
		}
	else if (block == MarkBlocks.NetherStone){
		getXP[8] += 45;
		}
	else if (block == MarkBlocks.OreOther){
		getXP[8] += 50;
		}




	else if (block == Blocks.dirt || block == Blocks.grass){
		getXP[10] += 5;
		}
	else if (block == MarkBlocks.GemOpalOre){
		getXP[10] += 8;
		}
	else if (block == Blocks.gravel){
		getXP[10] += 7;
		}
	else if (block == MarkBlocks.GemSapphireOre){
		getXP[10] += 12;
		}
	else if (block == Blocks.sand){
		getXP[10] += 9;
		}
	else if (block == MarkBlocks.GemOlivineOre){
		getXP[10] += 16;
		}
	else if (block == MarkBlocks.GemHyacinthOre){
		getXP[10] += 20;
		}
	else if (block == MarkBlocks.GemTopazOre){
		getXP[10] += 24;
		}
	else if (block == Blocks.mycelium){
		getXP[10] += 28;
		}
	else if (block == MarkBlocks.GemAmethystOre){
		getXP[10] += 32;
		}
	else if (block == Blocks.soul_sand){
		getXP[10] += 35;
		}
	else if (block == MarkBlocks.GemSiamOre){
		getXP[10] += 40;
		}
	else if (block == MarkBlocks.OtherSand){
		getXP[10] += 45;
		}
	else if (block == MarkBlocks.GemAquamarineOre){
		getXP[10] += 50;
		}


	else if (block == Blocks.log){
		getXP[11] += 10;
		}
	else if (block == Blocks.cactus){
		getXP[11] += 12;
		}
	else if (block == Blocks.log2){
		getXP[11] += 18;
		}
	else if (block == MarkBlocks.LogYew){
		getXP[11] += 30;
		}
	else if (block == MarkBlocks.LogNetherBranch){
		getXP[11] += 45;
		}
	else if (block == MarkBlocks.LogNetherWood){
		getXP[11] += 60;
		}

	else {

		}

	if (notnull == true){
		getEventXp();
	}






}
	public static void getEventXp() {

		for (int i = 0;i < 35; i++){
			if (getXP[i] > 500000 && Skill.MainLock == 1){
				getXP[i] = 500000;
			}
			else if (getXP[i] > 85000000 && Skill.MainLock == 2){
				getXP[i] = 85000000;
			}
			else if (getXP[i] > 2000000000 && Skill.MainLock == 3){
				getXP[i] = 2000000000;
			}

		}

		Skill.getXp(Skill.Player);
			for(int j = 0; j < 35; j++){
		Skill.XP[j] += getXP[j];
			}
		}
		}

 

oh and also, i'm creating some extra stuff like blocks and items and trees. (that new model system for textures is a bit differend than i remembered previous)and that works fine :)

my Mod: Extended RPG [W.I.P]

Posted

yeah, have worked on it. but got a real fight right now with the packetHandler (IMessage/IMessageHandler)

 

i put my files here again

here's My EventHandler

EventHandlerMark.java:

 

package com.modMark.Skill;

import java.util.List;

import com.modMark.Item_Block.MarkBlocks;

import akka.actor.FSM.State;
import ibxm.Player;
import net.minecraft.block.Block;
import net.minecraft.block.BlockCrops;
import net.minecraft.block.BlockStone;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.EntityEvent.EntityConstructing;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed;
import net.minecraftforge.event.terraingen.SaplingGrowTreeEvent;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.event.world.BlockEvent.BreakEvent;
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import scala.reflect.internal.Trees.ThisSubstituter;



public class EventHandlerMark {

public boolean notnull;





@SubscribeEvent
public void onEntityConstructing(EntityConstructing event)
{		
	if (event.entity instanceof EntityPlayer && XpSave.get((EntityPlayer) event.entity) == null){	
		XpSave.register((EntityPlayer) event.entity);

		EntityPlayer player = (EntityPlayer) event.entity;
		XpSave p = XpSave.get(player);

		for (int i = 0; i < 35; i++){
			p.XP[i] = 0;

		}

	}


}

@SubscribeEvent
public void Farming(SaplingGrowTreeEvent event)
{


}




@SubscribeEvent
public void MinExcaWCFarm_Req(BreakSpeed event)
{
	//Event for req level Mining, Excavation, Woodcutting & Farming
	EntityPlayer player = event.entityPlayer;
	XpSave p = XpSave.get(player);

	Block block = event.state.getBlock();
	if (block == Blocks.stone || block == Blocks.cobblestone){
		p.requireLvl(8, 0);
		}


	if (block == Blocks.wheat){
		p.requireLvl(7, 0);
		}
	if (block == Blocks.carrots){
		p.requireLvl(7, 5);
		}
	if (block == Blocks.potatoes){
		p.requireLvl(7, 10);
		}



	if (block == Blocks.coal_ore){
		p.requireLvl(8, 5);
		}
	if (block == Blocks.emerald_ore){
		p.requireLvl(8, 10);
		}
	if (block == Blocks.iron_ore){
		p.requireLvl(8, 20);
		}
	if (block == Blocks.lapis_ore){
		p.requireLvl(8, 25);
		}
	if (block == Blocks.gold_ore){
		p.requireLvl(8, 30);
		}
	if (block == Blocks.diamond_ore){
		p.requireLvl(8, 40);
		}
	if (block == Blocks.redstone_ore || block == Blocks.lit_redstone_ore ||block == Blocks.redstone_block || block == Blocks.obsidian ){
		p.requireLvl(8, 45);
		}
	if (block == Blocks.netherrack ||block == Blocks.nether_brick ){
		p.requireLvl(8, 50);
		}
	if (block == MarkBlocks.OreNetherite){
		p.requireLvl(8, 60);
		}
	if (block == Blocks.quartz_ore || block == Blocks.quartz_block){
		p.requireLvl(8, 70);
		}
	if (block == MarkBlocks.CrystRack){
		p.requireLvl(8, 75);
		}
	if (block == MarkBlocks.OreCrystlium){
		p.requireLvl(8, 80);
		}



	//excavation
	if (block == Blocks.dirt || block == Blocks.grass){
		p.requireLvl(10, 0);
		}
	if (block == MarkBlocks.GemOpalOre){
		p.requireLvl(10, 5);
		}
	if (block == Blocks.gravel){
		p.requireLvl(10, 5);
		}
	if (block == MarkBlocks.GemSapphireOre){
		p.requireLvl(10, 10);
		}
	if (block == Blocks.sand){
		p.requireLvl(10, 10);
		}
	if (block == MarkBlocks.GemOlivineOre){
		p.requireLvl(10, 15);
		}
	if (block == MarkBlocks.GemHyacinthOre){
		p.requireLvl(10, 15);
		}
	if (block == MarkBlocks.GemTopazOre){
		p.requireLvl(10, 25);;
		}
	if (block == Blocks.mycelium){
		p.requireLvl(10, 30);
		}
	if (block == MarkBlocks.GemAmethystOre){
		p.requireLvl(10, 40);
		}
	if (block == Blocks.soul_sand){
		p.requireLvl(10, 50);
		}
	if (block == MarkBlocks.GemSiamOre){
		p.requireLvl(10, 60);
		}
	if (block == MarkBlocks.CrystSand){
		p.requireLvl(10, 75);
		}
	if (block == MarkBlocks.GemAquamarineOre){
		p.requireLvl(10, 80);
		}


	if (block == Blocks.log){
		p.requireLvl(11, 0);
		}
	if (block == Blocks.cactus){
		p.requireLvl(11, 10);
		}
	if (block == Blocks.log2){
		p.requireLvl(11, 20);
		}
	if (block == MarkBlocks.LogYew){
		p.requireLvl(11, 40);
		}
	if (block == MarkBlocks.LogNetherBranch){
		p.requireLvl(11, 60);
		}
	if (block == MarkBlocks.LogCrystWood){
		p.requireLvl(11, 80);
		}

	if (XpSave.candothis == false){
	event.setCanceled(true);
	}	
}



@SubscribeEvent
public void MinExcaWC_XP(BreakEvent event){

	EntityPlayer player = event.getPlayer();

	XpSave p = XpSave.get(player);
	Block block = event.state.getBlock();
	if (block != null || block != Blocks.air){
		this.notnull = true;
	}
	else{ this.notnull = false; }
	if (block == Blocks.stone || block == Blocks.cobblestone){	
		p.getXp(8, ;
		}



	if (block == Blocks.wheat && (((Integer)event.state.getValue(BlockCrops.AGE)).intValue() == 7)){
		p.getXp(7, 5);
	}
	else if (block == Blocks.carrots && (((Integer)event.state.getValue(BlockCrops.AGE)).intValue() == 7)){
		p.getXp(7, 7);
	}
	else if (block == Blocks.potatoes && (((Integer)event.state.getValue(BlockCrops.AGE)).intValue() == 7)){
		p.getXp(7, 9);
	}

	//mining
	else if (block == Blocks.coal_ore){
		p.getXp(8, 12);
		}
	else if (block == Blocks.emerald_ore){
		p.getXp(8, 16);
		}
	else if (block == Blocks.iron_ore){
		p.getXp(8, 20);
		}
	else if (block == Blocks.lapis_ore){
		p.getXp(8, 24);
		}
	else if (block == Blocks.gold_ore){
		p.getXp(8, 28);
		}
	else if (block == Blocks.diamond_ore){
		p.getXp(8, 32);
		}
	else if (block == Blocks.redstone_ore){
		p.getXp(8, 33);
		}
	else if (block == Blocks.obsidian){
		p.getXp(8, 34);
		}
	else if (block == Blocks.netherrack || block == Blocks.nether_brick){
		p.getXp(8, 35);
		}
	else if (block == MarkBlocks.OreNetherite){
		p.getXp(8, 40);
		}
	else if (block == Blocks.quartz_ore){
		p.getXp(8, 42);
		}
	else if (block == MarkBlocks.CrystRack){
		p.getXp(8, 45);
		}
	else if (block == MarkBlocks.OreCrystlium){
		p.getXp(8, 50);
		}




	else if (block == Blocks.dirt || block == Blocks.grass){
		p.getXp(10, 5);
		}
	else if (block == MarkBlocks.GemOpalOre){
		p.getXp(10, ;
		}
	else if (block == Blocks.gravel){
		p.getXp(10, 7);
		}
	else if (block == MarkBlocks.GemSapphireOre){
		p.getXp(10, 12);
		}
	else if (block == Blocks.sand){
		p.getXp(10, 9);
		}
	else if (block == MarkBlocks.GemOlivineOre){
		p.getXp(10, 16);
		}
	else if (block == MarkBlocks.GemHyacinthOre){
		p.getXp(10, 20);
		}
	else if (block == MarkBlocks.GemTopazOre){
		p.getXp(10, 24);
		}
	else if (block == Blocks.mycelium){
		p.getXp(10, 28);
		}
	else if (block == MarkBlocks.GemAmethystOre){
		p.getXp(10, 32);
		}
	else if (block == Blocks.soul_sand){
		p.getXp(10, 35);
		}
	else if (block == MarkBlocks.GemSiamOre){
		p.getXp(10, 40);
		}
	else if (block == MarkBlocks.CrystSand){
		p.getXp(10, 45);
		}
	else if (block == MarkBlocks.GemAquamarineOre){
		p.getXp(10, 50);
		}


	else if (block == Blocks.log){
		p.getXp(11, 10);
		}
	else if (block == Blocks.cactus){
		p.getXp(11, 12);
		}
	else if (block == Blocks.log2){
		p.getXp(11, 18);
		}
	else if (block == MarkBlocks.LogYew){
		p.getXp(11, 30);

		}
	else if (block == MarkBlocks.LogNetherBranch){
		p.getXp(11, 45);

		}
	else if (block == MarkBlocks.LogCrystWood){
		p.getXp(11, 60);
		}

	else {

		}

	if (notnull == true){
		p.getEventXp();
	}
}
}

 

I will come with the XpSave File(IExtendedEntityProperties) as soon as possible

same for the IMessageHandler and IMessage File

 

 

my Mod: Extended RPG [W.I.P]

Posted

hhm, I got an error... something with The Sending of my Packet from server to client. the game does'nt crash, but i don't get XP

but got an error in the console:

 

ps. this is much more work than i expected, all i want to do is to give every player the stats. so i need IExtendedEntityProperties for it. also, i need to send this to the client side to put it into the gui. because i got 35 skills  with xp variables that changes much i also need a datawatcher. ehh ok i'm lost right know...

 

here are the files

IExtendedEntityProperties file

package com.modMark.Skill;

import com.modMark.Main.MainRegistry;
import com.modMark.Packets.SkillPacket;

import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
import net.minecraftforge.common.IExtendedEntityProperties;

public class XpSave implements IExtendedEntityProperties {

public static final String EXT_PLAYER136 = "ExtendedPlayer";
private final EntityPlayer player;
public static boolean candothis;
public static int[] XP = new int[35];

public XpSave(EntityPlayer player){
	this.player = player;
	getEventXp();

}
public static final void register(EntityPlayer player)
{
player.registerExtendedProperties(XpSave.EXT_PLAYER136, new XpSave(player));
}

public static final XpSave get(EntityPlayer player)
{
	return (XpSave) player.getExtendedProperties(EXT_PLAYER136);
}

@Override
public void saveNBTData(NBTTagCompound compound) {
	NBTTagCompound properties = new NBTTagCompound();
	for(int i = 0;i < 35; i++){
	properties.setInteger("Skill[" + i + "]", XP[i]);

	}
}

@Override
public void loadNBTData(NBTTagCompound compound) {
	NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PLAYER136);
	for (int i = 0; i < 35; i++)
		XP[i] = properties.getInteger("Skill[" + i + "]");

}

@Override
public void init(Entity entity, World world) {

}

public int getXp(int SkillID, int amount){

	return XP[skillID] += amount;

}

public void requireLvl(int SkillID, int reqlvl){
	Skill.getSkillName();
	candothis = Skill.Level[skillID] >= reqlvl;
	if(candothis == false){
		ChatComponentText component = new ChatComponentText("You need " + reqlvl + " " + Skill.SkillName[skillID] + " for this");
		player.addChatComponentMessage(component);
	}


}

public static void getEventXp() {

for (int i = 0;i < 35; i++){
	if ((XP[i]) > 500000 && Skill.MainLock == 1){
		XP[i] = 500000;

	}
	else if ((XP[i]) > 85000000 && Skill.MainLock == 2){

		XP[i] = 85000000;
	}
	else if ((XP[i]) > 2000000000 && Skill.MainLock == 3){

		XP[i] = 2000000000;
	}
}
}
}

 

IMessage file

package com.modMark.Packets;

import com.modMark.Main.GuiStatlist;
import com.modMark.Skill.Skill;
import com.modMark.Skill.XpSave;

import io.netty.buffer.ByteBuf;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;

public class SkillPacket implements IMessage{

public SkillPacket() {}
public SkillPacket(int s){
	XpSave.getEventXp();

	EntityPlayer player = (EntityPlayer) Minecraft.getMinecraft().thePlayer;
	XpSave p = XpSave.get(player);
	for (int i = 0; i < 35; i++){
	p.XP[i] = s[i];
	}
}

@Override
public void fromBytes(ByteBuf buf) {
	for (int j = 0; j < 35; j++){
	buf.writeInt(XpSave.XP[j]);
	}
}

@Override
public void toBytes(ByteBuf buf) {
	for (int k = 0; k < 35; k++){
	XpSave.XP[k] = buf.readInt();
	}
}

}

IMessageHandler File

package com.modMark.Packets;



import com.modMark.Main.GuiStatlist;
import com.modMark.Skill.XpSave;

import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.IThreadListener;
import net.minecraft.world.WorldServer;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
import net.minecraftforge.fml.relauncher.Side;

public class MarkPacketHandler implements IMessageHandler<SkillPacket, IMessage > {

@Override
public IMessage onMessage(SkillPacket message, MessageContext ctx) {
	IThreadListener ThreadListener = Minecraft.getMinecraft();
			ThreadListener.addScheduledTask(new Runnable() {
				@Override
                public void run() {
			EntityPlayer player = (EntityPlayer) Minecraft.getMinecraft().thePlayer;
					XpSave p = XpSave.get(player);
					XpSave.getEventXp();
                    for (int i = 0; i < 35; i++){
                    	p.XP[i] = GuiStatlist.XP[i];
                    }
                }
			});
	return null;
}

}

 

and again my EventHandler File

package com.modMark.Skill;

import java.util.List;

import com.modMark.Item_Block.MarkBlocks;
import com.modMark.Main.MainRegistry;
import com.modMark.Packets.SkillPacket;

import akka.actor.FSM.State;
import ibxm.Player;
import net.minecraft.block.Block;
import net.minecraft.block.BlockCrops;
import net.minecraft.block.BlockStone;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.EntityEvent.EntityConstructing;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed;
import net.minecraftforge.event.terraingen.SaplingGrowTreeEvent;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.event.world.BlockEvent.BreakEvent;
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import scala.reflect.internal.Trees.ThisSubstituter;



public class EventHandlerMark {

public static boolean notnull;





@SubscribeEvent
public void onEntityConstructing(EntityConstructing event)
{		
	if (event.entity instanceof EntityPlayer && XpSave.get((EntityPlayer) event.entity) == null){	
		XpSave.register((EntityPlayer) event.entity);

		EntityPlayer player = (EntityPlayer) event.entity;
		XpSave p = XpSave.get(player);

		for (int i = 0; i < 35; i++){
			p.XP[i] = 0;

		}
	}


}

@SubscribeEvent
public void Farming(SaplingGrowTreeEvent event)
{


}




@SubscribeEvent
public void MinExcaWCFarm_Req(BreakSpeed event)
{
	//Event for req level Mining, Excavation, Woodcutting & Farming
	EntityPlayer player = event.entityPlayer;
	XpSave p = XpSave.get(player);

	Block block = event.state.getBlock();
	if (block == Blocks.stone || block == Blocks.cobblestone){
		p.requireLvl(8, 0);
		}


	if (block == Blocks.wheat){
		p.requireLvl(7, 0);
		}
	if (block == Blocks.carrots){
		p.requireLvl(7, 5);
		}
	if (block == Blocks.potatoes){
		p.requireLvl(7, 10);
		}



	if (block == Blocks.coal_ore){
		p.requireLvl(8, 5);
		}
	if (block == Blocks.emerald_ore){
		p.requireLvl(8, 10);
		}
	if (block == Blocks.iron_ore){
		p.requireLvl(8, 20);
		}
	if (block == Blocks.lapis_ore){
		p.requireLvl(8, 25);
		}
	if (block == Blocks.gold_ore){
		p.requireLvl(8, 30);
		}
	if (block == Blocks.diamond_ore){
		p.requireLvl(8, 40);
		}
	if (block == Blocks.redstone_ore || block == Blocks.lit_redstone_ore ||block == Blocks.redstone_block || block == Blocks.obsidian ){
		p.requireLvl(8, 45);
		}
	if (block == Blocks.netherrack ||block == Blocks.nether_brick ){
		p.requireLvl(8, 50);
		}
	if (block == MarkBlocks.OreNetherite){
		p.requireLvl(8, 60);
		}
	if (block == Blocks.quartz_ore || block == Blocks.quartz_block){
		p.requireLvl(8, 70);
		}
	if (block == MarkBlocks.CrystRack){
		p.requireLvl(8, 75);
		}
	if (block == MarkBlocks.OreCrystlium){
		p.requireLvl(8, 80);
		}



	//excavation
	if (block == Blocks.dirt || block == Blocks.grass){
		p.requireLvl(10, 0);
		}
	if (block == MarkBlocks.GemOpalOre){
		p.requireLvl(10, 5);
		}
	if (block == Blocks.gravel){
		p.requireLvl(10, 5);
		}
	if (block == MarkBlocks.GemSapphireOre){
		p.requireLvl(10, 10);
		}
	if (block == Blocks.sand){
		p.requireLvl(10, 10);
		}
	if (block == MarkBlocks.GemOlivineOre){
		p.requireLvl(10, 15);
		}
	if (block == MarkBlocks.GemHyacinthOre){
		p.requireLvl(10, 15);
		}
	if (block == MarkBlocks.GemTopazOre){
		p.requireLvl(10, 25);;
		}
	if (block == Blocks.mycelium){
		p.requireLvl(10, 30);
		}
	if (block == MarkBlocks.GemAmethystOre){
		p.requireLvl(10, 40);
		}
	if (block == Blocks.soul_sand){
		p.requireLvl(10, 50);
		}
	if (block == MarkBlocks.GemSiamOre){
		p.requireLvl(10, 60);
		}
	if (block == MarkBlocks.CrystSand){
		p.requireLvl(10, 75);
		}
	if (block == MarkBlocks.GemAquamarineOre){
		p.requireLvl(10, 80);
		}


	if (block == Blocks.log){
		p.requireLvl(11, 0);
		}
	if (block == Blocks.cactus){
		p.requireLvl(11, 10);
		}
	if (block == Blocks.log2){
		p.requireLvl(11, 20);
		}
	if (block == MarkBlocks.LogYew){
		p.requireLvl(11, 40);
		}
	if (block == MarkBlocks.LogNetherBranch){
		p.requireLvl(11, 60);
		}
	if (block == MarkBlocks.LogCrystWood){
		p.requireLvl(11, 80);
		}

	if (XpSave.candothis == false){
	event.setCanceled(true);
	}	
}



@SubscribeEvent
public void MinExcaWC_XP(BreakEvent event){

	EntityPlayer player = event.getPlayer();
	XpSave p = XpSave.get(player);
	Block block = event.state.getBlock();


	if (block != null || block != Blocks.air){
		this.notnull = true;
	}
	else{ this.notnull = false; }
	if (block == Blocks.stone || block == Blocks.cobblestone){	
		p.getXp(8, ;
		}



	else if (block == Blocks.wheat && (((Integer)event.state.getValue(BlockCrops.AGE)).intValue() == 7)){
		p.getXp(7, 5);
	}
	else if (block == Blocks.carrots && (((Integer)event.state.getValue(BlockCrops.AGE)).intValue() == 7)){
		p.getXp(7, 7);
	}
	else if (block == Blocks.potatoes && (((Integer)event.state.getValue(BlockCrops.AGE)).intValue() == 7)){
		p.getXp(7, 9);
	}

	//mining
	else if (block == Blocks.coal_ore){
		p.getXp(8, 12);
		}
	else if (block == Blocks.emerald_ore){
		p.getXp(8, 16);
		}
	else if (block == Blocks.iron_ore){
		p.getXp(8, 20);
		}
	else if (block == Blocks.lapis_ore){
		p.getXp(8, 24);
		}
	else if (block == Blocks.gold_ore){
		p.getXp(8, 28);
		}
	else if (block == Blocks.diamond_ore){
		p.getXp(8, 32);
		}
	else if (block == Blocks.redstone_ore){
		p.getXp(8, 33);
		}
	else if (block == Blocks.obsidian){
		p.getXp(8, 34);
		}
	else if (block == Blocks.netherrack || block == Blocks.nether_brick){
		p.getXp(8, 35);
		}
	else if (block == MarkBlocks.OreNetherite){
		p.getXp(8, 40);
		}
	else if (block == Blocks.quartz_ore){
		p.getXp(8, 42);
		}
	else if (block == MarkBlocks.CrystRack){
		p.getXp(8, 45);
		}
	else if (block == MarkBlocks.OreCrystlium){
		p.getXp(8, 50);
		}




	else if (block == Blocks.dirt || block == Blocks.grass){
		p.getXp(10, 5);
		}
	else if (block == MarkBlocks.GemOpalOre){
		p.getXp(10, ;
		}
	else if (block == Blocks.gravel){
		p.getXp(10, 7);
		}
	else if (block == MarkBlocks.GemSapphireOre){
		p.getXp(10, 12);
		}
	else if (block == Blocks.sand){
		p.getXp(10, 9);
		}
	else if (block == MarkBlocks.GemOlivineOre){
		p.getXp(10, 16);
		}
	else if (block == MarkBlocks.GemHyacinthOre){
		p.getXp(10, 20);
		}
	else if (block == MarkBlocks.GemTopazOre){
		p.getXp(10, 24);
		}
	else if (block == Blocks.mycelium){
		p.getXp(10, 28);
		}
	else if (block == MarkBlocks.GemAmethystOre){
		p.getXp(10, 32);
		}
	else if (block == Blocks.soul_sand){
		p.getXp(10, 35);
		}
	else if (block == MarkBlocks.GemSiamOre){
		p.getXp(10, 40);
		}
	else if (block == MarkBlocks.CrystSand){
		p.getXp(10, 45);
		}
	else if (block == MarkBlocks.GemAquamarineOre){
		p.getXp(10, 50);
		}


	else if (block == Blocks.log){
		p.getXp(11, 10);
		}
	else if (block == Blocks.cactus){
		p.getXp(11, 12);
		}
	else if (block == Blocks.log2){
		p.getXp(11, 18);
		}
	else if (block == MarkBlocks.LogYew){
		p.getXp(11, 30);

		}
	else if (block == MarkBlocks.LogNetherBranch){
		p.getXp(11, 45);

		}
	else if (block == MarkBlocks.LogCrystWood){
		p.getXp(11, 60);
		}

	else {

		}

	if (notnull == true){
		p.getEventXp();
		MainRegistry.network.sendTo(new SkillPacket(), (EntityPlayerMP) player);
	}
}
}

 

and here is the console:

[14:27:53] [server thread/ERROR] [FML]: FMLIndexedMessageCodec exception caught
io.netty.handler.codec.EncoderException: java.lang.IndexOutOfBoundsException: readerIndex(0) + length(4) exceeds writerIndex(1): UnpooledHeapByteBuf(ridx: 0, widx: 1, cap: 256)
at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:107) ~[MessageToMessageEncoder.class:4.0.23.Final]
at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116) ~[MessageToMessageCodec.class:4.0.23.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:658) ~[AbstractChannelHandlerContext.class:4.0.23.Final]
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:716) ~[AbstractChannelHandlerContext.class:4.0.23.Final]
at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:706) ~[AbstractChannelHandlerContext.class:4.0.23.Final]
at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:741) ~[AbstractChannelHandlerContext.class:4.0.23.Final]
at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:895) ~[DefaultChannelPipeline.class:4.0.23.Final]
at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:240) ~[AbstractChannel.class:4.0.23.Final]
at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.sendTo(SimpleNetworkWrapper.java:229) [simpleNetworkWrapper.class:?]
at com.modMark.Skill.EventHandlerMark.MinExcaWC_XP(EventHandlerMark.java:354) [EventHandlerMark.class:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_10_EventHandlerMark_MinExcaWC_XP_BreakEvent.invoke(.dynamic) [?:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:55) [ASMEventHandler.class:?]
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140) [EventBus.class:?]
at net.minecraftforge.common.ForgeHooks.onBlockBreakEvent(ForgeHooks.java:684) [ForgeHooks.class:?]
at net.minecraft.server.management.ItemInWorldManager.tryHarvestBlock(ItemInWorldManager.java:299) [itemInWorldManager.class:?]
at net.minecraft.server.management.ItemInWorldManager.onBlockClicked(ItemInWorldManager.java:164) [itemInWorldManager.class:?]
at net.minecraft.network.NetHandlerPlayServer.processPlayerDigging(NetHandlerPlayServer.java:551) [NetHandlerPlayServer.class:?]
at net.minecraft.network.play.client.C07PacketPlayerDigging.processPacket(C07PacketPlayerDigging.java:56) [C07PacketPlayerDigging.class:?]
at net.minecraft.network.play.client.C07PacketPlayerDigging.processPacket(C07PacketPlayerDigging.java:12) [C07PacketPlayerDigging.class:?]
at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) [PacketThreadUtil$1.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_40]
at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_40]
at net.minecraft.util.Util.runTask(Util.java:22) [util.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:736) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:681) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:159) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:548) [MinecraftServer.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_40]
Caused by: java.lang.IndexOutOfBoundsException: readerIndex(0) + length(4) exceeds writerIndex(1): UnpooledHeapByteBuf(ridx: 0, widx: 1, cap: 256)
at io.netty.buffer.AbstractByteBuf.checkReadableBytes(AbstractByteBuf.java:1175) ~[AbstractByteBuf.class:4.0.23.Final]
at io.netty.buffer.AbstractByteBuf.readInt(AbstractByteBuf.java:619) ~[AbstractByteBuf.class:4.0.23.Final]
at net.minecraft.network.PacketBuffer.readInt(PacketBuffer.java:697) ~[PacketBuffer.class:?]
at com.modMark.Packets.SkillPacket.toBytes(SkillPacket.java:30) ~[skillPacket.class:?]
at net.minecraftforge.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:11) ~[simpleIndexedCodec.class:?]
at net.minecraftforge.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:7) ~[simpleIndexedCodec.class:?]
at net.minecraftforge.fml.common.network.FMLIndexedMessageToMessageCodec.encode(FMLIndexedMessageToMessageCodec.java:55) ~[FMLIndexedMessageToMessageCodec.class:?]
at io.netty.handler.codec.MessageToMessageCodec$1.encode(MessageToMessageCodec.java:67) ~[MessageToMessageCodec$1.class:4.0.23.Final]
at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:89) ~[MessageToMessageEncoder.class:4.0.23.Final]
... 27 more

my Mod: Extended RPG [W.I.P]

Posted

yeah but i need some methods/fields outside their class. but then eclipse gives me errors with "make it static" and if i do, the error disappears. if i use the methods/fields inside their class, i can use "this.

but okay here are my files again.

EventHandler:

package com.modMark.Skill;

import java.util.List;

import com.modMark.Item_Block.MarkBlocks;
import com.modMark.Main.MainRegistry;
import com.modMark.Packets.SkillPacket;

import akka.actor.FSM.State;
import ibxm.Player;
import net.minecraft.block.Block;
import net.minecraft.block.BlockCrops;
import net.minecraft.block.BlockStone;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.EntityEvent.EntityConstructing;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed;
import net.minecraftforge.event.terraingen.SaplingGrowTreeEvent;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.event.world.BlockEvent.BreakEvent;
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import scala.reflect.internal.Trees.ThisSubstituter;



public class EventHandlerMark {

public static boolean notnull;





@SubscribeEvent
public void onEntityConstructing(EntityConstructing event)
{		
	if (event.entity instanceof EntityPlayer && MarkData.get((EntityPlayer) event.entity) == null){	
		MarkData.register((EntityPlayer) event.entity);
		System.out.println("Creating properties for the player" + event.entity.getName());
	}


}

@SubscribeEvent
public void onEntityJoinWorld(EntityJoinWorldEvent event) {
    if (event.entity instanceof EntityPlayer) {
        MarkData.get((EntityPlayer) event.entity).RequestingSync();
    }
}

@SubscribeEvent
public void onPlayerCloned(PlayerEvent.Clone event) {
    NBTTagCompound compound = new NBTTagCompound();
    MarkData.get(event.original).saveReviveRelevantNBTData(compound, event.wasDeath);
    MarkData.get(event.entityPlayer).loadNBTData(compound);
}
@SubscribeEvent
public void Farming(SaplingGrowTreeEvent event)
{
	//problem: need to put what player placed the block

}




@SubscribeEvent
public void MinExcaWCFarm_Req(BreakSpeed event)
{
	//Event for req level Mining, Excavation, Woodcutting & Farming
	EntityPlayer player = event.entityPlayer;
	MarkData p = MarkData.get(player);

	Block block = event.state.getBlock();
	if (block == Blocks.stone || block == Blocks.cobblestone){
		p.requireLvl(8, 0);
		}


	if (block == Blocks.wheat){
		p.requireLvl(7, 0);
		}
	if (block == Blocks.carrots){
		p.requireLvl(7, 5);
		}
	if (block == Blocks.potatoes){
		p.requireLvl(7, 10);
		}



	if (block == Blocks.coal_ore){
		p.requireLvl(8, 5);
		}
	if (block == Blocks.emerald_ore){
		p.requireLvl(8, 10);
		}
	if (block == Blocks.iron_ore){
		p.requireLvl(8, 20);
		}
	if (block == Blocks.lapis_ore){
		p.requireLvl(8, 25);
		}
	if (block == Blocks.gold_ore){
		p.requireLvl(8, 30);
		}
	if (block == Blocks.diamond_ore){
		p.requireLvl(8, 40);
		}
	if (block == Blocks.redstone_ore || block == Blocks.lit_redstone_ore ||block == Blocks.redstone_block || block == Blocks.obsidian ){
		p.requireLvl(8, 45);
		}
	if (block == Blocks.netherrack ||block == Blocks.nether_brick ){
		p.requireLvl(8, 50);
		}
	if (block == MarkBlocks.OreNetherite){
		p.requireLvl(8, 60);
		}
	if (block == Blocks.quartz_ore || block == Blocks.quartz_block){
		p.requireLvl(8, 70);
		}
	if (block == MarkBlocks.CrystRack){
		p.requireLvl(8, 75);
		}
	if (block == MarkBlocks.OreCrystlium){
		p.requireLvl(8, 80);
		}



	//excavation
	if (block == Blocks.dirt || block == Blocks.grass){
		p.requireLvl(10, 0);
		}
	if (block == MarkBlocks.GemOpalOre){
		p.requireLvl(10, 5);
		}
	if (block == Blocks.gravel){
		p.requireLvl(10, 5);
		}
	if (block == MarkBlocks.GemSapphireOre){
		p.requireLvl(10, 10);
		}
	if (block == Blocks.sand){
		p.requireLvl(10, 10);
		}
	if (block == MarkBlocks.GemOlivineOre){
		p.requireLvl(10, 15);
		}
	if (block == MarkBlocks.GemHyacinthOre){
		p.requireLvl(10, 15);
		}
	if (block == MarkBlocks.GemTopazOre){
		p.requireLvl(10, 25);;
		}
	if (block == Blocks.mycelium){
		p.requireLvl(10, 30);
		}
	if (block == MarkBlocks.GemAmethystOre){
		p.requireLvl(10, 40);
		}
	if (block == Blocks.soul_sand){
		p.requireLvl(10, 50);
		}
	if (block == MarkBlocks.GemSiamOre){
		p.requireLvl(10, 60);
		}
	if (block == MarkBlocks.CrystSand){
		p.requireLvl(10, 75);
		}
	if (block == MarkBlocks.GemAquamarineOre){
		p.requireLvl(10, 80);
		}


	if (block == Blocks.log){
		p.requireLvl(11, 0);
		}
	if (block == Blocks.cactus){
		p.requireLvl(11, 10);
		}
	if (block == Blocks.log2){
		p.requireLvl(11, 20);
		}
	if (block == MarkBlocks.LogYew){
		p.requireLvl(11, 40);
		}
	if (block == MarkBlocks.LogNetherBranch){
		p.requireLvl(11, 60);
		}
	if (block == MarkBlocks.LogCrystWood){
		p.requireLvl(11, 80);
		}

	if (MarkData.candothis == false){
	event.setCanceled(true);
	}	
}



@SubscribeEvent
public void MinExcaWC_XP(BreakEvent event){

	EntityPlayer player = event.getPlayer();
	MarkData p = MarkData.get(player);
	Block block = event.state.getBlock();


	if (block != null || block != Blocks.air){
		this.notnull = true;
	}
	else{ this.notnull = false; }
	if (block == Blocks.stone || block == Blocks.cobblestone){	
		p.addXp(8, ;
		}



	else if (block == Blocks.wheat && (((Integer)event.state.getValue(BlockCrops.AGE)).intValue() == 7)){
		p.addXp(7, 5);
	}
	else if (block == Blocks.carrots && (((Integer)event.state.getValue(BlockCrops.AGE)).intValue() == 7)){
		p.addXp(7, 7);
	}
	else if (block == Blocks.potatoes && (((Integer)event.state.getValue(BlockCrops.AGE)).intValue() == 7)){
		p.addXp(7, 9);
	}

	//mining
	else if (block == Blocks.coal_ore){
		p.addXp(8, 12);
		}
	else if (block == Blocks.emerald_ore){
		p.addXp(8, 16);
		}
	else if (block == Blocks.iron_ore){
		p.addXp(8, 20);
		}
	else if (block == Blocks.lapis_ore){
		p.addXp(8, 24);
		}
	else if (block == Blocks.gold_ore){
		p.addXp(8, 28);
		}
	else if (block == Blocks.diamond_ore){
		p.addXp(8, 32);
		}
	else if (block == Blocks.redstone_ore){
		p.addXp(8, 33);
		}
	else if (block == Blocks.obsidian){
		p.addXp(8, 34);
		}
	else if (block == Blocks.netherrack || block == Blocks.nether_brick){
		p.addXp(8, 35);
		}
	else if (block == MarkBlocks.OreNetherite){
		p.addXp(8, 40);
		}
	else if (block == Blocks.quartz_ore){
		p.addXp(8, 42);
		}
	else if (block == MarkBlocks.CrystRack){
		p.addXp(8, 45);
		}
	else if (block == MarkBlocks.OreCrystlium){
		p.addXp(8, 50);
		}




	else if (block == Blocks.dirt || block == Blocks.grass){
		p.addXp(10, 5);
		}
	else if (block == MarkBlocks.GemOpalOre){
		p.addXp(10, ;
		}
	else if (block == Blocks.gravel){
		p.addXp(10, 7);
		}
	else if (block == MarkBlocks.GemSapphireOre){
		p.addXp(10, 12);
		}
	else if (block == Blocks.sand){
		p.addXp(10, 9);
		}
	else if (block == MarkBlocks.GemOlivineOre){
		p.addXp(10, 16);
		}
	else if (block == MarkBlocks.GemHyacinthOre){
		p.addXp(10, 20);
		}
	else if (block == MarkBlocks.GemTopazOre){
		p.addXp(10, 24);
		}
	else if (block == Blocks.mycelium){
		p.addXp(10, 28);
		}
	else if (block == MarkBlocks.GemAmethystOre){
		p.addXp(10, 32);
		}
	else if (block == Blocks.soul_sand){
		p.addXp(10, 35);
		}
	else if (block == MarkBlocks.GemSiamOre){
		p.addXp(10, 40);
		}
	else if (block == MarkBlocks.CrystSand){
		p.addXp(10, 45);
		}
	else if (block == MarkBlocks.GemAquamarineOre){
		p.addXp(10, 50);
		}


	else if (block == Blocks.log){
		p.addXp(11, 10);
		}
	else if (block == Blocks.cactus){
		p.addXp(11, 12);
		}
	else if (block == Blocks.log2){
		p.addXp(11, 18);
		}
	else if (block == MarkBlocks.LogYew){
		p.addXp(11, 30);

		}
	else if (block == MarkBlocks.LogNetherBranch){
		p.addXp(11, 45);

		}
	else if (block == MarkBlocks.LogCrystWood){
		p.addXp(11, 60);
		}

	else {

		}

	if (notnull == true){
		p.getXp();
		MainRegistry.network.sendTo(new SkillPacket(), (EntityPlayerMP) player);

	}
}
}

MarkData (previous called XpSave, but i thought MarkData was a better name)

package com.modMark.Skill;

import com.modMark.Main.MainRegistry;
import com.modMark.Packets.SkillPacket;

import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagIntArray;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
import net.minecraftforge.common.IExtendedEntityProperties;

public class MarkData implements IExtendedEntityProperties {

public static final String EXT_PLAYER136 = "ModMark136Data";
private final EntityPlayer player;
public static boolean candothis;
public static int[] XP = new int[35];

public MarkData(EntityPlayer player){
	this.player = player;
	for (int i = 0; i < 35; i++){
		XP[i] = 0;	
	}
	System.out.println("Set Xps to 0!!");
}
public final static void register(EntityPlayer player)
{
player.registerExtendedProperties(MarkData.EXT_PLAYER136, new MarkData(player));
}

public final static MarkData get(EntityPlayer player)
{
	return (MarkData) player.getExtendedProperties(EXT_PLAYER136);

}
public boolean isServerSide() {
    return this.player instanceof EntityPlayerMP;
}

@Override
public void saveNBTData(NBTTagCompound compound) {
	NBTTagCompound Array = new NBTTagCompound();

	Array.setIntArray("Skill136", this.getXp());

	compound.setTag(EXT_PLAYER136 , Array);

}

@Override
public void loadNBTData(NBTTagCompound compound) {
	NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PLAYER136);

		if (compound.hasKey("Skill136", 11)){
		this.setXP(properties.getIntArray("Skill136"));
		System.out.println("Loading Xp Levels");

	}
}

@Override
public void init(Entity entity, World world) {

}


public void setXP(int[] Xp){

	XP = Xp;
}

public int addXp(int SkillID, int amount){
	Skill.Lvlcalc(player);
	Skill.getSkillName();
	if((XP[skillID] + amount) >= Skill.NextLevel[skillID] && XP[skillID] < Skill.NextLevel[skillID]){
	ChatComponentText component = new ChatComponentText("Congratulations! Your Level in " + Skill.SkillName[skillID] + " is now " + (Skill.Level[skillID]+ 1));
	player.addChatComponentMessage(component);
	}
	//ChatComponentText component2 = new ChatComponentText(Skill.SkillName[skillID] + " XP: " + (XP[skillID] + amount));
	//player.addChatComponentMessage(component2);
	return XP[skillID] += amount;


}

public void requireLvl(int SkillID, int reqlvl){
	Skill.getSkillName();
	candothis = Skill.Level[skillID] >= reqlvl;
	if(candothis == false){
		ChatComponentText component = new ChatComponentText("You need " + reqlvl + " " + Skill.SkillName[skillID] + " for this");
		player.addChatComponentMessage(component);
	}


}

public int[] getXp() {

for (int i = 0;i < 35; i++){
	if ((XP[i]) > 500000 && Skill.MainLock == 1){
		XP[i] = 500000;

	}
	else if ((XP[i]) > 85000000 && Skill.MainLock == 2){

		XP[i] = 85000000;
	}
	else if ((XP[i]) > 2000000000 && Skill.MainLock == 3){

		XP[i] = 2000000000;
	}

}
return XP;
}

public void sync() {
    if (this.isServerSide()){
        MainRegistry.network.sendTo(new SkillPacket(), (EntityPlayerMP) player);
    }
}
public void RequestingSync() {
    if (!this.isServerSide())
    	MainRegistry.network.sendToServer(new SkillPacket());
}

public void saveReviveRelevantNBTData(NBTTagCompound compound, boolean wasDeath) {

        this.saveNBTData(compound);
}
}

And the Packet+PacketHandler class,(i did the IMessageHandler class as an inner class of IMessage, to make it more "organisable"

package com.modMark.Packets;

import com.modMark.Main.GuiStatlist;
import com.modMark.Skill.MarkData;
import com.modMark.Skill.Skill;

import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IThreadListener;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;

public class SkillPacket implements IMessage{

private int ID;
private int[] XP = new int[35];

public SkillPacket() {}
public SkillPacket(EntityPlayer E,int[] s ){
	this.ID = E.getEntityId();
	this.XP = s;

}


@Override
public void fromBytes(ByteBuf buf) {
	for (int k = 0; k < 35; k++){
		this.XP[k] = buf.readInt();
	}
		this.ID = buf.readInt();
}

@Override
public void toBytes(ByteBuf buf) {
	for (int j = 0; j < 35; j++){
		buf.writeInt(this.XP[j]);
		}
		buf.writeInt(this.ID);
}


//-----------------------------------------------------------------------------------------------

public static class MarkHandler implements IMessageHandler<SkillPacket, IMessage > {

@Override
public IMessage onMessage(SkillPacket message, MessageContext ctx) {
	IThreadListener ThreadListener = Minecraft.getMinecraft();
			ThreadListener.addScheduledTask(new Runnable() {
				@Override
                public void run() {
					for (int i = 0; i < 35; i++){

					//still need something to get my message here.


					}
					//ChatComponentText component2 = new ChatComponentText(player.getName() + " Excavation "  + " XP: " + p.XP[10]);
					//player.addChatComponentMessage(component2);
                    
                }
			});
	return null;
}

}
}

 

my Mod: Extended RPG [W.I.P]

Posted

srry then, i tried as much to change as many static field/method to non-statics

finally, he saves my stats(or something like that). but got a little problem if i play my mod with more people.

i check some events (breakEvent/ItemCraftedEvent/ItemSmeltedEvent) to get XP. but if a player is influent by an event. I always get XP and the other player gets XP only if he craft/smelt/break something or event don't get xp at all.

 

so whats the problem?(also, i hope my files are better now :) )

EventHandlerMark (contains EventHandler)

package com.modMark.Skill;

import java.util.List;

import com.modMark.Item_Block.MarkBlocks;
import com.modMark.Main.MainRegistry;
import com.modMark.Packets.SkillPacket;

import akka.actor.FSM.State;
import ibxm.Player;
import net.minecraft.block.Block;
import net.minecraft.block.BlockCrops;
import net.minecraft.block.BlockStone;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.EntityEvent.EntityConstructing;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
import net.minecraftforge.event.entity.player.PlayerUseItemEvent;
import net.minecraftforge.event.terraingen.SaplingGrowTreeEvent;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.event.world.BlockEvent.BreakEvent;
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemSmeltedEvent;
import scala.reflect.internal.Trees.ThisSubstituter;



public class EventHandlerMark {







@SubscribeEvent
public void onEntityConstructing(EntityConstructing event)
{		
	if (event.entity instanceof EntityPlayer && MarkData.get((EntityPlayer) event.entity) == null){	
		MarkData.register((EntityPlayer) event.entity);
		System.out.println("Registering Player!");
	}
    else if(event.entity instanceof EntityPlayer && MarkData.get((EntityPlayer) event.entity) != null){
    	NBTTagCompound compound = new NBTTagCompound();
    	MarkData.get((EntityPlayer)event.entity).loadNBTData(compound);
    } else{}


}




@SubscribeEvent
public void onEntityJoinWorld(EntityJoinWorldEvent event) {
	if (event.entity instanceof EntityPlayer) {
        MarkData.get((EntityPlayer) event.entity).RequestingSync();
        System.out.println("PlayerData is from onEntityJoinWorld");
    } 
    
    
}



@SubscribeEvent
public void onPlayerCloned(PlayerEvent.Clone event) {
    NBTTagCompound compound = new NBTTagCompound();
    MarkData.get(event.original).saveReviveRelevantNBTData(compound, event.wasDeath);
    MarkData.get(event.entityPlayer).loadNBTData(compound);
    System.out.println("PlayerData is Cloned");
}
@SubscribeEvent
public void Farming(SaplingGrowTreeEvent event)
{
	//problem: need to put what player placed the block

}




@SubscribeEvent
public void MinExcaWCFarm_Req(BreakSpeed event)
{
	//Event for req level Mining, Excavation, Woodcutting & Farming
	EntityPlayer player = event.entityPlayer;
	MarkData p = MarkData.get(player);
	System.out.println("PlayerData is from BreakSpeedEvent");
	Block block = event.state.getBlock();
	if (block == Blocks.stone || block == Blocks.cobblestone){
		p.requireLvl(8, 0, 0);
		}


	else if (block == Blocks.wheat){
		p.requireLvl(7, 0, 0);
		}
	else if (block == Blocks.carrots){
		p.requireLvl(7, 5, 0);
		}
	else if (block == Blocks.potatoes){
		p.requireLvl(7, 10, 0);
		}



	else if (block == Blocks.coal_ore){
		p.requireLvl(8, 5, 0);
		}
	else if (block == Blocks.emerald_ore){
		p.requireLvl(8, 10, 0);
		}
	else if (block == Blocks.iron_ore){
		p.requireLvl(8, 20, 0);
		}
	else if (block == Blocks.lapis_ore){
		p.requireLvl(8, 25, 0);
		}
	else if (block == Blocks.gold_ore){
		p.requireLvl(8, 30, 0);
		}
	else if (block == Blocks.diamond_ore){
		p.requireLvl(8, 40, 0);
		}
	else if (block == Blocks.redstone_ore || block == Blocks.lit_redstone_ore ||block == Blocks.redstone_block || block == Blocks.obsidian ){
		p.requireLvl(8, 45, 0);
		}
	else if (block == Blocks.netherrack ||block == Blocks.nether_brick ){
		p.requireLvl(8, 50, 0);
		}
	else if (block == MarkBlocks.OreNetherite){
		p.requireLvl(8, 60, 0);
		}
	else if (block == Blocks.quartz_ore || block == Blocks.quartz_block){
		p.requireLvl(8, 70, 0);
		}
	else if (block == MarkBlocks.CrystRack){
		p.requireLvl(8, 75, 0);
		}
	else if (block == MarkBlocks.OreCrystlium){
		p.requireLvl(8, 80, 0);
		}



	//excavation
	else if (block == Blocks.dirt || block == Blocks.grass){
		p.requireLvl(10, 0, 0);
		}
	else if (block == MarkBlocks.GemOpalOre){
		p.requireLvl(10, 5, 0);
		}
	else if (block == Blocks.gravel){
		p.requireLvl(10, 5, 0);
		}
	else if (block == MarkBlocks.GemSapphireOre){
		p.requireLvl(10, 10, 0);
		}
	else if (block == Blocks.sand){
		p.requireLvl(10, 10, 0);
		}
	else if (block == MarkBlocks.GemOlivineOre){
		p.requireLvl(10, 15, 0);
		}
	else if (block == MarkBlocks.GemHyacinthOre){
		p.requireLvl(10, 15, 0);
		}
	else if (block == MarkBlocks.GemTopazOre){
		p.requireLvl(10, 25, 0);
		}
	else if (block == Blocks.mycelium){
		p.requireLvl(10, 30, 0);
		}
	else if (block == MarkBlocks.GemAmethystOre){
		p.requireLvl(10, 40, 0);
		}
	else if (block == Blocks.soul_sand){
		p.requireLvl(10, 50, 0);
		}
	else if (block == MarkBlocks.GemSiamOre){
		p.requireLvl(10, 60, 0);
		}
	else if (block == MarkBlocks.CrystSand){
		p.requireLvl(10, 75, 0);
		}
	else if (block == MarkBlocks.GemAquamarineOre){
		p.requireLvl(10, 80, 0);
		}


	else if (block == Blocks.log){
		p.requireLvl(11, 0, 0);
		}
	else if (block == Blocks.cactus){
		p.requireLvl(11, 10, 0);
		}
	else if (block == Blocks.log2){
		p.requireLvl(11, 20, 0);
		}
	else if (block == MarkBlocks.LogYew){
		p.requireLvl(11, 40, 0);
		}
	else if (block == MarkBlocks.LogNetherBranch){
		p.requireLvl(11, 60, 0);
		}
	else if (block == MarkBlocks.LogCrystWood){
		p.requireLvl(11, 80, 0);
		}

	if (MarkData.candothis == false){
	event.setCanceled(true);
	}	
}



@SubscribeEvent
public void MinExcaWC_XP(BreakEvent event){


	MarkData p = MarkData.get(event.getPlayer());


	System.out.println("PlayerData is from BreakEvent");
	Block block = event.state.getBlock();



	if (block == Blocks.stone || block == Blocks.cobblestone){	
		p.addXp(8, ;
		}



	else if (block == Blocks.wheat && (((Integer)event.state.getValue(BlockCrops.AGE)).intValue() == 7)){
		p.addXp(7, 5);
	}
	else if (block == Blocks.carrots && (((Integer)event.state.getValue(BlockCrops.AGE)).intValue() == 7)){
		p.addXp(7, 7);
	}
	else if (block == Blocks.potatoes && (((Integer)event.state.getValue(BlockCrops.AGE)).intValue() == 7)){
		p.addXp(7, 9);
	}

	//mining
	else if (block == Blocks.coal_ore){
		p.addXp(8, 12);
		}
	else if (block == Blocks.emerald_ore){
		p.addXp(8, 16);
		}
	else if (block == Blocks.iron_ore){
		p.addXp(8, 20);
		}
	else if (block == Blocks.lapis_ore){
		p.addXp(8, 24);
		}
	else if (block == Blocks.gold_ore){
		p.addXp(8, 28);
		}
	else if (block == Blocks.diamond_ore){
		p.addXp(8, 32);
		}
	else if (block == Blocks.redstone_ore){
		p.addXp(8, 33);
		}
	else if (block == Blocks.obsidian){
		p.addXp(8, 34);
		}
	else if (block == Blocks.netherrack || block == Blocks.nether_brick){
		p.addXp(8, 35);
		}
	else if (block == MarkBlocks.OreNetherite){
		p.addXp(8, 40);
		}
	else if (block == Blocks.quartz_ore){
		p.addXp(8, 42);
		}
	else if (block == MarkBlocks.CrystRack){
		p.addXp(8, 45);
		}
	else if (block == MarkBlocks.OreCrystlium){
		p.addXp(8, 50);
		}




	else if (block == Blocks.dirt || block == Blocks.grass){
		p.addXp(10, 5);
		}
	else if (block == MarkBlocks.GemOpalOre){
		p.addXp(10, ;
		}
	else if (block == Blocks.gravel){
		p.addXp(10, 7);
		}
	else if (block == MarkBlocks.GemSapphireOre){
		p.addXp(10, 12);
		}
	else if (block == Blocks.sand){
		p.addXp(10, 9);
		}
	else if (block == MarkBlocks.GemOlivineOre){
		p.addXp(10, 16);
		}
	else if (block == MarkBlocks.GemHyacinthOre){
		p.addXp(10, 20);
		}
	else if (block == MarkBlocks.GemTopazOre){
		p.addXp(10, 24);
		}
	else if (block == Blocks.mycelium){
		p.addXp(10, 28);
		}
	else if (block == MarkBlocks.GemAmethystOre){
		p.addXp(10, 32);
		}
	else if (block == Blocks.soul_sand){
		p.addXp(10, 35);
		}
	else if (block == MarkBlocks.GemSiamOre){
		p.addXp(10, 40);
		}
	else if (block == MarkBlocks.CrystSand){
		p.addXp(10, 45);
		}
	else if (block == MarkBlocks.GemAquamarineOre){
		p.addXp(10, 50);
		}


	else if (block == Blocks.log){
		p.addXp(11, 10);
		}
	else if (block == Blocks.cactus){
		p.addXp(11, 12);
		}
	else if (block == Blocks.log2){
		p.addXp(11, 18);
		}
	else if (block == MarkBlocks.LogYew){
		p.addXp(11, 30);

		}
	else if (block == MarkBlocks.LogNetherBranch){
		p.addXp(11, 45);

		}
	else if (block == MarkBlocks.LogCrystWood){
		p.addXp(11, 60);
		}



		p.sync();
		p.getXp();



	}

@SubscribeEvent
public void PlayerInteractEvent(PlayerInteractEvent event){


	if(event.action == Action.LEFT_CLICK_BLOCK && event.face != null && event.pos != null && event.useBlock != null && event.useItem != null){
		EntityPlayer player =  event.entityPlayer;
		if(player.getCurrentEquippedItem() != null){
		Item item = player.getCurrentEquippedItem().getItem();
		MarkData p = MarkData.get(event.entityPlayer);


	//Stone

	if(item == Items.stone_hoe){ p.requireLvl(7, 10, 1); }
	else if(item == Items.stone_pickaxe){ p.requireLvl(8, 10, 1); }
	else if(item == Items.stone_shovel){ p.requireLvl(10, 10, 1); }
	else if(item == Items.stone_axe){ p.requireLvl(11, 10, 1); }
	//Iron
	else if(item == Items.iron_hoe){ p.requireLvl(7, 20, 1); }
	else if(item == Items.iron_pickaxe){ p.requireLvl(8, 20, 1); }
	else if(item == Items.iron_shovel){ p.requireLvl(10, 20, 1); }
	else if(item == Items.iron_axe){ p.requireLvl(11, 20, 1); }
	//Gold
	else if(item == Items.golden_hoe){ p.requireLvl(7, 30, 1); }
	else if(item == Items.golden_pickaxe){ p.requireLvl(8, 30, 1); }
	else if(item == Items.golden_shovel){ p.requireLvl(10, 30, 1); }
	else if(item == Items.golden_axe){ p.requireLvl(11, 30, 1); }
	//Diamond
	else if(item == Items.diamond_hoe){ p.requireLvl(7, 40, 1); }
	else if(item == Items.diamond_pickaxe){ p.requireLvl(8, 40, 1); }
	else if(item == Items.diamond_shovel){ p.requireLvl(10, 40, 1); }
	else if(item == Items.diamond_axe){ p.requireLvl(11, 40, 1); }
	else{p.requireLvl(10, 0, 1);}

	if (MarkData.candothisTool == false & event.action == Action.LEFT_CLICK_BLOCK){
		event.setCanceled(true);
	}
	else{}
	}
	else{}}else{}
}


@SubscribeEvent
public void ItemCraftedEvent(ItemCraftedEvent event){
	Item item = event.crafting.getItem();


	MarkData p = MarkData.get(event.player);
	if (p != null){

	//Tailory
	if(item == Item.getItemFromBlock(Blocks.wool)){ p.addXp(14, 5);}

	//Smithing
	if(item == Items.wooden_sword){ p.addXp(15, 3);}
	else if(item == Items.wooden_hoe){ p.addXp(15, 3);}
	else if(item == Items.wooden_shovel){ p.addXp(15, 3);}
	else if(item == Items.wooden_pickaxe){ p.addXp(15, 3);}
	else if(item == Items.wooden_axe){ p.addXp(15, 3);}

	else if(item == Items.stone_sword){ p.addXp(15, 9);}
	else if(item == Items.stone_hoe){ p.addXp(15, 9);}
	else if(item == Items.stone_shovel){ p.addXp(15, 6);}
	else if(item == Items.stone_pickaxe){ p.addXp(15, 12);}
	else if(item == Items.stone_axe){ p.addXp(15, 12);}

	else if(item == Items.iron_sword){ p.addXp(15, 19);}
	else if(item == Items.iron_hoe){ p.addXp(15, 19);}
	else if(item == Items.iron_shovel){ p.addXp(15, 11);}
	else if(item == Items.iron_pickaxe){ p.addXp(15, 27);}
	else if(item == Items.iron_axe){ p.addXp(15, 27);}

	else if(item == Items.golden_sword){ p.addXp(15, 25);}
	else if(item == Items.golden_hoe){ p.addXp(15, 25);}
	else if(item == Items.golden_shovel){ p.addXp(15, 14);}
	else if(item == Items.golden_pickaxe){ p.addXp(15, 36);}
	else if(item == Items.golden_axe){ p.addXp(15, 36);}

	else if(item == Items.diamond_sword){ p.addXp(15, 27);}
	else if(item == Items.diamond_hoe){ p.addXp(15, 27);}
	else if(item == Items.diamond_shovel){ p.addXp(15, 15);}
	else if(item == Items.diamond_pickaxe){ p.addXp(15, 39);}
	else if(item == Items.diamond_axe){ p.addXp(15, 39);}

	//Tanning
	else if(item == Items.leather){ p.addXp(16, 10);}
	else if(item == Items.leather_boots){ p.addXp(16, 16);}
	else if(item == Items.leather_helmet){ p.addXp(16, 20);}
	else if(item == Items.leather_leggings){ p.addXp(16, 28);}
	else if(item == Items.leather_chestplate){ p.addXp(16, 32);}
	//Jewelry
	//--
	//Fletching
	else if(item == Items.stick){ p.addXp(18, 4);}
	//Construction
	else if(item == Item.getItemFromBlock(Blocks.planks))
	{ p.addXp(22, 5);}
	else if(item == Item.getItemFromBlock(Blocks.bed)){ p.addXp(22, 30);}
	else if(item == Item.getItemFromBlock(Blocks.oak_door)||item == Item.getItemFromBlock(Blocks.spruce_door)||item == Item.getItemFromBlock(Blocks.birch_door)||item == Item.getItemFromBlock(Blocks.jungle_door))
	{ p.addXp(22, 30);}	
	else if(item == Item.getItemFromBlock(Blocks.oak_stairs)||item == Item.getItemFromBlock(Blocks.spruce_stairs)||item == Item.getItemFromBlock(Blocks.birch_stairs)||item == Item.getItemFromBlock(Blocks.jungle_stairs))
	{ p.addXp(22, 30);}	

	p.sync();
	p.getXp();
	}
}

@SubscribeEvent
public void ItemSmeltedEvent(ItemSmeltedEvent event){
	Item item = event.smelting.getItem();

	EntityPlayer player = event.player;
	MarkData p = MarkData.get(player);
	if (p != null){

	//smithing
	if(item == Item.getItemFromBlock(Blocks.stone)){ p.addXp(15, (3 * event.smelting.stackSize));}
	else if(item == Items.iron_ingot){ p.addXp(15, (8 * event.smelting.stackSize));}
	else if(item == Items.gold_ingot){ p.addXp(15, (11 * event.smelting.stackSize));}
	//juwelry
	else if(item == Item.getItemFromBlock(Blocks.glass)){ p.addXp(17, (4 * event.smelting.stackSize));}
	//cooking
	else if(item == Items.cooked_porkchop || item == Items.cooked_beef || item == Items.cooked_chicken|| item == Items.cooked_fish || item == Items.cooked_rabbit){ p.addXp(19, (4 * event.smelting.stackSize));}

		p.sync();
		p.getXp();
		}
}
}

MarkData  (contains IExtendedEntityProperties

package com.modMark.Skill;

import com.modMark.Main.MainRegistry;
import com.modMark.Packets.SkillPacket;

import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagIntArray;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
import net.minecraftforge.common.IExtendedEntityProperties;

public class MarkData implements IExtendedEntityProperties {

public int MainLock = 1;

public EntityPlayer Player;
public int XpLock1 = 0;
public int XpLock2 = 0;
public int XpLock3 = 0;
public int XpLock4 = 0;
public int XpLock5 = 0;
public int XpLock6 = 0;
public int XpLock7 = 0;


public String[] SkillName = new String[35]; //head
 //head
public double[] Level1 = new double[35];
public int[] Level = new int[35]; //head
public double[] NextLevel0 = new double[35];
public double[] NextLevel1 = new double[35];
public int[] NextLevel = new int[35]; //head
public int[] XpNeed = new int[35]; //head
public double[] Degrees1 = new double[35];
public double[] Degrees = new double[35]; //head

public int Total;
public int Totalcb;
public int Totalga;
public int Totalar;
public int Totalsp;
public int Totalot;
public double Combat1;
public int Combat;


public static final String EXT_PLAYER136 = "ModMark136Data";
private final EntityPlayer player;
public static boolean candothis;
public static boolean candothisTool;
public static int[] XP = new int[35];

public MarkData(EntityPlayer player){
	this.player = player;

	for (int i = 0; i < 35; i++){
	if (this.XP[i] == 0){
		XP[i] = 0;	
	}

}
}
public static void register(EntityPlayer player)
{
player.registerExtendedProperties(MarkData.EXT_PLAYER136, new MarkData(player));
System.out.println("register Player");
}

public static MarkData get(EntityPlayer player)
{

	return (MarkData) player.getExtendedProperties(EXT_PLAYER136);


}
public boolean isServerSide() {
    return player instanceof EntityPlayerMP;
}

@Override
public void saveNBTData(NBTTagCompound compound) {
	NBTTagCompound Array = new NBTTagCompound();

	Array.setIntArray("Skill136", this.getXp());

	compound.setTag(EXT_PLAYER136 , Array);
	System.out.println("Saving Xp Levels for " + player.getName() + " ," + Array);
}

@Override
public void loadNBTData(NBTTagCompound compound) {
	NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PLAYER136);


		this.setXP(properties.getIntArray("Skill136"));
		System.out.println("Loading Xp Levels");




}
@Override
public void init(Entity entity, World world) {

}

public static void resetXP(){
	for (int i = 0; i < 35; i++)
	XP[i] = 0;
}

public void setXP(int[] Xp){

	this.XP = Xp;
}

public int addXp(int SkillID, int amount){



	this.Lvlcalc(player);
	this.setSkillName();
	if((XP[skillID] + amount) >= this.NextLevel[skillID] && XP[skillID] < this.NextLevel[skillID]){
	ChatComponentText component = new ChatComponentText("Congratulations! Your Level in " + this.SkillName[skillID] + " is now " + (this.Level[skillID]+ 1));
	player.addChatComponentMessage(component);
	}

	return this.XP[skillID] += amount;


}

//this is to check if the requirement level is high enough to do the action. 
//	SkillID = the ID of the skill.
//	reqlvl = the requirement level to do the action
//	method = the text that will apear
public void requireLvl(int SkillID, int reqlvl, int method){
	this.getSkillName();
	this.Lvlcalc(Player);

		if (method == 0){
			candothis = this.Level[skillID] >= reqlvl;
			if(candothis == false){
		ChatComponentText component = new ChatComponentText("You need " + reqlvl + " " + this.SkillName[skillID] + " for this");
		player.addChatComponentMessage(component);
		}}

		if (method == 1){
		candothisTool = this.Level[skillID] >= reqlvl;
		if(candothisTool == false){
		ChatComponentText component = new ChatComponentText("You need a level of " + reqlvl + " " + this.SkillName[skillID] + " to use this tool");
		player.addChatComponentMessage(component);
		}}
		else {}




}

public int[] getXp() {

for (int i = 0;i < 35; i++){
	if ((this.XP[i]) > 500000 && this.MainLock == 1){
		this.XP[i] = 500000;

	}
	else if ((this.XP[i]) > 85000000 && this.MainLock == 2){

		this.XP[i] = 85000000;
	}
	else if ((this.XP[i]) > 2000000000 && this.MainLock == 3){

		this.XP[i] = 2000000000;
	}

}
return this.XP;
}

public void sync() {
    if (this.isServerSide()){
    	
        MainRegistry.network.sendTo(new SkillPacket(), (EntityPlayerMP) player);
    }
}
public void RequestingSync() {
    if (!this.isServerSide())
    	MainRegistry.network.sendToServer(new SkillPacket());
}

public void saveReviveRelevantNBTData(NBTTagCompound compound, boolean wasDeath) {

        this.saveNBTData(compound);
}


public void setSkillName(){

	 this.SkillName[0] = "Constitution";
	 this.SkillName[1] = "Melee";
	 this.SkillName[2] = "Ranged";
	 this.SkillName[3] = "Magic";
	 this.SkillName[4] = "Defence";
	 this.SkillName[5] = "Endurance";
	 this.SkillName[6] = "Slayer";
	 this.SkillName[7] = "Farming";
	 this.SkillName[8] = "Mining";
	 this.SkillName[9] = "Hunter";
	 this.SkillName[10] = "Excavation";
	 this.SkillName[11] = "Woodcutting";
	 this.SkillName[12] = "Fishing";
	 this.SkillName[13] = "Archeology";
	 this.SkillName[14] = "Tailory";
	 this.SkillName[15] = "Smithing";
	 this.SkillName[16] = "Tanning";
	 this.SkillName[17] = "Jewelry";
	 this.SkillName[18] = "Fletching";
	 this.SkillName[19] = "Cooking";
	 this.SkillName[20] = "Herblore";
	 this.SkillName[21] = "Honour";
	 this.SkillName[22] = "Construction";
	 this.SkillName[23] = "Agility";
	 this.SkillName[24] = "Dungeoneering";
	 this.SkillName[25] = "Firemaking";
	 this.SkillName[26] = "Lifestock";
	 this.SkillName[27] = "Knowledge";
	 this.SkillName[28] = "Technology";
	 this.SkillName[29] = "Petting";
	 this.SkillName[30] = "Chemistry";
	 this.SkillName[31] = "Specility";
	 this.SkillName[32] = "Mutating";
	 this.SkillName[33] = "Fisioning";
	 this.SkillName[34] = "Fusioning";
	  
	}

public String getSkillName() {

	return "skill";
}

 public void Lvlcalc(EntityPlayer player) {
	Player = player;


for (int i = 0; i < 35;i++) {

 if (this.getXp()[i] == 2000000000){
	 this.Level1[i] = 255;
	}
	else if (this.getXp()[i] >= 1720000000 && this.getXp()[i] <= 1999999999){
		this.Level1[i] = 254;
		}
	else if (this.getXp()[i] >= 1480000000 && this.getXp()[i] <= 1719999999){
		this.Level1[i] = 253;
	}
	else if (this.getXp()[i] >= 1280000000 && this.getXp()[i] <= 1479999999){
		this.Level1[i] = 252;
	}
	else if (this.getXp()[i] >= 1120000000 && this.getXp()[i] <= 1279999999){
		this.Level1[i] = 251;
	}
	else if (this.getXp()[i] >= 1000000000 && this.getXp()[i] <= 1119999999){
		this.Level1[i] = 250;
	}

	else if (this.getXp()[i] >= 954238196 && this.getXp()[i] <= 999999999){
		this.Level1[i] = 249;
	}

	else if (this.getXp()[i] >= 100005814 && this.getXp()[i] <= 954238195){
		this.Level1[i] = ((Math.log(this.getXp()[i] + 8287)/Math.log(8287))-1)*192+1;
	}

	else if (this.getXp()[i] >= 70404413 && this.getXp()[i] <= 100005813){
		this.Level1[i] = 200;
	}

	else if (this.getXp()[i] >= 701754 && this.getXp()[i] <= 70404412){
		this.Level1[i] = ((Math.log10(this.getXp()[i] + 7480)/Math.log10(7480))-1)*194+1;
	}
	else if (this.getXp()[i] >= 409286 && this.getXp()[i] <= 701753){
		this.Level1[i] = 99;
	}
	else if (this.getXp()[i] <= 409285){
		this.Level1[i] = ((Math.log10(this.getXp()[i] + 522)/Math.log10(522))-1)*92+1;
	}
	else {
		this.Level1[i] = 0;
	}

 	this.Level[i] = (int) Math.floor(this.Level1[i]); /** floors this.Level down*/
	this.NextLevel0[i] = (int) (this.Level[i] + 1);  /** says Level + 1*/
	this.NextLevel[i] = (int) Math.ceil(this.NextLevel1[i]);
	this.XpNeed[i] = (int) (this.NextLevel[i] - this.getXp()[i]);

	if (this.Level[i] == 99 || this.Level[i] == 200 || this.Level[i] == 255) 
		{ this.Degrees[i] = 0; }
	else {
	this.Degrees[i] = ((this.getXp()[i] - Math.ceil(this.Degrees1[i])) / (this.NextLevel[i] - Math.ceil(this.Degrees1[i]))) * 39;
    }


	if (this.Level[i] < 99) {
		this.NextLevel1[i] = (Math.pow(522, (this.NextLevel0[i] - 1)/92 +1) - 522);
	}
	else if (this.Level[i] == 99) {
		this.NextLevel1[i] = 701754;
	}
	else if (this.Level[i] >= 100 && this.Level[i] < 200) {
		this.NextLevel1[i] = (Math.pow(7480, (this.NextLevel0[i] - 1)/194 +1) - 7480);
	}
	else if (this.Level[i] == 200) {
		this.NextLevel1[i] = 100005814;
	}
	else if (this.Level[i] >= 201 && this.Level[i] < 249) {
		this.NextLevel1[i] = (Math.pow(8287, (this.NextLevel0[i] - 1)/192 +1) - 8287);
	}
	else if (this.Level[i] == 249) {
		this.NextLevel1[i] = 1000000000;
	}
	else if (this.Level[i] == 250) {
		this.NextLevel1[i] = 1120000000;
	}
	else if (this.Level[i] == 251) {
		this.NextLevel1[i] = 1280000000;
	}
	else if (this.Level[i] == 252) {
		this.NextLevel1[i] = 1480000000;
	}
	else if (this.Level[i] == 253) {
		this.NextLevel1[i] = 1720000000;
	}
	else if (this.Level[i] == 254) {
		this.NextLevel1[i] = 2000000000;		
	}
	else {
		this.NextLevel1[i] = 0;
	}



	if (this.Level[i] <= 98) {
		this.Degrees1[i] = (Math.pow(522, (this.NextLevel0[i] - 2)/92 +1) - 522) ;
	}

	else if (this.Level[i] >= 100 && this.Level[i] <= 199) {
		this.Degrees1[i] = (Math.pow(7480, (this.NextLevel0[i] - 2)/194 +1) - 7480);
	}
	else if (this.Level[i] >= 201 && this.Level[i] <= 249) {
		this.Degrees1[i] = (Math.pow(8287, (this.NextLevel0[i] - 2)/192 +1) - 8287);
	}
	else if (this.Level[i] == 250) {
		this.Degrees1[i] = 1000000000;
	}
	else if (this.Level[i] == 251) {
		this.Degrees1[i] = 1120000000;
	}
	else if (this.Level[i] == 252) {
		this.Degrees1[i] = 1280000000;
	}
	else if (this.Level[i] == 253) {
		this.Degrees1[i] = 1480000000;
	}
	else if (this.Level[i] == 254) {
		this.Degrees1[i] = 1720000000;
	}

	else {
		this.Degrees1[i] = 0;
		}
	}
 }
 public void getCombatLvl(EntityPlayer player){
	 Player = player;
	 Lvlcalc(Player);
if(this.Level[1] >= this.Level[2] && this.Level[1] >= this.Level[3]){

	Combat1 = (Math.sqrt(this.Level[0]) * Math.sqrt(this.Level[5]) + this.Level[1] + this.Level[4]) / 765*350;
}
else if(this.Level[2] >= this.Level[3]){

	Combat1 = (Math.sqrt(this.Level[0]) * Math.sqrt(this.Level[5]) + this.Level[2] + this.Level[4]) / 765*350;
}
else
{
	Combat1 = (Math.sqrt(this.Level[0]) * Math.sqrt(this.Level[5]) + this.Level[3] + this.Level[4]) / 765*350;
}

Combat = (int) Math.floor(Combat1);
 }
 public void getTotalLvl(EntityPlayer player) {
	 Player = player;
	 Lvlcalc(Player);
Totalcb = this.Level[0] + this.Level[1] + this.Level[2] + this.Level[3] + this.Level[4] + this.Level[5] + this.Level[6];
Totalga = this.Level[7] + this.Level[8] + this.Level[9] + this.Level[10] + this.Level[11] + this.Level[12] + this.Level[13];
Totalar = this.Level[14] + this.Level[15] + this.Level[16] + this.Level[17] + this.Level[18] + this.Level[19] + this.Level[20];
Totalsp = this.Level[21] + this.Level[22] + this.Level[23] + this.Level[24] + this.Level[25] + this.Level[26] + this.Level[27];
Totalot = this.Level[28] + this.Level[29] + this.Level[30] + this.Level[31] + this.Level[32] + this.Level[33] + this.Level[34];

Total = Totalcb + Totalga + Totalar + Totalsp + Totalot;

}	
}

SkillPacket (contains IMessage and IMessageHandler)

package com.modMark.Packets;

import com.modMark.Main.GuiStatlist;
import com.modMark.Skill.MarkData;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IThreadListener;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;

public class SkillPacket implements IMessage{

private int ID;
private int[] XP = new int[35];

public SkillPacket() {}
public SkillPacket(EntityPlayer E, int[] s ){
	this.ID = E.getEntityId();
	this.XP = s;

}


@Override
public void fromBytes(ByteBuf buf) {
	for (int k = 0; k < 35; k++){
		this.XP[k] = buf.readInt();
	}
		this.ID = buf.readInt();
}

@Override
public void toBytes(ByteBuf buf) {
	for (int j = 0; j < 35; j++){
		buf.writeInt(this.XP[j]);
		}
		buf.writeInt(this.ID);
}


//-----------------------------------------------------------------------------------------------

public static class MarkHandler implements IMessageHandler<SkillPacket, IMessage > {

@Override
public IMessage onMessage(final SkillPacket message, MessageContext ctx) {
	IThreadListener ThreadListener = Minecraft.getMinecraft();
			ThreadListener.addScheduledTask(new Runnable() {
				@Override
                public void run() {


					for (int i = 0; i < 35; i++){
						EntityPlayer player = Minecraft.getMinecraft().thePlayer;
					MarkData p = MarkData.get(player);

					 message.XP = p.getXp();


					}
					System.out.println("PlayerData is from the PacketHandler");
                    
                }
			});
	return null;
}

}
}

my Mod: Extended RPG [W.I.P]

Posted

Why is

candothis

still static?  It is the property you use to determine if the player being operated on can mine the block or not, yet this is still a shared value.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Why is

candothis

still static?  It is the property you use to determine if the player being operated on can mine the block or not, yet this is still a shared value.

oops forgot to remove that static, but changed it :)

  • The code in
    onEntityConstructing

    is a mess and unnecessary. All you need in there is

    MarkData.register

    . No if-checks, no loading from empty NBT.

  • You send the entityID in your packet, but you never use it.
  • In your message handler you put stuff into the message instead of taking stuff out. This makes no sense.
  • The code in your IEEP is a mess, what in the heck are all those fields?
  • Overall your code formatting is a mess. Your indentation is absolutely inconsistent and it's all barely readable.

you need an if statement for onEntityConstruction to check if the entity is a player, otherwise you got a crash report like "entityRabbit cannot be cast to EntityPlayer." but i have make my IEEP more clearer so you can read it

here are my files again:

 

EventHandler:

package com.modMark.Skill;

import java.util.List;

import com.modMark.Item_Block.MarkBlocks;
import com.modMark.Main.MainRegistry;
import com.modMark.Packets.SkillPacket;

import akka.actor.FSM.State;
import ibxm.Player;
import net.minecraft.block.Block;
import net.minecraft.block.BlockCrops;
import net.minecraft.block.BlockStone;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.EntityEvent.EntityConstructing;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
import net.minecraftforge.event.entity.player.PlayerUseItemEvent;
import net.minecraftforge.event.terraingen.SaplingGrowTreeEvent;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.event.world.BlockEvent.BreakEvent;
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemSmeltedEvent;
import scala.reflect.internal.Trees.ThisSubstituter;



public class EventHandlerMark {







@SubscribeEvent
public void onEntityConstructing(EntityConstructing event)
{		
	if (event.entity instanceof EntityPlayer && MarkData.get((EntityPlayer) event.entity) == null){	
		MarkData.register((EntityPlayer) event.entity);
		System.out.println("Registering Player!");
	}
}




@SubscribeEvent
public void onEntityJoinWorld(EntityJoinWorldEvent event) {
	if (event.entity instanceof EntityPlayer) {
        MarkData.get((EntityPlayer) event.entity).RequestingSync();
        System.out.println("PlayerData is from onEntityJoinWorld");
    } 
    
    
}



@SubscribeEvent
public void onPlayerCloned(PlayerEvent.Clone event) {
    NBTTagCompound compound = new NBTTagCompound();
    MarkData.get(event.original).saveReviveRelevantNBTData(compound, event.wasDeath);
    MarkData.get(event.entityPlayer).loadNBTData(compound);
    System.out.println("PlayerData is Cloned");
}
@SubscribeEvent
public void Farming(SaplingGrowTreeEvent event)
{
	//problem: need to put what player placed the block

}




@SubscribeEvent
public void MinExcaWCFarm_Req(BreakSpeed event)
{
	//Event for req level Mining, Excavation, Woodcutting & Farming
	EntityPlayer player = event.entityPlayer;
	MarkData p = MarkData.get(player);
	System.out.println("PlayerData is from BreakSpeedEvent");
	Block block = event.state.getBlock();
	if (block == Blocks.stone || block == Blocks.cobblestone){
		p.requireLvl(8, 0, 0);
		}


	else if (block == Blocks.wheat){
		p.requireLvl(7, 0, 0);
		}
	else if (block == Blocks.carrots){
		p.requireLvl(7, 5, 0);
		}
	else if (block == Blocks.potatoes){
		p.requireLvl(7, 10, 0);
		}



	else if (block == Blocks.coal_ore){
		p.requireLvl(8, 5, 0);
		}
	else if (block == Blocks.emerald_ore){
		p.requireLvl(8, 10, 0);
		}
	else if (block == Blocks.iron_ore){
		p.requireLvl(8, 20, 0);
		}
	else if (block == Blocks.lapis_ore){
		p.requireLvl(8, 25, 0);
		}
	else if (block == Blocks.gold_ore){
		p.requireLvl(8, 30, 0);
		}
	else if (block == Blocks.diamond_ore){
		p.requireLvl(8, 40, 0);
		}
	else if (block == Blocks.redstone_ore || block == Blocks.lit_redstone_ore ||block == Blocks.redstone_block || block == Blocks.obsidian ){
		p.requireLvl(8, 45, 0);
		}
	else if (block == Blocks.netherrack ||block == Blocks.nether_brick ){
		p.requireLvl(8, 50, 0);
		}
	else if (block == MarkBlocks.OreNetherite){
		p.requireLvl(8, 60, 0);
		}
	else if (block == Blocks.quartz_ore || block == Blocks.quartz_block){
		p.requireLvl(8, 70, 0);
		}
	else if (block == MarkBlocks.CrystRack){
		p.requireLvl(8, 75, 0);
		}
	else if (block == MarkBlocks.OreCrystlium){
		p.requireLvl(8, 80, 0);
		}



	//excavation
	else if (block == Blocks.dirt || block == Blocks.grass){
		p.requireLvl(10, 0, 0);
		}
	else if (block == MarkBlocks.GemOpalOre){
		p.requireLvl(10, 5, 0);
		}
	else if (block == Blocks.gravel){
		p.requireLvl(10, 5, 0);
		}
	else if (block == MarkBlocks.GemSapphireOre){
		p.requireLvl(10, 10, 0);
		}
	else if (block == Blocks.sand){
		p.requireLvl(10, 10, 0);
		}
	else if (block == MarkBlocks.GemOlivineOre){
		p.requireLvl(10, 15, 0);
		}
	else if (block == MarkBlocks.GemHyacinthOre){
		p.requireLvl(10, 15, 0);
		}
	else if (block == MarkBlocks.GemTopazOre){
		p.requireLvl(10, 25, 0);
		}
	else if (block == Blocks.mycelium){
		p.requireLvl(10, 30, 0);
		}
	else if (block == MarkBlocks.GemAmethystOre){
		p.requireLvl(10, 40, 0);
		}
	else if (block == Blocks.soul_sand){
		p.requireLvl(10, 50, 0);
		}
	else if (block == MarkBlocks.GemSiamOre){
		p.requireLvl(10, 60, 0);
		}
	else if (block == MarkBlocks.CrystSand){
		p.requireLvl(10, 75, 0);
		}
	else if (block == MarkBlocks.GemAquamarineOre){
		p.requireLvl(10, 80, 0);
		}


	else if (block == Blocks.log){
		p.requireLvl(11, 0, 0);
		}
	else if (block == Blocks.cactus){
		p.requireLvl(11, 10, 0);
		}
	else if (block == Blocks.log2){
		p.requireLvl(11, 20, 0);
		}
	else if (block == MarkBlocks.LogYew){
		p.requireLvl(11, 40, 0);
		}
	else if (block == MarkBlocks.LogNetherBranch){
		p.requireLvl(11, 60, 0);
		}
	else if (block == MarkBlocks.LogCrystWood){
		p.requireLvl(11, 80, 0);
		}

	if (p.candothis == false){
	event.setCanceled(true);
	}	
}



@SubscribeEvent
public void MinExcaWC_XP(BreakEvent event){


	MarkData p = MarkData.get(event.getPlayer());


	System.out.println("PlayerData is from BreakEvent");
	Block block = event.state.getBlock();



	if (block == Blocks.stone || block == Blocks.cobblestone){	
		p.addXp(8, ;
		}



	else if (block == Blocks.wheat && (((Integer)event.state.getValue(BlockCrops.AGE)).intValue() == 7)){
		p.addXp(7, 5);
	}
	else if (block == Blocks.carrots && (((Integer)event.state.getValue(BlockCrops.AGE)).intValue() == 7)){
		p.addXp(7, 7);
	}
	else if (block == Blocks.potatoes && (((Integer)event.state.getValue(BlockCrops.AGE)).intValue() == 7)){
		p.addXp(7, 9);
	}

	//mining
	else if (block == Blocks.coal_ore){
		p.addXp(8, 12);
		}
	else if (block == Blocks.emerald_ore){
		p.addXp(8, 16);
		}
	else if (block == Blocks.iron_ore){
		p.addXp(8, 20);
		}
	else if (block == Blocks.lapis_ore){
		p.addXp(8, 24);
		}
	else if (block == Blocks.gold_ore){
		p.addXp(8, 28);
		}
	else if (block == Blocks.diamond_ore){
		p.addXp(8, 32);
		}
	else if (block == Blocks.redstone_ore){
		p.addXp(8, 33);
		}
	else if (block == Blocks.obsidian){
		p.addXp(8, 34);
		}
	else if (block == Blocks.netherrack || block == Blocks.nether_brick){
		p.addXp(8, 35);
		}
	else if (block == MarkBlocks.OreNetherite){
		p.addXp(8, 40);
		}
	else if (block == Blocks.quartz_ore){
		p.addXp(8, 42);
		}
	else if (block == MarkBlocks.CrystRack){
		p.addXp(8, 45);
		}
	else if (block == MarkBlocks.OreCrystlium){
		p.addXp(8, 50);
		}




	else if (block == Blocks.dirt || block == Blocks.grass){
		p.addXp(10, 5);
		}
	else if (block == MarkBlocks.GemOpalOre){
		p.addXp(10, ;
		}
	else if (block == Blocks.gravel){
		p.addXp(10, 7);
		}
	else if (block == MarkBlocks.GemSapphireOre){
		p.addXp(10, 12);
		}
	else if (block == Blocks.sand){
		p.addXp(10, 9);
		}
	else if (block == MarkBlocks.GemOlivineOre){
		p.addXp(10, 16);
		}
	else if (block == MarkBlocks.GemHyacinthOre){
		p.addXp(10, 20);
		}
	else if (block == MarkBlocks.GemTopazOre){
		p.addXp(10, 24);
		}
	else if (block == Blocks.mycelium){
		p.addXp(10, 28);
		}
	else if (block == MarkBlocks.GemAmethystOre){
		p.addXp(10, 32);
		}
	else if (block == Blocks.soul_sand){
		p.addXp(10, 35);
		}
	else if (block == MarkBlocks.GemSiamOre){
		p.addXp(10, 40);
		}
	else if (block == MarkBlocks.CrystSand){
		p.addXp(10, 45);
		}
	else if (block == MarkBlocks.GemAquamarineOre){
		p.addXp(10, 50);
		}


	else if (block == Blocks.log){
		p.addXp(11, 10);
		}
	else if (block == Blocks.cactus){
		p.addXp(11, 12);
		}
	else if (block == Blocks.log2){
		p.addXp(11, 18);
		}
	else if (block == MarkBlocks.LogYew){
		p.addXp(11, 30);

		}
	else if (block == MarkBlocks.LogNetherBranch){
		p.addXp(11, 45);

		}
	else if (block == MarkBlocks.LogCrystWood){
		p.addXp(11, 60);
		}



		p.sync();
		p.getXp();



	}

@SubscribeEvent
public void PlayerInteractEvent(PlayerInteractEvent event){


	if(event.action == Action.LEFT_CLICK_BLOCK && event.face != null && event.pos != null && event.useBlock != null && event.useItem != null){
		EntityPlayer player =  event.entityPlayer;
		if(player.getCurrentEquippedItem() != null){
		Item item = player.getCurrentEquippedItem().getItem();
		MarkData p = MarkData.get(event.entityPlayer);


	//Stone

	if(item == Items.stone_hoe){ p.requireLvl(7, 10, 1); }
	else if(item == Items.stone_pickaxe){ p.requireLvl(8, 10, 1); }
	else if(item == Items.stone_shovel){ p.requireLvl(10, 10, 1); }
	else if(item == Items.stone_axe){ p.requireLvl(11, 10, 1); }
	//Iron
	else if(item == Items.iron_hoe){ p.requireLvl(7, 20, 1); }
	else if(item == Items.iron_pickaxe){ p.requireLvl(8, 20, 1); }
	else if(item == Items.iron_shovel){ p.requireLvl(10, 20, 1); }
	else if(item == Items.iron_axe){ p.requireLvl(11, 20, 1); }
	//Gold
	else if(item == Items.golden_hoe){ p.requireLvl(7, 30, 1); }
	else if(item == Items.golden_pickaxe){ p.requireLvl(8, 30, 1); }
	else if(item == Items.golden_shovel){ p.requireLvl(10, 30, 1); }
	else if(item == Items.golden_axe){ p.requireLvl(11, 30, 1); }
	//Diamond
	else if(item == Items.diamond_hoe){ p.requireLvl(7, 40, 1); }
	else if(item == Items.diamond_pickaxe){ p.requireLvl(8, 40, 1); }
	else if(item == Items.diamond_shovel){ p.requireLvl(10, 40, 1); }
	else if(item == Items.diamond_axe){ p.requireLvl(11, 40, 1); }
	else{p.requireLvl(10, 0, 1);}

	if (p.candothisTool == false & event.action == Action.LEFT_CLICK_BLOCK){
		event.setCanceled(true);
	}
	else{}
	}
	else{}}else{}
}


@SubscribeEvent
public void ItemCraftedEvent(ItemCraftedEvent event){
	Item item = event.crafting.getItem();


	MarkData p = MarkData.get(event.player);
	if (p != null){

	//Tailory
	if(item == Item.getItemFromBlock(Blocks.wool)){ p.addXp(14, 5);}

	//Smithing
	if(item == Items.wooden_sword){ p.addXp(15, 3);}
	else if(item == Items.wooden_hoe){ p.addXp(15, 3);}
	else if(item == Items.wooden_shovel){ p.addXp(15, 3);}
	else if(item == Items.wooden_pickaxe){ p.addXp(15, 3);}
	else if(item == Items.wooden_axe){ p.addXp(15, 3);}

	else if(item == Items.stone_sword){ p.addXp(15, 9);}
	else if(item == Items.stone_hoe){ p.addXp(15, 9);}
	else if(item == Items.stone_shovel){ p.addXp(15, 6);}
	else if(item == Items.stone_pickaxe){ p.addXp(15, 12);}
	else if(item == Items.stone_axe){ p.addXp(15, 12);}

	else if(item == Items.iron_sword){ p.addXp(15, 19);}
	else if(item == Items.iron_hoe){ p.addXp(15, 19);}
	else if(item == Items.iron_shovel){ p.addXp(15, 11);}
	else if(item == Items.iron_pickaxe){ p.addXp(15, 27);}
	else if(item == Items.iron_axe){ p.addXp(15, 27);}

	else if(item == Items.golden_sword){ p.addXp(15, 25);}
	else if(item == Items.golden_hoe){ p.addXp(15, 25);}
	else if(item == Items.golden_shovel){ p.addXp(15, 14);}
	else if(item == Items.golden_pickaxe){ p.addXp(15, 36);}
	else if(item == Items.golden_axe){ p.addXp(15, 36);}

	else if(item == Items.diamond_sword){ p.addXp(15, 27);}
	else if(item == Items.diamond_hoe){ p.addXp(15, 27);}
	else if(item == Items.diamond_shovel){ p.addXp(15, 15);}
	else if(item == Items.diamond_pickaxe){ p.addXp(15, 39);}
	else if(item == Items.diamond_axe){ p.addXp(15, 39);}

	//Tanning
	else if(item == Items.leather){ p.addXp(16, 10);}
	else if(item == Items.leather_boots){ p.addXp(16, 16);}
	else if(item == Items.leather_helmet){ p.addXp(16, 20);}
	else if(item == Items.leather_leggings){ p.addXp(16, 28);}
	else if(item == Items.leather_chestplate){ p.addXp(16, 32);}
	//Jewelry
	//--
	//Fletching
	else if(item == Items.stick){ p.addXp(18, 4);}
	//Construction
	else if(item == Item.getItemFromBlock(Blocks.planks))
	{ p.addXp(22, 5);}
	else if(item == Item.getItemFromBlock(Blocks.bed)){ p.addXp(22, 30);}
	else if(item == Item.getItemFromBlock(Blocks.oak_door)||item == Item.getItemFromBlock(Blocks.spruce_door)||item == Item.getItemFromBlock(Blocks.birch_door)||item == Item.getItemFromBlock(Blocks.jungle_door))
	{ p.addXp(22, 30);}	
	else if(item == Item.getItemFromBlock(Blocks.oak_stairs)||item == Item.getItemFromBlock(Blocks.spruce_stairs)||item == Item.getItemFromBlock(Blocks.birch_stairs)||item == Item.getItemFromBlock(Blocks.jungle_stairs))
	{ p.addXp(22, 30);}	

	p.sync();
	p.getXp();
	}
}

@SubscribeEvent
public void ItemSmeltedEvent(ItemSmeltedEvent event){
	Item item = event.smelting.getItem();

	EntityPlayer player = event.player;
	MarkData p = MarkData.get(player);
	if (p != null){

	//smithing
	if(item == Item.getItemFromBlock(Blocks.stone)){ p.addXp(15, (3 * event.smelting.stackSize));}
	else if(item == Items.iron_ingot){ p.addXp(15, (8 * event.smelting.stackSize));}
	else if(item == Items.gold_ingot){ p.addXp(15, (11 * event.smelting.stackSize));}
	//juwelry
	else if(item == Item.getItemFromBlock(Blocks.glass)){ p.addXp(17, (4 * event.smelting.stackSize));}
	//cooking
	else if(item == Items.cooked_porkchop || item == Items.cooked_beef || item == Items.cooked_chicken|| item == Items.cooked_fish || item == Items.cooked_rabbit){ p.addXp(19, (4 * event.smelting.stackSize));}

		p.sync();
		p.getXp();
		}
}
}

 

IEEP:

package com.modMark.Skill;

import com.modMark.Main.MainRegistry;
import com.modMark.Packets.SkillPacket;

import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagIntArray;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
import net.minecraftforge.common.IExtendedEntityProperties;

public class MarkData implements IExtendedEntityProperties {

//this field is used in getXP()
public int MainLock = 1;

//you know this
public EntityPlayer Player;
//this fields are some future this to unlock the locked skills
public int XpLock1 = 0;
public int XpLock2 = 0;
public int XpLock3 = 0;
public int XpLock4 = 0;
public int XpLock5 = 0;
public int XpLock6 = 0;
public int XpLock7 = 0;

//The name of the Skill
public String[] SkillName = new String[35]; //head
//this field are for calculating the skill levels ect
public double[] Level1 = new double[35];
public int[] Level = new int[35]; //head
public double[] NextLevel0 = new double[35];
public double[] NextLevel1 = new double[35];
public int[] NextLevel = new int[35]; //head
public int[] XpNeed = new int[35]; //head


//total and combat level
public int Total;

public double Combat1;
public int Combat;


public static final String EXT_PLAYER136 = "ModMark136Data";
private final EntityPlayer player;
public boolean candothis;
public boolean candothisTool;
public static int[] XP = new int[35];

public MarkData(EntityPlayer player){
	this.player = player;
	//sets the skill Xps to zero(i don't know i this makes sence)
	for (int i = 0; i < 35; i++){
	if (this.XP[i] == 0){
		XP[i] = 0;	
	}

}
}

public static void register(EntityPlayer player)
{
player.registerExtendedProperties(MarkData.EXT_PLAYER136, new MarkData(player));
System.out.println("register Player");
}



public static MarkData get(EntityPlayer player)
{

	return (MarkData) player.getExtendedProperties(EXT_PLAYER136);


}


public boolean isServerSide() {
    return player instanceof EntityPlayerMP;
}



@Override
public void saveNBTData(NBTTagCompound compound) {
	NBTTagCompound Array = new NBTTagCompound();

	Array.setIntArray("Skill136", this.getXp());

	compound.setTag(EXT_PLAYER136 , Array);
	System.out.println("Saving Xp Levels for " + player.getName() + " ," + Array);
}




@Override
public void loadNBTData(NBTTagCompound compound) {
	NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PLAYER136);


		this.setXP(properties.getIntArray("Skill136"));
		System.out.println("Loading Xp Levels");




}
@Override
public void init(Entity entity, World world) {

}



public static void resetXP(){
	for (int i = 0; i < 35; i++)
	XP[i] = 0;
}



public void setXP(int[] Xp){

	this.XP = Xp;
}



public int addXp(int SkillID, int amount){



	this.Lvlcalc(player);
	this.setSkillName();
	if((XP[skillID] + amount) >= this.NextLevel[skillID] && XP[skillID] < this.NextLevel[skillID]){
	ChatComponentText component = new ChatComponentText("Congratulations! Your Level in " + this.SkillName[skillID] + " is now " + (this.Level[skillID]+ 1));
	player.addChatComponentMessage(component);
	}

	return this.XP[skillID] += amount;


}

//this is to check if the requirement level is high enough to do the action. 
//	SkillID = the ID of the skill.
//	reqlvl = the requirement level to do the action
//	method = the text that will apear
public void requireLvl(int SkillID, int reqlvl, int method){
	this.setSkillName();
	this.Lvlcalc(Player);

		if (method == 0){
			candothis = this.Level[skillID] >= reqlvl;
			if(candothis == false){
		ChatComponentText component = new ChatComponentText("You need " + reqlvl + " " + this.SkillName[skillID] + " for this");
		player.addChatComponentMessage(component);
		}}

		if (method == 1){
		candothisTool = this.Level[skillID] >= reqlvl;
		if(candothisTool == false){
		ChatComponentText component = new ChatComponentText("You need a level of " + reqlvl + " " + this.SkillName[skillID] + " to use this tool");
		player.addChatComponentMessage(component);
		}}
		else {}




}

public int[] getXp() {

for (int i = 0;i < 35; i++){
		if ((this.XP[i]) > 500000 && this.MainLock == 1)				{this.XP[i] = 500000;}
	else if ((this.XP[i]) > 85000000 && this.MainLock == 2)				{this.XP[i] = 85000000;}
	else if ((this.XP[i]) > 2000000000 && this.MainLock == 3)			{this.XP[i] = 2000000000;}

	}

return this.XP;

}




public void sync() {
    if (this.isServerSide()){
    	
        MainRegistry.network.sendTo(new SkillPacket(), (EntityPlayerMP) player);
    }
}
public void RequestingSync() {
    if (!this.isServerSide())
    	MainRegistry.network.sendToServer(new SkillPacket());
}
//saves data if death or end
public void saveReviveRelevantNBTData(NBTTagCompound compound, boolean wasDeath) {

        this.saveNBTData(compound);
}

//sets the name of the skill
public void setSkillName(){

	 this.SkillName[0] = "Constitution";
	 this.SkillName[1] = "Melee";
	 this.SkillName[2] = "Ranged";
	 this.SkillName[3] = "Magic";
	 this.SkillName[4] = "Defence";
	 this.SkillName[5] = "Endurance";
	 this.SkillName[6] = "Slayer";
	 this.SkillName[7] = "Farming";
	 this.SkillName[8] = "Mining";
	 this.SkillName[9] = "Hunter";
	 this.SkillName[10] = "Excavation";
	 this.SkillName[11] = "Woodcutting";
	 this.SkillName[12] = "Fishing";
	 this.SkillName[13] = "Archeology";
	 this.SkillName[14] = "Tailory";
	 this.SkillName[15] = "Smithing";
	 this.SkillName[16] = "Tanning";
	 this.SkillName[17] = "Jewelry";
	 this.SkillName[18] = "Fletching";
	 this.SkillName[19] = "Cooking";
	 this.SkillName[20] = "Herblore";
	 this.SkillName[21] = "Honour";
	 this.SkillName[22] = "Construction";
	 this.SkillName[23] = "Agility";
	 this.SkillName[24] = "Dungeoneering";
	 this.SkillName[25] = "Firemaking";
	 this.SkillName[26] = "Lifestock";
	 this.SkillName[27] = "Knowledge";
	 this.SkillName[28] = "Technology";
	 this.SkillName[29] = "Petting";
	 this.SkillName[30] = "Chemistry";
	 this.SkillName[31] = "Specility";
	 this.SkillName[32] = "Mutating";
	 this.SkillName[33] = "Fisioning";
	 this.SkillName[34] = "Fusioning";
	  
	}


//this methode is to calculate my XP to level(and this really works!!)
 public void Lvlcalc(EntityPlayer player) {
	Player = player;


for (int i = 0; i < 35;i++) {

		if (this.getXp()[i] == 2000000000)										{this.Level1[i] = 255;}
	else if (this.getXp()[i] >= 1720000000 && this.getXp()[i] <= 1999999999)	{this.Level1[i] = 254;}
	else if (this.getXp()[i] >= 1480000000 && this.getXp()[i] <= 1719999999)	{this.Level1[i] = 253;}
	else if (this.getXp()[i] >= 1280000000 && this.getXp()[i] <= 1479999999)	{this.Level1[i] = 252;}
	else if (this.getXp()[i] >= 1120000000 && this.getXp()[i] <= 1279999999)	{this.Level1[i] = 251;}
	else if (this.getXp()[i] >= 1000000000 && this.getXp()[i] <= 1119999999)	{this.Level1[i] = 250;}
	else if (this.getXp()[i] >= 954238196 && this.getXp()[i] <= 999999999)		{this.Level1[i] = 249;}
	else if (this.getXp()[i] >= 100005814 && this.getXp()[i] <= 954238195)		{this.Level1[i] = ((Math.log(this.getXp()[i] + 8287)/Math.log(8287))-1)*192+1;}
	else if (this.getXp()[i] >= 70404413 && this.getXp()[i] <= 100005813)		{this.Level1[i] = 200;}
	else if (this.getXp()[i] >= 701754 && this.getXp()[i] <= 70404412)			{this.Level1[i] = ((Math.log10(this.getXp()[i] + 7480)/Math.log10(7480))-1)*194+1;}
	else if (this.getXp()[i] >= 409286 && this.getXp()[i] <= 701753)			{this.Level1[i] = 99;}
	else if (this.getXp()[i] <= 409285)											{this.Level1[i] = ((Math.log10(this.getXp()[i] + 522)/Math.log10(522))-1)*92+1;}
	else 																		{this.Level1[i] = 0;}


 	this.Level[i] = (int) Math.floor(this.Level1[i]); /** floors this.Level down*/
	this.NextLevel0[i] = (int) (this.Level[i] + 1);  /** says Level + 1*/
	this.NextLevel[i] = (int) Math.ceil(this.NextLevel1[i]);
	this.XpNeed[i] = (int) (this.NextLevel[i] - this.getXp()[i]);


		if (this.Level[i] < 99) 												{this.NextLevel1[i] = (Math.pow(522, (this.NextLevel0[i] - 1)/92 +1) - 522);}
	else if (this.Level[i] == 99)												{this.NextLevel1[i] = 701754;}
	else if (this.Level[i] >= 100 && this.Level[i] < 200) 						{this.NextLevel1[i] = (Math.pow(7480, (this.NextLevel0[i] - 1)/194 +1) - 7480);}
	else if (this.Level[i] == 200) 												{this.NextLevel1[i] = 100005814;}
	else if (this.Level[i] >= 201 && this.Level[i] < 249) 						{this.NextLevel1[i] = (Math.pow(8287, (this.NextLevel0[i] - 1)/192 +1) - 8287);}
	else if (this.Level[i] == 249) 												{this.NextLevel1[i] = 1000000000;}
	else if (this.Level[i] == 250) 												{this.NextLevel1[i] = 1120000000;}
	else if (this.Level[i] == 251) 												{this.NextLevel1[i] = 1280000000;}
	else if (this.Level[i] == 252) 												{this.NextLevel1[i] = 1480000000;}
	else if (this.Level[i] == 253) 												{this.NextLevel1[i] = 1720000000;}
	else if (this.Level[i] == 254) 												{this.NextLevel1[i] = 2000000000;}
	else 																		{this.NextLevel1[i] = 0;}

	}}




 //to calculate the combat level
 public void getCombatLvl(EntityPlayer player){
	 Player = player;
	 Lvlcalc(Player);
if(this.Level[1] >= this.Level[2] && this.Level[1] >= this.Level[3]){

	Combat1 = (Math.sqrt(this.Level[0]) * Math.sqrt(this.Level[5]) + this.Level[1] + this.Level[4]) / 765*350;
}
else if(this.Level[2] >= this.Level[3]){

	Combat1 = (Math.sqrt(this.Level[0]) * Math.sqrt(this.Level[5]) + this.Level[2] + this.Level[4]) / 765*350;
}
else
{
	Combat1 = (Math.sqrt(this.Level[0]) * Math.sqrt(this.Level[5]) + this.Level[3] + this.Level[4]) / 765*350;
}

Combat = (int) Math.floor(Combat1);
 }







 //to calculate the Total Level----------------------------------------------------------------------
 public void getTotalLvl(EntityPlayer player) {
	 Player = player;
	 Lvlcalc(Player);
	 this.Total = 0;
for (int i = 0; i < 35; i++){
	Total += this.Level[i];
}

}	
}

 

PacketHandler thing:

package com.modMark.Packets;

import com.modMark.Main.GuiStatlist;
import com.modMark.Skill.MarkData;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IThreadListener;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;

public class SkillPacket implements IMessage{



public SkillPacket() {}
public SkillPacket(EntityPlayer E, int[] s ){

	MarkData p = MarkData.get(Minecraft.getMinecraft().thePlayer);

	p.XP = s;

}


@Override
public void fromBytes(ByteBuf buf) {
	MarkData p = MarkData.get(Minecraft.getMinecraft().thePlayer);
	for (int k = 0; k < 35; k++){

		p.XP[k] = buf.readInt();
	}

}

@Override
public void toBytes(ByteBuf buf) {
	MarkData p = MarkData.get(Minecraft.getMinecraft().thePlayer);
	for (int j = 0; j < 35; j++){

		buf.writeInt(p.XP[j]);
		}

}


//-----------------------------------------------------------------------------------------------

public static class MarkHandler implements IMessageHandler<SkillPacket, IMessage > {

@Override
public IMessage onMessage(final SkillPacket message, MessageContext ctx) {
	IThreadListener ThreadListener = Minecraft.getMinecraft();
			ThreadListener.addScheduledTask(new Runnable() {
				@Override
                public void run() {


					for (int i = 0; i < 35; i++){

					MarkData p = MarkData.get(Minecraft.getMinecraft().thePlayer);

					 GuiStatlist.XP = p.XP;


					}
					System.out.println("PlayerData is from the PacketHandler");
                    
                }
			});
	return null;
}

}
}

 

the XP in guiStatlist wil be used to show in the gui, and works correctly :)

the bugs are still, I receive every package but my friends only got if they to something like it should be.

but the biggest problem is that everyone shares the same xp so if i mine, my friends gets mining xp to and visa versa.

my Mod: Extended RPG [W.I.P]

Posted

One major problem with your code is you are using Minecraft.getMinecraft().thePlayer almost everywhere. That is the CLIENT player only, and you should NOT use it pretty much ever. Use the player you pass to your constructor, e.g.:

public SkillPacket(EntityPlayer player, int[] s ) { // you pass 'player' here, use it!
MarkData p = MarkData.get(player); // here, instead of Minecraft.getMinecraft().thePlayer
p.XP = s;
}

 

However, the problem that you are experiencing is, still, that you do not understand the static keyword. Your IEEP#XP field CAN NOT be static lest you want every single player on the server to always have identical amounts of XP.

 

And please, use some constants for your skill IDs (or wrap them in class instances) - how is anyone supposed to know what skill 15 is? Your code is going to be a nightmare to debug down the road, if it isn't already.

Posted
//oh boy! we pass in an entity player! this is probably the one we want to do stuff to!
public SkillPacket(EntityPlayer E, int[] s ){

	//yeah! lets IGNORE THE FUCK OUT OF IT.
	MarkData p = MarkData.get(Minecraft.getMinecraft().thePlayer);

	p.XP = s;

}

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Okay, Changed my XP tot non-static, so now i understand that, but still got an console error

 

now, i gonna try again what i'm doing exactly

 

first, I mine a block.

then MinExcaWC_XP will be called.

 

public void MinExcaWC_XP(BreakEvent event){
// this Method Checks what Block What Player Breaks
// And then, this adds XP (I Checked if this works on Serverside, and it's all fine.)
// and tells to Synchronise

MarkData p = MarkData.get(event.getPlayer());
[...]
p.Sync();

}

 

Now we gonna Look at some things in the


public static MarkData get(EntityPlayer player)
{
	return (MarkData) player.getExtendedProperties(EXT_PLAYER136);
}

//it is nessesary to check if The Player is on the ServerSide, Otherwise you got an error like "EntityPlayerSP cannot be cast to EntityPlayerMP"
public boolean isServerSide() {
    return player instanceof EntityPlayerMP;
}

public void sync() {
    if (this.isServerSide()){
    	
        MainRegistry.network.sendTo(new SkillPacket(), (EntityPlayerMP) player);
        System.out.println("Player: " + player);
    }
}

 

here is the error:

[21:35:37] [server thread/ERROR] [FML]: FMLIndexedMessageCodec exception caught
io.netty.handler.codec.EncoderException: java.lang.NullPointerException
at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:107) ~[MessageToMessageEncoder.class:4.0.23.Final]
at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116) ~[MessageToMessageCodec.class:4.0.23.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:658) ~[AbstractChannelHandlerContext.class:4.0.23.Final]
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:716) ~[AbstractChannelHandlerContext.class:4.0.23.Final]
at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:706) ~[AbstractChannelHandlerContext.class:4.0.23.Final]
at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:741) ~[AbstractChannelHandlerContext.class:4.0.23.Final]
at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:895) ~[DefaultChannelPipeline.class:4.0.23.Final]
at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:240) ~[AbstractChannel.class:4.0.23.Final]
at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.sendTo(SimpleNetworkWrapper.java:229) [simpleNetworkWrapper.class:?]
at com.modMark.Skill.MarkData.sync(MarkData.java:202) [MarkData.class:?]
at com.modMark.Skill.EventHandlerMark.MinExcaWC_XP(EventHandlerMark.java:373) [EventHandlerMark.class:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_9_EventHandlerMark_MinExcaWC_XP_BreakEvent.invoke(.dynamic) [?:?]
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:55) [ASMEventHandler.class:?]
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140) [EventBus.class:?]
at net.minecraftforge.common.ForgeHooks.onBlockBreakEvent(ForgeHooks.java:684) [ForgeHooks.class:?]
at net.minecraft.server.management.ItemInWorldManager.tryHarvestBlock(ItemInWorldManager.java:299) [itemInWorldManager.class:?]
at net.minecraft.server.management.ItemInWorldManager.blockRemoving(ItemInWorldManager.java:251) [itemInWorldManager.class:?]
at net.minecraft.network.NetHandlerPlayServer.processPlayerDigging(NetHandlerPlayServer.java:562) [NetHandlerPlayServer.class:?]
at net.minecraft.network.play.client.C07PacketPlayerDigging.processPacket(C07PacketPlayerDigging.java:56) [C07PacketPlayerDigging.class:?]
at net.minecraft.network.play.client.C07PacketPlayerDigging.processPacket(C07PacketPlayerDigging.java:12) [C07PacketPlayerDigging.class:?]
at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) [PacketThreadUtil$1.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_40]
at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_40]
at net.minecraft.util.Util.runTask(Util.java:22) [util.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:736) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:681) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:159) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:548) [MinecraftServer.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_40]
Caused by: java.lang.NullPointerException
at com.modMark.Packets.SkillPacket.toBytes(SkillPacket.java:50) ~[skillPacket.class:?]
at net.minecraftforge.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:11) ~[simpleIndexedCodec.class:?]
at net.minecraftforge.fml.common.network.simpleimpl.SimpleIndexedCodec.encodeInto(SimpleIndexedCodec.java:7) ~[simpleIndexedCodec.class:?]
at net.minecraftforge.fml.common.network.FMLIndexedMessageToMessageCodec.encode(FMLIndexedMessageToMessageCodec.java:55) ~[FMLIndexedMessageToMessageCodec.class:?]
at io.netty.handler.codec.MessageToMessageCodec$1.encode(MessageToMessageCodec.java:67) ~[MessageToMessageCodec$1.class:4.0.23.Final]
at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:89) ~[MessageToMessageEncoder.class:4.0.23.Final]
... 28 more

 

 

and my updated IMessage + IMessageHandler class:

package com.modMark.Packets;

import com.modMark.Main.GuiStatlist;
import com.modMark.Skill.MarkData;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IThreadListener;
import net.minecraftforge.fml.common.network.ByteBufUtils;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;

public class SkillPacket implements IMessage{

private EntityPlayer Player;
private int[] XP;

public SkillPacket() {}
public SkillPacket(int[] s, EntityPlayer player){
	MarkData p = MarkData.get(player);
	this.Player = player;
	s = p.getXp();
	XP = p.getXp();

	System.out.println("Test-1 Packet" + player);
}


@Override
public void fromBytes(ByteBuf buf) {

	for (int k = 0; k < 35; k++){

		XP[k] = buf.readInt();

	}
	System.out.println("Test-2 Packet" + Player + " Excavation XP: " + XP[10]);
}

@Override
public void toBytes(ByteBuf buf) {

	for (int j = 0; j < 35; j++){

		buf.writeInt(XP[j]);
		}
	System.out.println("Test-3 Packet" + Player + " Excavation XP: " + XP[10]);
}


//-----------------------------------------------------------------------------------------------

public static class MarkHandler implements IMessageHandler<SkillPacket, IMessage > {

@Override
public IMessage onMessage(final SkillPacket message, MessageContext ctx) {
	IThreadListener ThreadListener = Minecraft.getMinecraft();
			ThreadListener.addScheduledTask(new Runnable() {
				@Override
                public void run() {
					final EntityPlayer player = Minecraft.getMinecraft().thePlayer;
					MarkData p = MarkData.get(player);
					GuiStatlist.XP = message.XP;

					System.out.println("PlayerData is send to " + player); 
                    
                }
			});
	return null;
}

}
}

 

I can feel i'm almost there. I know this code is maybe to complex for me. but I want the learn it.

I already created a very cool gui. some blocks(not the easiest) and some Items.

my Mod: Extended RPG [W.I.P]

Posted

...

 

public class SkillPacket implements IMessage{

private EntityPlayer Player;

//oh, you not gonna mis this laughery. Look at it, the perfect way to initialise an Array 
//-.-
private int[] XP;

// Changed to

private int

my Mod: Extended RPG [W.I.P]

Posted

public static SimpleNetworkWrapper network;

 

and in my pre-Init i got this

 

network = NetworkRegistry.INSTANCE.newSimpleChannel("mark13695");

network.registerMessage(SkillPacket.MarkHandler.class , SkillPacket.class, 0, Side.CLIENT);

 

no error anymore but my player is null:

this print: System.out.println("Test-3 Packet" + this.Player + " Excavation XP: " + XP[10]);

gives me this

[21:39:03] [Client thread/INFO] [sTDOUT]: [com.modMark.Packets.SkillPacket:toBytes:52]: Test-3 Packetnull Excavation XP: 0

my Mod: Extended RPG [W.I.P]

Posted

oh, was editing this class so much i forgotten to remove it

 

and:

 

[22:18:27] [Client thread/FATAL]: Error executing task
java.util.concurrent.ExecutionException: java.lang.NullPointerException
at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_40]
at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_40]
at net.minecraft.util.Util.runTask(Util.java:23) [util.class:?]
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1070) [Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:380) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:116) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_40]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_40]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_40]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_40]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_40]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_40]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_40]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_40]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
at GradleStart.main(GradleStart.java:26) [start/:?]
Caused by: java.lang.NullPointerException
at com.modMark.Skill.MarkData.get(MarkData.java:80) ~[MarkData.class:?]
at com.modMark.Packets.SkillPacket$MarkHandler$1.run(SkillPacket.java:72) ~[skillPacket$MarkHandler$1.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_40]
at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_40]
at net.minecraft.util.Util.runTask(Util.java:22) ~[util.class:?]
... 15 more

 

package com.modMark.Packets;

import com.modMark.Main.GuiStatlist;
import com.modMark.Skill.MarkData;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IThreadListener;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.ByteBufUtils;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;

public class SkillPacket implements IMessage{

private int ID;
private int[] XP = new int[35];

public SkillPacket() {}
public SkillPacket(int[] s, EntityPlayer player){

	this.ID = player.getEntityId();
	this.XP = s;



	System.out.println("Test-1 Packet" + player);
}


@Override
public void fromBytes(ByteBuf buf) {

	for (int k = 0; k < 35; k++){

		this.XP[k] = buf.readInt();

	}
	this.ID = buf.readInt();
	System.out.println("Test-2 Packet " + ID + " Excavation XP: " + this.XP[10]);
}

@Override
public void toBytes(ByteBuf buf) {

	for (int j = 0; j < 35; j++){

		buf.writeInt(this.XP[j]);
		}
		buf.writeInt(this.ID);
	System.out.println("Test-3 Packet " + ID + " Excavation XP: " + XP[10]);
}


//-----------------------------------------------------------------------------------------------

public static class MarkHandler implements IMessageHandler<SkillPacket, IMessage > {

@Override
public IMessage onMessage(final SkillPacket message, MessageContext ctx) {
	IThreadListener ThreadListener = Minecraft.getMinecraft();
			ThreadListener.addScheduledTask(new Runnable() {
				@Override
                public void run() {
					final EntityPlayer player = (EntityPlayer) Minecraft.getMinecraft().theWorld.getEntityByID(message.ID);

					MarkData p = MarkData.get(player);
					p.XP = message.XP;
					message.XP = GuiStatlist.XP;

					System.out.println("PlayerData is send to " + player); 
                    
                }
			});
	return null;
}

}
}

 

[22:18:27] [server thread/INFO] [sTDOUT]: [com.modMark.Packets.SkillPacket:toBytes:56]: Test-3 Packet 0 Excavation XP: 0

my Mod: Extended RPG [W.I.P]

Posted

in the Methode sync in my IEEP class

i Changed this:

public void sync() {
    if (this.isServerSide()){
    	
        MainRegistry.network.sendTo(new SkillPacket(), (EntityPlayerMP) player);
        System.out.println("Player: " + player);
    }
}

 

to this

 

public void sync() {
    if (this.isServerSide()){
    	
        MainRegistry.network.sendTo(new SkillPacket([code]this.XP, this.player

), (EntityPlayerMP) player);

        System.out.println("Player: " + player);

    }

}[/code]

 

and again my Packet class:

package com.modMark.Packets;

import com.modMark.Main.GuiStatlist;
import com.modMark.Skill.MarkData;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IThreadListener;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.ByteBufUtils;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;

public class SkillPacket implements IMessage{

private int ID;
private int[] XP = new int[35];

public SkillPacket() {}
public SkillPacket(int[] s, EntityPlayer player){

	this.ID = player.getEntityId();
	this.XP = s;



	System.out.println("Test-1 Packet" + player);
}


@Override
public void fromBytes(ByteBuf buf) {

	for (int k = 0; k < 35; k++){

		this.XP[k] = buf.readInt();

	}
	this.ID = buf.readInt();
	System.out.println("Test-2 Packet " + ID + " Excavation XP: " + this.XP[10]);
}

@Override
public void toBytes(ByteBuf buf) {

	for (int j = 0; j < 35; j++){

		buf.writeInt(this.XP[j]);
		}
		buf.writeInt(this.ID);
	System.out.println("Test-3 Packet " + ID + " Excavation XP: " + XP[10]);
}


//-----------------------------------------------------------------------------------------------

public static class MarkHandler implements IMessageHandler<SkillPacket, IMessage > {

@Override
public IMessage onMessage(final SkillPacket message, MessageContext ctx) {
	IThreadListener ThreadListener = Minecraft.getMinecraft();
			ThreadListener.addScheduledTask(new Runnable() {
				@Override
                public void run() {
					final EntityPlayer player = (EntityPlayer) Minecraft.getMinecraft().theWorld.getEntityByID(message.ID);

					MarkData p = MarkData.get(player);
					p.setXP(message.XP);
					GuiStatlist.XP = p.XP; 

					System.out.println("PlayerData is send to " + player); 
                    
                }
			});
	return null;
}

}
}

 

it seems to work, but got one problem, unfortunatly its when a player gets XP, the player will be kicked out of the server, but i saw i don't get xp anymore from othore players breaking a block

 

this are the only logs i could found from the kick:

 

[22:59:11] [server thread/INFO]: Player2[/iP:Port] logged in with entity id 5742 at (25.5, 70.0, -96.5)
[22:59:11] [server thread/INFO]: Player2 joined the game
[22:59:12] [Client thread/INFO]: [CHAT] Player2 joined the game
[22:59:17] [server thread/INFO]: Player2 has just earned the achievement [Taking Inventory]
[22:59:17] [Client thread/INFO]: [CHAT] Player2 has just earned the achievement [Taking Inventory]
[22:59:44] [server thread/INFO]: Player2 lost connection: TextComponent{text='Disconnected', siblings=[], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null}}
[22:59:44] [server thread/INFO]: Player2 left the game
[22:59:44] [Client thread/INFO]: [CHAT] Player2 left the game
[22:59:56] [user Authenticator #2/INFO]: UUID of player Player2 is e3b2d6e7-01a6-447d-ba3b-a08bc8adc2eb
[23:00:15] [server thread/INFO]: Player2 lost connection: TranslatableComponent{key='disconnect.genericReason', args=[internal Exception: java.io.IOException: The external host has lost connextion], siblings=[], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null}}
[23:00:15] [server thread/INFO]: Player2 left the game
[23:00:15] [Client thread/INFO]: [CHAT] Player2 left the game
[23:00:32] [user Authenticator #3/INFO]: UUID of player Player2 is e3b2d6e7-01a6-447d-ba3b-a08bc8adc2eb
[23:00:51] [server thread/INFO]: Player2 lost connection: TranslatableComponent{key='disconnect.genericReason', args=[internal Exception: java.io.IOException: The external host has lost connextion], siblings=[], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null}}

oh well checked the wrong log :P

this is the error

[22:59:44] [Netty Server IO #4/ERROR] [FML/]: NetworkDispatcher exception
java.io.IOException: De externe host heeft een verbinding verbroken
at sun.nio.ch.SocketDispatcher.read0(Native Method) ~[?:1.8.0_25]
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43) ~[?:1.8.0_25]
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) ~[?:1.8.0_25]
at sun.nio.ch.IOUtil.read(IOUtil.java:192) ~[?:1.8.0_25]
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:379) ~[?:1.8.0_25]
at io.netty.buffer.UnpooledUnsafeDirectByteBuf.setBytes(UnpooledUnsafeDirectByteBuf.java:446) ~[unpooledUnsafeDirectByteBuf.class:4.0.23.Final]
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:881) ~[AbstractByteBuf.class:4.0.23.Final]
at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:225) ~[NioSocketChannel.class:4.0.23.Final]
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:119) [AbstractNioByteChannel$NioByteUnsafe.class:4.0.23.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511) [NioEventLoop.class:4.0.23.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) [NioEventLoop.class:4.0.23.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) [NioEventLoop.class:4.0.23.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354) [NioEventLoop.class:4.0.23.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116) [singleThreadEventExecutor$2.class:4.0.23.Final]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_25]

my Mod: Extended RPG [W.I.P]

Posted

found something out...

 

[22:59:44] [Netty Server IO #4/ERROR] [FML/]: NetworkDispatcher exception
java.io.IOException: De externe host heeft een verbinding verbroken
at sun.nio.ch.SocketDispatcher.read0(Native Method) ~[?:1.8.0_25]
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43) ~[?:1.8.0_25]
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) ~[?:1.8.0_25]
at sun.nio.ch.IOUtil.read(IOUtil.java:192) ~[?:1.8.0_25]
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:379) ~[?:1.8.0_25]
at io.netty.buffer.UnpooledUnsafeDirectByteBuf.setBytes(UnpooledUnsafeDirectByteBuf.java:446) ~[unpooledUnsafeDirectByteBuf.class:4.0.23.Final]
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:881) ~[AbstractByteBuf.class:4.0.23.Final]
at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:225) ~[NioSocketChannel.class:4.0.23.Final]
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:119) [AbstractNioByteChannel$NioByteUnsafe.class:4.0.23.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511) [NioEventLoop.class:4.0.23.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) [NioEventLoop.class:4.0.23.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) [NioEventLoop.class:4.0.23.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354) [NioEventLoop.class:4.0.23.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116) [singleThreadEventExecutor$2.class:4.0.23.Final]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_25]
[22:59:44] [server thread/INFO] [sTDOUT/]: [com.modMark.Skill.MarkData:saveNBTData:99]: Saving Xp Levels for Player2 ,{Skill136:[0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,]}
[22:59:56] [server thread/INFO] [sTDOUT/]: [com.modMark.Skill.MarkData:register:72]: register Player
[22:59:56] [server thread/INFO] [sTDOUT/]: [com.modMark.Skill.EventHandlerMark:onEntityConstructing:61]: Registering Player!
[22:59:56] [Netty Server IO #5/TRACE] [FML/]: Handshake channel activating
[22:59:56] [Netty Server IO #5/DEBUG] [FML/]: FMLHandshakeServerState: null->FMLHandshakeServerState$1:START
[22:59:56] [Netty Server IO #5/DEBUG] [FML/]:   Next: HELLO
[22:59:56] [Netty Server IO #5/DEBUG] [FML/]: FMLHandshakeServerState: $ClientHello->FMLHandshakeServerState$2:HELLO
[22:59:56] [Netty Server IO #5/INFO] [FML/]: Client protocol version 2
[22:59:56] [Netty Server IO #5/DEBUG] [FML/]:   Next: HELLO
[22:59:56] [Netty Server IO #5/DEBUG] [FML/]: FMLHandshakeServerState: $ModList:4 mods->FMLHandshakeServerState$2:HELLO
[22:59:56] [Netty Server IO #5/INFO] [FML/]: Client attempting to join with 4 mods : [email protected],[email protected],[email protected],[email protected] test-6
[22:59:56] [Netty Server IO #5/DEBUG] [FML/]:   Next: WAITINGCACK
[22:59:56] [Netty Server IO #5/DEBUG] [FML/]: FMLHandshakeServerState: $HandshakeAck:{2}->FMLHandshakeServerState$3:WAITINGCACK
[22:59:56] [Netty Server IO #5/DEBUG] [FML/]:   Next: COMPLETE
[23:00:15] [Netty Server IO #5/ERROR] [FML/]: NetworkDispatcher exception
java.io.IOException: De externe host heeft een verbinding verbroken
at sun.nio.ch.SocketDispatcher.read0(Native Method) ~[?:1.8.0_25]
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43) ~[?:1.8.0_25]
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) ~[?:1.8.0_25]
at sun.nio.ch.IOUtil.read(IOUtil.java:192) ~[?:1.8.0_25]
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:379) ~[?:1.8.0_25]
at io.netty.buffer.UnpooledUnsafeDirectByteBuf.setBytes(UnpooledUnsafeDirectByteBuf.java:446) ~[unpooledUnsafeDirectByteBuf.class:4.0.23.Final]
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:881) ~[AbstractByteBuf.class:4.0.23.Final]
at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:225) ~[NioSocketChannel.class:4.0.23.Final]
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:119) [AbstractNioByteChannel$NioByteUnsafe.class:4.0.23.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511) [NioEventLoop.class:4.0.23.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) [NioEventLoop.class:4.0.23.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) [NioEventLoop.class:4.0.23.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354) [NioEventLoop.class:4.0.23.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116) [singleThreadEventExecutor$2.class:4.0.23.Final]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_25]

 

I think the issue here is that during the first login the handshake is processed fully as it should be, but later, it is'nt.

the first login he payloads the Register but SHOULD'NT on a second login or third.

 

and i still know always if i join a world he well registry.

 

ok, if i check the onEntityConstructing event:

@SubscribeEvent
public void onEntityConstructing(EntityConstructing event)
{		
//event.entity instanceof EntityPlayer = is the Entity a player
//MarkData.get((EntityPlayer) event.entity) == null , this checks if there is already data saved for the player
	if (event.entity instanceof EntityPlayer && MarkData.get((EntityPlayer) event.entity) == null){	
		MarkData.register((EntityPlayer) event.entity);
		System.out.println("Registering Player!");
	}
}

but strangly he will always tell that te if statment is true, because he always registers when log in, but if he register, the system noticed that theres already data available for the player

 

my Mod: Extended RPG [W.I.P]

Posted

yeah solve it, the error did'nt came from my mod but from something from internet connection

it works fine now. but you know, i'm writing a big mod so maybe i think i have more questions for other things that i can't get to work

thanks for the help :)

my Mod: Extended RPG [W.I.P]

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I need to know what mod is doing this crash, i mean the mod xenon is doing the crash but i want to know who mod is incompatible with xenon, but please i need to know a solution if i need to replace xenon, i cant use optifine anymore and all the other mods i tried(sodium, lithium, vulkan, etc) doesn't work, it crash the game.
    • I have been trying to solve a consistent crashing issue on my brother's computer where it will crash during the "Scanning Mod Candidates" phase of the loading process that starts when you click the play button on the Minecraft launcher. The issue seems to stem from a missing library that it mentions in the log file I provide below. I might I'm missing the bigger issue here for a smaller one but hopefully someone can find what I'm missing. Here's all of the stuff that I've been able to figure out so far: 1. It has nothing to do with mods, the crash happened with a real modpack, and even when I made a custom modpack and launched it without putting ANY mods into it (That is where the log file comes from by the way). 2. I have tried to find this class like a file in the Minecraft folders, but I've had no luck finding it (I don't think it works like that, but since I really don't understand how it works, I just figured I'd try). 3. I haven't seen anyone else have this issue before. 4. I know that my modpack (with mods) does work since I've run it on my computer, and it works fantastic. For some reason my brother's computer can't seem to run anything through curseforge. 5. This is for Minecraft version 1.20.1, Minecraft launcher version 3.4.50-2.1.3, forge 47.3.0, and curseforge app version 1.256.0.21056 6. My brother is using a Dell laptop from 6 years ago running Windows 10 (If you think more info on this would help, please ask as I do have it. I'm just choosing not to put it here for now). 7. I have reinstalled the curseforge app and installed Minecraft version 1.20.1. I have not reinstalled Minecraft or forge 47.3.0 but I didn't know if that would help. 8. I had an error code of 1 Please let me know if there is anything else that I am missing that you would like me to add to this post/add in a comment! Lastly, many thanks in advance to whoever can help! ------------- LOG FILE (latest.log) ------------- (from /Users/<NAME OF USER>/cursforge/minecraft/Instances/<THE NAME OF MY EMPTY MODPACK>/logs/latest.log) (This was made after running an empty modpack with same versions for all apps) ("[REDACTED]" is not the actual text from the log, it is me replacing text I figured wouldn't be necessary for fixing and would hurt my privacy) https://pastebin.com/hxXvGGEK ------------- DEBUG.LOG (I realized that I should have put this here first after I had done all of the work on putting latest.log in) -------------------- (again, "[REDACTED]" is not the actual text from the log, it is me replacing text I figured wouldn't be necessary for fixing and would hurt my privacy) https://pastebin.com/Fmh8GHYs
    • Pastebin... https://pastebin.com/Y3iZ85L5   Brand new profile, does not point to a mod as far as I can tell, my fatal message just has something about mixins. Don't know much about reading logs like this, but am genuinely stuck, please help. Java updated, pc restarted.
    • I was playing minecraft, forge 47.3.0 and 1.20.1, but when i tried to play minecraft now only crashes, i need help please. here is the crash report: https://securelogger.net/files/e6640a4f-9ed0-4acc-8d06-2e500c77aaaf.txt
  • Topics

×
×
  • Create New...

Important Information

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