Jump to content

coolAlias

Members
  • Posts

    2805
  • Joined

  • Last visited

Posts posted by coolAlias

  1. If that's still not working the only thing I can see that is different is I save the shooter's name to NBT:

    // save
    compound.setString("shooter", getShooter() instanceof EntityPlayer ? ((EntityPlayer) getShooter()).username : "");
    // load
    dataWatcher.updateObject(SHOOTER_DATAWATCHER_INDEX, compound.hasKey("shooter") ? compound.getString("shooter") : "");
    

  2. Thanks for this! I was wondering how to go about this. Turns out you can define multiple sounds in one line:

    "armorbreak": {"category": "player","sounds": ["armorbreak1", "armorbreak2", "armorbreak3", "armorbreak4"]}
    

    and then play them with just the registered string to get a randomized sound from within. Lots of cool stuff to learn in the vanilla sounds.json file. ;)

  3. Yeah, your packet / handling is not set up correctly to handle what you are trying to do, and you don't actually send any data with your packet...

    props.activeSpellID=1;
    

    That line is setting the value on the client side, when what you want to be doing is writing that data to the packet so it can be sent to the server. You will need to handle this packet separately from your other packet for extended properties, since the data it contains will be different.

  4. Also, link.

     

    One key point that I haven't yet included in that tutorial is that you need to be aware of which event bus your events are on, so you can register your handlers appropriately. You will need a separate handler for each event bus.

     

    TickEvents are part of cpw.mods.fml.common.gameevents, and have multiple types from which to choose (ClientTickEvent, ServerTickEvent, etc.). FML Events are registered like this:

    FMLCommonHandler.instance().bus().register(new YourFMLEventHandler());
    

     

    Most of the other events are in net.minecraftforge.event, as well as net.minecraftforge.client.event, and these are typically registered as follows:

    MinecraftForge.EVENT_BUS.register(new YourEventHandler());
    

    Some are registered instead to the TERRAIN_BUS, and yet others to the ORE_GEN_BUS, but most use the EVENT_BUS.

     

    Again, it's best to have a separate handler for each type that you need, and even to split up your handler into separate ones depending on usage if you find you have a lot of events.

     

    There doesn't seem to be any limit on the number you can register, though if you are listening to the same event in multiple handlers you will need to be extra careful that you are not conflicting with yourself.

  5. That is indeed what I was looking for, thank you. It still seems odd to me that it isn't included by default in the event as a class field, as well as either the buttonstate (which can be gotten from Keyboard as well) or something similar to the tick start / tick end.

     

    Guess I'm just spoiled by all the tools handed to us by the Forge team :P

  6. If you mean HUD, then check this: http://www.minecraftforge.net/wiki/Gui_Overlay

     

    It's a little outdated, but will work fine if you know just a little bit about what you are doing.

     

    Here also are two tutorials on using NBT, one in an Item, and one in a Block, but you can do the same pretty much anywhere you have access to something that will allow you to save NBT:

     

    http://www.minecraftforge.net/wiki/Item_nbt

     

    http://www.minecraftforge.net/wiki/How_to_use_NBT_Tag_Compound

  7. I'm updating my KeyBinding/Handling class using the KeyInputEvent, but the event has no fields for distinguishing which key was pressed or anything else for that matter.

     

    Does anyone know if it's planned to implement those features in the future, like they were previously in the KeyHandler class? Because having access to the KeyBinding pressed as well as tickStart or tickEnd was extremely useful... unless I'm missing the obvious again and it's in there somewhere?

  8. I register it in the ClientProxy, and yes, I really do want a render tick handler ;) I use it to modify the players movement more smoothly for certain effects, such as dodging, locking on to a target, etc.

     

    EDIT: After some more looking around, I found you can use ClientTickEvent as a more specific listener, while of course still checking for the correct type. Should be good enough xD

     

    EDIT 2: Derp. Just saw RenderTickEvent right under the client one... perfect!

  9. You are super helpful, thank you :D

     

    One more quick question: is there a way to make sure that I only listen to the RENDER type tick, other than the following? Basically what I'm getting at is before I registered my handler only on the client side, and I'm wondering if that is possible to do with the new setup.

     

    Thanks again for sharing your knowledge!

    @SubscribeEvent
    public void onRenderTick(TickEvent event) {
    if (event.type != Type.RENDER) {
    return;
    }
    // do stuff
    }
    

  10. Sure:

    @Override
    public void entityInit() {
    super.entityInit();
    dataWatcher.addObject(SHOOTER_DATAWATCHER_INDEX, "");
    }
    

    When you create your custom arrow using this method, though, you MUST call the 'setShooter(player)' method from earlier, as that is what updates the arrow's shooter:

    // should look something like this:
    EntityArrowCustom arrow = new EntityArrowCustom(world, player).setShooter(player);
    

×
×
  • Create New...

Important Information

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