Entity spawn adjustment - tracker
This commit is contained in:
parent
859ebae365
commit
6d0f7ace17
|
@ -106,6 +106,7 @@ import cpw.mods.fml.common.TickType;
|
|||
import cpw.mods.fml.common.modloader.ModLoaderHelper;
|
||||
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
|
||||
import cpw.mods.fml.common.modloader.ModProperty;
|
||||
import cpw.mods.fml.common.network.EntitySpawnAdjustmentPacket;
|
||||
import cpw.mods.fml.common.network.EntitySpawnPacket;
|
||||
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
|
||||
import cpw.mods.fml.common.registry.IThrowableEntity;
|
||||
|
@ -399,4 +400,13 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
throw Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustEntityLocationOnClient(EntitySpawnAdjustmentPacket packet)
|
||||
{
|
||||
Entity ent = client.field_71441_e.func_73024_a(packet.entityId);
|
||||
ent.field_70118_ct = packet.serverX;
|
||||
ent.field_70117_cu = packet.serverY;
|
||||
ent.field_70116_cv = packet.serverZ;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ import com.google.common.collect.ImmutableList.Builder;
|
|||
import com.google.common.collect.Lists;
|
||||
|
||||
import cpw.mods.fml.common.discovery.ContainerType;
|
||||
import cpw.mods.fml.common.network.EntitySpawnAdjustmentPacket;
|
||||
import cpw.mods.fml.common.network.EntitySpawnPacket;
|
||||
import cpw.mods.fml.common.registry.TickRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
@ -350,4 +351,9 @@ public class FMLCommonHandler
|
|||
{
|
||||
return sidedDelegate.spawnEntityIntoClientWorld(cls, entitySpawnPacket);
|
||||
}
|
||||
|
||||
public void adjustEntityLocationOnClient(EntitySpawnAdjustmentPacket entitySpawnAdjustmentPacket)
|
||||
{
|
||||
sidedDelegate.adjustEntityLocationOnClient(entitySpawnAdjustmentPacket);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import net.minecraft.src.Entity;
|
|||
import net.minecraft.src.World;
|
||||
|
||||
import cpw.mods.fml.common.modloader.ModProperty;
|
||||
import cpw.mods.fml.common.network.EntitySpawnAdjustmentPacket;
|
||||
import cpw.mods.fml.common.network.EntitySpawnPacket;
|
||||
|
||||
public interface IFMLSidedHandler
|
||||
|
@ -28,4 +29,6 @@ public interface IFMLSidedHandler
|
|||
void showGuiScreen(Object clientGuiElement);
|
||||
|
||||
Entity spawnEntityIntoClientWorld(Class<? extends Entity> entityClass, EntitySpawnPacket packet);
|
||||
|
||||
void adjustEntityLocationOnClient(EntitySpawnAdjustmentPacket entitySpawnAdjustmentPacket);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
package cpw.mods.fml.common.network;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
import net.minecraft.src.NetHandler;
|
||||
import net.minecraft.src.NetworkManager;
|
||||
|
||||
public class EntitySpawnAdjustmentPacket extends FMLPacket
|
||||
{
|
||||
|
||||
public EntitySpawnAdjustmentPacket()
|
||||
{
|
||||
super(Type.ENTITYSPAWNADJUSTMENT);
|
||||
}
|
||||
|
||||
public int entityId;
|
||||
public int serverX;
|
||||
public int serverY;
|
||||
public int serverZ;
|
||||
|
||||
@Override
|
||||
public byte[] generatePacket(Object... data)
|
||||
{
|
||||
ByteArrayDataOutput dat = ByteStreams.newDataOutput();
|
||||
dat.writeInt((Integer) data[0]);
|
||||
dat.writeInt((Integer) data[1]);
|
||||
dat.writeInt((Integer) data[2]);
|
||||
dat.writeInt((Integer) data[3]);
|
||||
return dat.toByteArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FMLPacket consumePacket(byte[] data)
|
||||
{
|
||||
ByteArrayDataInput dat = ByteStreams.newDataInput(data);
|
||||
entityId = dat.readInt();
|
||||
serverX = dat.readInt();
|
||||
serverY = dat.readInt();
|
||||
serverZ = dat.readInt();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(NetworkManager network, FMLNetworkHandler handler, NetHandler netHandler, String userName)
|
||||
{
|
||||
FMLCommonHandler.instance().adjustEntityLocationOnClient(this);
|
||||
}
|
||||
|
||||
}
|
|
@ -302,4 +302,14 @@ public class FMLNetworkHandler
|
|||
pkt.field_73628_b = pkt.field_73629_c.length;
|
||||
return pkt;
|
||||
}
|
||||
|
||||
public static void makeEntitySpawnAdjustment(int entityId, EntityPlayerMP player, int serverX, int serverY, int serverZ)
|
||||
{
|
||||
Packet250CustomPayload pkt = new Packet250CustomPayload();
|
||||
pkt.field_73630_a = "FML";
|
||||
pkt.field_73629_c = FMLPacket.makePacket(Type.ENTITYSPAWNADJUSTMENT, entityId, serverX, serverY, serverZ);
|
||||
pkt.field_73628_b = pkt.field_73629_c.length;
|
||||
|
||||
player.field_71135_a.func_72567_b(pkt);
|
||||
}
|
||||
}
|
|
@ -43,7 +43,11 @@ public abstract class FMLPacket
|
|||
/**
|
||||
* Spawn an entity on the client from the server
|
||||
*/
|
||||
ENTITYSPAWN(EntitySpawnPacket.class);
|
||||
ENTITYSPAWN(EntitySpawnPacket.class),
|
||||
/**
|
||||
* Fixes entity location data after spawning
|
||||
*/
|
||||
ENTITYSPAWNADJUSTMENT(EntitySpawnAdjustmentPacket.class);
|
||||
|
||||
|
||||
private Class<? extends FMLPacket> packetType;
|
||||
|
|
|
@ -93,7 +93,7 @@ public class EntityRegistry
|
|||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
FMLLog.log(Level.WARNING, e, "The mod %s tried to register the entity (name,class) (%s,%s) one or bothe of which are already registered", mc.getModId(), entityName, entityClass.getName());
|
||||
FMLLog.log(Level.WARNING, e, "The mod %s tried to register the entity (name,class) (%s,%s) one or both of which are already registered", mc.getModId(), entityName, entityClass.getName());
|
||||
return;
|
||||
}
|
||||
entityRegistrations.put(mc, er);
|
||||
|
|
|
@ -27,6 +27,7 @@ import net.minecraft.server.MinecraftServer;
|
|||
import net.minecraft.src.BaseMod;
|
||||
import net.minecraft.src.BiomeGenBase;
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.Entity;
|
||||
import net.minecraft.src.EntityItem;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.EntityPlayerMP;
|
||||
|
@ -54,6 +55,8 @@ import cpw.mods.fml.common.ProxyInjector;
|
|||
import cpw.mods.fml.common.Side;
|
||||
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
|
||||
import cpw.mods.fml.common.modloader.ModProperty;
|
||||
import cpw.mods.fml.common.network.EntitySpawnAdjustmentPacket;
|
||||
import cpw.mods.fml.common.network.EntitySpawnPacket;
|
||||
|
||||
/**
|
||||
* Handles primary communication from hooked code into the system
|
||||
|
@ -173,4 +176,17 @@ public class FMLServerHandler implements IFMLSidedHandler
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity spawnEntityIntoClientWorld(Class<? extends Entity> entityClass, EntitySpawnPacket packet)
|
||||
{
|
||||
// NOOP
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustEntityLocationOnClient(EntitySpawnAdjustmentPacket entitySpawnAdjustmentPacket)
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue