#Error that is not an error
1 messages · Page 1 of 1 (latest)
Do some debugging. Find all MMs in the area and print out their mythic type and mobId to make sure they are detected propery.
already done this
in the code that i share there is Debug
Logger.log
The image is the prove of that
What did you find out?
So from what i can see
Collection<ActiveMob> mobsInRegion = regionManager.getMobsInsideRegion(regionID);
returns an empty collection, is that right?
The first "warning" is the RegionID, the 1st "info" is the mob in region, the 2d "info" is the playersinRegion, the 3rd "info" is the mobId, the 2d "warning" is the activeMobs collection, and the last "info" is the mob display name
yep
also this: Collection<ActiveMob> activeMobs = MythicBukkit.inst().getMobManager().getActiveMobs(am -> am.getMobType().equals(mobId));
If this is also empty, then the mob is simply not loaded at that time.
with one mob everything works smoothly, in this region and with this mob it does not work. However, the logic is the same
what should I do?
Make sure the chunks for this region are loded before you check them
How do I check whether the chunks are loaded or not
Just load them by calling World#getChunkAt(int, int)
Honestly im seeing quite a few loopholes in your code that can cause some problems.
But you will find them soon when testing further.
I would also recommend to clean up your code quite a bit. It will be much easier to read and debug if you
try to write clean code from the beginning 🙂
Yes of course, the plugin is still in beta and in testing phase
Anyway thank you, I will try now
Thank you very much, it works now! Do you have some advice? I'm learning so advice is welcome 🙂
Using setAmount won’t remove items on newer versions
and what should I use?
Well there is two ways, easiest would just be to check if the amount is 1 if so, set the slot it is in to 0, if not remove 1.
The other would be to clone the item, set the cloned amount to 1 and use inventory#removeItem and check the success
How do I get all the chunks? I have the cuboid coordinates of the region, should I use those?
ok, thanks : )
I think you mean older versions. In newer versions, setting the amount to 0 is perfectly fine.
Huh fr?
Im pretty sure. At least for 1.18 - 1.20.4 ive used this without problems
int minPointX = (int) regions.getDouble("regions." + regionID.trim() + ".minPoint.x");
int maxPointZ = (int) regions.getDouble("regions." + regionID.trim() + ".maxPoint.z");
world.getChunkAt(minPointX, maxPointZ);
the integer are ok, but non the chuck
You should never read from configurations like that during runtime. It is incredibly error prone.
Anyways: You need to get all chunks within those corner points.
And X / Z are chunk coordinates, not world coordinates. So you need to convert the corner coordinates to chunk coordinates
and then iterate through all chunks within thos two corners
a thing like this?
Location minPoint = regionManager.getMinPoint(regionID, plugin, world);
Location maxPoint = regionManager.getMaxPoint(regionID, plugin, world);
int chunkX1 = (int) minPoint.getX() >> 4;
int chunkZ1 = (int) minPoint.getZ() >> 4;
int chunkX2 = (int) maxPoint.getX() >> 4;
int chunkZ2 = (int) maxPoint.getZ() >> 4;
for (int x = Math.min(chunkX1, chunkX2); x <= Math.max(chunkX1, chunkX2); x++) {
for (int z = Math.min(chunkZ1, chunkZ2); z <= Math.max(chunkZ1, chunkZ2); z++) {
Chunk chunk = world.getChunkAt(x, z);
chunk.load();
}
}
Sure. chunk.load() is redundant
ok, but the same problem
Check if the mob is loaded 5 ticks later