Jump to content

hydroflame

Members
  • Posts

    1511
  • Joined

  • Last visited

Posts posted by hydroflame

  1. hashmap are simply and purely overpowered...and also super easy to use

    see heres how a hashmap work:

     

    HashMap<Key, Storage> asd;

    Key and storage are 2 object (such as Block, ItemStack, String wtv )  //note if you want to store primitive, you have to use their Object, int -> Integer, float -> Float etc

     

    hashmap has a 0 argument constructor, you can use it

     

    now here is the beauty of it

     

    when placing stuff in a hashmap you will use the "put" method, it will require 1 Key and 1 Storage

    exemple; String, EntityPlayerMP

    hashMap.put("hydroflame", player);

     

    the hashmap will place in its own internal structure a way to find the variable player super quickly if you give it "hydroflame"

     

    you do thsi with the method "get(key)"

     

    ex:

    EntityPlayerMP player = playerMap.get("hydroflame");

     

    in your case you might want to do something like

     

    HashMap<Integer, Integer> smeltMap= new HashMap<Integer, Integer>();

    //first integer behing the item id, second behing the amount required to smelt

    //so you would add during construction of the smeltMap

    smeltMap(Item.iron.id, 9);//note it might not be this exact syntax

    //and then whenever someone put an item in your special furnace slot

    int id = theIdFromTheSlot();

    int qtyRequired = smeltMap.get(id);

    if(qtyInSlot >= qtyRequired){

        startSmelting();

    }

     

     

    Cheers, welcome to the beautifull world of hashMap

     

    -hydroflame, FRev-

  2. Hey guys,

     

    here's my problem, I have a certain block with a tile entity and a menu on right click to change some value on it. Since the menu is client side only, you would want the change to propagate to other player, but I'm not sure what is the correct way. I know that on server side you can call world.markBlockForUpdate(x, y, z) (or some method with similar name, I'm not in front of my code so I'm not sure)  and from there everything should take care of itself.

     

    so far my solution is to make a customload packet containing x, y, z of the tile entity and the change but when i arrive server side on the method "handle(manager, packet, player)" the only way I FOUND (I'm sort of hoping there's another method) to get to the world with the tile entity is to cast player as EntityPlayerMP and use the worldObj on it. BUT here's the problem, using this method, were expecting that the player will be in the same world as the Tile Entity when the packet is being processes and if for SOME reason the packet were to be processes much later and the player has had time to switch dimension. the change would not appear.

     

    At the moment its not a real problem. In my test the packets were always processes VERY quickly, but i know it's not a good thing that I'm relying on this.

     

    so my question is: does anyone know of a good reliable way to update tile entity from client to server to all client ?

     

    Thanks

     

    -hydroflame, FRev-

     

    extra:

    I research a bit into packet132TileEntityData and sending this kind of packet from client to server side will just kick the client. because server doesn't want these kind of packets.

  3. https://github.com/MinecraftForge/MinecraftForge/blob/master/patches/minecraft/net/minecraft/item/ItemInWorldManager.java.patch#L222

     

    well to start that thing doesn't work, tried to change it everytime a player logs in and respawn (IPlayerTracker) didnt change block reach, after that i tried changing the value directly (blockReachDistance)  didn't have any effect,

    also, i printed blockReachDistance and it was printing the right number, but i still had a range of ~4-5, am i missing something i need to change

     

    second, i tried following the call hierarchy of getBlockReachDistance, doesnt seem to intersect any code that defines entity interraction distance.

     

    -Olivier-

  4. hi just throwing the idea, it would be nice to be able to change the distance where player can interract with each other. like instead of behing ~5 block we could set it wtv we want

     

    why this could be fun

    spells: locking on target with fireballs, healing, lightning etc

    increase decrease melee range: for the lulz

    implement actual legit trade system between players by right clicking on them, or pressing a key(and set range activatable)

    mount animals from further/closer

     

    i know its doable its already implemented in my mod, but its pretty dirty, ill try to make a PR for it soon

     

    cheers

     

    ps:NOT talking about block reach distance but actual entity interraction distance

  5. im having the EXACT same problem, i have been able to see that its coming from either the Container, the TileEntity or both. So far i simply passed a ContainerChest to my block/tileentity/gui and the clicking problems seems to be solved. i need to investiate more so ill copy the whole ContainerChest into my custom Container and try to understand exactly how our code is causing the problem

     

    EDIT: it seems container have a certain area(on the screen) themselves, and clicking on a slot that is outside that area will insta-drop the item

     

    EDIT 2: i was right bout the slot behing "out of range of the gui" to fix it, make sur in your gui you resize the xSize and ySize of your gui to fit the length and width of your container placement, also modify guiLeft and guiTop if needed

  6. he'll need at least a onBlockPlacedEvent, who would add the coord and owner to the database, then he could use the PlayerInteractEvent to detect action.leftclickblock and cancel it if the owner of the owner of the block is not the same as the breaker (tcheck that by asking the database, wtv the kind of structure used) take note that youll need a faster response time depending on how many players are playing. more player mean it need to be faster. (at least fast enough to not create lag)

  7. if you need to do this for every vanilla block instead of changing every base class you could keep track of who owns what block in a data structure and cancel inapropriate action by tchecking in that datastructure if the owner of the block is the same as the one breaking  it. you will need a super efficient data structure thought (like the nbt)

  8. keepcalm, there are problems when you consider playerInteractEvent as a blockplaceevent or a block removeevent that cannot be fixed without creating the proper event by modifying the src. for exemple, if you cancel ALL right click block (like you were canceling all blockPlaced) you can still place blocks by spaming right click.

  9. unfortunately, forge standard doesnt have a OnBlockPlaced Event, yet you are lucky because i made those events a couple of weeks ago (just didnt do a pull request yet) so if you're interrested on those events, tell me i can send you the modified classes needed to use those events. also, for putting the "owner of a block, youll need to use a tile Entity. Look it up on the wiki tutorial its very well made and explain everything needed to be done.

  10. hello, im trying to add new elements to the inGameGui. im using a implementation of ITickHandler to do it. but when i render anything in the method tickStart the visual elements just blink very fast. its still possible to see them, but id like them to be still.

     

    you can see a video demonstration here:

     

    and here is the code used for rendering (inside ITickHandler.tickStart implementation)

     

    Minecraft.getMinecraft().fontRenderer.drawStringWithShadow("some string", 10, 10, 10000100);

  11. im my mod, i need to do stuff when the player places block and remove block (like canceling and giving exp). unfortunately the current PlayerInteractEvent will not filter if the block is actually destroyed or just left clicked. at the moment, my program is giving out exp even when the player only left click any block. The problem is, i cant use removeBlockByPlayer because i would then need a hook for that method for eeeeeveeery block in minecraft, so yeah... plz make a hook for these 3 events ? we would also fix this bug ->

    http://www.minecraftforge.net/forum/index.php/topic,3094.0.html

     

     

    or if you guys already have a solution id be happy to hear it :D

  12. hi, i came accross this weird bug where cancelled event wouldn't be processed before the next event and the 2nd event wouldn't be properly processed.

     

    the code is really simple (the one needed to reproduce the bug anyway):

     

    @ForgeSubscribe

    public void cancelAllBlockPlaced(PlayerInteractEvent event){

    if(event.action == event.Action.RIGHT_CLICK_BLOCK){

    event.setCanceled(true);

    }

    }

     

    so basicly this should stop ALL block from behing placed (as well as removing the possibility of using crafting table and other GUI block but that's not the point)

     

    but this code appears to be skipped when the players spam right click to place blocks

    example:

    p = player

    [] = empty block

     

    p[][][][]

    p[][][c][]

     

    when the player right click once on block 'c', the event is canceled correctly (nice :D)

    when the player spam r click the ground (not too fast), it makes a block appear and dissapear .

    finally, when the player right click at a fast enough speed, he can place a block on the canceled block (before it dissapear) and permanently place a new block

    ex:

     

    before:

    p[][][]

    p[][][]

     

    click 1:

    p[][][][]

    p[][][c][]

     

    click 2 (shortly after click 1):

    p[][][][]

    p[][c][c][]

     

    after forge cancel event 1:

    p[][][][]

    p[][c][][]

     

    anybody know why it does this and an easy way to fix this (beside adding the event to a thread and look if all event were canceled succefully/correctly)?

     

    thx in advance

×
×
  • Create New...

Important Information

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