mirror of
https://github.com/GTNewHorizons/MagicBees.git
synced 2026-11-12 08:17:29 +00:00
Merge my branch into the main one, initial work on the thaumic apiary
Might have messed something up. Not quite sure
This commit is contained in:
1 parent
33b0af6682
commit
016049ef67
12 files changed
+339
-37
No files matched your search
@@ -3,53 +3,112 @@ package magicbees.block;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import magicbees.client.gui.UIScreens;
|
||||
import magicbees.main.CommonProxy;
|
||||
import magicbees.main.MagicBees;
|
||||
import magicbees.main.utils.TabMagicBees;
|
||||
import magicbees.tileentity.TileEntityThaumicApiary;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class BlockThaumicApiary extends BlockContainer
|
||||
{
|
||||
public BlockThaumicApiary()
|
||||
{
|
||||
super(Material.wood);
|
||||
this.setCreativeTab(TabMagicBees.tabMagicBees);
|
||||
this.setBlockName("thaumicApiary");
|
||||
this.setHardness(1f);
|
||||
this.setResistance(1.5f);
|
||||
this.setHarvestLevel("axe", 0);
|
||||
}
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon[] icons;
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
boolean activate = false;
|
||||
public BlockThaumicApiary()
|
||||
{
|
||||
super(Material.wood);
|
||||
this.setCreativeTab(TabMagicBees.tabMagicBees);
|
||||
this.setBlockName("thaumicApiary");
|
||||
this.setHardness(1f);
|
||||
this.setResistance(1.5f);
|
||||
this.setHarvestLevel("axe", 0);
|
||||
}
|
||||
|
||||
if (!player.isSneaking())
|
||||
{
|
||||
player.openGui(MagicBees.object, UIScreens.THAUMIC_APIARY.ordinal(), world, x, y, z);
|
||||
activate = true;
|
||||
}
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9 )
|
||||
{
|
||||
boolean activate = false;
|
||||
|
||||
return activate;
|
||||
}
|
||||
if (!player.isSneaking())
|
||||
{
|
||||
player.openGui(MagicBees.object, UIScreens.THAUMIC_APIARY.ordinal(), world, x, y, z);
|
||||
activate = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister register)
|
||||
{
|
||||
return activate;
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta){
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_)
|
||||
{
|
||||
return new TileEntityThaumicApiary();
|
||||
}
|
||||
if (side == 0){
|
||||
return icons[0];
|
||||
}else if (side == 1){
|
||||
return icons[1];
|
||||
}else if (side == 2 || side == 3){
|
||||
return icons[2];
|
||||
}else{
|
||||
return icons[4];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister register)
|
||||
{
|
||||
icons = new IIcon[5];
|
||||
|
||||
icons[0] = register.registerIcon(CommonProxy.DOMAIN + ":thaumicapiary.0");
|
||||
icons[1] = register.registerIcon(CommonProxy.DOMAIN + ":thaumicapiary.1");
|
||||
icons[2] = register.registerIcon(CommonProxy.DOMAIN + ":thaumicapiary.2");
|
||||
icons[4] = register.registerIcon(CommonProxy.DOMAIN + ":thaumicapiary.4");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int metadata) {
|
||||
return new TileEntityThaumicApiary();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int meta){
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if (te != null && te instanceof IInventory){
|
||||
IInventory inventory = (IInventory)te;
|
||||
|
||||
for (int i = 0; i < inventory.getSizeInventory(); i++){
|
||||
ItemStack itemStack = inventory.getStackInSlotOnClosing(i);
|
||||
|
||||
if (itemStack != null){
|
||||
float spawnX = x + world.rand.nextFloat();
|
||||
float spawnY = y + world.rand.nextFloat();
|
||||
float spawnZ = z + world.rand.nextFloat();
|
||||
|
||||
EntityItem droppedItem = new EntityItem(world, spawnX, spawnY, spawnZ, itemStack);
|
||||
|
||||
float mult = 0.05F;
|
||||
|
||||
droppedItem.motionX = (-0.5F + world.rand.nextFloat()) * mult;
|
||||
droppedItem.motionY = (4 + world.rand.nextFloat()) * mult;
|
||||
droppedItem.motionZ = (-0.5F + world.rand.nextFloat()) * mult;
|
||||
|
||||
world.spawnEntityInWorld(droppedItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.breakBlock(world, x, y, z, block, meta);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user