• 0

    posted a message on [Forge][1.6.4 - 1.8] EventHandler and IExtendedEntityProperties
    Huh, wonder why that was left there lol :P thanks for all the help man, seems to be working now.
    Posted in: Mapping and Modding Tutorials
  • 0

    posted a message on [Forge][1.6.4 - 1.8] EventHandler and IExtendedEntityProperties
    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());
    		 }
    }
    }

    Posted in: Mapping and Modding Tutorials
  • 0

    posted a message on [Forge][1.6.4 - 1.8] EventHandler and IExtendedEntityProperties
    Quote from coolAlias
    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);
    Posted in: Mapping and Modding Tutorials
  • 0

    posted a message on [Forge][1.6.4 - 1.8] EventHandler and IExtendedEntityProperties
    Quote from coolAlias

    Try changing "if(PacketHandler.keypressed1 = true)" to "if(PacketHandler.keypressed1 == true)"

    nope, didn't work
    Posted in: Mapping and Modding Tutorials
  • 0

    posted a message on [Forge][1.6.4 - 1.8] EventHandler and IExtendedEntityProperties
    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?
    }
    }


    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());
             }

    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.
    Posted in: Mapping and Modding Tutorials
  • 0

    posted a message on [Forge][1.6.4 - 1.8] EventHandler and IExtendedEntityProperties
    Quote from coolAlias

    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;
    }
    }

    Posted in: Mapping and Modding Tutorials
  • 0

    posted a message on [Forge][1.6.4 - 1.8] EventHandler and IExtendedEntityProperties
    PacketHandler

    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

    Posted in: Mapping and Modding Tutorials
  • 0

    posted a message on [Forge][1.6.4 - 1.8] EventHandler and IExtendedEntityProperties
    Quote from coolAlias

    --snip--

    Well, I think I got that to work, but for some reason I'm getting this error on world startup and when joining a server:

    2013-12-24 18:17:06 [INFO] [STDERR] java.io.EOFException
    2013-12-24 18:17:06 [INFO] [STDERR] at java.io.DataInputStream.readByte(Unknown Source)
    2013-12-24 18:17:06 [INFO] [STDERR] at afg.flash.PacketHandler.handleExtendedProperties(PacketHandler.java:46)
    2013-12-24 18:17:06 [INFO] [STDERR] at afg.flash.PacketHandler.onPacketData(PacketHandler.java:23)
    2013-12-24 18:17:06 [INFO] [STDERR] at cpw.mods.fml.common.network.NetworkRegistry.handlePacket(NetworkRegistry.java:255)
    2013-12-24 18:17:06 [INFO] [STDERR] at cpw.mods.fml.common.network.NetworkRegistry.handleCustomPacket(NetworkRegistry.java:245)
    2013-12-24 18:17:06 [INFO] [STDERR] at cpw.mods.fml.common.network.FMLNetworkHandler.handlePacket250Packet(FMLNetworkHandler.java:85)
    2013-12-24 18:17:06 [INFO] [STDERR] at net.minecraft.client.multiplayer.NetClientHandler.handleCustomPayload(NetClientHandler.java:1651)
    2013-12-24 18:17:06 [INFO] [STDERR] at net.minecraft.network.packet.Packet250CustomPayload.processPacket(Packet250CustomPayload.java:70)
    2013-12-24 18:17:06 [INFO] [STDERR] at net.minecraft.network.MemoryConnection.processReadPackets(MemoryConnection.java:89)
    2013-12-24 18:17:06 [INFO] [STDERR] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1967)
    2013-12-24 18:17:06 [INFO] [STDERR] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:910)
    2013-12-24 18:17:06 [INFO] [STDERR] at net.minecraft.client.Minecraft.run(Minecraft.java:838)
    2013-12-24 18:17:06 [INFO] [STDERR] at net.minecraft.client.main.Main.main(Main.java:93)
    2013-12-24 18:17:06 [INFO] [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2013-12-24 18:17:06 [INFO] [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    2013-12-24 18:17:06 [INFO] [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    2013-12-24 18:17:06 [INFO] [STDERR] at java.lang.reflect.Method.invoke(Unknown Source)
    2013-12-24 18:17:06 [INFO] [STDERR] at net.minecraft.launchwrapper.Launch.launch(Launch.java:131)
    2013-12-24 18:17:06 [INFO] [STDERR] at net.minecraft.launchwrapper.Launch.main(Launch.java:27)
    I could really use some help, can give you some of the code if that would help at all, which classes would you need?
    Posted in: Mapping and Modding Tutorials
  • 0

    posted a message on [Forge][1.6.4 - 1.8] EventHandler and IExtendedEntityProperties
    Sorry, I guess I wasn't that clear, what I mean was in this part in the packethandler:
    }
    switch (key) {
    case Keyboard.KEY_RBRACKET: System.out.println("This worked"); break;
    }

    what I have there doesn't seem to be working.
    Posted in: Mapping and Modding Tutorials
  • 0

    posted a message on [Forge][1.6.4 - 1.8] EventHandler and IExtendedEntityProperties
    So, one last question for you, and in hindsight I should probably put this in the keybinding tutorial page but oh well, I'm already writing it, so in your comment there you showed a better way to do multiple keybindings which helped a lot, but if I'm correct that has the keymap on the keybinding class, which the server can't access, so when you send a packet, how does the server know what key was pressed?

    I'm also confused on this line in the example packet you listed(specifically ModInfo.CHANNEL), is it specific to your mod or am I missing something?:
    return new Packet250CustomPayload(ModInfo.CHANNEL, bos.toByteArray());
    Posted in: Mapping and Modding Tutorials
  • 0

    posted a message on [Forge][1.6.4 - 1.8] EventHandler and IExtendedEntityProperties
    Got another error, this time in the packet handling portion of the gui tutorial, at these lines it's saying .isServer cannot be resolved or is not a field, but I can see it clearly in the Side.java class, really confusing me.

    if (FMLCommonHandler.instance().getEffectiveSide()].isServer) {
    EntityPlayerMP player1 = (EntityPlayerMP) player;
    PacketDispatcher.sendPacketToPlayer(packet, (Player) player1);
    }


    EDIT: Nevermind, i feel really dumb now, just have to add a parenthesis...
    Posted in: Mapping and Modding Tutorials
  • 0

    posted a message on [Forge][1.6.4 - 1.8] EventHandler and IExtendedEntityProperties

    I'm attempting to follow your Tutorial, and I'm having a bit of trouble with the bit about keeping the value after death, specifically these lines.

    proxy.storeEntityData(((EntityPlayer) event.entity).username, playerData);

    // call our handy static one-liner to save custom data to the proxy

    PlayerValues.saveProxyData((EntityPlayer) event.entity);
    }

    wondering if you could give me any help, it's saying "proxy cannot be resolved" and "The method saveProxyData(EntityPlayer) is undefined for the type ExtendedPLayer"
    Posted in: Mapping and Modding Tutorials
  • 0

    posted a message on (Xeno's) Reliquary v1.0.6d
    Awh, I was really liking that I didn't have to make much more splash serum while i was making stuff. Oh well, more work for me :P
    Posted in: Minecraft Mods
  • 1

    posted a message on (Xeno's) Reliquary v1.0.6d
    I made an account just to say that there is 5 people :)
    Posted in: Minecraft Mods
  • To post a comment, please .