DimDoors/StevenDimDoors/mod_pocketDim/blocks/dimHatch.java
2013-06-10 17:03:52 -04:00

79 lines
No EOL
2.8 KiB
Java

package StevenDimDoors.mod_pocketDim.blocks;
import StevenDimDoors.mod_pocketDim.DimData;
import StevenDimDoors.mod_pocketDim.LinkData;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
import StevenDimDoors.mod_pocketDim.world.pocketProvider;
import net.minecraft.block.BlockTrapDoor;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
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.util.MathHelper;
import net.minecraft.world.World;
public class dimHatch extends BlockTrapDoor
{
public dimHatch(int par1,int par2, Material par2Material)
{
super(par1, Material.iron);
this.setCreativeTab(CreativeTabs.tabTransport);
// this.setTextureFile("/PocketBlockTextures.png");
// this.blockIndexInTexture = 16;
}
public void registerIcons(IconRegister par1IconRegister)
{
this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2());
}
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
{
{
int var10 = par1World.getBlockMetadata(par2, par3, par4);
par1World.setBlockMetadataWithNotify(par2, par3, par4, var10 ^ 4,2);
par1World.playAuxSFXAtEntity(par5EntityPlayer, 1003, par2, par3, par4, 0);
return true;
}
}
//Teleports the player to the exit link of that dimension, assuming it is a pocket
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity)
{
int num = par1World.getBlockMetadata(par2, par3, par4);
if(!par1World.isRemote&&(num>3&&num<8||num>11)&&par1World.provider instanceof pocketProvider)
{
this.onPoweredBlockChange(par1World, par2, par3, par4, false);
DimData dimData = (DimData) dimHelper.instance.dimList.get(par1World.provider.dimensionId);
LinkData exitLink=dimData.exitDimLink;
exitLink.locDimID=par1World.provider.dimensionId;
dimHelper.instance.teleportToPocket(par1World, exitLink, par5Entity);
}
}
public void onPoweredBlockChange(World par1World, int par2, int par3, int par4, boolean par5)
{
int var6 = par1World.getBlockMetadata(par2, par3, par4);
boolean var7 = (var6 & 4) > 0;
if (var7 != par5)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, var6 ^ 4,2);
par1World.playAuxSFXAtEntity((EntityPlayer)null, 1003, par2, par3, par4, 0);
}
}
}