redid orientation handling, works better now.
Vastly improved y level detection for teleports
This commit is contained in:
@@ -72,7 +72,7 @@ public class ChaosDoor extends dimDoor
|
||||
|
||||
if(newDim)
|
||||
{
|
||||
LinkData link = new LinkData(par1World.provider.dimensionId, mod_pocketDim.limboDimID, par2, par3, par4, par2, par3+500, par4, false);
|
||||
LinkData link = new LinkData(par1World.provider.dimensionId, mod_pocketDim.limboDimID, par2, par3, par4, par2, par3+500, par4, false,0);
|
||||
link.linkOrientation= par1World.getBlockMetadata(par2, par3-1, par4);
|
||||
dimHelper.instance.createLink(link);
|
||||
// System.out.println(link.linkOrientation);
|
||||
@@ -124,7 +124,7 @@ public class ChaosDoor extends dimDoor
|
||||
{
|
||||
foundRandomDest=true;
|
||||
|
||||
dimHelper.instance.teleportToPocket(par1World, new LinkData(link.destDimID,link.locDimID,link.destXCoord,link.destYCoord,link.destZCoord,link.locXCoord,link.locYCoord,link.locZCoord,link.isLocPocket), par5Entity);
|
||||
dimHelper.instance.teleportToPocket(par1World, new LinkData(link.destDimID,link.locDimID,link.destXCoord,link.destYCoord,link.destZCoord,link.locXCoord,link.locYCoord,link.locZCoord,link.isLocPocket,0), par5Entity);
|
||||
|
||||
if(dimHelper.getWorld(link.locDimID)!=null)
|
||||
{
|
||||
|
||||
@@ -127,9 +127,9 @@ public class DimData implements Serializable
|
||||
|
||||
|
||||
|
||||
LinkData linkData= new LinkData(this.dimID, destinationDimID, locationXCoord, locationYCoord, locationZCoord, destinationXCoord, destinationYCoord,destinationZCoord,this.isPocket);
|
||||
LinkData linkData= new LinkData(this.dimID, destinationDimID, locationXCoord, locationYCoord, locationZCoord, destinationXCoord, destinationYCoord,destinationZCoord,this.isPocket,linkOrientation);
|
||||
|
||||
|
||||
linkData.linkOrientation=linkOrientation;
|
||||
|
||||
return this.addLinkToDim(linkData);
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public class LinkData implements Serializable
|
||||
this.destZCoord=exitZ;
|
||||
}
|
||||
|
||||
public LinkData(int locationDimID, int destinationDimID, int locationXCoord, int locationYCoord, int locationZCoord, int destinationXCoord, int destinationYCoord, int destinationZCoord, boolean isPocket)
|
||||
public LinkData(int locationDimID, int destinationDimID, int locationXCoord, int locationYCoord, int locationZCoord, int destinationXCoord, int destinationYCoord, int destinationZCoord, boolean isPocket,int orientation)
|
||||
{
|
||||
|
||||
this.exists=true;
|
||||
@@ -55,6 +55,7 @@ public class LinkData implements Serializable
|
||||
this.destDimID=destinationDimID;
|
||||
this.locDimID=locationDimID;
|
||||
this.isLocPocket=isPocket;
|
||||
this.linkOrientation=orientation;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -104,9 +104,8 @@ public class PacketHandler implements IPacketHandler
|
||||
{
|
||||
DimData dimDataToAddLink= dimHelper.dimList.get(dimId);
|
||||
|
||||
LinkData linkToAdd = new LinkData(dimId, data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readBoolean());
|
||||
LinkData linkToAdd = new LinkData(dimId, data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readBoolean(),data.readInt());
|
||||
linkToAdd.hasGennedDoor=data.readBoolean();
|
||||
linkToAdd.linkOrientation=data.readInt();
|
||||
|
||||
dimHelper.instance.createLink(linkToAdd);
|
||||
|
||||
@@ -130,7 +129,7 @@ public class PacketHandler implements IPacketHandler
|
||||
{
|
||||
DimData dimDataToRemoveFrom= dimHelper.dimList.get(dimId);
|
||||
|
||||
LinkData linkToAdd = new LinkData(dimId, data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readBoolean());
|
||||
LinkData linkToAdd = new LinkData(dimId, data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readInt(), data.readBoolean(),data.readInt());
|
||||
dimDataToRemoveFrom.removeLinkAtCoords(linkToAdd.locDimID, linkToAdd.locXCoord,linkToAdd.locYCoord, linkToAdd.locZCoord);
|
||||
|
||||
}
|
||||
@@ -224,9 +223,9 @@ public class PacketHandler implements IPacketHandler
|
||||
dataOut.writeInt(link.destYCoord);
|
||||
dataOut.writeInt(link.destZCoord);
|
||||
dataOut.writeBoolean(link.isLocPocket);
|
||||
dataOut.writeBoolean(link.hasGennedDoor);
|
||||
dataOut.writeInt(link.linkOrientation);
|
||||
|
||||
dataOut.writeInt(link.linkOrientation);
|
||||
dataOut.writeBoolean(link.hasGennedDoor);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class RiftGenerator implements IWorldGenerator
|
||||
{
|
||||
// System.out.println(String.valueOf(i)+"x "+String.valueOf(j)+"y "+String.valueOf(k)+"z"+"Large gen");
|
||||
|
||||
link = new LinkData(world.provider.dimensionId, 0, i, j+1, k, i, j+1, k, true);
|
||||
link = new LinkData(world.provider.dimensionId, 0, i, j+1, k, i, j+1, k, true,rand.nextInt(4));
|
||||
link = dimHelper.instance.createPocket(link,true, true);
|
||||
this.shouldSave=true;
|
||||
|
||||
@@ -104,7 +104,7 @@ public class RiftGenerator implements IWorldGenerator
|
||||
{
|
||||
//System.out.println(String.valueOf(i)+"x "+String.valueOf(j)+"y "+String.valueOf(k)+"z"+"med gen");
|
||||
|
||||
link = new LinkData(world.provider.dimensionId, 0, i, j+1, k, i, j+1, k, true);
|
||||
link = new LinkData(world.provider.dimensionId, 0, i, j+1, k, i, j+1, k, true,rand.nextInt(4));
|
||||
link = dimHelper.instance.createPocket(link,true, true);
|
||||
this.shouldSave=true;
|
||||
|
||||
@@ -168,7 +168,7 @@ public class RiftGenerator implements IWorldGenerator
|
||||
|
||||
if(world.isBlockOpaqueCube(i, j-2, k)||world.isBlockOpaqueCube(i, j-1, k))
|
||||
{
|
||||
link = new LinkData(world.provider.dimensionId, 0, i, j+1, k, i, j+1, k, true);
|
||||
link = new LinkData(world.provider.dimensionId, 0, i, j+1, k, i, j+1, k, true,rand.nextInt(4));
|
||||
link =dimHelper.instance.createPocket(link,true, true);
|
||||
|
||||
for(int xc=-3;xc<4;xc++)
|
||||
|
||||
@@ -4,6 +4,8 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
@@ -834,8 +836,7 @@ public class SchematicLoader
|
||||
|
||||
|
||||
|
||||
LinkData sideLink = new LinkData(link.destDimID,0,point.getX(), point.getY(), point.getZ(),xNoise+point.getX(), point.getY()+1, zNoise+point.getZ(),true);
|
||||
sideLink.linkOrientation=world.getBlockMetadata(point.getX(), point.getY()-1, point.getZ());
|
||||
LinkData sideLink = new LinkData(link.destDimID,0,point.getX(), point.getY(), point.getZ(),xNoise+point.getX(), point.getY()+1, zNoise+point.getZ(),true,world.getBlockMetadata(point.getX(), point.getY()-1, point.getZ()));
|
||||
dimHelper.instance.createPocket(sideLink, true, true);
|
||||
|
||||
|
||||
@@ -855,7 +856,7 @@ public class SchematicLoader
|
||||
|
||||
LinkData randomLink=dimHelper.instance.getRandomLinkData(false);
|
||||
|
||||
LinkData sideLink = new LinkData(link.destDimID,dimHelper.dimList.get(link.locDimID).exitDimLink.destDimID,point.getX(), point.getY(), point.getZ(),point.getX(), 0, point.getZ(),true);
|
||||
LinkData sideLink = new LinkData(link.destDimID,dimHelper.dimList.get(link.locDimID).exitDimLink.destDimID,point.getX(), point.getY(), point.getZ(),point.getX(), 0, point.getZ(),true,-10);
|
||||
|
||||
if(sideLink.destDimID==mod_pocketDim.limboDimID)
|
||||
{
|
||||
@@ -868,8 +869,13 @@ public class SchematicLoader
|
||||
}
|
||||
|
||||
|
||||
dimHelper.getWorld((sideLink.destDimID)).getChunkProvider().loadChunk(point.getX() >> 4, point.getZ() >> 4);
|
||||
sideLink.destYCoord=dimHelper.getWorld(sideLink.destDimID).getHeightValue(point.getX(), point.getZ())+1;
|
||||
|
||||
sideLink.destYCoord=yCoordHelper.getFirstUncovered(sideLink.destDimID, point.getX(),10,point.getZ());
|
||||
|
||||
if(sideLink.destYCoord<5)
|
||||
{
|
||||
sideLink.destYCoord=70;
|
||||
}
|
||||
|
||||
sideLink.linkOrientation=world.getBlockMetadata(point.getX(), point.getY()-1, point.getZ());
|
||||
dimHelper.instance.createLink(sideLink);
|
||||
|
||||
@@ -59,6 +59,7 @@ public class TransientDoor extends ExitDoor
|
||||
|
||||
public void onBlockAdded(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
super.onBlockAdded(par1World, par2, par3, par4);
|
||||
this.updateAttatchedTile(par1World, par2, par3, par4);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public class BlockDimWall extends Block
|
||||
*/
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
if(!par1World.isRemote&&entityPlayer.getCurrentEquippedItem()!=null)
|
||||
if(entityPlayer.getCurrentEquippedItem()!=null)
|
||||
{
|
||||
Item playerEquip = entityPlayer.getCurrentEquippedItem().getItem();
|
||||
|
||||
@@ -78,7 +78,10 @@ public class BlockDimWall extends Block
|
||||
|
||||
if(entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemBlock)
|
||||
{
|
||||
|
||||
if(par1World.isRemote)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!entityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
|
||||
@@ -78,7 +78,7 @@ public class BlockDimWallPerm extends Block
|
||||
int y = dimHelper.getWorld(0).getHeightValue(x, z);
|
||||
|
||||
//this complicated chunk teleports the player back to the overworld at some random location. Looks funky becaue it has to load the chunk
|
||||
dimHelper.instance.teleportToPocket(par1World, new LinkData(par1World.provider.dimensionId,0,x,y,z,link.locXCoord,link.locYCoord,link.locZCoord,link.isLocPocket),
|
||||
dimHelper.instance.teleportToPocket(par1World, new LinkData(par1World.provider.dimensionId,0,x,y,z,link.locXCoord,link.locYCoord,link.locZCoord,link.isLocPocket,0),
|
||||
EntityPlayer.class.cast(par5Entity));
|
||||
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -67,11 +68,11 @@ public class ExitDoor extends dimDoor
|
||||
{
|
||||
//System.out.println("exitToOverowrld from "+String.valueOf(locDimID));
|
||||
|
||||
int yCoord=yCoordHelper.getFirstUncovered(ExitDimID, par2, par3, par4);
|
||||
|
||||
|
||||
|
||||
dimHelper.instance.createLink(locDimID, ExitDimID, par2, par3, par4, par2, par3, par4,par1World.getBlockMetadata(par2, par3-1, par4));
|
||||
dimHelper.instance.createLink(ExitDimID, locDimID, par2, par3, par4, par2, par3, par4,dimHelper.instance.flipDoorMetadata(par1World.getBlockMetadata(par2, par3-1, par4)));
|
||||
dimHelper.instance.createLink(locDimID, ExitDimID, par2, par3, par4, par2, yCoord, par4,par1World.getBlockMetadata(par2, par3-1, par4));
|
||||
dimHelper.instance.createLink(ExitDimID, locDimID, par2, yCoord, par4, par2, par3, par4,dimHelper.instance.flipDoorMetadata(par1World.getBlockMetadata(par2, par3-1, par4)));
|
||||
|
||||
|
||||
|
||||
@@ -81,8 +82,7 @@ public class ExitDoor extends dimDoor
|
||||
{
|
||||
//System.out.println("Created new dim from "+String.valueOf(par1World.provider.dimensionId));
|
||||
|
||||
LinkData link = new LinkData(par1World.provider.dimensionId, 0, par2, par3, par4, par2, par3, par4, true);
|
||||
link.linkOrientation= par1World.getBlockMetadata(par2, par3-1, par4);
|
||||
LinkData link = new LinkData(par1World.provider.dimensionId, 0, par2, par3, par4, par2, par3, par4, true, par1World.getBlockMetadata(par2, par3-1, par4));
|
||||
dimHelper.instance.createPocket(link,false, false);
|
||||
|
||||
|
||||
|
||||
@@ -257,8 +257,7 @@ public class dimDoor extends BlockContainer
|
||||
|
||||
|
||||
|
||||
LinkData link = new LinkData(par1World.provider.dimensionId, 0, par2, par3, par4, par2, par3, par4, true);
|
||||
link.linkOrientation= par1World.getBlockMetadata(par2, par3-1, par4);
|
||||
LinkData link = new LinkData(par1World.provider.dimensionId, 0, par2, par3, par4, par2, par3, par4, true,par1World.getBlockMetadata(par2, par3-1, par4));
|
||||
dimHelper.instance.createPocket(link,true, false);
|
||||
// System.out.println(link.linkOrientation);
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public class CommandAddDungeonRift extends CommandBase
|
||||
MathHelper.floor_double(this.getCommandSenderAsPlayer(var1).posZ),
|
||||
MathHelper.floor_double(this.getCommandSenderAsPlayer(var1).posX),
|
||||
MathHelper.floor_double(this.getCommandSenderAsPlayer(var1).posY)+1,
|
||||
MathHelper.floor_double(this.getCommandSenderAsPlayer(var1).posZ),true);
|
||||
MathHelper.floor_double(this.getCommandSenderAsPlayer(var1).posZ),true,3);
|
||||
|
||||
link = dimHelper.instance.createPocket(link,true, true);
|
||||
|
||||
|
||||
@@ -467,8 +467,7 @@ public class dimHelper extends DimensionManager
|
||||
|
||||
|
||||
|
||||
LinkData linkData =new LinkData( locationDimID, destinationDimID, locationXCoord, locationYCoord, locationZCoord, destinationXCoord, destinationYCoord ,destinationZCoord,false);
|
||||
linkData.linkOrientation=linkOrientation;
|
||||
LinkData linkData =new LinkData( locationDimID, destinationDimID, locationXCoord, locationYCoord, locationZCoord, destinationXCoord, destinationYCoord ,destinationZCoord,false,linkOrientation);
|
||||
return this.createLink(linkData);
|
||||
|
||||
|
||||
@@ -637,18 +636,20 @@ public class dimHelper extends DimensionManager
|
||||
{
|
||||
this.initDimension(destinationID);
|
||||
}
|
||||
int locOrientation = linkData.linkOrientation;
|
||||
int destOrientation = this.getLinkDataFromCoords(destX, destY, destZ, destinationID).linkOrientation;
|
||||
|
||||
int blockToReplace= this.getWorld(destinationID).getBlockId(destX, destY, destZ);
|
||||
if(blockToReplace!=mod_pocketDim.dimDoorID&&blockToReplace!=mod_pocketDim.linkExitDoorID&&blockToReplace!=mod_pocketDim.linkDimDoorID&&blockToReplace!=mod_pocketDim.ExitDoorID&&blockToReplace!=mod_pocketDim.transientDoorID)
|
||||
{
|
||||
this.getWorld(destinationID).setBlock(destX, destY-1, destZ, doorTypeToPlace,dimHelper.instance.flipDoorMetadata(world.getBlockMetadata(locX, locY-1, locZ)),2);
|
||||
this.getWorld(destinationID).setBlock(destX, destY-1, destZ, doorTypeToPlace,destOrientation,2);
|
||||
this.getWorld(destinationID).setBlock(destX, destY, destZ, doorTypeToPlace,world.getBlockMetadata(locX, locY, locZ),2);
|
||||
// System.out.println("Genned door");
|
||||
}
|
||||
|
||||
if(id==mod_pocketDim.transientDoorID&&!dimHelper.dimList.get((destinationID)).hasBeenFilled)
|
||||
{
|
||||
this.getWorld(destinationID).setBlock(destX, destY-1, destZ, id,dimHelper.instance.flipDoorMetadata(world.getBlockMetadata(locX, locY-1, locZ)),2);
|
||||
this.getWorld(destinationID).setBlock(destX, destY-1, destZ, id,destOrientation,2);
|
||||
this.getWorld(destinationID).setBlock(destX, destY, destZ, id,world.getBlockMetadata(locX, locY, locZ),2);
|
||||
}
|
||||
|
||||
|
||||
68
StevenDimDoors/mod_pocketDim/helpers/yCoordHelper.java
Normal file
68
StevenDimDoors/mod_pocketDim/helpers/yCoordHelper.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package StevenDimDoors.mod_pocketDim.helpers;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.dimHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
|
||||
public class yCoordHelper
|
||||
{
|
||||
public static int getFirstUncovered(LinkData pointerLink)
|
||||
{
|
||||
return yCoordHelper.getFirstUncovered(pointerLink.destDimID, pointerLink.destXCoord,pointerLink.destYCoord, pointerLink.destZCoord);
|
||||
}
|
||||
public static int getFirstUncovered(int worldID, int x, int yStart, int z)
|
||||
{
|
||||
if(dimHelper.getWorld(worldID)==null||dimHelper.getWorld(worldID).provider==null)
|
||||
{
|
||||
dimHelper.initDimension(worldID);
|
||||
}
|
||||
|
||||
return yCoordHelper.getFirstUncovered(dimHelper.getWorld(worldID),x,yStart,z);
|
||||
}
|
||||
public static int getFirstUncovered(World world, int x, int yStart, int z)
|
||||
{
|
||||
int yCoord=yStart;
|
||||
|
||||
Chunk chunk = world.getChunkProvider().loadChunk(x >> 4, z >> 4);
|
||||
|
||||
int xC=(x % 16)< 0 ? (x % 16)+16 : (x % 16);
|
||||
int yC=yCoord;
|
||||
int zC=(z % 16)< 0 ? (z % 16)+16 : (z % 16);
|
||||
|
||||
|
||||
boolean flag=false;
|
||||
|
||||
do
|
||||
{
|
||||
flag=false;
|
||||
if(chunk.getBlockID(xC, yC-1, zC)!=0)
|
||||
{
|
||||
if(!Block.blocksList[chunk.getBlockID(xC, yC-1, zC)].blockMaterial.isReplaceable()||Block.blocksList[chunk.getBlockID(xC, yC-1, zC)].blockMaterial.isLiquid())
|
||||
{
|
||||
|
||||
flag=true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(chunk.getBlockID(xC, yC, zC)!=0)
|
||||
{
|
||||
if(!Block.blocksList[chunk.getBlockID(xC, yC, zC)].blockMaterial.isReplaceable()||Block.blocksList[chunk.getBlockID(xC, yC, zC)].blockMaterial.isLiquid())
|
||||
{
|
||||
|
||||
flag=true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
yC++;
|
||||
}
|
||||
while(flag&&yC<245);
|
||||
|
||||
|
||||
return yC-1;
|
||||
}
|
||||
}
|
||||
@@ -148,70 +148,51 @@ public class ItemRiftBlade extends itemDimDoor
|
||||
|
||||
public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4)
|
||||
{
|
||||
Vec3 var2 = par3EntityPlayer.getLook(1.0F);
|
||||
|
||||
double cooef = -2;
|
||||
var2.xCoord*=cooef;
|
||||
var2.yCoord*=cooef;
|
||||
var2.zCoord*=cooef;
|
||||
double var5 = par3EntityPlayer.posX - var2.xCoord;
|
||||
double var9 = par3EntityPlayer.posZ - var2.zCoord;
|
||||
double var7 =par3EntityPlayer.posY-var2.yCoord+2;
|
||||
|
||||
int x = MathHelper.floor_double(var5);
|
||||
int y = MathHelper.floor_double(var7);
|
||||
int z = MathHelper.floor_double(var9);
|
||||
|
||||
|
||||
if(dimHelper.dimList.get(par2World.provider.dimensionId)!=null&&!par2World.isRemote)
|
||||
int rotation = (int) (MathHelper.floor_double((double)((par3EntityPlayer.rotationYaw+90) * 4.0F / 360.0F) + 0.5D) & 3);
|
||||
LinkData link = new LinkData(par2World.provider.dimensionId, 0, x, y, z, x, y, z, true,rotation);
|
||||
|
||||
if(this.getMaxItemUseDuration(par1ItemStack)-par4>12&&!par2World.isRemote&&this.canPlace(par2World, x, y, z, rotation))
|
||||
{
|
||||
|
||||
if(this.getMaxItemUseDuration(par1ItemStack)-par4>12)
|
||||
{
|
||||
if(dimHelper.dimList.get(par2World.provider.dimensionId)!=null)
|
||||
{
|
||||
if(dimHelper.dimList.get(par2World.provider.dimensionId).depth==0)
|
||||
{
|
||||
dimHelper.instance.createPocket(link,true, false);
|
||||
|
||||
Vec3 var2 = par3EntityPlayer.getLook(1.0F);
|
||||
}
|
||||
|
||||
double cooef = -2;
|
||||
var2.xCoord*=cooef;
|
||||
var2.yCoord*=cooef;
|
||||
var2.zCoord*=cooef;
|
||||
double var5 = par3EntityPlayer.posX - var2.xCoord;
|
||||
double var9 = par3EntityPlayer.posZ - var2.zCoord;
|
||||
double var7 =par3EntityPlayer.posY-var2.yCoord+2;
|
||||
}
|
||||
else
|
||||
{
|
||||
dimHelper.instance.createPocket(link,true, false);
|
||||
|
||||
int x = MathHelper.floor_double(var5);
|
||||
int y = MathHelper.floor_double(var7);
|
||||
int z = MathHelper.floor_double(var9);
|
||||
}
|
||||
|
||||
|
||||
int rotation = (int) (MathHelper.floor_double((double)((par3EntityPlayer.rotationYaw+90) * 4.0F / 360.0F) + 0.5D) & 3);
|
||||
LinkData link = new LinkData(par2World.provider.dimensionId, 0, x, y, z, x, y, z, true);
|
||||
placeDoorBlock(par2World, x, y-1, z, rotation, mod_pocketDim.transientDoor);
|
||||
|
||||
|
||||
if(dimHelper.dimList.get(par2World.provider.dimensionId).depth==0)
|
||||
{
|
||||
link.linkOrientation= rotation;
|
||||
dimHelper.instance.createPocket(link,true, false);
|
||||
|
||||
|
||||
}
|
||||
else if(dimHelper.dimList.get(par2World.provider.dimensionId).depth==1)
|
||||
{
|
||||
link.linkOrientation= rotation;
|
||||
dimHelper.instance.createLink(link);
|
||||
//System.out.println("doingup");
|
||||
int ExitDimID= dimHelper.dimList.get(par2World.provider.dimensionId).exitDimLink.destDimID;
|
||||
|
||||
dimHelper.instance.createLink(link.locDimID, ExitDimID, x, y, z, x, y, z,rotation);
|
||||
dimHelper.instance.createLink(ExitDimID, link.locDimID, x, y, z, x, y, z,dimHelper.instance.flipDoorMetadata(rotation));
|
||||
|
||||
|
||||
}
|
||||
else if(dimHelper.dimList.get(par2World.provider.dimensionId).isPocket)
|
||||
{
|
||||
link.linkOrientation= rotation;
|
||||
dimHelper.instance.createPocket(link,false, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
placeDoorBlock(par2World, x, y-1, z, rotation, mod_pocketDim.transientDoor);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -242,7 +223,7 @@ public class ItemRiftBlade extends itemDimDoor
|
||||
|
||||
if (!this.canPlace(par2World, par4, par5, par6, var12)||dimHelper.instance.getLinkDataFromCoords(par4, par5+1, par6, par2World)==null)
|
||||
{
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -371,6 +352,8 @@ public class ItemRiftBlade extends itemDimDoor
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,8 @@ package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
@@ -9,8 +11,12 @@ import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemStableFabric extends Item
|
||||
@@ -32,13 +38,86 @@ public class ItemStableFabric extends Item
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
|
||||
//System.out.println("Block metadata is "+par3World.getBlockMetadata(par4, par5, par6));
|
||||
System.out.println("Block metadata is "+par3World.getBlockMetadata(par4, par5, par6));
|
||||
//System.out.println("Block texture data is "+Block.blocksList[par3World.getBlockId(par4, par5, par6)].getBlockTexture(par3World,par4, par5, par6,par7).getIconName());
|
||||
//System.out.println("Block name is is "+Block.blocksList[par3World.getBlockId(par4, par5, par6)].getUnlocalizedName2());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public MovingObjectPosition getMovingObjectPositionFromPlayer(World par1World, EntityPlayer par2EntityPlayer, boolean par3)
|
||||
{
|
||||
float var4 = 1.0F;
|
||||
float var5 = par2EntityPlayer.prevRotationPitch + (par2EntityPlayer.rotationPitch - par2EntityPlayer.prevRotationPitch) * var4;
|
||||
float var6 = par2EntityPlayer.prevRotationYaw + (par2EntityPlayer.rotationYaw - par2EntityPlayer.prevRotationYaw) * var4;
|
||||
double var7 = par2EntityPlayer.prevPosX + (par2EntityPlayer.posX - par2EntityPlayer.prevPosX) * (double)var4;
|
||||
double var9 = par2EntityPlayer.prevPosY + (par2EntityPlayer.posY - par2EntityPlayer.prevPosY) * (double)var4 + 1.62D - (double)par2EntityPlayer.yOffset;
|
||||
double var11 = par2EntityPlayer.prevPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.prevPosZ) * (double)var4;
|
||||
Vec3 var13 = par1World.getWorldVec3Pool().getVecFromPool(var7, var9, var11);
|
||||
float var14 = MathHelper.cos(-var6 * 0.017453292F - (float)Math.PI);
|
||||
float var15 = MathHelper.sin(-var6 * 0.017453292F - (float)Math.PI);
|
||||
float var16 = -MathHelper.cos(-var5 * 0.017453292F);
|
||||
float var17 = MathHelper.sin(-var5 * 0.017453292F);
|
||||
float var18 = var15 * var16;
|
||||
float var20 = var14 * var16;
|
||||
double var21 = 5.0D;
|
||||
if (par2EntityPlayer instanceof EntityPlayerMP)
|
||||
{
|
||||
var21 = 4;
|
||||
}
|
||||
Vec3 var23 = var13.addVector((double)var18 * var21, (double)var17 * var21, (double)var20 * var21);
|
||||
return par1World.rayTraceBlocks_do_do(var13, var23, true, false);
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
Boolean didFindThing=false;
|
||||
MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(par3EntityPlayer.worldObj, par3EntityPlayer, false );
|
||||
if(hit!=null&&!par2World.isRemote)
|
||||
{
|
||||
if(par2World.getBlockId(hit.blockX, hit.blockY, hit.blockZ)==mod_pocketDim.blockRiftID)
|
||||
{
|
||||
LinkData link = dimHelper.instance.getLinkDataFromCoords(hit.blockX, hit.blockY, hit.blockZ, par2World);
|
||||
if(link!=null)
|
||||
{
|
||||
Block var11;
|
||||
if(par1ItemStack.getItem() instanceof itemExitDoor )
|
||||
{
|
||||
var11 = mod_pocketDim.ExitDoor;
|
||||
}
|
||||
|
||||
else if(par1ItemStack.getItem() instanceof ItemChaosDoor )
|
||||
{
|
||||
var11 = mod_pocketDim.chaosDoor;
|
||||
}
|
||||
else
|
||||
{
|
||||
var11 = mod_pocketDim.dimDoor;
|
||||
}
|
||||
|
||||
int par4 = hit.blockX;
|
||||
int par5 = hit.blockY-1;
|
||||
int par6 = hit.blockZ;
|
||||
int par7 = 0 ;
|
||||
|
||||
|
||||
|
||||
|
||||
if (par3EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par3EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack)&&!par2World.isRemote)
|
||||
{
|
||||
int var12 = MathHelper.floor_double((double)((par3EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
|
||||
System.out.println("Link orientation is " + link.linkOrientation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
|
||||
}
|
||||
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ public class itemDimDoor extends ItemDoor
|
||||
{
|
||||
int var12 = MathHelper.floor_double((double)((par2EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
|
||||
if (!var11.canPlaceBlockAt(par3World, par4, par5, par6)||!this.canPlace(par3World, par4, par5, par6, var12))
|
||||
if (!this.canPlace(par3World, par4, par5, par6, var12)||!this.canPlace(par3World, par4, par5+1, par6, var12))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -167,9 +167,9 @@ public class itemDimDoor extends ItemDoor
|
||||
{
|
||||
int var12 = MathHelper.floor_double((double)((par3EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
|
||||
if (!this.canPlace(par2World, par4, par5, par6, var12)||dimHelper.instance.getLinkDataFromCoords(par4, par5+1, par6, par2World)==null)
|
||||
if (!this.canPlace(par2World, par4, par5, par6, var12)||!this.canPlace(par2World, par4-1, par5, par6, var12)||dimHelper.instance.getLinkDataFromCoords(par4, par5+1, par6, par2World)==null)
|
||||
{
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -192,8 +192,27 @@ public class itemDimDoor extends ItemDoor
|
||||
|
||||
public boolean canPlace(World world,int i, int j, int k, int p)
|
||||
{
|
||||
int id = world.getBlockId(i, j, k);
|
||||
|
||||
return true;
|
||||
boolean flag = true;
|
||||
if(id==mod_pocketDim.blockDimWallID||id==mod_pocketDim.blockRiftID||id==mod_pocketDim.blockDimWallPermID)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if(id!=0)
|
||||
{
|
||||
if(!Block.blocksList[id].blockMaterial.isReplaceable())
|
||||
{
|
||||
|
||||
flag=false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return flag;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,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 cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -88,8 +89,12 @@ public class itemLinkSignature extends Item
|
||||
{
|
||||
offset = 1;
|
||||
}
|
||||
dimHelper.instance.createLink(par3World.provider.dimensionId, linkCoords[3], par4, par5+offset, par6, linkCoords[0], linkCoords[1], linkCoords[2]);
|
||||
dimHelper.instance.createLink(linkCoords[3], par3World.provider.dimensionId, linkCoords[0], linkCoords[1], linkCoords[2],par4, par5+offset, par6);
|
||||
int orientation = MathHelper.floor_double((double)((par2EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
|
||||
dimHelper.instance.createLink(par3World.provider.dimensionId, linkCoords[3], par4, par5+offset, par6, linkCoords[0], linkCoords[1], linkCoords[2],linkCoords[4]);
|
||||
dimHelper.instance.createLink(linkCoords[3], par3World.provider.dimensionId, linkCoords[0], linkCoords[1], linkCoords[2],par4, par5+offset, par6,orientation);
|
||||
|
||||
|
||||
|
||||
--par1ItemStack.stackSize;
|
||||
par2EntityPlayer.sendChatToPlayer("Rift Created");
|
||||
@@ -105,13 +110,15 @@ public class itemLinkSignature extends Item
|
||||
}
|
||||
else
|
||||
{
|
||||
int orientation = MathHelper.floor_double((double)((par2EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
|
||||
if(par3World.getBlockId(par4, par5, par6)==Block.snow.blockID)
|
||||
{
|
||||
offset = 1;
|
||||
}
|
||||
//otherwise, it creates the first half of the link. Next click will complete it.
|
||||
key= dimHelper.instance.createUniqueInterDimLinkKey();
|
||||
this.writeToNBT(par1ItemStack, par4, par5+offset, par6,par3World.provider.dimensionId);
|
||||
this.writeToNBT(par1ItemStack, par4, par5+offset, par6,par3World.provider.dimensionId,orientation);
|
||||
|
||||
|
||||
|
||||
@@ -159,7 +166,7 @@ public class itemLinkSignature extends Item
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToNBT(ItemStack itemStack,int x, int y, int z, int dimID)
|
||||
public void writeToNBT(ItemStack itemStack,int x, int y, int z, int dimID,int orientation)
|
||||
{
|
||||
NBTTagCompound tag;
|
||||
|
||||
@@ -178,6 +185,7 @@ public class itemLinkSignature extends Item
|
||||
tag.setInteger("linkZ", z);
|
||||
tag.setInteger("linkDimID", dimID);
|
||||
tag.setBoolean("isCreated", true);
|
||||
tag.setInteger("orientation", orientation);
|
||||
|
||||
itemStack.setTagCompound(tag);
|
||||
|
||||
@@ -203,6 +211,8 @@ public class itemLinkSignature extends Item
|
||||
linkCoords[1]=tag.getInteger("linkY");
|
||||
linkCoords[2]=tag.getInteger("linkZ");
|
||||
linkCoords[3]=tag.getInteger("linkDimID");
|
||||
linkCoords[4]=tag.getInteger("orientation");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user