Add the game mechanic for warping the player directly to Thresholds when falling out of the world.
This commit is contained in:
parent
a644bf3994
commit
27b184a040
1 changed files with 22 additions and 0 deletions
|
@ -7,6 +7,7 @@ import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||||
import dev.zontreck.libzontreck.util.ItemUtils;
|
import dev.zontreck.libzontreck.util.ItemUtils;
|
||||||
import dev.zontreck.libzontreck.util.heads.HeadUtilities;
|
import dev.zontreck.libzontreck.util.heads.HeadUtilities;
|
||||||
|
import dev.zontreck.libzontreck.vectors.Vector3;
|
||||||
import dev.zontreck.libzontreck.vectors.WorldPosition;
|
import dev.zontreck.libzontreck.vectors.WorldPosition;
|
||||||
import dev.zontreck.otemod.OTEMod;
|
import dev.zontreck.otemod.OTEMod;
|
||||||
import dev.zontreck.otemod.configs.OTEServerConfig;
|
import dev.zontreck.otemod.configs.OTEServerConfig;
|
||||||
|
@ -22,6 +23,9 @@ import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.server.level.ServerPlayerGameMode;
|
import net.minecraft.server.level.ServerPlayerGameMode;
|
||||||
|
import net.minecraft.world.damagesource.DamageSource;
|
||||||
|
import net.minecraft.world.damagesource.DamageSources;
|
||||||
|
import net.minecraft.world.damagesource.DamageTypes;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.entity.item.ItemEntity;
|
import net.minecraft.world.entity.item.ItemEntity;
|
||||||
|
@ -32,6 +36,7 @@ import net.minecraft.world.level.GameType;
|
||||||
import net.minecraftforge.common.ForgeSpawnEggItem;
|
import net.minecraftforge.common.ForgeSpawnEggItem;
|
||||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||||
|
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||||
import net.minecraftforge.eventbus.api.EventPriority;
|
import net.minecraftforge.eventbus.api.EventPriority;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
@ -111,6 +116,23 @@ public class EventHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onPlayerFallOutOfWorld(LivingHurtEvent ev)
|
||||||
|
{
|
||||||
|
if(ev.getEntity() instanceof Player)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(ev.getSource().is(DamageTypes.FELL_OUT_OF_WORLD))
|
||||||
|
{
|
||||||
|
// Teleport the player to Thresholds
|
||||||
|
WorldPosition pos = new WorldPosition(new Vector3(), ModDimensions.THRESHOLD_DIM());
|
||||||
|
ServerPlayer sp = (ServerPlayer) ev.getEntity();
|
||||||
|
sp.teleportTo(pos.getActualDimension(), 0, 365, 0, 0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onEntityKilled(LivingDropsEvent ev){
|
public void onEntityKilled(LivingDropsEvent ev){
|
||||||
if(ev.getEntity().level().isClientSide)return;
|
if(ev.getEntity().level().isClientSide)return;
|
||||||
|
|
Reference in a new issue