Mazes #117

Merged
StevenRS11 merged 101 commits from mazes into DevBranch 2013-12-29 07:03:48 +00:00
10 changed files with 130 additions and 37 deletions
Showing only changes of commit f40f42298f - Show all commits

View File

@@ -45,5 +45,6 @@ processResources
jar jar
{ {
destinationDir = new File("build/dist/") destinationDir = new File("build/dist/")
archiveName = "DimensionalDoors-${version}-${BUILD_NUMBER}" archiveName = "DimensionalDoors-${version}-" + System.getenv("BUILD_NUMBER") + ".jar"
} }

View File

@@ -4,6 +4,7 @@ import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.INetworkManager; import net.minecraft.network.INetworkManager;
import net.minecraft.network.NetLoginHandler; import net.minecraft.network.NetLoginHandler;
import net.minecraft.network.packet.NetHandler; import net.minecraft.network.packet.NetHandler;
@@ -11,6 +12,10 @@ import net.minecraft.network.packet.Packet1Login;
import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.server.integrated.IntegratedServer; import net.minecraft.server.integrated.IntegratedServer;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.network.ForgePacket;
import net.minecraftforge.common.network.packet.DimensionRegisterPacket;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager; import StevenDimDoors.mod_pocketDim.core.PocketManager;
import cpw.mods.fml.common.network.IConnectionHandler; import cpw.mods.fml.common.network.IConnectionHandler;
import cpw.mods.fml.common.network.Player; import cpw.mods.fml.common.network.Player;
@@ -20,25 +25,14 @@ public class ConnectionHandler implements IConnectionHandler
@Override @Override
public String connectionReceived(NetLoginHandler netHandler, INetworkManager manager) public String connectionReceived(NetLoginHandler netHandler, INetworkManager manager)
{ {
try for(NewDimData data : PocketManager.getDimensions())
{ {
Packet250CustomPayload packet = new Packet250CustomPayload();
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); Packet250CustomPayload[] pkt = ForgePacket.makePacketSet(new DimensionRegisterPacket(data.id(), DimensionManager.getProviderType(data.id())));
DataOutputStream writer = new DataOutputStream(buffer); manager.addToSendQueue(pkt[0]);
writer.writeByte(PacketConstants.CLIENT_JOIN_PACKET_ID);
PocketManager.writePacket(writer);
writer.close();
packet.channel = PacketConstants.CHANNEL_NAME;
packet.data = buffer.toByteArray();
packet.length = packet.data.length;
manager.addToSendQueue(packet);
}
catch (IOException e)
{
//This shouldn't happen...
e.printStackTrace();
} }
return null; return null;
} }
@Override @Override

View File

@@ -0,0 +1,39 @@
package StevenDimDoors.mod_pocketDim;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.network.ForgePacket;
import net.minecraftforge.common.network.packet.DimensionRegisterPacket;
import cpw.mods.fml.common.IPlayerTracker;
public class PlayerTracker implements IPlayerTracker
{
@Override
public void onPlayerLogin(EntityPlayer player)
{
}
@Override
public void onPlayerLogout(EntityPlayer player) {
// TODO Auto-generated method stub
}
@Override
public void onPlayerChangedDimension(EntityPlayer player) {
// TODO Auto-generated method stub
}
@Override
public void onPlayerRespawn(EntityPlayer player)
{
}
}

View File

@@ -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

View File

@@ -10,6 +10,7 @@ import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.network.packet.Packet41EntityEffect; import net.minecraft.network.packet.Packet41EntityEffect;
import net.minecraft.network.packet.Packet43Experience; import net.minecraft.network.packet.Packet43Experience;
import net.minecraft.network.packet.Packet9Respawn; import net.minecraft.network.packet.Packet9Respawn;
@@ -19,6 +20,8 @@ import net.minecraft.util.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldServer; import net.minecraft.world.WorldServer;
import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.network.ForgePacket;
import net.minecraftforge.common.network.packet.DimensionRegisterPacket;
import StevenDimDoors.mod_pocketDim.DDProperties; import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.Point3D; import StevenDimDoors.mod_pocketDim.Point3D;
import StevenDimDoors.mod_pocketDim.mod_pocketDim; import StevenDimDoors.mod_pocketDim.mod_pocketDim;
@@ -271,6 +274,7 @@ public class DDTeleporter
throw new IllegalArgumentException("destination cannot be null."); throw new IllegalArgumentException("destination cannot be null.");
} }
//This beautiful teleport method is based off of xCompWiz's teleport function. //This beautiful teleport method is based off of xCompWiz's teleport function.
WorldServer oldWorld = (WorldServer) entity.worldObj; WorldServer oldWorld = (WorldServer) entity.worldObj;
@@ -316,6 +320,10 @@ public class DDTeleporter
{ {
// We need to do all this special stuff to move a player between dimensions. // We need to do all this special stuff to move a player between dimensions.
//Register the dim on the client when we teleport to it.
Packet250CustomPayload[] pkt = ForgePacket.makePacketSet(new DimensionRegisterPacket(newWorld.provider.dimensionId, DimensionManager.getProviderType(newWorld.provider.dimensionId)));
player.playerNetServerHandler.sendPacketToPlayer(pkt[0]);
// Set the new dimension and inform the client that it's moving to a new world. // Set the new dimension and inform the client that it's moving to a new world.
player.dimension = destination.getDimension(); player.dimension = destination.getDimension();
player.playerNetServerHandler.sendPacketToPlayer(new Packet9Respawn(player.dimension, (byte)player.worldObj.difficultySetting, newWorld.getWorldInfo().getTerrainType(), newWorld.getHeight(), player.theItemInWorldManager.getGameType())); player.playerNetServerHandler.sendPacketToPlayer(new Packet9Respawn(player.dimension, (byte)player.worldObj.difficultySetting, newWorld.getWorldInfo().getTerrainType(), newWorld.getHeight(), player.theItemInWorldManager.getGameType()));

View File

@@ -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)

View File

@@ -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;

View File

@@ -50,6 +50,7 @@ import StevenDimDoors.mod_pocketDim.world.PocketProvider;
import StevenDimDoors.mod_pocketDimClient.ClientPacketHandler; import StevenDimDoors.mod_pocketDimClient.ClientPacketHandler;
import StevenDimDoors.mod_pocketDimClient.ClientTickHandler; import StevenDimDoors.mod_pocketDimClient.ClientTickHandler;
import cpw.mods.fml.common.IPlayerTracker;
import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.Mod.Instance;
@@ -93,7 +94,7 @@ serverPacketHandlerSpec =
@SidedPacketHandler(channels = {PacketConstants.CHANNEL_NAME}, packetHandler = ServerPacketHandler.class)) @SidedPacketHandler(channels = {PacketConstants.CHANNEL_NAME}, packetHandler = ServerPacketHandler.class))
public class mod_pocketDim public class mod_pocketDim
{ {
public static final String version = "$VERSION$"; public static final String version = "2.2.0";
public static final String modid = "dimdoors"; public static final String modid = "dimdoors";
//need to clean up //need to clean up
@@ -136,6 +137,7 @@ public class mod_pocketDim
public static DDProperties properties; public static DDProperties properties;
public static MonolithSpawner spawner; //Added this field temporarily. Will be refactored out later. public static MonolithSpawner spawner; //Added this field temporarily. Will be refactored out later.
public static GatewayGenerator riftGen; public static GatewayGenerator riftGen;
public static PlayerTracker tracker;
public static CreativeTabs dimDoorsCreativeTab = new CreativeTabs("dimDoorsCreativeTab") public static CreativeTabs dimDoorsCreativeTab = new CreativeTabs("dimDoorsCreativeTab")
{ {
@@ -213,6 +215,8 @@ public class mod_pocketDim
mod_pocketDim.pocketBiome= (new BiomeGenPocket(properties.PocketBiomeID)); mod_pocketDim.pocketBiome= (new BiomeGenPocket(properties.PocketBiomeID));
GameRegistry.registerWorldGenerator(mod_pocketDim.riftGen); GameRegistry.registerWorldGenerator(mod_pocketDim.riftGen);
tracker = new PlayerTracker();
GameRegistry.registerPlayerTracker(tracker);
GameRegistry.registerBlock(goldDoor, "Golden Door"); GameRegistry.registerBlock(goldDoor, "Golden Door");
GameRegistry.registerBlock(goldDimDoor, "Golden Dimensional Door"); GameRegistry.registerBlock(goldDimDoor, "Golden Dimensional Door");

View File

@@ -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);
} }
} }

View File

@@ -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