Added orientation to linkdata and door regen
This commit is contained in:
@@ -114,10 +114,9 @@ public class ItemRiftBlade extends ItemSword
|
||||
var2.zCoord*=cooef;
|
||||
double var5 = holder.posX - var2.xCoord;
|
||||
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))
|
||||
{
|
||||
var7 = MathHelper.floor_double(holder.posY - var2.yCoord) ;
|
||||
|
||||
|
||||
double var7 = MathHelper.floor_double(holder.posY - var2.yCoord) ;
|
||||
|
||||
int var14 = MathHelper.floor_double(var5);
|
||||
int var15 = MathHelper.floor_double(var7);
|
||||
@@ -127,7 +126,7 @@ public class ItemRiftBlade extends ItemSword
|
||||
var15++;
|
||||
}
|
||||
var7=var15;
|
||||
}
|
||||
|
||||
|
||||
holder.setPositionAndUpdate(var5, var7, var9);
|
||||
holder.playSound("mob.endermen.portal", 1.0F, 1.0F);
|
||||
|
||||
@@ -7,6 +7,7 @@ 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.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
@@ -66,14 +67,15 @@ public class ItemRiftSignature extends Item
|
||||
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)
|
||||
{
|
||||
//The link was used before and already has an endpoint stored. Create links connecting the two endpoints.
|
||||
NewDimData sourceDimension = PocketManager.getDimensionData(source.getDimension());
|
||||
NewDimData destinationDimension = PocketManager.getDimensionData(world);
|
||||
DimLink link = sourceDimension.createLink(source.getX(), source.getY(), source.getZ(), LinkTypes.NORMAL);
|
||||
DimLink reverse = destinationDimension.createLink(x, y, z, 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,orientation);
|
||||
destinationDimension.setDestination(link, x, y, z);
|
||||
sourceDimension.setDestination(reverse, source.getX(), source.getY(), source.getZ());
|
||||
|
||||
@@ -102,7 +104,7 @@ public class ItemRiftSignature extends Item
|
||||
else
|
||||
{
|
||||
//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");
|
||||
world.playSoundAtEntity(player,"mods.DimDoors.sfx.riftStart", 0.6f, 1);
|
||||
}
|
||||
@@ -116,7 +118,7 @@ public class ItemRiftSignature extends Item
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
Point4D source = getSource(par1ItemStack);
|
||||
Point4DOrientation source = getSource(par1ItemStack);
|
||||
if (source != null)
|
||||
{
|
||||
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();
|
||||
|
||||
tag.setInteger("linkX", x);
|
||||
tag.setInteger("linkY", y);
|
||||
tag.setInteger("linkZ", z);
|
||||
tag.setInteger("orientation", orientation);
|
||||
tag.setInteger("linkDimID", dimension.id());
|
||||
|
||||
itemStack.setTagCompound(tag);
|
||||
@@ -149,11 +152,12 @@ public class ItemRiftSignature extends Item
|
||||
tag.removeTag("linkX");
|
||||
tag.removeTag("linkY");
|
||||
tag.removeTag("linkZ");
|
||||
tag.removeTag("orientation");
|
||||
tag.removeTag("linkDimID");
|
||||
itemStack.setItemDamage(0);
|
||||
}
|
||||
|
||||
public static Point4D getSource(ItemStack itemStack)
|
||||
public static Point4DOrientation getSource(ItemStack itemStack)
|
||||
{
|
||||
if (itemStack.getItemDamage() != 0)
|
||||
{
|
||||
@@ -164,15 +168,52 @@ public class ItemRiftSignature extends Item
|
||||
Integer x = tag.getInteger("linkX");
|
||||
Integer y = tag.getInteger("linkY");
|
||||
Integer z = tag.getInteger("linkZ");
|
||||
Integer orientation = tag.getInteger("orientation");
|
||||
Integer dimID = tag.getInteger("linkDimID");
|
||||
|
||||
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);
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ 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.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
@@ -46,7 +47,8 @@ public class ItemStabilizedRiftSignature extends ItemRiftSignature
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
// 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.
|
||||
NewDimData sourceDimension = PocketManager.getDimensionData(source.getDimension());
|
||||
NewDimData destinationDimension = PocketManager.getDimensionData(world);
|
||||
DimLink link = sourceDimension.createLink(source.getX(), source.getY(), source.getZ(), LinkTypes.NORMAL);
|
||||
DimLink reverse = destinationDimension.createLink(x, y, z, 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,orientation);
|
||||
destinationDimension.setDestination(link, x, y, z);
|
||||
sourceDimension.setDestination(reverse, source.getX(), source.getY(), source.getZ());
|
||||
|
||||
@@ -89,7 +91,7 @@ public class ItemStabilizedRiftSignature extends ItemRiftSignature
|
||||
else
|
||||
{
|
||||
//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");
|
||||
world.playSoundAtEntity(player,"mods.DimDoors.sfx.riftStart", 0.6f, 1);
|
||||
}
|
||||
@@ -104,7 +106,7 @@ public class ItemStabilizedRiftSignature extends ItemRiftSignature
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
Point4D source = getSource(par1ItemStack);
|
||||
Point4DOrientation source = getSource(par1ItemStack);
|
||||
if (source != null)
|
||||
{
|
||||
par3List.add("Leads to (" + source.getX() + ", " + source.getY() + ", " + source.getZ() + ") at dimension #" + source.getDimension());
|
||||
|
||||
Reference in New Issue
Block a user