From 44a0d4b3ec4f06b1e2405ff15572ab931506282e Mon Sep 17 00:00:00 2001 From: CannibalVox Date: Sun, 15 Mar 2015 22:19:13 -0500 Subject: [PATCH] Correct various weirdness with personal doors in pocket dimensions --- .../mod_pocketDim/blocks/PersonalDimDoor.java | 6 ++++- .../mod_pocketDim/core/DDTeleporter.java | 22 ++++++++++++++----- .../mod_pocketDim/core/LinkType.java | 1 + .../mod_pocketDim/core/NewDimData.java | 3 ++- .../tileentities/TileEntityRift.java | 2 +- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/blocks/PersonalDimDoor.java b/src/main/java/StevenDimDoors/mod_pocketDim/blocks/PersonalDimDoor.java index c95975c2..9c7f2978 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/blocks/PersonalDimDoor.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/blocks/PersonalDimDoor.java @@ -1,5 +1,6 @@ package StevenDimDoors.mod_pocketDim.blocks; +import StevenDimDoors.mod_pocketDim.world.PersonalPocketProvider; import net.minecraft.block.material.Material; import net.minecraft.item.Item; import net.minecraft.world.World; @@ -28,7 +29,10 @@ public class PersonalDimDoor extends BaseDimDoor DimLink link = dimension.getLink(x, y, z); if (link == null) { - dimension.createLink(x, y, z, LinkType.PERSONAL, world.getBlockMetadata(x, y - 1, z)); + if (world.provider instanceof PersonalPocketProvider) + dimension.createLink(x, y, z, LinkType.LIMBO, world.getBlockMetadata(x, y-1, z)); + else + dimension.createLink(x, y, z, LinkType.PERSONAL, world.getBlockMetadata(x, y - 1, z)); } } } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/core/DDTeleporter.java b/src/main/java/StevenDimDoors/mod_pocketDim/core/DDTeleporter.java index e651fc23..84a5f1b8 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/core/DDTeleporter.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/core/DDTeleporter.java @@ -3,6 +3,7 @@ package StevenDimDoors.mod_pocketDim.core; import java.util.ArrayList; import java.util.Random; +import StevenDimDoors.mod_pocketDim.world.LimboProvider; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.gameevent.PlayerEvent; import net.minecraft.block.Block; @@ -499,13 +500,22 @@ public class DDTeleporter case POCKET: return PocketBuilder.generateNewPocket(link, properties, door, DimensionType.POCKET); case PERSONAL: - return setupPersonalLink(link, properties, (EntityPlayer)entity, door); + return setupPersonalLink(link, properties, entity, door); case SAFE_EXIT: return generateSafeExit(link, properties); case DUNGEON_EXIT: return generateDungeonExit(link, properties); case UNSAFE_EXIT: return generateUnsafeExit(link); + case LIMBO: + if(!(entity instanceof EntityPlayer)) + { + return false; + } + + Point4D dest = LimboProvider.getLimboSkySpawn((EntityPlayer)entity, DDProperties.instance()); + link.tail.setDestination(dest); + return true; case NORMAL: case REVERSE: case RANDOM: @@ -515,13 +525,14 @@ public class DDTeleporter } } - private static boolean setupPersonalLink(DimLink link, DDProperties properties,EntityPlayer player, Block door) + private static boolean setupPersonalLink(DimLink link, DDProperties properties,Entity entity, Block door) { - if(!(player instanceof EntityPlayer)) + if(!(entity instanceof EntityPlayer)) { return false; } - + + EntityPlayer player = (EntityPlayer)entity; NewDimData dim = PocketManager.getPersonalDimensionForPlayer(player.getGameProfile().getId().toString()); if(dim == null) { @@ -533,8 +544,7 @@ public class DDTeleporter { PocketManager.getDimensionData(link.source().getDimension()).setLinkDestination(personalHomeLink, link.source().getX(), link.source().getY(), link.source().getZ()); } - - dim.setLinkDestination(link, dim.origin.getX(), dim.origin.getY(), dim.origin.getZ()); + return true; } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/core/LinkType.java b/src/main/java/StevenDimDoors/mod_pocketDim/core/LinkType.java index 2f0311f5..ba9567ea 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/core/LinkType.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/core/LinkType.java @@ -14,6 +14,7 @@ public enum LinkType UNSAFE_EXIT(6), REVERSE(7), PERSONAL(8), + LIMBO(9), CLIENT(-1337); LinkType(int index) diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/core/NewDimData.java b/src/main/java/StevenDimDoors/mod_pocketDim/core/NewDimData.java index f3df3ebe..ec76b8ce 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/core/NewDimData.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/core/NewDimData.java @@ -428,7 +428,8 @@ public abstract class NewDimData implements IPackable } // Raise deletion event - linkWatcher.onDeleted(new ClientLinkData(link)); + if (linkWatcher != null) + linkWatcher.onDeleted(new ClientLinkData(link)); target.clear(); modified = true; } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/tileentities/TileEntityRift.java b/src/main/java/StevenDimDoors/mod_pocketDim/tileentities/TileEntityRift.java index bd0231b4..c6d38dfd 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/tileentities/TileEntityRift.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/tileentities/TileEntityRift.java @@ -164,7 +164,7 @@ public class TileEntityRift extends DDTileEntityBase if (growth <= 0 && !worldObj.isRemote) { DimLink link = PocketManager.getLink(this.xCoord, this.yCoord, this.zCoord, worldObj); - if (link != null) + if (link != null && !worldObj.isRemote) { dimension.deleteLink(link); }