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)
|
private static void sendDimPacket(byte id, ClientDimData data)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -131,7 +131,7 @@ public abstract class NewDimData
|
||||||
protected Point4D origin;
|
protected Point4D origin;
|
||||||
protected int orientation;
|
protected int orientation;
|
||||||
protected DungeonData dungeon;
|
protected DungeonData dungeon;
|
||||||
protected IUpdateWatcher<ClientLinkData> linkWatcher;
|
public IUpdateWatcher<ClientLinkData> linkWatcher;
|
||||||
|
|
||||||
protected NewDimData(int id, NewDimData parent, boolean isPocket, boolean isDungeon,
|
protected NewDimData(int id, NewDimData parent, boolean isPocket, boolean isDungeon,
|
||||||
IUpdateWatcher<ClientLinkData> linkWatcher)
|
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
|
* Set as true if we are a client that has connected to a dedicated server
|
||||||
*/
|
*/
|
||||||
public static volatile boolean isConnected = false;
|
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 final UpdateWatcherProxy<ClientDimData> dimWatcher = new UpdateWatcherProxy<ClientDimData>();
|
||||||
private static ArrayList<NewDimData> rootDimensions = null;
|
private static ArrayList<NewDimData> rootDimensions = null;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
package StevenDimDoors.mod_pocketDim.tileentities;
|
package StevenDimDoors.mod_pocketDim.tileentities;
|
||||||
|
|
||||||
|
import StevenDimDoors.mod_pocketDim.ServerPacketHandler;
|
||||||
|
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
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;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
public class TileEntityDimDoor extends TileEntity
|
public class TileEntityDimDoor extends TileEntity
|
||||||
|
@ -18,7 +23,19 @@ public class TileEntityDimDoor extends TileEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound nbt)
|
public void readFromNBT(NBTTagCompound nbt)
|
||||||
|
@ -54,4 +71,6 @@ public class TileEntityDimDoor extends TileEntity
|
||||||
nbt.setBoolean("isDungeonChainLink", isDungeonChainLink);
|
nbt.setBoolean("isDungeonChainLink", isDungeonChainLink);
|
||||||
nbt.setBoolean("hasGennedPair", hasGennedPair);
|
nbt.setBoolean("hasGennedPair", hasGennedPair);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import net.minecraft.network.packet.Packet132TileEntityData;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
|
import StevenDimDoors.mod_pocketDim.ServerPacketHandler;
|
||||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||||
|
@ -36,6 +37,7 @@ public class TileEntityRift extends TileEntity
|
||||||
private int count=200;
|
private int count=200;
|
||||||
private int count2 = 0;
|
private int count2 = 0;
|
||||||
public int age = 0;
|
public int age = 0;
|
||||||
|
private boolean hasUpdated = false;
|
||||||
|
|
||||||
public HashMap<Integer, double[]> renderingCenters = new HashMap<Integer, double[]>();
|
public HashMap<Integer, double[]> renderingCenters = new HashMap<Integer, double[]>();
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
|
@ -47,7 +49,7 @@ public class TileEntityRift extends TileEntity
|
||||||
public void updateEntity()
|
public void updateEntity()
|
||||||
{
|
{
|
||||||
//Invalidate this tile entity if it shouldn't exist
|
//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();
|
this.invalidate();
|
||||||
if (worldObj.getBlockId(xCoord, yCoord, zCoord) == mod_pocketDim.blockRift.blockID)
|
if (worldObj.getBlockId(xCoord, yCoord, zCoord) == mod_pocketDim.blockRift.blockID)
|
||||||
|
@ -64,6 +66,10 @@ public class TileEntityRift extends TileEntity
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//The code for the new rift rendering hooks in here, as well as in the ClientProxy to bind the TESR to the rift.
|
//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.
|
//It is inactive for now.
|
||||||
/**
|
/**
|
||||||
|
@ -100,6 +106,8 @@ public class TileEntityRift extends TileEntity
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void clearBlocksOnRift()
|
public void clearBlocksOnRift()
|
||||||
{
|
{
|
||||||
//clears blocks for the new rending effect
|
//clears blocks for the new rending effect
|
||||||
|
@ -345,19 +353,13 @@ public class TileEntityRift extends TileEntity
|
||||||
nbt.setInteger("spawnedEndermenID", this.spawnedEndermenID);
|
nbt.setInteger("spawnedEndermenID", this.spawnedEndermenID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Packet getDescriptionPacket()
|
public Packet getDescriptionPacket()
|
||||||
{
|
{
|
||||||
Packet132TileEntityData packet = new Packet132TileEntityData();
|
if(PocketManager.getLink(xCoord, yCoord, zCoord, worldObj)!=null)
|
||||||
packet.actionType = 0;
|
{
|
||||||
packet.xPosition = xCoord;
|
return ServerPacketHandler.createLinkPacket(PocketManager.getLink(xCoord, yCoord, zCoord, worldObj).link());
|
||||||
packet.yPosition = yCoord;
|
}
|
||||||
packet.zPosition = zCoord;
|
return null;
|
||||||
|
|
||||||
NBTTagCompound nbt = new NBTTagCompound();
|
|
||||||
writeToNBT(nbt);
|
|
||||||
packet.data = nbt;
|
|
||||||
return packet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue