Working on Flower Models and Update Forestry

This commit is contained in:
Nedelosk committed 2016-10-25 18:08:12 +02:00
1 parent 5171e33764
commit 7dba116937
57 files changed
+814 -727

No files matched your search

+2 -2
View File
@@ -13,7 +13,7 @@ import binnie.botany.core.BotanyCore;
import binnie.botany.core.BotanyGUI;
import binnie.botany.core.ModuleCore;
import binnie.botany.flower.BlockFlower;
import binnie.botany.flower.ItemFlower;
import binnie.botany.flower.ItemBotany;
import binnie.botany.flower.ItemInsulatedTube;
import binnie.botany.flower.TileEntityFlower;
import binnie.botany.gardening.*;
@@ -78,7 +78,7 @@ public class Botany extends AbstractMod {
public static ItemMisc misc;
public static ItemEncyclopedia encyclopedia;
public static ItemEncyclopedia encyclopediaIron;
public static ItemFlower flowerItem;
public static ItemBotany flowerItem;
public static ItemPigment pigment;
public static ItemClay clay;
public static BlockCeramic ceramic;
@@ -3,13 +3,14 @@ package binnie.botany.api;
import javax.annotation.Nonnull;
import forestry.api.core.IModelManager;
import forestry.api.genetics.IAlleleProperty;
import forestry.api.genetics.IAlleleSpecies;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public interface IAlleleFlowerSpecies extends IAlleleSpecies {
public interface IAlleleFlowerSpecies extends IAlleleSpecies, IAlleleProperty<IAlleleFlowerSpecies> {
IFlowerType getType();
EnumAcidity getPH();
@@ -21,7 +22,7 @@ public interface IAlleleFlowerSpecies extends IAlleleSpecies {
@SideOnly(Side.CLIENT)
@Nonnull
ModelResourceLocation getFlowerModel(EnumFlowerStage type);
ModelResourceLocation getFlowerModel(EnumFlowerStage type, boolean flowered, int section);
@SideOnly(Side.CLIENT)
void registerModels(Item item, IModelManager manager, EnumFlowerStage type);
@@ -8,21 +8,17 @@ import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
//import net.minecraft.util.IIcon;
public interface IFlowerType {
// IIcon getStem(final EnumFlowerStage p0, final boolean p1, final int p2);
//
// IIcon getPetalIcon(final EnumFlowerStage p0, final boolean p1, final int p2);
//
// IIcon getVariantIcon(final EnumFlowerStage p0, final boolean p1, final int p2);
public interface IFlowerType<I extends IFlowerType> extends Comparable<I> {
@SideOnly(Side.CLIENT)
void registerModels(Item item, IModelManager manager, EnumFlowerStage type);
@Nonnull
ModelResourceLocation getModel(EnumFlowerStage type);
@SideOnly(Side.CLIENT)
ModelResourceLocation getModel(EnumFlowerStage type, boolean flowered, int section);
String getName();
int getID();
int getSections();
@@ -11,9 +11,7 @@ import forestry.core.blocks.IColoredBlock;
import forestry.core.items.IColoredItem;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
@@ -40,7 +38,8 @@ public class BlockCeramic extends Block implements IBlockMetadata, IColoredBlock
this.setCreativeTab(CreativeTabBotany.instance);
}
@SideOnly(Side.CLIENT)
@Override
@SideOnly(Side.CLIENT)
public void registerModel(Item item, IModelManager manager) {
for (final EnumFlowerColor c : EnumFlowerColor.values()) {
manager.registerItemModel(item, c.ordinal());
@@ -7,7 +7,6 @@ import binnie.core.block.IBlockMetadata;
import binnie.core.block.TileEntityMetadata;
import binnie.extratrees.ExtraTrees;
import forestry.core.blocks.IColoredBlock;
import forestry.core.items.IColoredItem;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
@@ -17,7 +16,6 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
@@ -29,8 +27,6 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List;
import java.util.Random;
import org.apache.logging.log4j.core.net.Facility;
public class BlockStained extends Block implements IBlockMetadata, IColoredBlock {
public BlockStained() {
super(Material.GLASS);
@@ -7,7 +7,6 @@ import binnie.botany.Botany;
import binnie.botany.genetics.EnumFlowerColor;
import binnie.botany.items.BotanyItems;
import binnie.core.AbstractMod;
import binnie.core.BinnieCore;
import binnie.extratrees.api.IDesignMaterial;
import binnie.extratrees.api.IDesignSystem;
import binnie.extratrees.api.IPattern;
@@ -210,7 +210,7 @@ public class GardenLogic extends FarmLogic {
}
private boolean trySetWater(final Vect position) {
final FluidStack water = Binnie.Liquid.getLiquidStack("water", 1000);
final FluidStack water = Binnie.Liquid.getFluidStack("water", 1000);
if (this.moisture == EnumMoisture.Damp) {
if (!this.housing.hasLiquid(water)) {
return false;
@@ -7,21 +7,31 @@ import java.util.Random;
import com.mojang.authlib.GameProfile;
import binnie.botany.Botany;
import binnie.botany.api.EnumFlowerStage;
import binnie.botany.api.IFlower;
import binnie.botany.api.IFlowerType;
import binnie.botany.core.BotanyCore;
import binnie.botany.gardening.Gardening;
import binnie.botany.genetics.FlowerDefinition;
import binnie.core.BinnieCore;
import binnie.core.util.TileUtil;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import forestry.core.blocks.IColoredBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
@@ -29,10 +39,12 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockFlower extends BlockContainer implements /*IItemModelRegister, */IColoredBlock {
public class BlockFlower extends BlockContainer implements IColoredBlock, IItemModelRegister {
public static final AxisAlignedBB FLOWER_BLOCK_AABB = new AxisAlignedBB(0.3D, 0.0D, 0.3D, 0.7D, 0.6D, 0.7D);
/* PROPERTYS */
public static final PropertyFlower FLOWER = new PropertyFlower("flower", IFlowerType.class);
public BlockFlower() {
super(Material.PLANTS);
final float f = 0.2f;
@@ -46,18 +58,18 @@ public class BlockFlower extends BlockContainer implements /*IItemModelRegister,
return new TileEntityFlower();
}
/*@Override
@Override
@SideOnly(Side.CLIENT)
public void registerModel(Item item, IModelManager manager) {
for (final EnumFlowerType type : EnumFlowerType.values()) {
type.registerIcons(par1IconRegister);
}
}*/
for(EnumFlowerStage type : EnumFlowerStage.VALUES){
for (IFlowerType flowerType : (List<IFlowerType>)FLOWER.getAllowedValues()) {
flowerType.registerModels(item, manager, type);
}
}
}
@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) {
//flowers have no collision
return null;
}
@@ -98,21 +110,7 @@ public class BlockFlower extends BlockContainer implements /*IItemModelRegister,
}
Gardening.tryGrowSection(world, pos);
}
/*@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(final IBlockAccess world, final int x, final int y, final int z, final int side) {
final TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileEntityFlower) {
final TileEntityFlower f = (TileEntityFlower) tile;
final EnumFlowerStage stage = (f.getAge() == 0) ? EnumFlowerStage.SEED : EnumFlowerStage.FLOWER;
final IFlowerType flower = f.getType();
final int section = f.getRenderSection();
final boolean flowered = f.isFlowered();
return (RendererBotany.pass == 0) ? flower.getStem(stage, flowered, section) : ((RendererBotany.pass == 1) ? flower.getPetalIcon(stage, flowered, section) : flower.getVariantIcon(stage, flowered, section));
}
return super.getIcon(world, x, y, z, side);
}*/␍
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockState state, IBlockAccess world, BlockPos pos, int tintIndex) {
@@ -141,13 +139,51 @@ public class BlockFlower extends BlockContainer implements /*IItemModelRegister,
if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).getSection() > 0) {
return downState.getBlock() == Botany.flower;
}
return this.canPlaceBlockOn(blockState.getBlock());
return this.canPlaceBlockOn(downState.getBlock());
}
protected boolean canPlaceBlockOn(final Block block) {
return block == Blocks.GRASS || block == Blocks.DIRT || block == Blocks.FARMLAND || Gardening.isSoil(block);
}
@Override
@SideOnly(Side.CLIENT)
public EnumBlockRenderType getRenderType(IBlockState state) {
return EnumBlockRenderType.MODEL;
}
@SideOnly(Side.CLIENT)
@Override
public EnumOffsetType getOffsetType() {
return EnumOffsetType.XZ;
}
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
TileEntityFlower flower = TileUtil.getTile(world, pos, TileEntityFlower.class);
if(flower != null && flower.getFlower() != null){
state = state.withProperty(FLOWER, flower.getFlower().getGenome().getPrimary().getType());
}else{
state = state.withProperty(FLOWER, FlowerDefinition.Dandelion.getSpecies().getType());
}
return state;
}
@Override
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, FLOWER);
}
@Override
public int getMetaFromState(IBlockState state) {
return 0;
}
@Override
public BlockRenderLayer getBlockLayer() {
return BlockRenderLayer.CUTOUT;
}
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block blockIn) {
this.checkAndDropBlock(world, pos);
@@ -203,4 +239,5 @@ public class BlockFlower extends BlockContainer implements /*IItemModelRegister,
}
return hasBeenBroken;
}
}
+148 -179
View File
@@ -1,32 +1,59 @@
package binnie.botany.flower;
import binnie.Binnie;
import binnie.botany.Botany;
import binnie.botany.CreativeTabBotany;
import binnie.botany.api.EnumFlowerChromosome;
import binnie.botany.api.EnumFlowerStage;
import binnie.botany.api.IAlleleFlowerSpecies;
import binnie.botany.api.IFlower;
import binnie.botany.api.IFlowerType;
import binnie.botany.core.BotanyCore;
import binnie.botany.genetics.Flower;
import binnie.botany.genetics.FlowerDefinition;
import binnie.botany.genetics.FlowerGenome;
import binnie.core.BinnieCore;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IPollinatable;
import forestry.core.config.Config;
import forestry.core.items.IColoredItem;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List;
public abstract class ItemBotany extends Item {
// @Override
// @SideOnly(Side.CLIENT)
// public int getSpriteNumber() {
// return 0;
// }
public class ItemBotany extends Item implements IColoredItem, IItemModelRegister {
public ItemBotany(final String name) {
private EnumFlowerStage type;
private String tag;
public ItemBotany(final String name, EnumFlowerStage type, String tag) {
this.setCreativeTab(CreativeTabBotany.instance);
this.setUnlocalizedName(name);
setRegistryName(name);
this.hasSubtypes = true;
this.type = type;
this.tag = tag;
}
@Override
@@ -52,35 +79,30 @@ public abstract class ItemBotany extends Item {
final IIndividual individual = this.getIndividual(itemstack);
return individual != null && individual.getGenome() != null && individual.hasEffect();
}
//
// @Override
// public void addInformation(final ItemStack itemstack, final EntityPlayer player, final List list, final boolean flag) {
// if (!itemstack.hasTagCompound()) {
// return;
// }
// final IFlower individual = (IFlower) this.getIndividual(itemstack);
// if (individual == null) {
// list.add("This item is bugged. Destroy it!");
// return;
// }
// list.add("§e" + individual.getGenome().getPrimaryColor().getName() + ((individual.getGenome().getPrimaryColor() == individual.getGenome().getSecondaryColor()) ? "" : (" and " + individual.getGenome().getSecondaryColor().getName())) + ", " + individual.getGenome().getStemColor().getName() + " Stem");
// if (individual.isAnalyzed()) {
// if (BinnieCore.proxy.isShiftDown()) {
// individual.addTooltip(list);
// }
// else {
// list.add("§o<Hold shift for details>");
// }
// }
// else {
// list.add("<Unknown>");
// }
// }
// @Override
// @SideOnly(Side.CLIENT)
// public void registerIcons(final IIconRegister par1IconRegister) {
// }
@Override
public void addInformation(final ItemStack itemstack, final EntityPlayer player, final List list, final boolean flag) {
if (!itemstack.hasTagCompound()) {
return;
}
final IFlower individual = (IFlower) this.getIndividual(itemstack);
if (individual == null) {
list.add("This item is bugged. Destroy it!");
return;
}
list.add("§e" + individual.getGenome().getPrimaryColor().getColourName() + ((individual.getGenome().getPrimaryColor() == individual.getGenome().getSecondaryColor()) ? "" : (" and " + individual.getGenome().getSecondaryColor().getColourName())) + ", " + individual.getGenome().getStemColor().getColourName() + " Stem");
if (individual.isAnalyzed()) {
if (BinnieCore.proxy.isShiftDown()) {
individual.addTooltip(list);
}
else {
list.add("§o<Hold shift for details>");
}
}
else {
list.add("<Unknown>");
}
}
protected IIndividual getIndividual(final ItemStack itemstack) {
return new Flower(itemstack.getTagCompound());
@@ -100,7 +122,7 @@ public abstract class ItemBotany extends Item {
return "Unknown";
}
final IIndividual individual = this.getIndividual(itemstack);
return (individual != null && individual.getGenome() != null) ? (individual.getDisplayName() + this.getTag()) : "Corrupted Flower";
return (individual != null && individual.getGenome() != null) ? (individual.getDisplayName() + tag) : "Corrupted Flower";
}
@Override
@@ -113,155 +135,102 @@ public abstract class ItemBotany extends Item {
if (hideSecrets && individual.isSecret() && !Config.isDebug) {
continue;
}
itemList.add(BotanyCore.getFlowerRoot().getMemberStack(individual.copy(), this.getStage()));
itemList.add(BotanyCore.getFlowerRoot().getMemberStack(individual.copy(), type));
}
}
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
final IFlower flower = BotanyCore.speciesRoot.getMember(stack);
if (flower == null || flower.getGenome() == null) {
return 16777215;
}
return (tintIndex == 0) ? flower.getGenome().getStemColor().getColor(flower.isWilted()) : ((tintIndex == 1) ? flower.getGenome().getPrimaryColor().getColor(flower.isWilted()) : flower.getGenome().getSecondaryColor().getColor(flower.isWilted()));
}
@Override
@SideOnly(Side.CLIENT)
public void registerModel(Item item, IModelManager manager) {
manager.registerItemModel(item, new BotanyMeshDefinition());
}
@SideOnly(Side.CLIENT)
private class BotanyMeshDefinition implements ItemMeshDefinition {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
IFlower flower = BotanyCore.getFlowerRoot().getMember(stack);
if (flower == null || flower.getGenome() == null || flower.getGenome().getPrimary() == null) {
return null;
}
IAlleleFlowerSpecies flowerSpecies = flower.getGenome().getPrimary();
if (flowerSpecies == null) {
flowerSpecies = FlowerDefinition.Dandelion.getSpecies();
}
IFlowerType flowerType = flowerSpecies.getType();
return flowerSpecies.getFlowerModel(type, flower.hasFlowered(), flowerType.getSections() - 1);
}
// @Override
// public int getColorFromItemStack(final ItemStack itemstack, final int renderPass) {
// final IFlower flower = BotanyCore.speciesRoot.getMember(itemstack);
// if (flower == null || flower.getGenome() == null) {
// return 16777215;
// }
// return (renderPass == 0) ? flower.getGenome().getStemColor().getColor(flower.isWilted()) : ((renderPass == 1) ? flower.getGenome().getPrimaryColor().getColor(flower.isWilted()) : flower.getGenome().getSecondaryColor().getColor(flower.isWilted()));
// }
}
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (type == EnumFlowerStage.POLLEN) {
final IFlower flower = Binnie.Genetics.getFlowerRoot().getMember(stack);
final TileEntity target = world.getTileEntity(pos);
if (!(target instanceof IPollinatable)) {
return EnumActionResult.PASS;
}
final IPollinatable pollinatable = (IPollinatable) target;
if (!pollinatable.canMateWith(flower)) {
return EnumActionResult.FAIL;
}
pollinatable.mateWith(flower);
if (!player.capabilities.isCreativeMode) {
--stack.stackSize;
}
return EnumActionResult.SUCCESS;
}
else {
IBlockState iblockstate = world.getBlockState(pos);
Block block = iblockstate.getBlock();
// @Override
// public boolean requiresMultipleRenderPasses() {
// return true;
// }
//
// @Override
// public int getRenderPasses(final int metadata) {
// return 3;
// }
//
// @Override
// @SideOnly(Side.CLIENT)
// public IIcon getIcon(final ItemStack itemstack, final int renderPass) {
// final IFlower flower = BotanyCore.speciesRoot.getMember(itemstack);
// if (flower == null || flower.getGenome() == null || flower.getGenome().getPrimary() == null) {
// return EnumFlowerType.Allium.getBlank();
// }
// final IFlowerType type = flower.getGenome().getPrimary().getType();
// if (renderPass == 0) {
// return type.getStem(this.getStage(), flower.hasFlowered(), type.getSections() - 1);
// }
// if (renderPass == 1) {
// return type.getPetalIcon(this.getStage(), flower.hasFlowered(), type.getSections() - 1);
// }
// return type.getVariantIcon(this.getStage(), flower.hasFlowered(), type.getSections() - 1);
// }
if (!block.isReplaceable(world, pos))
{
pos = pos.offset(facing);
}
// @Override
// public boolean onItemUse(final ItemStack itemstack, final EntityPlayer player, final World world, int x, int y, int z, int side, final float px, final float py, final float pz) {
// if (this.getStage() == EnumFlowerStage.POLLEN) {
// final IFlower flower = Binnie.Genetics.getFlowerRoot().getMember(itemstack);
// final TileEntity target = world.getTileEntity(x, y, z);
// if (!(target instanceof IPollinatable)) {
// return false;
// }
// final IPollinatable pollinatable = (IPollinatable) target;
// if (!pollinatable.canMateWith(flower)) {
// return false;
// }
// pollinatable.mateWith(flower);
// if (!player.capabilities.isCreativeMode) {
// --itemstack.stackSize;
// }
// return true;
// }
// else {
// final Block blockFlower = Botany.flower;
// final Block blockAlreadyThere = world.getBlock(x, y, z);
// if (blockAlreadyThere == Blocks.snow_layer && (world.getBlockMetadata(x, y, z) & 0x7) < 1) {
// side = 1;
// }
// else if (blockAlreadyThere != Blocks.vine && blockAlreadyThere != Blocks.tallgrass && blockAlreadyThere != Blocks.deadbush && !blockAlreadyThere.isReplaceable(world, x, y, z)) {
// if (side == 0) {
// --y;
// }
// if (side == 1) {
// ++y;
// }
// if (side == 2) {
// --z;
// }
// if (side == 3) {
// ++z;
// }
// if (side == 4) {
// --x;
// }
// if (side == 5) {
// ++x;
// }
// }
// if (itemstack.stackSize == 0) {
// return false;
// }
// if (!player.canPlayerEdit(x, y, z, side, itemstack)) {
// return false;
// }
// if (y == 255 && blockFlower.getMaterial().isSolid()) {
// return false;
// }
// if (world.canPlaceEntityOnSide(blockFlower, x, y, z, false, side, player, itemstack)) {
// final int i1 = this.getMetadata(itemstack.getItemDamage());
// final int j1 = blockFlower.onBlockPlaced(world, x, y, z, side, px, py, pz, i1);
// if (this.placeBlockAt(itemstack, player, world, x, y, z, side, px, py, pz, j1)) {
// world.playSoundEffect(x + 0.5f, y + 0.5f, z + 0.5f, blockFlower.stepSound.func_150496_b(), (blockFlower.stepSound.getVolume() + 1.0f) / 2.0f, blockFlower.stepSound.getPitch() * 0.8f);
// --itemstack.stackSize;
// }
// return true;
// }
// return false;
// }
// }
if (stack.stackSize != 0 && player.canPlayerEdit(pos, facing, stack) && world.canBlockBePlaced(Botany.flower, pos, false, facing, (Entity)null, stack))
{
int i = this.getMetadata(stack.getMetadata());
IBlockState iblockstate1 = Botany.flower.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, i, player, stack);
// @SideOnly(Side.CLIENT)
// public boolean func_150936_a(final World p_150936_1_, int p_150936_2_, int p_150936_3_, int p_150936_4_, int p_150936_5_, final EntityPlayer p_150936_6_, final ItemStack p_150936_7_) {
// final Block field_150939_a = Botany.flower;
// final Block block = p_150936_1_.getBlock(p_150936_2_, p_150936_3_, p_150936_4_);
// if (block == Blocks.snow_layer) {
// p_150936_5_ = 1;
// }
// else if (block != Blocks.vine && block != Blocks.tallgrass && block != Blocks.deadbush && !block.isReplaceable(p_150936_1_, p_150936_2_, p_150936_3_, p_150936_4_)) {
// if (p_150936_5_ == 0) {
// --p_150936_3_;
// }
// if (p_150936_5_ == 1) {
// ++p_150936_3_;
// }
// if (p_150936_5_ == 2) {
// --p_150936_4_;
// }
// if (p_150936_5_ == 3) {
// ++p_150936_4_;
// }
// if (p_150936_5_ == 4) {
// --p_150936_2_;
// }
// if (p_150936_5_ == 5) {
// ++p_150936_2_;
// }
// }
// return p_150936_1_.canPlaceEntityOnSide(field_150939_a, p_150936_2_, p_150936_3_, p_150936_4_, false, p_150936_5_, (Entity) null, p_150936_7_);
// }
//
// public boolean placeBlockAt(final ItemStack stack, final EntityPlayer player, final World world, final int x, final int y, final int z, final int side, final float hitX, final float hitY, final float hitZ, final int metadata) {
// final Block field_150939_a = Botany.flower;
// if (!world.setBlock(x, y, z, field_150939_a, metadata, 3)) {
// return false;
// }
// if (world.getBlock(x, y, z) == field_150939_a) {
// field_150939_a.onBlockPlacedBy(world, x, y, z, player, stack);
// field_150939_a.onPostBlockPlaced(world, x, y, z, metadata);
// }
// return true;
// }
if (placeBlockAt(stack, player, world, pos, facing, hitX, hitY, hitZ, iblockstate1))
{
SoundType soundtype = world.getBlockState(pos).getBlock().getSoundType(world.getBlockState(pos), world, pos, player);
world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
--stack.stackSize;
}
public abstract EnumFlowerStage getStage();
return EnumActionResult.SUCCESS;
}
else
{
return EnumActionResult.FAIL;
}
}
}
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState){
if (!world.setBlockState(pos, newState, 3)){
return false;
}
public abstract String getTag();
IBlockState state = world.getBlockState(pos);
if (state.getBlock() == Botany.flower) {
ItemBlock.setTileEntityNBT(world, player, pos, stack);
Botany.flower.onBlockPlacedBy(world, pos, state, player, stack);
}
return true;
}
}
@@ -1,19 +0,0 @@
package binnie.botany.flower;
import binnie.botany.api.EnumFlowerStage;
public class ItemFlower extends ItemBotany {
public ItemFlower() {
super("itemFlower");
}
@Override
public EnumFlowerStage getStage() {
return EnumFlowerStage.FLOWER;
}
@Override
public String getTag() {
return "";
}
}
@@ -1,19 +0,0 @@
package binnie.botany.flower;
import binnie.botany.api.EnumFlowerStage;
public class ItemPollen extends ItemBotany {
public ItemPollen() {
super("pollen");
}
@Override
public EnumFlowerStage getStage() {
return EnumFlowerStage.POLLEN;
}
@Override
public String getTag() {
return " Pollen";
}
}
@@ -1,19 +0,0 @@
package binnie.botany.flower;
import binnie.botany.api.EnumFlowerStage;
public class ItemSeed extends ItemBotany {
public ItemSeed() {
super("seed");
}
@Override
public EnumFlowerStage getStage() {
return EnumFlowerStage.SEED;
}
@Override
public String getTag() {
return " Germling";
}
}
@@ -0,0 +1,54 @@
package binnie.botany.flower;
import com.google.common.base.Optional;
import binnie.botany.api.IAlleleFlowerSpecies;
import binnie.botany.api.IFlowerType;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import net.minecraft.block.properties.PropertyHelper;
public class PropertyFlower<I extends IFlowerType<I>> extends PropertyHelper<I> {
public PropertyFlower(String name, Class<I> flowerTypeClass) {
super(name, flowerTypeClass);
}
@Override
public List<I> getAllowedValues() {
List<I> flowerTypes = new ArrayList<>();
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
if (allele instanceof IAlleleFlowerSpecies) {
IFlowerType flowerType = ((IAlleleFlowerSpecies) allele).getType();
if(!flowerTypes.contains(flowerType)){
flowerTypes.add((I) flowerType);
}
}
}
return flowerTypes;
}
/**
* Get the name for the given value.
*/
@Override
public String getName(IFlowerType value) {
return value.getName().toLowerCase(Locale.ENGLISH);
}
@Override
public Optional<I> parseValue(String value) {
IAllele allele = AlleleManager.alleleRegistry.getAllele(value);
if (IAlleleFlowerSpecies.class.isInstance(allele)) {
IAlleleFlowerSpecies alleleValue = IAlleleFlowerSpecies.class.cast(allele);
return (Optional<I>) Optional.of(alleleValue.getType());
}
return Optional.absent();
}
}
@@ -1,54 +0,0 @@
package binnie.botany.flower;
public class RendererBotany// implements ISimpleBlockRenderingHandler
{
// public static int renderID;
// public static int pass;
//
// @Override
// public void renderInventoryBlock(final Block block, final int metadata, final int modelID, final RenderBlocks renderer) {
// }
//
// @Override
// public boolean renderWorldBlock(final IBlockAccess world, final int x, final int y, final int z, final Block block, final int modelId, final RenderBlocks renderer) {
// final Tessellator tessellator = Tessellator.instance;
// tessellator.setBrightness(block.getMixedBrightnessForBlock(renderer.blockAccess, x, y, z));
// double d1 = x;
// final double d2 = y;
// double d3 = z;
// long i1 = x * 3129871 ^ z * 116129781L;
// i1 = i1 * i1 * 42317861L + i1 * 11L;
// d1 += ((i1 >> 16 & 0xFL) / 15.0f - 0.5) * 0.3;
// d3 += ((i1 >> 24 & 0xFL) / 15.0f - 0.5) * 0.3;
// final int rot = (int) (i1 % 4L);
// for (int j = 0; j < 3; ++j) {
// RendererBotany.pass = j;
// final int l = block.colorMultiplier(renderer.blockAccess, x, y, z);
// float f = (l >> 16 & 0xFF) / 255.0f;
// float f2 = (l >> 8 & 0xFF) / 255.0f;
// float f3 = (l & 0xFF) / 255.0f;
// if (EntityRenderer.anaglyphEnable) {
// final float f4 = (f * 30.0f + f2 * 59.0f + f3 * 11.0f) / 100.0f;
// final float f5 = (f * 30.0f + f2 * 70.0f) / 100.0f;
// final float f6 = (f * 30.0f + f3 * 70.0f) / 100.0f;
// f = f4;
// f2 = f5;
// f3 = f6;
// }
// tessellator.setColorOpaque_F(f, f2, f3);
// final IIcon iicon = block.getIcon(world, x, y, z, 0);
// renderer.drawCrossedSquares(iicon, d1, d2, d3, 1.0f);
// }
// return false;
// }
//
// @Override
// public boolean shouldRender3DInInventory(final int i) {
// return false;
// }
//
// @Override
// public int getRenderId() {
// return RendererBotany.renderID;
// }
}
@@ -1,15 +1,21 @@
package binnie.botany.flower;
import binnie.Binnie;
import binnie.botany.Botany;
import binnie.botany.api.EnumFlowerStage;
import binnie.botany.api.EnumSoilType;
import binnie.botany.api.IAlleleFlowerSpecies;
import binnie.botany.api.IFlower;
import binnie.botany.api.IFlowerColour;
import binnie.botany.api.IFlowerGenome;
import binnie.botany.api.IFlowerType;
import binnie.botany.core.BotanyCore;
import binnie.botany.gardening.BlockPlant;
import binnie.botany.gardening.Gardening;
import binnie.botany.genetics.EnumFlowerColor;
import binnie.botany.genetics.EnumFlowerType;
import binnie.botany.genetics.Flower;
import binnie.botany.network.PacketFlowerUpdate;
import binnie.core.BinnieCore;
import com.mojang.authlib.GameProfile;
import forestry.api.core.EnumHumidity;
@@ -20,20 +26,23 @@ import forestry.api.genetics.IPollinatable;
import forestry.api.lepidopterology.IButterfly;
import forestry.api.lepidopterology.IButterflyNursery;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDoublePlant.EnumPlantType;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.common.EnumPlantType;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
public class TileEntityFlower extends TileEntity /*implements IPollinatable, IButterflyNursery*/{
public class TileEntityFlower extends TileEntity implements IPollinatable, IButterflyNursery{
IFlower flower;
GameProfile owner;
int section;
@@ -96,9 +105,9 @@ public class TileEntityFlower extends TileEntity /*implements IPollinatable, IBu
this.owner = owner;
}
/*@Override
public EnumSet<EnumPlantType> getPlantType() {
return EnumSet.of(EnumPlantType.Plains);
@Override
public EnumPlantType getPlantType() {
return EnumPlantType.Plains;
}
@Override
@@ -120,9 +129,9 @@ public class TileEntityFlower extends TileEntity /*implements IPollinatable, IBu
final IAlleleFlowerSpecies primary2 = this.getFlower().getGenome().getPrimary();
if (primary == primary2 || this.worldObj.rand.nextInt(4) == 0) {
this.getFlower().mate((IFlower) individual);
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
worldObj.markBlockRangeForRenderUpdate(pos, pos);
}
}*/
}
public IFlower getFlower() {
if (this.getSection() <= 0) {
@@ -141,139 +150,148 @@ public class TileEntityFlower extends TileEntity /*implements IPollinatable, IBu
}
public void randomUpdate(final Random rand) {
// if (this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord) != Botany.flower) {
// this.invalidate();
// return;
// }
// if (this.getSection() > 0) {
// return;
// }
// if (this.flower == null) {
// return;
// }
// if (this.flower.getGenome() == null) {
// this.invalidate();
// return;
// }
// if (!this.isBreeding()) {
// return;
// }
// float light = this.worldObj.getBlockLightValue(this.xCoord, this.yCoord, this.zCoord);
// if (light < 6.0f) {
// for (int dx = -2; dx <= 2; ++dx) {
// for (int dy = -2; dy <= 2; ++dy) {
// light -= (this.worldObj.canBlockSeeTheSky(this.xCoord, this.yCoord, this.zCoord) ? 0.0f : 0.5f);
// }
// }
// }
// final boolean canTolerate = Gardening.canTolerate(this.getFlower(), this.worldObj, this.xCoord, this.yCoord, this.zCoord);
// final EnumSoilType soil = Gardening.getSoilType(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
// if (rand.nextFloat() < this.getFlower().getGenome().getAgeChance()) {
// if (this.flower.getAge() < 1) {
// if (canTolerate && light > 6.0f) {
// this.doFlowerAge();
// }
// }
// else {
// this.doFlowerAge();
// }
// }
// if (canTolerate && this.flower.getAge() > 1 && !this.flower.isWilted() && light > 6.0f) {
// this.flower.setFlowered(true);
// }
// if (!canTolerate && this.flower.isWilted() && rand.nextInt(2 + Math.max(this.flower.getAge(), 2)) == 0) {
// this.kill();
// return;
// }
// if (light < 2.0f && this.flower.isWilted()) {
// this.kill();
// return;
// }
// if (!canTolerate || light < 1.0f) {
// this.flower.setWilted(true);
// }
// else {
// this.flower.setWilted(false);
// }
// float CHANCE_DISPERSAL = 0.8f;
// CHANCE_DISPERSAL += 0.2f * this.flower.getGenome().getFertility();
// CHANCE_DISPERSAL *= 1.0f + soil.ordinal() * 0.5f;
// float CHANCE_POLLINATE = 1.0f;
// CHANCE_POLLINATE += 0.25f * this.flower.getGenome().getFertility();
// CHANCE_POLLINATE *= 1.0f + soil.ordinal() * 0.5f;
// final float CHANCE_SELFPOLLINATE = 0.2f * CHANCE_POLLINATE;
// if (this.worldObj.rand.nextFloat() < CHANCE_DISPERSAL && this.flower.hasFlowered() && !this.flower.isWilted()) {
// final IFlowerGenome mate = this.flower.getMate();
// if (mate != null) {
// boolean dispersed = false;
// for (int a = 0; a < 5 && !dispersed; ++a) {
// int dx2;
// int dz;
// for (dx2 = 0, dz = 0; dx2 == 0 && dz == 0; dx2 = rand.nextInt(3) - 1, dz = rand.nextInt(3) - 1) {
// }
// final Block b = this.getWorldObj().getBlock(this.xCoord + dx2, this.yCoord, this.zCoord + dz);
// final Block b2 = this.getWorldObj().getBlock(this.xCoord + dx2, this.yCoord - 1, this.zCoord + dz);
// if (b == Blocks.air && Gardening.isSoil(b2)) {
// final IFlower offspring = this.flower.getOffspring(this.getWorldObj());
// if (offspring != null) {
// Gardening.plant(this.getWorldObj(), this.xCoord + dx2, this.yCoord, this.zCoord + dz, offspring, this.getOwner());
// this.flower.removeMate();
// dispersed = true;
// }
// }
// }
// }
if (this.worldObj.getBlockState(pos).getBlock() != Botany.flower) {
this.invalidate();
return;
}
if (this.getSection() > 0) {
return;
}
if (this.flower == null) {
return;
}
if (this.flower.getGenome() == null) {
this.invalidate();
return;
}
if (!this.isBreeding()) {
return;
}
float light = this.worldObj.getLight(pos);
if (light < 6.0f) {
for (int dx = -2; dx <= 2; ++dx) {
for (int dy = -2; dy <= 2; ++dy) {
light -= (this.worldObj.canBlockSeeSky(pos) ? 0.0f : 0.5f);
}
}
}
final boolean canTolerate = Gardening.canTolerate(this.getFlower(), this.worldObj, pos);
final EnumSoilType soil = Gardening.getSoilType(this.worldObj, pos.down());
if (rand.nextFloat() < this.getFlower().getGenome().getAgeChance()) {
if (this.flower.getAge() < 1) {
if (canTolerate && light > 6.0f) {
this.doFlowerAge();
}
}
else {
this.doFlowerAge();
}
}
if (canTolerate && this.flower.getAge() > 1 && !this.flower.isWilted() && light > 6.0f) {
this.flower.setFlowered(true);
}
if (!canTolerate && this.flower.isWilted() && rand.nextInt(2 + Math.max(this.flower.getAge(), 2)) == 0) {
this.kill();
return;
}
if (light < 2.0f && this.flower.isWilted()) {
this.kill();
return;
}
if (!canTolerate || light < 1.0f) {
this.flower.setWilted(true);
}
else {
this.flower.setWilted(false);
}
float CHANCE_DISPERSAL = 0.8f;
CHANCE_DISPERSAL += 0.2f * this.flower.getGenome().getFertility();
CHANCE_DISPERSAL *= 1.0f + soil.ordinal() * 0.5f;
float CHANCE_POLLINATE = 1.0f;
CHANCE_POLLINATE += 0.25f * this.flower.getGenome().getFertility();
CHANCE_POLLINATE *= 1.0f + soil.ordinal() * 0.5f;
final float CHANCE_SELFPOLLINATE = 0.2f * CHANCE_POLLINATE;
if (this.worldObj.rand.nextFloat() < CHANCE_DISPERSAL && this.flower.hasFlowered() && !this.flower.isWilted()) {
final IFlowerGenome mate = this.flower.getMate();
if (mate != null) {
boolean dispersed = false;
for (int a = 0; a < 5 && !dispersed; ++a) {
int dx2;
int dz;
for (dx2 = 0, dz = 0; dx2 == 0 && dz == 0; dx2 = rand.nextInt(3) - 1, dz = rand.nextInt(3) - 1) {
}
final Block b2 = worldObj.getBlockState(pos.add(dx2, -1, dz)).getBlock();
if (worldObj.isAirBlock(pos.add(dx2, 0, dz)) && Gardening.isSoil(b2)) {
final IFlower offspring = this.flower.getOffspring(worldObj, pos);
if (offspring != null) {
Gardening.plant(worldObj, pos.add(dx2, 0, dz), offspring, this.getOwner());
this.flower.removeMate();
dispersed = true;
}
}
}
}
}
// if (this.worldObj.rand.nextFloat() < CHANCE_POLLINATE && this.flower.hasFlowered() && !this.flower.isWilted()) {
// for (int a2 = 0; a2 < 4; ++a2) {
// int dx3;
// int dz2;
// for (dx3 = 0, dz2 = 0; dx3 == 0 && dz2 == 0; dx3 = rand.nextInt(5) - 2, dz2 = rand.nextInt(5) - 2) {
// }
// final TileEntity tile = this.getWorldObj().getTileEntity(this.xCoord + dx3, this.yCoord, this.zCoord + dz2);
// if (tile instanceof IPollinatable && ((IPollinatable) tile).canMateWith(this.getFlower())) {
// ((IPollinatable) tile).mateWith(this.getFlower());
// }
// }
// }
// if (this.worldObj.rand.nextFloat() < CHANCE_SELFPOLLINATE && this.flower.hasFlowered() && this.flower.getMate() == null) {
// this.mateWith(this.getFlower());
// }
// this.spawnButterflies();
// this.matureCaterpillar();
// this.checkIfDead(false);
// this.updateRender(true);
// }
if (this.worldObj.rand.nextFloat() < CHANCE_POLLINATE && this.flower.hasFlowered() && !this.flower.isWilted()) {
for (int a2 = 0; a2 < 4; ++a2) {
int dx3;
int dz2;
for (dx3 = 0, dz2 = 0; dx3 == 0 && dz2 == 0; dx3 = rand.nextInt(5) - 2, dz2 = rand.nextInt(5) - 2) {
}
final TileEntity tile = worldObj.getTileEntity(pos.add(dx3, 0, dz2));
if (tile instanceof IPollinatable && ((IPollinatable) tile).canMateWith(this.getFlower())) {
((IPollinatable) tile).mateWith(this.getFlower());
}
}
}
if (this.worldObj.rand.nextFloat() < CHANCE_SELFPOLLINATE && this.flower.hasFlowered() && this.flower.getMate() == null) {
this.mateWith(this.getFlower());
}
this.spawnButterflies();
this.matureCaterpillar();
this.checkIfDead(false);
this.updateRender(true);
}
// private void doFlowerAge() {
// this.getFlower().age();
// if (this.getFlower().getAge() == 1) {
// Gardening.onGrowFromSeed(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
// if (this.getOwner() != null && this.getFlower() != null) {
// BotanyCore.getFlowerRoot().getBreedingTracker(this.getWorldObj(), this.getOwner()).registerBirth(this.getFlower());
// }
// }
// }
// @Override
// public Packet getDescriptionPacket() {
// if (this.renderInfo == null && this.getFlower() != null && this.getFlower().getGenome() != null) {
// this.renderInfo = new RenderInfo(this.getFlower(), this);
// }
// return (this.renderInfo != null) ? Botany.instance.getNetworkWrapper().getPacketFrom(new MessageFlowerUpdate(this.xCoord, this.yCoord, this.zCoord, this.renderInfo).GetMessage()) : null;
// }
private void doFlowerAge() {
this.getFlower().age();
if (this.getFlower().getAge() == 1) {
Gardening.onGrowFromSeed(this.worldObj, pos);
if (this.getOwner() != null && this.getFlower() != null) {
BotanyCore.getFlowerRoot().getBreedingTracker(worldObj, this.getOwner()).registerBirth(this.getFlower());
}
}
}
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
super.onDataPacket(net, pkt);
if(pkt instanceof PacketFlowerUpdate){
setRender(((PacketFlowerUpdate) pkt).render);
}
}
@Override
public SPacketUpdateTileEntity getUpdatePacket() {
if (this.renderInfo == null && this.getFlower() != null && this.getFlower().getGenome() != null) {
this.renderInfo = new RenderInfo(this.getFlower(), this);
}
return (this.renderInfo != null) ? new PacketFlowerUpdate(pos, 0, getUpdateTag(), renderInfo) : null;
}
public void updateRender(final boolean update) {
// if (update && this.getFlower() != null && this.getFlower().getGenome() != null) {
// final RenderInfo newInfo = new RenderInfo(this.getFlower(), this);
// if (this.renderInfo == null || !newInfo.equals(this.renderInfo)) {
// this.setRender(newInfo);
// }
// }
// final TileEntity above = this.worldObj.getTileEntity(this.xCoord, this.yCoord + 1, this.zCoord);
// if (above instanceof TileEntityFlower) {
// ((TileEntityFlower) above).updateRender(true);
// }
if (update && this.getFlower() != null && this.getFlower().getGenome() != null) {
final RenderInfo newInfo = new RenderInfo(this.getFlower(), this);
if (this.renderInfo == null || !newInfo.equals(this.renderInfo)) {
this.setRender(newInfo);
}
}
final TileEntity above = this.worldObj.getTileEntity(pos.up());
if (above instanceof TileEntityFlower) {
((TileEntityFlower) above).updateRender(true);
}
}
public int getSection() {
@@ -294,75 +312,75 @@ public class TileEntityFlower extends TileEntity /*implements IPollinatable, IBu
return Binnie.Genetics.getFlowerRoot().getMemberStack(this.getFlower(), EnumFlowerStage.getStage(getFlower()));
}
// private TileEntityFlower getRoot() {
// if (this.getSection() == 0) {
// return null;
// }
// final TileEntity tile = this.worldObj.getTileEntity(this.xCoord, this.yCoord - this.getSection(), this.zCoord);
// return (tile instanceof TileEntityFlower) ? ((TileEntityFlower) tile) : null;
// }
private TileEntityFlower getRoot() {
if (this.getSection() == 0) {
return null;
}
final TileEntity tile = this.worldObj.getTileEntity(pos.down(getSection()));
return (tile instanceof TileEntityFlower) ? ((TileEntityFlower) tile) : null;
}
public void onShear() {
// if (this.getRoot() != null) {
// this.getRoot().onShear();
// }
// if (this.getFlower() != null && this.getFlower().getAge() > 1) {
// final Random rand = new Random();
// final IFlower cutting = (IFlower) this.getFlower().copy();
// cutting.setAge(0);
// final ItemStack cuttingStack = BotanyCore.getFlowerRoot().getMemberStack(cutting, EnumFlowerStage.SEED.ordinal());
// final float f = 0.7f;
// final double d = rand.nextFloat() * f + (1.0f - f) * 0.5;
// final double d2 = rand.nextFloat() * f + (1.0f - f) * 0.5;
// final double d3 = rand.nextFloat() * f + (1.0f - f) * 0.5;
// final EntityItem entityitem = new EntityItem(this.worldObj, this.xCoord + d, this.yCoord + d2, this.zCoord + d3, cuttingStack);
// entityitem.delayBeforeCanPickup = 10;
// this.worldObj.spawnEntityInWorld(entityitem);
// for (int maxAge = this.getFlower().getMaxAge(), i = 0; i < maxAge; ++i) {
// if (rand.nextBoolean()) {
// this.getFlower().age();
// if (this.checkIfDead(true)) {
// return;
// }
// }
// }
// }
if (this.getRoot() != null) {
this.getRoot().onShear();
}
if (this.getFlower() != null && this.getFlower().getAge() > 1) {
final Random rand = new Random();
final IFlower cutting = (IFlower) this.getFlower().copy();
cutting.setAge(0);
final ItemStack cuttingStack = BotanyCore.getFlowerRoot().getMemberStack(cutting, EnumFlowerStage.SEED);
final float f = 0.7f;
final double d = rand.nextFloat() * f + (1.0f - f) * 0.5;
final double d2 = rand.nextFloat() * f + (1.0f - f) * 0.5;
final double d3 = rand.nextFloat() * f + (1.0f - f) * 0.5;
final EntityItem entityitem = new EntityItem(this.worldObj, pos.getX() + d, pos.getY() + d2, pos.getZ() + d3, cuttingStack);
entityitem.setPickupDelay(10);
this.worldObj.spawnEntityInWorld(entityitem);
for (int maxAge = this.getFlower().getMaxAge(), i = 0; i < maxAge; ++i) {
if (rand.nextBoolean()) {
this.getFlower().age();
if (this.checkIfDead(true)) {
return;
}
}
}
}
}
public boolean checkIfDead(final boolean wasCut) {
// if (this.getSection() != 0) {
// return this.getRoot().checkIfDead(wasCut);
// }
// final EnumSoilType soil = Gardening.getSoilType(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
// final int maxAge = (int) (this.flower.getMaxAge() * (1.0f + soil.ordinal() * 0.25f));
// if (this.flower.getAge() > maxAge) {
// if (!wasCut && this.flower.getMate() != null) {
// this.worldObj.setBlockToAir(this.xCoord, this.yCoord, this.zCoord);
// final IFlower offspring = this.flower.getOffspring(this.getWorldObj());
// final TileEntity above = this.worldObj.getTileEntity(this.xCoord, this.yCoord + 1, this.zCoord);
// if (above instanceof TileEntityFlower) {
// this.worldObj.setBlockToAir(this.xCoord, this.yCoord + 1, this.zCoord);
// }
// Gardening.plant(this.worldObj, this.xCoord, this.yCoord, this.zCoord, offspring, this.getOwner());
// }
// else {
// this.kill();
// }
// return true;
// }
if (this.getSection() != 0) {
return this.getRoot().checkIfDead(wasCut);
}
final EnumSoilType soil = Gardening.getSoilType(this.worldObj, pos);
final int maxAge = (int) (this.flower.getMaxAge() * (1.0f + soil.ordinal() * 0.25f));
if (this.flower.getAge() > maxAge) {
if (!wasCut && this.flower.getMate() != null) {
this.worldObj.setBlockToAir(pos);
final IFlower offspring = this.flower.getOffspring(worldObj, pos.down());
final TileEntity above = this.worldObj.getTileEntity(pos.up());
if (above instanceof TileEntityFlower) {
this.worldObj.setBlockToAir(pos.up());
}
Gardening.plant(this.worldObj, pos, offspring, this.getOwner());
}
else {
this.kill();
}
return true;
}
return false;
}
public void kill() {
// if (this.flower.getAge() > 0) {
// this.worldObj.setBlock(this.xCoord, this.yCoord, this.zCoord, Botany.plant, BlockPlant.Type.DeadFlower.ordinal(), 2);
// }
// else {
// this.worldObj.setBlockToAir(this.xCoord, this.yCoord, this.zCoord);
// }
// for (int i = 1; this.worldObj.getTileEntity(this.xCoord, this.yCoord + i, this.zCoord) instanceof TileEntityFlower; ++i) {
// this.worldObj.setBlockToAir(this.xCoord, this.yCoord + i, this.zCoord);
// }
if (this.flower.getAge() > 0) {
this.worldObj.setBlockState(pos, Botany.plant.getStateFromMeta(BlockPlant.Type.DeadFlower.ordinal()), 2);
}
else {
this.worldObj.setBlockToAir(pos);
}
for (int i = 1; this.worldObj.getTileEntity(pos.up(i)) instanceof TileEntityFlower; ++i) {
this.worldObj.setBlockToAir(pos.up(i));
}
}
public boolean onBonemeal() {
@@ -447,11 +465,13 @@ public class TileEntityFlower extends TileEntity /*implements IPollinatable, IBu
}
public EnumTemperature getTemperature() {
@Override
public EnumTemperature getTemperature() {
return EnumTemperature.getFromValue(this.worldObj.getBiome(getPos()).getTemperature());
}
public EnumHumidity getHumidity() {
@Override
public EnumHumidity getHumidity() {
return EnumHumidity.getFromValue(this.worldObj.getBiome(getPos()).getRainfall());
}
@@ -466,56 +486,57 @@ public class TileEntityFlower extends TileEntity /*implements IPollinatable, IBu
return false;
}
// @Override
// public IButterfly getCaterpillar() {
// return this.caterpillar;
// }
//
// @Override
// public IIndividual getNanny() {
// return this.getFlower();
// }
//
// @Override
// public void setCaterpillar(final IButterfly butterfly) {
// this.caterpillar = butterfly;
// this.matureTime = 0;
// }
//
// @Override
// public boolean canNurse(final IButterfly butterfly) {
// return this.getFlower() != null && !this.getFlower().isWilted() && this.getFlower().getAge() > 1;
// }
@Override
public IButterfly getCaterpillar() {
return this.caterpillar;
}
@Override
public IIndividual getNanny() {
return this.getFlower();
}
@Override
public void setCaterpillar(final IButterfly butterfly) {
this.caterpillar = butterfly;
this.matureTime = 0;
}
@Override
public boolean canNurse(final IButterfly butterfly) {
return this.getFlower() != null && !this.getFlower().isWilted() && this.getFlower().getAge() > 1;
}
private void matureCaterpillar() {
// if (this.getCaterpillar() == null) {
// return;
// }
//TODO Spawn the caterpillar in a cocon on the next Tree or other thing
/*if (this.getCaterpillar() == null) {
return;
}
++this.matureTime;
// if (this.matureTime >= this.caterpillar.getGenome().getLifespan() / (this.caterpillar.getGenome().getFertility() * 2) && this.caterpillar.canTakeFlight(this.worldObj, this.xCoord, this.yCoord, this.zCoord)) {
// if (this.worldObj.isAirBlock(this.xCoord, this.yCoord + 1, this.zCoord)) {
// this.attemptButterflySpawn(this.worldObj, this.caterpillar, this.xCoord, this.yCoord + 1, this.zCoord);
// }
// else if (this.worldObj.isAirBlock(this.xCoord - 1, this.yCoord, this.zCoord)) {
// this.attemptButterflySpawn(this.worldObj, this.caterpillar, this.xCoord - 1, this.yCoord, this.zCoord);
// }
// else if (this.worldObj.isAirBlock(this.xCoord + 1, this.yCoord, this.zCoord)) {
// this.attemptButterflySpawn(this.worldObj, this.caterpillar, this.xCoord + 1, this.yCoord, this.zCoord);
// }
// else if (this.worldObj.isAirBlock(this.xCoord, this.yCoord, this.zCoord - 1)) {
// this.attemptButterflySpawn(this.worldObj, this.caterpillar, this.xCoord, this.yCoord, this.zCoord - 1);
// }
// else if (this.worldObj.isAirBlock(this.xCoord, this.yCoord, this.zCoord + 1)) {
// this.attemptButterflySpawn(this.worldObj, this.caterpillar, this.xCoord, this.yCoord, this.zCoord + 1);
// }
// this.setCaterpillar(null);
// }
if (this.matureTime >= this.caterpillar.getGenome().getLifespan() / (this.caterpillar.getGenome().getFertility() * 2) && this.caterpillar.canTakeFlight(this.worldObj, this.xCoord, this.yCoord, this.zCoord)) {
if (this.worldObj.isAirBlock(this.xCoord, this.yCoord + 1, this.zCoord)) {
this.attemptButterflySpawn(this.worldObj, this.caterpillar, this.xCoord, this.yCoord + 1, this.zCoord);
}
else if (this.worldObj.isAirBlock(this.xCoord - 1, this.yCoord, this.zCoord)) {
this.attemptButterflySpawn(this.worldObj, this.caterpillar, this.xCoord - 1, this.yCoord, this.zCoord);
}
else if (this.worldObj.isAirBlock(this.xCoord + 1, this.yCoord, this.zCoord)) {
this.attemptButterflySpawn(this.worldObj, this.caterpillar, this.xCoord + 1, this.yCoord, this.zCoord);
}
else if (this.worldObj.isAirBlock(this.xCoord, this.yCoord, this.zCoord - 1)) {
this.attemptButterflySpawn(this.worldObj, this.caterpillar, this.xCoord, this.yCoord, this.zCoord - 1);
}
else if (this.worldObj.isAirBlock(this.xCoord, this.yCoord, this.zCoord + 1)) {
this.attemptButterflySpawn(this.worldObj, this.caterpillar, this.xCoord, this.yCoord, this.zCoord + 1);
}
this.setCaterpillar(null);
}*/
}
public void setRender(final RenderInfo render) {
this.renderInfo = render;
this.section = this.renderInfo.section;
//this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
worldObj.markBlockRangeForRenderUpdate(pos, pos);
}
public int getAge() {
@@ -550,7 +571,8 @@ public class TileEntityFlower extends TileEntity /*implements IPollinatable, IBu
return (this.renderInfo == null) ? EnumFlowerType.Poppy : this.renderInfo.type;
}
public Biome getBiome() {
@Override
public Biome getBiome() {
return this.getWorld().getBiome(getPos());
}
@@ -602,16 +624,15 @@ public class TileEntityFlower extends TileEntity /*implements IPollinatable, IBu
this.type = flower.getGenome().getType();
}
}
//
// @Override
// public BlockPos getCoordinates() {
// return getPos();
// }
//
// // TODO ??
// @Override
// public boolean isPollinated() {
// return isBreeding();
// }
@Override
public BlockPos getCoordinates() {
return getPos();
}
@Override
public boolean isPollinated() {
return isBreeding();
}
}
@@ -90,8 +90,8 @@ public class AlleleFlowerSpecies extends AlleleSpecies implements IAlleleFlowerS
}
@Override
public ModelResourceLocation getFlowerModel(EnumFlowerStage type) {
return flowerType.getModel(type);
public ModelResourceLocation getFlowerModel(EnumFlowerStage type, boolean flowered, int section) {
return flowerType.getModel(type, flowered, section);
}
@Override
@@ -99,4 +99,9 @@ public class AlleleFlowerSpecies extends AlleleSpecies implements IAlleleFlowerS
flowerType.registerModels(item, manager, type);
}
@Override
public int compareTo(IAlleleFlowerSpecies o) {
return 0;
}
}
@@ -3,6 +3,7 @@ package binnie.botany.genetics;
import binnie.botany.Botany;
import binnie.botany.api.IFlowerColour;
import binnie.botany.core.BotanyCore;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAlleleInteger;
import net.minecraft.util.IStringSerializable;
@@ -2944,6 +2945,12 @@ public enum EnumFlowerColor implements IFlowerColour, IAlleleInteger, IStringSer
addMix(EnumFlowerColor.YellowGreen, EnumFlowerColor.White, EnumFlowerColor.Khaki, 95);
addMix(EnumFlowerColor.YellowGreen, EnumFlowerColor.Yellow, EnumFlowerColor.Khaki, 110);
}
public static void initColours(){
for (EnumFlowerColor color : EnumFlowerColor.values()) {
AlleleManager.alleleRegistry.registerAllele(color);
}
}
@Override
public String getColourName() {
@@ -1,12 +1,17 @@
package binnie.botany.genetics;
import java.util.Locale;
import binnie.Constants;
import binnie.botany.api.EnumFlowerStage;
import binnie.botany.api.IFlowerType;
import forestry.api.core.IModelManager;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public enum EnumFlowerType implements IFlowerType {
public enum EnumFlowerType implements IFlowerType<EnumFlowerType> {
Dandelion,
Poppy,
Orchid,
@@ -56,17 +61,10 @@ public enum EnumFlowerType implements IFlowerType {
Hollyhock(2);
int sections;
// IIcon[] stem;
// IIcon[] petal;
// IIcon[] variant;
// IIcon[] unflowered;
// IIcon seedStem;
// IIcon seedPetal;
// IIcon seedVariant;
// IIcon pollenStem;
// IIcon pollenPetal;
// IIcon pollenVariant;
// IIcon blank;
ModelResourceLocation[] flowered;
ModelResourceLocation[] unflowered;
ModelResourceLocation seed;
ModelResourceLocation pollen;
EnumFlowerType() {
this(1);
@@ -74,63 +72,38 @@ public enum EnumFlowerType implements IFlowerType {
EnumFlowerType(final int sections) {
this.sections = sections;
// this.stem = new IIcon[sections];
// this.petal = new IIcon[sections];
// this.variant = new IIcon[sections];
// this.unflowered = new IIcon[sections];
this.flowered = new ModelResourceLocation[sections];
this.unflowered = new ModelResourceLocation[sections];
}
// @Override
// public IIcon getStem(final EnumFlowerStage stage, final boolean flowered, final int section) {
// return (stage == EnumFlowerStage.SEED) ? this.seedStem : ((stage == EnumFlowerStage.POLLEN) ? this.pollenStem : this.stem[section % this.sections]);
// }
//
// @Override
// public IIcon getPetalIcon(final EnumFlowerStage stage, final boolean flowered, final int section) {
// return (stage == EnumFlowerStage.SEED) ? this.seedPetal : ((stage == EnumFlowerStage.POLLEN) ? this.pollenPetal : (flowered ? this.petal[section % this.sections] : this.unflowered[section % this.sections]));
// }
//
// @Override
// public IIcon getVariantIcon(final EnumFlowerStage stage, final boolean flowered, final int section) {
// return (stage == EnumFlowerStage.SEED) ? this.seedVariant : ((stage == EnumFlowerStage.POLLEN) ? this.pollenVariant : (flowered ? this.variant[section % this.sections] : this.blank));
// }
//
// public void registerIcons(final IIconRegister register) {
// for (int i = 0; i < this.sections; ++i) {
// final String suf = (i == 0) ? "" : ("" + (i + 1));
// final String pre = (this.sections == 1) ? "" : "double/";
// this.stem[i] = Botany.proxy.getIcon(register, "flowers/" + pre + this.toString().toLowerCase() + suf + ".0");
// this.petal[i] = Botany.proxy.getIcon(register, "flowers/" + pre + this.toString().toLowerCase() + suf + ".1");
// this.variant[i] = Botany.proxy.getIcon(register, "flowers/" + pre + this.toString().toLowerCase() + suf + ".2");
// this.unflowered[i] = Botany.proxy.getIcon(register, "flowers/" + pre + this.toString().toLowerCase() + suf + ".3");
// }
// this.blank = Botany.proxy.getIcon(register, "flowers/blank");
// this.seedStem = Botany.proxy.getIcon(register, "flowers/seed.0");
// this.seedPetal = Botany.proxy.getIcon(register, "flowers/seed.1");
// this.seedVariant = Botany.proxy.getIcon(register, "flowers/seed.2");
// this.pollenStem = Botany.proxy.getIcon(register, "flowers/pollen.0");
// this.pollenPetal = Botany.proxy.getIcon(register, "flowers/pollen.1");
// this.pollenVariant = Botany.proxy.getIcon(register, "flowers/pollen.2");
// }
/* @SideOnly(Side.CLIENT)
public void registerModel(Item item, IModelManager manager){
@Override
@SideOnly(Side.CLIENT)
public void registerModels(Item item, IModelManager manager, EnumFlowerStage type){
for (int i = 0; i < this.sections; ++i) {
final String suf = (i == 0) ? "" : ("" + (i + 1));
final String pre = (this.sections == 1) ? "" : "double/";
this.stem[i] = Botany.proxy.getIcon(register, "flowers/" + pre + this.toString().toLowerCase() + suf + ".0");
this.petal[i] = Botany.proxy.getIcon(register, "flowers/" + pre + this.toString().toLowerCase() + suf + ".1");
this.variant[i] = Botany.proxy.getIcon(register, "flowers/" + pre + this.toString().toLowerCase() + suf + ".2");
this.unflowered[i] = Botany.proxy.getIcon(register, "flowers/" + pre + this.toString().toLowerCase() + suf + ".3");
this.flowered[i] = new ModelResourceLocation(Constants.BOTANY_MOD_ID, "flowers/" + pre + this.toString().toLowerCase() + suf + "_flowered");
this.unflowered[i] = new ModelResourceLocation(Constants.BOTANY_MOD_ID, "flowers/" + pre + this.toString().toLowerCase() + suf + "_unflowered");
}
this.blank = Botany.proxy.getIcon(register, "flowers/blank");
this.seedStem = Botany.proxy.getIcon(register, "flowers/seed.0");
this.seedPetal = Botany.proxy.getIcon(register, "flowers/seed.1");
this.seedVariant = Botany.proxy.getIcon(register, "flowers/seed.2");
this.pollenStem = Botany.proxy.getIcon(register, "flowers/pollen.0");
this.pollenPetal = Botany.proxy.getIcon(register, "flowers/pollen.1");
this.pollenVariant = Botany.proxy.getIcon(register, "flowers/pollen.2");
}*/
this.seed = new ModelResourceLocation(Constants.BOTANY_MOD_ID, "flowers/seed");
this.pollen = new ModelResourceLocation(Constants.BOTANY_MOD_ID, "flowers/pollen");
}
@SideOnly(Side.CLIENT)
@Override
public ModelResourceLocation getModel(EnumFlowerStage type, boolean flowered, int section) {
if(type == EnumFlowerStage.SEED){
return seed;
}else if(type == EnumFlowerStage.POLLEN){
return pollen;
}else{
if(flowered){
return this.flowered[section % this.sections];
}else{
return unflowered[section % this.sections];
}
}
}
@Override
public int getID() {
@@ -141,14 +114,10 @@ public enum EnumFlowerType implements IFlowerType {
public int getSections() {
return this.sections;
}
@Override
public void registerModels(Item item, IModelManager manager, EnumFlowerStage type) {
}
@Override
public ModelResourceLocation getModel(EnumFlowerStage type) {
return null;
public String getName() {
return name().toLowerCase(Locale.ENGLISH);
}
// public IIcon getBlank() {
@@ -9,6 +9,8 @@ import forestry.core.genetics.alleles.AlleleHelper;
import forestry.core.genetics.alleles.EnumAllele;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -963,7 +965,7 @@ public enum FlowerDefinition implements IFlowerDefinition {
}
FlowerDefinition(final String name, final String branch, final String binomial, final IFlowerType flowerType, final boolean isDominant, final EnumFlowerColor primaryColor, final EnumFlowerColor secondaryColor) {
String uid = Constants.CORE_MOD_ID + ".flower" + this;
String uid = Constants.BOTANY_MOD_ID + ".flower" + this;
String unlocalizedDescription = "botany.description.flower" + this;
String unlocalizedName = "botany.flowers.species." + name;
@@ -1045,6 +1047,11 @@ public enum FlowerDefinition implements IFlowerDefinition {
return BotanyCore.getFlowerRoot().getMemberStack(flower, flowerStage);
}
public static void preInitFlowers(){
MinecraftForge.EVENT_BUS.post(new AlleleSpeciesRegisterEvent(FlowerManager.flowerRoot));
}
public static void initFlowers() {
for (FlowerDefinition flower : values()) {
flower.init();
@@ -6,6 +6,7 @@ import binnie.botany.core.BotanyCore;
import forestry.api.core.EnumTemperature;
import forestry.api.genetics.*;
import forestry.core.genetics.Genome;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class FlowerGenome extends Genome implements IFlowerGenome {
@@ -16,6 +17,19 @@ public class FlowerGenome extends Genome implements IFlowerGenome {
public FlowerGenome(final IChromosome[] chromosomes) {
super(chromosomes);
}
public static IAlleleFlowerSpecies getSpecies(ItemStack itemStack) {
if (!FlowerManager.flowerRoot.isMember(itemStack)) {
return null;
}
IAlleleSpecies species = getSpeciesDirectly(FlowerManager.flowerRoot, itemStack);
if (species instanceof IAlleleFlowerSpecies) {
return (IAlleleFlowerSpecies) species;
}
return (IAlleleFlowerSpecies) getActiveAllele(itemStack, EnumFlowerChromosome.SPECIES, FlowerManager.flowerRoot);
}
@Override
public IAlleleFlowerSpecies getPrimary() {
@@ -2,6 +2,7 @@ package binnie.botany.genetics;
import binnie.Binnie;
import binnie.botany.Botany;
import binnie.botany.api.EnumFlowerStage;
import binnie.botany.core.BotanyCore;
import binnie.botany.flower.*;
import binnie.core.BinnieCore;
@@ -14,6 +15,7 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
@@ -22,17 +24,22 @@ public class ModuleGenetics implements IInitializable {
@Override
public void preInit() {
/* INIT API*/
binnie.botany.api.FlowerManager.flowerFactory = new FlowerFactory();
EnumFlowerColor.setupMutations();
Botany.flower = new BlockFlower();
Botany.flowerItem = new ItemFlower();
Botany.pollen = new ItemPollen();
Botany.seed = new ItemSeed();
AlleleManager.alleleRegistry.registerSpeciesRoot(BotanyCore.getFlowerRoot());
AlleleManager.alleleRegistry.registerAllele(ModuleGenetics.alleleEffectNone);
EnumFlowerColor.setupMutations();
FlowerDefinition.preInitFlowers();
Botany.flower = new BlockFlower();
GameRegistry.register(Botany.flower);
GameRegistry.register(new ItemBlock(Botany.flower).setRegistryName(Botany.flower.getRegistryName()));
BinnieCore.proxy.registerTileEntity(TileEntityFlower.class, "botany.tile.flower", null);
//Need we this ?
GameRegistry.register(new ItemBlock(Botany.flower).setRegistryName(Botany.flower.getRegistryName()));
Botany.flowerItem = new ItemBotany("itemFlower", EnumFlowerStage.FLOWER, "");
Botany.pollen = new ItemBotany("pollen", EnumFlowerStage.POLLEN, "Pollen");
Botany.seed = new ItemBotany("seed", EnumFlowerStage.SEED, " Germling");
Botany.database = new ItemDictionary();
Botany.encyclopedia = new ItemEncyclopedia(false);
Botany.encyclopediaIron = new ItemEncyclopedia(true);
@@ -40,23 +47,37 @@ public class ModuleGenetics implements IInitializable {
@Override
public void init() {
for (final EnumFlowerColor color : EnumFlowerColor.values()) {
AlleleManager.alleleRegistry.registerAllele(color.getAllele());
}
EnumFlowerColor.initColours();
FlowerDefinition.initFlowers();
//TODO RENDERING
// RendererBotany.renderID = RenderingRegistry.getNextAvailableRenderId();
BinnieCore.proxy.registerBlockRenderer(new RendererBotany());
}
@Override
public void postInit() {
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(Botany.encyclopedia), "fff", "fbf", "fff", 'f', new ItemStack(Blocks.RED_FLOWER, 1, 32767), 'b', Items.BOOK));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(Botany.encyclopedia), "fff", "fbf", "fff", 'f', new ItemStack(Blocks.YELLOW_FLOWER, 1, 32767), 'b', Items.BOOK));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(Botany.encyclopedia), "fff", "fbf", "fff", 'f', new ItemStack(Botany.flower, 1, 32767), 'b', Items.BOOK));
OreDictionary.registerOre("flower", new ItemStack(Blocks.RED_FLOWER, 1, OreDictionary.WILDCARD_VALUE));
OreDictionary.registerOre("flower", new ItemStack(Blocks.YELLOW_FLOWER, 1, OreDictionary.WILDCARD_VALUE));
OreDictionary.registerOre("flower", new ItemStack(Blocks.DOUBLE_PLANT, 1, 0));
OreDictionary.registerOre("flower", new ItemStack(Blocks.DOUBLE_PLANT, 1, 1));
OreDictionary.registerOre("flower", new ItemStack(Blocks.DOUBLE_PLANT, 1, 4));
OreDictionary.registerOre("flower", new ItemStack(Blocks.DOUBLE_PLANT, 1, 5));
OreDictionary.registerOre("flower", new ItemStack(Botany.flower, 1, OreDictionary.WILDCARD_VALUE));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(Botany.encyclopedia),
"fff",
"fbf",
"fff",
'f', "flower",
'b', Items.BOOK));
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(Botany.encyclopediaIron), new ItemStack(Botany.encyclopedia), "ingotIron"));
FlowerManager.flowerRegistry.registerAcceptableFlower(Botany.flower, "flowersVanilla");
RecipeManagers.carpenterManager.addRecipe(100, Binnie.Liquid.getLiquidStack("water", 2000), null, new ItemStack(Botany.database), "X#X", "YEY", "RDR", '#', Blocks.GLASS_PANE, 'X', Items.GOLD_INGOT, 'Y', Items.GOLD_NUGGET, 'R', Items.REDSTONE, 'D', Items.DIAMOND, 'E', Items.EMERALD);
RecipeManagers.carpenterManager.addRecipe(100, Binnie.Liquid.getFluidStack("water", 2000), null, new ItemStack(Botany.database),
"X#X",
"YEY",
"RDR",
'#', Blocks.GLASS_PANE,
'X', Items.GOLD_INGOT,
'Y', Items.GOLD_NUGGET,
'R', Items.REDSTONE,
'D', Items.DIAMOND,
'E', Items.EMERALD);
}
}
@@ -16,6 +16,11 @@ public class MessageFlowerUpdate extends MessageCoordinates {
super(PacketID.FlowerUpdate.ordinal(), posX, posY, posZ);
this.render = render;
}
@Override
public MessageBinnie GetMessage() {
return super.GetMessage();
}
public MessageFlowerUpdate(final MessageBinnie message) {
super(message);
@@ -0,0 +1,50 @@
package binnie.botany.network;
import java.io.IOException;
import binnie.botany.flower.TileEntityFlower;
import binnie.botany.genetics.EnumFlowerColor;
import binnie.botany.genetics.EnumFlowerType;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.util.math.BlockPos;
public class PacketFlowerUpdate extends SPacketUpdateTileEntity {
public TileEntityFlower.RenderInfo render;
public PacketFlowerUpdate(BlockPos blockPos, int metadata, NBTTagCompound compound, final TileEntityFlower.RenderInfo render) {
super(blockPos, metadata, compound);
this.render = render;
}
@Override
public void readPacketData(PacketBuffer buf) throws IOException {
super.readPacketData(buf);
this.render = new TileEntityFlower.RenderInfo();
this.render.primary = EnumFlowerColor.values()[buf.readByte()];
this.render.secondary = EnumFlowerColor.values()[buf.readByte()];
this.render.stem = EnumFlowerColor.values()[buf.readByte()];
this.render.type = EnumFlowerType.values()[buf.readByte()];
this.render.age = buf.readByte();
this.render.section = buf.readByte();
this.render.wilted = buf.readBoolean();
this.render.flowered = buf.readBoolean();
}
@Override
public void writePacketData(PacketBuffer buf) throws IOException {
super.writePacketData(buf);
buf.writeByte(this.render.primary.getID());
buf.writeByte(this.render.secondary.getID());
buf.writeByte(this.render.stem.getID());
buf.writeByte(this.render.type.ordinal());
buf.writeByte(this.render.age);
buf.writeByte(this.render.section);
buf.writeBoolean(this.render.wilted);
buf.writeBoolean(this.render.flowered);
}
}
@@ -1,8 +1,6 @@
package binnie.core.block;
import forestry.api.core.IModelBaker;
import forestry.arboriculture.blocks.BlockForestryLeaves;
import forestry.arboriculture.models.ModelLeaves;
import forestry.core.models.ModelBlockCached;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
@@ -47,7 +47,7 @@ public class ItemFluidContainer extends ItemFood {
private FluidStack getLiquid(final ItemStack stack) {
final String liquid = ItemFluidContainer.idToFluid.get(stack.getItemDamage());
return (liquid == null) ? null : Binnie.Liquid.getLiquidStack(liquid, 1000);
return (liquid == null) ? null : Binnie.Liquid.getFluidStack(liquid, 1000);
}
// @Override
@@ -36,7 +36,7 @@ public class ManagerLiquid extends ManagerBase {
return bFluid;
}
public FluidStack getLiquidStack(final String name, final int amount) {
public FluidStack getFluidStack(final String name, final int amount) {
return FluidRegistry.getFluidStack(name.toLowerCase(), amount);
}
@@ -12,7 +12,7 @@ public abstract class TankValidator extends Validator<FluidStack> {
private Fluid fluid;
public Basic(final String name) {
this.fluid = Binnie.Liquid.getLiquidStack(name, 1).getFluid();
this.fluid = Binnie.Liquid.getFluidStack(name, 1).getFluid();
}
@Override
@@ -1,8 +1,6 @@
package binnie.core.proxy;
import binnie.Constants;
import binnie.core.machines.RendererMachine;
import binnie.core.machines.TileEntityMachine;
import binnie.core.models.ModelManager;
import binnie.core.resource.BinnieResource;
import binnie.craftgui.resource.minecraft.CraftGUIResourceManager;
@@ -13,7 +13,6 @@ import binnie.extrabees.apiary.machine.AlvearyStimulator;
import forestry.api.core.Tabs;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
@@ -1,6 +1,5 @@
package binnie.extrabees.apiary;
import binnie.core.BinnieCore;
import binnie.core.machines.TileEntityMachine;
import binnie.extrabees.apiary.machine.AlvearyMachine;
import com.mojang.authlib.GameProfile;
@@ -1,11 +1,9 @@
package binnie.extrabees.apiary.machine;
import binnie.core.BinnieCore;
import binnie.core.machines.Machine;
import binnie.core.machines.inventory.ComponentInventorySlots;
import binnie.core.machines.inventory.SlotValidator;
import binnie.core.machines.inventory.ValidatorIcon;
import binnie.core.proxy.BinnieProxy;
import binnie.craftgui.minecraft.IMachineInformation;
import binnie.extrabees.ExtraBees;
import binnie.extrabees.apiary.ComponentBeeModifier;
@@ -103,7 +103,7 @@ public enum ExtraBeeItems implements IItemMisc {
if (woodGear != null) {
gear = new ItemStack(woodGear, 1);
}
RecipeManagers.carpenterManager.addRecipe(100, Binnie.Liquid.getLiquidStack("for.honey", 500), null, ExtraBeeItems.ScentedGear.get(1), " j ", "bgb", " p ", 'j', Mods.Forestry.item("royalJelly"), 'b', Mods.Forestry.item("beeswax"), 'p', Mods.Forestry.item("pollen"), 'g', gear);
RecipeManagers.carpenterManager.addRecipe(100, Binnie.Liquid.getFluidStack("for.honey", 500), null, ExtraBeeItems.ScentedGear.get(1), " j ", "bgb", " p ", 'j', Mods.Forestry.item("royalJelly"), 'b', Mods.Forestry.item("beeswax"), 'p', Mods.Forestry.item("pollen"), 'g', gear);
}
ExtraBeeItems(final String name, final String iconPath) {
@@ -3,7 +3,6 @@ package binnie.extrabees.core;
import binnie.Binnie;
import binnie.core.IInitializable;
import binnie.extrabees.ExtraBees;
import binnie.genetics.Genetics;
import forestry.api.core.Tabs;
public class ModuleCore implements IInitializable {
@@ -47,7 +47,7 @@ public class ModuleGenetics implements IInitializable {
++ebSpeciesCount;
}
}
RecipeManagers.carpenterManager.addRecipe(100, Binnie.Liquid.getLiquidStack("water", 2000), null, new ItemStack(ExtraBees.dictionary), "X#X", "YEY", "RDR", '#', Blocks.GLASS_PANE, 'X', Items.GOLD_INGOT, 'Y', "ingotTin", 'R', Items.REDSTONE, 'D', Items.DIAMOND, 'E', Items.EMERALD);
RecipeManagers.carpenterManager.addRecipe(100, Binnie.Liquid.getFluidStack("water", 2000), null, new ItemStack(ExtraBees.dictionary), "X#X", "YEY", "RDR", '#', Blocks.GLASS_PANE, 'X', Items.GOLD_INGOT, 'Y', "ingotTin", 'R', Items.REDSTONE, 'D', Items.DIAMOND, 'E', Items.EMERALD);
}
public static IGenome getGenome(final IAlleleBeeSpecies allele0) {
@@ -416,7 +416,7 @@ public enum ExtraBeesEffect implements IAlleleBeeEffect {
}
IFluidHandler fluidHandler = TileUtil.getCapability(world, pos, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.UP);
if (fluidHandler != null) {
fluidHandler.fill(Binnie.Liquid.getLiquidStack("water", 100), true);
fluidHandler.fill(Binnie.Liquid.getFluidStack("water", 100), true);
break;
}
break;
@@ -58,7 +58,7 @@ public enum ExtraBeeLiquid implements ILiquidType {
@Override
public FluidStack get(final int amount) {
return Binnie.Liquid.getLiquidStack(this.ident, amount);
return Binnie.Liquid.getFluidStack(this.ident, amount);
}
@Override
@@ -62,7 +62,7 @@ public enum EnumHoneyDrop implements IItemEnum {
}
public void addRecipe() {
final FluidStack liquid = Binnie.Liquid.getLiquidStack(this.liquidName, 200);
final FluidStack liquid = Binnie.Liquid.getFluidStack(this.liquidName, 200);
if (liquid != null) {
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{this.get(1)}, liquid, this.remenant, 100);
}
@@ -36,7 +36,7 @@ public enum EnumPropolis implements IItemEnum {
}
public void addRecipe() {
final FluidStack liquid = Binnie.Liquid.getLiquidStack(this.liquidName, 500);
final FluidStack liquid = Binnie.Liquid.getFluidStack(this.liquidName, 500);
if (liquid != null) {
RecipeManagers.squeezerManager.addRecipe(20, new ItemStack[]{this.get(1)}, liquid, null, 0);
}
@@ -44,7 +44,7 @@ public enum EnumPropolis implements IItemEnum {
@Override
public boolean isActive() {
return this.active && Binnie.Liquid.getLiquidStack(this.liquidName, 100) != null;
return this.active && Binnie.Liquid.getFluidStack(this.liquidName, 100) != null;
}
public static EnumPropolis get(final ItemStack itemStack) {
@@ -3,19 +3,15 @@ package binnie.extrabees.products;
import binnie.core.Mods;
import binnie.extrabees.ExtraBees;
import binnie.extrabees.core.ExtraBeeItems;
import forestry.api.core.IModelManager;
import forestry.api.core.Tabs;
import forestry.core.items.IColoredItem;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.oredict.OreDictionary;
import java.util.Locale;
public class ItemHoneyComb extends ItemProduct implements IColoredItem {
public ItemHoneyComb() {
@@ -1,7 +1,6 @@
package binnie.extrabees.products;
import binnie.core.item.IItemEnum;
import binnie.core.item.IItemMisc;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import net.minecraft.creativetab.CreativeTabs;
@@ -9,7 +8,6 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import java.util.List;
import java.util.Locale;
public class ItemProduct extends Item implements IItemModelRegister {
IItemEnum[] types;
@@ -110,7 +110,7 @@ public enum Alcohol implements IFluidType, ICocktailLiquid {
@Override
public FluidStack get(final int amount) {
return Binnie.Liquid.getLiquidStack(this.getIdentifier(), amount);
return Binnie.Liquid.getFluidStack(this.getIdentifier(), amount);
}
@Override
@@ -99,7 +99,7 @@ public enum Juice implements IFluidType, ICocktailLiquid {
@Override
public FluidStack get(final int amount) {
return Binnie.Liquid.getLiquidStack(this.getIdentifier(), amount);
return Binnie.Liquid.getFluidStack(this.getIdentifier(), amount);
}
@Override
@@ -99,7 +99,7 @@ public enum Liqueur implements IFluidType, ICocktailLiquid {
@Override
public FluidStack get(final int amount) {
return Binnie.Liquid.getLiquidStack(this.getIdentifier(), amount);
return Binnie.Liquid.getFluidStack(this.getIdentifier(), amount);
}
@Override
@@ -81,7 +81,7 @@ public enum MiscFluid implements IFluidType, ICocktailLiquid {
@Override
public FluidStack get(final int amount) {
return Binnie.Liquid.getLiquidStack(this.getIdentifier(), amount);
return Binnie.Liquid.getFluidStack(this.getIdentifier(), amount);
}
@Override
@@ -87,7 +87,7 @@ public class ModuleAlcohol implements IInitializable {
}
for (final Alcohol alcohol : Alcohol.values()) {
for (final String fermentLiquid : alcohol.fermentationLiquid) {
final FluidStack fluid = Binnie.Liquid.getLiquidStack(fermentLiquid, 5);
final FluidStack fluid = Binnie.Liquid.getFluidStack(fermentLiquid, 5);
if (fluid != null) {
Brewery.addRecipe(fluid, alcohol.get(5));
}
@@ -102,7 +102,7 @@ public enum Spirit implements IFluidType, ICocktailLiquid {
@Override
public FluidStack get(final int amount) {
return Binnie.Liquid.getLiquidStack(this.getIdentifier(), amount);
return Binnie.Liquid.getFluidStack(this.getIdentifier(), amount);
}
@Override
@@ -54,6 +54,6 @@ public class DrinkLiquid implements IDrinkLiquid {
@Override
public FluidStack get(final int amount) {
return Binnie.Liquid.getLiquidStack(this.ident, amount);
return Binnie.Liquid.getFluidStack(this.ident, amount);
}
}
@@ -7,8 +7,6 @@ import binnie.extratrees.block.PlankType;
import forestry.api.core.Tabs;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.item.ItemStack;
public class BlockCarpentry extends BlockDesign {
@@ -61,7 +61,7 @@ public enum ExtraTreeLiquid implements ILiquidType {
@Override
public FluidStack get(final int i) {
return Binnie.Liquid.getLiquidStack(this.ident, i);
return Binnie.Liquid.getFluidStack(this.ident, i);
}
@Override
@@ -126,15 +126,15 @@ public enum Food implements IItemMisc {
}
public void addJuice(final Juice juice, final int time, final int amount, final int mulch) {
RecipeManagers.squeezerManager.addRecipe(time, new ItemStack[]{this.get(1)}, Binnie.Liquid.getLiquidStack("juice", amount), Mods.Forestry.stack("mulch"), mulch);
RecipeManagers.squeezerManager.addRecipe(time, new ItemStack[]{this.get(1)}, Binnie.Liquid.getFluidStack("juice", amount), Mods.Forestry.stack("mulch"), mulch);
}
public void addJuice(final int time, final int amount, final int mulch) {
RecipeManagers.squeezerManager.addRecipe(time, new ItemStack[]{this.get(1)}, Binnie.Liquid.getLiquidStack("juice", amount), Mods.Forestry.stack("mulch"), mulch);
RecipeManagers.squeezerManager.addRecipe(time, new ItemStack[]{this.get(1)}, Binnie.Liquid.getFluidStack("juice", amount), Mods.Forestry.stack("mulch"), mulch);
}
public void addOil(final int time, final int amount, final int mulch) {
RecipeManagers.squeezerManager.addRecipe(time, new ItemStack[]{this.get(1)}, Binnie.Liquid.getLiquidStack("seedoil", amount), Mods.Forestry.stack("mulch"), mulch);
RecipeManagers.squeezerManager.addRecipe(time, new ItemStack[]{this.get(1)}, Binnie.Liquid.getFluidStack("seedoil", amount), Mods.Forestry.stack("mulch"), mulch);
}
public static void registerOreDictionary() {
@@ -127,15 +127,15 @@ public class ModuleItems implements IInitializable {
CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(Food.Papayimar.get(1), minium, "cropPapaya"));
} catch (Exception ex) {
}
RecipeManagers.carpenterManager.addRecipe(100, Binnie.Liquid.getLiquidStack("water", 2000), null, new ItemStack(ExtraTrees.itemDictionary), "X#X", "YEY", "RDR", '#', Blocks.GLASS_PANE, 'X', Items.GOLD_INGOT, 'Y', "ingotCopper", 'R', Items.REDSTONE, 'D', Items.DIAMOND, 'E', Items.EMERALD);
RecipeManagers.carpenterManager.addRecipe(100, Binnie.Liquid.getLiquidStack("water", 2000), null, new ItemStack(ExtraTrees.itemDictionaryLepi), "X#X", "YEY", "RDR", '#', Blocks.GLASS_PANE, 'X', Items.GOLD_INGOT, 'Y', "ingotBronze", 'R', Items.REDSTONE, 'D', Items.DIAMOND, 'E', Items.EMERALD);
RecipeManagers.carpenterManager.addRecipe(100, Binnie.Liquid.getFluidStack("water", 2000), null, new ItemStack(ExtraTrees.itemDictionary), "X#X", "YEY", "RDR", '#', Blocks.GLASS_PANE, 'X', Items.GOLD_INGOT, 'Y', "ingotCopper", 'R', Items.REDSTONE, 'D', Items.DIAMOND, 'E', Items.EMERALD);
RecipeManagers.carpenterManager.addRecipe(100, Binnie.Liquid.getFluidStack("water", 2000), null, new ItemStack(ExtraTrees.itemDictionaryLepi), "X#X", "YEY", "RDR", '#', Blocks.GLASS_PANE, 'X', Items.GOLD_INGOT, 'Y', "ingotBronze", 'R', Items.REDSTONE, 'D', Items.DIAMOND, 'E', Items.EMERALD);
RecipeManagers.stillManager.addRecipe(25, ExtraTreeLiquid.Resin.get(5), ExtraTreeLiquid.Turpentine.get(3));
RecipeManagers.carpenterManager.addRecipe(25, ExtraTreeLiquid.Turpentine.get(50), null, ((ItemMisc) ExtraTrees.itemMisc).getStack(ExtraTreeItems.WoodWax, 4), "x", 'x', Mods.Forestry.stack("beeswax"));
if (Binnie.Liquid.getLiquidStack("Creosote Oil", 100) != null) {
RecipeManagers.carpenterManager.addRecipe(25, Binnie.Liquid.getLiquidStack("Creosote Oil", 50), null, ((ItemMisc) ExtraTrees.itemMisc).getStack(ExtraTreeItems.WoodWax, 1), "x", 'x', Mods.Forestry.stack("beeswax"));
if (Binnie.Liquid.getFluidStack("Creosote Oil", 100) != null) {
RecipeManagers.carpenterManager.addRecipe(25, Binnie.Liquid.getFluidStack("Creosote Oil", 50), null, ((ItemMisc) ExtraTrees.itemMisc).getStack(ExtraTreeItems.WoodWax, 1), "x", 'x', Mods.Forestry.stack("beeswax"));
}
for (final FluidContainerRegistry.FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) {
if (data.fluid.isFluidEqual(Binnie.Liquid.getLiquidStack("water", 0)) && data.fluid.amount == 1000) {
if (data.fluid.isFluidEqual(Binnie.Liquid.getFluidStack("water", 0)) && data.fluid.amount == 1000) {
CraftingManager.getInstance().addRecipe(Mods.Forestry.stack("mulch"), " b ", "bwb", " b ", 'b', ExtraTreeItems.Bark.get(1), 'w', data.filledContainer.copy());
}
}
@@ -461,7 +461,7 @@ public class Brewery {
this.grainCrops.put(stack, grainType);
}
}
this.water = Binnie.Liquid.getLiquidStack("water", 5);
this.water = Binnie.Liquid.getFluidStack("water", 5);
this.hops = OreDictionary.getOres("cropHops").get(0);
this.add(Alcohol.Ale);
this.add(Alcohol.Lager);
@@ -74,7 +74,7 @@ public enum GeneticLiquid implements IFluidType {
@Override
public FluidStack get(final int amount) {
return Binnie.Liquid.getLiquidStack(this.getIdentifier(), amount);
return Binnie.Liquid.getFluidStack(this.getIdentifier(), amount);
}
@Override
@@ -120,7 +120,7 @@ public class ModuleItem implements IInitializable {
'c', GeneticsItems.IntegratedCircuit.get(itemGenetics, 1), 'd', Items.DIAMOND));
RecipeManagers.carpenterManager.addRecipe(100, Binnie.Liquid.getLiquidStack("water", 2000), null,
RecipeManagers.carpenterManager.addRecipe(100, Binnie.Liquid.getFluidStack("water", 2000), null,
new ItemStack(Genetics.database),
"X#X", "YEY", "RDR",
'#', Blocks.GLASS_PANE, 'X', Items.DIAMOND, 'Y', Items.DIAMOND, 'R', Items.REDSTONE, 'D', Items.ENDER_EYE, 'E', Blocks.OBSIDIAN);
@@ -41,7 +41,7 @@ public class Incubator {
private static List<IIncubatorRecipe> RECIPES = new ArrayList<>();
public static void addRecipes() {
Incubator.RECIPES.add(new IncubatorRecipe(GeneticsItems.GrowthMedium.get(1), Binnie.Liquid.getLiquidStack("water", 25), GeneticLiquid.GrowthMedium.get(25), 0.2f));
Incubator.RECIPES.add(new IncubatorRecipe(GeneticsItems.GrowthMedium.get(1), Binnie.Liquid.getFluidStack("water", 25), GeneticLiquid.GrowthMedium.get(25), 0.2f));
Incubator.RECIPES.add(new IncubatorRecipe(new ItemStack(Items.WHEAT), GeneticLiquid.GrowthMedium.get(25), GeneticLiquid.Bacteria.get(5), 0.2f));
Incubator.RECIPES.add(new IncubatorRecipe(GeneticsItems.GrowthMedium.get(1), GeneticLiquid.Bacteria.get(0), GeneticLiquid.Bacteria.get(5), 0.05f));
Incubator.RECIPES.add(new IncubatorRecipe(new ItemStack(Items.SUGAR), GeneticLiquid.Bacteria.get(2), null, 0.5f, 0.2f)