Search in sources :

Example 1 with BOPPlants

use of biomesoplenty.api.enums.BOPPlants in project BiomesOPlenty by Glitchfiend.

the class BlockBOPPlant method canBlockStay.

@Override
public boolean canBlockStay(World world, BlockPos pos, IBlockState state) {
    BOPPlants plant = ((BOPPlants) state.getValue(this.variantProperty));
    Block blockAbove = world.getBlockState(pos.up()).getBlock();
    switch(plant) {
        case DEADGRASS:
        case DESERTGRASS:
            return BlockQueries.litDry.matches(world, pos.down()) || BlockQueries.sustainsNether.matches(world, pos.down());
        case TINYCACTUS:
            return BlockQueries.litDry.matches(world, pos.down()) || BlockQueries.litFertile.matches(world, pos.down());
        case DESERTSPROUTS:
        case DUNEGRASS:
            return BlockQueries.litSand.matches(world, pos.down());
        case SPECTRALFERN:
            return BlockQueries.spectralMoss.matches(world, pos.down());
        case THORN:
            return BlockQueries.fertileOrNetherrack.matches(world, pos.down()) || BlockQueries.sustainsNether.matches(world, pos.down());
        case CATTAIL:
            return BlockQueries.litFertileWaterside.matches(world, pos.down());
        case RIVERCANE:
            // river cane can also be placed on top of itself
            return BlockQueries.litFertileWaterside.matches(world, pos.down()) || (world.getBlockState(pos.down()) == state);
        case DEVILWEED:
            return BlockQueries.fertile.matches(world, pos.down());
        case REED:
            return BlockQueries.suitableForReed.matches(world, pos.down());
        case ROOT:
            // roots hang down - check against block above
            return BlockQueries.fertile.matches(world, pos.up());
        case LEAFPILE:
        case DEADLEAFPILE:
            return BlockQueries.solid.matches(world, pos.down());
        default:
            return BlockQueries.litFertile.matches(world, pos.down());
    }
}
Also used : Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) BOPPlants(biomesoplenty.api.enums.BOPPlants)

Example 2 with BOPPlants

use of biomesoplenty.api.enums.BOPPlants in project BiomesOPlenty by Glitchfiend.

the class BlockBOPPlant method onEntityCollidedWithBlock.

@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
    switch((BOPPlants) state.getValue(this.variantProperty)) {
        case POISONIVY:
            // poison ivy poisons players who walk into it, unless they're wearing boots and pants
            if (entity instanceof EntityPlayer) {
                InventoryPlayer inventory = ((EntityPlayer) entity).inventory;
                if (inventory.armorInventory.get(0) != ItemStack.EMPTY && inventory.armorInventory.get(1) != ItemStack.EMPTY) {
                    break;
                }
                ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(MobEffects.POISON, 100));
            }
            break;
        case THORN:
        case TINYCACTUS:
            // thorns and tiny cacti damage players who walk into them, unless they're wearing boots and pants
            if (entity instanceof EntityPlayer) {
                InventoryPlayer inventory = ((EntityPlayer) entity).inventory;
                if (inventory.armorInventory.get(0) != ItemStack.EMPTY && inventory.armorInventory.get(1) != ItemStack.EMPTY) {
                    break;
                }
                entity.attackEntityFrom(DamageSource.CACTUS, 1);
            }
            break;
        default:
            break;
    }
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) PotionEffect(net.minecraft.potion.PotionEffect) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BOPPlants(biomesoplenty.api.enums.BOPPlants)

Example 3 with BOPPlants

use of biomesoplenty.api.enums.BOPPlants in project BiomesOPlenty by Glitchfiend.

the class BlockBOPPlant method isReplaceable.

@Override
public boolean isReplaceable(IBlockAccess world, BlockPos pos) {
    IBlockState state = world.getBlockState(pos);
    BOPPlants plant = (BOPPlants) state.getValue(this.variantProperty);
    switch(plant) {
        case THORN:
        case WILDRICE:
        case CATTAIL:
        case RIVERCANE:
        case TINYCACTUS:
        case RAFFLESIA:
            return false;
        default:
            return true;
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BOPPlants(biomesoplenty.api.enums.BOPPlants)

Example 4 with BOPPlants

use of biomesoplenty.api.enums.BOPPlants in project BiomesOPlenty by Glitchfiend.

the class BlockBOPPlant method getDrops.

// get the items dropped when you bash the bush
@Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
    Random rand = world instanceof World ? ((World) world).rand : RANDOM;
    // start with an empty stack
    List<ItemStack> ret = new java.util.ArrayList<ItemStack>();
    // add items based on the VARIANT
    BOPPlants plant = (BOPPlants) state.getValue(this.variantProperty);
    switch(plant) {
        case SHORTGRASS:
        case MEDIUMGRASS:
        case WHEATGRASS:
        case DAMPGRASS:
            if (rand.nextInt(8) == 0) {
                // 1 in 8 chance of getting a seed from this grass
                ret.add(ForgeHooks.getGrassSeed(rand, fortune));
            }
            break;
        case SPROUT:
            if (rand.nextInt(50) == 0) {
                // in in 50 chance of getting a carrot or potato from SPROUT
                ret.add(new ItemStack(rand.nextInt(2) == 0 ? Items.CARROT : Items.POTATO));
            }
            break;
        case KORU:
            if (rand.nextInt(64) == 0) {
                // 1 in 64 change of getting a turnip seed from KORU
                ret.add(new ItemStack(BOPItems.turnip_seeds));
            }
            break;
        case BERRYBUSH:
            // BERRYBUSH always drops berries
            ret.add(new ItemStack(BOPItems.berries));
            break;
        case WILDRICE:
            // wildrice drops itself only 1 in 5 times
            if (rand.nextInt(5) == 0) {
                ret.add(paging.getVariantItem(plant));
            }
            break;
        case CATTAIL:
        case RIVERCANE:
        case TINYCACTUS:
        case REED:
        case ROOT:
        case RAFFLESIA:
            // these variants drop themselves as items
            ret.add(paging.getVariantItem(plant));
            break;
        default:
            // the rest drop nothing
            break;
    }
    return ret;
}
Also used : Random(java.util.Random) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) BOPPlants(biomesoplenty.api.enums.BOPPlants)

Example 5 with BOPPlants

use of biomesoplenty.api.enums.BOPPlants in project BiomesOPlenty by Glitchfiend.

the class BlockBOPPlant method onSheared.

@Override
public List<ItemStack> onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) {
    // start with an empty stack
    List<ItemStack> ret = new java.util.ArrayList<ItemStack>();
    // add items based on the VARIANT
    BOPPlants plant = ((BOPPlants) world.getBlockState(pos).getValue(this.variantProperty));
    switch(plant) {
        case CATTAIL:
        case RIVERCANE:
        case TINYCACTUS:
        case REED:
        case ROOT:
            // these items drop themselves as items when the block is broken (from getDrops), so we don't want to add anything else for using shears
            break;
        case BERRYBUSH:
            // BERRYBUSH gives a regular bush when sheared (note this is in addition to the berry from getDrops)
            ret.add(paging.getVariantItem(BOPPlants.BUSH));
            // ret.add(new ItemStack(BOPItems.berries, 1));
            break;
        default:
            // for everything else, get the block as an item
            ret.add(paging.getVariantItem(plant));
            break;
    }
    return ret;
}
Also used : ItemStack(net.minecraft.item.ItemStack) BOPPlants(biomesoplenty.api.enums.BOPPlants)

Aggregations

BOPPlants (biomesoplenty.api.enums.BOPPlants)7 ItemStack (net.minecraft.item.ItemStack)4 IBlockState (net.minecraft.block.state.IBlockState)2 BlockBOPPlant (biomesoplenty.common.block.BlockBOPPlant)1 Random (java.util.Random)1 Block (net.minecraft.block.Block)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityItem (net.minecraft.entity.item.EntityItem)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 InventoryPlayer (net.minecraft.entity.player.InventoryPlayer)1 ItemBlock (net.minecraft.item.ItemBlock)1 PotionEffect (net.minecraft.potion.PotionEffect)1 ActionResult (net.minecraft.util.ActionResult)1 EnumActionResult (net.minecraft.util.EnumActionResult)1 BlockPos (net.minecraft.util.math.BlockPos)1 RayTraceResult (net.minecraft.util.math.RayTraceResult)1 World (net.minecraft.world.World)1 FakePlayer (net.minecraftforge.common.util.FakePlayer)1