Fixed Transdimensional Trapdoor and More #87
@@ -10,11 +10,11 @@ import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingFallEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import StevenDimDoors.mod_pocketDim.core.DDTeleporter;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.ticking.RiftRegenerator;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
import StevenDimDoors.mod_pocketDim.world.LimboProvider;
|
||||
import StevenDimDoors.mod_pocketDim.world.PocketProvider;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -69,8 +69,11 @@ public class EventHookContainer
|
||||
public boolean LivingDeathEvent(LivingDeathEvent event)
|
||||
{
|
||||
Entity entity = event.entity;
|
||||
if (entity instanceof EntityPlayer && entity.worldObj.provider instanceof PocketProvider
|
||||
&& properties.LimboEnabled)
|
||||
|
||||
if (entity instanceof EntityPlayer && properties.LimboEnabled)
|
||||
{
|
||||
NewDimData dimension = PocketManager.getDimensionData(entity.worldObj);
|
||||
if (dimension.isDungeon())
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
if (!properties.LimboReturnsInventoryEnabled)
|
||||
@@ -78,11 +81,13 @@ public class EventHookContainer
|
||||
player.inventory.clearInventory(-1, -1);
|
||||
}
|
||||
ChunkCoordinates coords = LimboProvider.getLimboSkySpawn(player.worldObj.rand);
|
||||
DDTeleporter.teleportEntity(player, new Point4D(coords.posX, coords.posY, coords.posZ, mod_pocketDim.properties.LimboDimensionID));
|
||||
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;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public class BlockDimWallPerm extends Block
|
||||
//FIXME: Shouldn't we make the player's destination safe BEFORE teleporting him?!
|
||||
//player.setPositionAndUpdate( x, y, z );
|
||||
Point4D destination = new Point4D(destinationX, destinationY, destinationZ, 0);
|
||||
DDTeleporter.teleportEntity(player, destination);
|
||||
DDTeleporter.teleportEntity(player, destination, false);
|
||||
|
||||
//player.setPositionAndUpdate( x, y, z );
|
||||
|
||||
|
||||
@@ -39,98 +39,98 @@ public class 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 y = destination.getY();
|
||||
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)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
player.rotationYaw=(orientation*90)+90;
|
||||
if(orientation==2||orientation==6)
|
||||
switch (orientation)
|
||||
{
|
||||
player.setPositionAndUpdate( x+1.5, y-1, z+.5 );
|
||||
}
|
||||
else if(orientation==3||orientation==7)
|
||||
{
|
||||
player.setPositionAndUpdate( x+.5, y-1, z+1.5 );
|
||||
}
|
||||
else if(orientation==0||orientation==4)
|
||||
{
|
||||
player.setPositionAndUpdate(x-.5, y-1, z+.5);
|
||||
}
|
||||
else if(orientation==1||orientation==5)
|
||||
{
|
||||
player.setPositionAndUpdate(x+.5, y-1, z-.5);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setPositionAndUpdate(x, y-1, z);
|
||||
case 0:
|
||||
player.setPositionAndUpdate(x - 0.5, y - 1, z + 0.5);
|
||||
break;
|
||||
case 1:
|
||||
player.setPositionAndUpdate(x + 0.5, y - 1, z - 0.5);
|
||||
break;
|
||||
case 2:
|
||||
player.setPositionAndUpdate(x + 1.5, y - 1, z + 0.5);
|
||||
break;
|
||||
case 3:
|
||||
player.setPositionAndUpdate(x + 0.5, y - 1, z + 1.5);
|
||||
break;
|
||||
default:
|
||||
player.setPositionAndUpdate(x, y - 1, z);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (entity instanceof EntityMinecart)
|
||||
{
|
||||
entity.motionX=0;
|
||||
entity.motionZ=0;
|
||||
entity.motionY=0;
|
||||
entity.rotationYaw=(orientation*90)+90;
|
||||
entity.motionX = 0;
|
||||
entity.motionZ = 0;
|
||||
entity.motionY = 0;
|
||||
|
||||
if(orientation==2||orientation==6)
|
||||
switch (orientation)
|
||||
{
|
||||
DDTeleporter.setEntityPosition(entity, x+1.5, y, z+.5 );
|
||||
entity.motionX =.39;
|
||||
case 0:
|
||||
DDTeleporter.setEntityPosition(entity, x - 0.5, y, z + 0.5);
|
||||
entity.motionX = -0.39;
|
||||
entity.worldObj.updateEntityWithOptionalForce(entity, false);
|
||||
break;
|
||||
case 1:
|
||||
DDTeleporter.setEntityPosition(entity, x + 0.5, y, z - 0.5);
|
||||
entity.motionZ = -0.39;
|
||||
entity.worldObj.updateEntityWithOptionalForce(entity, false);
|
||||
break;
|
||||
case 2:
|
||||
DDTeleporter.setEntityPosition(entity, x + 1.5, y, z + 0.5);
|
||||
entity.motionX = 0.39;
|
||||
entity.worldObj.updateEntityWithOptionalForce(entity, false);
|
||||
break;
|
||||
case 3:
|
||||
DDTeleporter.setEntityPosition(entity, x + 0.5, y, z + 1.5 );
|
||||
entity.motionZ = 0.39;
|
||||
entity.worldObj.updateEntityWithOptionalForce(entity, false);
|
||||
break;
|
||||
default:
|
||||
DDTeleporter.setEntityPosition(entity, x, y, z);
|
||||
break;
|
||||
}
|
||||
else if(orientation==3||orientation==7)
|
||||
{
|
||||
DDTeleporter.setEntityPosition(entity, x+.5, y, z+1.5 );
|
||||
entity.motionZ =.39;
|
||||
entity.worldObj.updateEntityWithOptionalForce(entity, false);
|
||||
}
|
||||
else if(orientation==0||orientation==4)
|
||||
{
|
||||
DDTeleporter.setEntityPosition(entity,x-.5, y, z+.5);
|
||||
entity.motionX =-.39;
|
||||
entity.worldObj.updateEntityWithOptionalForce(entity, false);
|
||||
}
|
||||
else if(orientation==1||orientation==5)
|
||||
{
|
||||
DDTeleporter.setEntityPosition(entity,x+.5, y, z-.5);
|
||||
entity.motionZ =-.39;
|
||||
entity.worldObj.updateEntityWithOptionalForce(entity, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
DDTeleporter.setEntityPosition(entity,x, y, z);
|
||||
}
|
||||
}
|
||||
else if (entity instanceof Entity)
|
||||
switch (orientation)
|
||||
{
|
||||
entity.rotationYaw=(orientation*90)+90;
|
||||
if(orientation==2||orientation==6)
|
||||
{
|
||||
DDTeleporter.setEntityPosition(entity, x+1.5, y, z+.5 );
|
||||
}
|
||||
else if(orientation==3||orientation==7)
|
||||
{
|
||||
|
||||
DDTeleporter.setEntityPosition(entity, x+.5, y, z+1.5 );
|
||||
}
|
||||
else if(orientation==0||orientation==4)
|
||||
{
|
||||
DDTeleporter.setEntityPosition(entity,x-.5, y, z+.5);
|
||||
}
|
||||
else if(orientation==1||orientation==5)
|
||||
{
|
||||
DDTeleporter.setEntityPosition(entity,x+.5, y, z-.5);
|
||||
}
|
||||
else
|
||||
{
|
||||
DDTeleporter.setEntityPosition(entity,x, y, z);
|
||||
case 0:
|
||||
setEntityPosition(entity, x - 0.5, y, z + 0.5);
|
||||
break;
|
||||
case 1:
|
||||
setEntityPosition(entity, x + 0.5, y, z - 0.5);
|
||||
break;
|
||||
case 2:
|
||||
setEntityPosition(entity, x + 1.5, y, z + 0.5);
|
||||
break;
|
||||
case 3:
|
||||
setEntityPosition(entity, x + 0.5, y, z + 1.5);
|
||||
break;
|
||||
default:
|
||||
setEntityPosition(entity, x, y, z);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -164,7 +164,7 @@ public class DDTeleporter
|
||||
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)
|
||||
{
|
||||
@@ -185,7 +185,7 @@ public class DDTeleporter
|
||||
// Is something riding? Handle it first.
|
||||
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.
|
||||
@@ -193,7 +193,7 @@ public class DDTeleporter
|
||||
if (cart != 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.
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
// 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?
|
||||
{
|
||||
@@ -306,7 +306,7 @@ public class DDTeleporter
|
||||
GameRegistry.onPlayerChangedDimension((EntityPlayer)entity);
|
||||
|
||||
}
|
||||
DDTeleporter.placeInPortal(entity, newWorld, destination, properties);
|
||||
DDTeleporter.placeInPortal(entity, newWorld, destination, properties, checkOrientation);
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -355,13 +355,13 @@ public class DDTeleporter
|
||||
Point4D randomDestination = getRandomDestination();
|
||||
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);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -439,6 +439,10 @@ public abstract class NewDimData
|
||||
{
|
||||
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);
|
||||
this.origin = incoming.destination();
|
||||
|
||||
@@ -150,7 +150,7 @@ public class MobMonolith extends EntityFlying implements IMob
|
||||
(int) this.posY + 500,
|
||||
(int) this.posZ + MathHelper.getRandomIntegerInRange(rand, -250, 250),
|
||||
properties.LimboDimensionID);
|
||||
DDTeleporter.teleportEntity(entityPlayer, destination);
|
||||
DDTeleporter.teleportEntity(entityPlayer, destination, false);
|
||||
this.aggro = 0;
|
||||
|
||||
entityPlayer.worldObj.playSoundAtEntity(entityPlayer,"mods.DimDoors.sfx.crack",13, 1);
|
||||
|
||||
Reference in New Issue
Block a user