Added orientation to linkdata and door regen

This commit is contained in:
StevenRS11
2013-09-30 00:21:52 -04:00
parent 670b9a2902
commit f47a9d8b99
18 changed files with 148 additions and 49 deletions

View File

@@ -30,7 +30,7 @@ public class BlockGoldDimDoor extends BaseDimDoor implements IDimDoor
DimLink link = dimension.getLink(x, y, z); DimLink link = dimension.getLink(x, y, z);
if (link == null) if (link == null)
{ {
dimension.createLink(x, y, z, LinkTypes.POCKET); dimension.createLink(x, y, z, LinkTypes.POCKET,world.getBlockMetadata(x, y - 1, z));
} }
} }

View File

@@ -26,7 +26,7 @@ public class DimensionalDoor extends BaseDimDoor
DimLink link = dimension.getLink(x, y, z); DimLink link = dimension.getLink(x, y, z);
if (link == null) if (link == null)
{ {
dimension.createLink(x, y, z, LinkTypes.POCKET); dimension.createLink(x, y, z, LinkTypes.POCKET,world.getBlockMetadata(x, y - 1, z));
} }
} }

View File

@@ -71,7 +71,7 @@ public class TransientDoor extends BaseDimDoor
DimLink link = dimension.getLink(x, y, z); DimLink link = dimension.getLink(x, y, z);
if (link == null && dimension.isPocketDimension()) if (link == null && dimension.isPocketDimension())
{ {
dimension.createLink(x, y, z, LinkTypes.SAFE_EXIT); dimension.createLink(x, y, z, LinkTypes.SAFE_EXIT,world.getBlockMetadata(x, y - 1, z));
} }
} }
} }

View File

@@ -21,7 +21,7 @@ public class UnstableDoor extends BaseDimDoor
if (!world.isRemote && world.getBlockId(x, y - 1, z) == this.blockID) if (!world.isRemote && world.getBlockId(x, y - 1, z) == this.blockID)
{ {
NewDimData dimension = PocketManager.getDimensionData(world); NewDimData dimension = PocketManager.getDimensionData(world);
dimension.createLink(x, y, z, LinkTypes.RANDOM); dimension.createLink(x, y, z, LinkTypes.RANDOM,world.getBlockMetadata(x, y - 1, z));
} }
} }
@Override @Override

View File

@@ -25,7 +25,7 @@ public class WarpDoor extends BaseDimDoor
DimLink link = dimension.getLink(x, y, z); DimLink link = dimension.getLink(x, y, z);
if (link == null && dimension.isPocketDimension()) if (link == null && dimension.isPocketDimension())
{ {
dimension.createLink(x, y, z, LinkTypes.SAFE_EXIT); dimension.createLink(x, y, z, LinkTypes.SAFE_EXIT,world.getBlockMetadata(x, y - 1, z));
} }
} }
} }

View File

@@ -15,6 +15,7 @@ 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;
import net.minecraft.potion.PotionEffect; import net.minecraft.potion.PotionEffect;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper; 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;
@@ -22,11 +23,13 @@ import net.minecraftforge.common.DimensionManager;
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;
import StevenDimDoors.mod_pocketDim.blocks.BlockRift;
import StevenDimDoors.mod_pocketDim.blocks.IDimDoor; import StevenDimDoors.mod_pocketDim.blocks.IDimDoor;
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper; import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
import StevenDimDoors.mod_pocketDim.items.BaseItemDoor; import StevenDimDoors.mod_pocketDim.items.BaseItemDoor;
import StevenDimDoors.mod_pocketDim.items.ItemDimensionalDoor; import StevenDimDoors.mod_pocketDim.items.ItemDimensionalDoor;
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator; import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor;
import StevenDimDoors.mod_pocketDim.util.Point4D; import StevenDimDoors.mod_pocketDim.util.Point4D;
import StevenDimDoors.mod_pocketDim.world.PocketBuilder; import StevenDimDoors.mod_pocketDim.world.PocketBuilder;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
@@ -447,7 +450,6 @@ public class DDTeleporter
{ {
return; return;
} }
if (link.linkType() == LinkTypes.RANDOM) if (link.linkType() == LinkTypes.RANDOM)
{ {
Point4D randomDestination = getRandomDestination(); Point4D randomDestination = getRandomDestination();
@@ -459,6 +461,7 @@ public class DDTeleporter
} }
else else
{ {
buildExitDoor(door, link, DDProperties.instance());
entity = teleportEntity(entity, link.destination(), link.linkType() != LinkTypes.UNSAFE_EXIT); entity = teleportEntity(entity, link.destination(), link.linkType() != LinkTypes.UNSAFE_EXIT);
entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F); entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F);
} }
@@ -563,6 +566,38 @@ public class DDTeleporter
return false; return false;
} }
private static void buildExitDoor(Block door,DimLink link, DDProperties prop)
{
World startWorld = PocketManager.loadDimension(link.source().getDimension());
World destWorld = PocketManager.loadDimension(link.destination().getDimension());
TileEntity doorTE = startWorld.getBlockTileEntity(link.source().getX(), link.source().getY(), link.source.getZ());
if(doorTE instanceof TileEntityDimDoor)
{
if((TileEntityDimDoor.class.cast(doorTE).hasGennedPair))
{
return;
}
TileEntityDimDoor.class.cast(doorTE).hasGennedPair=true;
Block blockToReplace = Block.blocksList[destWorld.getBlockId(link.destination().getX(), link.destination().getY(), link.destination().getZ())];
if(!destWorld.isAirBlock(link.destination().getX(), link.destination().getY(), link.destination().getZ()))
{
if(!blockToReplace.isBlockReplaceable(destWorld, link.destination().getX(), link.destination().getY(), link.destination().getZ()))
{
return;
}
}
BaseItemDoor.placeDoorBlock(destWorld, link.destination().getX(), link.destination().getY()-1, link.destination().getZ(),link.getDestinationOrientation(), door);
TileEntity doorDestTE = startWorld.getBlockTileEntity(link.destination().getX(), link.destination().getY(), link.destination().getZ());
if(doorDestTE instanceof TileEntityDimDoor)
{
TileEntityDimDoor.class.cast(doorDestTE).hasGennedPair=true;
}
}
}
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.source.getDimension());
@@ -647,12 +682,12 @@ public class DDTeleporter
} }
// Create a reverse link for returning // Create a reverse link for returning
int orientation = getDestinationOrientation(source, properties);
NewDimData sourceDim = PocketManager.getDimensionData(link.source().getDimension()); NewDimData sourceDim = PocketManager.getDimensionData(link.source().getDimension());
DimLink reverse = destinationDim.createLink(x, y + 2, z, LinkTypes.REVERSE); DimLink reverse = destinationDim.createLink(x, y + 2, z, LinkTypes.REVERSE,orientation);
sourceDim.setDestination(reverse, source.getX(), source.getY(), source.getZ()); sourceDim.setDestination(reverse, source.getX(), source.getY(), source.getZ());
// Set up the warp door at the destination // Set up the warp door at the destination
int orientation = getDestinationOrientation(source, properties);
orientation = BlockRotator.transformMetadata(orientation, 2, properties.WarpDoorID); orientation = BlockRotator.transformMetadata(orientation, 2, properties.WarpDoorID);
ItemDimensionalDoor.placeDoorBlock(world, x, y + 1, z, orientation, mod_pocketDim.warpDoor); ItemDimensionalDoor.placeDoorBlock(world, x, y + 1, z, orientation, mod_pocketDim.warpDoor);

View File

@@ -10,10 +10,12 @@ public abstract class DimLink
protected Point4D source; protected Point4D source;
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) protected DimLink(Point4D source, DimLink parent, int orientation)
{ {
this.orientation=orientation;
this.parent = parent; this.parent = parent;
this.source = source; this.source = source;
this.tail = parent.tail; this.tail = parent.tail;
@@ -21,13 +23,13 @@ public abstract class DimLink
parent.children.add(this); parent.children.add(this);
} }
protected DimLink(Point4D source, int linkType) protected DimLink(Point4D source, int linkType, int orientation)
{ {
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.source = source;
this.tail = new LinkTail(linkType, null); this.tail = new LinkTail(linkType, null);
@@ -43,7 +45,10 @@ public abstract class DimLink
{ {
return tail.getDestination(); return tail.getDestination();
} }
public int getDestinationOrientation()
{
return PocketManager.getLink(source.getX(), source.getY(), source.getZ(), source.getDimension()).orientation();
}
public boolean hasDestination() public boolean hasDestination()
{ {
return (tail.getDestination() != null); return (tail.getDestination() != null);
@@ -68,6 +73,10 @@ public abstract class DimLink
{ {
return tail.getLinkType(); return tail.getLinkType();
} }
public int orientation()
{
return orientation;
}
public String toString() public String toString()
{ {

View File

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

View File

@@ -17,14 +17,14 @@ public abstract class NewDimData
{ {
private static class InnerDimLink extends DimLink private static class InnerDimLink extends DimLink
{ {
public InnerDimLink(Point4D source, DimLink parent) public InnerDimLink(Point4D source, DimLink parent,int orientation)
{ {
super(source, parent); super(source, parent,orientation);
} }
public InnerDimLink(Point4D source, int linkType) public InnerDimLink(Point4D source, int linkType, int orientation)
{ {
super(source, linkType); super(source, linkType,orientation);
} }
public void setDestination(int x, int y, int z, NewDimData dimension) public void setDestination(int x, int y, int z, NewDimData dimension)
@@ -236,19 +236,22 @@ public abstract class NewDimData
{ {
return Math.abs(i) + Math.abs(j) + Math.abs(k); return Math.abs(i) + Math.abs(j) + Math.abs(k);
} }
public DimLink createLink(int x, int y, int z, int linkType) public DimLink createLink(int x, int y, int z, int linkType)
{ {
return createLink(new Point4D(x, y, z, id), linkType); return createLink(new Point4D(x, y, z, id), linkType,-1);
}
public DimLink createLink(int x, int y, int z, int linkType,int orientation)
{
return createLink(new Point4D(x, y, z, id), linkType,orientation);
} }
private DimLink createLink(Point4D source, int linkType) private DimLink createLink(Point4D source, int linkType,int orientation)
{ {
//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); link = new InnerDimLink(source, linkType,orientation);
linkMapping.put(source, link); linkMapping.put(source, link);
linkList.add(link); linkList.add(link);
} }
@@ -279,7 +282,7 @@ 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); link = new InnerDimLink(source, parent, parent.orientation);
linkMapping.put(source, link); linkMapping.put(source, link);
linkList.add(link); linkList.add(link);

View File

@@ -238,12 +238,12 @@ public class DungeonSchematic extends Schematic {
filler.apply(world, minCorner, maxCorner); filler.apply(world, minCorner, maxCorner);
//Set up entrance door rift //Set up entrance door rift
createEntranceReverseLink(dimension, pocketCenter, entryLink); createEntranceReverseLink(dimension, pocketCenter, entryLink, world);
//Set up link data for dimensional doors //Set up link data for dimensional doors
for (Point3D location : dimensionalDoorLocations) for (Point3D location : dimensionalDoorLocations)
{ {
createDimensionalDoorLink(dimension, location, entranceDoorLocation, turnAngle, pocketCenter); createDimensionalDoorLink(dimension, location, entranceDoorLocation, turnAngle, pocketCenter,world);
} }
//Set up link data for exit door //Set up link data for exit door
@@ -285,9 +285,10 @@ public class DungeonSchematic extends Schematic {
} }
} }
private static void createEntranceReverseLink(NewDimData dimension, Point3D pocketCenter, DimLink entryLink) private static void createEntranceReverseLink(NewDimData dimension, Point3D pocketCenter, DimLink entryLink,World world)
{ {
DimLink reverseLink = dimension.createLink(pocketCenter.getX(), pocketCenter.getY(), pocketCenter.getZ(), LinkTypes.REVERSE); int orientation = world.getBlockMetadata(pocketCenter.getX(), pocketCenter.getY()-1, pocketCenter.getZ());
DimLink reverseLink = dimension.createLink(pocketCenter.getX(), pocketCenter.getY(), pocketCenter.getZ(), LinkTypes.REVERSE,orientation);
Point4D destination = entryLink.source(); Point4D destination = entryLink.source();
NewDimData prevDim = PocketManager.getDimensionData(destination.getDimension()); NewDimData prevDim = PocketManager.getDimensionData(destination.getDimension());
prevDim.setDestination(reverseLink, destination.getX(), destination.getY(), destination.getZ()); prevDim.setDestination(reverseLink, destination.getX(), destination.getY(), destination.getZ());
@@ -295,10 +296,12 @@ public class DungeonSchematic extends Schematic {
private static void createExitDoorLink(World world, NewDimData dimension, Point3D point, Point3D entrance, int rotation, Point3D pocketCenter) private static void createExitDoorLink(World world, NewDimData dimension, Point3D point, Point3D entrance, int rotation, Point3D pocketCenter)
{ {
//Transform the door's location to the pocket coordinate system //Transform the door's location to the pocket coordinate system
Point3D location = point.clone(); Point3D location = point.clone();
BlockRotator.transformPoint(location, entrance, rotation, pocketCenter); BlockRotator.transformPoint(location, entrance, rotation, pocketCenter);
dimension.createLink(location.getX(), location.getY(), location.getZ(), LinkTypes.DUNGEON_EXIT); int orientation = world.getBlockMetadata(location.getX(), location.getY()-1, location.getZ());
dimension.createLink(location.getX(), location.getY(), location.getZ(), LinkTypes.DUNGEON_EXIT,orientation);
//Replace the sandstone block under the exit door with the same block as the one underneath it //Replace the sandstone block under the exit door with the same block as the one underneath it
int x = location.getX(); int x = location.getX();
int y = location.getY() - 3; int y = location.getY() - 3;
@@ -311,12 +314,14 @@ public class DungeonSchematic extends Schematic {
} }
} }
private static void createDimensionalDoorLink(NewDimData dimension, Point3D point, Point3D entrance, int rotation, Point3D pocketCenter) private static void createDimensionalDoorLink(NewDimData dimension, Point3D point, Point3D entrance, int rotation, Point3D pocketCenter,World world)
{ {
//Transform the door's location to the pocket coordinate system //Transform the door's location to the pocket coordinate system
Point3D location = point.clone(); Point3D location = point.clone();
BlockRotator.transformPoint(location, entrance, rotation, pocketCenter); BlockRotator.transformPoint(location, entrance, rotation, pocketCenter);
dimension.createLink(location.getX(), location.getY(), location.getZ(), LinkTypes.DUNGEON); int orientation = world.getBlockMetadata(location.getX(), location.getY()-1, location.getZ());
dimension.createLink(location.getX(), location.getY(), location.getZ(), LinkTypes.DUNGEON,orientation);
} }
private static void spawnMonolith(World world, Point3D point, Point3D entrance, int rotation, Point3D pocketCenter, boolean canSpawn) private static void spawnMonolith(World world, Point3D point, Point3D entrance, int rotation, Point3D pocketCenter, boolean canSpawn)

View File

@@ -279,7 +279,7 @@ public class DungeonHelper
{ {
//Create a link above the specified position. Link to a new pocket dimension. //Create a link above the specified position. Link to a new pocket dimension.
NewDimData dimension = PocketManager.getDimensionData(world); NewDimData dimension = PocketManager.getDimensionData(world);
DimLink link = dimension.createLink(x, y + 1, z, LinkTypes.POCKET); DimLink link = dimension.createLink(x, y + 1, z, LinkTypes.POCKET,3);
//Place a Warp Door linked to that pocket //Place a Warp Door linked to that pocket
ItemDimensionalDoor.placeDoorBlock(world, x, y, z, 3, mod_pocketDim.warpDoor); ItemDimensionalDoor.placeDoorBlock(world, x, y, z, 3, mod_pocketDim.warpDoor);

View File

@@ -114,10 +114,9 @@ public class ItemRiftBlade extends ItemSword
var2.zCoord*=cooef; var2.zCoord*=cooef;
double var5 = holder.posX - var2.xCoord; double var5 = holder.posX - var2.xCoord;
double var9 = holder.posZ - var2.zCoord; double var9 = holder.posZ - var2.zCoord;
double var7 =holder.worldObj.getHeightValue(MathHelper.floor_double(var5), MathHelper.floor_double(var9));
if((Math.abs((holder.posY - var2.yCoord)-var7)>2))
{ double var7 = MathHelper.floor_double(holder.posY - var2.yCoord) ;
var7 = MathHelper.floor_double(holder.posY - var2.yCoord) ;
int var14 = MathHelper.floor_double(var5); int var14 = MathHelper.floor_double(var5);
int var15 = MathHelper.floor_double(var7); int var15 = MathHelper.floor_double(var7);
@@ -127,7 +126,7 @@ public class ItemRiftBlade extends ItemSword
var15++; var15++;
} }
var7=var15; var7=var15;
}
holder.setPositionAndUpdate(var5, var7, var9); holder.setPositionAndUpdate(var5, var7, var9);
holder.playSound("mob.endermen.portal", 1.0F, 1.0F); holder.playSound("mob.endermen.portal", 1.0F, 1.0F);

View File

@@ -7,6 +7,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.DimensionManager;
import StevenDimDoors.mod_pocketDim.mod_pocketDim; import StevenDimDoors.mod_pocketDim.mod_pocketDim;
@@ -66,14 +67,15 @@ public class ItemRiftSignature extends Item
return true; return true;
} }
Point4D source = getSource(stack); Point4DOrientation source = getSource(stack);
int orientation = MathHelper.floor_double((double) ((player.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
if (source != null) if (source != null)
{ {
//The link was used before and already has an endpoint stored. Create links connecting the two endpoints. //The link was used before and already has an endpoint stored. Create links connecting the two endpoints.
NewDimData sourceDimension = PocketManager.getDimensionData(source.getDimension()); NewDimData sourceDimension = PocketManager.getDimensionData(source.getDimension());
NewDimData destinationDimension = PocketManager.getDimensionData(world); NewDimData destinationDimension = PocketManager.getDimensionData(world);
DimLink link = sourceDimension.createLink(source.getX(), source.getY(), source.getZ(), LinkTypes.NORMAL); DimLink link = sourceDimension.createLink(source.getX(), source.getY(), source.getZ(), LinkTypes.NORMAL,source.getOrientation());
DimLink reverse = destinationDimension.createLink(x, y, z, LinkTypes.NORMAL); DimLink reverse = destinationDimension.createLink(x, y, z, LinkTypes.NORMAL,orientation);
destinationDimension.setDestination(link, x, y, z); destinationDimension.setDestination(link, x, y, z);
sourceDimension.setDestination(reverse, source.getX(), source.getY(), source.getZ()); sourceDimension.setDestination(reverse, source.getX(), source.getY(), source.getZ());
@@ -102,7 +104,7 @@ public class ItemRiftSignature extends Item
else else
{ {
//The link signature has not been used. Store its current target as the first location. //The link signature has not been used. Store its current target as the first location.
setSource(stack, x, y, z, PocketManager.getDimensionData(world)); setSource(stack, x, y, z,orientation, PocketManager.getDimensionData(world));
player.sendChatToPlayer("Location Stored in Rift Signature"); player.sendChatToPlayer("Location Stored in Rift Signature");
world.playSoundAtEntity(player,"mods.DimDoors.sfx.riftStart", 0.6f, 1); world.playSoundAtEntity(player,"mods.DimDoors.sfx.riftStart", 0.6f, 1);
} }
@@ -116,7 +118,7 @@ public class ItemRiftSignature extends Item
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{ {
Point4D source = getSource(par1ItemStack); Point4DOrientation source = getSource(par1ItemStack);
if (source != null) if (source != null)
{ {
par3List.add("Leads to (" + source.getX() + ", " + source.getY() + ", " + source.getZ() + ") at dimension #" + source.getDimension()); par3List.add("Leads to (" + source.getX() + ", " + source.getY() + ", " + source.getZ() + ") at dimension #" + source.getDimension());
@@ -129,13 +131,14 @@ public class ItemRiftSignature extends Item
} }
} }
public static void setSource(ItemStack itemStack, int x, int y, int z, NewDimData dimension) public static void setSource(ItemStack itemStack, int x, int y, int z, int orientation, NewDimData dimension)
{ {
NBTTagCompound tag = new NBTTagCompound(); NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("linkX", x); tag.setInteger("linkX", x);
tag.setInteger("linkY", y); tag.setInteger("linkY", y);
tag.setInteger("linkZ", z); tag.setInteger("linkZ", z);
tag.setInteger("orientation", orientation);
tag.setInteger("linkDimID", dimension.id()); tag.setInteger("linkDimID", dimension.id());
itemStack.setTagCompound(tag); itemStack.setTagCompound(tag);
@@ -149,11 +152,12 @@ public class ItemRiftSignature extends Item
tag.removeTag("linkX"); tag.removeTag("linkX");
tag.removeTag("linkY"); tag.removeTag("linkY");
tag.removeTag("linkZ"); tag.removeTag("linkZ");
tag.removeTag("orientation");
tag.removeTag("linkDimID"); tag.removeTag("linkDimID");
itemStack.setItemDamage(0); itemStack.setItemDamage(0);
} }
public static Point4D getSource(ItemStack itemStack) public static Point4DOrientation getSource(ItemStack itemStack)
{ {
if (itemStack.getItemDamage() != 0) if (itemStack.getItemDamage() != 0)
{ {
@@ -164,15 +168,52 @@ public class ItemRiftSignature extends Item
Integer x = tag.getInteger("linkX"); Integer x = tag.getInteger("linkX");
Integer y = tag.getInteger("linkY"); Integer y = tag.getInteger("linkY");
Integer z = tag.getInteger("linkZ"); Integer z = tag.getInteger("linkZ");
Integer orientation = tag.getInteger("orientation");
Integer dimID = tag.getInteger("linkDimID"); Integer dimID = tag.getInteger("linkDimID");
if (x != null && y != null && z != null && dimID != null) if (x != null && y != null && z != null && dimID != null)
{ {
return new Point4D(x, y, z, dimID); return new Point4DOrientation(x, y, z,orientation, dimID);
} }
} }
itemStack.setItemDamage(0); itemStack.setItemDamage(0);
} }
return null; return null;
} }
static class Point4DOrientation
{
private Point4D point;
private int orientation;
Point4DOrientation(int x, int y, int z, int orientation, int dimID)
{
this.point= new Point4D(x,y,z,dimID);
this.orientation=orientation;
} }
int getX()
{
return point.getX();
}
int getY()
{
return point.getY();
}
int getZ()
{
return point.getZ();
}
int getDimension()
{
return point.getDimension();
}
int getOrientation()
{
return orientation;
}
}
}

View File

@@ -6,6 +6,7 @@ import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.DimensionManager;
import StevenDimDoors.mod_pocketDim.mod_pocketDim; import StevenDimDoors.mod_pocketDim.mod_pocketDim;
@@ -46,7 +47,8 @@ public class ItemStabilizedRiftSignature extends ItemRiftSignature
} }
// Check if the Stabilized Rift Signature has been initialized // Check if the Stabilized Rift Signature has been initialized
Point4D source = getSource(stack); Point4DOrientation source = getSource(stack);
int orientation = MathHelper.floor_double((double) ((player.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
if (source != null) if (source != null)
{ {
// Yes, it's initialized. Check if the player is in creative // Yes, it's initialized. Check if the player is in creative
@@ -60,8 +62,8 @@ public class ItemStabilizedRiftSignature extends ItemRiftSignature
//The link was used before and already has an endpoint stored. Create links connecting the two endpoints. //The link was used before and already has an endpoint stored. Create links connecting the two endpoints.
NewDimData sourceDimension = PocketManager.getDimensionData(source.getDimension()); NewDimData sourceDimension = PocketManager.getDimensionData(source.getDimension());
NewDimData destinationDimension = PocketManager.getDimensionData(world); NewDimData destinationDimension = PocketManager.getDimensionData(world);
DimLink link = sourceDimension.createLink(source.getX(), source.getY(), source.getZ(), LinkTypes.NORMAL); DimLink link = sourceDimension.createLink(source.getX(), source.getY(), source.getZ(), LinkTypes.NORMAL,source.getOrientation());
DimLink reverse = destinationDimension.createLink(x, y, z, LinkTypes.NORMAL); DimLink reverse = destinationDimension.createLink(x, y, z, LinkTypes.NORMAL,orientation);
destinationDimension.setDestination(link, x, y, z); destinationDimension.setDestination(link, x, y, z);
sourceDimension.setDestination(reverse, source.getX(), source.getY(), source.getZ()); sourceDimension.setDestination(reverse, source.getX(), source.getY(), source.getZ());
@@ -89,7 +91,7 @@ public class ItemStabilizedRiftSignature extends ItemRiftSignature
else else
{ {
//The link signature has not been used. Store its current target as the first location. //The link signature has not been used. Store its current target as the first location.
setSource(stack, x, y, z, PocketManager.getDimensionData(world)); setSource(stack, x, y, z, orientation, PocketManager.getDimensionData(world));
player.sendChatToPlayer("Location Stored in Rift Signature"); player.sendChatToPlayer("Location Stored in Rift Signature");
world.playSoundAtEntity(player,"mods.DimDoors.sfx.riftStart", 0.6f, 1); world.playSoundAtEntity(player,"mods.DimDoors.sfx.riftStart", 0.6f, 1);
} }
@@ -104,7 +106,7 @@ public class ItemStabilizedRiftSignature extends ItemRiftSignature
@Override @Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{ {
Point4D source = getSource(par1ItemStack); Point4DOrientation source = getSource(par1ItemStack);
if (source != null) if (source != null)
{ {
par3List.add("Leads to (" + source.getX() + ", " + source.getY() + ", " + source.getZ() + ") at dimension #" + source.getDimension()); par3List.add("Leads to (" + source.getX() + ", " + source.getY() + ", " + source.getZ() + ") at dimension #" + source.getDimension());

View File

@@ -174,7 +174,7 @@ public class mod_pocketDim
transientDoor = new TransientDoor(properties.TransientDoorID, Material.iron, properties).setHardness(1.0F) .setUnlocalizedName("transientDoor"); transientDoor = new TransientDoor(properties.TransientDoorID, Material.iron, properties).setHardness(1.0F) .setUnlocalizedName("transientDoor");
goldDimDoor = new BlockGoldDimDoor(properties.GoldDimDoorID, Material.iron, properties).setHardness(1.0F) .setUnlocalizedName("dimDoorGold"); goldDimDoor = new BlockGoldDimDoor(properties.GoldDimDoorID, Material.iron, properties).setHardness(1.0F) .setUnlocalizedName("dimDoorGold");
goldDoor = new BlockDoorGold(properties.GoldDoorID, Material.iron, properties).setLightValue(1.0F).setHardness(0.1F).setUnlocalizedName("doorGold"); goldDoor = new BlockDoorGold(properties.GoldDoorID, Material.iron, properties).setHardness(0.1F).setUnlocalizedName("doorGold");
blockDimWall = new BlockDimWall(properties.FabricBlockID, 0, Material.iron).setLightValue(1.0F).setHardness(0.1F).setUnlocalizedName("blockDimWall"); blockDimWall = new BlockDimWall(properties.FabricBlockID, 0, Material.iron).setLightValue(1.0F).setHardness(0.1F).setUnlocalizedName("blockDimWall");
blockDimWallPerm = (new BlockDimWallPerm(properties.PermaFabricBlockID, 0, Material.iron)).setLightValue(1.0F).setBlockUnbreakable().setResistance(6000000.0F).setUnlocalizedName("blockDimWallPerm"); blockDimWallPerm = (new BlockDimWallPerm(properties.PermaFabricBlockID, 0, Material.iron)).setLightValue(1.0F).setBlockUnbreakable().setResistance(6000000.0F).setUnlocalizedName("blockDimWallPerm");
warpDoor = new WarpDoor(properties.WarpDoorID, Material.wood, properties).setHardness(1.0F) .setUnlocalizedName("dimDoorWarp"); warpDoor = new WarpDoor(properties.WarpDoorID, Material.wood, properties).setHardness(1.0F) .setUnlocalizedName("dimDoorWarp");

View File

@@ -13,6 +13,7 @@ public class TileEntityDimDoor extends TileEntity
public int orientation; public int orientation;
public boolean hasExit; public boolean hasExit;
public boolean isDungeonChainLink; public boolean isDungeonChainLink;
public boolean hasGennedPair=false;
@@ -45,6 +46,8 @@ public class TileEntityDimDoor extends TileEntity
this.isDungeonChainLink = nbt.getBoolean("isDungeonChainLink"); this.isDungeonChainLink = nbt.getBoolean("isDungeonChainLink");
this.hasGennedPair = nbt.getBoolean("hasGennedPair");
@@ -69,6 +72,7 @@ public class TileEntityDimDoor extends TileEntity
nbt.setBoolean("isDungeonChainLink", isDungeonChainLink); nbt.setBoolean("isDungeonChainLink", isDungeonChainLink);
nbt.setBoolean("hasGennedPair", hasGennedPair);
} }
} }

Binary file not shown.

Binary file not shown.