#Error that is not an error

1 messages · Page 1 of 1 (latest)

rancid roost
#

.

jade wraith
#

Do some debugging. Find all MMs in the area and print out their mythic type and mobId to make sure they are detected propery.

rancid roost
#

in the code that i share there is Debug

#

Logger.log

#

The image is the prove of that

jade wraith
jade wraith
#

So from what i can see

Collection<ActiveMob> mobsInRegion = regionManager.getMobsInsideRegion(regionID);

returns an empty collection, is that right?

rancid roost
# jade wraith What did you find out?

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

rancid roost
#

also this: Collection<ActiveMob> activeMobs = MythicBukkit.inst().getMobManager().getActiveMobs(am -> am.getMobType().equals(mobId));

jade wraith
#

If this is also empty, then the mob is simply not loaded at that time.

rancid roost
#

with one mob everything works smoothly, in this region and with this mob it does not work. However, the logic is the same

jade wraith
#

Make sure the chunks for this region are loded before you check them

rancid roost
#

How do I check whether the chunks are loaded or not

jade wraith
#

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 🙂

rancid roost
#

Anyway thank you, I will try now

rancid roost
meager igloo
#

Using setAmount won’t remove items on newer versions

rancid roost
#

and what should I use?

meager igloo
#

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

rancid roost
jade wraith
jade wraith
#

Im pretty sure. At least for 1.18 - 1.20.4 ive used this without problems

rancid roost
jade wraith
rancid roost
# jade wraith You should never read from configurations like that during runtime. It is incred...

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();
                    }
                }
jade wraith
#

Sure. chunk.load() is redundant

rancid roost
jade wraith
#

Check if the mob is loaded 5 ticks later

rancid roost