Created
December 28, 2013 11:55
-
-
Save hanetzer/8158663 to your computer and use it in GitHub Desktop.
BlockLaptop.java
This file contains hidden or 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 netz.mods.cpc.block; | |
import java.util.List; | |
import java.util.Random; | |
import net.minecraft.block.Block; | |
import net.minecraft.block.BlockContainer; | |
import net.minecraft.block.material.Material; | |
import net.minecraft.entity.Entity; | |
import net.minecraft.entity.EntityLiving; | |
import net.minecraft.entity.player.EntityPlayer; | |
import net.minecraft.tileentity.TileEntity; | |
import net.minecraft.util.AxisAlignedBB; | |
import net.minecraft.util.MathHelper; | |
import net.minecraft.world.IBlockAccess; | |
import net.minecraft.world.World; | |
import netz.mods.cpc.CPC; | |
import netz.mods.cpc.tileentity.TileEntityLaptop; | |
public class BlockLaptop extends BlockContainer { | |
public BlockLaptop(int par1) { | |
super(par1, Material.iron); | |
this.setCreativeTab(CPC.tabCPC); | |
this.setTextureName("cpc:laptop"); | |
this.setUnlocalizedName("computer"); | |
} | |
public int idDropped(int par1, Random par2Random, int par3) { | |
return CPCBlock.laptop.blockID; | |
} | |
public int quantityDropped(Random random) { | |
return 1; | |
} | |
public AxisAlignedBB getSelectedBoundingBoxFromPool_do(World world, int i, int j, int k) { | |
int l = world.getBlockMetadata(i, j, k); | |
if (l == 0) { | |
this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.98F, 0.9F, 1.0F); | |
} | |
if (l == 1) { | |
this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.98F, 0.9F, 1.0F); | |
} | |
if (l == 2) { | |
this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.98F, 0.9F, 1.0F); | |
} | |
if (l == 3) { | |
this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.98F, 0.9F, 1.0F); | |
} | |
return super.getSelectedBoundingBoxFromPool(world, i, j, k); | |
} | |
public void setBlockBoundsBasedOnState(IBlockAccess world, int i, int j, int k) { | |
int l = world.getBlockMetadata(i, j, k); | |
if (l == 0) { | |
this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.98F, 0.9F, 1.0F); | |
} | |
if (l == 1) { | |
this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.98F, 0.9F, 1.0F); | |
} | |
if (l == 2) { | |
this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.98F, 0.9F, 1.0F); | |
} | |
if (l == 3) { | |
this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.98F, 0.9F, 1.0F); | |
} | |
} | |
@SuppressWarnings("rawtypes") | |
public void addCollidingBlockToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6ArrayList, Entity par7Entity) { | |
int i = par1World.getBlockMetadata(par2, par3, par4); | |
if (i == 0) { | |
this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.98F, 0.9F, 1.0F); | |
} | |
if (i == 1) { | |
this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.98F, 0.9F, 1.0F); | |
} | |
if (i == 2) { | |
this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.98F, 0.9F, 1.0F); | |
} | |
if (i == 3) { | |
this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.98F, 0.9F, 1.0F); | |
} | |
} | |
public int getRenderType() { | |
return -1; | |
} | |
public boolean isOpaqueCube() { | |
return false; | |
} | |
public boolean renderAsNormalBlock() { | |
return false; | |
} | |
public void onBlockAdded(World par1World, int par2, int par3, int par4) { | |
super.onBlockAdded(par1World, par2, par3, par4); | |
//this.setDefaultDirection(par1World, par2, par3, par4); | |
} | |
/*private void setDefaultDirection(World par1World, int par2, int par3, int par4) { | |
if (!par1World.isRemote) { | |
int i = par1World.getBlockId(par2, par3, par4 - 1); | |
int j = par1World.getBlockId(par2, par3, par4 + 1); | |
int k = par1World.getBlockId(par2 - 1, par3, par4); | |
int l = par1World.getBlockId(par2 + 1, par3, par4); | |
byte byte0 = 3; | |
if (Block.opaqueCubeLookup[i] && !Block.opaqueCubeLookup[j]) { | |
byte0 = 3; | |
} | |
if (Block.opaqueCubeLookup[j] && !Block.opaqueCubeLookup[i]) { | |
byte0 = 2; | |
} | |
if (Block.opaqueCubeLookup[k] && !Block.opaqueCubeLookup[l]) { | |
byte0 = 5; | |
} | |
if (Block.opaqueCubeLookup[l] && !Block.opaqueCubeLookup[k]) { | |
byte0 = 4; | |
} | |
par1World.setBlockMetadataWithNotify(par2, par3, par4, byte0, 2); | |
} | |
}*/ | |
public void breakBlock(World var1, int var2, int var3, int var4, int par5EntityPlayer, int par6i) { | |
var1.removeBlockTileEntity(var2, var3, var4); | |
super.breakBlock(var1, var2, var3, var4, par5EntityPlayer, par6i); | |
} | |
@Override | |
public boolean onBlockActivated(World world, int par2x, int par3y, int par4z, EntityPlayer par5EntityPlayer, int par6i, float par7a, float par8b, float par9c) { | |
if (world.blockHasTileEntity(par2x, par3y, par4z) && !par5EntityPlayer.isSneaking() && world.isRemote) { | |
par5EntityPlayer.openGui(CPC.instance, 0, world, par2x, par3y, par4z); | |
return true; | |
} | |
return false; | |
} | |
public TileEntity createNewTileEntity(World var1) { | |
return new TileEntityLaptop(); | |
} | |
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving) { | |
int par6i = MathHelper.floor_double((double) (par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3; | |
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6i, 2); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment