Merging Canvox's patch #106

Merged
StevenRS11 merged 14 commits from master into 1.6.2-code 2013-12-17 02:10:44 +00:00
23 changed files with 250 additions and 201 deletions

View File

@@ -42,20 +42,14 @@ public class ConnectionHandler implements IConnectionHandler
} }
@Override @Override
public void connectionOpened(NetHandler netClientHandler, String server, int port, INetworkManager manager) public void connectionOpened(NetHandler netClientHandler, String server, int port, INetworkManager manager) { }
{
}
@Override @Override
public void connectionOpened(NetHandler netClientHandler,MinecraftServer server, INetworkManager manager) public void connectionOpened(NetHandler netClientHandler,MinecraftServer server, INetworkManager manager) { }
{
}
@Override @Override
public void connectionClosed(INetworkManager manager) public void connectionClosed(INetworkManager manager)
{ {
if(PocketManager.isConnected) if(PocketManager.isConnected)
{ {
PocketManager.unload(); PocketManager.unload();
@@ -63,14 +57,12 @@ public class ConnectionHandler implements IConnectionHandler
} }
@Override @Override
public void clientLoggedIn(NetHandler clientHandler, INetworkManager manager, Packet1Login login) public void clientLoggedIn(NetHandler clientHandler, INetworkManager manager, Packet1Login login) { }
{
return;
}
@Override @Override
public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager) public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager)
{ {
//Send information about all the registered dimensions and links to the client
} }
} }

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 StevenDimDoors.mod_pocketDim.watcher.ClientLinkData;
import net.minecraft.network.INetworkManager; import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.network.packet.Packet250CustomPayload;
import StevenDimDoors.mod_pocketDim.core.PocketManager; import StevenDimDoors.mod_pocketDim.core.PocketManager;
@@ -40,16 +41,16 @@ public class ServerPacketHandler implements IPacketHandler
} }
} }
private static class LinkWatcher implements IUpdateWatcher<Point4D> private static class LinkWatcher implements IUpdateWatcher<ClientLinkData>
{ {
@Override @Override
public void onCreated(Point4D message) public void onCreated(ClientLinkData message)
{ {
sendLinkPacket(PacketConstants.CREATE_LINK_PACKET_ID, message); sendLinkPacket(PacketConstants.CREATE_LINK_PACKET_ID, message);
} }
@Override @Override
public void onDeleted(Point4D message) public void onDeleted(ClientLinkData message)
{ {
sendLinkPacket(PacketConstants.DELETE_LINK_PACKET_ID, message); sendLinkPacket(PacketConstants.DELETE_LINK_PACKET_ID, message);
} }
@@ -77,7 +78,7 @@ public class ServerPacketHandler implements IPacketHandler
} }
} }
private static void sendLinkPacket(byte id, Point4D data) private static void sendLinkPacket(byte id, ClientLinkData message)
{ {
try try
{ {
@@ -85,7 +86,7 @@ public class ServerPacketHandler implements IPacketHandler
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream writer = new DataOutputStream(buffer); DataOutputStream writer = new DataOutputStream(buffer);
writer.writeByte(id); writer.writeByte(id);
Point4D.write(data, writer); message.write(writer);
writer.close(); writer.close();
packet.channel = PacketConstants.CHANNEL_NAME; packet.channel = PacketConstants.CHANNEL_NAME;
packet.data = buffer.toByteArray(); packet.data = buffer.toByteArray();

View File

@@ -33,6 +33,13 @@ public class CommandCreateDungeonRift extends DDCommandBase
return instance; return instance;
} }
@Override
public String getCommandUsage(ICommandSender sender) {
return "Usage: /dd-rift <dungeon name>\r\n" +
" /dd-rift list\r\n" +
" /dd-rift random";
}
@Override @Override
protected DDCommandResult processCommand(EntityPlayer sender, String[] command) protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
{ {
@@ -130,10 +137,4 @@ public class CommandCreateDungeonRift extends DDCommandBase
} }
return bestMatch; return bestMatch;
} }
@Override
public String getCommandUsage(ICommandSender icommandsender) {
// TODO Auto-generated method stub
return null;
}
} }

View File

@@ -21,6 +21,11 @@ public class CommandCreatePocket extends DDCommandBase
return instance; return instance;
} }
@Override
public String getCommandUsage(ICommandSender sender) {
return "Usage: /dd-create";
}
@Override @Override
protected DDCommandResult processCommand(EntityPlayer sender, String[] command) protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
{ {
@@ -46,10 +51,4 @@ public class CommandCreatePocket extends DDCommandBase
} }
return DDCommandResult.SUCCESS; return DDCommandResult.SUCCESS;
} }
@Override
public String getCommandUsage(ICommandSender icommandsender) {
// TODO Auto-generated method stub
return null;
}
} }

View File

@@ -28,6 +28,11 @@ public class CommandDeleteAllLinks extends DDCommandBase
return instance; return instance;
} }
@Override
public String getCommandUsage(ICommandSender sender) {
return "Usage: /dd-deletelinks <targetDimensionID>";
}
@Override @Override
protected DDCommandResult processCommand(EntityPlayer sender, String[] command) protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
{ {
@@ -66,10 +71,4 @@ public class CommandDeleteAllLinks extends DDCommandBase
} }
return DDCommandResult.SUCCESS; //TEMPORARY HACK return DDCommandResult.SUCCESS; //TEMPORARY HACK
} }
@Override
public String getCommandUsage(ICommandSender icommandsender) {
// TODO Auto-generated method stub
return null;
}
} }

View File

@@ -28,6 +28,11 @@ public class CommandDeleteRifts extends DDCommandBase
return instance; return instance;
} }
@Override
public String getCommandUsage(ICommandSender sender) {
return "Usage: /dd-??? <dimension ID>";
}
@Override @Override
protected DDCommandResult processCommand(EntityPlayer sender, String[] command) protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
{ {
@@ -68,10 +73,4 @@ public class CommandDeleteRifts extends DDCommandBase
} }
return DDCommandResult.SUCCESS; //TEMPORARY HACK return DDCommandResult.SUCCESS; //TEMPORARY HACK
} }
@Override
public String getCommandUsage(ICommandSender icommandsender) {
// TODO Auto-generated method stub
return null;
}
} }

View File

@@ -26,6 +26,13 @@ public class CommandExportDungeon extends DDCommandBase
return instance; return instance;
} }
@Override
public String getCommandUsage(ICommandSender sender) {
return "Usage: /dd-export <dungeon type> <dungeon name> open <weight>\r\n" +
" /dd-export <dungeon type> <dungeon name> closed <weight>\r\n" +
" /dd-export <schematic name> override";
}
@Override @Override
protected DDCommandResult processCommand(EntityPlayer sender, String[] command) protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
{ {
@@ -166,10 +173,4 @@ public class CommandExportDungeon extends DDCommandBase
} }
return buffer.toString(); return buffer.toString();
} }
@Override
public String getCommandUsage(ICommandSender icommandsender) {
// TODO Auto-generated method stub
return null;
}
} }

View File

@@ -28,6 +28,11 @@ public class CommandResetDungeons extends DDCommandBase
return instance; return instance;
} }
@Override
public String getCommandUsage(ICommandSender sender) {
return "/dd-resetdungeons";
}
@Override @Override
protected DDCommandResult processCommand(EntityPlayer sender, String[] command) protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
{ {
@@ -89,10 +94,4 @@ public class CommandResetDungeons extends DDCommandBase
sendChat(sender,("Reset complete. " + resetCount + " out of " + dungeonCount + " dungeons were reset.")); sendChat(sender,("Reset complete. " + resetCount + " out of " + dungeonCount + " dungeons were reset."));
return DDCommandResult.SUCCESS; return DDCommandResult.SUCCESS;
} }
@Override
public String getCommandUsage(ICommandSender icommandsender) {
// TODO Auto-generated method stub
return null;
}
} }

View File

@@ -29,6 +29,11 @@ public class CommandTeleportPlayer extends DDCommandBase
return instance; return instance;
} }
@Override
public String getCommandUsage(ICommandSender sender) {
return "Usage: /dd-tp <player name> <dimension id> <x> <y> <z>";
}
/** /**
* TODO- Change to accept variety of input, like just coords, just dim ID, or two player names. * TODO- Change to accept variety of input, like just coords, just dim ID, or two player names.
*/ */
@@ -85,12 +90,6 @@ public class CommandTeleportPlayer extends DDCommandBase
{ {
return false; return false;
} }
} }
@Override
public String getCommandUsage(ICommandSender icommandsender) {
// TODO Auto-generated method stub
return null;
}
} }

View File

@@ -72,12 +72,12 @@ public abstract class DDCommandBase extends CommandBase
sendChat(player,(result.getMessage())); sendChat(player,(result.getMessage()));
} }
} }
public static void sendChat(EntityPlayer player, String message) public static void sendChat(EntityPlayer player, String message)
{ {
ChatMessageComponent cmp = new ChatMessageComponent(); ChatMessageComponent cmp = new ChatMessageComponent();
cmp.addText(message); cmp.addText(message);
player.sendChatToPlayer(cmp); player.sendChatToPlayer(cmp);
} }
} }

View File

@@ -356,13 +356,13 @@ public class DDTeleporter
oldWorld.getChunkFromChunkCoords(entX, entZ).isModified = true; oldWorld.getChunkFromChunkCoords(entX, entZ).isModified = true;
} }
// Memory concerns. // Memory concerns.
// oldWorld.releaseEntitySkin(entity); oldWorld.onEntityRemoved(entity);
if (player == null) // Are we NOT working with a player? if (player == null) // Are we NOT working with a player?
{ {
NBTTagCompound entityNBT = new NBTTagCompound(); NBTTagCompound entityNBT = new NBTTagCompound();
entity.isDead = false; entity.isDead = false;
entity.writeToNBTOptional(entityNBT); entity.writeMountToNBT(entityNBT);
entity.isDead = true; entity.isDead = true;
entity = EntityList.createEntityFromNBT(entityNBT, newWorld); entity = EntityList.createEntityFromNBT(entityNBT, newWorld);
@@ -469,7 +469,7 @@ public class DDTeleporter
{ {
if(PocketManager.isBlackListed(link.destination().getDimension())) if(PocketManager.isBlackListed(link.destination().getDimension()))
{ {
link=PocketManager.getDimensionData(link.source().getDimension()).createLink(link.source,LinkTypes.SAFE_EXIT,link.orientation); link=PocketManager.getDimensionData(link.source().getDimension()).createLink(link.link.point,LinkTypes.SAFE_EXIT,link.link.orientation);
} }
else else
{ {
@@ -545,7 +545,7 @@ public class DDTeleporter
// To avoid loops, don't generate a destination if the player is // To avoid loops, don't generate a destination if the player is
// already in a non-pocket dimension. // already in a non-pocket dimension.
NewDimData current = PocketManager.getDimensionData(link.source.getDimension()); NewDimData current = PocketManager.getDimensionData(link.link.point.getDimension());
if (current.isPocketDimension()) if (current.isPocketDimension())
{ {
Point4D source = link.source(); Point4D source = link.source();
@@ -569,7 +569,7 @@ public class DDTeleporter
{ {
World startWorld = PocketManager.loadDimension(link.source().getDimension()); World startWorld = PocketManager.loadDimension(link.source().getDimension());
World destWorld = PocketManager.loadDimension(link.destination().getDimension()); World destWorld = PocketManager.loadDimension(link.destination().getDimension());
TileEntity doorTE = startWorld.getBlockTileEntity(link.source().getX(), link.source().getY(), link.source.getZ()); TileEntity doorTE = startWorld.getBlockTileEntity(link.source().getX(), link.source().getY(), link.link.point.getZ());
if(doorTE instanceof TileEntityDimDoor) if(doorTE instanceof TileEntityDimDoor)
{ {
if((TileEntityDimDoor.class.cast(doorTE).hasGennedPair)) if((TileEntityDimDoor.class.cast(doorTE).hasGennedPair))
@@ -599,7 +599,7 @@ public class DDTeleporter
} }
private static boolean generateSafeExit(DimLink link, DDProperties properties) private static boolean generateSafeExit(DimLink link, DDProperties properties)
{ {
NewDimData current = PocketManager.getDimensionData(link.source.getDimension()); NewDimData current = PocketManager.getDimensionData(link.link.point.getDimension());
return generateSafeExit(current.root(), link, properties); return generateSafeExit(current.root(), link, properties);
} }
@@ -608,7 +608,7 @@ public class DDTeleporter
// A dungeon exit acts the same as a safe exit, but has the chance of // A dungeon exit acts the same as a safe exit, but has the chance of
// taking the user to any non-pocket dimension, excluding Limbo and The End. // taking the user to any non-pocket dimension, excluding Limbo and The End.
NewDimData current = PocketManager.getDimensionData(link.source.getDimension()); NewDimData current = PocketManager.getDimensionData(link.link.point.getDimension());
ArrayList<NewDimData> roots = PocketManager.getRootDimensions(); ArrayList<NewDimData> roots = PocketManager.getRootDimensions();
int shiftChance = START_ROOT_SHIFT_CHANCE + ROOT_SHIFT_CHANCE_PER_LEVEL * (current.packDepth() - 1); int shiftChance = START_ROOT_SHIFT_CHANCE + ROOT_SHIFT_CHANCE_PER_LEVEL * (current.packDepth() - 1);

View File

@@ -4,46 +4,56 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import StevenDimDoors.mod_pocketDim.util.Point4D; import StevenDimDoors.mod_pocketDim.util.Point4D;
import StevenDimDoors.mod_pocketDim.watcher.ClientLinkData;
public abstract class DimLink public abstract class DimLink
{ {
protected Point4D source; protected ClientLinkData link;
protected DimLink parent; protected DimLink parent;
protected LinkTail tail; protected LinkTail tail;
protected int orientation;
protected List<DimLink> children; protected List<DimLink> children;
protected DimLink(Point4D source, DimLink parent, int orientation) protected DimLink(ClientLinkData link, DimLink parent)
{ {
if (parent.source.getDimension() != source.getDimension()) if (parent.link.point.getDimension() != link.point.getDimension())
{ {
// Ban having children in other dimensions to avoid serialization issues with cross-dimensional tails // Ban having children in other dimensions to avoid serialization issues with cross-dimensional tails
throw new IllegalArgumentException("source and parent.source must have the same dimension."); throw new IllegalArgumentException("source and parent.source must have the same dimension.");
} }
this.orientation=orientation;
this.parent = parent; this.parent = parent;
this.source = source; this.link = link;
this.tail = parent.tail; this.tail = parent.tail;
this.children = new LinkedList<DimLink>(); this.children = new LinkedList<DimLink>();
parent.children.add(this); parent.children.add(this);
} }
protected DimLink(Point4D source, int linkType, int orientation) protected DimLink(ClientLinkData link, int linkType)
{ {
if ((linkType < LinkTypes.ENUM_MIN || linkType > LinkTypes.ENUM_MAX) && linkType != LinkTypes.CLIENT_SIDE) if ((linkType < LinkTypes.ENUM_MIN || linkType > LinkTypes.ENUM_MAX) && linkType != LinkTypes.CLIENT_SIDE)
{ {
throw new IllegalArgumentException("The specified link type is invalid."); throw new IllegalArgumentException("The specified link type is invalid.");
} }
this.orientation = orientation;
this.parent = null; this.parent = null;
this.source = source; this.link = link;
this.tail = new LinkTail(linkType, null); this.tail = new LinkTail(linkType, null);
this.children = new LinkedList<DimLink>(); this.children = new LinkedList<DimLink>();
} }
public Point4D source() public Point4D source()
{ {
return source; return link.point;
}
public int orientation()
{
return link.orientation;
}
public ClientLinkData link()
{
return link;
} }
public Point4D destination() public Point4D destination()
@@ -52,7 +62,7 @@ public abstract class DimLink
} }
public int getDestinationOrientation() public int getDestinationOrientation()
{ {
return PocketManager.getLink(source.getX(), source.getY(), source.getZ(), source.getDimension()).orientation(); return PocketManager.getLink(link.point.getX(), link.point.getY(), link.point.getZ(), link.point.getDimension()).link().orientation;
} }
public boolean hasDestination() public boolean hasDestination()
{ {
@@ -78,13 +88,9 @@ public abstract class DimLink
{ {
return tail.getLinkType(); return tail.getLinkType();
} }
public int orientation()
{
return orientation;
}
public String toString() public String toString()
{ {
return source + " -> " + (hasDestination() ? destination() : ""); return link.point + " -> " + (hasDestination() ? destination() : "");
} }
} }

View File

@@ -6,6 +6,7 @@ import java.util.Map;
import java.util.Random; import java.util.Random;
import java.util.TreeMap; import java.util.TreeMap;
import StevenDimDoors.mod_pocketDim.watcher.ClientLinkData;
import net.minecraft.world.World; import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.DDProperties; import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.Point3D; import StevenDimDoors.mod_pocketDim.Point3D;
@@ -21,12 +22,12 @@ public abstract class NewDimData
{ {
public InnerDimLink(Point4D source, DimLink parent,int orientation) public InnerDimLink(Point4D source, DimLink parent,int orientation)
{ {
super(source, parent,orientation); super(new ClientLinkData(source, orientation), parent);
} }
public InnerDimLink(Point4D source, int linkType, int orientation) public InnerDimLink(Point4D source, int linkType, int orientation)
{ {
super(source, linkType,orientation); super(new ClientLinkData(source, orientation), linkType);
} }
public void setDestination(int x, int y, int z, NewDimData dimension) public void setDestination(int x, int y, int z, NewDimData dimension)
@@ -50,7 +51,7 @@ public abstract class NewDimData
} }
parent = null; parent = null;
source = null; link = null;
tail = new LinkTail(0, null); tail = new LinkTail(0, null);
} }
@@ -65,7 +66,7 @@ public abstract class NewDimData
//Ignore this request silently //Ignore this request silently
return false; return false;
} }
if (nextParent.source.getDimension() != source.getDimension()) if (nextParent.link.point.getDimension() != link.point.getDimension())
{ {
// Ban having children in other dimensions to avoid serialization issues with cross-dimensional tails // Ban having children in other dimensions to avoid serialization issues with cross-dimensional tails
throw new IllegalArgumentException("source and parent.source must have the same dimension."); throw new IllegalArgumentException("source and parent.source must have the same dimension.");
@@ -88,7 +89,7 @@ public abstract class NewDimData
parent = nextParent; parent = nextParent;
tail = nextParent.tail; tail = nextParent.tail;
nextParent.children.add(this); nextParent.children.add(this);
this.orientation=orientation; this.link.orientation=orientation;
return true; return true;
} }
@@ -111,7 +112,7 @@ public abstract class NewDimData
parent = null; parent = null;
tail = new LinkTail(linkType, null); tail = new LinkTail(linkType, null);
//Set new orientation //Set new orientation
this.orientation=orientation; this.link.orientation=orientation;
} }
} }
@@ -130,10 +131,10 @@ public abstract class NewDimData
protected Point4D origin; protected Point4D origin;
protected int orientation; protected int orientation;
protected DungeonData dungeon; protected DungeonData dungeon;
protected IUpdateWatcher<Point4D> linkWatcher; protected IUpdateWatcher<ClientLinkData> linkWatcher;
protected NewDimData(int id, NewDimData parent, boolean isPocket, boolean isDungeon, protected NewDimData(int id, NewDimData parent, boolean isPocket, boolean isDungeon,
IUpdateWatcher<Point4D> linkWatcher) IUpdateWatcher<ClientLinkData> linkWatcher)
{ {
// The isPocket flag is redundant. It's meant as an integrity safeguard. // The isPocket flag is redundant. It's meant as an integrity safeguard.
if (isPocket && (parent == null)) if (isPocket && (parent == null))
@@ -267,7 +268,7 @@ public abstract class NewDimData
//Link created! //Link created!
if(linkType!=LinkTypes.CLIENT_SIDE) if(linkType!=LinkTypes.CLIENT_SIDE)
{ {
linkWatcher.onCreated(link.source); linkWatcher.onCreated(link.link);
} }
return link; return link;
} }
@@ -290,19 +291,19 @@ public abstract class NewDimData
InnerDimLink link = linkMapping.get(source); InnerDimLink link = linkMapping.get(source);
if (link == null) if (link == null)
{ {
link = new InnerDimLink(source, parent, parent.orientation); link = new InnerDimLink(source, parent, parent.link.orientation);
linkMapping.put(source, link); linkMapping.put(source, link);
linkList.add(link); linkList.add(link);
//Link created! //Link created!
linkWatcher.onCreated(link.source); linkWatcher.onCreated(link.link);
} }
else else
{ {
if (link.overwrite(parent, parent.orientation)) if (link.overwrite(parent, parent.link.orientation))
{ {
//Link created! //Link created!
linkWatcher.onCreated(link.source); linkWatcher.onCreated(link.link);
} }
} }
return link; return link;
@@ -319,7 +320,7 @@ public abstract class NewDimData
{ {
linkList.remove(target); linkList.remove(target);
//Raise deletion event //Raise deletion event
linkWatcher.onDeleted(target.source); linkWatcher.onDeleted(target.link);
target.clear(); target.clear();
} }
return (target != null); return (target != null);
@@ -334,9 +335,9 @@ public abstract class NewDimData
linkList.remove(target); linkList.remove(target);
//Raise deletion event //Raise deletion event
//TODO why is source null here? //TODO why is source null here?
if(target.source!=null) if(target.link!=null)
{ {
linkWatcher.onDeleted(target.source); linkWatcher.onDeleted(target.link);
} }
target.clear(); target.clear();
} }

View File

@@ -47,7 +47,7 @@ public class PocketManager
// that any link destinations must be real dimensions controlled by PocketManager. // that any link destinations must be real dimensions controlled by PocketManager.
public InnerDimData(int id, InnerDimData parent, boolean isPocket, boolean isDungeon, public InnerDimData(int id, InnerDimData parent, boolean isPocket, boolean isDungeon,
IUpdateWatcher<Point4D> linkWatcher) IUpdateWatcher<ClientLinkData> linkWatcher)
{ {
super(id, parent, isPocket, isDungeon, linkWatcher); super(id, parent, isPocket, isDungeon, linkWatcher);
} }
@@ -119,7 +119,7 @@ public class PocketManager
Point3D parentPoint = new Point3D(-1,-1,-1); Point3D parentPoint = new Point3D(-1,-1,-1);
if(link.parent!=null) if(link.parent!=null)
{ {
parentPoint=link.parent.source.toPoint3D(); parentPoint=link.parent.link.point.toPoint3D();
} }
for(DimLink childLink : link.children) for(DimLink childLink : link.children)
@@ -127,7 +127,7 @@ public class PocketManager
children.add(childLink.source().toPoint3D()); children.add(childLink.source().toPoint3D());
} }
PackedLinkTail tail = new PackedLinkTail(link.tail.getDestination(),link.tail.getLinkType()); PackedLinkTail tail = new PackedLinkTail(link.tail.getDestination(),link.tail.getLinkType());
Links.add(new PackedLinkData(link.source,parentPoint,tail,link.orientation,children)); Links.add(new PackedLinkData(link.link.point,parentPoint,tail,link.link.orientation,children));
PackedLinkTail tempTail = new PackedLinkTail(link.tail.getDestination(),link.tail.getLinkType()); PackedLinkTail tempTail = new PackedLinkTail(link.tail.getDestination(),link.tail.getLinkType());
if(Tails.contains(tempTail)) if(Tails.contains(tempTail))
@@ -208,9 +208,11 @@ public class PocketManager
private static volatile boolean isLoading = false; private static volatile boolean isLoading = false;
private static volatile boolean isLoaded = false; private static volatile boolean isLoaded = false;
private static volatile boolean isSaving = false; private static volatile boolean isSaving = false;
/**
* 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>();
private static final UpdateWatcherProxy<Point4D> linkWatcher = new UpdateWatcherProxy<Point4D>();
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;
@@ -572,6 +574,10 @@ public class PocketManager
//Any pocket dimension must be listed with PocketManager to have a dimension ID //Any pocket dimension must be listed with PocketManager to have a dimension ID
//assigned, so it's safe to assume that any unknown dimensions don't belong to us. //assigned, so it's safe to assume that any unknown dimensions don't belong to us.
if(PocketManager.dimensionData == null)
{
System.out.println("Something odd happend during shutdown");
}
NewDimData dimension = PocketManager.dimensionData.get(dimensionID); NewDimData dimension = PocketManager.dimensionData.get(dimensionID);
if (dimension == null) if (dimension == null)
{ {
@@ -598,7 +604,7 @@ public class PocketManager
{ {
throw new IllegalStateException("Pocket dimensions have already been unloaded!"); throw new IllegalStateException("Pocket dimensions have already been unloaded!");
} }
save(); save();
unregisterPockets(); unregisterPockets();
dimensionData = null; dimensionData = null;
@@ -644,12 +650,12 @@ public class PocketManager
return dimWatcher.unregisterReceiver(watcher); return dimWatcher.unregisterReceiver(watcher);
} }
public static void registerLinkWatcher(IUpdateWatcher<Point4D> watcher) public static void registerLinkWatcher(IUpdateWatcher<ClientLinkData> watcher)
{ {
linkWatcher.registerReceiver(watcher); linkWatcher.registerReceiver(watcher);
} }
public static boolean unregisterLinkWatcher(IUpdateWatcher<Point4D> watcher) public static boolean unregisterLinkWatcher(IUpdateWatcher<ClientLinkData> watcher)
{ {
return linkWatcher.unregisterReceiver(watcher); return linkWatcher.unregisterReceiver(watcher);
} }

View File

@@ -39,6 +39,7 @@ public class Compactor
for (DimLink link : dimension.links()) for (DimLink link : dimension.links())
{ {
Point4D.write(link.source(), output); Point4D.write(link.source(), output);
output.writeInt(link.orientation());
} }
} }

View File

@@ -27,9 +27,8 @@ public class ItemBlockDimWall extends ItemBlock
return damageValue; return damageValue;
} }
@Override public String getUnlocalizedName(ItemStack par1ItemStack)
public String getUnlocalizedName(ItemStack par1ItemStack)
{ {
return subNames[(par1ItemStack.getItemDamage())]; return subNames[this.getDamage(par1ItemStack)];
} }
} }

View File

@@ -62,15 +62,14 @@ public class ItemRiftBlade extends ItemSword
return material != Material.plants && material != Material.vine && material != Material.coral && material != Material.leaves && material != Material.pumpkin ? 1.0F : 1.5F; return material != Material.plants && material != Material.vine && material != Material.coral && material != Material.leaves && material != Material.pumpkin ? 1.0F : 1.5F;
} }
} }
@Override @Override
@SuppressWarnings({ "unchecked", "rawtypes"})
public Multimap getItemAttributeModifiers() public Multimap getItemAttributeModifiers()
{ {
Multimap multimap = super.getItemAttributeModifiers(); Multimap multimap = super.getItemAttributeModifiers();
multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", 7, 0)); multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", (double)7, 0));
return multimap; return multimap;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)

View File

@@ -93,7 +93,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 = "1.6.2R2.1.1RC1"; public static final String version = "$VERSION$";
public static final String modid = "dimdoors"; public static final String modid = "dimdoors";
//need to clean up //need to clean up

View File

@@ -6,6 +6,7 @@ import net.minecraft.entity.DataWatcher;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityFlying; import net.minecraft.entity.EntityFlying;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.monster.IMob; import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@@ -67,6 +68,12 @@ public class MobMonolith extends EntityFlying implements IMob
} }
@Override @Override
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
this.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.maxHealth).setAttribute(20);
}
public boolean canBePushed() public boolean canBePushed()
{ {
return false; return false;
@@ -100,6 +107,7 @@ public class MobMonolith extends EntityFlying implements IMob
{ {
this.setDead(); this.setDead();
} }
super.onEntityUpdate(); super.onEntityUpdate();
if (this.isEntityAlive() && this.isEntityInsideOpaqueBlock()) if (this.isEntityAlive() && this.isEntityInsideOpaqueBlock())

View File

@@ -32,6 +32,8 @@ public class ClientDimData
public static ClientDimData read(DataInputStream input) throws IOException public static ClientDimData read(DataInputStream input) throws IOException
{ {
return new ClientDimData(input.readInt(), input.readInt()); int id = input.readInt();
int rootId = input.readInt();
return new ClientDimData(id, rootId);
} }
} }

View File

@@ -32,7 +32,9 @@ public class ClientLinkData
public static ClientLinkData read(DataInputStream input) throws IOException public static ClientLinkData read(DataInputStream input) throws IOException
{ {
return new ClientLinkData(Point4D.read(input), input.readInt()); Point4D point = Point4D.read(input);
int orientation = input.readInt();
return new ClientLinkData(point, orientation);
} }
} }

183
build.xml
View File

@@ -1,62 +1,93 @@
<project name="DimensionalDoors" default="install" basedir="."> <project name="DimensionalDoors" default="install" basedir=".">
<property environment="env" /> <property environment="env" />
<property name="project.name" value="DimDoors" />
<property name="src.dir" value="StevenDimDoors" />
<property name="resources.dir" value="resources" />
<property name="schematics.dir" value="schematics" />
<property name="versionclass.dir" value="mod_pocketDim" />
<property name="versionclass.file" value="mod_pocketDim.java"/>
<property name="minecraft.version" value="1.6.4" />
<property name="forge.forgeversion" value="9.11.1" />
<property name="forge.buildnum" value="953" />
<property name="build.dir" value="build" /> <property name="build.dir" value="build" />
<property name="classes.dir" value="${build.dir}/packaging" /> <property name="classes.dir" value="${build.dir}/packaging" />
<property name="src.dir" value="src" /> <property name="resourcePack.dir" value="${classes.dir}" />
<property name="forge.version" value="1.6.2-9.10.1.871" /> <property name="schematicPack.dir" value="${classes.dir}/schematics/" />
<property name="apiclasses.dir" value="${build.dir}/api-packaging" />
<property name="forge.version" value="${minecraft.version}-${forge.forgeversion}.${forge.buildnum}" />
<property name="forge.url" value="http://files.minecraftforge.net/minecraftforge/minecraftforge-src-${forge.version}.zip" /> <property name="forge.url" value="http://files.minecraftforge.net/minecraftforge/minecraftforge-src-${forge.version}.zip" />
<property name="mcp.version" value="804" />
<property name="forge.dir" value="${build.dir}/forge" /> <property name="forge.dir" value="${build.dir}/forge" />
<property name="mcp.dir" value="${forge.dir}/mcp" /> <property name="mcp.dir" value="${forge.dir}/mcp" />
<property name="mcpsrc.dir" value="${mcp.dir}/src/minecraft" /> <property name="mcpsrc.dir" value="${mcp.dir}/src/minecraft/StevenDimDoors" />
<property name="resources.dir" value="resources" />
<property name="package.meta-inf" value="META-INF" /> <property name="package.meta-inf" value="META-INF" />
<property name="build.ver" value="1.6.2" />
<property name="dist.dir" value="${build.dir}/dist" /> <property name="dist.dir" value="${build.dir}/dist" />
<property name="download.dir" value="downloads" /> <property name="download.dir" value="${build.dir}/downloads" />
<property name="lib.dir" value="${mcp.dir}/lib" /> <property name="lib.dir" value="${mcp.dir}/lib" />
<property file="${forge.dir}/forgeversion.properties" /> <property file="${forge.dir}/forgeversion.properties" />
<condition property="forge.already.installed"> <condition property="forge.already.installed">
<equals arg1="${forge.build.number}" arg2="871" /> <equals arg1="${forge.build.number}" arg2="${forge.buildnum}" />
</condition> </condition>
<property name="verclass.dir" value="${mcpsrc.dir}/StevenDimDoors/mod_pocketDim/" />
<property name="verclass.name" value="mod_pocketDim.java"/>
<mkdir dir="${download.dir}"/> <mkdir dir="${download.dir}"/>
<mkdir dir="${build.dir}" /> <mkdir dir="${build.dir}" />
<target name="get-version" depends="setup-forge">
<mkdir dir="${mcpsrc.dir}/StevenDimDoors" />
<copy todir="${mcpsrc.dir}/StevenDimDoors" overwrite="true">
<fileset dir="StevenDimDoors" />
</copy>
<target name="get-version" depends="setup-forge">
<!-- Copy source -->
<exec dir="${verclass.dir}" executable="sh" osfamily="unix" outputproperty="grep.out"> <copy todir="${mcpsrc.dir}" overwrite="true">
<arg value="-c"/> <fileset dir="${src.dir}"/>
<arg value="grep -o -P '[0-9.]+R[0-9.]+(RC[0-9]+)?(B[0-9]+)?' ${verclass.name}"/> </copy>
</exec>
<exec executable="python" osfamily="unix"> <!-- Get the version from the mcmod.info -->
<arg value="versionscript.py" /> <script language="javascript">
<arg value="${grep.out}" /> importClass(java.io.File);
</exec> importClass(java.nio.file.Files)
<echo message="Grepped version: ${grep.out}"/> importClass(java.io.FileReader);
<copy todir="${classes.dir}" file="mcmod.info" overwrite="true"/> importClass(java.io.BufferedReader);
importClass(java.io.FileWriter);
importClass(java.io.BufferedWriter);
echo = project.createTask("echo");
echo.setMessage("Parsing mcmod.info...");
echo.perform();
var file = new File("./mcmod.info");
fr = new FileReader(file);
br = new BufferedReader(fr);
// Read the file.
// This assumes the file has no line
var line;
var json = "";
while ((line = br.readLine()) != null) {
json += line;
}
var struct = JSON.parse(json);
var version = struct["modlist"][0].version;
echo = project.createTask("echo");
echo.setMessage("Parsed version: " + version);
echo.perform();
project.setProperty("mod.version", version);
</script>
<!-- Replace the version information in the mod class -->
<replace file="${mcpsrc.dir}/${versionclass.dir}/${versionclass.file}">
<replacefilter token="$VERSION$" value="${mod.version}"/>
</replace>
</target> </target>
<available property="forge-exists" file="${download.dir}/minecraftforge-src-${forge.version}.zip" /> <available property="forge-exists" file="${download.dir}/minecraftforge-src-${forge.version}.zip" />
<available property="already-compiled" file="${classes.dir}/deathrat" /> <available property="already-compiled" file="${classes.dir}/${src.dir}" />
<condition property="should-download-ant-contrib"> <condition property="should-download-ant-contrib">
<or> <or>
<available file="${download.dir}/ant-contrib/ant-contrib-1.0b3.jar"/> <available file="${download.dir}/ant-contrib/ant-contrib-1.0b3.jar"/>
@@ -65,14 +96,13 @@
</condition> </condition>
<target name="install" depends="build"> <target name="install" depends="build">
<copy todir="${classes.dir}/schematics" overwrite="true"> <delete dir="${mcpsrc.dir}/${src.dir}" />
<fileset dir="schematics" /> <delete dir="${dist.dir}" />
</copy> <jar destfile="${dist.dir}/${project.name}-${mod.version}-${build.number}.jar" basedir="${classes.dir}"/>
<zip destfile="${dist.dir}/DimensionalDoors-${grep.out}-${build.number}.zip" basedir="${classes.dir}"/>
<delete dir="${classes.dir}" /> <delete dir="${classes.dir}" />
<delete dir="${mcp.dir}/reobf"/> <delete dir="${mcp.dir}/reobf"/>
<delete dir="${mcpsrc}/StevenDimDoors" /> <delete dir="{$apiclasses.dir}" />
<delete dir="${mcpsrc}/Steven" /> <delete dir="${mcpsrc.dir}/${src.dir}" />
</target> </target>
<target name="build" depends="get-version" unless="already-compiled"> <target name="build" depends="get-version" unless="already-compiled">
@@ -87,19 +117,36 @@
<!-- Reobf --> <!-- Reobf -->
<exec dir="${mcp.dir}" executable="cmd" osfamily="windows"> <exec dir="${mcp.dir}" executable="cmd" osfamily="windows">
<arg line="/c reobfuscate_srg.bat"/> <arg line="/c reobfuscate.bat --srgnames"/>
</exec> </exec>
<exec dir="${mcp.dir}" executable="sh" osfamily="unix"> <exec dir="${mcp.dir}" executable="sh" osfamily="unix">
<arg value="reobfuscate_srg.sh" /> <arg value="reobfuscate.sh" />
</exec> </exec>
<copy todir="${classes.dir}"> <copy todir="${classes.dir}">
<fileset dir="${mcp.dir}/reobf/minecraft"/> <fileset dir="${mcp.dir}/reobf/minecraft"/>
</copy> </copy>
<copy todir="${classes.dir}">
<fileset dir="${resources.dir}"/> <copy todir="${resourcePack.dir}">
<fileset dir="${resources.dir}" />
</copy> </copy>
<copy todir="${schematicPack.dir}">
<fileset dir="${schematics.dir}" />
</copy>
<copy todir="${classes.dir}">
<fileset file="mcmod.info" />
</copy>
<copy todir="${classes.dir}">
<fileset file="${resources.dir}/pack.mcmeta" />
</copy>
<delete file="${resourcePack.dir}/mcmod.info" />
<delete file="${resourcePack.dir}/pack.mcmeta" />
</target> </target>
<target name="build-number-there" if="env.BUILD_NUMBER" > <target name="build-number-there" if="env.BUILD_NUMBER" >
@@ -109,7 +156,7 @@
<target name="build-number-not-there" unless="env.BUILD_NUMBER" > <target name="build-number-not-there" unless="env.BUILD_NUMBER" >
<echo message="!! No build number set !!" /> <echo message="!! No build number set !!" />
<property name="build.number" value="CUSTOM_BUILD" /> <property name="build.number" value="0" />
</target> </target>
<target name="setup-forge" depends="download-forge,build-number-there,build-number-not-there" unless="forge.already.installed"> <target name="setup-forge" depends="download-forge,build-number-there,build-number-not-there" unless="forge.already.installed">
@@ -120,16 +167,10 @@
<include name="minecraftforge-src-${forge.version}.zip"/> <include name="minecraftforge-src-${forge.version}.zip"/>
</fileset> </fileset>
</unzip> </unzip>
<!-- Change executables' permitions --> <!-- Change executables' permitions -->
<chmod file="${forge.dir}/install.sh" perm="+x"/> <chmod file="${forge.dir}/install.sh" perm="+x"/>
<!-- if your building on OSX these 2 should be executable -->
<!-- Install forge --> <!-- Install forge -->
<delete dir="${mcp.dir}" failonerror="no"/> <delete dir="${mcp.dir}" failonerror="no"/>
<exec dir="${forge.dir}" executable="cmd" osfamily="windows" inputstring="Yes\n"> <exec dir="${forge.dir}" executable="cmd" osfamily="windows" inputstring="Yes\n">
@@ -138,38 +179,29 @@
<exec dir="${forge.dir}" executable="sh" osfamily="unix" inputstring="Yes\n"> <exec dir="${forge.dir}" executable="sh" osfamily="unix" inputstring="Yes\n">
<arg value="install.sh" /> <arg value="install.sh" />
</exec> </exec>
<chmod file="${mcp.dir}/updatemd5.sh" perm="+x"/> <chmod file="${mcp.dir}/updatemd5.sh" perm="+x"/>
<chmod file="${mcp.dir}/recompile.sh" perm="+x"/> <chmod file="${mcp.dir}/recompile.sh" perm="+x"/>
<chmod file="${mcp.dir}/reobfuscate_srg.sh" perm="+x"/> <chmod file="${mcp.dir}/reobfuscate.sh" perm="+x"/>
<chmod file="${mcp.dir}/runtime/bin/astyle-osx" perm="+x" /> <chmod file="${mcp.dir}/runtime/bin/astyle-osx" perm="+x" />
<chmod file="${mcp.dir}/runtime/bin/jad-osx" perm="+x" /> <chmod file="${mcp.dir}/runtime/bin/jad-osx" perm="+x" />
<!-- Copy libraries -->
<!-- <copy todir="${mcp.dir}/lib" >
<fileset dir="lib" >
<patternset includes="*.jar" />
</fileset>
</copy> -->
</target> </target>
<target name="download-forge" depends="download-ant-contrib" unless="forge-exists"> <target name="download-forge" depends="download-ant-contrib" unless="forge-exists">
<taskdef resource="net/sf/antcontrib/antlib.xml"> <taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath> <classpath>
<pathelement location="${download.dir}/ant-contrib/ant-contrib-1.0b3.jar"/> <pathelement location="${download.dir}/ant-contrib/ant-contrib-1.0b3.jar"/>
<fileset dir="${download.dir}/ant-contrib/lib"> <fileset dir="${download.dir}/ant-contrib/lib">
<include name="*.jar"/> <include name="*.jar"/>
</fileset> </fileset>
</classpath> </classpath>
</taskdef> </taskdef>
<echo message="Downloading forge... " /> <echo message="Downloading forge... " />
<get src="${forge.url}" dest="${download.dir}/minecraftforge-src-${forge.version}.zip" /> <get src="http://files.minecraftforge.net/minecraftforge-src-${forge.version}.zip"
dest="${download.dir}/minecraftforge-src-${forge.version}.zip" />
</target> </target>
<target name="download-ant-contrib" unless="should-download-ant-contrib"> <target name="download-ant-contrib" unless="should-download-ant-contrib">
<echo message="Getting: ant-contrib"/> <echo message="Getting: ant-contrib"/>
<mkdir dir="${download.dir}/tmp"/> <mkdir dir="${download.dir}/tmp"/>
@@ -195,5 +227,4 @@
</target> </target>
</project> </project>

View File

@@ -1,9 +1,12 @@
{
"modinfoversion":2,
"modlist":
[ [
{ {
"modid": "DimDoors", "modid": "DimDoors",
"name": "Dimensional Doors", "name": "Dimensional Doors",
"description": "Bend and twist reality itself, creating pocket dimensions, rifts, and much more", "description": "Bend and twist reality itself, creating pocket dimensions, rifts, and much more",
"version": "1.5.2R1.4.1RC1", "version": "1.6.4R2.1.2RC1",
"credits": "Created by StevenRS11, Coded by StevenRS11 and SenseiKiwi, Logo and Testing by Jaitsu", "credits": "Created by StevenRS11, Coded by StevenRS11 and SenseiKiwi, Logo and Testing by Jaitsu",
"logoFile": "/dimdoors_logo.png", "logoFile": "/dimdoors_logo.png",
"mcversion": "", "mcversion": "",
@@ -15,3 +18,4 @@
"dependencies": [ "Forge"] "dependencies": [ "Forge"]
} }
] ]
}