Fixed rift rotation bug & added teleport command
Moved the selection of the dungeon to when the player first enters the door, not when the rift is created.
This commit is contained in:
parent
0edbf1f14d
commit
d747c96c08
3 changed files with 107 additions and 20 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -173,11 +173,13 @@ public class dimHelper extends DimensionManager
|
|||
{
|
||||
|
||||
EntityPlayerMP player = (EntityPlayerMP)entity;
|
||||
|
||||
//player.closeScreen();
|
||||
|
||||
|
||||
if (difDest)
|
||||
{
|
||||
GameRegistry.onPlayerChangedDimension((EntityPlayer)entity);
|
||||
|
||||
player.dimension = link.destDimID;
|
||||
player.playerNetServerHandler.sendPacketToPlayer(new Packet9Respawn(player.dimension, (byte)player.worldObj.difficultySetting, newWorld.getWorldInfo().getTerrainType(), newWorld.getHeight(), player.theItemInWorldManager.getGameType()));
|
||||
|
@ -308,8 +310,6 @@ public class dimHelper extends DimensionManager
|
|||
if(this.dimList.containsKey(destinationID) && this.dimList.containsKey(world.provider.dimensionId))
|
||||
{
|
||||
this.generatePocket(linkData);
|
||||
|
||||
|
||||
if(mod_pocketDim.teleTimer==0||entity instanceof EntityPlayer)
|
||||
{
|
||||
mod_pocketDim.teleTimer=2+rand.nextInt(2);
|
||||
|
@ -324,15 +324,7 @@ public class dimHelper extends DimensionManager
|
|||
{
|
||||
entity = this.teleportEntity(world, entity, linkData);
|
||||
}
|
||||
if(entity instanceof EntityPlayerMP)
|
||||
{
|
||||
|
||||
if(world.provider.dimensionId!=linkData.destDimID)
|
||||
{
|
||||
GameRegistry.onPlayerChangedDimension((EntityPlayer)entity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -689,25 +681,25 @@ public class dimHelper extends DimensionManager
|
|||
if(orientation==0)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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;
|
||||
|
@ -1018,10 +1010,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.
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import StevenDimDoors.mod_pocketDim.commands.CommandExportDungeon;
|
|||
import StevenDimDoors.mod_pocketDim.commands.CommandPrintDimensionData;
|
||||
import StevenDimDoors.mod_pocketDim.commands.CommandPruneDimensions;
|
||||
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.dimHelper;
|
||||
|
@ -442,6 +443,7 @@ public class mod_pocketDim
|
|||
CommandPrintDimensionData.instance().register(event);
|
||||
CommandPruneDimensions.instance().register(event);
|
||||
CommandCreatePocket.instance().register(event);
|
||||
CommandTeleportPlayer.instance().register(event);
|
||||
dimHelper.instance.load();
|
||||
|
||||
if(!dimHelper.dimList.containsKey(properties.LimboDimensionID))
|
||||
|
|
Loading…
Reference in a new issue