Fixed Transdimensional Trapdoor and More #87

Merged
SenseiKiwi merged 17 commits from rewrite into DevBranch 2013-09-09 05:08:07 +00:00
5 changed files with 102 additions and 93 deletions
Showing only changes of commit 156c61a772 - Show all commits

View File

@@ -10,11 +10,11 @@ import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingFallEvent; import net.minecraftforge.event.entity.living.LivingFallEvent;
import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.event.world.WorldEvent;
import StevenDimDoors.mod_pocketDim.core.DDTeleporter; import StevenDimDoors.mod_pocketDim.core.DDTeleporter;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager; import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.ticking.RiftRegenerator; import StevenDimDoors.mod_pocketDim.ticking.RiftRegenerator;
import StevenDimDoors.mod_pocketDim.util.Point4D; import StevenDimDoors.mod_pocketDim.util.Point4D;
import StevenDimDoors.mod_pocketDim.world.LimboProvider; import StevenDimDoors.mod_pocketDim.world.LimboProvider;
import StevenDimDoors.mod_pocketDim.world.PocketProvider;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@@ -69,19 +69,24 @@ public class EventHookContainer
public boolean LivingDeathEvent(LivingDeathEvent event) public boolean LivingDeathEvent(LivingDeathEvent event)
{ {
Entity entity = event.entity; Entity entity = event.entity;
if (entity instanceof EntityPlayer && entity.worldObj.provider instanceof PocketProvider
&& properties.LimboEnabled) if (entity instanceof EntityPlayer && properties.LimboEnabled)
{ {
EntityPlayer player = (EntityPlayer) entity; NewDimData dimension = PocketManager.getDimensionData(entity.worldObj);
if (!properties.LimboReturnsInventoryEnabled) if (dimension.isDungeon())
{ {
player.inventory.clearInventory(-1, -1); EntityPlayer player = (EntityPlayer) entity;
if (!properties.LimboReturnsInventoryEnabled)
{
player.inventory.clearInventory(-1, -1);
}
ChunkCoordinates coords = LimboProvider.getLimboSkySpawn(player.worldObj.rand);
Point4D destination = new Point4D(coords.posX, coords.posY, coords.posZ, mod_pocketDim.properties.LimboDimensionID);
DDTeleporter.teleportEntity(player, destination, false);
player.setEntityHealth(player.getMaxHealth());
event.setCanceled(true);
return false;
} }
ChunkCoordinates coords = LimboProvider.getLimboSkySpawn(player.worldObj.rand);
DDTeleporter.teleportEntity(player, new Point4D(coords.posX, coords.posY, coords.posZ, mod_pocketDim.properties.LimboDimensionID));
player.setEntityHealth(player.getMaxHealth());
event.setCanceled(true);
return false;
} }
return true; return true;
} }

View File

@@ -67,7 +67,7 @@ public class BlockDimWallPerm extends Block
//FIXME: Shouldn't we make the player's destination safe BEFORE teleporting him?! //FIXME: Shouldn't we make the player's destination safe BEFORE teleporting him?!
//player.setPositionAndUpdate( x, y, z ); //player.setPositionAndUpdate( x, y, z );
Point4D destination = new Point4D(destinationX, destinationY, destinationZ, 0); Point4D destination = new Point4D(destinationX, destinationY, destinationZ, 0);
DDTeleporter.teleportEntity(player, destination); DDTeleporter.teleportEntity(player, destination, false);
//player.setPositionAndUpdate( x, y, z ); //player.setPositionAndUpdate( x, y, z );

View File

@@ -39,98 +39,98 @@ public class DDTeleporter
private DDTeleporter() { } private DDTeleporter() { }
private static void placeInPortal(Entity entity, WorldServer world, Point4D destination, DDProperties properties) private static void placeInPortal(Entity entity, WorldServer world, Point4D destination, DDProperties properties, boolean checkOrientation)
{ {
int x = destination.getX(); int x = destination.getX();
int y = destination.getY(); int y = destination.getY();
int z = destination.getZ(); int z = destination.getZ();
int orientation = getDestinationOrientation(destination, properties); int orientation;
if (checkOrientation)
{
orientation = getDestinationOrientation(destination, properties);
entity.rotationYaw = (orientation * 90) + 90;
}
else
{
//Teleport the entity to the precise destination point
orientation = -1;
}
if (entity instanceof EntityPlayer) if (entity instanceof EntityPlayer)
{ {
EntityPlayer player = (EntityPlayer) entity; EntityPlayer player = (EntityPlayer) entity;
player.rotationYaw=(orientation*90)+90; switch (orientation)
if(orientation==2||orientation==6)
{ {
player.setPositionAndUpdate( x+1.5, y-1, z+.5 ); case 0:
} player.setPositionAndUpdate(x - 0.5, y - 1, z + 0.5);
else if(orientation==3||orientation==7) break;
{ case 1:
player.setPositionAndUpdate( x+.5, y-1, z+1.5 ); player.setPositionAndUpdate(x + 0.5, y - 1, z - 0.5);
} break;
else if(orientation==0||orientation==4) case 2:
{ player.setPositionAndUpdate(x + 1.5, y - 1, z + 0.5);
player.setPositionAndUpdate(x-.5, y-1, z+.5); break;
} case 3:
else if(orientation==1||orientation==5) player.setPositionAndUpdate(x + 0.5, y - 1, z + 1.5);
{ break;
player.setPositionAndUpdate(x+.5, y-1, z-.5); default:
} player.setPositionAndUpdate(x, y - 1, z);
else break;
{
player.setPositionAndUpdate(x, y-1, z);
} }
} }
else if (entity instanceof EntityMinecart) else if (entity instanceof EntityMinecart)
{ {
entity.motionX=0; entity.motionX = 0;
entity.motionZ=0; entity.motionZ = 0;
entity.motionY=0; entity.motionY = 0;
entity.rotationYaw=(orientation*90)+90;
if(orientation==2||orientation==6) switch (orientation)
{ {
DDTeleporter.setEntityPosition(entity, x+1.5, y, z+.5 ); case 0:
entity.motionX =.39; DDTeleporter.setEntityPosition(entity, x - 0.5, y, z + 0.5);
entity.worldObj.updateEntityWithOptionalForce(entity, false); entity.motionX = -0.39;
} entity.worldObj.updateEntityWithOptionalForce(entity, false);
else if(orientation==3||orientation==7) break;
{ case 1:
DDTeleporter.setEntityPosition(entity, x+.5, y, z+1.5 ); DDTeleporter.setEntityPosition(entity, x + 0.5, y, z - 0.5);
entity.motionZ =.39; entity.motionZ = -0.39;
entity.worldObj.updateEntityWithOptionalForce(entity, false); entity.worldObj.updateEntityWithOptionalForce(entity, false);
} break;
else if(orientation==0||orientation==4) case 2:
{ DDTeleporter.setEntityPosition(entity, x + 1.5, y, z + 0.5);
DDTeleporter.setEntityPosition(entity,x-.5, y, z+.5); entity.motionX = 0.39;
entity.motionX =-.39; entity.worldObj.updateEntityWithOptionalForce(entity, false);
entity.worldObj.updateEntityWithOptionalForce(entity, false); break;
} case 3:
else if(orientation==1||orientation==5) DDTeleporter.setEntityPosition(entity, x + 0.5, y, z + 1.5 );
{ entity.motionZ = 0.39;
DDTeleporter.setEntityPosition(entity,x+.5, y, z-.5); entity.worldObj.updateEntityWithOptionalForce(entity, false);
entity.motionZ =-.39; break;
entity.worldObj.updateEntityWithOptionalForce(entity, false); default:
} DDTeleporter.setEntityPosition(entity, x, y, z);
else break;
{
DDTeleporter.setEntityPosition(entity,x, y, z);
} }
} }
else if (entity instanceof Entity) else
{ {
entity.rotationYaw=(orientation*90)+90; switch (orientation)
if(orientation==2||orientation==6)
{ {
DDTeleporter.setEntityPosition(entity, x+1.5, y, z+.5 ); case 0:
} setEntityPosition(entity, x - 0.5, y, z + 0.5);
else if(orientation==3||orientation==7) break;
{ case 1:
setEntityPosition(entity, x + 0.5, y, z - 0.5);
DDTeleporter.setEntityPosition(entity, x+.5, y, z+1.5 ); break;
} case 2:
else if(orientation==0||orientation==4) setEntityPosition(entity, x + 1.5, y, z + 0.5);
{ break;
DDTeleporter.setEntityPosition(entity,x-.5, y, z+.5); case 3:
} setEntityPosition(entity, x + 0.5, y, z + 1.5);
else if(orientation==1||orientation==5) break;
{ default:
DDTeleporter.setEntityPosition(entity,x+.5, y, z-.5); setEntityPosition(entity, x, y, z);
} break;
else
{
DDTeleporter.setEntityPosition(entity,x, y, z);
} }
} }
} }
@@ -164,7 +164,7 @@ public class DDTeleporter
return world.getBlockMetadata(door.getX(), door.getY() - 1, door.getZ()) & 3; return world.getBlockMetadata(door.getX(), door.getY() - 1, door.getZ()) & 3;
} }
public static Entity teleportEntity(Entity entity, Point4D destination) public static Entity teleportEntity(Entity entity, Point4D destination, boolean checkOrientation)
{ {
if (entity == null) if (entity == null)
{ {
@@ -185,7 +185,7 @@ public class DDTeleporter
// Is something riding? Handle it first. // Is something riding? Handle it first.
if (entity.riddenByEntity != null) if (entity.riddenByEntity != null)
{ {
return teleportEntity(entity.riddenByEntity, destination); return teleportEntity(entity.riddenByEntity, destination, checkOrientation);
} }
// Are we riding something? Dismount and tell the mount to go first. // Are we riding something? Dismount and tell the mount to go first.
@@ -193,7 +193,7 @@ public class DDTeleporter
if (cart != null) if (cart != null)
{ {
entity.mountEntity(null); entity.mountEntity(null);
cart = teleportEntity(cart, destination); cart = teleportEntity(cart, destination, checkOrientation);
// We keep track of both so we can remount them on the other side. // We keep track of both so we can remount them on the other side.
} }
@@ -211,7 +211,7 @@ public class DDTeleporter
// GreyMaria: What is this even accomplishing? We're doing the exact same thing at the end of this all. // GreyMaria: What is this even accomplishing? We're doing the exact same thing at the end of this all.
// TODO Check to see if this is actually vital. // TODO Check to see if this is actually vital.
DDTeleporter.placeInPortal(entity, newWorld, destination, properties); DDTeleporter.placeInPortal(entity, newWorld, destination, properties, checkOrientation);
if (difDest) // Are we moving our target to a new dimension? if (difDest) // Are we moving our target to a new dimension?
{ {
@@ -306,7 +306,7 @@ public class DDTeleporter
GameRegistry.onPlayerChangedDimension((EntityPlayer)entity); GameRegistry.onPlayerChangedDimension((EntityPlayer)entity);
} }
DDTeleporter.placeInPortal(entity, newWorld, destination, properties); DDTeleporter.placeInPortal(entity, newWorld, destination, properties, checkOrientation);
return entity; return entity;
} }
@@ -355,13 +355,13 @@ public class DDTeleporter
Point4D randomDestination = getRandomDestination(); Point4D randomDestination = getRandomDestination();
if (randomDestination != null) if (randomDestination != null)
{ {
entity = teleportEntity(entity, randomDestination); entity = teleportEntity(entity, randomDestination, true);
entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F); entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F);
} }
} }
else else
{ {
entity = teleportEntity(entity, link.destination()); entity = teleportEntity(entity, link.destination(), link.linkType() != LinkTypes.UNSAFE_EXIT);
entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F); entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F);
} }
} }

View File

@@ -439,6 +439,10 @@ public abstract class NewDimData
{ {
throw new IllegalStateException("The dimension has already been initialized."); throw new IllegalStateException("The dimension has already been initialized.");
} }
if (orientation < 0 || orientation > 3)
{
throw new IllegalArgumentException("orientation must be between 0 and 3, inclusive.");
}
setDestination(incoming, originX, originY, originZ); setDestination(incoming, originX, originY, originZ);
this.origin = incoming.destination(); this.origin = incoming.destination();

View File

@@ -150,7 +150,7 @@ public class MobMonolith extends EntityFlying implements IMob
(int) this.posY + 500, (int) this.posY + 500,
(int) this.posZ + MathHelper.getRandomIntegerInRange(rand, -250, 250), (int) this.posZ + MathHelper.getRandomIntegerInRange(rand, -250, 250),
properties.LimboDimensionID); properties.LimboDimensionID);
DDTeleporter.teleportEntity(entityPlayer, destination); DDTeleporter.teleportEntity(entityPlayer, destination, false);
this.aggro = 0; this.aggro = 0;
entityPlayer.worldObj.playSoundAtEntity(entityPlayer,"mods.DimDoors.sfx.crack",13, 1); entityPlayer.worldObj.playSoundAtEntity(entityPlayer,"mods.DimDoors.sfx.crack",13, 1);