2013-02-18 03:46:16 +01:00
|
|
|
package StevenDimDoors.mod_pocketDim;
|
|
|
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
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.entity.Entity;
|
|
|
|
import net.minecraft.util.AxisAlignedBB;
|
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;
|
|
|
|
import net.minecraft.world.IBlockAccess;
|
|
|
|
import net.minecraft.world.World;
|
2013-08-29 08:14:24 +02:00
|
|
|
import StevenDimDoors.mod_pocketDim.blocks.ExitDoor;
|
|
|
|
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
|
|
|
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
2013-02-18 03:46:16 +01:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
|
|
|
public class TransientDoor extends ExitDoor
|
|
|
|
{
|
2013-08-29 08:14:24 +02:00
|
|
|
|
2013-02-18 03:46:16 +01:00
|
|
|
protected TransientDoor(int par1, Material material)
|
|
|
|
{
|
2013-03-22 05:58:55 +01:00
|
|
|
super(par1, Material.grass);
|
2013-08-29 08:14:24 +02:00
|
|
|
// this.blockIndexInTexture = 18;
|
2013-02-18 03:46:16 +01:00
|
|
|
|
2013-06-14 01:01:54 +02:00
|
|
|
if (properties == null)
|
|
|
|
properties = DDProperties.instance();
|
2013-02-18 03:46:16 +01:00
|
|
|
}
|
2013-08-29 08:14:24 +02:00
|
|
|
|
2013-06-14 01:01:54 +02:00
|
|
|
private static DDProperties properties = null;
|
2013-08-29 08:14:24 +02:00
|
|
|
|
2013-03-29 23:19:27 +01:00
|
|
|
public void registerIcons(IconRegister par1IconRegister)
|
2013-08-29 08:14:24 +02:00
|
|
|
{
|
|
|
|
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()+"_top");
|
2013-03-29 23:19:27 +01:00
|
|
|
|
2013-08-29 08:14:24 +02:00
|
|
|
}
|
2013-03-29 23:19:27 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
|
2013-08-29 08:14:24 +02:00
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
{
|
|
|
|
|
|
|
|
return this.blockIcon;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
public boolean isCollidable()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void onBlockAdded(World par1World, int par2, int par3, int par4)
|
|
|
|
{
|
|
|
|
super.onBlockAdded(par1World, par2, par3, par4);
|
|
|
|
this.updateAttachedTile(par1World, par2, par3, par4);
|
|
|
|
}
|
|
|
|
|
|
|
|
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
2013-02-18 03:46:16 +01:00
|
|
|
|
|
|
|
@Override
|
2013-08-29 08:14:24 +02:00
|
|
|
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
|
|
|
|
{
|
|
|
|
//TODO: Would it kill us to use REASONABLE variable names? <_< ~SenseiKiwi
|
|
|
|
int var12 = (int) (MathHelper.floor_double((double) ((entity.rotationYaw + 90) * 4.0F / 360.0F) + 0.5D) & 3);
|
|
|
|
|
|
|
|
int orientation = world.getBlockMetadata(x, y - 1, z);
|
|
|
|
if (!world.isRemote && (orientation >= 4 && orientation <= 7) && (orientation - 4) == var12 &&
|
|
|
|
world.getBlockId(x, y - 1, z) == this.blockID)
|
|
|
|
{
|
|
|
|
this.onPoweredBlockChange(world, x, y, z, false);
|
|
|
|
|
|
|
|
IDimLink link = PocketManager.getLink(x, y, z, world.provider.dimensionId);
|
|
|
|
if (link != null)
|
2013-02-18 03:46:16 +01:00
|
|
|
{
|
2013-08-31 13:39:52 +02:00
|
|
|
DDTeleporter.traverseDimDoor(world, link, entity);
|
|
|
|
//Turn the transient door into a rift AFTER teleporting the entity.
|
|
|
|
//The door's orientation may be needed for generating a room at the link's destination.
|
2013-08-29 08:14:24 +02:00
|
|
|
world.setBlock(x, y, z, properties.RiftBlockID);
|
|
|
|
world.setBlockToAir(x, y - 1, z);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-03-22 05:58:55 +01:00
|
|
|
|
2013-08-29 08:14:24 +02:00
|
|
|
public int idPicked(World par1World, int par2, int par3, int par4)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2013-02-18 03:46:16 +01:00
|
|
|
|
2013-08-29 08:14:24 +02:00
|
|
|
public int idDropped(int par1, Random par2Random, int par3)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2013-02-18 03:46:16 +01:00
|
|
|
|
2013-08-29 08:14:24 +02:00
|
|
|
public int getRenderType()
|
|
|
|
{
|
|
|
|
return 8;
|
|
|
|
}
|
2013-02-18 03:46:16 +01:00
|
|
|
}
|