Skip to content
This repository has been archived by the owner on Jan 26, 2019. It is now read-only.

Commit

Permalink
Pass environment to transferrer and register with client
Browse files Browse the repository at this point in the history
  • Loading branch information
robotia committed Mar 4, 2016
1 parent d6c1555 commit 1a7e463
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,6 @@ public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cau
// Grab the To and From World Handles.
net.minecraft.world.WorldServer fromWorld = ((CraftWorld) from.getWorld()).getHandle();
net.minecraft.world.WorldServer toWorld = ((CraftWorld) to.getWorld()).getHandle();

// Close any foreign inventory
if (getHandle().openContainer != getHandle().inventoryContainer) {
getHandle().closeScreen();
Expand All @@ -506,7 +505,7 @@ public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cau
} else {
//Thermos....transfer them correctly?!
this.getHandle().mountEntity(null);
thermos.thermite.ThermiteTeleportationHandler.transferPlayerToDimension(this.getHandle(), toWorld.dimension, this.getHandle().mcServer.getConfigurationManager());
thermos.thermite.ThermiteTeleportationHandler.transferPlayerToDimension(this.getHandle(), toWorld.dimension, this.getHandle().mcServer.getConfigurationManager(), to.getWorld().getEnvironment());
//this.getHandle().playerNetServerHandler.teleport(to);
this.getHandle().playerNetServerHandler.teleport(to);
//this.getHandle().playerNetServerHandler.setPlayerLocation(to.getX(), to.getY(), to.getZ(), this.getHandle().rotationYaw, this.getHandle().rotationPitch);
Expand Down
26 changes: 20 additions & 6 deletions src/main/java/thermos/thermite/ThermiteTeleportationHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

import java.util.Iterator;

import org.bukkit.World.Environment;

import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.network.FMLEmbeddedChannel;
import cpw.mods.fml.common.network.FMLOutboundHandler;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.play.server.S07PacketRespawn;
Expand All @@ -12,12 +16,15 @@
import net.minecraft.util.MathHelper;
import net.minecraft.world.WorldProvider;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.network.ForgeMessage;
import net.minecraftforge.common.network.ForgeNetworkHandler;

public class ThermiteTeleportationHandler {
public static void transferEntityToDimension(Entity ent, int dim, ServerConfigurationManager manager) {
public static void transferEntityToDimension(Entity ent, int dim, ServerConfigurationManager manager, Environment environ) {

if (ent instanceof EntityPlayerMP) {
transferPlayerToDimension((EntityPlayerMP) ent, dim, manager);
transferPlayerToDimension((EntityPlayerMP) ent, dim, manager, environ);
return;
}
WorldServer worldserver = manager.getServerInstance().worldServerForDimension(ent.dimension);
Expand Down Expand Up @@ -53,15 +60,22 @@ public static void transferEntityToWorld(Entity ent, WorldServer oldWorld, World
ent.setWorld(newWorld);
}

public static void transferPlayerToDimension(EntityPlayerMP player, int dim, ServerConfigurationManager manager) {
public static void transferPlayerToDimension(EntityPlayerMP player, int dim, ServerConfigurationManager manager, Environment environ) {

int oldDim = player.dimension;
WorldServer worldserver = manager.getServerInstance().worldServerForDimension(player.dimension);
player.dimension = dim;
WorldServer worldserver1 = manager.getServerInstance().worldServerForDimension(player.dimension);
int fakeDim = dim;
if(!net.minecraftforge.common.DimensionManager.isDimensionRegistered(dim))fakeDim = 0;
player.playerNetServerHandler.sendPacket(new S07PacketRespawn(fakeDim, player.worldObj.difficultySetting, player.worldObj.getWorldInfo()
// Cauldron dont crash the client, let 'em know there's a new dimension in town
if (DimensionManager.isBukkitDimension(dim))
{
FMLEmbeddedChannel serverChannel = ForgeNetworkHandler.getServerChannel();
serverChannel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER);
serverChannel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player);
serverChannel.writeOutbound(new ForgeMessage.DimensionRegisterMessage(dim, environ.getId()));
}
// Cauldron end
player.playerNetServerHandler.sendPacket(new S07PacketRespawn(dim, worldserver1.difficultySetting, worldserver1.getWorldInfo()
.getTerrainType(), player.theItemInWorldManager.getGameType()));
worldserver.removePlayerEntityDangerously(player);
if (player.riddenByEntity != null) {
Expand Down

0 comments on commit 1a7e463

Please sign in to comment.