Merged Upstream Changes
This commit is contained in:
@@ -0,0 +1,97 @@
|
|||||||
|
package StevenDimDoors.mod_pocketDim.commands;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
|
|
||||||
|
import StevenDimDoors.mod_pocketDim.BlankTeleporter;
|
||||||
|
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||||
|
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.WorldServer;
|
||||||
|
|
||||||
|
|
||||||
|
public class CommandTeleportPlayer extends DDCommandBase
|
||||||
|
{
|
||||||
|
private static CommandTeleportPlayer instance = null;
|
||||||
|
|
||||||
|
private CommandTeleportPlayer()
|
||||||
|
{
|
||||||
|
super("dd-tp", new String[] {"<Player Name> <Dimension ID> <X Coord> <Y Coord> <Z Coord>"} );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CommandTeleportPlayer instance()
|
||||||
|
{
|
||||||
|
if (instance == null)
|
||||||
|
{
|
||||||
|
instance = new CommandTeleportPlayer();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO- Change to accept variety of input, like just coords, just dim ID, or two player names.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
||||||
|
{
|
||||||
|
List dimensionIDs = Arrays.asList(dimHelper.getStaticDimensionIDs()); //Gets list of all registered dimensions, regardless if loaded or not
|
||||||
|
EntityPlayer targetPlayer = sender;
|
||||||
|
int dimDestinationID = sender.worldObj.provider.dimensionId;
|
||||||
|
|
||||||
|
if(command.length == 5)
|
||||||
|
{
|
||||||
|
for(int i= 1; i <5;i++)
|
||||||
|
{
|
||||||
|
if(!isInteger(command[i]))
|
||||||
|
{
|
||||||
|
return DDCommandResult.INVALID_ARGUMENTS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(sender.worldObj.getPlayerEntityByName(command[0])!=null) //Gets the targeted player
|
||||||
|
{
|
||||||
|
targetPlayer = sender.worldObj.getPlayerEntityByName(command[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return DDCommandResult.INVALID_ARGUMENTS;
|
||||||
|
}
|
||||||
|
dimDestinationID=Integer.parseInt(command[1]);//gets the target dim ID from the command string
|
||||||
|
|
||||||
|
if(!dimensionIDs.contains(dimDestinationID))
|
||||||
|
{
|
||||||
|
return DDCommandResult.INVALID_DIMENSION_ID;
|
||||||
|
}
|
||||||
|
if(dimHelper.getWorld(dimDestinationID)==null)
|
||||||
|
{
|
||||||
|
dimHelper.initDimension(dimDestinationID);
|
||||||
|
}
|
||||||
|
|
||||||
|
FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().transferPlayerToDimension((EntityPlayerMP) targetPlayer, dimDestinationID, new BlankTeleporter(dimHelper.getWorld(dimDestinationID)));
|
||||||
|
targetPlayer.setPositionAndUpdate(Integer.parseInt(command[2]),Integer.parseInt(command[3]),Integer.parseInt(command[4]));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return DDCommandResult.INVALID_ARGUMENTS;
|
||||||
|
}
|
||||||
|
return DDCommandResult.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInteger( String input )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Integer.parseInt( input );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(Exception e )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -174,11 +174,13 @@ public class dimHelper extends DimensionManager
|
|||||||
{
|
{
|
||||||
|
|
||||||
EntityPlayerMP player = (EntityPlayerMP)entity;
|
EntityPlayerMP player = (EntityPlayerMP)entity;
|
||||||
|
|
||||||
//player.closeScreen();
|
//player.closeScreen();
|
||||||
|
|
||||||
|
|
||||||
if (difDest)
|
if (difDest)
|
||||||
{
|
{
|
||||||
|
GameRegistry.onPlayerChangedDimension((EntityPlayer)entity);
|
||||||
|
|
||||||
player.dimension = link.destDimID;
|
player.dimension = link.destDimID;
|
||||||
player.playerNetServerHandler.sendPacketToPlayer(new Packet9Respawn(player.dimension, (byte)player.worldObj.difficultySetting, newWorld.getWorldInfo().getTerrainType(), newWorld.getHeight(), player.theItemInWorldManager.getGameType()));
|
player.playerNetServerHandler.sendPacketToPlayer(new Packet9Respawn(player.dimension, (byte)player.worldObj.difficultySetting, newWorld.getWorldInfo().getTerrainType(), newWorld.getHeight(), player.theItemInWorldManager.getGameType()));
|
||||||
@@ -309,8 +311,6 @@ public class dimHelper extends DimensionManager
|
|||||||
if(this.dimList.containsKey(destinationID) && this.dimList.containsKey(world.provider.dimensionId))
|
if(this.dimList.containsKey(destinationID) && this.dimList.containsKey(world.provider.dimensionId))
|
||||||
{
|
{
|
||||||
this.generatePocket(linkData);
|
this.generatePocket(linkData);
|
||||||
|
|
||||||
|
|
||||||
if(mod_pocketDim.teleTimer==0||entity instanceof EntityPlayer)
|
if(mod_pocketDim.teleTimer==0||entity instanceof EntityPlayer)
|
||||||
{
|
{
|
||||||
mod_pocketDim.teleTimer=2+rand.nextInt(2);
|
mod_pocketDim.teleTimer=2+rand.nextInt(2);
|
||||||
@@ -325,15 +325,7 @@ public class dimHelper extends DimensionManager
|
|||||||
{
|
{
|
||||||
entity = this.teleportEntity(world, entity, linkData);
|
entity = this.teleportEntity(world, entity, linkData);
|
||||||
}
|
}
|
||||||
if(entity instanceof EntityPlayerMP)
|
|
||||||
{
|
|
||||||
|
|
||||||
if(world.provider.dimensionId!=linkData.destDimID)
|
|
||||||
{
|
|
||||||
GameRegistry.onPlayerChangedDimension((EntityPlayer)entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -690,25 +682,25 @@ public class dimHelper extends DimensionManager
|
|||||||
if(orientation==0)
|
if(orientation==0)
|
||||||
{
|
{
|
||||||
x=x+15;
|
x=x+15;
|
||||||
this.getWorld(incomingLink.destDimID).provider.setSpawnPoint(x-1, y, z);
|
//this.getWorld(incomingLink.destDimID).provider.setSpawnPoint(x-1, y, z);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(orientation==1)
|
else if(orientation==1)
|
||||||
{
|
{
|
||||||
z=z+15;
|
z=z+15;
|
||||||
this.getWorld(incomingLink.destDimID).provider.setSpawnPoint(x, y, z-1);
|
//this.getWorld(incomingLink.destDimID).provider.setSpawnPoint(x, y, z-1);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(orientation==2)
|
else if(orientation==2)
|
||||||
{
|
{
|
||||||
x=x-15;
|
x=x-15;
|
||||||
this.getWorld(incomingLink.destDimID).provider.setSpawnPoint(x+1, y, z);
|
//this.getWorld(incomingLink.destDimID).provider.setSpawnPoint(x+1, y, z);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(orientation==3)
|
else if(orientation==3)
|
||||||
{
|
{
|
||||||
z=z-15;
|
z=z-15;
|
||||||
this.getWorld(incomingLink.destDimID).provider.setSpawnPoint(x, y, z+1);
|
//this.getWorld(incomingLink.destDimID).provider.setSpawnPoint(x, y, z+1);
|
||||||
|
|
||||||
}
|
}
|
||||||
int searchRadius=19;
|
int searchRadius=19;
|
||||||
@@ -1015,10 +1007,6 @@ public class dimHelper extends DimensionManager
|
|||||||
link = this.createLink(this.getWorld(link.locDimID).provider.dimensionId,dimensionID,link.locXCoord,link.locYCoord,link.locZCoord, link.destXCoord,link.destYCoord,link.destZCoord,link.linkOrientation); //creates and registers the two rifts that link the parent and pocket dim.
|
link = this.createLink(this.getWorld(link.locDimID).provider.dimensionId,dimensionID,link.locXCoord,link.locYCoord,link.locZCoord, link.destXCoord,link.destYCoord,link.destZCoord,link.linkOrientation); //creates and registers the two rifts that link the parent and pocket dim.
|
||||||
this.createLink(dimensionID,this.getWorld(link.locDimID).provider.dimensionId, link.destXCoord,link.destYCoord,link.destZCoord, link.locXCoord,link.locYCoord,link.locZCoord, this.flipDoorMetadata(link.linkOrientation));
|
this.createLink(dimensionID,this.getWorld(link.locDimID).provider.dimensionId, link.destXCoord,link.destYCoord,link.destZCoord, link.locXCoord,link.locYCoord,link.locZCoord, this.flipDoorMetadata(link.linkOrientation));
|
||||||
|
|
||||||
if (isRandomRift)
|
|
||||||
{
|
|
||||||
DungeonHelper.instance().generateDungeonLink(link);
|
|
||||||
}
|
|
||||||
|
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ import StevenDimDoors.mod_pocketDim.commands.CommandExportDungeon;
|
|||||||
import StevenDimDoors.mod_pocketDim.commands.CommandPrintDimensionData;
|
import StevenDimDoors.mod_pocketDim.commands.CommandPrintDimensionData;
|
||||||
import StevenDimDoors.mod_pocketDim.commands.CommandPruneDimensions;
|
import StevenDimDoors.mod_pocketDim.commands.CommandPruneDimensions;
|
||||||
import StevenDimDoors.mod_pocketDim.commands.CommandResetDungeons;
|
import StevenDimDoors.mod_pocketDim.commands.CommandResetDungeons;
|
||||||
|
import StevenDimDoors.mod_pocketDim.commands.CommandTeleportPlayer;
|
||||||
|
import StevenDimDoors.mod_pocketDim.helpers.BlockRotationHelper;
|
||||||
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
||||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||||
import StevenDimDoors.mod_pocketDim.items.ItemBlockDimWall;
|
import StevenDimDoors.mod_pocketDim.items.ItemBlockDimWall;
|
||||||
@@ -437,6 +439,7 @@ public class mod_pocketDim
|
|||||||
CommandPrintDimensionData.instance().register(event);
|
CommandPrintDimensionData.instance().register(event);
|
||||||
CommandPruneDimensions.instance().register(event);
|
CommandPruneDimensions.instance().register(event);
|
||||||
CommandCreatePocket.instance().register(event);
|
CommandCreatePocket.instance().register(event);
|
||||||
|
CommandTeleportPlayer.instance().register(event);
|
||||||
dimHelper.instance.load();
|
dimHelper.instance.load();
|
||||||
|
|
||||||
if(!dimHelper.dimList.containsKey(properties.LimboDimensionID))
|
if(!dimHelper.dimList.containsKey(properties.LimboDimensionID))
|
||||||
|
|||||||
Reference in New Issue
Block a user