added locking doors and cleaned up

This commit is contained in:
StevenRS11 2014-05-20 03:17:32 -04:00
parent ac9b3d73e8
commit 8f9dfea947
23 changed files with 507 additions and 277 deletions

View file

@ -1,7 +1,6 @@
package StevenDimDoors.mod_pocketDim.blocks; package StevenDimDoors.mod_pocketDim.blocks;
import java.util.Random; import java.util.Random;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockDoor; import net.minecraft.block.BlockDoor;
import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.ITileEntityProvider;
@ -11,7 +10,7 @@ import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon; import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
@ -22,7 +21,8 @@ import StevenDimDoors.mod_pocketDim.config.DDProperties;
import StevenDimDoors.mod_pocketDim.core.DDTeleporter; import StevenDimDoors.mod_pocketDim.core.DDTeleporter;
import StevenDimDoors.mod_pocketDim.core.DimLink; import StevenDimDoors.mod_pocketDim.core.DimLink;
import StevenDimDoors.mod_pocketDim.core.PocketManager; import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator; import StevenDimDoors.mod_pocketDim.items.ItemDDKey;
import StevenDimDoors.mod_pocketDim.items.ItemDDLockCreator;
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor; import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -74,6 +74,12 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{ {
if(!checkCanOpen(world, x, y, z, player))
{
return false;
}
final int MAGIC_CONSTANT = 1003; final int MAGIC_CONSTANT = 1003;
int metadata = this.getFullMetadata(world, x, y, z); int metadata = this.getFullMetadata(world, x, y, z);
@ -92,6 +98,7 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
} }
world.playAuxSFXAtEntity(player, MAGIC_CONSTANT, x, y, z, 0); world.playAuxSFXAtEntity(player, MAGIC_CONSTANT, x, y, z, 0);
return true; return true;
} }
@ -188,21 +195,33 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
public boolean isDoorOnRift(World world, int x, int y, int z) public boolean isDoorOnRift(World world, int x, int y, int z)
{ {
if(this.isUpperDoorBlock( world.getBlockMetadata(x, y, z))) return this.getLink(world, x, y, z) != null;
}
public DimLink getLink(World world, int x, int y, int z)
{ {
if(PocketManager.getLink(x, y, z, world.provider.dimensionId) != null||PocketManager.getLink(x, y-1, z, world.provider.dimensionId) != null) DimLink link= PocketManager.getLink(x, y, z, world.provider.dimensionId);
if(link!=null)
{ {
return true; return link;
}
if(isUpperDoorBlock( world.getBlockMetadata(x, y, z)))
{
link = PocketManager.getLink(x, y-1, z, world.provider.dimensionId);
if(link!=null)
{
return link;
} }
} }
else else
{ {
if(PocketManager.getLink(x, y, z, world.provider.dimensionId) != null||PocketManager.getLink(x, y+1, z, world.provider.dimensionId) != null) link = PocketManager.getLink(x, y+1, z, world.provider.dimensionId);
if(link != null)
{ {
return true; return link;
} }
} }
return false; return null;
} }
/** /**
@ -312,6 +331,10 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
@Override @Override
public void onNeighborBlockChange(World world, int x, int y, int z, int neighborID) public void onNeighborBlockChange(World world, int x, int y, int z, int neighborID)
{ {
if(this.hasLock(world, x, y, z))
{
return;
}
int metadata = world.getBlockMetadata(x, y, z); int metadata = world.getBlockMetadata(x, y, z);
if (isUpperDoorBlock(metadata)) if (isUpperDoorBlock(metadata))
{ {
@ -429,16 +452,63 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn
} }
} }
public static boolean isUpperDoorBlock(int metadata) public boolean isUpperDoorBlock(int metadata)
{ {
return (metadata & 8) != 0; return (metadata & 8) != 0;
} }
public static boolean isDoorOpen(int metadata) public boolean isDoorOpen(int metadata)
{ {
return (metadata & 4) != 0; return (metadata & 4) != 0;
} }
public boolean hasLock(World world, int x, int y, int z)
{
DimLink link = getLink(world, x, y, z);
if(link!=null&&link.isLocked())
{
return true;
}
return false;
}
public boolean checkCanOpen(World world, int x, int y, int z)
{
return this.checkCanOpen(world, x, y, z, null);
}
public boolean checkCanOpen(World world, int x, int y, int z, EntityPlayer player)
{
if(!hasLock(world, x, y, z))
{
return true;
}
if(player == null)
{
return false;
}
DimLink link = getLink(world, x, y, z);
ItemStack itemStack;
for(ItemStack item : player.inventory.mainInventory)
{
if(item != null)
{
if(item.getItem() instanceof ItemDDKey)
{
if(ItemDDKey.getBoundLink(item)==link)
{
return true;
}
}
}
}
return false;
}
protected static boolean isEntityFacingDoor(int metadata, EntityLivingBase entity) protected static boolean isEntityFacingDoor(int metadata, EntityLivingBase entity)
{ {
// Although any entity has the proper fields for this check, // Although any entity has the proper fields for this check,

View file

@ -16,109 +16,25 @@ import net.minecraft.world.IBlockAccess;
public class BlockDoorGold extends BlockDoor public class BlockDoorGold extends BlockDoor
{ {
@SideOnly(Side.CLIENT)
private Icon[] upperTextures;
@SideOnly(Side.CLIENT)
private Icon[] lowerTextures;
public BlockDoorGold(int par1, Material par2Material) public BlockDoorGold(int par1, Material par2Material)
{ {
super(par1, par2Material); super(par1, par2Material);
} }
@Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister) protected String getTextureName()
{ {
upperTextures = new Icon[2]; return mod_pocketDim.modid + ":" + this.getUnlocalizedName();
lowerTextures = new Icon[2];
upperTextures[0] = iconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName() + "_upper");
lowerTextures[0] = iconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName() + "_lower");
upperTextures[1] = new IconFlipped(upperTextures[0], true, false);
lowerTextures[1] = new IconFlipped(lowerTextures[0], true, false);
} }
@Override @Override
public int idDropped(int par1, Random par2Random, int par3) public int idDropped(int par1, Random par2Random, int par3)
{ {
return (par1 & 8) != 0 ? 0 : mod_pocketDim.itemGoldenDoor.itemID; return (par1 & 8) != 0 ? 0 : mod_pocketDim.itemGoldenDoor.itemID;
} }
/**
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
*/
@Override
@SideOnly(Side.CLIENT)
public Icon getIcon(int side, int metadata)
{
return this.upperTextures[0];
}
/**
* Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
*/
@Override
@SideOnly(Side.CLIENT)
public Icon getBlockTexture(IBlockAccess blockAccess, int x, int y, int z, int side)
{
if (side != 1 && side != 0)
{
int fullMetadata = this.getFullMetadata(blockAccess, x, y, z);
int orientation = fullMetadata & 3;
boolean reversed = false;
if (BaseDimDoor.isDoorOpen(fullMetadata))
{
if (orientation == 0 && side == 2)
{
reversed = !reversed;
}
else if (orientation == 1 && side == 5)
{
reversed = !reversed;
}
else if (orientation == 2 && side == 3)
{
reversed = !reversed;
}
else if (orientation == 3 && side == 4)
{
reversed = !reversed;
}
}
else
{
if (orientation == 0 && side == 5)
{
reversed = !reversed;
}
else if (orientation == 1 && side == 3)
{
reversed = !reversed;
}
else if (orientation == 2 && side == 4)
{
reversed = !reversed;
}
else if (orientation == 3 && side == 2)
{
reversed = !reversed;
}
if ((fullMetadata & 16) != 0)
{
reversed = !reversed;
}
}
if (BaseDimDoor.isUpperDoorBlock(fullMetadata))
return this.upperTextures[reversed ? 1 : 0];
else
return this.lowerTextures[reversed ? 1 : 0];
}
else
{
return this.lowerTextures[0];
}
}
} }

View file

@ -13,4 +13,7 @@ public interface IDimDoor
public int getDrops(); public int getDrops();
public TileEntity initDoorTE(World world, int x, int y, int z); public TileEntity initDoorTE(World world, int x, int y, int z);
public boolean isDoorOnRift(World world, int x, int y, int z);
} }

View file

@ -18,7 +18,6 @@ import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager; import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityTransTrapdoor; import StevenDimDoors.mod_pocketDim.tileentities.TileEntityTransTrapdoor;
@SuppressWarnings("deprecation")
public class TransTrapdoor extends BlockTrapDoor implements IDimDoor, ITileEntityProvider public class TransTrapdoor extends BlockTrapDoor implements IDimDoor, ITileEntityProvider
{ {
@ -126,4 +125,10 @@ public class TransTrapdoor extends BlockTrapDoor implements IDimDoor, ITileEntit
world.setBlockTileEntity(x, y, z, te); world.setBlockTileEntity(x, y, z, te);
return te; return te;
} }
@Override
public boolean isDoorOnRift(World world, int x, int y, int z)
{
return PocketManager.getLink(x, y, z, world)!=null;
}
} }

View file

@ -62,11 +62,11 @@ public class CommandResetDungeons extends DDCommandBase
{ {
if(link.linkType()==LinkTypes.REVERSE) if(link.linkType()==LinkTypes.REVERSE)
{ {
data.createLink(link.source(), LinkTypes.DUNGEON_EXIT, link.orientation()); data.createLink(link.source(), LinkTypes.DUNGEON_EXIT, link.orientation(), false);
} }
if(link.linkType()==LinkTypes.DUNGEON) if(link.linkType()==LinkTypes.DUNGEON)
{ {
data.createLink(link.source(), LinkTypes.DUNGEON, link.orientation()); data.createLink(link.source(), LinkTypes.DUNGEON, link.orientation(), false);
} }
} }
} }

View file

@ -46,6 +46,8 @@ public class DDProperties
public final int UnstableDoorItemID; public final int UnstableDoorItemID;
public final int WarpDoorItemID; public final int WarpDoorItemID;
public final int WorldThreadItemID; public final int WorldThreadItemID;
public final int DDKeyItemID;
public final int DDLockCreatorItemID;
/** /**
@ -204,6 +206,8 @@ public class DDProperties
GoldenDoorItemID = config.getItem("Gold Door Item ID", 5678).getInt(); GoldenDoorItemID = config.getItem("Gold Door Item ID", 5678).getInt();
GoldenDimensionalDoorItemID = config.getItem("Gold Dim Door Item ID", 5679).getInt(); GoldenDimensionalDoorItemID = config.getItem("Gold Dim Door Item ID", 5679).getInt();
WorldThreadItemID = config.getItem("World Thread Item ID", 5680).getInt(); WorldThreadItemID = config.getItem("World Thread Item ID", 5680).getInt();
DDKeyItemID = config.getItem("Rift Key Item ID", 5681).getInt();
DDLockCreatorItemID = config.getItem("Rift Interlock Item ID", 5682).getInt();
LimboBlockID = config.getTerrainBlock("World Generation Block IDs - must be less than 256", "Limbo Block ID", 217, LimboBlockID = config.getTerrainBlock("World Generation Block IDs - must be less than 256", "Limbo Block ID", 217,
"Blocks used for the terrain in Limbo").getInt(); "Blocks used for the terrain in Limbo").getInt();

View file

@ -485,7 +485,7 @@ public class DDTeleporter
{ {
if(PocketManager.isBlackListed(link.destination().getDimension())) if(PocketManager.isBlackListed(link.destination().getDimension()))
{ {
link=PocketManager.getDimensionData(link.source().getDimension()).createLink(link.link.point,LinkTypes.SAFE_EXIT,link.link.orientation); link=PocketManager.getDimensionData(link.source().getDimension()).createLink(link.point,LinkTypes.SAFE_EXIT,link.orientation, false);
} }
else else
{ {
@ -561,7 +561,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.link.point.getDimension()); NewDimData current = PocketManager.getDimensionData(link.point.getDimension());
if (current.isPocketDimension()) if (current.isPocketDimension())
{ {
Point4D source = link.source(); Point4D source = link.source();
@ -585,7 +585,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.link.point.getZ()); TileEntity doorTE = startWorld.getBlockTileEntity(link.source().getX(), link.source().getY(), link.point.getZ());
if(doorTE instanceof TileEntityDimDoor) if(doorTE instanceof TileEntityDimDoor)
{ {
if((TileEntityDimDoor.class.cast(doorTE).hasGennedPair)) if((TileEntityDimDoor.class.cast(doorTE).hasGennedPair))
@ -617,7 +617,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.link.point.getDimension()); NewDimData current = PocketManager.getDimensionData(link.point.getDimension());
return generateSafeExit(current.root(), link, properties); return generateSafeExit(current.root(), link, properties);
} }
@ -628,7 +628,7 @@ public class DDTeleporter
// There is a chance of choosing the Nether first before other root dimensions // There is a chance of choosing the Nether first before other root dimensions
// to compensate for servers with many Mystcraft ages or other worlds. // to compensate for servers with many Mystcraft ages or other worlds.
NewDimData current = PocketManager.getDimensionData(link.link.point.getDimension()); NewDimData current = PocketManager.getDimensionData(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

@ -8,27 +8,31 @@ import StevenDimDoors.mod_pocketDim.watcher.ClientLinkData;
public abstract class DimLink public abstract class DimLink
{ {
protected ClientLinkData link; protected Point4D point;
protected int orientation;
protected boolean isLocked;
protected DimLink parent; protected DimLink parent;
protected LinkTail tail; protected LinkTail tail;
protected List<DimLink> children; protected List<DimLink> children;
protected DimLink(ClientLinkData link, DimLink parent) protected DimLink(Point4D point, int orientation, boolean locked, DimLink parent)
{ {
if (parent.link.point.getDimension() != link.point.getDimension()) if (parent.point.getDimension() != 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.parent = parent; this.parent = parent;
this.link = link; this.point = point;
this.tail = parent.tail; this.tail = parent.tail;
this.orientation = orientation;
this.isLocked = locked;
this.children = new LinkedList<DimLink>(); this.children = new LinkedList<DimLink>();
parent.children.add(this); parent.children.add(this);
} }
protected DimLink(ClientLinkData link, int linkType) protected DimLink(Point4D point, int orientation, boolean locked, 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)
{ {
@ -36,24 +40,41 @@ public abstract class DimLink
} }
this.parent = null; this.parent = null;
this.link = link; this.point = point;
this.orientation = orientation;
this.isLocked = locked;
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 link.point; return point;
}
public void clear()
{
//Release children
for (DimLink child : children)
{
child.parent = null;
}
children.clear();
//Release parent
if (parent != null)
{
parent.children.remove(this);
}
parent = null;
point = null;
tail = new LinkTail(0, null);
} }
public int orientation() public int orientation()
{ {
return link.orientation; return orientation;
}
public ClientLinkData link()
{
return link;
} }
public Point4D destination() public Point4D destination()
@ -94,8 +115,18 @@ public abstract class DimLink
return tail.getLinkType(); return tail.getLinkType();
} }
public boolean isLocked()
{
return isLocked;
}
public void setLocked(boolean bol)
{
isLocked = bol;
}
public String toString() public String toString()
{ {
return link.point + " -> " + (hasDestination() ? destination() : ""); return point + " -> " + (hasDestination() ? destination() : "");
} }
} }

View file

@ -28,5 +28,4 @@ class LinkTail
public void setLinkType(int linkType) { public void setLinkType(int linkType) {
this.linkType = linkType; this.linkType = linkType;
} }
} }

View file

@ -12,21 +12,26 @@ import StevenDimDoors.mod_pocketDim.Point3D;
import StevenDimDoors.mod_pocketDim.config.DDProperties; import StevenDimDoors.mod_pocketDim.config.DDProperties;
import StevenDimDoors.mod_pocketDim.dungeon.DungeonData; import StevenDimDoors.mod_pocketDim.dungeon.DungeonData;
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPack; import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPack;
import StevenDimDoors.mod_pocketDim.saving.IPackable;
import StevenDimDoors.mod_pocketDim.saving.PackedDimData;
import StevenDimDoors.mod_pocketDim.saving.PackedDungeonData;
import StevenDimDoors.mod_pocketDim.saving.PackedLinkData;
import StevenDimDoors.mod_pocketDim.saving.PackedLinkTail;
import StevenDimDoors.mod_pocketDim.util.Point4D; import StevenDimDoors.mod_pocketDim.util.Point4D;
import StevenDimDoors.mod_pocketDim.watcher.IUpdateWatcher; import StevenDimDoors.mod_pocketDim.watcher.IUpdateWatcher;
public abstract class NewDimData public abstract class NewDimData implements IPackable<PackedDimData>
{ {
private static class InnerDimLink extends DimLink private static class InnerDimLink extends DimLink
{ {
public InnerDimLink(Point4D source, DimLink parent, int orientation) public InnerDimLink(Point4D source, DimLink parent, int orientation, boolean isLocked)
{ {
super(new ClientLinkData(source, orientation), parent); super(source, orientation, isLocked, parent);
} }
public InnerDimLink(Point4D source, int linkType, int orientation) public InnerDimLink(Point4D source, int linkType, int orientation, boolean isLocked)
{ {
super(new ClientLinkData(source, orientation), linkType); super(source, orientation, isLocked, linkType);
} }
public void setDestination(int x, int y, int z, NewDimData dimension) public void setDestination(int x, int y, int z, NewDimData dimension)
@ -34,26 +39,6 @@ public abstract class NewDimData
tail.setDestination(new Point4D(x, y, z, dimension.id())); tail.setDestination(new Point4D(x, y, z, dimension.id()));
} }
public void clear()
{
//Release children
for (DimLink child : children)
{
((InnerDimLink) child).parent = null;
}
children.clear();
//Release parent
if (parent != null)
{
parent.children.remove(this);
}
parent = null;
link = null;
tail = new LinkTail(0, null);
}
public boolean overwrite(InnerDimLink nextParent,int orientation) public boolean overwrite(InnerDimLink nextParent,int orientation)
{ {
if (nextParent == null) if (nextParent == null)
@ -65,7 +50,7 @@ public abstract class NewDimData
//Ignore this request silently //Ignore this request silently
return false; return false;
} }
if (nextParent.link.point.getDimension() != link.point.getDimension()) if (nextParent.point.getDimension() != 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 +73,7 @@ public abstract class NewDimData
parent = nextParent; parent = nextParent;
tail = nextParent.tail; tail = nextParent.tail;
nextParent.children.add(this); nextParent.children.add(this);
this.link.orientation=orientation; this.orientation=orientation;
return true; return true;
} }
@ -111,7 +96,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.link.orientation=orientation; this.orientation=orientation;
} }
} }
@ -294,16 +279,16 @@ public abstract class NewDimData
public DimLink createLink(int x, int y, int z, int linkType, int orientation) public DimLink createLink(int x, int y, int z, int linkType, int orientation)
{ {
return createLink(new Point4D(x, y, z, id), linkType, orientation); return createLink(new Point4D(x, y, z, id), linkType, orientation, false);
} }
public DimLink createLink(Point4D source, int linkType, int orientation) public DimLink createLink(Point4D source, int linkType, int orientation, boolean locked)
{ {
//Return an existing link if there is one to avoid creating multiple links starting at the same point. //Return an existing link if there is one to avoid creating multiple links starting at the same point.
InnerDimLink link = linkMapping.get(source); InnerDimLink link = linkMapping.get(source);
if (link == null) if (link == null)
{ {
link = new InnerDimLink(source, linkType, orientation); link = new InnerDimLink(source, linkType, orientation, locked);
linkMapping.put(source, link); linkMapping.put(source, link);
linkList.add(link); linkList.add(link);
} }
@ -316,42 +301,41 @@ public abstract class NewDimData
//Link created! //Link created!
if (linkType != LinkTypes.CLIENT_SIDE) if (linkType != LinkTypes.CLIENT_SIDE)
{ {
linkWatcher.onCreated(link.link); linkWatcher.onCreated(new ClientLinkData(link));
} }
return link; return link;
} }
public DimLink createChildLink(int x, int y, int z, DimLink parent) public DimLink createChildLink(int x, int y, int z, DimLink parent)
{ {
if (parent == null) return createChildLink(new Point4D(x, y, z, id), (InnerDimLink) parent, false);
{
throw new IllegalArgumentException("parent cannot be null.");
} }
return createChildLink(new Point4D(x, y, z, id), (InnerDimLink) parent); public DimLink createChildLink(Point4D source, DimLink parent, boolean locked)
}
private DimLink createChildLink(Point4D source, InnerDimLink parent)
{ {
//To avoid having multiple links at a single point, if we find an existing link then we overwrite //To avoid having multiple links at a single point, if we find an existing link then we overwrite
//its destination data instead of creating a new instance. //its destination data instead of creating a new instance.
if (parent == null)
{
throw new IllegalArgumentException("parent cannot be null.");
}
InnerDimLink link = linkMapping.get(source); InnerDimLink link = linkMapping.get(source);
if (link == null) if (link == null)
{ {
link = new InnerDimLink(source, parent, parent.link.orientation); link = new InnerDimLink(source, parent, parent.orientation, locked);
linkMapping.put(source, link); linkMapping.put(source, link);
linkList.add(link); linkList.add(link);
//Link created! //Link created!
linkWatcher.onCreated(link.link); linkWatcher.onCreated(new ClientLinkData(link));
} }
else else
{ {
if (link.overwrite(parent, parent.link.orientation)) if (link.overwrite((InnerDimLink) parent, parent.orientation))
{ {
//Link created! //Link created!
linkWatcher.onCreated(link.link); linkWatcher.onCreated(new ClientLinkData(link));
} }
} }
modified = true; modified = true;
@ -369,7 +353,7 @@ public abstract class NewDimData
{ {
linkList.remove(target); linkList.remove(target);
//Raise deletion event //Raise deletion event
linkWatcher.onDeleted(target.link); linkWatcher.onDeleted(new ClientLinkData(link));
target.clear(); target.clear();
modified = true; modified = true;
} }
@ -605,6 +589,102 @@ public abstract class NewDimData
this.modified = false; this.modified = false;
} }
public void clear()
{
// If this dimension has a parent, remove it from its parent's list of children
if (parent != null)
{
parent.children.remove(this);
}
// Remove this dimension as the parent of its children
for (NewDimData child : children)
{
child.parent = null;
}
// Clear all fields
id = Integer.MIN_VALUE;
linkMapping.clear();
linkMapping = null;
linkList.clear();
linkList = null;
children.clear();
children = null;
isDungeon = false;
isFilled = false;
depth = Integer.MIN_VALUE;
packDepth = Integer.MIN_VALUE;
origin = null;
orientation = Integer.MIN_VALUE;
dungeon = null;
linkWatcher = null;
}
public PackedDimData pack()
{
ArrayList<Integer> ChildIDs = new ArrayList<Integer>();
ArrayList<PackedLinkData> Links = new ArrayList<PackedLinkData>();
ArrayList<PackedLinkTail> Tails = new ArrayList<PackedLinkTail>();
PackedDungeonData packedDungeon=null;
if(this.dungeon!=null)
{
packedDungeon= new PackedDungeonData(dungeon.weight(), dungeon.isOpen(), dungeon.isInternal(),
dungeon.schematicPath(), dungeon.schematicName(), dungeon.dungeonType().Name,
dungeon.dungeonType().Owner.getName());
}
//Make a list of children
for(NewDimData data : this.children)
{
ChildIDs.add(data.id);
}
for(DimLink link:this.links())
{
ArrayList<Point3D> children = new ArrayList<Point3D>();
Point3D parentPoint = new Point3D(-1,-1,-1);
if(link.parent!=null)
{
parentPoint=link.parent.point.toPoint3D();
}
for(DimLink childLink : link.children)
{
children.add(childLink.source().toPoint3D());
}
PackedLinkTail tail = new PackedLinkTail(link.tail.getDestination(),link.tail.getLinkType());
Links.add(new PackedLinkData(link.point,parentPoint,tail,link.orientation,children,link.isLocked()));
PackedLinkTail tempTail = new PackedLinkTail(link.tail.getDestination(),link.tail.getLinkType());
if(Tails.contains(tempTail))
{
Tails.add(tempTail);
}
}
int parentID=this.id;
Point3D originPoint=new Point3D(0,0,0);
if(this.parent!=null)
{
parentID = this.parent.id;
}
if(this.origin!=null)
{
originPoint=this.origin.toPoint3D();
}
return new PackedDimData(this.id, depth, this.packDepth, parentID, this.root().id(), orientation,
isDungeon, isFilled,packedDungeon, originPoint, ChildIDs, Links, Tails);
// FIXME: IMPLEMENTATION PLZTHX
//I tried
}
@Override
public String name()
{
return String.valueOf(id);
}
public String toString() public String toString()
{ {
return "DimID= " + this.id; return "DimID= " + this.id;

View file

@ -41,7 +41,7 @@ import StevenDimDoors.mod_pocketDim.watcher.UpdateWatcherProxy;
*/ */
public class PocketManager public class PocketManager
{ {
private static class InnerDimData extends NewDimData implements IPackable<PackedDimData> private static class InnerDimData extends NewDimData
{ {
// This class allows us to instantiate NewDimData indirectly without exposing // This class allows us to instantiate NewDimData indirectly without exposing
// a public constructor from NewDimData. It's meant to stop us from constructing // a public constructor from NewDimData. It's meant to stop us from constructing
@ -60,101 +60,6 @@ public class PocketManager
super(id, root); super(id, root);
} }
public void clear()
{
// If this dimension has a parent, remove it from its parent's list of children
if (parent != null)
{
parent.children.remove(this);
}
// Remove this dimension as the parent of its children
for (NewDimData child : children)
{
child.parent = null;
}
// Clear all fields
id = Integer.MIN_VALUE;
linkMapping.clear();
linkMapping = null;
linkList.clear();
linkList = null;
children.clear();
children = null;
isDungeon = false;
isFilled = false;
depth = Integer.MIN_VALUE;
packDepth = Integer.MIN_VALUE;
origin = null;
orientation = Integer.MIN_VALUE;
dungeon = null;
linkWatcher = null;
}
@Override
public String name()
{
return String.valueOf(id);
}
@Override
public PackedDimData pack()
{
ArrayList<Integer> ChildIDs = new ArrayList<Integer>();
ArrayList<PackedLinkData> Links = new ArrayList<PackedLinkData>();
ArrayList<PackedLinkTail> Tails = new ArrayList<PackedLinkTail>();
PackedDungeonData packedDungeon=null;
if(this.dungeon!=null)
{
packedDungeon= new PackedDungeonData(dungeon.weight(), dungeon.isOpen(), dungeon.isInternal(),
dungeon.schematicPath(), dungeon.schematicName(), dungeon.dungeonType().Name,
dungeon.dungeonType().Owner.getName());
}
//Make a list of children
for(NewDimData data : this.children)
{
ChildIDs.add(data.id);
}
for(DimLink link:this.links())
{
ArrayList<Point3D> children = new ArrayList<Point3D>();
Point3D parentPoint = new Point3D(-1,-1,-1);
if(link.parent!=null)
{
parentPoint=link.parent.link.point.toPoint3D();
}
for(DimLink childLink : link.children)
{
children.add(childLink.source().toPoint3D());
}
PackedLinkTail tail = new PackedLinkTail(link.tail.getDestination(),link.tail.getLinkType());
Links.add(new PackedLinkData(link.link.point,parentPoint,tail,link.link.orientation,children));
PackedLinkTail tempTail = new PackedLinkTail(link.tail.getDestination(),link.tail.getLinkType());
if(Tails.contains(tempTail))
{
Tails.add(tempTail);
}
}
int parentID=this.id;
Point3D originPoint=new Point3D(0,0,0);
if(this.parent!=null)
{
parentID = this.parent.id;
}
if(this.origin!=null)
{
originPoint=this.origin.toPoint3D();
}
return new PackedDimData(this.id, depth, this.packDepth, parentID, this.root().id(), orientation,
isDungeon, isFilled,packedDungeon, originPoint, ChildIDs, Links, Tails);
// FIXME: IMPLEMENTATION PLZTHX
//I tried
}
} }
private static class ClientLinkWatcher implements IUpdateWatcher<ClientLinkData> private static class ClientLinkWatcher implements IUpdateWatcher<ClientLinkData>

View file

@ -0,0 +1,73 @@
package StevenDimDoors.mod_pocketDim.items;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.DimLink;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
public class ItemDDKey extends Item
{
public ItemDDKey(int itemID)
{
super(itemID);
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
}
@Override
public void registerIcons(IconRegister par1IconRegister)
{
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("item.", ""));
}
@Override
@SideOnly(Side.CLIENT)
public boolean hasEffect(ItemStack par1ItemStack)
{
return true;
}
public static void setBoundDoor(ItemStack itemStack, DimLink link)
{
NBTTagCompound tag = new NBTTagCompound();
int x = link.source().getX();
int y = link.source().getY();
int z = link.source().getZ();
tag.setInteger("linkX", x);
tag.setInteger("linkY", y);
tag.setInteger("linkZ", z);
tag.setInteger("linkDimID", link.source().getDimension());
itemStack.setTagCompound(tag);
itemStack.setItemDamage(1);
}
public static DimLink getBoundLink(ItemStack itemStack)
{
if (itemStack.hasTagCompound())
{
NBTTagCompound tag = itemStack.getTagCompound();
Integer x = tag.getInteger("linkX");
Integer y = tag.getInteger("linkY");
Integer z = tag.getInteger("linkZ");
Integer dimID = tag.getInteger("linkDimID");
if (x != null && y != null && z != null && dimID != null)
{
return PocketManager.getLink(x, y, z, dimID);
}
}
return null;
}
}

View file

@ -0,0 +1,111 @@
package StevenDimDoors.mod_pocketDim.items;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.blocks.IDimDoor;
import StevenDimDoors.mod_pocketDim.core.DimLink;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.items.ItemRiftSignature.Point4DOrientation;
public class ItemDDLockCreator extends Item
{
public ItemDDLockCreator(int itemID)
{
super(itemID);
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
}
@Override
public void registerIcons(IconRegister par1IconRegister)
{
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("item.", ""));
}
@Override
@SideOnly(Side.CLIENT)
public boolean hasEffect(ItemStack itemStack)
{
return itemStack.hasTagCompound();
}
public boolean onItemUseFirst(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float playerX, float playerY, float playerZ)
{
int blockID = world.getBlockId(x, y, z);
if(!(Block.blocksList[blockID] instanceof IDimDoor))
{
return false;
}
DimLink link = PocketManager.getLink(x, y, z, world);
if(link==null)
{
return false;
}
if(itemStack.hasTagCompound())
{
if(link == getBoundLink(itemStack))
{
link.setLocked(!link.isLocked());
return true;
}
return false;
}
setBoundDoor(itemStack,link);
link.setLocked(true);
return true;
}
public static void setBoundDoor(ItemStack itemStack, DimLink link)
{
NBTTagCompound tag = new NBTTagCompound();
int x = link.source().getX();
int y = link.source().getY();
int z = link.source().getZ();
tag.setInteger("linkX", x);
tag.setInteger("linkY", y);
tag.setInteger("linkZ", z);
tag.setInteger("linkDimID", link.source().getDimension());
itemStack.setTagCompound(tag);
itemStack.setItemDamage(1);
}
public DimLink getBoundLink(ItemStack itemStack)
{
if (itemStack.hasTagCompound())
{
NBTTagCompound tag = itemStack.getTagCompound();
Integer x = tag.getInteger("linkX");
Integer y = tag.getInteger("linkY");
Integer z = tag.getInteger("linkZ");
Integer dimID = tag.getInteger("linkDimID");
if (x != null && y != null && z != null && dimID != null)
{
return PocketManager.getLink(x, y, z, dimID);
}
}
return null;
}
public String getItemStackDisplayName(ItemStack par1ItemStack)
{
return StatCollector.translateToLocal(this.getUnlocalizedName(par1ItemStack) + ".name");
}
}

View file

@ -42,6 +42,8 @@ import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.helpers.ChunkLoaderHelper; import StevenDimDoors.mod_pocketDim.helpers.ChunkLoaderHelper;
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper; import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
import StevenDimDoors.mod_pocketDim.items.ItemBlockDimWall; import StevenDimDoors.mod_pocketDim.items.ItemBlockDimWall;
import StevenDimDoors.mod_pocketDim.items.ItemDDKey;
import StevenDimDoors.mod_pocketDim.items.ItemDDLockCreator;
import StevenDimDoors.mod_pocketDim.items.ItemDimensionalDoor; import StevenDimDoors.mod_pocketDim.items.ItemDimensionalDoor;
import StevenDimDoors.mod_pocketDim.items.ItemGoldDimDoor; import StevenDimDoors.mod_pocketDim.items.ItemGoldDimDoor;
import StevenDimDoors.mod_pocketDim.items.ItemGoldDoor; import StevenDimDoors.mod_pocketDim.items.ItemGoldDoor;
@ -136,6 +138,8 @@ public class mod_pocketDim
public static Item itemStableFabric; public static Item itemStableFabric;
public static Item itemUnstableDoor; public static Item itemUnstableDoor;
public static Item itemStabilizedLinkSignature; public static Item itemStabilizedLinkSignature;
public static Item itemDDKey;
public static Item itemDDLockCreator;
public static BiomeGenBase limboBiome; public static BiomeGenBase limboBiome;
public static BiomeGenBase pocketBiome; public static BiomeGenBase pocketBiome;
@ -209,6 +213,8 @@ public class mod_pocketDim
dimensionalDoor = (DimensionalDoor) (new DimensionalDoor(properties.DimensionalDoorID, Material.iron, properties).setHardness(1.0F).setResistance(2000.0F) .setUnlocalizedName("dimDoor")); dimensionalDoor = (DimensionalDoor) (new DimensionalDoor(properties.DimensionalDoorID, Material.iron, properties).setHardness(1.0F).setResistance(2000.0F) .setUnlocalizedName("dimDoor"));
transTrapdoor = (TransTrapdoor) (new TransTrapdoor(properties.TransTrapdoorID, Material.wood).setHardness(1.0F) .setUnlocalizedName("dimHatch")); transTrapdoor = (TransTrapdoor) (new TransTrapdoor(properties.TransTrapdoorID, Material.wood).setHardness(1.0F) .setUnlocalizedName("dimHatch"));
itemDDKey = (new ItemDDKey(properties.DDKeyItemID)).setUnlocalizedName("itemDDKey");
itemDDLockCreator = (new ItemDDLockCreator(properties.DDLockCreatorItemID)).setUnlocalizedName("itemDDLockCreator");
itemGoldenDoor = (new ItemGoldDoor(properties.GoldenDoorItemID, Material.wood)).setUnlocalizedName("itemGoldDoor"); itemGoldenDoor = (new ItemGoldDoor(properties.GoldenDoorItemID, Material.wood)).setUnlocalizedName("itemGoldDoor");
itemGoldenDimensionalDoor = (new ItemGoldDimDoor(properties.GoldenDimensionalDoorItemID, Material.iron, (ItemDoor)this.itemGoldenDoor)).setUnlocalizedName("itemGoldDimDoor"); itemGoldenDimensionalDoor = (new ItemGoldDimDoor(properties.GoldenDimensionalDoorItemID, Material.iron, (ItemDoor)this.itemGoldenDoor)).setUnlocalizedName("itemGoldDimDoor");
itemDimensionalDoor = (ItemDimensionalDoor) (new ItemDimensionalDoor(properties.DimensionalDoorItemID, Material.iron, (ItemDoor)Item.doorIron)).setUnlocalizedName("itemDimDoor"); itemDimensionalDoor = (ItemDimensionalDoor) (new ItemDimensionalDoor(properties.DimensionalDoorItemID, Material.iron, (ItemDoor)Item.doorIron)).setUnlocalizedName("itemDimDoor");
@ -272,6 +278,8 @@ public class mod_pocketDim
LanguageRegistry.addName(itemDimensionalDoor, "Dimensional Door"); LanguageRegistry.addName(itemDimensionalDoor, "Dimensional Door");
LanguageRegistry.addName(itemRiftBlade, "Rift Blade"); LanguageRegistry.addName(itemRiftBlade, "Rift Blade");
LanguageRegistry.addName(itemWorldThread, "World Thread"); LanguageRegistry.addName(itemWorldThread, "World Thread");
LanguageRegistry.addName(itemDDKey, "Unbound Rift Key");
LanguageRegistry.addName(itemDDLockCreator, "Unbound Rift Interlock");
/** /**
* Add names for multiblock inventory item * Add names for multiblock inventory item

View file

@ -197,7 +197,7 @@ public class DDSaveHandler
linkType = LinkTypes.NORMAL; linkType = LinkTypes.NORMAL;
} }
DimLink link = data.createLink(packedLink.source, linkType, packedLink.orientation); DimLink link = data.createLink(packedLink.source, linkType, packedLink.orientation, packedLink.locked);
Point4D destination = packedLink.tail.destination; Point4D destination = packedLink.tail.destination;
if(destination!=null) if(destination!=null)
{ {
@ -216,7 +216,7 @@ public class DDSaveHandler
NewDimData data = PocketManager.getDimensionData(packedLink.source.getDimension()); NewDimData data = PocketManager.getDimensionData(packedLink.source.getDimension());
if(data.getLink(packedLink.parent)!=null) if(data.getLink(packedLink.parent)!=null)
{ {
data.createChildLink(packedLink.source.getX(), packedLink.source.getY(), packedLink.source.getZ(), data.getLink(packedLink.parent)); data.createChildLink(packedLink.source, data.getLink(packedLink.parent), packedLink.locked);
} }
unpackedLinks.add(packedLink); unpackedLinks.add(packedLink);
} }

View file

@ -202,6 +202,8 @@ public class DimDataProcessor extends BaseConfigurationProcessor<PackedDimData>
private PackedLinkData createLinkDataFromJson(JsonReader reader) throws IOException private PackedLinkData createLinkDataFromJson(JsonReader reader) throws IOException
{ {
boolean locked = false;
Point4D source; Point4D source;
Point3D parent; Point3D parent;
PackedLinkTail tail; PackedLinkTail tail;
@ -230,9 +232,16 @@ public class DimDataProcessor extends BaseConfigurationProcessor<PackedDimData>
children.add(this.createPointFromJson(reader)); children.add(this.createPointFromJson(reader));
} }
reader.endArray(); reader.endArray();
if(reader.peek()== JsonToken.NAME)
{
reader.nextName();
locked = reader.nextBoolean();
}
reader.endObject(); reader.endObject();
return new PackedLinkData(source, parent, tail, orientation, children); return new PackedLinkData(source, parent, tail, orientation, children, locked);
} }
private PackedDungeonData createDungeonDataFromJson(JsonReader reader) throws IOException private PackedDungeonData createDungeonDataFromJson(JsonReader reader) throws IOException
{ {
@ -293,6 +302,7 @@ public class DimDataProcessor extends BaseConfigurationProcessor<PackedDimData>
} }
linkType = reader.nextInt(); linkType = reader.nextInt();
reader.endObject(); reader.endObject();
return new PackedLinkTail(destination, linkType); return new PackedLinkTail(destination, linkType);

View file

@ -80,7 +80,7 @@ public class OldSaveImporter
PackedLinkTail tail = new PackedLinkTail(destintion, link.linkOrientation); PackedLinkTail tail = new PackedLinkTail(destintion, link.linkOrientation);
List<Point3D> children = new ArrayList<Point3D>(); List<Point3D> children = new ArrayList<Point3D>();
PackedLinkData newPackedLink = new PackedLinkData(source, new Point3D(-1,-1,-1), tail, link.linkOrientation,children); PackedLinkData newPackedLink = new PackedLinkData(source, new Point3D(-1,-1,-1), tail, link.linkOrientation,children, false);
newPackedLinkData.add(newPackedLink); newPackedLinkData.add(newPackedLink);
allPackedLinks.add(newPackedLink); allPackedLinks.add(newPackedLink);

View file

@ -12,13 +12,15 @@ public class PackedLinkData
public final PackedLinkTail tail; public final PackedLinkTail tail;
public final int orientation; public final int orientation;
public final List<Point3D> children; public final List<Point3D> children;
public final boolean locked;
public PackedLinkData(Point4D source, Point3D parent, PackedLinkTail tail, int orientation, List<Point3D> children) public PackedLinkData(Point4D source, Point3D parent, PackedLinkTail tail, int orientation, List<Point3D> children, boolean locked)
{ {
this.source=source; this.source=source;
this.parent=parent; this.parent=parent;
this.tail=tail; this.tail=tail;
this.orientation=orientation; this.orientation=orientation;
this.children=children; this.children=children;
this.locked = locked;
} }
} }

View file

@ -6,6 +6,7 @@ import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.blocks.IDimDoor; import StevenDimDoors.mod_pocketDim.blocks.IDimDoor;
import StevenDimDoors.mod_pocketDim.core.NewDimData; import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager; import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.watcher.ClientLinkData;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet;
@ -32,7 +33,7 @@ public class TileEntityDimDoor extends DDTileEntityBase
{ {
if(PocketManager.getLink(xCoord, yCoord, zCoord, worldObj)!=null) if(PocketManager.getLink(xCoord, yCoord, zCoord, worldObj)!=null)
{ {
return ServerPacketHandler.createLinkPacket(PocketManager.getLink(xCoord, yCoord, zCoord, worldObj).link()); return ServerPacketHandler.createLinkPacket(new ClientLinkData(PocketManager.getLink(xCoord, yCoord, zCoord, worldObj)));
} }
return null; return null;
} }

View file

@ -32,6 +32,7 @@ import StevenDimDoors.mod_pocketDim.core.DimLink;
import StevenDimDoors.mod_pocketDim.core.NewDimData; import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager; import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.util.Point4D; import StevenDimDoors.mod_pocketDim.util.Point4D;
import StevenDimDoors.mod_pocketDim.watcher.ClientLinkData;
public class TileEntityRift extends DDTileEntityBase public class TileEntityRift extends DDTileEntityBase
{ {
@ -375,7 +376,7 @@ public class TileEntityRift extends DDTileEntityBase
{ {
if (PocketManager.getLink(xCoord, yCoord, zCoord, worldObj) != null) if (PocketManager.getLink(xCoord, yCoord, zCoord, worldObj) != null)
{ {
return ServerPacketHandler.createLinkPacket(PocketManager.getLink(xCoord, yCoord, zCoord, worldObj).link()); return ServerPacketHandler.createLinkPacket(new ClientLinkData(PocketManager.getLink(xCoord, yCoord, zCoord, worldObj)));
} }
return null; return null;
} }

View file

@ -11,30 +11,35 @@ public class ClientLinkData
{ {
public Point4D point; public Point4D point;
public int orientation; public int orientation;
public boolean isLocked;
public ClientLinkData(DimLink link) public ClientLinkData(DimLink link)
{ {
this.point= link.source(); this.point= link.source();
this.orientation=link.orientation(); this.orientation=link.orientation();
this.isLocked = link.isLocked();
} }
public ClientLinkData(Point4D point, int orientation) public ClientLinkData(Point4D point, int orientation, boolean isLocked)
{ {
this.point = point; this.point = point;
this.orientation=orientation; this.orientation=orientation;
this.isLocked = isLocked;
} }
public void write(DataOutputStream output) throws IOException public void write(DataOutputStream output) throws IOException
{ {
Point4D.write(point, output); Point4D.write(point, output);
output.writeInt(orientation); output.writeInt(orientation);
output.writeBoolean(isLocked);
} }
public static ClientLinkData read(DataInputStream input) throws IOException public static ClientLinkData read(DataInputStream input) throws IOException
{ {
Point4D point = Point4D.read(input); Point4D point = Point4D.read(input);
int orientation = input.readInt(); int orientation = input.readInt();
return new ClientLinkData(point, orientation); boolean isLocked = input.readBoolean();
return new ClientLinkData(point, orientation, isLocked);
} }
} }

View file

@ -0,0 +1,6 @@
package StevenDimDoors.mod_pocketDim.world;
public interface ILockable
{
}

View file

@ -66,7 +66,7 @@ public class PocketBuilder
if(originLink==null) if(originLink==null)
{ {
int orientation = linkIn.orientation(); int orientation = linkIn.orientation();
originLink=dimension.createLink(oldLinkPos, LinkTypes.SAFE_EXIT, (orientation+2)%4); originLink=dimension.createLink(oldLinkPos, LinkTypes.SAFE_EXIT, (orientation+2)%4, false);
return false; return false;
} }
//The link that originally created the dungeon on the way in //The link that originally created the dungeon on the way in
@ -75,7 +75,7 @@ public class PocketBuilder
{ {
int orientation = linkIn.orientation(); int orientation = linkIn.orientation();
dimension.deleteLink(originLink); dimension.deleteLink(originLink);
dimension.createLink(oldLinkPos, LinkTypes.SAFE_EXIT, (orientation+2)%4); dimension.createLink(oldLinkPos, LinkTypes.SAFE_EXIT, (orientation+2)%4, false);
return false; return false;
} }
NewDimData parent = PocketManager.getDimensionData(incomingLink.source().getDimension()); NewDimData parent = PocketManager.getDimensionData(incomingLink.source().getDimension());