2013-02-18 03:46:16 +01:00
|
|
|
package StevenDimDoors.mod_pocketDim;
|
|
|
|
|
2013-06-10 23:03:52 +02:00
|
|
|
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
2013-02-18 03:46:16 +01:00
|
|
|
import net.minecraft.entity.Entity;
|
2013-03-10 05:04:20 +01:00
|
|
|
import net.minecraft.entity.item.EntityMinecart;
|
2013-02-18 03:46:16 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.world.Teleporter;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraft.world.WorldServer;
|
|
|
|
|
2013-04-07 06:37:13 +02:00
|
|
|
public class pocketTeleporter
|
2013-02-18 03:46:16 +01:00
|
|
|
{
|
|
|
|
int x,y,z;
|
2013-04-07 06:37:13 +02:00
|
|
|
|
2013-02-18 03:46:16 +01:00
|
|
|
LinkData sendingLink;
|
|
|
|
|
|
|
|
|
2013-04-07 06:37:13 +02:00
|
|
|
public pocketTeleporter()
|
2013-02-18 03:46:16 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2013-04-07 06:37:13 +02:00
|
|
|
|
2013-02-18 03:46:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new portal near an entity.
|
|
|
|
*/
|
2013-04-07 06:37:13 +02:00
|
|
|
|
|
|
|
public void placeInPortal(Entity par1Entity, WorldServer world, LinkData link)
|
2013-03-10 05:04:20 +01:00
|
|
|
{
|
2013-04-07 06:37:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
this.x=link.destXCoord;
|
|
|
|
this.y=link.destYCoord;
|
|
|
|
this.z=link.destZCoord;
|
2013-05-09 23:16:27 +02:00
|
|
|
|
2013-04-07 06:37:13 +02:00
|
|
|
this.sendingLink=link;
|
|
|
|
|
2013-05-09 23:16:27 +02:00
|
|
|
int id;
|
|
|
|
|
|
|
|
|
|
|
|
id=dimHelper.instance.getDestOrientation(sendingLink);
|
|
|
|
|
|
|
|
|
2013-03-10 05:04:20 +01:00
|
|
|
if(par1Entity instanceof EntityPlayer)
|
|
|
|
{
|
|
|
|
EntityPlayer player = (EntityPlayer) par1Entity;
|
2013-02-18 03:46:16 +01:00
|
|
|
|
|
|
|
|
2013-05-09 23:16:27 +02:00
|
|
|
|
|
|
|
|
2013-02-18 03:46:16 +01:00
|
|
|
//System.out.println("Teleporting with link oreintation "+id);
|
|
|
|
|
2013-03-10 05:04:20 +01:00
|
|
|
|
|
|
|
player.rotationYaw=(id*90)+90;
|
|
|
|
if(id==2||id==6)
|
|
|
|
{
|
|
|
|
player.setPositionAndUpdate( x+1.5, y-1, z+.5 );
|
2013-02-18 03:46:16 +01:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
else if(id==3||id==7)
|
|
|
|
{
|
|
|
|
|
|
|
|
player.setPositionAndUpdate( x+.5, y-1, z+1.5 );
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
else if(id==0||id==4)
|
|
|
|
{
|
|
|
|
|
|
|
|
player.setPositionAndUpdate(x-.5, y-1, z+.5);
|
|
|
|
|
|
|
|
}
|
|
|
|
else if(id==1||id==5)
|
|
|
|
{
|
|
|
|
player.setPositionAndUpdate(x+.5, y-1, z-.5);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
player.setPositionAndUpdate(x, y-1, z);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-03-10 05:04:20 +01:00
|
|
|
}
|
2013-03-10 23:39:17 +01:00
|
|
|
|
2013-03-10 05:04:20 +01:00
|
|
|
else if(par1Entity instanceof EntityMinecart)
|
|
|
|
{
|
2013-03-10 17:49:29 +01:00
|
|
|
par1Entity.motionX=0;
|
|
|
|
par1Entity.motionZ=0;
|
|
|
|
par1Entity.motionY=0;
|
2013-05-09 23:16:27 +02:00
|
|
|
|
2013-03-10 05:04:20 +01:00
|
|
|
|
2013-03-18 23:42:56 +01:00
|
|
|
|
2013-03-10 23:39:17 +01:00
|
|
|
par1Entity.rotationYaw=(id*90)+90;
|
2013-03-10 05:04:20 +01:00
|
|
|
|
|
|
|
if(id==2||id==6)
|
|
|
|
{
|
2013-03-10 17:49:29 +01:00
|
|
|
|
2013-03-10 23:39:17 +01:00
|
|
|
|
2013-03-10 05:04:20 +01:00
|
|
|
this.setEntityPosition(par1Entity, x+1.5, y, z+.5 );
|
2013-03-10 23:39:17 +01:00
|
|
|
par1Entity.motionX =.39;
|
2013-04-01 09:15:16 +02:00
|
|
|
par1Entity.worldObj.updateEntityWithOptionalForce(par1Entity, false);
|
|
|
|
|
2013-03-10 05:04:20 +01:00
|
|
|
}
|
|
|
|
else if(id==3||id==7)
|
|
|
|
{
|
|
|
|
|
2013-03-10 23:39:17 +01:00
|
|
|
|
2013-03-10 17:49:29 +01:00
|
|
|
this.setEntityPosition(par1Entity, x+.5, y, z+1.5 );
|
2013-03-10 23:39:17 +01:00
|
|
|
par1Entity.motionZ =.39;
|
2013-04-01 09:15:16 +02:00
|
|
|
par1Entity.worldObj.updateEntityWithOptionalForce(par1Entity, false);
|
|
|
|
|
2013-03-10 17:49:29 +01:00
|
|
|
|
2013-03-10 05:04:20 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
else if(id==0||id==4)
|
|
|
|
{
|
|
|
|
|
2013-03-10 23:39:17 +01:00
|
|
|
|
2013-03-10 17:49:29 +01:00
|
|
|
this.setEntityPosition(par1Entity,x-.5, y, z+.5);
|
2013-03-10 23:39:17 +01:00
|
|
|
par1Entity.motionX =-.39;
|
2013-04-01 09:15:16 +02:00
|
|
|
par1Entity.worldObj.updateEntityWithOptionalForce(par1Entity, false);
|
|
|
|
|
2013-03-10 17:49:29 +01:00
|
|
|
|
2013-03-10 05:04:20 +01:00
|
|
|
}
|
|
|
|
else if(id==1||id==5)
|
|
|
|
{
|
2013-03-10 23:39:17 +01:00
|
|
|
|
2013-03-10 17:49:29 +01:00
|
|
|
this.setEntityPosition(par1Entity,x+.5, y, z-.5);
|
2013-03-10 23:39:17 +01:00
|
|
|
par1Entity.motionZ =-.39;
|
2013-04-01 09:15:16 +02:00
|
|
|
par1Entity.worldObj.updateEntityWithOptionalForce(par1Entity, false);
|
|
|
|
|
2013-03-10 17:49:29 +01:00
|
|
|
|
2013-03-10 05:04:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.setEntityPosition(par1Entity,x, y, z);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-03-10 23:39:17 +01:00
|
|
|
|
2013-03-10 05:04:20 +01:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
else if(par1Entity instanceof Entity)
|
|
|
|
{
|
2013-05-09 23:16:27 +02:00
|
|
|
|
2013-03-10 05:04:20 +01:00
|
|
|
//System.out.println("Teleporting with link oreintation "+id);
|
|
|
|
|
|
|
|
|
|
|
|
par1Entity.rotationYaw=(id*90)+90;
|
|
|
|
|
2013-03-18 23:42:56 +01:00
|
|
|
// EntityMinecart.class.cast(par1Entity).isinreverse=false;
|
2013-03-10 05:04:20 +01:00
|
|
|
if(id==2||id==6)
|
|
|
|
{
|
|
|
|
this.setEntityPosition(par1Entity, x+1.5, y, z+.5 );
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
else if(id==3||id==7)
|
|
|
|
{
|
|
|
|
|
|
|
|
this.setEntityPosition(par1Entity, x+.5, y, z+1.5 );
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
else if(id==0||id==4)
|
|
|
|
{
|
|
|
|
|
|
|
|
this.setEntityPosition(par1Entity,x-.5, y, z+.5);
|
|
|
|
|
|
|
|
}
|
|
|
|
else if(id==1||id==5)
|
|
|
|
{
|
|
|
|
this.setEntityPosition(par1Entity,x+.5, y, z-.5);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.setEntityPosition(par1Entity,x, y, z);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2013-03-10 23:39:17 +01:00
|
|
|
|
2013-02-18 03:46:16 +01:00
|
|
|
}
|
|
|
|
|
2013-03-10 05:04:20 +01:00
|
|
|
public void setEntityPosition(Entity entity, double x, double y, double z)
|
|
|
|
{
|
|
|
|
entity.lastTickPosX = entity.prevPosX = entity.posX = x;
|
|
|
|
entity.lastTickPosY = entity.prevPosY = entity.posY = y + (double)entity.yOffset;
|
|
|
|
entity.lastTickPosZ = entity.prevPosZ = entity.posZ = z;
|
|
|
|
entity.setPosition(x, y, z);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-03-29 23:19:27 +01:00
|
|
|
|
2013-04-07 06:37:13 +02:00
|
|
|
|
2013-02-18 03:46:16 +01:00
|
|
|
}
|