diff --git a/StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java b/StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java index a23dac62..c017fff0 100644 --- a/StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java +++ b/StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java @@ -4,6 +4,8 @@ import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; +import net.minecraft.block.BlockDoor; +import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.Entity; @@ -26,10 +28,14 @@ import StevenDimDoors.mod_pocketDim.tileentities.TileEntityDimDoor; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public abstract class BaseDimDoor extends BlockContainer implements IDimDoor +public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEntityProvider { protected final DDProperties properties; private Icon blockIconBottom; + protected boolean isBlockContainer=true; + private boolean isTileProvider = true; + + public BaseDimDoor(int blockID, Material material, DDProperties properties) { @@ -43,6 +49,18 @@ public abstract class BaseDimDoor extends BlockContainer implements IDimDoor this.blockIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()+"_top"); this.blockIconBottom = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2()+"_bottom"); } + + @SideOnly(Side.CLIENT) + + /** + * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata + */ + public Icon getIcon(int par1, int par2) + { + return this.blockIcon; + } + + @Override public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) @@ -116,34 +134,6 @@ public abstract class BaseDimDoor extends BlockContainer implements IDimDoor } - /** - * A function to open a door. - */ - public void onPoweredBlockChange(World par1World, int par2, int par3, int par4, boolean par5) - { - int var6 = this.getFullMetadata(par1World, par2, par3, par4); - boolean var7 = (var6 & 4) != 0; - - if (var7 != par5) - { - int var8 = var6 & 7; - var8 ^= 4; - - if ((var6 & 8) == 0) - { - par1World.setBlockMetadataWithNotify(par2, par3, par4, var8,2); - par1World.markBlockRangeForRenderUpdate(par2, par3, par4, par2, par3, par4); - } - else - { - par1World.setBlockMetadataWithNotify(par2, par3 - 1, par4, var8,2); - par1World.markBlockRangeForRenderUpdate(par2, par3 - 1, par4, par2, par3, par4); - } - - par1World.playAuxSFXAtEntity((EntityPlayer)null, 1003, par2, par3, par4, 0); - } - } - @Override public void onBlockAdded(World world, int x, int y, int z) { @@ -195,82 +185,6 @@ public abstract class BaseDimDoor extends BlockContainer implements IDimDoor tile.openOrClosed = this.isDoorOpen( par1World, par2, par3, par4); tile.orientation = this.getFullMetadata(par1World, par2, par3, par4) & 7; } - - public boolean isDoorOpen(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) - { - return (this.getFullMetadata(par1IBlockAccess, par2, par3, par4) & 4) != 0; - } - - @Override - public boolean isOpaqueCube() - { - return false; - } - - @Override - public boolean getBlocksMovement(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) - { - int var5 = this.getFullMetadata(par1IBlockAccess, par2, par3, par4); - return (var5 & 4) != 0; - } - - /** - * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) - */ - @Override - public boolean renderAsNormalBlock() - { - return false; - } - - /** - * The type of render function that is called for this block - */ - @Override - public int getRenderType() - { - return 7; - } - - - /** - * Returns the bounding box of the wired rectangular prism to render. - */ - @Override - @SideOnly(Side.CLIENT) - public AxisAlignedBB getSelectedBoundingBoxFromPool(World par1World, int par2, int par3, int par4) - { - this.setBlockBoundsBasedOnState(par1World, par2, par3, par4); - return super.getSelectedBoundingBoxFromPool(par1World, par2, par3, par4); - } - - /** - * Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been - * cleared to be reused) - */ - public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) - { - this.setBlockBoundsBasedOnState(par1World, par2, par3, par4); - return super.getCollisionBoundingBoxFromPool(par1World, par2, par3, par4); - } - - /** - * Updates the blocks bounds based on its current state. Args: world, x, y, z - */ - @Override - public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) - { - this.setDoorRotation(this.getFullMetadata(par1IBlockAccess, par2, par3, par4)); - } - - /** - * Returns 0, 1, 2 or 3 depending on where the hinge is. - */ - public int getDoorOrientation(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) - { - return this.getFullMetadata(par1IBlockAccess, par2, par3, par4) & 3; - } - private void setDoorRotation(int par1) { float var2 = 0.1875F; @@ -353,14 +267,6 @@ public abstract class BaseDimDoor extends BlockContainer implements IDimDoor } } - /** - * Called when the block is clicked by a player. Args: x, y, z, entityPlayer - */ - @Override - public void onBlockClicked(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer) - { - // System.out.println(this.getFullMetadata(par1World, par2, par3, par4)%4); - } /** * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are @@ -425,61 +331,6 @@ public abstract class BaseDimDoor extends BlockContainer implements IDimDoor } } - /** - * Ray traces through the blocks collision from start vector to end vector returning a ray trace hit. Args: world, - * x, y, z, startVec, endVec - */ - @Override - public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3) - { - this.setBlockBoundsBasedOnState(par1World, par2, par3, par4); - return super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3); - } - - /** - * Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z - */ - @Override - public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) - { - return par3 >= 255 ? false : par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) && super.canPlaceBlockAt(par1World, par2, par3, par4) && super.canPlaceBlockAt(par1World, par2, par3 + 1, par4); - } - - /** - * Returns the mobility information of the block, 0 = free, 1 = can't push but can move over, 2 = total immobility - * and stop pistons - */ - @Override - public int getMobilityFlag() - { - return 2; - } - - /** - * Returns the full metadata value created by combining the metadata of both blocks the door takes up. - */ - public int getFullMetadata(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) - { - int var5 = par1IBlockAccess.getBlockMetadata(par2, par3, par4); - boolean var6 = (var5 & 8) != 0; - int var7; - int var8; - - if (var6) - { - var7 = par1IBlockAccess.getBlockMetadata(par2, par3 - 1, par4); - var8 = var5; - } - else - { - var7 = var5; - var8 = par1IBlockAccess.getBlockMetadata(par2, par3 + 1, par4); - } - - boolean var9 = (var8 & 1) != 0; - return var7 & 7 | (var6 ? 8 : 0) | (var9 ? 16 : 0); - } - /** * only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative) */