finally fixed minecart door crashes
Signed-off-by: StevenRS11 <stevenrs11@aol.com>
This commit is contained in:
@@ -8,12 +8,17 @@ import java.util.Collection;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.network.INetworkManager;
|
import net.minecraft.network.INetworkManager;
|
||||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
|
|
||||||
|
import cpw.mods.fml.client.FMLClientHandler;
|
||||||
|
import cpw.mods.fml.common.network.FMLNetworkHandler;
|
||||||
import cpw.mods.fml.common.network.IPacketHandler;
|
import cpw.mods.fml.common.network.IPacketHandler;
|
||||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||||
import cpw.mods.fml.common.network.Player;
|
import cpw.mods.fml.common.network.Player;
|
||||||
@@ -25,6 +30,7 @@ public class PacketHandler implements IPacketHandler
|
|||||||
public static int removeLinkPacketID = 5;
|
public static int removeLinkPacketID = 5;
|
||||||
public static int linkKeyPacketID = 7;
|
public static int linkKeyPacketID = 7;
|
||||||
public static int dimPacketID = 6;
|
public static int dimPacketID = 6;
|
||||||
|
public static int updateRiderPacketID = 8;
|
||||||
|
|
||||||
|
|
||||||
public static int dimUpdatePacketID = 1;
|
public static int dimUpdatePacketID = 1;
|
||||||
@@ -142,6 +148,23 @@ public class PacketHandler implements IPacketHandler
|
|||||||
LinkData link = new LinkData(data.readInt(), data.readInt(), data.readInt(), data.readInt());
|
LinkData link = new LinkData(data.readInt(), data.readInt(), data.readInt(), data.readInt());
|
||||||
dimHelper.instance.interDimLinkList.put(data.readInt(), link);
|
dimHelper.instance.interDimLinkList.put(data.readInt(), link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(id==this.updateRiderPacketID)
|
||||||
|
{
|
||||||
|
int mountID=data.readInt();
|
||||||
|
EntityPlayer playerSP = FMLClientHandler.instance().getClient().thePlayer;
|
||||||
|
World world = playerSP.worldObj;
|
||||||
|
Entity mount = world.getEntityByID(mountID);
|
||||||
|
|
||||||
|
//playerSP.mountEntity(mount);
|
||||||
|
//playerSP.ridingEntity=mount;
|
||||||
|
//mount.riddenByEntity=playerSP;
|
||||||
|
|
||||||
|
playerSP.updateRiderPosition();
|
||||||
|
|
||||||
|
//mount.updateRidden();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -409,6 +432,37 @@ public class PacketHandler implements IPacketHandler
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Packet250CustomPayload sendUpdateRiderPacket(int id)
|
||||||
|
{
|
||||||
|
|
||||||
|
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||||
|
DataOutputStream dataOut = new DataOutputStream(bos);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
dataOut.writeByte(PacketHandler.updateRiderPacketID);
|
||||||
|
|
||||||
|
dataOut.writeInt(id);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
Packet250CustomPayload packet= new Packet250CustomPayload();
|
||||||
|
packet.channel="DimDoorPackets";
|
||||||
|
packet.data = bos.toByteArray();
|
||||||
|
packet.length = bos.size();;
|
||||||
|
PacketDispatcher.sendPacketToAllPlayers(packet);
|
||||||
|
return packet;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -99,35 +99,32 @@ public class dimDoor extends BlockContainer
|
|||||||
linkData= dimHelper.instance.getLinkDataFromCoords(par2, par3+1, par4, par1World);
|
linkData= dimHelper.instance.getLinkDataFromCoords(par2, par3+1, par4, par1World);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!(par5Entity instanceof EntityPlayer)&&num>3)
|
||||||
|
{
|
||||||
|
this.onPoweredBlockChange(par1World, par2, par3, par4, false);
|
||||||
|
dimHelper.instance.teleportToPocket(par1World, linkData, par5Entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(!par1World.isRemote&&(num==5||num==4||num==6||num==7)&&(num-4)==var12)
|
||||||
if(!par1World.isRemote&&(num==5||num==4||num==6||num==7)&&(num-4)==var12)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
//int destinationID= dimHelper.instance.getDestIDFromCoords(par2, par3, par4, par1World);
|
//int destinationID= dimHelper.instance.getDestIDFromCoords(par2, par3, par4, par1World);
|
||||||
|
|
||||||
|
|
||||||
|
this.onPoweredBlockChange(par1World, par2, par3, par4, false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//if(par5Entity instanceof EntityLiving)
|
|
||||||
{
|
|
||||||
this.onPoweredBlockChange(par1World, par2, par3, par4, false);
|
|
||||||
}
|
|
||||||
dimHelper.instance.teleportToPocket(par1World, linkData, par5Entity);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (!(par5Entity instanceof EntityPlayer)&&num>3)
|
|
||||||
{
|
|
||||||
|
|
||||||
if(par5Entity instanceof EntityLiving)
|
|
||||||
{
|
|
||||||
this.onPoweredBlockChange(par1World, par2, par3, par4, false);
|
|
||||||
}
|
|
||||||
dimHelper.instance.teleportToPocket(par1World, linkData, par5Entity);
|
dimHelper.instance.teleportToPocket(par1World, linkData, par5Entity);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.network.packet.Packet10Flying;
|
||||||
import net.minecraft.network.packet.Packet39AttachEntity;
|
import net.minecraft.network.packet.Packet39AttachEntity;
|
||||||
import net.minecraft.network.packet.Packet41EntityEffect;
|
import net.minecraft.network.packet.Packet41EntityEffect;
|
||||||
import net.minecraft.network.packet.Packet43Experience;
|
import net.minecraft.network.packet.Packet43Experience;
|
||||||
@@ -135,25 +136,22 @@ public class dimHelper extends DimensionManager
|
|||||||
|
|
||||||
private Entity teleportEntity(World oldWorld, Entity entity, LinkData link) //this beautiful teleport method is based off of xCompWiz's teleport function.
|
private Entity teleportEntity(World oldWorld, Entity entity, LinkData link) //this beautiful teleport method is based off of xCompWiz's teleport function.
|
||||||
{
|
{
|
||||||
Entity cart;
|
Entity cart=entity.ridingEntity;
|
||||||
if(entity.riddenByEntity!=null)
|
if(entity.riddenByEntity!=null)
|
||||||
{
|
{
|
||||||
cart= entity;
|
return this.teleportEntity(oldWorld,entity.riddenByEntity, link);
|
||||||
entity=entity.riddenByEntity;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (entity.ridingEntity != null)
|
||||||
{
|
{
|
||||||
|
entity.mountEntity(null);
|
||||||
cart = entity.ridingEntity;
|
cart = teleportEntity(oldWorld, cart, link);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if (entity.ridingEntity != null)
|
|
||||||
{
|
|
||||||
|
|
||||||
entity.mountEntity(entity.ridingEntity);
|
|
||||||
|
|
||||||
cart = teleportEntity(oldWorld, cart, link);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -176,7 +174,8 @@ public class dimHelper extends DimensionManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mod_pocketDim.teleporter.placeInPortal(entity, newWorld, link);
|
||||||
|
|
||||||
if ((entity instanceof EntityPlayerMP))
|
if ((entity instanceof EntityPlayerMP))
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -264,28 +263,32 @@ public class dimHelper extends DimensionManager
|
|||||||
|
|
||||||
entity.worldObj.updateEntityWithOptionalForce(entity, false);
|
entity.worldObj.updateEntityWithOptionalForce(entity, false);
|
||||||
|
|
||||||
mod_pocketDim.teleporter.placeInPortal(entity, newWorld, link);
|
|
||||||
|
|
||||||
|
|
||||||
if ((entity != null) && (cart != null))
|
if ((entity != null) && (cart != null))
|
||||||
{
|
{
|
||||||
|
|
||||||
if ((entity instanceof EntityPlayerMP))
|
if ((entity instanceof EntityPlayerMP))
|
||||||
{
|
{
|
||||||
EntityPlayerMP playerMP = (EntityPlayerMP)entity;
|
EntityPlayerMP playerMP = (EntityPlayerMP)entity;
|
||||||
entity.worldObj.updateEntityWithOptionalForce(entity, true);
|
entity.worldObj.updateEntityWithOptionalForce(entity, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
entity.mountEntity(cart);
|
entity.mountEntity(cart);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(entity instanceof EntityPlayerMP)
|
||||||
|
{
|
||||||
|
WorldServer.class.cast(newWorld).theChunkProviderServer.loadChunk(MathHelper.floor_double(entity.posX) >> 4, MathHelper.floor_double(entity.posZ) >> 4);
|
||||||
|
}
|
||||||
|
mod_pocketDim.teleporter.placeInPortal(entity, newWorld, link);
|
||||||
|
return entity;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(entity instanceof EntityPlayerMP)
|
|
||||||
{
|
|
||||||
WorldServer.class.cast(newWorld).theChunkProviderServer.loadChunk(MathHelper.floor_double(entity.posX) >> 4, MathHelper.floor_double(entity.posZ) >> 4);
|
|
||||||
}
|
|
||||||
return entity;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -306,6 +309,8 @@ public class dimHelper extends DimensionManager
|
|||||||
if(linkData!=null)
|
if(linkData!=null)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int destinationID=linkData.destDimID;
|
int destinationID=linkData.destDimID;
|
||||||
|
|
||||||
int x=linkData.destXCoord;
|
int x=linkData.destXCoord;
|
||||||
@@ -334,15 +339,27 @@ public class dimHelper extends DimensionManager
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
entity = this.teleportEntity(world, entity, linkData);
|
||||||
|
|
||||||
this.teleportEntity(world, entity, linkData);
|
|
||||||
if(entity instanceof EntityPlayerMP&&world.provider.dimensionId!=linkData.destDimID)
|
|
||||||
|
|
||||||
|
if(entity instanceof EntityPlayerMP)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if(entity.ridingEntity!=null)
|
||||||
|
{
|
||||||
|
EntityPlayerMP.class.cast(entity).playerNetServerHandler.sendPacketToPlayer(PacketHandler.sendUpdateRiderPacket(entity.ridingEntity.entityId));
|
||||||
|
|
||||||
|
}
|
||||||
|
if(world.provider.dimensionId!=linkData.destDimID)
|
||||||
|
{
|
||||||
GameRegistry.onPlayerChangedDimension((EntityPlayer)entity);
|
GameRegistry.onPlayerChangedDimension((EntityPlayer)entity);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
System.out.println(entity.worldObj.getWorldInfo().getDimension());
|
|
||||||
System.out.println(entity.worldObj.provider.dimensionId);
|
|
||||||
|
|
||||||
entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F);
|
entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F);
|
||||||
|
|
||||||
@@ -403,6 +420,7 @@ public class dimHelper extends DimensionManager
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user