use of pneumaticCraft.common.block.pneumaticPlants.BlockPneumaticPlantBase in project PneumaticCraft by MineMaarten.
the class ItemPlasticPlants method onItemRightClick.
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
BlockPneumaticPlantBase plant = (BlockPneumaticPlantBase) getPlantBlockIDFromSeed(stack.getItemDamage());
if (plant == Blockss.squidPlant) {
MovingObjectPosition mop = getMovingObjectPositionFromPlayer(world, player, true);
if (mop != null) {
int x = mop.blockX;
int y = mop.blockY;
int z = mop.blockZ;
if (player.canPlayerEdit(x, y, z, 1, stack) && player.canPlayerEdit(x, y + 1, z, 1, stack)) {
if (plant.canBlockStay(world, x, y + 1, z) && world.isAirBlock(x, y + 1, z)) {
stack.stackSize--;
world.setBlock(x, y + 1, z, Blockss.squidPlant, 7, 3);
}
}
}
}
return stack;
}
use of pneumaticCraft.common.block.pneumaticPlants.BlockPneumaticPlantBase in project PneumaticCraft by MineMaarten.
the class ModuleAirGrate method checkForPlantsAndFarm.
private void checkForPlantsAndFarm(World worldObj, int x, int y, int z, int plantCheckRange) {
if (grateRange > 0 && worldObj.getTotalWorldTime() % 5 == 0) {
if (plantCheckX < x - plantCheckRange || plantCheckZ < z - plantCheckRange) {
plantCheckX = x - plantCheckRange;
plantCheckZ = z - plantCheckRange;
}
if (plantCheckX != x || plantCheckZ != z) {
// we know that we're no plant, avoid getBlock
Block b = worldObj.getBlock(plantCheckX, y, plantCheckZ);
NetworkHandler.sendToAllAround(new PacketSpawnParticle("reddust", plantCheckX + 0.5, y + 0.5, plantCheckZ + 0.5, 0, 0, 0), worldObj);
if (b instanceof BlockPneumaticPlantBase) {
((BlockPneumaticPlantBase) b).attemptFarmByAirGrate(worldObj, plantCheckX, y, plantCheckZ);
}
}
if (plantCheckZ++ >= z + plantCheckRange) {
plantCheckZ = z - plantCheckRange;
if (plantCheckX++ >= x + plantCheckRange) {
plantCheckX = x - plantCheckRange;
}
}
}
}
Aggregations