Created
April 8, 2012 17:45
-
-
Save arilotter/2338712 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.minecraft.src; | |
import java.util.ArrayList; | |
import java.util.Random; | |
public class BlockChargeAltar extends Block { | |
public BlockChargeAltar(int i, int j) { | |
super(i, j, Material.rock); | |
} | |
/** | |
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata | |
*/ | |
public int getBlockTextureFromSideAndMetadata(int par1, int par2) | |
{ | |
if (par1 == 1) | |
{ | |
return mod_Aero.chargeAltarTopTexture; | |
} | |
if (par1 == 0) | |
{ | |
return mod_Aero.chargeAltarBottomTexture; | |
} | |
else | |
{ | |
return mod_Aero.chargeAltarSideTexture; | |
} | |
} | |
/** | |
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two | |
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. | |
*/ | |
public boolean isOpaqueCube() | |
{ | |
return false; | |
} | |
/** | |
* The type of render function that is called for this block | |
*/ | |
public int getRenderType() | |
{ | |
return mod_Aero.chargeAltarRenderID; | |
} | |
/** | |
* Sets the block's bounds for rendering it as an item | |
*/ | |
public void setBlockBoundsForItemRender() | |
{ | |
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.8125F, 1.0F); | |
} | |
/** | |
* Adds to the supplied array any colliding bounding boxes with the passed in bounding box. Args: world, x, y, z, | |
* axisAlignedBB, arrayList | |
*/ | |
public void getCollidingBoundingBoxes(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, ArrayList par6ArrayList) | |
{ | |
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.8125F, 1.0F); | |
super.getCollidingBoundingBoxes(par1World, par2, par3, par4, par5AxisAlignedBB, par6ArrayList); | |
int i = par1World.getBlockMetadata(par2, par3, par4); | |
if (isChargeInserted(i)) | |
{ | |
setBlockBounds(0.3125F, 0.8125F, 0.3125F, 0.6875F, 1.0F, 0.6875F); | |
super.getCollidingBoundingBoxes(par1World, par2, par3, par4, par5AxisAlignedBB, par6ArrayList); | |
} | |
setBlockBoundsForItemRender(); | |
} | |
/** | |
* checks if a charge has been inserted into the altar block. parameters: metadata | |
*/ | |
public static boolean isChargeInserted(int par0) | |
{ | |
return (par0 & 4) != 0; | |
} | |
/** | |
* Returns the ID of the items to drop on destruction. | |
*/ | |
public int idDropped(int par1, Random par2Random, int par3) | |
{ | |
return blockID; | |
} | |
/** | |
* Called when the block is placed in the world. | |
*/ | |
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving) | |
{ | |
int i = ((MathHelper.floor_double((double)((par5EntityLiving.rotationYaw * 4F) / 360F) + 0.5D) & 3) + 2) % 4; | |
par1World.setBlockMetadataWithNotify(par2, par3, par4, i); | |
} | |
public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer) | |
{ | |
if (world.getBlockId(i, j, k) == blockID && entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().itemID == mod_Aero.blankCharge.shiftedIndex) { | |
int l = world.getBlockMetadata(i, j, k); | |
world.setBlockMetadataWithNotify(i, j, k, l + 4); | |
world.notifyBlockChange(i, j, k, l); | |
return true; | |
} | |
return false; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.minecraft.src; | |
public class mod_Aero extends BaseMod { | |
public static Block chargeAltar; | |
public static int chargeAltarRenderID; | |
public static Item blankCharge; | |
public static Item lightningCharge; | |
public static int chargeAltarTopTexture; | |
public static int chargeAltarBottomTexture; | |
public static int chargeAltarSideTexture; | |
public mod_Aero() | |
{ | |
//Wat. | |
} | |
public boolean renderBlockChargeAltar(Block par1Block, int par2, int par3, int par4, RenderBlocks renderblocks, IBlockAccess iblockaccess) | |
{ | |
int i = iblockaccess.getBlockMetadata(par2, par3, par4); | |
int j = i & 3; | |
if (j == 0) | |
{ | |
renderblocks.uvRotateTop = 3; | |
} | |
else if (j == 3) | |
{ | |
renderblocks.uvRotateTop = 1; | |
} | |
else if (j == 1) | |
{ | |
renderblocks.uvRotateTop = 2; | |
} | |
renderblocks.overrideBlockTexture = chargeAltarTopTexture; | |
if (!BlockChargeAltar.isChargeInserted(i)) | |
{ | |
par1Block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.8125F, 1.0F); | |
renderblocks.renderStandardBlock(par1Block, par2, par3, par4); | |
par1Block.setBlockBoundsForItemRender(); | |
renderblocks.uvRotateTop = 0; | |
return true; | |
} | |
else | |
{ | |
par1Block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.8125F, 1.0F); | |
renderblocks.renderStandardBlock(par1Block, par2, par3, par4); | |
renderblocks.overrideBlockTexture = 172; | |
par1Block.setBlockBounds(0.25F, 0.8125F, 0.25F, 0.75F, 1.0F, 0.75F); | |
renderblocks.renderStandardBlock(par1Block, par2, par3, par4); | |
renderblocks.clearOverrideBlockTexture(); | |
par1Block.setBlockBoundsForItemRender(); | |
renderblocks.uvRotateTop = 0; | |
return true; | |
} | |
} | |
public String getVersion() | |
{ | |
return "INTERNAL ALPHA - DO NOT USE"; | |
} | |
public void load() { | |
//////////////////////////////////////////////////////// | |
//Charge Altar Textures///////////////////////////////// | |
//////////////////////////////////////////////////////// | |
chargeAltarTopTexture = ModLoader.addOverride("/terrain.png", "/aero/altartop.png"); | |
chargeAltarBottomTexture = ModLoader.addOverride("/terrain.png", "/aero/altarbottom.png"); | |
chargeAltarSideTexture = ModLoader.addOverride("/terrain.png", "/aero/altarside.png"); | |
//Charge Altar Main Code | |
chargeAltar = new BlockChargeAltar(150, 12).setHardness(2.0F).setResistance(5.0F).setBlockName("chargeAltar"); | |
ModLoader.registerBlock(chargeAltar); | |
ModLoader.addName(chargeAltar, "TEH ALTAR OF CHARGES"); | |
ModLoader.addRecipe(new ItemStack(chargeAltar, 1), new Object[] { | |
"#", '#', Block.dirt | |
}); | |
//Charge Altar RenderID | |
chargeAltarRenderID = ModLoader.getUniqueBlockModelID(this, false); | |
//////////////////////////////////////////////////////// | |
//////////////////////////////////////////////////////// | |
//Blank Charge Code///////////////////////////////////// | |
//////////////////////////////////////////////////////// | |
blankCharge = new ItemBlankCharge(2000).setItemName("blankCharge"); | |
blankCharge.iconIndex = ModLoader.addOverride("/gui/items.png", "/aero/blankcharge.png"); | |
ModLoader.addName(blankCharge, "Blank Charge"); | |
ModLoader.addRecipe(new ItemStack(blankCharge, 1), new Object[] { | |
"#", '#', Block.planks | |
}); | |
lightningCharge = new ItemLightningCharge(2001).setItemName("lightningCharge"); | |
lightningCharge.iconIndex = ModLoader.addOverride("/gui/items.png", "/aero/lightningcharge.png"); | |
ModLoader.addName(lightningCharge, "Lightning Charge"); | |
ModLoader.addRecipe(new ItemStack(lightningCharge, 1), new Object[] { | |
"##", '#', Block.dirt | |
}); | |
} | |
public boolean RenderWorldBlock(RenderBlocks renderblocks, IBlockAccess iblockaccess, int i, int j, int k, Block block, int l) | |
{ | |
if (l == chargeAltarRenderID) | |
{ | |
return renderBlockChargeAltar(block, i, j, k, renderblocks, iblockaccess); | |
} | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment