From 59e0172dfddcc2ea17e45154527b955c7ba07341 Mon Sep 17 00:00:00 2001 From: Amnet Date: Thu, 30 May 2013 00:37:21 +0200 Subject: [PATCH] Falling out of the world in the Promised Land will teleport to y=256 in OW. --- .../biomesoplenty/helpers/EntitiesHelper.java | 22 +++++++++++++++++++ .../biomesoplenty/helpers/TeleporterFall.java | 19 ++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 src/minecraft/biomesoplenty/helpers/TeleporterFall.java diff --git a/src/minecraft/biomesoplenty/helpers/EntitiesHelper.java b/src/minecraft/biomesoplenty/helpers/EntitiesHelper.java index e7a2b4810..324b9b606 100644 --- a/src/minecraft/biomesoplenty/helpers/EntitiesHelper.java +++ b/src/minecraft/biomesoplenty/helpers/EntitiesHelper.java @@ -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))); + } + } + } + } } diff --git a/src/minecraft/biomesoplenty/helpers/TeleporterFall.java b/src/minecraft/biomesoplenty/helpers/TeleporterFall.java new file mode 100644 index 000000000..11a40da87 --- /dev/null +++ b/src/minecraft/biomesoplenty/helpers/TeleporterFall.java @@ -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; + } +}