Removed the null check in BlockDimensionalPortal

Neither ServerStartingEvent or ServerStartedEvent, were able to
initialized the LocationsHandler correctly, so it was placed in onWorldLoad
This commit is contained in:
Phil M. H 2019-03-08 02:27:14 -05:00
parent 4c76d42ef4
commit d7b8c829ae
3 changed files with 15 additions and 11 deletions

View file

@ -76,20 +76,18 @@ public class BlockDimensionalPortal extends BlockInteger {
if (!world.isRemote && world.getTileEntity(pos) instanceof TileDimensionalPortal) {
TileDimensionalPortal tile = (TileDimensionalPortal) world.getTileEntity(pos);
LocationsHandler.verifyIsInitialized();
ArrayList<PortalLocation> linkedLocations = LocationsHandler.getLinkedLocations(tile.portalID);
if (linkedLocations != null && linkedLocations.size() > 1) {
if (world.getTileEntity(tile.getMasterStonePos()) != null && world.getTileEntity(tile.getMasterStonePos()) instanceof IMasterRitualStone) {
IMasterRitualStone masterRitualStone = (IMasterRitualStone) world.getTileEntity(tile.getMasterStonePos());
TileEntity tileEntity = world.getTileEntity(tile.getMasterStonePos());
if (tileEntity instanceof IMasterRitualStone) {
IMasterRitualStone masterRitualStone = (IMasterRitualStone) tileEntity;
PortalLocation portal;
int index = linkedLocations.size() - 1; //index of most recent PortalLocation
if (linkedLocations.get(index).equals(new PortalLocation(masterRitualStone.getBlockPos().up(), world.provider.getDimension()))) {
portal = linkedLocations.get(index-1); // if most recent PortalLocaiton = this, get the 2nd most recent
} else {
portal = linkedLocations.get(index);
}
if (linkedLocations.get(index).equals(new PortalLocation(masterRitualStone.getBlockPos().up(), world.provider.getDimension())))
index--; // if most recent PortalLocation = this, get the 2nd most recent
portal = linkedLocations.get(index);
if (portal.getDimension() == world.provider.getDimension()) {
TeleportQueue.getInstance().addITeleport(new Teleports.TeleportSameDim(portal.getX(), portal.getY(), portal.getZ(), entity, masterRitualStone.getOwner(), false));
} else {

View file

@ -86,7 +86,6 @@ public class RitualPortal extends Ritual {
}
}
}
LocationsHandler.verifyIsInitialized();
LocationsHandler.addLocation(name, new PortalLocation(x, y + 1, z, world.provider.getDimension()));
portalRitualTag.setString(PORTAL_ID_TAG, name);
return true;
@ -151,7 +150,6 @@ public class RitualPortal extends Ritual {
int z = masterRitualStone.getBlockPos().getZ();
EnumFacing direction = masterRitualStone.getDirection();
LocationsHandler.verifyIsInitialized();
LocationsHandler.removeLocation(portalRitualTag.getString(PORTAL_ID_TAG), new PortalLocation(x, y + 1, z, world.provider.getDimension()));
if (direction == EnumFacing.NORTH || direction == EnumFacing.SOUTH) {

View file

@ -32,6 +32,7 @@ import WayofTime.bloodmagic.potion.BMPotionUtils;
import WayofTime.bloodmagic.potion.PotionEventHandlers;
import WayofTime.bloodmagic.ritual.IMasterRitualStone;
import WayofTime.bloodmagic.ritual.RitualManager;
import WayofTime.bloodmagic.ritual.portal.LocationsHandler;
import WayofTime.bloodmagic.soul.DemonWillHolder;
import WayofTime.bloodmagic.util.Constants;
import WayofTime.bloodmagic.util.Utils;
@ -79,6 +80,8 @@ import net.minecraftforge.event.entity.player.PlayerPickupXpEvent;
import net.minecraftforge.event.world.ExplosionEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLServerStartedEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
@ -467,6 +470,7 @@ public class GenericHandler {
targetTaskMapMap.computeIfAbsent(world, k -> new HashMap<>());
PotionEventHandlers.flightListMap.computeIfAbsent(world, k -> new ArrayList<>());
PotionEventHandlers.noGravityListMap.computeIfAbsent(world, k -> new ArrayList<>());
LocationsHandler.verifyIsInitialized();;
}
@SubscribeEvent
@ -479,4 +483,8 @@ public class GenericHandler {
PotionEventHandlers.flightListMap.get(world).clear();
PotionEventHandlers.noGravityListMap.get(world).clear();
}
@EventHandler
public static void onServerStarted(FMLServerStartedEvent event) {
}
}