Search in sources :

Example 1 with BlockAlveary

use of forestry.apiculture.gadgets.BlockAlveary in project ForestryMC by ForestryMC.

the class PluginApiculture method preInit.

@Override
public void preInit() {
    super.preInit();
    MinecraftForge.EVENT_BUS.register(this);
    ForestryBlock.apiculture.registerBlock(new BlockBase(Material.iron), ItemForestryBlock.class, "apiculture");
    ForestryBlock.apiculture.block().setCreativeTab(Tabs.tabApiculture);
    ForestryBlock.apiculture.block().setHarvestLevel("axe", 0);
    definitionApiary = ((BlockBase) ForestryBlock.apiculture.block()).addDefinition(new MachineDefinition(Defaults.DEFINITION_APIARY_META, "forestry.Apiary", TileApiary.class, ShapedRecipeCustom.createShapedRecipe(ForestryBlock.apiculture.getItemStack(1, Defaults.DEFINITION_APIARY_META), "XXX", "#C#", "###", 'X', "slabWood", '#', "plankWood", 'C', ForestryItem.impregnatedCasing)).setFaces(0, 1, 2, 2, 4, 4, 0, 7));
    definitionChest = ((BlockBase) ForestryBlock.apiculture.block()).addDefinition(new MachineDefinition(Defaults.DEFINITION_APIARISTCHEST_META, "forestry.ApiaristChest", TileApiaristChest.class, ShapedRecipeCustom.createShapedRecipe(ForestryBlock.apiculture.getItemStack(1, Defaults.DEFINITION_APIARISTCHEST_META), " # ", "XYX", "XXX", '#', Blocks.glass, 'X', "beeComb", 'Y', Blocks.chest)).setFaces(0, 1, 2, 3, 4, 4));
    definitionBeehouse = ((BlockBase) ForestryBlock.apiculture.block()).addDefinition(new MachineDefinition(Defaults.DEFINITION_BEEHOUSE_META, "forestry.Beehouse", TileBeehouse.class, ShapedRecipeCustom.createShapedRecipe(ForestryBlock.apiculture.getItemStack(1, Defaults.DEFINITION_BEEHOUSE_META), "XXX", "#C#", "###", 'X', "slabWood", '#', "plankWood", 'C', "beeComb")).setFaces(0, 1, 2, 2, 4, 4, 0, 7));
    definitionAnalyzer = ((BlockBase) ForestryBlock.core.block()).addDefinition(new MachineDefinition(Defaults.DEFINITION_ANALYZER_META, "forestry.Analyzer", TileAnalyzer.class, PluginApiculture.proxy.getRendererAnalyzer(Defaults.TEXTURE_PATH_BLOCKS + "/analyzer_")));
    ForestryBlock.beehives.registerBlock(new BlockBeehives(), ItemForestryBlock.class, "beehives");
    // Candles
    ForestryBlock.candle.registerBlock(new BlockCandle(), ItemCandleBlock.class, "candle");
    ForestryBlock.stump.registerBlock(new BlockStump(), ItemForestryBlock.class, "stump");
    // Alveary and Components
    ForestryBlock.alveary.registerBlock(new BlockAlveary(), ItemAlvearyBlock.class, "alveary");
    ForestryBlock.alveary.block().setHarvestLevel("axe", 0);
    // Add triggers
    if (PluginManager.Module.BUILDCRAFT_STATEMENTS.isEnabled()) {
        ApicultureTriggers.initialize();
    }
    if (Config.enableVillager) {
        // Register village components with the Structure registry.
        VillageHandlerApiculture.registerVillageComponents();
    }
    // Commands
    PluginCore.rootCommand.addChildCommand(new CommandBee());
}
Also used : TileApiaristChest(forestry.apiculture.gadgets.TileApiaristChest) TileBeehouse(forestry.apiculture.gadgets.TileBeehouse) BlockStump(forestry.apiculture.gadgets.BlockStump) BlockAlveary(forestry.apiculture.gadgets.BlockAlveary) MachineDefinition(forestry.core.gadgets.MachineDefinition) BlockBase(forestry.core.gadgets.BlockBase) BlockBeehives(forestry.apiculture.gadgets.BlockBeehives) BlockCandle(forestry.apiculture.gadgets.BlockCandle) TileApiary(forestry.apiculture.gadgets.TileApiary) CommandBee(forestry.apiculture.commands.CommandBee)

Example 2 with BlockAlveary

use of forestry.apiculture.gadgets.BlockAlveary in project ForestryMC by ForestryMC.

the class AlleleEffectRadioactive method doEffect.

@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
    World world = housing.getWorld();
    if (isHalted(storedData, housing)) {
        return storedData;
    }
    int[] areaAr = genome.getTerritory();
    Vect area = new Vect(areaAr[0] * 2, areaAr[1] * 2, areaAr[2] * 2);
    Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 2), -Math.round(area.z / 2));
    // Radioactivity hurts players and mobs
    Vect min = new Vect(housing.getXCoord() + offset.x, housing.getYCoord() + offset.y, housing.getZCoord() + offset.z);
    Vect max = new Vect(housing.getXCoord() + offset.x + area.x, housing.getYCoord() + offset.y + area.y, housing.getZCoord() + offset.z + area.z);
    AxisAlignedBB hurtBox = AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, max.y, max.z);
    @SuppressWarnings("rawtypes") List list = housing.getWorld().getEntitiesWithinAABB(EntityLivingBase.class, hurtBox);
    for (Object obj : list) {
        EntityLivingBase entity = (EntityLivingBase) obj;
        int damage = 8;
        // armor.
        if (entity instanceof EntityPlayer) {
            int count = ItemArmorApiarist.wearsItems((EntityPlayer) entity, getUID(), true);
            // Full set, no damage/effect
            if (count > 3) {
                continue;
            } else if (count > 2) {
                damage = 1;
            } else if (count > 1) {
                damage = 2;
            } else if (count > 0) {
                damage = 3;
            }
        }
        entity.attackEntityFrom(damageSourceBeeRadioactive, damage);
    }
    Random rand = housing.getWorld().rand;
    // Radioactivity destroys environment
    for (int i = 0; i < 20; i++) {
        Vect randomPos = new Vect(rand.nextInt(area.x), rand.nextInt(area.y), rand.nextInt(area.z));
        Vect posBlock = randomPos.add(new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord()));
        posBlock = posBlock.add(offset);
        if (posBlock.y <= 1 || posBlock.y >= housing.getWorld().getActualHeight()) {
            continue;
        }
        // Don't destroy ourself and blocks below us.
        if (posBlock.x == housing.getXCoord() && posBlock.z == housing.getZCoord() && posBlock.y <= housing.getYCoord()) {
            continue;
        }
        if (world.isAirBlock(posBlock.x, posBlock.y, posBlock.z)) {
            continue;
        }
        Block block = world.getBlock(posBlock.x, posBlock.y, posBlock.z);
        if (block instanceof BlockAlveary) {
            continue;
        }
        TileEntity tile = world.getTileEntity(posBlock.x, posBlock.y, posBlock.z);
        if (tile instanceof IBeeHousing) {
            continue;
        }
        if (tile instanceof TileAlveary) {
            continue;
        }
        if (block.getBlockHardness(world, posBlock.x, posBlock.y, posBlock.z) < 0) {
            continue;
        }
        world.setBlockToAir(posBlock.x, posBlock.y, posBlock.z);
        break;
    }
    return storedData;
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) BlockAlveary(forestry.apiculture.gadgets.BlockAlveary) Vect(forestry.core.vect.Vect) IBeeHousing(forestry.api.apiculture.IBeeHousing) World(net.minecraft.world.World) TileAlveary(forestry.apiculture.gadgets.TileAlveary) TileEntity(net.minecraft.tileentity.TileEntity) Random(java.util.Random) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Block(net.minecraft.block.Block) List(java.util.List)

Aggregations

BlockAlveary (forestry.apiculture.gadgets.BlockAlveary)2 IBeeHousing (forestry.api.apiculture.IBeeHousing)1 CommandBee (forestry.apiculture.commands.CommandBee)1 BlockBeehives (forestry.apiculture.gadgets.BlockBeehives)1 BlockCandle (forestry.apiculture.gadgets.BlockCandle)1 BlockStump (forestry.apiculture.gadgets.BlockStump)1 TileAlveary (forestry.apiculture.gadgets.TileAlveary)1 TileApiaristChest (forestry.apiculture.gadgets.TileApiaristChest)1 TileApiary (forestry.apiculture.gadgets.TileApiary)1 TileBeehouse (forestry.apiculture.gadgets.TileBeehouse)1 BlockBase (forestry.core.gadgets.BlockBase)1 MachineDefinition (forestry.core.gadgets.MachineDefinition)1 Vect (forestry.core.vect.Vect)1 List (java.util.List)1 Random (java.util.Random)1 Block (net.minecraft.block.Block)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 TileEntity (net.minecraft.tileentity.TileEntity)1 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)1