Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,21 @@ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p
}
EndOfTimeSourceProperty source = (EndOfTimeSourceProperty) player
.getExtendedProperties(EndOfTimeSourceProperty.PROP_KEY);

WorldServer dest = MinecraftServer.getServer()
.worldServerForDimension(source.entranceWorld);

BlockPos spawn = findSpawnLocation(dest, source.entranceX, source.entranceY, source.entranceZ);
if (spawn == null) {

if (!source.isSet || spawn == null) {
ChunkCoordinates playerSpawn = player.getBedLocation(0);
if (playerSpawn != null) playerSpawn = EntityPlayer.verifyRespawnCoordinates(dest, playerSpawn, false);
if (playerSpawn == null) {
playerSpawn = dest.getSpawnPoint();
playerSpawn.posY = dest.getTopSolidOrLiquidBlock(playerSpawn.posX, playerSpawn.posZ);
}
player.addChatComponentMessage(new ChatComponentTranslation("uie.chat.portal.blocked"));
teleport((EntityPlayerMP) player, dest, playerSpawn.posX, playerSpawn.posY, playerSpawn.posZ);
} else {
teleport((EntityPlayerMP) player, dest, spawn.x, spawn.y, spawn.z);
}
Expand All @@ -122,6 +132,8 @@ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p
source.entranceX = x;
source.entranceY = y;
source.entranceZ = z;
source.isSet = true;

teleport((EntityPlayerMP) player, dest, spawn.posX, spawn.posY + 1, spawn.posZ);
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
Expand Down Expand Up @@ -116,8 +117,17 @@ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p

BlockPos spawn = findSpawnLocation(dest, source.entranceX, source.entranceY, source.entranceZ);

if (spawn == null) {
if (!source.isSet || spawn == null) {
ChunkCoordinates playerSpawn = player.getBedLocation(0);
if (playerSpawn != null)
playerSpawn = EntityPlayer.verifyRespawnCoordinates(dest, playerSpawn, false);
if (playerSpawn == null) {
playerSpawn = dest.getSpawnPoint();
playerSpawn.posY = dest.getTopSolidOrLiquidBlock(playerSpawn.posX, playerSpawn.posZ);
}

player.addChatComponentMessage(new ChatComponentTranslation("uie.chat.portal.blocked"));
teleport((EntityPlayerMP) player, dest, playerSpawn.posX, playerSpawn.posY, playerSpawn.posZ);
} else {
teleport((EntityPlayerMP) player, dest, spawn.x, spawn.y, spawn.z);
}
Expand Down Expand Up @@ -159,6 +169,7 @@ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p
source.entranceX = x;
source.entranceY = y;
source.entranceZ = z;
source.isSet = true;

teleport((EntityPlayerMP) player, dest, spawn.x, spawn.y + 1, spawn.z);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class EndOfTimeSourceProperty implements IExtendedEntityProperties {
public static final String PROP_KEY = "end-of-time-source";

public int entranceX, entranceY, entranceZ, entranceWorld;
public boolean isSet;

@Override
public void saveNBTData(NBTTagCompound compound) {
Expand All @@ -28,6 +29,7 @@ public void saveNBTData(NBTTagCompound compound) {
tag.setInteger("entranceY", entranceY);
tag.setInteger("entranceZ", entranceZ);
tag.setInteger("entranceWorld", entranceWorld);
tag.setBoolean("isSet", isSet);
}

@Override
Expand All @@ -39,6 +41,7 @@ public void loadNBTData(NBTTagCompound compound) {
entranceY = tag.getInteger("entranceY");
entranceZ = tag.getInteger("entranceZ");
entranceWorld = tag.getInteger("entranceWorld");
isSet = tag.getBoolean("isSet");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class UnderWorldSourceProperty implements IExtendedEntityProperties {
public static final String PROP_KEY = "underworld-source";

public int entranceX, entranceY, entranceZ, entranceWorld;
public boolean isSet;

@Override
public void saveNBTData(NBTTagCompound compound) {
Expand All @@ -28,6 +29,7 @@ public void saveNBTData(NBTTagCompound compound) {
tag.setInteger("entranceY", entranceY);
tag.setInteger("entranceZ", entranceZ);
tag.setInteger("entranceWorld", entranceWorld);
tag.setBoolean("isSet", isSet);
}

@Override
Expand All @@ -39,6 +41,7 @@ public void loadNBTData(NBTTagCompound compound) {
entranceY = tag.getInteger("entranceY");
entranceZ = tag.getInteger("entranceZ");
entranceWorld = tag.getInteger("entranceWorld");
isSet = tag.getBoolean("isSet");
}
}

Expand Down