Fixed some black magic that occurred when a mob was summoned in a world that was loaded but didn't have a list entry that is supposed to be generated on world load. (#1618)

1.12
Tobias 2019-09-05 03:38:52 +02:00 committed by Nick Ignoffo
parent 6587068296
commit 3cdf4517a8
2 changed files with 9 additions and 8 deletions

View File

@ -3,6 +3,7 @@ package WayofTime.bloodmagic.potion;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.core.RegistrarBloodMagic;
import WayofTime.bloodmagic.event.SacrificeKnifeUsedEvent;
import com.google.common.collect.Lists;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IProjectile;
@ -55,7 +56,7 @@ public class PotionEventHandlers {
@SubscribeEvent
public static void onEntityUpdate(LivingEvent.LivingUpdateEvent event) {
EntityLivingBase eventEntityLiving = event.getEntityLiving();
List<EntityPlayer> flightList = flightListMap.get(eventEntityLiving.getEntityWorld());
List<EntityPlayer> flightList = flightListMap.getOrDefault(eventEntityLiving.getEntityWorld(), Lists.newArrayList());
if (eventEntityLiving instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) eventEntityLiving;
@ -91,7 +92,7 @@ public class PotionEventHandlers {
// }
// }
// }
List<EntityLivingBase> noGravityList = noGravityListMap.get(event.getEntityLiving().getEntityWorld());
List<EntityLivingBase> noGravityList = noGravityListMap.getOrDefault(event.getEntityLiving().getEntityWorld(), Lists.newArrayList());
if (eventEntityLiving.isPotionActive(RegistrarBloodMagic.SUSPENDED) && !eventEntityLiving.hasNoGravity()) {
eventEntityLiving.setNoGravity(true);
noGravityList.add(eventEntityLiving);

View File

@ -555,11 +555,11 @@ public class GenericHandler {
@SubscribeEvent
public static void onWorldUnload(WorldEvent.Unload event) {
World world = event.getWorld();
bounceMapMap.getOrDefault(world, Collections.emptyMap()).clear();
filledHandMapMap.getOrDefault(world, Collections.emptyMap()).clear();
attackTaskMapMap.getOrDefault(world, Collections.emptyMap()).clear();
targetTaskMapMap.getOrDefault(world, Collections.emptyMap()).clear();
PotionEventHandlers.flightListMap.getOrDefault(world, Collections.emptyList()).clear();
PotionEventHandlers.noGravityListMap.getOrDefault(world, Collections.emptyList()).clear();
bounceMapMap.remove(world);
filledHandMapMap.remove(world);
attackTaskMapMap.remove(world);
targetTaskMapMap.remove(world);
PotionEventHandlers.flightListMap.remove(world);
PotionEventHandlers.noGravityListMap.remove(world);
}
}