mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-27 23:33:00 +00:00
71 lines
2.4 KiB
Java
71 lines
2.4 KiB
Java
/*******************************************************************************
|
|
* Copyright (c) 2011-2014 SirSengir.
|
|
* All rights reserved. This program and the accompanying materials
|
|
* are made available under the terms of the GNU Lesser Public License v3
|
|
* which accompanies this distribution, and is available at
|
|
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
|
*
|
|
* Various Contributors including, but not limited to:
|
|
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
|
******************************************************************************/
|
|
package forestry.apiculture.flowers;
|
|
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.block.BlockFlowerPot;
|
|
import net.minecraft.tileentity.TileEntity;
|
|
import net.minecraft.tileentity.TileEntityFlowerPot;
|
|
import net.minecraft.world.World;
|
|
|
|
import forestry.api.apiculture.FlowerManager;
|
|
import forestry.api.genetics.IFlowerGrowthRule;
|
|
import forestry.api.genetics.IFlowerRegistry;
|
|
import forestry.api.genetics.IIndividual;
|
|
|
|
public class VanillaFlowerPotGrowthRule implements IFlowerGrowthRule {
|
|
|
|
@Override
|
|
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
|
|
|
|
TileEntity tile = world.getTileEntity(x, y, z);
|
|
if (!(tile instanceof TileEntityFlowerPot)) {
|
|
return false;
|
|
}
|
|
|
|
TileEntityFlowerPot flowerPotTile = (TileEntityFlowerPot) tile;
|
|
if (flowerPotTile.getFlowerPotItem() != null) {
|
|
return false;
|
|
}
|
|
|
|
Block block = world.getBlock(x, y, z);
|
|
if (!(block instanceof BlockFlowerPot)) {
|
|
return false;
|
|
}
|
|
|
|
BlockFlowerPot flowerPot = (BlockFlowerPot) block;
|
|
|
|
int flower;
|
|
if (flowerType.equals(FlowerManager.FlowerTypeVanilla) || flowerType.equals(FlowerManager.FlowerTypeSnow)) {
|
|
flower = world.rand.nextInt(2) + 1;
|
|
} else if (flowerType.equals(FlowerManager.FlowerTypeJungle)) {
|
|
flower = 6;
|
|
} else if (flowerType.equals(FlowerManager.FlowerTypeCacti)) {
|
|
flower = world.rand.nextInt(2) + 9;
|
|
} else if (flowerType.equals(FlowerManager.FlowerTypeMushrooms)) {
|
|
flower = world.rand.nextInt(2) + 7;
|
|
} else {
|
|
return false;
|
|
}
|
|
|
|
TileEntityFlowerPot newTile = (TileEntityFlowerPot) flowerPot.createNewTileEntity(world, flower);
|
|
|
|
flowerPotTile.func_145964_a(newTile.getFlowerPotItem(), newTile.getFlowerPotData());
|
|
flowerPotTile.markDirty();
|
|
|
|
if (!world.setBlockMetadataWithNotify(x, y, z, 1, 2)) {
|
|
world.markBlockForUpdate(x, y, z);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|