Fixed rendering, simplified netcode
This commit is contained in:
parent
4e0b7fa977
commit
9bd9cfb700
5 changed files with 66 additions and 19 deletions
|
@ -56,6 +56,32 @@ public class ServerPacketHandler implements IPacketHandler
|
|||
}
|
||||
}
|
||||
|
||||
public static Packet250CustomPayload createLinkPacket(ClientLinkData data)
|
||||
{
|
||||
try
|
||||
{
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
DataOutputStream writer = new DataOutputStream(buffer);
|
||||
writer.writeByte(PacketConstants.CREATE_LINK_PACKET_ID);
|
||||
data.write(writer);
|
||||
writer.close();
|
||||
packet.channel = PacketConstants.CHANNEL_NAME;
|
||||
packet.data = buffer.toByteArray();
|
||||
packet.length = packet.data.length;
|
||||
return packet;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
//This shouldn't happen...
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static void sendDimPacket(byte id, ClientDimData data)
|
||||
{
|
||||
try
|
||||
|
|
|
@ -131,7 +131,7 @@ public abstract class NewDimData
|
|||
protected Point4D origin;
|
||||
protected int orientation;
|
||||
protected DungeonData dungeon;
|
||||
protected IUpdateWatcher<ClientLinkData> linkWatcher;
|
||||
public IUpdateWatcher<ClientLinkData> linkWatcher;
|
||||
|
||||
protected NewDimData(int id, NewDimData parent, boolean isPocket, boolean isDungeon,
|
||||
IUpdateWatcher<ClientLinkData> linkWatcher)
|
||||
|
|
|
@ -212,7 +212,7 @@ public class PocketManager
|
|||
* Set as true if we are a client that has connected to a dedicated server
|
||||
*/
|
||||
public static volatile boolean isConnected = false;
|
||||
private static final UpdateWatcherProxy<ClientLinkData> linkWatcher = new UpdateWatcherProxy<ClientLinkData>();
|
||||
public static final UpdateWatcherProxy<ClientLinkData> linkWatcher = new UpdateWatcherProxy<ClientLinkData>();
|
||||
private static final UpdateWatcherProxy<ClientDimData> dimWatcher = new UpdateWatcherProxy<ClientDimData>();
|
||||
private static ArrayList<NewDimData> rootDimensions = null;
|
||||
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
package StevenDimDoors.mod_pocketDim.tileentities;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.ServerPacketHandler;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet130UpdateSign;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TileEntityDimDoor extends TileEntity
|
||||
|
@ -18,7 +23,19 @@ public class TileEntityDimDoor extends TileEntity
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() { }
|
||||
public void updateEntity()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
if(PocketManager.getLink(xCoord, yCoord, zCoord, worldObj)!=null)
|
||||
{
|
||||
return ServerPacketHandler.createLinkPacket(PocketManager.getLink(xCoord, yCoord, zCoord, worldObj).link());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
|
@ -54,4 +71,6 @@ public class TileEntityDimDoor extends TileEntity
|
|||
nbt.setBoolean("isDungeonChainLink", isDungeonChainLink);
|
||||
nbt.setBoolean("hasGennedPair", hasGennedPair);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import net.minecraft.network.packet.Packet132TileEntityData;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import StevenDimDoors.mod_pocketDim.ServerPacketHandler;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
|
@ -36,6 +37,7 @@ public class TileEntityRift extends TileEntity
|
|||
private int count=200;
|
||||
private int count2 = 0;
|
||||
public int age = 0;
|
||||
private boolean hasUpdated = false;
|
||||
|
||||
public HashMap<Integer, double[]> renderingCenters = new HashMap<Integer, double[]>();
|
||||
@SuppressWarnings("deprecation")
|
||||
|
@ -47,7 +49,7 @@ public class TileEntityRift extends TileEntity
|
|||
public void updateEntity()
|
||||
{
|
||||
//Invalidate this tile entity if it shouldn't exist
|
||||
if (PocketManager.getLink(xCoord, yCoord, zCoord, worldObj.provider.dimensionId) == null)
|
||||
if (!this.worldObj.isRemote && PocketManager.getLink(xCoord, yCoord, zCoord, worldObj.provider.dimensionId) == null)
|
||||
{
|
||||
this.invalidate();
|
||||
if (worldObj.getBlockId(xCoord, yCoord, zCoord) == mod_pocketDim.blockRift.blockID)
|
||||
|
@ -64,6 +66,10 @@ public class TileEntityRift extends TileEntity
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//The code for the new rift rendering hooks in here, as well as in the ClientProxy to bind the TESR to the rift.
|
||||
//It is inactive for now.
|
||||
/**
|
||||
|
@ -100,6 +106,8 @@ public class TileEntityRift extends TileEntity
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void clearBlocksOnRift()
|
||||
{
|
||||
//clears blocks for the new rending effect
|
||||
|
@ -345,19 +353,13 @@ public class TileEntityRift extends TileEntity
|
|||
nbt.setInteger("spawnedEndermenID", this.spawnedEndermenID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
Packet132TileEntityData packet = new Packet132TileEntityData();
|
||||
packet.actionType = 0;
|
||||
packet.xPosition = xCoord;
|
||||
packet.yPosition = yCoord;
|
||||
packet.zPosition = zCoord;
|
||||
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
packet.data = nbt;
|
||||
return packet;
|
||||
if(PocketManager.getLink(xCoord, yCoord, zCoord, worldObj)!=null)
|
||||
{
|
||||
return ServerPacketHandler.createLinkPacket(PocketManager.getLink(xCoord, yCoord, zCoord, worldObj).link());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue