redid orientation handling, works better now.
Vastly improved y level detection for teleports
This commit is contained in:
@@ -148,70 +148,51 @@ public class ItemRiftBlade extends itemDimDoor
|
||||
|
||||
public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4)
|
||||
{
|
||||
|
||||
|
||||
if(dimHelper.dimList.get(par2World.provider.dimensionId)!=null&&!par2World.isRemote)
|
||||
{
|
||||
|
||||
if(this.getMaxItemUseDuration(par1ItemStack)-par4>12)
|
||||
{
|
||||
|
||||
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);
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Vec3 var2 = par3EntityPlayer.getLook(1.0F);
|
||||
|
||||
|
||||
|
||||
|
||||
placeDoorBlock(par2World, x, y-1, z, rotation, mod_pocketDim.transientDoor);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
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);
|
||||
|
||||
|
||||
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(dimHelper.dimList.get(par2World.provider.dimensionId)!=null)
|
||||
{
|
||||
if(dimHelper.dimList.get(par2World.provider.dimensionId).depth==0)
|
||||
{
|
||||
dimHelper.instance.createPocket(link,true, false);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
dimHelper.instance.createPocket(link,true, false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
placeDoorBlock(par2World, x, y-1, z, rotation, mod_pocketDim.transientDoor);
|
||||
|
||||
}
|
||||
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