Jump to content
Search In
  • More options...
Find results that contain...
Find results in...


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About Slit_bodmod

  • Rank
    Tree Puncher

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hey I was wondering how if say you had a particular nbt file you wanted to be compiled with your mod in the data folder, how I could then read that file from the mod's resources in code, and if it's automatically checked whether it's overridden by datapacks that match that paticular file structure, and if not how you can do that?
  2. Ok cool, I changed it to something like this: public InteriorStyle getIntStyle() { try { tardis_lock.readLock().lock(); InteriorStyle ret_style = int_style; return ret_style; } finally { tardis_lock.readLock().unlock(); } } if there is any lock you would recommend over ReentrantReadWriteLock I'd be happy to use that, other wise you have been super helpful and I am very grateful
  3. Ok so I the version I am currently using looks a bit like this. I still have something that looks like this in order to pull a TardisManager. public static final Map<World,TardisManager> INSTANCES = new MapMaker().weakKeys().makeMap(); and the TardisManager contains this map. private final ConcurrentHashMap<Integer,Tardis> ALL_TARDISES = new ConcurrentHashMap(); so I can then pull a tardis object, I then have some stuff that looks like this inside of the Tardis class private ReentrantReadWriteLock tardis_lock; public InteriorStyle int_style; public InteriorS
  4. Yeah maybe it would be a better idea to have a separate immutable struct inside of my TardisManager.Tardis called TardisGenerationInfo or something that was always written in a thread safe way and was the only thing that the chunk generator was allowed to read from. So the reference to tardisManager is gotten through a ConcurrentMap, as well as the reference to the specific Tardis. so maybe this new object is stored in a separate hash map, or a reference to it can only be used from within the Tardis data structure and contains basically an immutable structure that be accesed by the chunk
  5. yes but will it stop me getting thread issues when reading and writing to that hash map? right, I gather the best way to go about doing this is with getters and setters for every variable (aaargh), and also locking and unlocking the read locks at the start of all functions, does this include the constructors, I assume not. I assume I do at the start of my serialisation function. also am I right to assume that the syntax for the locks is: my_class_lock.readLock().lock() my_class_lock.readLock().unlock() my_class_lock.writeLock().lock() my_class_lock.writeLock().
  6. No, I think if I make the underlying data structure in my TardisManager using a MapMaker it will be fine. As for using the ReentrantReadWriteLock appropriately. I assume I should lock it at the beginning of the copy constructor and unlock it at the end. What impact will this have. when I read/write to the other fields in my data structure, I assume it won't automatically be safe, do they have lock it first and then write to the data strucuture?
  7. right, well the trouble with creating a copy on the main thread is that the data is going to be modified as the world is running, particularly from the overworld (seeing as this chunk generator is designed to work for a specific dimension). so ideally I need the data to be the most up to date the moment I create a new chunk. That being said if the data changes while the chunk is being generated (or preferably when the region is being generated), the main thread still needs to keep track of that but I don't want the chunk generator to have its copy changed. So getting a hold of the TardisM
  8. ah right, so the Tardis manager contains a few different get functions for different Tardises, will they all need to be synchronised, will this impact performance as it's only this one niece case where they need to be accessed by another thread. getTardisForBlock returns a TardisManager.Tardis. the constructor that takes for TardisManager.Tardis that takes in another TardisManager.Tardis is basically just a copy constructor that returns a new object with the same values for this thread to modify and read. in-fact the Tardis manager stores all instances of Tardis that the program ever
  9. Oh also that enum I was talking about. So the attribute I need from that is a structure Template stored as a const variable within each instance of an enum. It thus only gets written to when the class is first inited and doesn't get edited beyond that so is that thread safe? just for clarity, it's an enum that a reference to is stored in TardisManager.Tardis containing a constant field of type Template
  10. ok so obviously I have a line of code that says this public static final Map<World,TardisManager> INSTANCES = new MapMaker().weakKeys().makeMap(); then I have my init function that looks like this @SubscribeEvent public static void onWorldLoading(AttachCapabilitiesEvent<World> event) { World world = event.getObject(); DWMCMod.LOGGER.error("attaching capabilities"+world); if (world instanceof ServerWorld) { ServerWorld accessWorld = world.getServer().getWorld(DWMCDimensions.TARDIS_WORLD_KEY); TardisManager tardisManager = ge
  11. ok so would it work if I just put and get objects from my map as though everything was normal. and then once I've got my reference I need to write a synchronised method that will pull the data I need and return it to the chunk generator. (I'm only gonna need to pull one object so I think it would it be better for the synchronised function and return a deep copy?) Also how do I get the ServerWorld from the IWorld, there isn't a function defined called getLevel, nor any function that returns a ServerWorld as far as I can see.
  12. Hi sorry for late response, Ok so I should create a map<World,WorldSavedData> that when a World Capability is attached will thread lock, and add a mapping of that world to it's appropriate savedData Then in my chunk generator, using IWorld.getLevel() (on an instance ofc), I can look it up in the map and modify it at will, and if I ever do need to write to it for whatever reason I need to lock it first. If this is true what system would you recommend to keep the variables safe? Should I use a java Lock class for the functionality I stated above or make the map volatile or r
  13. yes there's a priority system, would your item work using a supplier as that's probably the best way to do it
  14. ok, thankyou that's very helpful. I have begun work implementing it and was wondering if I could ask a few questions? - Would the values of my map also want to be weak as I presumably am also storing in the way that WorldSavedData automatically does so I don't want a copy of it to be stored -Will the reference in my map remain a reference, there is a good chance that the main thread will change the contents of my WorldSavedData and Ideally the chunkGenerator should respond to these changes appropriately - I don't know much about the internal structure of the jvm threading but se
  15. well what kind of alternatives are there for having level saveable data that my chunk generator can use, is there a way for me to pass other parameters into the constructor. Or a way for me to send data of any kind across the two threads. Maybe by saving a copy of the data statically somewhere and setting up appropriate checks around it?
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.