Falling out of the world in the Promised Land will teleport to y=256 in

OW.
This commit is contained in:
Amnet 2013-05-30 00:37:21 +02:00
parent b686323c08
commit 59e0172dfd
2 changed files with 41 additions and 0 deletions

View File

@ -8,14 +8,18 @@ import net.minecraft.entity.passive.EntityChicken;
import net.minecraft.entity.passive.EntityCow;
import net.minecraft.entity.passive.EntityPig;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraftforge.event.Event.Result;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.event.entity.living.LivingSpawnEvent.CheckSpawn;
import biomesoplenty.api.Blocks;
import biomesoplenty.api.Items;
import biomesoplenty.configuration.BOPConfiguration;
import biomesoplenty.mobs.ai.EntityAITemptArmour;
public class EntitiesHelper
@ -59,4 +63,22 @@ public class EntitiesHelper
event.setResult(Result.ALLOW);
}
}
@ForgeSubscribe
public void fallingFromPromisedLand(LivingHurtEvent event)
{
if (event.source == DamageSource.outOfWorld && event.entityLiving.dimension == BOPConfiguration.promisedLandDimID)
{
event.setCanceled(true);
if (!event.entityLiving.worldObj.isRemote && !event.entityLiving.isDead)
{
if (event.entityLiving instanceof EntityPlayerMP)
{
EntityPlayerMP thePlayer = (EntityPlayerMP) event.entityLiving;
thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, 0, new TeleporterFall(thePlayer.mcServer.worldServerForDimension(0)));
}
}
}
}
}

View File

@ -0,0 +1,19 @@
package biomesoplenty.helpers;
import net.minecraft.entity.Entity;
import net.minecraft.world.Teleporter;
import net.minecraft.world.WorldServer;
public class TeleporterFall extends Teleporter
{
public TeleporterFall(WorldServer par1WorldServer)
{
super(par1WorldServer);
}
public void placeInPortal(Entity par1Entity, double par2, double par4, double par6, float par8)
{
par1Entity.setLocationAndAngles(par2, 256.0, par6, par1Entity.rotationYaw, 0.0F);
par1Entity.motionX = par1Entity.motionY = par1Entity.motionZ = 0.0D;
}
}