Removed Obsolete Code from PocketManager
Removed obsolete code from PocketManager. Much of that functionality has already been reimplemented in other classes.
This commit is contained in:
@@ -7,34 +7,17 @@ import java.io.ObjectOutputStream;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.EntityList;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.network.packet.Packet41EntityEffect;
|
|
||||||
import net.minecraft.network.packet.Packet43Experience;
|
|
||||||
import net.minecraft.network.packet.Packet9Respawn;
|
|
||||||
import net.minecraft.potion.PotionEffect;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.MathHelper;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldServer;
|
|
||||||
import net.minecraftforge.common.DimensionManager;
|
import net.minecraftforge.common.DimensionManager;
|
||||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||||
import StevenDimDoors.mod_pocketDim.DDTeleporter;
|
|
||||||
import StevenDimDoors.mod_pocketDim.ObjectSaveInputStream;
|
import StevenDimDoors.mod_pocketDim.ObjectSaveInputStream;
|
||||||
import StevenDimDoors.mod_pocketDim.PacketHandler;
|
|
||||||
import StevenDimDoors.mod_pocketDim.TileEntityRift;
|
import StevenDimDoors.mod_pocketDim.TileEntityRift;
|
||||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
|
||||||
import StevenDimDoors.mod_pocketDim.helpers.DeleteFolder;
|
import StevenDimDoors.mod_pocketDim.helpers.DeleteFolder;
|
||||||
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
|
|
||||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||||
import cpw.mods.fml.common.FMLCommonHandler;
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
import cpw.mods.fml.common.registry.GameRegistry;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class regulates all the operations involving the storage and manipulation of dimensions. It handles saving dim data, teleporting the player, and
|
* This class regulates all the operations involving the storage and manipulation of dimensions. It handles saving dim data, teleporting the player, and
|
||||||
@@ -74,112 +57,6 @@ public class PocketManager
|
|||||||
return isInitialized;
|
return isInitialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ILinkData createLink(ILinkData link)
|
|
||||||
{
|
|
||||||
DDProperties properties = DDProperties.instance();
|
|
||||||
|
|
||||||
if(!PocketManager.dimList.containsKey(link.locDimID))
|
|
||||||
{
|
|
||||||
NewDimData locationDimData= new NewDimData(link.locDimID, false, 0, link.locDimID,link.locXCoord,link.locYCoord,link.locZCoord);
|
|
||||||
PocketManager.dimList.put(link.locDimID, locationDimData);
|
|
||||||
link.isLocPocket=false;
|
|
||||||
}
|
|
||||||
if(!dimList.containsKey(link.destDimID))
|
|
||||||
{
|
|
||||||
PocketManager.dimList.put(link.destDimID, new NewDimData(link.destDimID, false, 0, link.locDimID,link.locXCoord,link.locYCoord,link.locZCoord));
|
|
||||||
}
|
|
||||||
NewDimData locationDimData= PocketManager.instance.getDimData(link.locDimID);
|
|
||||||
link.isLocPocket=locationDimData.isPocket;
|
|
||||||
locationDimData.addLinkToDim(link);
|
|
||||||
|
|
||||||
World world = PocketManager.getWorld(link.locDimID);
|
|
||||||
if (world != null)
|
|
||||||
{
|
|
||||||
if (!mod_pocketDim.blockRift.isBlockImmune(world, link.locXCoord, link.locYCoord, link.locZCoord))
|
|
||||||
{
|
|
||||||
world.setBlock(link.locXCoord, link.locYCoord, link.locZCoord, properties.RiftBlockID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Notifies other players that a link has been created.
|
|
||||||
//TODO: Couldn't we use the serverside/clientside annotations to achieve this instead? Seems safer. ~SenseiKiwi
|
|
||||||
if(FMLCommonHandler.instance().getEffectiveSide()==Side.SERVER)
|
|
||||||
{
|
|
||||||
PacketHandler.onLinkCreatedPacket(link);
|
|
||||||
}
|
|
||||||
return link;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* properly deletes a link at the given coordinates. used by the rift remover. Also notifies clients of change.
|
|
||||||
* @param locationDimID
|
|
||||||
* @param locationXCoord
|
|
||||||
* @param locationYCoord
|
|
||||||
* @param locationZCoord
|
|
||||||
*/
|
|
||||||
public void removeLink( int locationDimID, int locationXCoord, int locationYCoord, int locationZCoord)
|
|
||||||
{
|
|
||||||
if(!PocketManager.dimList.containsKey(locationDimID))
|
|
||||||
{
|
|
||||||
NewDimData locationDimData= new NewDimData(locationDimID, false, 0, locationDimID,locationXCoord,locationYCoord,locationZCoord);
|
|
||||||
PocketManager.dimList.put(locationDimID, locationDimData);
|
|
||||||
}
|
|
||||||
ILinkData link = this.getLinkDataFromCoords(locationXCoord, locationYCoord, locationZCoord, locationDimID);
|
|
||||||
PocketManager.instance.getDimData(locationDimID).removeLinkAtCoords(link);
|
|
||||||
//updates clients that a rift has been removed
|
|
||||||
if(FMLCommonHandler.instance().getEffectiveSide()==Side.SERVER)
|
|
||||||
{
|
|
||||||
PacketHandler.onLinkRemovedPacket(link);
|
|
||||||
this.save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* generates a door based on what door was used to teleport. Only functions once per linking.
|
|
||||||
* @param world- door
|
|
||||||
* @param incLink
|
|
||||||
*/
|
|
||||||
public void generateDoor(World world, ILinkData incLink)
|
|
||||||
{
|
|
||||||
int locX = incLink.locXCoord;
|
|
||||||
int locY = incLink.locYCoord;
|
|
||||||
int locZ = incLink.locZCoord;
|
|
||||||
|
|
||||||
int destX = incLink.destXCoord;
|
|
||||||
int destY = incLink.destYCoord;
|
|
||||||
int destZ = incLink.destZCoord;
|
|
||||||
|
|
||||||
DDProperties properties = DDProperties.instance();
|
|
||||||
|
|
||||||
if(!incLink.hasGennedDoor)
|
|
||||||
{
|
|
||||||
int destinationID = incLink.destDimID;
|
|
||||||
|
|
||||||
int id =world.getBlockId(locX, locY, locZ);
|
|
||||||
if(id==properties.WarpDoorID||id==properties.DimensionalDoorID||id==properties.TransientDoorID)
|
|
||||||
{
|
|
||||||
int doorTypeToPlace=id;
|
|
||||||
if(DimensionManager.getWorld(destinationID)==null)
|
|
||||||
{
|
|
||||||
DimensionManager.initDimension(destinationID);
|
|
||||||
}
|
|
||||||
ILinkData destLink = this.getLinkDataFromCoords(destX, destY, destZ, destinationID);
|
|
||||||
int destOrientation = 0;
|
|
||||||
if(destLink!=null)
|
|
||||||
{
|
|
||||||
destOrientation = destLink.linkOrientation;
|
|
||||||
destLink.hasGennedDoor=true;
|
|
||||||
}
|
|
||||||
int blockToReplace= DimensionManager.getWorld(destinationID).getBlockId(destX, destY, destZ);
|
|
||||||
if(blockToReplace!=properties.DimensionalDoorID&&blockToReplace!=properties.WarpDoorID&&blockToReplace != properties.TransientDoorID)
|
|
||||||
{
|
|
||||||
DimensionManager.getWorld(destinationID).setBlock(destX, destY-1, destZ, doorTypeToPlace,destOrientation,2);
|
|
||||||
DimensionManager.getWorld(destinationID).setBlock(destX, destY, destZ, doorTypeToPlace,8,2);
|
|
||||||
}
|
|
||||||
incLink.hasGennedDoor=true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* simple method called on startup to register all dims saved in the dim list. Only tries to register pocket dims, though. Also calls load()
|
* simple method called on startup to register all dims saved in the dim list. Only tries to register pocket dims, though. Also calls load()
|
||||||
* @return
|
* @return
|
||||||
@@ -283,86 +160,6 @@ public class PocketManager
|
|||||||
while (keyLinkMapping.containsKey(linkKey));
|
while (keyLinkMapping.containsKey(linkKey));
|
||||||
return linkKey;
|
return linkKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method used to create and register a new pocket dimension. Creates a reverse link if necessary.
|
|
||||||
* Populates the destination as well.
|
|
||||||
*/
|
|
||||||
private NewDimData createDestinationPocket(IDimLink link)
|
|
||||||
{
|
|
||||||
//First check the destination type
|
|
||||||
if (link.linkType() != IDimLink.TYPE_DUNGEON && link.linkType() != IDimLink.TYPE_POCKET)
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("The link must lead to a dimensional dungeon or a pocket dimension.");
|
|
||||||
}
|
|
||||||
|
|
||||||
DDProperties properties = DDProperties.instance();
|
|
||||||
|
|
||||||
//FIXME: This code had a check for whether dimension 0 was null. Why? Removed it for the time being. ~SenseiKiwi
|
|
||||||
|
|
||||||
|
|
||||||
if (PocketManager.getWorld(link.locDimID) == null)
|
|
||||||
{
|
|
||||||
PocketManager.initDimension(link.locDimID);
|
|
||||||
}
|
|
||||||
|
|
||||||
int dimensionID;
|
|
||||||
int depth = this.getDimDepth(link.locDimID);
|
|
||||||
dimensionID = getNextFreeDimId();
|
|
||||||
registerDimension(dimensionID, properties.PocketProviderID);
|
|
||||||
NewDimData locationDimData;
|
|
||||||
NewDimData destDimData;
|
|
||||||
|
|
||||||
if(PocketManager.dimList.containsKey(link.locDimID)&&!DimensionManager.getWorld(link.locDimID).isRemote) //checks to see if dim is already registered. If not, it creates a DimData entry for it later
|
|
||||||
{
|
|
||||||
//randomizes exit if deep enough
|
|
||||||
locationDimData= dimList.get(DimensionManager.getWorld(link.locDimID).provider.dimensionId);
|
|
||||||
|
|
||||||
if(depth>5)
|
|
||||||
{
|
|
||||||
if(depth>=12)
|
|
||||||
{
|
|
||||||
depth=11;
|
|
||||||
}
|
|
||||||
if(rand.nextInt(13-depth)==0)
|
|
||||||
{
|
|
||||||
ILinkData link1=getRandomLinkData(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(locationDimData.isPocket) //determines the qualites of the pocket dim being created, based on parent dim.
|
|
||||||
{
|
|
||||||
if(isGoingDown)
|
|
||||||
{
|
|
||||||
destDimData= new NewDimData(dimensionID, true, locationDimData.depth+1, locationDimData.exitDimLink);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
destDimData= new NewDimData(dimensionID, true, locationDimData.depth-1, locationDimData.exitDimLink);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
destDimData= new NewDimData(dimensionID, true, 1, link.locDimID,link.locXCoord,link.locYCoord,link.locZCoord);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
locationDimData= new NewDimData(link.locDimID, false, 0, link.locDimID,link.locXCoord,link.locYCoord,link.locZCoord);
|
|
||||||
destDimData= new NewDimData(dimensionID, true, 1, link.locDimID,link.locXCoord,link.locYCoord,link.locZCoord);
|
|
||||||
}
|
|
||||||
destDimData.isDimRandomRift=isRandomRift;
|
|
||||||
PocketManager.dimList.put(DimensionManager.getWorld(link.locDimID).provider.dimensionId, locationDimData);
|
|
||||||
PocketManager.dimList.put(dimensionID, destDimData);
|
|
||||||
|
|
||||||
if(FMLCommonHandler.instance().getEffectiveSide()==Side.SERVER)//sends packet to clients notifying them that a new dim has been created.
|
|
||||||
{
|
|
||||||
PacketHandler.onDimCreatedPacket(destDimData);
|
|
||||||
}
|
|
||||||
link = this.createLink(DimensionManager.getWorld(link.locDimID).provider.dimensionId,dimensionID,link.locXCoord,link.locYCoord,link.locZCoord, link.destXCoord,constrainPocketY(link.destYCoord),link.destZCoord,link.linkOrientation); //creates and registers the two rifts that link the parent and pocket dim.
|
|
||||||
this.createLink(dimensionID,DimensionManager.getWorld(link.locDimID).provider.dimensionId, link.destXCoord,constrainPocketY(link.destYCoord),link.destZCoord, link.locXCoord,link.locYCoord,link.locZCoord, BlockRotator.transformMetadata(link.linkOrientation, 2, Block.doorWood.blockID));
|
|
||||||
return link;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function that saves all dim data in a hashMap. Calling too often can cause Concurrent modification exceptions, so be careful.
|
* Function that saves all dim data in a hashMap. Calling too often can cause Concurrent modification exceptions, so be careful.
|
||||||
|
|||||||
Reference in New Issue
Block a user