Posts by Bamse

A new update (0.9.3) is available now!

    Nice.


    But if understand that speed parameter is a server config parameter? It will affect speed of all vehicles? Ideally for this use cases i really love to can modify speed without affecting all vehicle normal behavior. Maybe method can get a more parameter like speedFactor, beside adaptToSurface? This way we can move for example twice as fast a vehicle (boat in this case) with a factor 2 or at half speed with a factor 0.5 compared with standard speed. This will be really wonderful! For example in my current implementation i don't move (teleport) boat at same speed along route, i have 3 phases:

    - acceleration (0-25% of route) where boat start moving more quick

    - cruise (25%-75%) where boat move at constant maximum speed

    - deceleration (75%-100%) where boat start to slow speed till stop

    A variable speed factor for moveTo() method it will help a lot this type of use case!

    And another question MoveTo will have only (x,z) coordinates or (x,y,z)? I suppose is first case and for y adapt by water/terrain?


    Thx

    Hey, that's a good point! Currently the waves are not taken into account, so setPosition() would still work, but it would cause the boat to temporarily hover above water or submerge. The API will provide a method to calculate the wave height at a specific location, but this will only help if you call vehicle.setPosition() very often (providing the final water position which also takes the waves into account)...


    We could change the setPosition() method to take waves into account automatically, but I'm not sure if that would be a good idea... right now this method allows you to set an arbitrary position (you can even set a position on land or in the air). Maybe a new "setPositionOnWater()" method would be better in this case? :thinking:


    Or maybe we change setPosition() to teleport a vehicle instantly, and add a new "moveTo()" method (which optionally takes waves into account)? This could be a cleaner solution... IMO the current behaviour isn't very intuitive anyway (I'd expect a vehicle to move to a new position instantly when calling setPosition())... the "moveTo" method could then get a few parameters, e.g. to determine if the boat should automatically adapt to waves or if a player should still be able to take control over the boat. Maybe that would be the best solution? ^^


    I like vehicle.setPositionOnWater(x,z) if that take in account wave position.

    But vehicle.moveOnWaterTo(x,z,adaptWave==true) with additional parameters don't sound bad. It can work for example to do last step to "normalize" position of boat with wave.

    Hi!


    With upcoming update very close and with "The next update will definitely introduce true ocean waves (including new boat behaviour of course)" i wonder if API is ready to handle the following scenario:

    I use a plugin to make a boat to follow automatic route (Ferry Travel). This internally is handled by moving (teleport) the boat along some predefined route (points defined by x,z coordinate). For y axis (water level) is more ore less around 90 (depend on boat type - rowboat, sailboat, have different values).


    Now questions:

    - With new wave mechanic where water in a some point x,z will be dynamic (other than static 90) how i will determine correct height via API to know where to teleport a boat in a new point at surface of water?


    So wee need some sort of API to can calculate real height of water (with wave corrections) in some point x,z.

    Moreover this is not enough, because different boat size sink in water different depth (rowboat versus sailboat) so we need a real API function to obtain "correct" Z value so vehicle (rowboat,sailboat,etc.) can be teleported on valid,"naturally" point x,z at surface of water.


    Now i move vehicle with some code like:



    Current movement of rowboat is on flat water level. So first align vehicle to target and latter move. But with real wave ... i see this like more steps:

    - First align direction of vehicle to desired direction

    - Second move vehicle in new location

    - Last step normalize rotation (keeping aligned direction) to naturally fit current wave (this i think need to be addressed via API too!)


    red51 i hope you will take in account this API additions (if is not yet some method who can achieve this scope) for new release.


    Thx in advance!

    I don't know if is easy/performant to implement but will be wonderful to have some event like


    OnPleyerEnterBiome()

    OnPlayerLeaveBiome()


    For region i don't think is supper important because we already have OnEnterSector ...


    Thx.

    I do some experiment on crossing border around 0,0 with a mix of differently sector type. My conclusion is:

    - close to border line of a sector, a biome from a region (example grass from Default/Ocean) can extend in neighbor sector for some blocks and are not cut along border line.


    So is unreliable to read biome on sector enter to get region type because that cross border biome overlaps. Inside sector at some distance from margin of sector data is accurate.


    Maybe a quick fix to detect on what type of sector enter is to read data not from chunk just entered sector, but from a chunk close to middle of sector and from that data to conclude what type of sector is it:

    - Default/ocean

    - Dry

    - Cold


    I make some function who work this way when enter some sector:

    1. Read data from table Sectors from Chunks.db

    2. if sector is here, sector have some chunks modified, already visited and from column region read exact sector type

    3. if not here, you entered a new sector, read a sample chunk for example from middle of that sector, read a biome from here and determine sector type.


    Maybe red51 will expose via API, sector type!

    Maybe region type can be read directly from table Sectors from Chunks.db


    But this work only for a changed sector (have at least one chunk altered and saved in db)! If you just enter a new sector and don't modify anything, sector data is not write on this table before any chunk is modified.



    Here my -1,-1 sector is a Arid/Dessert.


    After some override of a sector, i see values for column region:


    1 - Default

    2 - Ocean

    3 - Arid

    4 - Cold

    Ah, so you don't want to detect particular biome but whole type of region aka sector type (Default-Ocean / Dry / Cold)?



    Hmm maybe time when check event? i suppose you check on PlayerEnterSectorEvent ? If so, if read player position still on chunk of old sector? maybe use position of chunk from getNewPlayerPosition() and not chunk from actual player. I think Event PlayerEnterSectorEvent occur before enter sector.


    Note: Probable not that is cause. See following posts about overlap biome along border of sectors.

    I test it with some locations and always get same things as in F3 Info.





    Not sure what is wrong for you!


    I just use something like :


    Hi.


    I used bellow code to get a biome.

    So if i suppose correct, a code between

    - 1 and 49 is a Default (or Ocean) region

    - 50 and 99 is a Cold region

    - 100 -149 is a Arid region


    BTW:

    In same chunk you can have differently biome for each block position. In old java game i think biome was tied to whole chunk, not individual block positions from chunk?

    About shearing sheeps, basically this is handled by PlayerNpcInteractionEvent, but I just realized that this is way too limited... this definitely needs some better handling which provides more information about the actual interaction type. Right now it's triggered if you just press F, but it's also triggered when shearing sheeps etc. I will put this on my list (but I'm not sure if this will make it into the next hotfix)!

    Here i think about a more generic event like PlayerUseAction. This can be triggered basically when player use equipped item, like rope to leash, shear to shear a shep, knife to skin, knife on tanning rack, bucket to get milk, bucket to get water, etc. and maybe more like use on bread to get half bread, on melon to get slices, etc.

    I think on a long run the best is to threat them as metaobject, even if game not supplementary do some processing to them.
    On short term probable one enum with target will be very good to know exactly where item is placed (help in future too if other case will appear) and a getRelatedObjectDefinition() to can get definition (where item was placed in tanning rack or gramophone?) for sure is helpful.
    And second thing on item pickup (hide,leather,disk) can be do a fake event PlayerItemPickup (cancelable of course)? I see this event is not trigger at all for tanning rack. On place event is triggered, but on pickup no event.

    I don't see mention anywhere as issue is fixed, but after server update from yesterday, it seems new event PlayerPlaceItemEvent is fixed!


    I test with a few metaobjects:

    - Furnace - ok

    - drying rack - ok

    - oven - ok

    - grill - ok

    - skewer - ok

    - grinder - ok

    -paper press - ok


    But with tanning rack i encountered a new issue. I don't think is related with first one but same code who works for other station here give error because when i call method to retrieve definition of metaobject, return null if metaobject is a tanning rack!


    from log:


    Code
    [10:49:11] [ADMIN MESSAGE] (Notification) EXCEPTION OCCURRED IN PLUGIN 'TestRw' (AUTHOR: Bamse) <-- here i put a hide in tanning rack
    -> java.lang.NullPointerException: Cannot read field "name" because "def" is null
    at PLUGIN_CLASS_LOADER//bamse.rw.PermanentItemPlacement2.onPlayerPlaceItem(PermanentItemPlacement2.java:32)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    at java.base/java.lang.reflect.Method.invoke(Method.java:578)
    at net.jiw.unity.runtime.PluginEventHandler.triggerEvent(PluginEventHandler.java:138)
    16711680
    Object tanningrack (2060346) change info 0 -> 745



    Note (after more research):


    It seems tanning rack is a special object and not a metaobject? Maybe must threat same as a meta object? I can pickup hide from him and no event PlayerPickupItemEvent fired at all! (New event

    PlayerPlaceItemEvent is fired).

    So no way to know if item (hide or leather) is take from tanning rack or how to deny take item from him on some condition?


    Thx


    Bamse

    Hi


    First thx for adding this new event!


    Now i try to use but i hit some issue. For persistent item placement it work as expected, but it is a issue when try to add items on a metabject (furnace, grill). For example when i want to put ore in furnace, ore gone from inventory but on furnace don't appear nothing and i can put in same slot over and over new ore. If i don't use at all new event i can put items in metaobjects! it's like, with new event activated is canceled by default when put items in metaobjects!


    For testing purpose i use following code:


    From logs:


    Thx


    Bamse

    I tried to prevent baby animals pickup on some conditions, But i already solved with PlayerNpcInteractionEvent!


    About breeding of animals.


    So far i breed some cows, pigs and horses

    - For horse i always i get variant 0 (light brown) even mother are different variants.

    - For cow i always get same variant as mother


    So question is any got male version of adult from babies get from breeding? Or i was exceptionally unlucky and i got all babies as female variant when they grow, or is something wrong and no male from breeding? Some other player reported same thing, just female.