Improved ship scanner usability for new captains and admins
This commit is contained in:
parent
08937e6702
commit
cae95a4f26
5 changed files with 32 additions and 24 deletions
|
@ -186,7 +186,7 @@ public class TileEntityShipScanner extends TileEntityAbstractMachine implements
|
|||
optimumSpeed, blockToDeployPerTick));
|
||||
}
|
||||
sequencer.setBlocksPerTick(blockToDeployPerTick);
|
||||
sequencer.setCaptain(playerName);
|
||||
sequencer.setRequester(playerName, isShipToken);
|
||||
sequencer.setEffectSource(new Vector3(this).translate(0.5D));
|
||||
sequencer.setCallback(this);
|
||||
sequencer.enable();
|
||||
|
@ -718,15 +718,13 @@ public class TileEntityShipScanner extends TileEntityAbstractMachine implements
|
|||
final boolean isSuccess = deployShip(fileName, x, y, z, rotationSteps, false, reason);
|
||||
|
||||
// don't force captain when deploying from LUA
|
||||
playerName = null;
|
||||
/*
|
||||
final EntityPlayer entityPlayer = world.getClosestPlayer(pos, 8);
|
||||
final EntityPlayer entityPlayer = world.getClosestPlayer(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, 8.0D, false);
|
||||
if (entityPlayer != null) {
|
||||
playerName = entityPlayer.getCommandSenderName();
|
||||
playerName = entityPlayer.getName();
|
||||
} else {
|
||||
playerName = "";
|
||||
}
|
||||
/**/
|
||||
|
||||
return new Object[] { isSuccess, Commons.removeFormatting( reason.getUnformattedText() ) };
|
||||
}
|
||||
|
||||
|
|
|
@ -694,9 +694,6 @@ public class TileEntityShipCore extends TileEntityAbstractShipController impleme
|
|||
if (tileEntitySecurityStation != null) {
|
||||
tileEntitySecurityStation.players.clear();
|
||||
tileEntitySecurityStation.players.add(entityPlayerMP.getName());
|
||||
} else {
|
||||
WarpDrive.logger.warn(this + " Failed to find controller block");
|
||||
return false;
|
||||
}
|
||||
|
||||
final AxisAlignedBB aabb = new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
|
@ -706,9 +703,12 @@ public class TileEntityShipCore extends TileEntityAbstractShipController impleme
|
|||
return true;
|
||||
}
|
||||
|
||||
private static final VectorI[] SUMMON_OFFSETS = { new VectorI(2, 0, 0), new VectorI(-1, 0, 0),
|
||||
new VectorI(2, 0, 1), new VectorI(2, 0, -1), new VectorI(-1, 0, 1), new VectorI(-1, 0, -1),
|
||||
new VectorI(1, 0, 1), new VectorI(1, 0, -1), new VectorI( 0, 0, 1), new VectorI( 0, 0, -1) };
|
||||
private static final VectorI[] SUMMON_OFFSETS = {
|
||||
new VectorI(-1, 0, 0), new VectorI( 1, 0, 0),
|
||||
new VectorI(-1, 0, 1), new VectorI(-1, 0, -1),
|
||||
new VectorI( 1, 0, 1), new VectorI( 1, 0, -1),
|
||||
new VectorI( 0, 0, 1), new VectorI( 0, 0, -1),
|
||||
new VectorI(-2, 0, 0), new VectorI( 2, 0, 0) };
|
||||
private void summonPlayer(@Nonnull final EntityPlayerMP entityPlayer) {
|
||||
// find a free spot
|
||||
final BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(pos);
|
||||
|
|
|
@ -355,11 +355,14 @@ public class JumpShip {
|
|||
return isSuccess;
|
||||
}
|
||||
|
||||
public void setCaptain(final String playerName) {
|
||||
entitiesOnShip = new ArrayList<>();
|
||||
public void addPlayerToEntities(final String playerName) {
|
||||
if (entitiesOnShip == null) {
|
||||
entitiesOnShip = new ArrayList<>();
|
||||
}
|
||||
final EntityPlayerMP entityPlayerMP = Commons.getOnlinePlayerByName(playerName);
|
||||
if (entityPlayerMP == null) {
|
||||
WarpDrive.logger.error(String.format("%s setCaptain: captain is missing", this));
|
||||
WarpDrive.logger.error(String.format("%s Unable to add offline/missing player %s",
|
||||
this, playerName ));
|
||||
return;
|
||||
}
|
||||
final MovingEntity movingEntity = new MovingEntity(entityPlayerMP);
|
||||
|
|
|
@ -15,7 +15,8 @@ import net.minecraft.world.World;
|
|||
|
||||
public class DeploySequencer extends JumpSequencer {
|
||||
|
||||
private String playerName;
|
||||
private String playerNameRequester;
|
||||
private boolean isRequesterCaptain = false;
|
||||
private ISequencerCallbacks callback;
|
||||
|
||||
/*
|
||||
|
@ -31,9 +32,10 @@ public class DeploySequencer extends JumpSequencer {
|
|||
super(jumpShip, world, isInstantiated ? EnumShipMovementType.INSTANTIATE : EnumShipMovementType.RESTORE, destX, destY, destZ, rotationSteps);
|
||||
}
|
||||
|
||||
public void setCaptain(final String playerName) {
|
||||
this.playerName = playerName;
|
||||
ship.setCaptain(playerName);
|
||||
public void setRequester(final String playerName, final boolean isCaptain) {
|
||||
this.playerNameRequester = playerName;
|
||||
this.isRequesterCaptain = isCaptain;
|
||||
addPlayerToEntities(playerName);
|
||||
}
|
||||
|
||||
public void setCallback(final ISequencerCallbacks object) {
|
||||
|
@ -56,9 +58,9 @@ public class DeploySequencer extends JumpSequencer {
|
|||
protected void state_chunkReleasing() {
|
||||
super.state_chunkReleasing();
|
||||
|
||||
if (playerName != null) {
|
||||
if (playerNameRequester != null) {
|
||||
// Warn owner if deployment done but wait next tick for teleportation
|
||||
final EntityPlayerMP entityPlayerMP = Commons.getOnlinePlayerByName(playerName);
|
||||
final EntityPlayerMP entityPlayerMP = Commons.getOnlinePlayerByName(playerNameRequester);
|
||||
if (entityPlayerMP != null) {
|
||||
Commons.addChatMessage(entityPlayerMP, new WarpDriveText(Commons.styleCorrect, "warpdrive.builder.guide.ship_deployed"));
|
||||
}
|
||||
|
@ -67,8 +69,9 @@ public class DeploySequencer extends JumpSequencer {
|
|||
|
||||
@Override
|
||||
protected void state_finishing() {
|
||||
if (playerName != null && !playerName.isEmpty()) {
|
||||
final EntityPlayerMP entityPlayerMP = Commons.getOnlinePlayerByName(playerName);
|
||||
if ( playerNameRequester != null && !playerNameRequester.isEmpty()
|
||||
&& isRequesterCaptain ) {
|
||||
final EntityPlayerMP entityPlayerMP = Commons.getOnlinePlayerByName(playerNameRequester);
|
||||
if (entityPlayerMP != null) {
|
||||
final TileEntity tileEntity = targetWorld.getTileEntity(new BlockPos(destX, destY, destZ));
|
||||
if (tileEntity instanceof TileEntityShipCore) {
|
||||
|
@ -77,7 +80,7 @@ public class DeploySequencer extends JumpSequencer {
|
|||
Commons.addChatMessage(entityPlayerMP, new WarpDriveText(Commons.styleCorrect, "warpdrive.builder.guide.welcome_aboard"));
|
||||
} else {
|
||||
WarpDrive.logger.warn(String.format("Failed to assign new captain %s",
|
||||
playerName));
|
||||
playerNameRequester));
|
||||
}
|
||||
} else {
|
||||
WarpDrive.logger.warn(String.format("Unable to detect ship core after deployment, found %s",
|
||||
|
|
|
@ -167,6 +167,10 @@ public class JumpSequencer extends AbstractSequencer {
|
|||
this.v3Source = v3Source;
|
||||
}
|
||||
|
||||
public void addPlayerToEntities(final String playerName) {
|
||||
ship.addPlayerToEntities(playerName);
|
||||
}
|
||||
|
||||
public void enable() {
|
||||
isEnabled = true;
|
||||
register();
|
||||
|
|
Loading…
Reference in a new issue