@ForgeSubscribe
public void NameFormat(LivingUpdateEvent event){
EntityPlayer player = (EntityPlayer) event.entity;
}
Any idea how to actually set the username in here, I want to pull the value combatxp from my ExtendedPlayer, then do some checks, ie check if that value is over 20, then add a [1] to the username, if over 40 add [2] etc.
Also Happy Christmas everyone, going to go now and work more on this later.
Hoping eventually to add several skills with events for example to check if the player is a certain level before allowing them to wear certain armor etc, or to add damage.
Ok, so first off, a method name should never begin with a capital letter.
Secondly, I recommend you to name the method in a way that reminds you of the event it will be handling, and that event MUST be the parameter. In your case, you are off to the right start with your name, but then your parameter is 'LivingUpdateEvent' which is totally unrelated to the event you want.
Finally, whenever you want to set a value, either 'ctrl-click' the relevant class to see what member variables are available to you, or type in the name of the instance you have of that class, followed by a period '.' and a menu should pop up listing everything available.
// here's an example of a properly formatted, descriptive name; see how the parameter matches the method name?
@ForgeSubscribe
public void onNameFormat(PlayerEvent.NameFormat event) {
// here, we have an instance of the PlayerEvent.NameFormat class, and that instance is named 'event'
// type 'event' and then period '.' and see what comes up
// alternatively, ctrl-click on 'NameFormat' to open up the class, then use the outline (right-hand pane in Eclipse) to easily see what's available
}
Please read my above post more carefully; the things you did differently are the things causing it to not work.
EDIT: Also, in your onPacketData method, you only ever call 'handleExtendedProperties', so EVERY packet you send will be handled the same, which is not what you want. That's actually the source of your error, although you other things are wrong as well like I mentioned just above.
Please read my above post more carefully; the things you did differently are the things causing it to not work.
EDIT: Also, in your onPacketData method, you only ever call 'handleExtendedProperties', so EVERY packet you send will be handled the same, which is not what you want. That's actually the source of your error, although you other things are wrong as well like I mentioned just above.
Yeah, sorry, didn't even see that one, I think I got it all correct now, but I can't test it, because the keys won't work or appear in the controls, even though I registered the keyhandler, but don't I need to register it in the main class somehow?
Keyhandler
@SideOnly(Side.CLIENT)
public class KeybindHandler extends KeyHandler
{
/** Key index for easy handling and retrieval of keys and key descriptions */
public static final byte SpeedUp = 0, SlowDown = 1;
/** Key descriptions - this is what the player sees when changing key bindings in-game */
public static final String[] desc = {"Description 1","Description 2"};
/** Default key values */
private static final int[] keyValues = {Keyboard.KEY_Z, Keyboard.KEY_C};
/** This stores all the keybindings, but they must first be initialized */
public static final KeyBinding[] keys = new KeyBinding[desc.length];
/** Initializes keybindings and registers a new KeyHandler instance */
public static final void init()
{
// this way avoids declaring every key binding as its own 'static final' field
boolean[] repeat = new boolean[desc.length];
for (int i = 0; i < desc.length; ++i) {
keys[i] = new KeyBinding(desc[i], keyValues[i]);
repeat[i] = false;
}
KeyBindingRegistry.registerKeyBinding(new KeybindHandler(keys, repeat));
}
public KeybindHandler(KeyBinding[] keys, boolean[] repeat) { super(keys, repeat); }
public static byte key;
public static boolean[] repeat;
@Override
public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat) {
if (tickEnd)
{
if (kb.keyCode == keys[SpeedUp].keyCode) { key = SpeedUp; }
else if (kb.keyCode == keys[SlowDown].keyCode) { key = SlowDown; }
EntityClientPlayerMP player = FMLClientHandler.instance().getClient().thePlayer;
player.sendQueue.addToSendQueue(PacketKeyPress.getPacket((byte)(key)));
}
}
@Override
public String getLabel() {
// TODO Auto-generated method stub
return null;
}
@Override
public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd) {
// TODO Auto-generated method stub
}
@Override
public EnumSet<TickType> ticks() {
// TODO Auto-generated method stub
return null;
}
}
Yeah, sorry, didn't even see that one, I think I got it all correct now, but I can't test it, because the keys won't work or appear in the controls, even though I registered the keyhandler, but don't I need to register it in the main class somehow?
The way I've done it, the keybindings get registered in the 'init()' method, but that means you have to call the init method from either your ClientProxy (best because it's automatically only called on the client side) or somewhere in your main class (in which case you have to put a check if the side is client or you will crash when you load your mod on a server).
Since it's a static method, just type 'KeybindHandler.init()' wherever you decide to place it.
I have managed to get the name to change now but having problems with checking what the xp value is before setting it.
public class ModEventHandler {
ExtendedPlayer extendedPlayer = null;
public void load(FMLInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(new ModEventHandler());
}
}
Getting no errors so unsure what is going wrong, the xp is being added and stored correctly.
The line here 'ExtendedPlayer extendedPlayer = null;' you need to get rid of that. Extended properties needs to be retrieved each and every time for the player involved in an event; it can not be stored as a member variable of your event handling class (not to mention there is only ONE instance of your event handling class for ALL players).
So with that in mind, you should see why in your name format event it's not displaying things correctly.
yeah changing to static was a bad idea, the value is no longer kept after shutting down the game.
Yeah terrible idea xD Take a look at all the examples I gave of using extended properties. Do you ever see me using it statically? How am I using it that's different from how you're using it in the PlayerEvent.NameFormat event specifically? Just compare your use of ExtendedPlayer in that event to your use of it in all the other events and you should see what you're doing wrong.
The extra data you add using IExtendedEntityProperties is stored in that class, which saves the data to the player's NBT. You really need to understand how classes work in order to understand what that means, though. Each player in Minecraft has their own instance of EntityPlayer, and when you add extended properties, each player will have their own instance of the IExtendedEntityProperties class that you made. So when you declare a class member 'static', you're changing it from having a unique instance for each member of the class to having only ONE instance for ALL members of the class.
P.S. If you're going to post your code, could you please remove all the comments left in from the tutorial? It makes it harder to read, thanks!
Sigh, why can these things never work properly... D:.
It is all working perfectly in single player, but on multiplayer, the chat message is not changed (although a [1] is displayed next to the players name), and gaining xp does not seem to do anything, if the player logs in and out, or if the server is even restarted, they stay on level 1.
edit: After some playing around I have worked out it is actually storing the value correctly, but it is not displaying the name properly at all.
Ie I added an item to directly tell me my current xp, current xp is 99999 yet still displays me as level 1.
But at the same time it is working out to display the [1] over the players head yet not in the chat...
I don't understand how it can grab the [1], despite having saved the xp value of the player.
That's because the information about your level is stored on the server, and you need to synchronize that data on the client in order to display it properly. Please check in the tutorial, specifically section 3.3 about Gui, as it covers this issue in detail.
Btw, you realize that you are checking every single 'if' statement every single time the NameFormat event is called, right? And it's called every single render tick, which is a lot. You should really figure out a better way to do that; even just turning the order around so you start at the highest level and chain else-ifs would be better than the current setup.
I followed the tutorial in 3.3, got no errors but still got the same problem.
The code you had was throwing errors, and (cpw.mods.fml.common.network.Player) player1); was eclipses recommended fix, could well be causing issues.
The code I have does not have any errors, the errors come from randomly spamming copy / paste into your project. You need to slow down here buddy, take the time to read and understand what's going on, not just smash it into your code and expect it to magically work. There are so many things going on in there I don't even know where to begin, so my best advice to you is to start your ExtendedPlayer and all related class from scratch. Just scrap what you have now and start fresh, this time without using any copy / paste.
Furthermore, and I know this is said a lot and often met with derision, but you would do yourself a huge favor by learning more about Java. This post has some excellent links for just that purpose. It will help you avoid things like '(cpw.mods.fml.common.network.Player) player1)'.
Ok I went through a lot more carefully and rewrote and fixed a lot of stuff, also read that packet handling page properly. That common.network thing was due to importing the wrong "player" for a start.
Now my Package Handler is working, and I am getting the message about the sync working when run in eclipse, yet still getting the same result on a live server as before, and no message in the log.
Is your mod loaded on this live server, or are you only running your mod on your computer? In Eclipse, you can test your mod's multiplayer compatibility out by clicking the black down arrow next to the green 'run' button; this should open a drop-down menu. Run 'Server' first, then when it's ready, run 'Client'. Now you are simulating how your mod will run on a server that has your mod installed; try that and see if the message still doesn't show up.
The other possibility is that you just forgot to look in the wrong section of the console... When running the server and client from Eclipse, the console output is split into two sections, so if you're not looking in the 'server' tab of the console, you won't see your message. Likewise, when you log on to a server, you will not be getting server side messages printing in your client console. An easy way around this is to use player.addChatMessage(string) instead of System.out.println. You should get a message with your current xp if you do that.
One thing I am still confused about here, in the Packet Handling tutorial and in the code that seems to work, I have to use isServer(), but you use isServer without the () after it.
That's a typo on my part It's actually more efficient to use the player's world object, since we already have a player. Using the FML handler to get side is an expensive operation, but I wrote this tutorial when I was still mostly learning about packets myself.
And I am aware that my java knowledge is poor :/, this stuff I have got into here seems beyond me honestly. I am reading through lots of tutorials in general all the time, just it never touches on problems like this.
We all start somewhere, just keep at it. As your general knowledge of Java increases, you'll find that you are able to figure out more specific cases like this on your own, though I must admit, Minecraft code can be pretty quirky, especially the network side of it.
Hmm I tried loading up the server eclipse version, and did not get the message.
When I loaded up just the client one, I do get the message however.
Even weirder however, is that the [1] showed up in the chat while still in eclipse... Despite the message not being shown
You have to look in the server log, not the client console. There should be a server window that opens up, like it's own application, and that is where the server log is.
So, I think I finally have everything figured out with the packet handling, but for some reason the variable I'm using to see if the key was pressed isn't...
private void handlePacketKeyPress(Packet250CustomPayload packet1, Player player, DataInputStream inputStream)
{
byte key;
try {
key = inputStream.readByte();
} catch (IOException e) {
e.printStackTrace();
return;
}
switch (key) {
case KeybindHandler.SpeedUp: keypressed1 = true; System.out.println("this worked"); break;
case KeybindHandler.SlowDown: keypressed2 = true; System.out.println("this worked too"); break;
//this much is working, because the lines print, but the variable is not changing or the playerTick method isn't reading it for some reason?
}
}
Edit: I know that I need to set the keypressed variables back to false afterwards, but since they aren't working at all I figured I should get that first.
So, I think I finally have everything figured out with the packet handling, but for some reason the variable I'm using to see if the key was pressed isn't...
Try changing "if(PacketHandler.keypressed1 = true)" to "if(PacketHandler.keypressed1 == true)"
Then are you sure your tick handler is even working? Put a println outside of any 'if' statements and see if that prints.
no it didn't, which is weird because I have it registered, and it was working not too long ago..
@EventHandler // used in 1.6.2
public void load(FMLInitializationEvent event) {
TickRegistry.registerTickHandler(new PlayerTickHandler(EnumSet.of(TickType.PLAYER)), Side.SERVER);
no it didn't, which is weird because I have it registered, and it was working not too long ago..
@EventHandler // used in 1.6.2
public void load(FMLInitializationEvent event) {
TickRegistry.registerTickHandler(new PlayerTickHandler(EnumSet.of(TickType.PLAYER)), Side.SERVER);
That looks correct; my other guess is you changed the method signature without realizing it:
// this is what you have:
public static void playerTick(EntityPlayer player) { }
// if you put @Override above that, does it get highlighted in red?
I don't think that method should be static. But without looking, I may be wrong
It gets highlighted in red even without the static, I'm confused, this is the whole code for the tickhandler.
public class PlayerTickHandler implements ITickHandler
{
private final EnumSet<TickType> ticksToGet;
/*
* This Tick Handler will fire for whatever TickType's you construct and register it with.
*/
public PlayerTickHandler(EnumSet<TickType> ticksToGet)
{
this.ticksToGet = ticksToGet;
}
/*
* I suggest putting all your tick Logic in EITHER of these, but staying in one
*/
@Override
public void tickStart(EnumSet<TickType> type, Object... tickData)
{
if (FMLCommonHandler.instance().getEffectiveSide().isClient()){
playerTick((EntityPlayer)tickData[0]);
}
}
@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData)
{
}
@Override
public EnumSet<TickType> ticks()
{
return ticksToGet;
}
@Override
public String getLabel()
{
return "AfgPlayerTick";
}
@Override
public void playerTick(EntityPlayer player)
{ System.out.println("Heyheyehey");
if(PacketHandler.keypressed1 = true)
{
AfgExtendedPlayer props = AfgExtendedPlayer.get(player);
props.plusCurrentSS(.1F);
System.out.println("CurrentSS: " + props.getCurrentSS());
}
if(PacketHandler.keypressed2 = true)
{
AfgExtendedPlayer props = AfgExtendedPlayer.get(player);
props.minusCurrentSS(.1F);
System.out.println("CurrentSS: " + props.getCurrentSS());
}
}
}
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumOk, so first off, a method name should never begin with a capital letter.
Secondly, I recommend you to name the method in a way that reminds you of the event it will be handling, and that event MUST be the parameter. In your case, you are off to the right start with your name, but then your parameter is 'LivingUpdateEvent' which is totally unrelated to the event you want.
Finally, whenever you want to set a value, either 'ctrl-click' the relevant class to see what member variables are available to you, or type in the name of the instance you have of that class, followed by a period '.' and a menu should pop up listing everything available.
// here's an example of a properly formatted, descriptive name; see how the parameter matches the method name? @ForgeSubscribe public void onNameFormat(PlayerEvent.NameFormat event) { // here, we have an instance of the PlayerEvent.NameFormat class, and that instance is named 'event' // type 'event' and then period '.' and see what comes up // alternatively, ctrl-click on 'NameFormat' to open up the class, then use the outline (right-hand pane in Eclipse) to easily see what's available }public class PacketHandler implements IPacketHandler { public static final byte PACKET_KEY_PRESS = 1; @Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { if (packet.channel.equals("speedchannel")) { handleExtendedProperties(packet, player); } } private void handleExtendedProperties(Packet250CustomPayload packet, Player player) { DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data)); AfgExtendedPlayer props = AfgExtendedPlayer.get((EntityPlayer) player); try { props.setMaxSS(inputStream.readFloat()); props.setCurrentSS(inputStream.readFloat()); } catch (IOException e) { e.printStackTrace(); return; } System.out.println("[PACKET] Speed from packet: " + props.getCurrentSS() + "/" + props.getMaxSS()); if (packet.channel.equals("speedchannel")){ DataInputStream inputStream2 = new DataInputStream(new ByteArrayInputStream(packet.data)); byte packetType; try { packetType = inputStream.readByte(); } catch (IOException e) { e.printStackTrace(); return; } } } private void handlePacketKeyPress(Packet250CustomPayload packet, EntityPlayer player, DataInputStream inputStream) { byte key; try { key = inputStream.readByte(); } catch (IOException e) { e.printStackTrace(); return; } switch (key) { case Keyboard.KEY_RBRACKET: System.out.println("Wow, it actually worked"); break; } } }The Packet
public class PacketKeyPress { public static Packet250CustomPayload getPacket(byte key) { ByteArrayOutputStream bos = new ByteArrayOutputStream(2); DataOutputStream outputStream = new DataOutputStream(bos); try { outputStream.writeByte(PacketHandler.PACKET_KEY_PRESS); outputStream.writeByte(key); } catch (Exception ex) { ex.printStackTrace(); } return new Packet250CustomPayload("newspeedchannel", bos.toByteArray()); } }Keydown method
public KeybindHandler(KeyBinding[] keys, boolean[] repeat) { super(keys, repeat); } @Override public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat) { if (tickEnd) { EntityClientPlayerMP player = FMLClientHandler.instance().getClient().thePlayer; if (kb.keyCode == keys[KEY_CUSTOM_1].keyCode) { player.sendQueue.addToSendQueue(PacketKeyPress.getPacket((byte)(kb.keyCode))); } else if (kb.keyCode == keys[KEY_CUSTOM_2].keyCode) { player.sendQueue.addToSendQueue(PacketKeyPress.getPacket((byte)(kb.keyCode))); // do something else-
View User Profile
-
View Posts
-
Send Message
Curse PremiumPlease read my above post more carefully; the things you did differently are the things causing it to not work.
EDIT: Also, in your onPacketData method, you only ever call 'handleExtendedProperties', so EVERY packet you send will be handled the same, which is not what you want. That's actually the source of your error, although you other things are wrong as well like I mentioned just above.
Yeah, sorry, didn't even see that one, I think I got it all correct now, but I can't test it, because the keys won't work or appear in the controls, even though I registered the keyhandler, but don't I need to register it in the main class somehow?
Keyhandler
@SideOnly(Side.CLIENT) public class KeybindHandler extends KeyHandler { /** Key index for easy handling and retrieval of keys and key descriptions */ public static final byte SpeedUp = 0, SlowDown = 1; /** Key descriptions - this is what the player sees when changing key bindings in-game */ public static final String[] desc = {"Description 1","Description 2"}; /** Default key values */ private static final int[] keyValues = {Keyboard.KEY_Z, Keyboard.KEY_C}; /** This stores all the keybindings, but they must first be initialized */ public static final KeyBinding[] keys = new KeyBinding[desc.length]; /** Initializes keybindings and registers a new KeyHandler instance */ public static final void init() { // this way avoids declaring every key binding as its own 'static final' field boolean[] repeat = new boolean[desc.length]; for (int i = 0; i < desc.length; ++i) { keys[i] = new KeyBinding(desc[i], keyValues[i]); repeat[i] = false; } KeyBindingRegistry.registerKeyBinding(new KeybindHandler(keys, repeat)); } public KeybindHandler(KeyBinding[] keys, boolean[] repeat) { super(keys, repeat); } public static byte key; public static boolean[] repeat; @Override public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat) { if (tickEnd) { if (kb.keyCode == keys[SpeedUp].keyCode) { key = SpeedUp; } else if (kb.keyCode == keys[SlowDown].keyCode) { key = SlowDown; } EntityClientPlayerMP player = FMLClientHandler.instance().getClient().thePlayer; player.sendQueue.addToSendQueue(PacketKeyPress.getPacket((byte)(key))); } } @Override public String getLabel() { // TODO Auto-generated method stub return null; } @Override public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd) { // TODO Auto-generated method stub } @Override public EnumSet<TickType> ticks() { // TODO Auto-generated method stub return null; } }-
View User Profile
-
View Posts
-
Send Message
Curse PremiumThe way I've done it, the keybindings get registered in the 'init()' method, but that means you have to call the init method from either your ClientProxy (best because it's automatically only called on the client side) or somewhere in your main class (in which case you have to put a check if the side is client or you will crash when you load your mod on a server).
Since it's a static method, just type 'KeybindHandler.init()' wherever you decide to place it.
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumThe line here 'ExtendedPlayer extendedPlayer = null;' you need to get rid of that. Extended properties needs to be retrieved each and every time for the player involved in an event; it can not be stored as a member variable of your event handling class (not to mention there is only ONE instance of your event handling class for ALL players).
So with that in mind, you should see why in your name format event it's not displaying things correctly.
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumYeah terrible idea xD Take a look at all the examples I gave of using extended properties. Do you ever see me using it statically? How am I using it that's different from how you're using it in the PlayerEvent.NameFormat event specifically? Just compare your use of ExtendedPlayer in that event to your use of it in all the other events and you should see what you're doing wrong.
The extra data you add using IExtendedEntityProperties is stored in that class, which saves the data to the player's NBT. You really need to understand how classes work in order to understand what that means, though. Each player in Minecraft has their own instance of EntityPlayer, and when you add extended properties, each player will have their own instance of the IExtendedEntityProperties class that you made. So when you declare a class member 'static', you're changing it from having a unique instance for each member of the class to having only ONE instance for ALL members of the class.
P.S. If you're going to post your code, could you please remove all the comments left in from the tutorial? It makes it harder to read, thanks!
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumThat's because the information about your level is stored on the server, and you need to synchronize that data on the client in order to display it properly. Please check in the tutorial, specifically section 3.3 about Gui, as it covers this issue in detail.
Btw, you realize that you are checking every single 'if' statement every single time the NameFormat event is called, right? And it's called every single render tick, which is a lot. You should really figure out a better way to do that; even just turning the order around so you start at the highest level and chain else-ifs would be better than the current setup.
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumThe code I have does not have any errors, the errors come from randomly spamming copy / paste into your project. You need to slow down here buddy, take the time to read and understand what's going on, not just smash it into your code and expect it to magically work. There are so many things going on in there I don't even know where to begin, so my best advice to you is to start your ExtendedPlayer and all related class from scratch. Just scrap what you have now and start fresh, this time without using any copy / paste.
Furthermore, and I know this is said a lot and often met with derision, but you would do yourself a huge favor by learning more about Java. This post has some excellent links for just that purpose. It will help you avoid things like '(cpw.mods.fml.common.network.Player) player1)'.
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumThere you go! Nice work xD
Is your mod loaded on this live server, or are you only running your mod on your computer? In Eclipse, you can test your mod's multiplayer compatibility out by clicking the black down arrow next to the green 'run' button; this should open a drop-down menu. Run 'Server' first, then when it's ready, run 'Client'. Now you are simulating how your mod will run on a server that has your mod installed; try that and see if the message still doesn't show up.
The other possibility is that you just forgot to look in the wrong section of the console... When running the server and client from Eclipse, the console output is split into two sections, so if you're not looking in the 'server' tab of the console, you won't see your message. Likewise, when you log on to a server, you will not be getting server side messages printing in your client console. An easy way around this is to use player.addChatMessage(string) instead of System.out.println. You should get a message with your current xp if you do that.
That's a typo on my part
We all start somewhere, just keep at it. As your general knowledge of Java increases, you'll find that you are able to figure out more specific cases like this on your own, though I must admit, Minecraft code can be pretty quirky, especially the network side of it.
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumYou have to look in the server log, not the client console. There should be a server window that opens up, like it's own application, and that is where the server log is.
private void handlePacketKeyPress(Packet250CustomPayload packet1, Player player, DataInputStream inputStream) { byte key; try { key = inputStream.readByte(); } catch (IOException e) { e.printStackTrace(); return; } switch (key) { case KeybindHandler.SpeedUp: keypressed1 = true; System.out.println("this worked"); break; case KeybindHandler.SlowDown: keypressed2 = true; System.out.println("this worked too"); break; //this much is working, because the lines print, but the variable is not changing or the playerTick method isn't reading it for some reason? } }playerTick Method
public static void playerTick(EntityPlayer player) { if(PacketHandler.keypressed1 = true) { AfgExtendedPlayer props = AfgExtendedPlayer.get(player); props.plusCurrentSS(.1F); System.out.println("CurrentSS: " + props.getCurrentSS()); } if(PacketHandler.keypressed2 = true) { AfgExtendedPlayer props = AfgExtendedPlayer.get(player); props.minusCurrentSS(.1F); System.out.println("CurrentSS: " + props.getCurrentSS()); }-
View User Profile
-
View Posts
-
Send Message
Curse PremiumTry changing "if(PacketHandler.keypressed1 = true)" to "if(PacketHandler.keypressed1 == true)"
nope, didn't work
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumThen are you sure your tick handler is even working? Put a println outside of any 'if' statements and see if that prints.
@EventHandler // used in 1.6.2 public void load(FMLInitializationEvent event) { TickRegistry.registerTickHandler(new PlayerTickHandler(EnumSet.of(TickType.PLAYER)), Side.SERVER);-
View User Profile
-
View Posts
-
Send Message
Curse PremiumThat looks correct; my other guess is you changed the method signature without realizing it:
// this is what you have: public static void playerTick(EntityPlayer player) { } // if you put @Override above that, does it get highlighted in red?I don't think that method should be static. But without looking, I may be wrong
public class PlayerTickHandler implements ITickHandler { private final EnumSet<TickType> ticksToGet; /* * This Tick Handler will fire for whatever TickType's you construct and register it with. */ public PlayerTickHandler(EnumSet<TickType> ticksToGet) { this.ticksToGet = ticksToGet; } /* * I suggest putting all your tick Logic in EITHER of these, but staying in one */ @Override public void tickStart(EnumSet<TickType> type, Object... tickData) { if (FMLCommonHandler.instance().getEffectiveSide().isClient()){ playerTick((EntityPlayer)tickData[0]); } } @Override public void tickEnd(EnumSet<TickType> type, Object... tickData) { } @Override public EnumSet<TickType> ticks() { return ticksToGet; } @Override public String getLabel() { return "AfgPlayerTick"; } @Override public void playerTick(EntityPlayer player) { System.out.println("Heyheyehey"); if(PacketHandler.keypressed1 = true) { AfgExtendedPlayer props = AfgExtendedPlayer.get(player); props.plusCurrentSS(.1F); System.out.println("CurrentSS: " + props.getCurrentSS()); } if(PacketHandler.keypressed2 = true) { AfgExtendedPlayer props = AfgExtendedPlayer.get(player); props.minusCurrentSS(.1F); System.out.println("CurrentSS: " + props.getCurrentSS()); } } }-
View User Profile
-
View Posts
-
Send Message
Curse PremiumThat means it's not an inherited method - just leave off the @Override (and don't make it static either).
Your problem is you're getting server ticks, and take a look in your tickStart method:
@Override public void tickStart(EnumSet<TickType> type, Object... tickData) { if (FMLCommonHandler.instance().getEffectiveSide().isClient()){ playerTick((EntityPlayer)tickData[0]); }See anything in there that might never return true when you're ticking on the server?