Merge branch 'mc-1.12' of https://github.com/ForestryMC/ForestryMC into Greenhouse

This commit is contained in:
Nedelosk committed 2017-09-08 22:48:31 +02:00
1 parent 888c5268d5
commit 095e710bec
16 files changed
+96 -73

No files matched your search

@@ -9,18 +9,20 @@ import javax.annotation.Nullable;
import java.util.List;
import java.util.Set;
import forestry.api.core.IErrorState;
import forestry.api.genetics.IEffectData;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IIndividualLiving;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.IErrorState;
import forestry.api.genetics.IEffectData;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IIndividualLiving;
/**
* Other implementations than Forestry's default one are not supported.
*
@@ -95,7 +97,8 @@ public interface IBee extends IIndividualLiving {
/**
* Plants a random flower from the given list near the housing
* @param housing the location the bee is living
*
* @param housing the location the bee is living
* @param potentialFlowers the flowers to choose from
* @return the position of the planted flower, or null of none were planted
* @since Forestry 5.5.4
@@ -8,16 +8,18 @@ package forestry.api.apiculture;
import java.io.IOException;
import java.util.List;
import forestry.api.core.INbtReadable;
import forestry.api.core.INbtWritable;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.INbtReadable;
import forestry.api.core.INbtWritable;
/**
* Stores beekeeping logic for bee housings.
* Get one with BeeManager.beeRoot.createBeekeepingLogic(IBeeHousing housing)
@@ -23,9 +23,10 @@ public interface IFlowerGrowthHelper {
/**
* Plants a random flower from flowerType at the specified position.
* @param flowerType the flower type that can be planted
* @param world the world to plant flowers in
* @param pos the position to plant the flowers
*
* @param flowerType the flower type that can be planted
* @param world the world to plant flowers in
* @param pos the position to plant the flowers
* @param potentialFlowers the potential flowers that can be planted
* @return true if a flower was planted, false otherwise
* @since Forestry 5.5.4
@@ -9,14 +9,15 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.core.IBlockPosPredicate;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.core.IBlockPosPredicate;
// See {@link forestry.api.apiculture.FlowerManager}.FlowerType___ for basic Forestry flower types.
// Each IFlowerProvider has one flower type, and multiple IFlowerProviders may share one type.
// "Acceptable flowers" allow nearby bees to do work.
@@ -101,6 +102,7 @@ public interface IFlowerRegistry {
/**
* Calls the appropriate IFlowerGrowthRule to grow a flower at a specified position.
*
* @deprecated since Forestry 5.5.4. Use {@link #growFlower(String, World, IIndividual, BlockPos, Collection)}
*/
@Deprecated
@@ -10,6 +10,8 @@
******************************************************************************/
package forestry.apiculture;
import com.google.common.base.Preconditions;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.ArrayList;
@@ -19,7 +21,21 @@ import java.util.List;
import java.util.Set;
import java.util.Stack;
import com.google.common.base.Preconditions;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IApiaristTracker;
@@ -40,19 +56,6 @@ import forestry.core.config.Constants;
import forestry.core.errors.EnumErrorCode;
import forestry.core.utils.Log;
import forestry.core.utils.NetworkUtil;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BeekeepingLogic implements IBeekeepingLogic {
@@ -17,15 +17,6 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import forestry.api.apiculture.FlowerManager;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.core.INbtReadable;
import forestry.api.core.INbtWritable;
import forestry.api.core.IBlockPosPredicate;
import forestry.api.genetics.IFlowerProvider;
import forestry.core.utils.TickHelper;
import net.minecraft.block.state.IBlockState;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer;
@@ -33,6 +24,16 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.World;
import forestry.api.apiculture.FlowerManager;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.core.IBlockPosPredicate;
import forestry.api.core.INbtReadable;
import forestry.api.core.INbtWritable;
import forestry.api.genetics.IFlowerProvider;
import forestry.core.utils.TickHelper;
public class HasFlowersCache implements INbtWritable, INbtReadable {
private static final String NBT_KEY = "hasFlowerCache";
private static final String NBT_KEY_FLOWERS = "flowers";
@@ -117,7 +118,7 @@ public class HasFlowersCache implements INbtWritable, INbtReadable {
IBeeGenome genome = queen.getGenome();
String flowerType = genome.getFlowerProvider().getFlowerType();
if (!this.flowerData.flowerType.equals(flowerType)
|| !this.flowerData.territory.equals(genome.getTerritory())) {
|| !this.flowerData.territory.equals(genome.getTerritory())) {
flowerData = new FlowerData(queen, housing);
flowerCoords.clear();
flowers.clear();
@@ -13,6 +13,16 @@ package forestry.apiculture;
import java.io.IOException;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeekeepingLogic;
import forestry.api.genetics.IEffectData;
@@ -20,14 +30,6 @@ import forestry.apiculture.network.packets.PacketBeeLogicActive;
import forestry.apiculture.tiles.TileHive;
import forestry.core.utils.NetworkUtil;
import forestry.core.utils.TickHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class WorldgenBeekeepingLogic implements IBeekeepingLogic {
private final TileHive housing;
@@ -10,6 +10,10 @@
******************************************************************************/
package forestry.apiculture.flowers;
import com.google.common.base.Preconditions;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.HashMultimap;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collection;
@@ -21,9 +25,13 @@ import java.util.Map;
import java.util.Random;
import java.util.Set;
import com.google.common.base.Preconditions;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.HashMultimap;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.World;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.FlowerManager;
import forestry.api.apiculture.IBee;
@@ -39,12 +47,6 @@ import forestry.api.genetics.IIndividual;
import forestry.core.utils.BlockStateSet;
import forestry.core.utils.VectUtil;
import forestry.core.utils.WeightedCollection;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.World;
public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelper {
private final HashMultimap<String, IFlowerAcceptableRule> registeredRules;
@@ -12,27 +12,28 @@ package forestry.apiculture.flowers;
import java.util.Collection;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
public class GrowthRuleDirtGrass implements IFlowerGrowthRule {
@Override
@Deprecated
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, BlockPos pos) {
return isValidSpot(world, pos) &&
helper.plantRandomFlower(flowerType, world, pos);
helper.plantRandomFlower(flowerType, world, pos);
}
@Override
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, BlockPos pos, Collection<IBlockState> potentialFlowers) {
return isValidSpot(world, pos) &&
helper.plantRandomFlower(flowerType, world, pos, potentialFlowers);
helper.plantRandomFlower(flowerType, world, pos, potentialFlowers);
}
private boolean isValidSpot(World world, BlockPos pos) {
@@ -14,13 +14,14 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
public class GrowthRuleFertilize implements IFlowerGrowthRule {
private final List<Block> allowedItems;
@@ -12,27 +12,28 @@ package forestry.apiculture.flowers;
import java.util.Collection;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
public class GrowthRuleMycelium implements IFlowerGrowthRule {
@Override
@Deprecated
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, BlockPos pos) {
return isValidSpot(world, pos) &&
helper.plantRandomFlower(flowerType, world, pos);
helper.plantRandomFlower(flowerType, world, pos);
}
@Override
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, BlockPos pos, Collection<IBlockState> potentialFlowers) {
return isValidSpot(world, pos) &&
helper.plantRandomFlower(flowerType, world, pos, potentialFlowers);
helper.plantRandomFlower(flowerType, world, pos, potentialFlowers);
}
private boolean isValidSpot(World world, BlockPos pos) {
@@ -12,12 +12,13 @@ package forestry.apiculture.flowers;
import java.util.Collection;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
public class GrowthRuleNone implements IFlowerGrowthRule {
@Override
@@ -12,27 +12,28 @@ package forestry.apiculture.flowers;
import java.util.Collection;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
public class GrowthRuleSnow implements IFlowerGrowthRule {
@Override
@Deprecated
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, BlockPos pos) {
return isValidSpot(world, pos) &&
helper.plantRandomFlower(flowerType, world, pos);
helper.plantRandomFlower(flowerType, world, pos);
}
@Override
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, BlockPos pos, Collection<IBlockState> potentialFlowers) {
return isValidSpot(world, pos) &&
helper.plantRandomFlower(flowerType, world, pos, potentialFlowers);
helper.plantRandomFlower(flowerType, world, pos, potentialFlowers);
}
private boolean isValidSpot(World world, BlockPos pos) {
@@ -33,9 +33,10 @@ import net.minecraft.world.gen.structure.StructureBoundingBox;
import net.minecraft.world.gen.structure.StructureComponent;
import net.minecraft.world.gen.structure.StructureVillagePieces;
import net.minecraftforge.registries.ForgeRegistry;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.fml.common.registry.VillagerRegistry;
import net.minecraftforge.registries.ForgeRegistry;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeType;
@@ -1,5 +1,7 @@
package forestry.core.utils;
import com.google.common.base.Preconditions;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.Map;
@@ -8,8 +10,6 @@ import java.util.Random;
import java.util.Set;
import java.util.TreeMap;
import com.google.common.base.Preconditions;
public class WeightedCollection<T> {
private final NavigableMap<Double, T> map = new TreeMap<>();
private double total = 0;
@@ -23,6 +23,7 @@ import net.minecraft.world.gen.feature.WorldGenMinable;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.terraingen.DecorateBiomeEvent;
import net.minecraftforge.event.terraingen.PopulateChunkEvent;
import net.minecraftforge.fml.common.IWorldGenerator;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;