2013-04-17 02:48:49 +02:00
|
|
|
package StevenDimDoors.mod_pocketDim.blocks;
|
2013-02-18 03:46:16 +01:00
|
|
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
2013-04-17 02:48:49 +02:00
|
|
|
import StevenDimDoors.mod_pocketDim.DimData;
|
|
|
|
import StevenDimDoors.mod_pocketDim.LinkData;
|
|
|
|
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
2013-06-10 23:03:52 +02:00
|
|
|
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
2013-05-04 01:34:01 +02:00
|
|
|
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
2013-04-17 02:48:49 +02:00
|
|
|
|
2013-03-29 23:19:27 +01:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-02-18 03:46:16 +01:00
|
|
|
import net.minecraft.block.material.Material;
|
2013-03-29 23:19:27 +01:00
|
|
|
import net.minecraft.client.renderer.texture.IconRegister;
|
2013-02-18 03:46:16 +01:00
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
|
|
|
import net.minecraft.item.Item;
|
2013-03-29 23:19:27 +01:00
|
|
|
import net.minecraft.util.Icon;
|
2013-02-18 03:46:16 +01:00
|
|
|
import net.minecraft.util.MathHelper;
|
2013-03-29 23:19:27 +01:00
|
|
|
import net.minecraft.world.IBlockAccess;
|
2013-02-18 03:46:16 +01:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
|
|
|
public class ExitDoor extends dimDoor
|
|
|
|
{
|
|
|
|
|
2013-03-29 23:19:27 +01:00
|
|
|
private Icon blockIconBottom;
|
2013-04-17 02:48:49 +02:00
|
|
|
public ExitDoor(int par1, Material par2Material)
|
2013-02-18 03:46:16 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
super(par1, Material.wood);
|
|
|
|
// this.blockIndexInTexture = 19;
|
2013-03-29 23:19:27 +01:00
|
|
|
|
2013-02-18 03:46:16 +01:00
|
|
|
|
|
|
|
// TODO Auto-generated constructor stub
|
|
|
|
}
|
2013-03-29 23:19:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
public void registerIcons(IconRegister par1IconRegister)
|
|
|
|
{
|
|
|
|
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()+"_top");
|
|
|
|
this.blockIconBottom = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()+"_bottom");
|
|
|
|
|
|
|
|
}
|
2013-02-18 03:46:16 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onBlockAdded(World par1World, int par2, int par3, int par4)
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if(!par1World.isRemote&&par1World.getBlockId(par2, par3-1, par4)==this.blockID)
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
int locDimID=par1World.provider.dimensionId;
|
|
|
|
|
|
|
|
if(dimHelper.instance.dimList.containsKey(locDimID)&&dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World)==null)
|
|
|
|
{
|
|
|
|
DimData dimData = dimHelper.dimList.get(locDimID);
|
|
|
|
int ExitDimID = dimData.exitDimLink.destDimID;
|
2013-06-04 14:52:06 +02:00
|
|
|
if(dimHelper.dimList.get(par1World.provider.dimensionId).isPocket)
|
|
|
|
{
|
|
|
|
int yCoord=yCoordHelper.getFirstUncovered(ExitDimID, par2, par3, 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)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2013-02-18 03:46:16 +01:00
|
|
|
|
|
|
|
if(dimHelper.instance.getDimDepth(locDimID)==1)
|
|
|
|
{
|
|
|
|
//System.out.println("exitToOverowrld from "+String.valueOf(locDimID));
|
|
|
|
|
2013-05-04 01:34:01 +02:00
|
|
|
int yCoord=yCoordHelper.getFirstUncovered(ExitDimID, par2, par3, par4);
|
|
|
|
|
2013-02-18 03:46:16 +01:00
|
|
|
|
2013-05-04 01:34:01 +02:00
|
|
|
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)));
|
2013-02-18 03:46:16 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
else if(dimHelper.dimList.get(par1World.provider.dimensionId).isPocket)
|
|
|
|
{
|
|
|
|
//System.out.println("Created new dim from "+String.valueOf(par1World.provider.dimensionId));
|
|
|
|
|
2013-05-04 01:34:01 +02:00
|
|
|
LinkData link = new LinkData(par1World.provider.dimensionId, 0, par2, par3, par4, par2, par3, par4, true, par1World.getBlockMetadata(par2, par3-1, par4));
|
2013-02-18 03:46:16 +01:00
|
|
|
dimHelper.instance.createPocket(link,false, false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// dimHelper.instance.generatePocket(dimHelper.getWorld(destDimID), par2, par3, par4,par1World.getBlockMetadata(par2, par3-1, par4));
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2013-06-04 14:52:06 +02:00
|
|
|
**/
|
2013-02-18 03:46:16 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
else if (dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World)!=null)
|
|
|
|
{
|
|
|
|
|
|
|
|
//System.out.println("RiftPresent at "+String.valueOf(par1World.provider.dimensionId));
|
|
|
|
dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World).linkOrientation=par1World.getBlockMetadata(par2, par3-1, par4);
|
2013-06-04 02:56:15 +02:00
|
|
|
dimHelper.instance.getLinkDataFromCoords(par2, par3, par4, par1World).hasGennedDoor=false;
|
|
|
|
|
2013-02-18 03:46:16 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//this.onPoweredBlockChange(par1World, par2, par3, par4, false);
|
|
|
|
|
|
|
|
}
|
2013-03-29 23:19:27 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
|
|
|
|
*/
|
|
|
|
public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
|
|
|
|
{
|
|
|
|
if(par1IBlockAccess.getBlockId(par2, par3-1, par4)==this.blockID)
|
|
|
|
{
|
|
|
|
return this.blockIcon;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return this.blockIconBottom;
|
|
|
|
}
|
|
|
|
}
|
2013-02-18 03:46:16 +01:00
|
|
|
|
|
|
|
public int idPicked(World par1World, int par2, int par3, int par4)
|
|
|
|
{
|
|
|
|
return Item.doorWood.itemID;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int idDropped(int par1, Random par2Random, int par3)
|
|
|
|
{
|
|
|
|
return (par1 & 8) != 0 ? 0 : (Item.doorWood.itemID);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|