public static boolean canBlockStay(IBlockAccess world, BlockPos pos) { TileSapling tile = TileUtil.getTile(world, pos, TileSapling.class); if (tile == null) { return false; } ITree tree = tile.getTree(); return tree != null && tree.canStay(world, pos); }
@Override public void mate(ITree other) { mate = new TreeGenome(other.getGenome().getChromosomes()); }
@Nullable @Override public final AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) { ITree tree = getTree(worldIn, pos); if (tree != null && TreeDefinition.Willow.getUID().equals(tree.getIdent())) { return null; } return super.getCollisionBoundingBox(blockState, worldIn, pos); }
private static int getRequiredMaturity(World world, ITree tree) { ITreekeepingMode treekeepingMode = TreeManager.treeRoot.getTreekeepingMode(world); float maturationModifier = treekeepingMode.getMaturationModifier(tree.getGenome(), 1f); return Math.round(tree.getRequiredMaturity() * maturationModifier); }
@Override protected void getLeafDrop(NonNullList<ItemStack> drops, World world, @Nullable GameProfile playerProfile, BlockPos pos, float saplingModifier, int fortune) { ITree tree = getTree(world, pos); if (tree == null) { return; } // Add saplings List<ITree> saplings = tree.getSaplings(world, playerProfile, pos, saplingModifier); for (ITree sapling : saplings) { if (sapling != null) { drops.add(TreeManager.treeRoot.getMemberStack(sapling, EnumGermlingType.SAPLING)); } } // Add fruitsk ITreeGenome genome = tree.getGenome(); IFruitProvider fruitProvider = genome.getFruitProvider(); if (fruitProvider.isFruitLeaf(genome, world, pos)) { NonNullList<ItemStack> produceStacks = tree.produceStacks(world, pos, Integer.MAX_VALUE); drops.addAll(produceStacks); } }
@Override public boolean generate(World worldIn, Random rand, BlockPos position) { this.world = worldIn; this.startX = position.getX(); this.startY = position.getY(); this.startZ = position.getZ(); this.girth = this.tree.getGirth(); this.height = (int) (this.randBetween(this.getHeight()[0], this.getHeight()[1]) * this.tree.getGenome().getHeight()); if (this.tree.canGrow(world, position, this.girth, this.height) != null) { this.generate(); return true; } return false; }
@Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack mainHand = player.getHeldItem(EnumHand.MAIN_HAND); ItemStack offHand = player.getHeldItem(EnumHand.OFF_HAND); if (mainHand.isEmpty() && offHand.isEmpty()) { ITree tree = getTree(world, pos); if (tree == null) { return false; } IFruitProvider fruitProvider = tree.getGenome().getFruitProvider(); NonNullList<ItemStack> products = tree.produceStacks(world, pos, fruitProvider.getRipeningPeriod()); world.setBlockState(pos, ModuleArboriculture.getBlocks().getDefaultLeaves(tree.getIdent()), 2); for (ItemStack fruit : products) { ItemHandlerHelper.giveItemToPlayer(player, fruit); } return true; } return false; }
public AnalystPageFruit(IWidget parent, IArea area, ITree ind, IAnalystManager analystManager) { super(parent, area); setColor(13382400); ITreeGenome genome = ind.getGenome(); int y = 4; new ControlTextCentered(this, y, TextFormatting.UNDERLINE + getTitle()).setColor(getColor()); y += 12; IBreedingSystem treeSystem = Binnie.GENETICS.getSystem(TreeManager.treeRoot); String yieldAlleleName = treeSystem.getAlleleName(EnumTreeChromosome.YIELD, ind.getGenome().getActiveAllele(EnumTreeChromosome.YIELD)); new ControlTextCentered(this, y, TextFormatting.ITALIC + I18N.localise(AnalystConstants.FRUIT_KEY + ".yield") + ": " + yieldAlleleName).setColor(getColor()); y += 20; Collection<ItemStack> specialties = new UniqueItemStackSet(); Collection<ItemStack> wiid = new UniqueItemStackSet(); products.addAll(ind.getProducts().keySet()); specialties.addAll(ind.getSpecialties().keySet()); try { if (ind.getGenome().getFruitProvider() instanceof FruitProviderPod) { FruitProviderPod pod = (FruitProviderPod) ind.getGenome().getFruitProvider(); Field f = FruitProviderPod.class.getDeclaredField("drops"); f.setAccessible(true); y += 12; Collection<IAllele> fruitAlleles = Binnie.GENETICS.getChromosomeMap(TreeManager.treeRoot).get(EnumTreeChromosome.FRUITS); for (IFruitFamily fam : ind.getGenome().getPrimary().getSuitableFruit()) { Collection<ItemStack> stacks = new UniqueItemStackSet(); for (IAllele a : fruitAlleles) {
@Override protected void getLeafDrop(NonNullList<ItemStack> drops, World world, @Nullable GameProfile playerProfile, BlockPos pos, float saplingModifier, int fortune) { TileLeaves tile = TileUtil.getTile(world, pos, TileLeaves.class); if (tile == null) { return; } ITree tree = tile.getTree(); if (tree == null) { return; } // Add saplings List<ITree> saplings = tree.getSaplings(world, playerProfile, pos, saplingModifier); for (ITree sapling : saplings) { if (sapling != null) { drops.add(TreeManager.treeRoot.getMemberStack(sapling, EnumGermlingType.SAPLING)); } } // Add fruits if (tile.hasFruit()) { drops.addAll(tree.produceStacks(world, pos, tile.getRipeningTime())); } }
@Override public void setTree(ITree tree) { ITree oldTree = getTree(); super.setTree(tree); ITreeGenome genome = tree.getGenome(); species = genome.getPrimary(); if (oldTree != null && !tree.equals(oldTree)) { checkFruit = true; } if (tree.canBearFruit() && checkFruit && world != null && !world.isRemote) { IFruitProvider fruitProvider = genome.getFruitProvider(); if (fruitProvider.isFruitLeaf(genome, world, getPos())) { isFruitLeaf = fruitProvider.getFruitChance(genome, world, getPos()) >= world.rand.nextFloat(); } } if (isFruitLeaf) { IFruitProvider fruitProvider = genome.getFruitProvider(); if (world != null && world.isRemote) { fruitSprite = fruitProvider.getSprite(genome, world, getPos(), getRipeningTime()); } ripeningPeriod = (short) tree.getGenome().getFruitProvider().getRipeningPeriod(); } else if (world != null && world.isRemote) { fruitSprite = null; } markDirty(); }
for (ItemStack stack : tree.getProducts().keySet()) { widgetManager.add(new ItemStackWidget(widgetManager, x, textLayout.getLineY(), stack)); x += 18; for (ItemStack stack : tree.getSpecialties().keySet()) { Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(stack, guiAlyzer.getGuiLeft() + x, guiAlyzer.getGuiTop() + textLayout.getLineY()); x += 18;
@Override public boolean plantSapling(World world, ITree tree, GameProfile owner, BlockPos pos) { BlockRegistryArboriculture blocks = ModuleArboriculture.getBlocks(); IBlockState state = blocks.saplingGE.getDefaultState().withProperty(BlockSapling.TREE, tree.getGenome().getPrimary()); boolean placed = world.setBlockState(pos, state); if (!placed) { return false; } IBlockState blockState = world.getBlockState(pos); Block block = blockState.getBlock(); if (blocks.saplingGE != block) { return false; } TileSapling sapling = TileUtil.getTile(world, pos, TileSapling.class); if (sapling == null) { world.setBlockToAir(pos); return false; } sapling.setTree(tree.copy()); sapling.getOwnerHandler().setOwner(owner); PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.SoundFXType.BLOCK_PLACE, pos, blockState); NetworkUtil.sendNetworkPacket(packet, pos, world); return true; }
@Override protected void getLeafDrop(NonNullList<ItemStack> drops, World world, @Nullable GameProfile playerProfile, BlockPos pos, float saplingModifier, int fortune) { ITree tree = getTree(world, pos); if (tree == null) { return; } // Add saplings List<ITree> saplings = tree.getSaplings(world, playerProfile, pos, saplingModifier); for (ITree sapling : saplings) { if (sapling != null) { drops.add(TreeManager.treeRoot.getMemberStack(sapling, EnumGermlingType.SAPLING)); } } }
private Collection<ItemStack> getSpecialties(IIndividual individual) { if (individual instanceof IBee) { IBee bee = (IBee) individual; return bee.getSpecialtyList(); } else if (individual instanceof ITree) { ITree tree = (ITree) individual; return tree.getSpecialties().keySet(); } return Collections.emptyList(); }
private Collection<ItemStack> getProducts(IIndividual individual) { if (individual instanceof IBee) { IBee bee = (IBee) individual; return bee.getProduceList(); } else if (individual instanceof ITree) { ITree tree = (ITree) individual; return tree.getProducts().keySet(); } return Collections.emptyList(); } }
@Override public NonNullList<ItemStack> pickFruit(ItemStack tool) { ITree tree = getTree(); if (tree == null || !hasFruit()) { return NonNullList.create(); } NonNullList<ItemStack> produceStacks = tree.produceStacks(world, getPos(), getRipeningTime()); ripeningTime = 0; sendNetworkUpdateRipening(); return produceStacks; }
@Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack mainHand = player.getHeldItem(EnumHand.MAIN_HAND); ItemStack offHand = player.getHeldItem(EnumHand.OFF_HAND); if (mainHand.isEmpty() && offHand.isEmpty()) { PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.VisualFXType.BLOCK_BREAK, PacketFXSignal.SoundFXType.BLOCK_BREAK, pos, state); NetworkUtil.sendNetworkPacket(packet, pos, world); ITree tree = getTree(world, pos); if (tree == null) { return false; } IFruitProvider fruitProvider = tree.getGenome().getFruitProvider(); NonNullList<ItemStack> products = tree.produceStacks(world, pos, fruitProvider.getRipeningPeriod()); world.setBlockState(pos, ModuleArboriculture.getBlocks().getDefaultLeaves(tree.getIdent()), 2); for (ItemStack fruit : products) { ItemHandlerHelper.giveItemToPlayer(player, fruit); } return true; } return false; }
@Override protected void getLeafDrop(NonNullList<ItemStack> drops, World world, @Nullable GameProfile playerProfile, BlockPos pos, float saplingModifier, int fortune) { ITree tree = getTree(world, pos); if (tree == null) { return; } // Add saplings List<ITree> saplings = tree.getSaplings(world, playerProfile, pos, saplingModifier); for (ITree sapling : saplings) { if (sapling != null) { drops.add(TreeManager.treeRoot.getMemberStack(sapling, EnumGermlingType.SAPLING)); } } // Add fruitsk ITreeGenome genome = tree.getGenome(); IFruitProvider fruitProvider = genome.getFruitProvider(); if (fruitProvider.isFruitLeaf(genome, world, pos)) { NonNullList<ItemStack> produceStacks = tree.produceStacks(world, pos, Integer.MAX_VALUE); drops.addAll(produceStacks); } }
int speciesDominance0 = guiAlyzer.getColorCoding(tree.getGenome().getPrimary().isDominant()); int speciesDominance1 = guiAlyzer.getColorCoding(tree.getGenome().getSecondary().isDominant()); String fireproofActive = StringUtil.readableBoolean(tree.getGenome().getFireproof(), yes, no); String fireproofInactive = StringUtil.readableBoolean(((AlleleBoolean) tree.getGenome().getInactiveAllele(EnumTreeChromosome.FIREPROOF)).getValue(), yes, no); textLayout.drawLine(Translator.translateToLocal("for.gui." + tree.getGenome().getPrimary().getPlantType().toString().toLowerCase(Locale.ENGLISH)), GuiAlyzer.COLUMN_1, speciesDominance0); textLayout.drawLine(Translator.translateToLocal("for.gui." + tree.getGenome().getSecondary().getPlantType().toString().toLowerCase(Locale.ENGLISH)), GuiAlyzer.COLUMN_2, speciesDominance1); List<IFruitFamily> families0 = new ArrayList<>(tree.getGenome().getPrimary().getSuitableFruit()); List<IFruitFamily> families1 = new ArrayList<>(tree.getGenome().getSecondary().getSuitableFruit()); int fruitDominance0 = guiAlyzer.getColorCoding(tree.getGenome().getActiveAllele(EnumTreeChromosome.FRUITS).isDominant()); int fruitDominance1 = guiAlyzer.getColorCoding(tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS).isDominant()); IAllele fruit0 = tree.getGenome().getActiveAllele(EnumTreeChromosome.FRUITS); if (!tree.canBearFruit() && fruit0 != AlleleFruits.fruitNone) { strike = TextFormatting.STRIKETHROUGH.toString(); textLayout.drawLine(strike + tree.getGenome().getFruitProvider().getDescription(), GuiAlyzer.COLUMN_1, fruitDominance0); IAlleleFruit fruit1 = (IAlleleFruit) tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS); if (!tree.getGenome().getSecondary().getSuitableFruit().contains(fruit1.getProvider().getFamily()) && fruit1 != AlleleFruits.fruitNone) { strike = TextFormatting.STRIKETHROUGH.toString(); IFruitFamily primary = tree.getGenome().getFruitProvider().getFamily(); IFruitFamily secondary = ((IAlleleFruit) tree.getGenome().getInactiveAllele(EnumTreeChromosome.FRUITS)).getProvider().getFamily();