Compare commits

..
43 Commits
Author SHA1 Message Date
mezz cc4cc558b8 Fix #893 Shift-Removing items from a machine prefers the hotbar
(cherry picked from commit 099e6f47e8)
2015-10-16 11:56:56 -07:00
mezz 956aaca10c Fix #887 Particles are wrong when breaking wood items
(cherry picked from commit 140643bec3)
2015-10-14 12:21:08 -07:00
mezz 23f7c9c7d9 Bump version to 4.0.10 for 4.0 branch 2015-10-14 01:58:50 -07:00
mezz 3684792a39 Update Lang 2015-10-14 01:52:34 -07:00
mezz 0e81f373f0 Implement a generic ISpeciesType for ISpeciesRoot 2015-10-13 10:28:12 -07:00
mezz 59d1d3456b Fix #888 Squeezer should not work with reusable fluid containers 2015-10-13 08:08:53 -07:00
mezz 15fe11094b Bump version to 4.0.9 2015-10-11 19:04:57 -07:00
mezz 790e9b9fba Fix #883 ExtrabiomesXL saplings not fermenting with Honey 2015-10-11 19:04:16 -07:00
mezz c7ef2ef807 Bump version to 4.0.8 2015-10-11 06:12:17 -07:00
mezz 11fa7bbf75 Add improvements to the flower API 2015-10-11 06:12:17 -07:00
Nirek-K 4c2cbd77c1 Fix #876 Mustard internal naming is failure. 2015-10-11 04:58:45 -05:00
mezz f58de9e5cc Fix #880 Apiarist's chest does not creak when opened 2015-10-10 22:49:32 -07:00
mezz 3f0dc9e74f Fix #881 Update codebase to Java 7 2015-10-10 22:49:09 -07:00
mezz 9ecab0fecd Bump version to 4.0.7 2015-10-06 20:19:28 -07:00
mezz 01245f32c5 Fix #870 Analyzer turns pollen into saplings 2015-10-06 20:18:53 -07:00
mezz 8cc0da5c04 Fix #830 Multifarms do not plant saplings when Arboriculture is disabled 2015-10-05 23:42:00 -07:00
mezz 6e68768259 Fix #865 Farm with multiple gearboxes has "no power" if one has no power 2015-10-05 23:30:46 -07:00
mezz 9ee34b06b6 Remove unused part of NEI Recipe Handler 2015-10-05 22:17:29 -07:00
mezz b05c395300 Fix #867 Custom Forestry recipes not working with NEI [?] button 2015-10-05 22:17:03 -07:00
mezz 48ef020dc9 Fix #868 Last tin can won't be consumed by Farm GUI 2015-10-05 21:59:56 -07:00
mezz 83b7ce00f7 Fix #859 Multi Farm using single tube upgrade cannot set the direction 2015-10-03 22:48:39 -07:00
mezz 6165d80c0c Fix #807 Add direction labels to circuit board for farm configurations 2015-10-03 22:06:50 -07:00
James Mitchell 31cb40f7b6 Update CLA link 2015-10-03 20:35:23 -07:00
mezz 16e4801d48 Bump version to 4.0.6 2015-10-03 13:44:22 -07:00
InfinityRaider 8fb7d5eb67 FlowerRegistry and AgriCraft compatibility update
Add to CLA agreement
2015-10-03 13:35:27 -07:00
mezz 55866d6a64 #830 fix farm crash when Plugin Arboriculture is disabled 2015-10-03 00:51:31 -07:00
mezz 510cf83670 Fix #861 Worktable client crash 2015-10-03 00:28:01 -07:00
mezz 656a6451bf Improve bee complexity calculation by excluding blacklisted mutations 2015-10-03 00:22:59 -07:00
mezz 69ee5bde65 Bump version to 4.0.5 2015-10-03 00:12:26 -07:00
mezz 592895cc48 Add NEI Worktable [?] support and categories from NEI Addons 2015-10-03 00:12:02 -07:00
mezz 7b5febd394 Bump version to 4.0.4 2015-10-01 18:31:23 -07:00
mezz 71481d5ace Add API helpers for using the new IBeeHousing modifiers and listeners 2015-10-01 18:30:28 -07:00
mezz 1d0efd537e Fix #791 *alyzer slot behavior changed. (can't swap specimens) 2015-09-29 22:33:27 -07:00
mezz 5052df8844 Revert "Fix breaking change to the API in IMutation"
This reverts commit f020dcf2e2.
2015-09-29 21:10:11 -07:00
mezz b1d496f24f Fix #858 sometimes can't craft with multiple GregTech tools in Worktable 2015-09-29 21:07:23 -07:00
mezz 2bfe576f7e Bump version to 4.0.3 2015-09-29 15:21:30 -07:00
mezz cc5c8af338 Fix #856 Crash when clicking the fluid slot in NEI squeezer recipe 2015-09-29 15:20:35 -07:00
mezz 19a9c2681c Bump version to 4.0.2 2015-09-29 00:40:19 -07:00
mezz f020dcf2e2 Fix breaking change to the API in IMutation 2015-09-29 00:30:42 -07:00
mezz dd34765223 Bump version to 4.0.1 2015-09-28 23:47:54 -07:00
mezz 3253077466 Fix #854 OpenGL transparency issues 2015-09-28 23:45:18 -07:00
mezz 8743f29613 Fix #851 Add a way to get wood items from the API 2015-09-27 19:35:46 -07:00
mezz 0b6b201366 Fix bug in implementation of tryAddStack 2015-09-26 23:12:11 -07:00
244 changed files with 1867 additions and 1213 deletions

No files matched your search

+1 -1
View File
@@ -31,7 +31,7 @@ Beware of ugly code.
Bugfixes are generally welcome. If you want to contribute something which changes game mechanics, please talk to someone with commit privileges first. Nothing is more frustrating than putting a lot of work and effort into a new game mechanic and then having the PR rejected because it doesn’t fit gameplay-wise.
**If you submit a PR you must accept the [Contributor License Agreement](https://www.clahub.com/agreements/ForestryMC/ForestryMC). There is no way around that, since otherwise changing the license later - even to something more permissive! - , becomes close to impossible.**
**If you submit a PR you must accept the [Contributor License Agreement](https://cla-assistant.io/ForestryMC/ForestryMC). There is no way around that, since otherwise changing the license later - even to something more permissive! - , becomes close to impossible.**
### License & Copyright
+1 -1
View File
@@ -2,4 +2,4 @@ mcversion=1.7.10
forgeversion=10.13.3.1370-1.7.10
version_major=4
version_minor=0
version_patch=0
version_patch=10
+4
View File
@@ -36,6 +36,10 @@ ext.dirLang = "./lang"
ext.apiForestry = "./api/forestry"
ext.apiRedstoneFlux = "./api/redstoneflux"
// java version
sourceCompatibility = 1.7
targetCompatibility = 1.7
minecraft {
version = mcversion + "-" + forgeversion
runDir = "run"
+1
View File
@@ -3,3 +3,4 @@ samtrion;[email protected];2015-01-18
GenuineSounds;[email protected];2015-02-26
airbreather;[email protected];2015-04-10
ganymedes01;[email protected];2015-05-27
infinityraider;theoneandonlyraider@gmail;com;2015-10-03
+1 -1
Submodule lang updated: 2518a210e7...2843053395.
+7 -7
View File
@@ -70,7 +70,7 @@ public class Forestry {
public static Forestry instance;
private File configFolder;
private static final Map<String, ForestryItem> mappedItems = new HashMap<String, ForestryItem>();
private static final Map<String, ForestryItem> mappedItems = new HashMap<>();
static {
mappedItems.put("Forestry:builderBackpack", ForestryItem.builderBackpack);
@@ -87,12 +87,12 @@ public class Forestry {
}
public Forestry() {
FuelManager.fermenterFuel = new ItemStackMap<FermenterFuel>();
FuelManager.moistenerResource = new ItemStackMap<MoistenerFuel>();
FuelManager.rainSubstrate = new ItemStackMap<RainSubstrate>();
FuelManager.bronzeEngineFuel = new FluidMap<EngineBronzeFuel>();
FuelManager.copperEngineFuel = new ItemStackMap<EngineCopperFuel>();
FuelManager.generatorFuel = new FluidMap<GeneratorFuel>();
FuelManager.fermenterFuel = new ItemStackMap<>();
FuelManager.moistenerResource = new ItemStackMap<>();
FuelManager.rainSubstrate = new ItemStackMap<>();
FuelManager.bronzeEngineFuel = new FluidMap<>();
FuelManager.copperEngineFuel = new ItemStackMap<>();
FuelManager.generatorFuel = new FluidMap<>();
}
@SidedProxy(clientSide = "forestry.core.ForestryClient", serverSide = "forestry.core.ForestryCore")
@@ -60,7 +60,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
private int queenWorkCycleThrottle;
private IEffectData effectData[] = new IEffectData[2];
private final Stack<ItemStack> spawn = new Stack<ItemStack>();
private final Stack<ItemStack> spawn = new Stack<>();
private final HasFlowersCache hasFlowersCache = new HasFlowersCache();
private final QueenCanWorkCache queenCanWorkCache = new QueenCanWorkCache();
@@ -73,8 +73,8 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
public BeekeepingLogic(IBeeHousing housing) {
this.housing = housing;
this.beeModifier = new BeeHousingModifier(housing);
this.beeListener = new BeeHousingListener(housing);
this.beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
this.beeListener = BeeManager.beeRoot.createBeeHousingListener(housing);
}
// / SAVING & LOADING
@@ -112,7 +112,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
hasFlowersCache.writeToNBT(nbttagcompound);
Stack<ItemStack> spawnCopy = new Stack<ItemStack>();
Stack<ItemStack> spawnCopy = new Stack<>();
spawnCopy.addAll(spawn);
NBTTagList nbttaglist = new NBTTagList();
while (!spawnCopy.isEmpty()) {
@@ -373,7 +373,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
World world = beeHousing.getWorld();
Stack<ItemStack> offspring = new Stack<ItemStack>();
Stack<ItemStack> offspring = new Stack<>();
IApiaristTracker breedingTracker = BeeManager.beeRoot.getBreedingTracker(world, beeHousing.getOwner());
// Princess
@@ -399,7 +399,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
IBeeHousingInventory beeInventory = beeHousing.getBeeInventory();
Collection<ItemStack> spawn = new ArrayList<ItemStack>();
Collection<ItemStack> spawn = new ArrayList<>();
while (!offspring.isEmpty()) {
ItemStack spawned = offspring.pop();
@@ -72,7 +72,7 @@ public class BlockAlveary extends BlockStructure {
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
ArrayList<ItemStack> drop = new ArrayList<ItemStack>();
ArrayList<ItemStack> drop = new ArrayList<>();
drop.add(new ItemStack(this, 1, metadata != 1 ? metadata : 0));
return drop;
}
@@ -83,7 +83,7 @@ public class BlockBeehives extends BlockContainer {
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
ArrayList<ItemStack> ret = new ArrayList<>();
// Handle legacy block
if (metadata == 0) {
@@ -75,7 +75,7 @@ public class BlockCandle extends BlockTorch {
.put("dyeBlack", new Color(20, 20, 20).getRGB())
.build();
lightingItems = new HashSet<Item>(Arrays.asList(
lightingItems = new HashSet<>(Arrays.asList(
Items.flint_and_steel,
Items.flint,
Item.getItemFromBlock(Blocks.torch)
@@ -233,7 +233,7 @@ public class BlockCandle extends BlockTorch {
/* DROP HANDLING */
// Hack: When harvesting we need to get the drops in onBlockHarvested,
// because Mojang destroys the block and tile before calling getDrops.
private final ThreadLocal<ItemStack> drop = new ThreadLocal<ItemStack>();
private final ThreadLocal<ItemStack> drop = new ThreadLocal<>();
@Override
public void onBlockHarvested(World world, int x, int y, int z, int metadata, EntityPlayer player) {
@@ -253,7 +253,7 @@ public class BlockCandle extends BlockTorch {
dropStack = getCandleDrop(world, x, y, z);
}
ArrayList<ItemStack> drops = new ArrayList<ItemStack>(1);
ArrayList<ItemStack> drops = new ArrayList<>(1);
drops.add(dropStack);
return drops;
@@ -25,7 +25,7 @@ public class BeeModeHelper implements ICommandModeHelper {
public String[] getModeNames() {
ArrayList<IBeekeepingMode> beekeepingModes = BeeManager.beeRoot.getBeekeepingModes();
int modeStringCount = beekeepingModes.size();
List<String> modeStrings = new ArrayList<String>(modeStringCount);
List<String> modeStrings = new ArrayList<>(modeStringCount);
for (IBeekeepingMode mode : beekeepingModes) {
modeStrings.add(mode.getName());
}
@@ -53,7 +53,7 @@ public class BeeStatsSaveHelper implements IStatsSaveHelper {
@Override
public Collection<IAlleleSpecies> getSpecies() {
Collection<IAlleleSpecies> species = new ArrayList<IAlleleSpecies>();
Collection<IAlleleSpecies> species = new ArrayList<>();
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
if (allele instanceof IAlleleBeeSpecies) {
species.add((IAlleleBeeSpecies) allele);
@@ -39,7 +39,7 @@ public class CommandBeeGive extends SubCommand {
super("give");
setPermLevel(PermLevel.ADMIN);
List<String> beeTypeStrings = new ArrayList<String>();
List<String> beeTypeStrings = new ArrayList<>();
for (EnumBeeType type : EnumBeeType.values()) {
if (type == EnumBeeType.NONE) {
continue;
@@ -151,7 +151,7 @@ public class CommandBeeGive extends SubCommand {
}
private static String[] getSpecies() {
List<String> species = new ArrayList<String>();
List<String> species = new ArrayList<>();
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
if (allele instanceof IAlleleBeeSpecies) {
@@ -12,6 +12,8 @@ package forestry.apiculture.flowers;
import com.google.common.base.Objects;
import javax.annotation.Nonnull;
import net.minecraft.block.Block;
import net.minecraftforge.oredict.OreDictionary;
@@ -46,7 +48,7 @@ final class Flower implements IFlower {
}
@Override
public int compareTo(IFlower other) {
public int compareTo(@Nonnull IFlower other) {
return this.weight.compareTo(other.getWeight());
}
@@ -45,12 +45,13 @@ public class FlowerProvider implements IFlowerProvider {
EnumSet<EnumPlantType> plantTypes = pollinatable.getPlantType();
if (flowerType.equals(FlowerManager.FlowerTypeNether)) {
return plantTypes.contains(EnumPlantType.Nether);
} else if (flowerType.equals(FlowerManager.FlowerTypeCacti)) {
return plantTypes.contains(EnumPlantType.Desert);
} else {
return plantTypes.size() > 1 || !plantTypes.contains(EnumPlantType.Nether);
switch (flowerType) {
case FlowerManager.FlowerTypeNether:
return plantTypes.contains(EnumPlantType.Nether);
case FlowerManager.FlowerTypeCacti:
return plantTypes.contains(EnumPlantType.Desert);
default:
return plantTypes.size() > 1 || !plantTypes.contains(EnumPlantType.Nether);
}
}
@@ -34,25 +34,30 @@ import net.minecraft.tileentity.TileEntityFlowerPot;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.common.registry.GameRegistry;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.FlowerManager;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeModifier;
import forestry.api.genetics.IFlower;
import forestry.api.genetics.IFlowerAcceptableRule;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
import forestry.apiculture.BeeHousingModifier;
import forestry.core.config.Constants;
import forestry.core.utils.Log;
import forestry.core.utils.vect.MutableVect;
import forestry.core.utils.vect.Vect;
import forestry.plugins.PluginManager;
public final class FlowerRegistry implements IFlowerRegistry {
public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelper {
private final Set<String> defaultFlowerTypes = ImmutableSet.of(
FlowerManager.FlowerTypeVanilla,
@@ -66,17 +71,19 @@ public final class FlowerRegistry implements IFlowerRegistry {
FlowerManager.FlowerTypeGourd
);
private final HashMultimap<String, IFlowerAcceptableRule> registeredRules; // custom check
private final HashMultimap<String, Block> registeredBlocks; // quick first check
private final HashMultimap<String, IFlower> registeredFlowers; // full check
private final HashMultimap<String, Flower> registeredFlowers; // full check
private final ArrayListMultimap<String, IFlowerGrowthRule> growthRules;
private final Map<String, TreeMap<Double, IFlower>> chances;
private final Map<String, TreeMap<Double, Flower>> chances;
public FlowerRegistry() {
this.registeredRules = HashMultimap.create();
this.registeredBlocks = HashMultimap.create();
this.registeredFlowers = HashMultimap.create();
this.growthRules = ArrayListMultimap.create();
this.chances = new HashMap<String, TreeMap<Double, IFlower>>();
this.chances = new HashMap<>();
registerVanillaGrowthRules();
}
@@ -91,6 +98,17 @@ public final class FlowerRegistry implements IFlowerRegistry {
registerFlower(block, meta, 0.0, flowerTypes);
}
@Override
public void registerAcceptableFlowerRule(IFlowerAcceptableRule acceptableFlower, String... flowerTypes) {
for (String flowerType : flowerTypes) {
if (defaultFlowerTypes.contains(flowerType)) {
Log.severe("IFlowerAcceptableRules are too slow to be applied to Forestry's built-in flower type: " + flowerType + ".");
} else {
registeredRules.put(flowerType, acceptableFlower);
}
}
}
@Override
public void registerPlantableFlower(Block block, int meta, double weight, String... flowerTypes) {
registerFlower(block, meta, weight, flowerTypes);
@@ -114,7 +132,7 @@ public final class FlowerRegistry implements IFlowerRegistry {
throw new NullPointerException("Tried to register flower with null type. " + block);
}
Set<IFlower> flowers = this.registeredFlowers.get(flowerType);
Set<Flower> flowers = this.registeredFlowers.get(flowerType);
flowers.add(newFlower);
Set<Block> blocks = this.registeredBlocks.get(flowerType);
@@ -138,11 +156,12 @@ public final class FlowerRegistry implements IFlowerRegistry {
return null;
}
Set<IFlowerAcceptableRule> acceptableRules = this.registeredRules.get(flowerType);
Set<Block> acceptedBlocks = this.registeredBlocks.get(flowerType);
Set<IFlower> acceptedFlowers = this.registeredFlowers.get(flowerType);
Set<Flower> acceptedFlowers = this.registeredFlowers.get(flowerType);
World world = beeHousing.getWorld();
IBeeModifier beeModifier = new BeeHousingModifier(beeHousing);
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(beeHousing);
Vect area = getArea(bee.getGenome(), beeModifier);
Vect housingPos = new Vect(beeHousing.getCoordinates()).add(-area.x / 2, -area.y / 2, -area.z / 2);
@@ -152,6 +171,12 @@ public final class FlowerRegistry implements IFlowerRegistry {
Vect posBlock = Vect.add(housingPos, posCurrent);
for (IFlowerAcceptableRule acceptableRule : acceptableRules) {
if (acceptableRule.isAcceptableFlower(flowerType, world, posBlock.x, posBlock.y, posBlock.z)) {
return new ChunkCoordinates(posBlock.x, posBlock.y, posBlock.z);
}
}
if (isAcceptedFlower(flowerType, acceptedBlocks, acceptedFlowers, world, posBlock.x, posBlock.y, posBlock.z)) {
return new ChunkCoordinates(posBlock.x, posBlock.y, posBlock.z);
}
@@ -166,13 +191,20 @@ public final class FlowerRegistry implements IFlowerRegistry {
return false;
}
Set<IFlowerAcceptableRule> acceptedCustom = this.registeredRules.get(flowerType);
for (IFlowerAcceptableRule acceptableFlower : acceptedCustom) {
if (acceptableFlower.isAcceptableFlower(flowerType, world, x, y, z)) {
return true;
}
}
Set<Block> acceptedBlocks = this.registeredBlocks.get(flowerType);
Set<IFlower> acceptedFlowers = this.registeredFlowers.get(flowerType);
Set<Flower> acceptedFlowers = this.registeredFlowers.get(flowerType);
return isAcceptedFlower(flowerType, acceptedBlocks, acceptedFlowers, world, x, y, z);
}
private static boolean isAcceptedFlower(String flowerType, Set<Block> acceptedBlocks, Set<IFlower> acceptedFlowers, World world, int x, int y, int z) {
private static boolean isAcceptedFlower(String flowerType, Set<Block> acceptedBlocks, Set<Flower> acceptedFlowers, World world, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
final int meta;
@@ -190,15 +222,21 @@ public final class FlowerRegistry implements IFlowerRegistry {
meta = world.getBlockMetadata(x, y, z);
}
if (PluginManager.Module.AGRICRAFT.isEnabled() && (flowerType.equals(FlowerManager.FlowerTypeWheat) || flowerType.equals(FlowerManager.FlowerTypeNether))) {
if (PluginManager.Module.AGRICRAFT.isEnabled()) {
Block cropBlock = GameRegistry.findBlock("AgriCraft", "crops");
if (block == cropBlock) {
ArrayList<ItemStack> drops = block.getDrops(world, x, y, z, 7, 0);
if (drops.get(1).getItem() == Items.wheat_seeds && flowerType.equals(FlowerManager.FlowerTypeWheat)) {
return true;
}
if (drops.get(1).getItem() == Items.nether_wart && flowerType.equals(FlowerManager.FlowerTypeNether)) {
return true;
if(block instanceof IPlantable) {
//For agricraft versions which implement IPlantable in the BlockCrop class
block = ((IPlantable) block).getPlant(world, x, y, z);
} else {
//For earlier versions of AgriCraft
ArrayList<ItemStack> drops = block.getDrops(world, x, y, z, 7, 0);
if (drops.get(1).getItem() == Items.wheat_seeds && flowerType.equals(FlowerManager.FlowerTypeWheat)) {
return true;
}
if (drops.get(1).getItem() == Items.nether_wart && flowerType.equals(FlowerManager.FlowerTypeNether)) {
return true;
}
}
}
}
@@ -214,7 +252,15 @@ public final class FlowerRegistry implements IFlowerRegistry {
}
for (IFlowerGrowthRule rule : this.growthRules.get(flowerType)) {
if (rule.growFlower(this, flowerType, world, individual, x, y, z)) {
boolean success;
try {
success = rule.growFlower(this, flowerType, world, x, y, z);
} catch (Throwable ignored) {
// legacy method
success = rule.growFlower(this, flowerType, world, individual, x, y, z);
}
if (success) {
return true;
}
}
@@ -224,7 +270,7 @@ public final class FlowerRegistry implements IFlowerRegistry {
@Override
public Set<IFlower> getAcceptableFlowers(String flowerType) {
return this.registeredFlowers.get(flowerType);
return ImmutableSet.<IFlower>copyOf(this.registeredFlowers.get(flowerType));
}
@Override
@@ -240,21 +286,21 @@ public final class FlowerRegistry implements IFlowerRegistry {
@Override
public IFlower getRandomPlantableFlower(String flowerType, Random rand) {
TreeMap<Double, IFlower> chancesMap = getChancesMap(flowerType);
TreeMap<Double, Flower> chancesMap = getChancesMap(flowerType);
double maxKey = chancesMap.lastKey() + 1.0;
return chancesMap.get(chancesMap.lowerKey(rand.nextDouble() * maxKey));
}
@Override
public Collection<String> getFlowerTypes() {
return new ArrayList<String>(Sets.union(defaultFlowerTypes, registeredFlowers.keySet()));
return new ArrayList<>(Sets.union(defaultFlowerTypes, registeredFlowers.keySet()));
}
private TreeMap<Double, IFlower> getChancesMap(String flowerType) {
private TreeMap<Double, Flower> getChancesMap(String flowerType) {
if (!this.chances.containsKey(flowerType)) {
TreeMap<Double, IFlower> flowerChances = new TreeMap<Double, IFlower>();
TreeMap<Double, Flower> flowerChances = new TreeMap<>();
double count = 0.0;
for (IFlower flower : this.registeredFlowers.get(flowerType)) {
for (Flower flower : this.registeredFlowers.get(flowerType)) {
if (flower.isPlantable()) {
flowerChances.put(count, flower);
count += flower.getWeight();
@@ -266,13 +312,19 @@ public final class FlowerRegistry implements IFlowerRegistry {
}
private void registerVanillaGrowthRules() {
registerGrowthRule(new VanillaDirtGrassGrowthRule(), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
registerGrowthRule(new VanillaSnowGrowthRule(), FlowerManager.FlowerTypeSnow);
registerGrowthRule(new VanillaFlowerPotGrowthRule(), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow, FlowerManager.FlowerTypeMushrooms, FlowerManager.FlowerTypeCacti,
registerGrowthRule(new GrowthRuleDirtGrass(), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
registerGrowthRule(new GrowthRuleSnow(), FlowerManager.FlowerTypeSnow);
registerGrowthRule(new GrowthRuleFlowerPot(), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow, FlowerManager.FlowerTypeMushrooms, FlowerManager.FlowerTypeCacti,
FlowerManager.FlowerTypeJungle);
registerGrowthRule(new VanillaMyceliumGrowthRule(), FlowerManager.FlowerTypeMushrooms);
registerGrowthRule(new VanillaDefaultGrowthRule(), FlowerManager.FlowerTypeEnd);
registerGrowthRule(new VanillaFertilizeGrowthRule(Blocks.melon_stem, Blocks.pumpkin_stem), FlowerManager.FlowerTypeGourd);
registerGrowthRule(new VanillaFertilizeGrowthRule(Blocks.wheat), FlowerManager.FlowerTypeWheat);
registerGrowthRule(new GrowthRuleMycelium(), FlowerManager.FlowerTypeMushrooms);
registerGrowthRule(new GrowthRuleNone(), FlowerManager.FlowerTypeEnd);
registerGrowthRule(new GrowthRuleFertilize(Blocks.melon_stem, Blocks.pumpkin_stem), FlowerManager.FlowerTypeGourd);
registerGrowthRule(new GrowthRuleFertilize(Blocks.wheat), FlowerManager.FlowerTypeWheat);
}
@Override
public boolean plantRandomFlower(String flowerType, World world, int x, int y, int z) {
IFlower flower = getRandomPlantableFlower(flowerType, world.rand);
return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Constants.FLAG_BLOCK_SYNCH);
}
}
@@ -15,12 +15,13 @@ import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import forestry.api.genetics.IFlower;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
import forestry.core.config.Constants;
public class VanillaDirtGrassGrowthRule implements IFlowerGrowthRule {
public class GrowthRuleDirtGrass implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerRegistry flowerRegistry, String flowerType, World world, IIndividual individual, int x, int y, int z) {
@@ -37,4 +38,18 @@ public class VanillaDirtGrassGrowthRule implements IFlowerGrowthRule {
return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Constants.FLAG_BLOCK_SYNCH);
}
@Override
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, int x, int y, int z) {
if (!world.isAirBlock(x, y, z)) {
return false;
}
Block ground = world.getBlock(x, y - 1, z);
if (ground != Blocks.dirt && ground != Blocks.grass) {
return false;
}
return helper.plantRandomFlower(flowerType, world, x, y, z);
}
}
@@ -16,20 +16,30 @@ import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
public class VanillaFertilizeGrowthRule implements IFlowerGrowthRule {
public class GrowthRuleFertilize implements IFlowerGrowthRule {
private final List<Block> allowedItems;
public VanillaFertilizeGrowthRule(Block... allowedItems) {
public GrowthRuleFertilize(Block... allowedItems) {
this.allowedItems = Arrays.asList(allowedItems);
}
@Override
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
return growFlower(world, x, y, z);
}
@Override
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, int x, int y, int z) {
return growFlower(world, x, y, z);
}
private boolean growFlower(World world, int x, int y, int z) {
Block ground = world.getBlock(x, y, z);
int groundMeta;
for (Block b : this.allowedItems) {
@@ -17,15 +17,24 @@ import net.minecraft.tileentity.TileEntityFlowerPot;
import net.minecraft.world.World;
import forestry.api.apiculture.FlowerManager;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
public class VanillaFlowerPotGrowthRule implements IFlowerGrowthRule {
public class GrowthRuleFlowerPot implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
return growFlower(flowerType, world, x, y, z);
}
@Override
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, int x, int y, int z) {
return growFlower(flowerType, world, x, y, z);
}
private static boolean growFlower(String flowerType, World world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof TileEntityFlowerPot)) {
return false;
@@ -44,16 +53,22 @@ public class VanillaFlowerPotGrowthRule implements IFlowerGrowthRule {
BlockFlowerPot flowerPot = (BlockFlowerPot) block;
int flower;
if (flowerType.equals(FlowerManager.FlowerTypeVanilla) || flowerType.equals(FlowerManager.FlowerTypeSnow)) {
flower = world.rand.nextInt(2) + 1;
} else if (flowerType.equals(FlowerManager.FlowerTypeJungle)) {
flower = 6;
} else if (flowerType.equals(FlowerManager.FlowerTypeCacti)) {
flower = world.rand.nextInt(2) + 9;
} else if (flowerType.equals(FlowerManager.FlowerTypeMushrooms)) {
flower = world.rand.nextInt(2) + 7;
} else {
return false;
switch (flowerType) {
case FlowerManager.FlowerTypeVanilla:
case FlowerManager.FlowerTypeSnow:
flower = world.rand.nextInt(2) + 1;
break;
case FlowerManager.FlowerTypeJungle:
flower = 6;
break;
case FlowerManager.FlowerTypeCacti:
flower = world.rand.nextInt(2) + 9;
break;
case FlowerManager.FlowerTypeMushrooms:
flower = world.rand.nextInt(2) + 7;
break;
default:
return false;
}
TileEntityFlowerPot newTile = (TileEntityFlowerPot) flowerPot.createNewTileEntity(world, flower);
@@ -15,12 +15,13 @@ import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import forestry.api.genetics.IFlower;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
import forestry.core.config.Constants;
public class VanillaMyceliumGrowthRule implements IFlowerGrowthRule {
public class GrowthRuleMycelium implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
@@ -37,4 +38,18 @@ public class VanillaMyceliumGrowthRule implements IFlowerGrowthRule {
return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Constants.FLAG_BLOCK_SYNCH);
}
@Override
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, int x, int y, int z) {
if (!world.isAirBlock(x, y, z)) {
return false;
}
Block ground = world.getBlock(x, y - 1, z);
if (ground != Blocks.mycelium) {
return false;
}
return helper.plantRandomFlower(flowerType, world, x, y, z);
}
}
@@ -12,15 +12,21 @@ package forestry.apiculture.flowers;
import net.minecraft.world.World;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
public class VanillaDefaultGrowthRule implements IFlowerGrowthRule {
public class GrowthRuleNone implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
return true;
}
@Override
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, int x, int y, int z) {
return true;
}
}
@@ -15,12 +15,13 @@ import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import forestry.api.genetics.IFlower;
import forestry.api.genetics.IFlowerGrowthHelper;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
import forestry.core.config.Constants;
public class VanillaSnowGrowthRule implements IFlowerGrowthRule {
public class GrowthRuleSnow implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
@@ -37,4 +38,18 @@ public class VanillaSnowGrowthRule implements IFlowerGrowthRule {
return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Constants.FLAG_BLOCK_SYNCH);
}
@Override
public boolean growFlower(IFlowerGrowthHelper helper, String flowerType, World world, int x, int y, int z) {
if (world.getBlock(x, y, z) != Blocks.snow) {
return false;
}
Block ground = world.getBlock(x, y - 1, z);
if (ground != Blocks.dirt && ground != Blocks.grass) {
return false;
}
return helper.plantRandomFlower(flowerType, world, x, y, z);
}
}
@@ -30,6 +30,7 @@ import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.FlowerManager;
import forestry.api.apiculture.IAlleleBeeEffect;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IApiaristTracker;
@@ -52,7 +53,6 @@ import forestry.api.genetics.IFlowerProvider;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IMutation;
import forestry.api.genetics.IPollinatable;
import forestry.apiculture.BeeHousingModifier;
import forestry.arboriculture.genetics.pollination.FakePollinatable;
import forestry.arboriculture.genetics.pollination.ICheckPollinatable;
import forestry.core.config.Config;
@@ -251,9 +251,9 @@ public class Bee extends IndividualLiving implements IBee {
World world = housing.getWorld();
BiomeGenBase biome = housing.getBiome();
Set<IErrorState> errorStates = new HashSet<IErrorState>();
Set<IErrorState> errorStates = new HashSet<>();
IBeeModifier beeModifier = new BeeHousingModifier(housing);
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
// / Rain needs tolerant flyers
if (world.isRaining() && !genome.getTolerantFlyer() && BiomeHelper.canRainOrSnow(biome) && !beeModifier.isSealed()) {
@@ -316,7 +316,7 @@ public class Bee extends IndividualLiving implements IBee {
@Override
public ArrayList<BiomeGenBase> getSuitableBiomes() {
ArrayList<BiomeGenBase> suitableBiomes = new ArrayList<BiomeGenBase>();
ArrayList<BiomeGenBase> suitableBiomes = new ArrayList<>();
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray()) {
if (isSuitableBiome(biome)) {
suitableBiomes.add(biome);
@@ -402,7 +402,7 @@ public class Bee extends IndividualLiving implements IBee {
// / PRODUCTION
@Override
public ItemStack[] getProduceList() {
ArrayList<ItemStack> products = new ArrayList<ItemStack>();
ArrayList<ItemStack> products = new ArrayList<>();
IAlleleBeeSpecies primary = genome.getPrimary();
IAlleleBeeSpecies secondary = genome.getSecondary();
@@ -448,7 +448,7 @@ public class Bee extends IndividualLiving implements IBee {
return null;
}
List<ItemStack> products = new ArrayList<ItemStack>();
List<ItemStack> products = new ArrayList<>();
IAlleleBeeSpecies primary = genome.getPrimary();
IAlleleBeeSpecies secondary = genome.getSecondary();
@@ -458,7 +458,7 @@ public class Bee extends IndividualLiving implements IBee {
setIsNatural(false);
}
IBeeModifier beeHousingModifier = new BeeHousingModifier(housing);
IBeeModifier beeHousingModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
IBeeModifier beeModeModifier = mode.getBeeModifier();
// Bee genetic speed * beehousing * beekeeping mode
@@ -518,7 +518,7 @@ public class Bee extends IndividualLiving implements IBee {
return null;
}
List<IBee> bees = new ArrayList<IBee>();
List<IBee> bees = new ArrayList<>();
ChunkCoordinates housingCoordinates = housing.getCoordinates();
int toCreate = BeeManager.beeRoot.getBeekeepingMode(world).getFinalFertility(this, world, housingCoordinates.posX, housingCoordinates.posY, housingCoordinates.posZ);
@@ -630,7 +630,7 @@ public class Bee extends IndividualLiving implements IBee {
@Override
public IIndividual retrievePollen(IBeeHousing housing) {
IBeeModifier beeModifier = new BeeHousingModifier(housing);
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
int chance = Math.round(genome.getFlowering() * beeModifier.getFloweringModifier(getGenome(), 1f));
@@ -673,7 +673,7 @@ public class Bee extends IndividualLiving implements IBee {
@Override
public boolean pollinateRandom(IBeeHousing housing, IIndividual pollen) {
IBeeModifier beeModifier = new BeeHousingModifier(housing);
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
int chance = (int) (genome.getFlowering() * beeModifier.getFloweringModifier(getGenome(), 1f));
@@ -720,7 +720,7 @@ public class Bee extends IndividualLiving implements IBee {
@Override
public void plantFlowerRandom(IBeeHousing housing) {
IBeeModifier beeModifier = new BeeHousingModifier(housing);
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
int chance = Math.round(genome.getFlowering() * beeModifier.getFloweringModifier(getGenome(), 1f));
@@ -742,7 +742,7 @@ public class Bee extends IndividualLiving implements IBee {
Vect randomPos = Vect.getRandomPositionInArea(random, area);
Vect posBlock = Vect.add(housingPos, randomPos, offset);
if (provider.growFlower(world, this, posBlock.x, posBlock.y, posBlock.z)) {
if (FlowerManager.flowerRegistry.growFlower(provider.getFlowerType(), world, this, posBlock.x, posBlock.y, posBlock.z)) {
break;
}
}
@@ -33,6 +33,8 @@ import forestry.api.apiculture.IApiaristTracker;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeListener;
import forestry.api.apiculture.IBeeModifier;
import forestry.api.apiculture.IBeeMutation;
import forestry.api.apiculture.IBeeRoot;
import forestry.api.apiculture.IBeekeepingLogic;
@@ -42,6 +44,8 @@ import forestry.api.genetics.IAllele;
import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IMutation;
import forestry.apiculture.BeeHousingListener;
import forestry.apiculture.BeeHousingModifier;
import forestry.apiculture.BeekeepingLogic;
import forestry.core.config.ForestryItem;
import forestry.core.genetics.SpeciesRoot;
@@ -204,7 +208,7 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
}
/* TEMPLATES */
private static final ArrayList<IBee> beeTemplates = new ArrayList<IBee>();
private static final ArrayList<IBee> beeTemplates = new ArrayList<>();
@Override
public ArrayList<IBee> getIndividualTemplates() {
@@ -226,7 +230,7 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
/**
* List of possible mutations on species alleles.
*/
private static final ArrayList<IBeeMutation> beeMutations = new ArrayList<IBeeMutation>();
private static final ArrayList<IBeeMutation> beeMutations = new ArrayList<>();
@Override
public Collection<IBeeMutation> getMutations(boolean shuffle) {
@@ -252,7 +256,7 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
}
/* BREEDING MODES */
private final ArrayList<IBeekeepingMode> beekeepingModes = new ArrayList<IBeekeepingMode>();
private final ArrayList<IBeekeepingMode> beekeepingModes = new ArrayList<>();
private static IBeekeepingMode activeBeekeepingMode;
@Override
@@ -326,6 +330,16 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
return new BeekeepingLogic(housing);
}
@Override
public IBeeModifier createBeeHousingModifier(IBeeHousing housing) {
return new BeeHousingModifier(housing);
}
@Override
public IBeeListener createBeeHousingListener(IBeeHousing housing) {
return new BeeHousingListener(housing);
}
@Override
public IChromosomeType[] getKaryotype() {
return EnumBeeChromosome.values();
@@ -21,7 +21,6 @@ import forestry.api.apiculture.IBeeModifier;
import forestry.api.apiculture.IBeeMutationCustom;
import forestry.api.apiculture.IBeeRoot;
import forestry.api.genetics.IAllele;
import forestry.apiculture.BeeHousingModifier;
import forestry.core.genetics.mutations.Mutation;
public class BeeMutation extends Mutation implements IBeeMutationCustom {
@@ -48,7 +47,7 @@ public class BeeMutation extends Mutation implements IBeeMutationCustom {
return 0;
}
IBeeModifier beeHousingModifier = new BeeHousingModifier(housing);
IBeeModifier beeHousingModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
IBeeModifier beeModeModifier = BeeManager.beeRoot.getBeekeepingMode(world).getBeeModifier();
processedChance *= beeHousingModifier.getMutationModifier(genome0, genome1, processedChance);
@@ -16,13 +16,13 @@ import java.util.Random;
import net.minecraft.world.World;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.DefaultBeeModifier;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeModifier;
import forestry.api.apiculture.IBeekeepingMode;
import forestry.apiculture.BeeHousingModifier;
public class BeekeepingMode implements IBeekeepingMode {
@@ -53,7 +53,7 @@ public class BeekeepingMode implements IBeekeepingMode {
@Override
public ArrayList<String> getDescription() {
ArrayList<String> ret = new ArrayList<String>();
ArrayList<String> ret = new ArrayList<>();
ret.add("beemode." + name.toLowerCase(Locale.ENGLISH) + ".desc");
return ret;
}
@@ -84,7 +84,7 @@ public class BeekeepingMode implements IBeekeepingMode {
return false;
}
IBeeModifier beeModifier = new BeeHousingModifier(housing);
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
return queen.getGeneration() > 96 + rand.nextInt(6) + rand.nextInt(6) &&
rand.nextFloat() < 0.02f * beeModifier.getGeneticDecay(queen.getGenome(), 1f);
@@ -92,7 +92,7 @@ public class BeekeepingMode implements IBeekeepingMode {
@Override
public boolean isOverworked(IBee queen, IBeeHousing housing) {
IBeeModifier beeModifier = new BeeHousingModifier(housing);
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
float productionModifier = beeModifier.getProductionModifier(queen.getGenome(), 1f);
if (productionModifier > 16) {
@@ -106,7 +106,7 @@ public class BeekeepingMode implements IBeekeepingMode {
@Override
public boolean isDegenerating(IBee queen, IBee offspring, IBeeHousing housing) {
IBeeModifier beeModifier = new BeeHousingModifier(housing);
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
float mutationModifier = beeModifier.getMutationModifier(queen.getGenome(), queen.getMate(), 1.0f);
if (mutationModifier > 10) {
@@ -25,7 +25,7 @@ import forestry.api.apiculture.IHiveDrop;
public class HiveDrop implements IHiveDrop {
private final IBeeDefinition beeTemplate;
private final ArrayList<ItemStack> additional = new ArrayList<ItemStack>();
private final ArrayList<ItemStack> additional = new ArrayList<>();
private final int chance;
private float ignobleShare = 0.0f;
@@ -59,7 +59,7 @@ public class HiveDrop implements IHiveDrop {
@Override
public ArrayList<ItemStack> getAdditional(World world, int x, int y, int z, int fortune) {
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
ArrayList<ItemStack> ret = new ArrayList<>();
for (ItemStack stack : additional) {
ret.add(stack.copy());
}
@@ -45,8 +45,8 @@ import forestry.core.utils.GeneticsUtil;
import forestry.core.utils.ItemStackUtil;
public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpeciesCustom {
private final Map<ItemStack, Float> productChances = new HashMap<ItemStack, Float>();
private final Map<ItemStack, Float> specialtyChances = new HashMap<ItemStack, Float>();
private final Map<ItemStack, Float> productChances = new HashMap<>();
private final Map<ItemStack, Float> specialtyChances = new HashMap<>();
private final int primaryColour;
private final int secondaryColour;
@@ -137,7 +137,7 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
@Override
public ItemStack[] getResearchBounty(World world, GameProfile researcher, IIndividual individual, int bountyLevel) {
ArrayList<ItemStack> bounty = new ArrayList<ItemStack>();
ArrayList<ItemStack> bounty = new ArrayList<>();
Collections.addAll(bounty, super.getResearchBounty(world, researcher, individual, bountyLevel));
if (bountyLevel > 10) {
@@ -12,12 +12,12 @@ package forestry.apiculture.genetics.alleles;
import net.minecraft.util.AxisAlignedBB;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IAlleleBeeEffect;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeModifier;
import forestry.api.genetics.IEffectData;
import forestry.apiculture.BeeHousingModifier;
import forestry.core.genetics.alleles.AlleleCategorized;
import forestry.core.utils.vect.MutableVect;
import forestry.core.utils.vect.Vect;
@@ -51,7 +51,7 @@ public class AlleleEffectNone extends AlleleCategorized implements IAlleleBeeEff
}
protected Vect getModifiedArea(IBeeGenome genome, IBeeHousing housing) {
IBeeModifier beeModifier = new BeeHousingModifier(housing);
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
float territoryModifier = beeModifier.getTerritoryModifier(genome, 1f);
MutableVect area = new MutableVect(genome.getTerritory());
@@ -71,7 +71,7 @@ public class AlleleEffectNone extends AlleleCategorized implements IAlleleBeeEff
}
protected AxisAlignedBB getBounding(IBeeGenome genome, IBeeHousing housing) {
IBeeModifier beeModifier = new BeeHousingModifier(housing);
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
float territoryModifier = beeModifier.getTerritoryModifier(genome, 1.0f);
MutableVect area = new MutableVect(genome.getTerritory());
@@ -49,7 +49,7 @@ public class AlleleEffectResurrection extends AlleleEffectThrottled {
}
public static List<Resurrectable> getReanimationList() {
ArrayList<Resurrectable> list = new ArrayList<Resurrectable>();
ArrayList<Resurrectable> list = new ArrayList<>();
list.add(new Resurrectable(new ItemStack(Items.bone), EntitySkeleton.class));
list.add(new Resurrectable(new ItemStack(Items.arrow), EntitySkeleton.class));
list.add(new Resurrectable(new ItemStack(Items.rotten_flesh), EntityZombie.class));
@@ -58,7 +58,7 @@ public class AlleleEffectResurrection extends AlleleEffectThrottled {
}
public static List<Resurrectable> getResurrectionList() {
ArrayList<Resurrectable> list = new ArrayList<Resurrectable>();
ArrayList<Resurrectable> list = new ArrayList<>();
list.add(new Resurrectable(new ItemStack(Items.gunpowder), EntityCreeper.class));
list.add(new Resurrectable(new ItemStack(Items.ender_pearl), EntityEnderman.class));
list.add(new Resurrectable(new ItemStack(Items.string), EntitySpider.class));
@@ -39,7 +39,7 @@ public class GuiBeealyzer extends GuiAlyzer {
public GuiBeealyzer(EntityPlayer player, BeealyzerInventory inventory) {
super("rootBees", player, new ContainerAlyzer(inventory, player), inventory, "gui.beealyzer");
ArrayList<ItemStack> beeList = new ArrayList<ItemStack>();
ArrayList<ItemStack> beeList = new ArrayList<>();
((ItemBeeGE) ForestryItem.beeDroneGE.item()).addCreativeItems(beeList, false);
for (ItemStack beeStack : beeList) {
IAlleleBeeSpecies species = BeeGenome.getSpecies(beeStack);
@@ -49,7 +49,7 @@ public class GuiHabitatLocator extends GuiForestry<ContainerHabitatLocator, Habi
new HabitatSlot(9, "Mushroom"),
new HabitatSlot(10, "Nether"),
new HabitatSlot(11, "End")};
private final Map<BiomeDictionary.Type, HabitatSlot> biomeToHabitat = new EnumMap<BiomeDictionary.Type, HabitatSlot>(BiomeDictionary.Type.class);
private final Map<BiomeDictionary.Type, HabitatSlot> biomeToHabitat = new EnumMap<>(BiomeDictionary.Type.class);
private int startX;
private int startY;
@@ -34,7 +34,7 @@ public class GuiImprinter extends GuiForestry<ContainerImprinter, ImprinterInven
private int startX;
private int startY;
private final Map<String, ItemStack> iconStacks = new HashMap<String, ItemStack>();
private final Map<String, ItemStack> iconStacks = new HashMap<>();
public GuiImprinter(InventoryPlayer inventoryplayer, ImprinterInventory inventory) {
super(Constants.TEXTURE_PATH_GUI + "/imprinter.png", new ContainerImprinter(inventoryplayer, inventory), inventory);
@@ -42,7 +42,7 @@ public class GuiImprinter extends GuiForestry<ContainerImprinter, ImprinterInven
xSize = 176;
ySize = 185;
List<ItemStack> beeList = new ArrayList<ItemStack>();
List<ItemStack> beeList = new ArrayList<>();
((ItemBeeGE) ForestryItem.beeDroneGE.item()).addCreativeItems(beeList, false);
for (ItemStack beeStack : beeList) {
IAlleleBeeSpecies species = BeeGenome.getSpecies(beeStack);
@@ -12,13 +12,12 @@ package forestry.apiculture.items;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import forestry.api.apiculture.BeeManager;
import forestry.api.apiculture.IBee;
import forestry.api.core.ForestryAPI;
import forestry.api.core.Tabs;
import forestry.api.genetics.ISpeciesRoot;
import forestry.core.config.Config;
import forestry.core.gui.IHintSource;
import forestry.core.items.ItemAlyzer;
@@ -48,48 +47,11 @@ public class ItemBeealyzer extends ItemAlyzer {
}
@Override
protected boolean isSpecimen(ItemStack itemStack) {
return BeeManager.beeRoot.isMember(itemStack);
protected ISpeciesRoot getSpeciesRoot() {
return BeeManager.beeRoot;
}
@Override
public void onSlotClick(EntityPlayer player) {
// Source slot to analyze empty
if (getStackInSlot(SLOT_SPECIMEN) == null) {
return;
}
IBee bee = BeeManager.beeRoot.getMember(getStackInSlot(SLOT_SPECIMEN));
// No bee, abort
if (bee == null) {
return;
}
// Analyze if necessary
if (!bee.isAnalyzed()) {
// Requires energy
if (!isEnergy(getStackInSlot(SLOT_ENERGY))) {
return;
}
bee.analyze();
if (player != null) {
BeeManager.beeRoot.getBreedingTracker(player.worldObj, player.getGameProfile()).registerSpecies(bee.getGenome().getPrimary());
BeeManager.beeRoot.getBreedingTracker(player.worldObj, player.getGameProfile()).registerSpecies(bee.getGenome().getSecondary());
}
NBTTagCompound nbttagcompound = new NBTTagCompound();
bee.writeToNBT(nbttagcompound);
getStackInSlot(SLOT_SPECIMEN).setTagCompound(nbttagcompound);
// Decrease energy
decrStackSize(SLOT_ENERGY, 1);
}
setInventorySlotContents(SLOT_ANALYZE_1, getStackInSlot(SLOT_SPECIMEN));
setInventorySlotContents(SLOT_SPECIMEN, null);
}
// / IHINTSOURCE
@Override
@@ -59,7 +59,7 @@ public class ItemHabitatLocator extends ItemInventoried {
private static final String iconName = "forestry:biomefinder";
private Set<BiomeGenBase> targetBiomes = new HashSet<BiomeGenBase>();
private Set<BiomeGenBase> targetBiomes = new HashSet<>();
private boolean biomeFound = false;
private int searchRadiusIteration = 0;
private int searchAngleIteration = 0;
@@ -108,7 +108,7 @@ public class ItemHabitatLocator extends ItemInventoried {
private void startBiomeSearch(IBee bee, EntityPlayer player) {
this.targetBiomes = new HashSet<BiomeGenBase>(bee.getSuitableBiomes());
this.targetBiomes = new HashSet<>(bee.getSuitableBiomes());
this.searchAngleIteration = 0;
this.searchRadiusIteration = 0;
this.biomeFound = false;
@@ -237,9 +237,9 @@ public class ItemHabitatLocator extends ItemInventoried {
return new ChunkCoordinates(pos.x, pos.y, pos.z);
}
private static final Set<BiomeGenBase> waterBiomes = new HashSet<BiomeGenBase>();
private static final Set<BiomeGenBase> netherBiomes = new HashSet<BiomeGenBase>();
private static final Set<BiomeGenBase> endBiomes = new HashSet<BiomeGenBase>();
private static final Set<BiomeGenBase> waterBiomes = new HashSet<>();
private static final Set<BiomeGenBase> netherBiomes = new HashSet<>();
private static final Set<BiomeGenBase> endBiomes = new HashSet<>();
static {
Collections.addAll(waterBiomes, BiomeDictionary.getBiomesForType(BiomeDictionary.Type.BEACH));
@@ -107,7 +107,7 @@ public class ItemHoneycomb extends ItemForestryMultiPass {
}
private int getRandomCombType(Random random, boolean includeSecret) {
List<Integer> validCombs = new ArrayList<Integer>(combs.length);
List<Integer> validCombs = new ArrayList<>(combs.length);
for (int i = 0; i < combs.length; i++) {
if (!combs[i].isSecret || includeSecret) {
validCombs.add(i);
@@ -35,7 +35,6 @@ import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.IClimateControlled;
import forestry.apiculture.BeeHousingInventory;
import forestry.apiculture.BeeHousingModifier;
import forestry.core.access.EnumAccess;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.multiblock.CoordTriplet;
@@ -60,11 +59,11 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
private float humidChange = 0.0f;
// PARTS
private final Set<IBeeModifier> beeModifiers = new HashSet<IBeeModifier>();
private final Set<IBeeListener> beeListeners = new HashSet<IBeeListener>();
private final Set<IAlvearyComponent.Climatiser> climatisers = new HashSet<IAlvearyComponent.Climatiser>();
private final Set<IAlvearyComponent.Active> activeComponents = new HashSet<IAlvearyComponent.Active>();
private final Set<IAlvearyComponent> allComponents = new HashSet<IAlvearyComponent>();
private final Set<IBeeModifier> beeModifiers = new HashSet<>();
private final Set<IBeeListener> beeListeners = new HashSet<>();
private final Set<IAlvearyComponent.Climatiser> climatisers = new HashSet<>();
private final Set<IAlvearyComponent.Active> activeComponents = new HashSet<>();
private final Set<IAlvearyComponent> allComponents = new HashSet<>();
// CLIENT
private int breedingProgressPercent = 0;
@@ -384,7 +383,7 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
@Override
public EnumTemperature getTemperature() {
IBeeModifier beeModifier = new BeeHousingModifier(this);
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(this);
if (beeModifier.isHellish() && tempChange >= 0) {
return EnumTemperature.HELLISH;
}
@@ -133,7 +133,7 @@ public class TileAlvearyPlain extends TileAlveary implements IBeeHousing, IClima
@Optional.Method(modid = "BuildCraftAPI|statements")
@Override
public Collection<ITriggerExternal> getExternalTriggers(ForgeDirection side, TileEntity tile) {
Collection<ITriggerExternal> res = new ArrayList<ITriggerExternal>();
Collection<ITriggerExternal> res = new ArrayList<>();
res.add(ApicultureTriggers.missingQueen);
res.add(ApicultureTriggers.missingDrone);
return res;
@@ -40,7 +40,7 @@ import forestry.core.utils.ItemStackUtil;
public class TileAlvearySwarmer extends TileAlvearyWithGui implements ISidedInventory, IActivatable, IAlvearyComponent.Active {
private final SwarmerInventory inventory;
private final Stack<ItemStack> pendingSpawns = new Stack<ItemStack>();
private final Stack<ItemStack> pendingSpawns = new Stack<>();
private boolean active;
public TileAlvearySwarmer() {
@@ -159,6 +159,6 @@ public class ParticleRenderer {
}
private boolean lazyAdd = false;
private final List<EntityFX> particles = new ArrayList<EntityFX>();
private final List<EntityFX> newParticles = new ArrayList<EntityFX>();
private final List<EntityFX> particles = new ArrayList<>();
private final List<EntityFX> newParticles = new ArrayList<>();
}
@@ -40,6 +40,7 @@ public class TileApiaristChest extends TileNaturalistChest {
checkedForLegacyBlock = true;
}
super.updateServerSide();
}
private void migrateFromLegacyBlock() {
@@ -70,7 +70,7 @@ public class TileApiary extends TileAbstractBeeHousing {
@Override
public Collection<IBeeModifier> getBeeModifiers() {
List<IBeeModifier> beeModifiers = new ArrayList<IBeeModifier>();
List<IBeeModifier> beeModifiers = new ArrayList<>();
beeModifiers.add(beeModifier);
@@ -159,7 +159,7 @@ public class TileApiary extends TileAbstractBeeHousing {
}
public Collection<IHiveFrame> getFrames() {
Collection<IHiveFrame> hiveFrames = new ArrayList<IHiveFrame>(SLOT_FRAMES_COUNT);
Collection<IHiveFrame> hiveFrames = new ArrayList<>(SLOT_FRAMES_COUNT);
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
ItemStack stackInSlot = getStackInSlot(i);
@@ -181,7 +181,7 @@ public class TileApiary extends TileAbstractBeeHousing {
@Optional.Method(modid = "BuildCraftAPI|statements")
@Override
public Collection<ITriggerExternal> getExternalTriggers(ForgeDirection side, TileEntity tile) {
LinkedList<ITriggerExternal> res = new LinkedList<ITriggerExternal>();
LinkedList<ITriggerExternal> res = new LinkedList<>();
res.add(ApicultureTriggers.missingQueen);
res.add(ApicultureTriggers.missingDrone);
res.add(ApicultureTriggers.noFrames);
@@ -33,12 +33,13 @@ import forestry.api.apiculture.FlowerManager;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.arboriculture.EnumWoodType;
import forestry.api.arboriculture.TreeManager;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IFlower;
import forestry.apiculture.tiles.TileApiary;
import forestry.arboriculture.WoodType;
import forestry.arboriculture.worldgen.BlockTypeLog;
import forestry.arboriculture.worldgen.BlockTypeVanillaStairs;
import forestry.arboriculture.worldgen.BlockTypeWood;
@@ -79,12 +80,14 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
boolean fireproof = (random.nextInt(4) == 0);
WoodType roofWood = WoodType.getRandom(random);
EnumWoodType roofWood = EnumWoodType.getRandom(random);
EnumWoodType logWood = EnumWoodType.getRandom(random);
EnumWoodType fenceWood = EnumWoodType.getRandom(random);
logs = new BlockTypeLog(WoodType.getRandom(random).getLog(fireproof));
planks = new BlockTypeWood(roofWood.getPlanks(fireproof));
stairs = new BlockTypeWoodStairs(roofWood.getStairs(fireproof));
fence = new BlockTypeWood(WoodType.getRandom(random).getFence(fireproof));
logs = new BlockTypeLog(TreeManager.woodItemAccess.getLog(logWood, fireproof));
planks = new BlockTypeWood(TreeManager.woodItemAccess.getPlanks(roofWood, fireproof));
stairs = new BlockTypeWoodStairs(TreeManager.woodItemAccess.getStairs(roofWood, fireproof));
fence = new BlockTypeWood(TreeManager.woodItemAccess.getFence(fenceWood, fireproof));
} else {
int roofMeta = random.nextInt(16);
@@ -340,7 +343,7 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
EnumHumidity biomeHumidity = EnumHumidity.getFromValue(biome.rainfall);
// Add bees that can live in this environment
List<IBeeGenome> valid = new ArrayList<IBeeGenome>();
List<IBeeGenome> valid = new ArrayList<>();
for (IBeeGenome genome : candidates) {
if (checkBiomeHazard(genome, biomeTemperature, biomeHumidity)) {
valid.add(genome);
@@ -25,7 +25,7 @@ import forestry.api.core.EnumTemperature;
public final class Hive {
private final IHiveDescription hiveDescription;
private final List<IHiveDrop> drops = new ArrayList<IHiveDrop>();
private final List<IHiveDrop> drops = new ArrayList<>();
public Hive(IHiveDescription hiveDescription) {
if (hiveDescription == null) {
@@ -19,7 +19,7 @@ import net.minecraft.world.World;
public class HiveGenGround extends HiveGen {
private final Set<Material> groundMaterials = new HashSet<Material>();
private final Set<Material> groundMaterials = new HashSet<>();
public HiveGenGround(Block... groundBlocks) {
for (Block block : groundBlocks) {
@@ -22,7 +22,7 @@ import forestry.api.apiculture.hives.IHiveRegistry;
public class HiveRegistry implements IHiveRegistry {
private final Map<String, Hive> hives = new HashMap<String, Hive>();
private final Map<String, Hive> hives = new HashMap<>();
@Override
public void registerHive(String hiveName, IHiveDescription hiveDescription) {
@@ -50,7 +50,7 @@ public class HiveRegistry implements IHiveRegistry {
}
public List<Hive> getHives() {
return new ArrayList<Hive>(hives.values());
return new ArrayList<>(hives.values());
}
public List<IHiveDrop> getDrops(String hiveName) {
@@ -37,7 +37,7 @@ public class FruitProviderNone implements IFruitProvider {
}
}
private static final HashMap<String, OverlayType> overlayTypes = new HashMap<String, OverlayType>();
private static final HashMap<String, OverlayType> overlayTypes = new HashMap<>();
static {
overlayTypes.put("berries", new OverlayType("berries", (short) 1000));
@@ -28,7 +28,7 @@ import forestry.api.genetics.IFruitFamily;
*/
public class FruitProviderRandom extends FruitProviderNone {
private final Map<ItemStack, Float> products = new HashMap<ItemStack, Float>();
private final Map<ItemStack, Float> products = new HashMap<>();
private int colour = 0xffffff;
public FruitProviderRandom(String key, IFruitFamily family, ItemStack product, float modifier) {
@@ -48,7 +48,7 @@ public class FruitProviderRandom extends FruitProviderNone {
@Override
public ItemStack[] getFruits(ITreeGenome genome, World world, int x, int y, int z, int ripeningTime) {
ArrayList<ItemStack> product = new ArrayList<ItemStack>();
ArrayList<ItemStack> product = new ArrayList<>();
float modeYieldMod = TreeManager.treeRoot.getTreekeepingMode(world).getYieldModifier(genome, 1f);
@@ -25,7 +25,7 @@ import forestry.api.genetics.IFruitFamily;
public class FruitProviderRipening extends FruitProviderNone {
private final Map<ItemStack, Float> products = new HashMap<ItemStack, Float>();
private final Map<ItemStack, Float> products = new HashMap<>();
private int colourCallow = 0xffffff;
@@ -63,7 +63,7 @@ public class FruitProviderRipening extends FruitProviderNone {
@Override
public ItemStack[] getFruits(ITreeGenome genome, World world, int x, int y, int z, int ripeningTime) {
ArrayList<ItemStack> product = new ArrayList<ItemStack>();
ArrayList<ItemStack> product = new ArrayList<>();
float stage = getRipeningStage(ripeningTime);
if (stage < 0.5f) {
@@ -21,6 +21,7 @@ import net.minecraft.village.MerchantRecipeList;
import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler;
import forestry.api.arboriculture.EnumGermlingType;
import forestry.api.arboriculture.EnumWoodType;
import forestry.api.arboriculture.ITree;
import forestry.api.arboriculture.ITreeGenome;
import forestry.api.arboriculture.TreeManager;
@@ -40,8 +41,8 @@ public class VillageHandlerArboriculture implements IVillageTradeHandler {
recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 8), randomTreeStack));
recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 2), ForestryItem.grafterProven.getItemStack()));
WoodType randomWoodType = WoodType.VALUES[random.nextInt(WoodType.VALUES.length)];
ItemStack planks = randomWoodType.getPlanks(false);
EnumWoodType randomWoodType = EnumWoodType.getRandom(random);
ItemStack planks = TreeManager.woodItemAccess.getPlanks(randomWoodType, false);
planks.stackSize = 32;
recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 1), planks));
@@ -0,0 +1,133 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.arboriculture;
import java.util.EnumMap;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import forestry.api.arboriculture.EnumWoodType;
import forestry.api.arboriculture.IWoodItemAccess;
public class WoodItemAccess implements IWoodItemAccess {
private static final EnumMap<EnumWoodType, ItemStack> logs = new EnumMap<>(EnumWoodType.class);
private static final EnumMap<EnumWoodType, ItemStack> logsFireproof = new EnumMap<>(EnumWoodType.class);
private static final EnumMap<EnumWoodType, ItemStack> planks = new EnumMap<>(EnumWoodType.class);
private static final EnumMap<EnumWoodType, ItemStack> planksFireproof = new EnumMap<>(EnumWoodType.class);
private static final EnumMap<EnumWoodType, ItemStack> slabs = new EnumMap<>(EnumWoodType.class);
private static final EnumMap<EnumWoodType, ItemStack> slabsFireproof = new EnumMap<>(EnumWoodType.class);
private static final EnumMap<EnumWoodType, ItemStack> fences = new EnumMap<>(EnumWoodType.class);
private static final EnumMap<EnumWoodType, ItemStack> fencesFireproof = new EnumMap<>(EnumWoodType.class);
private static final EnumMap<EnumWoodType, ItemStack> stairs = new EnumMap<>(EnumWoodType.class);
private static final EnumMap<EnumWoodType, ItemStack> stairsFireproof = new EnumMap<>(EnumWoodType.class);
private static ItemStack getStack(EnumWoodType woodType, Block block) {
NBTTagCompound woodNBT = new NBTTagCompound();
woodType.saveToCompound(woodNBT);
ItemStack itemStack = new ItemStack(block);
itemStack.setTagCompound(woodNBT);
return itemStack;
}
public static void registerLog(Block block, EnumWoodType woodType, boolean fireproof) {
ItemStack itemStack = getStack(woodType, block);
if (fireproof) {
logsFireproof.put(woodType, itemStack);
} else {
logs.put(woodType, itemStack);
}
}
public static void registerPlanks(Block block, EnumWoodType woodType, boolean fireproof) {
ItemStack itemStack = getStack(woodType, block);
if (fireproof) {
planksFireproof.put(woodType, itemStack);
} else {
planks.put(woodType, itemStack);
}
}
public static void registerSlab(Block block, EnumWoodType woodType, boolean fireproof) {
ItemStack itemStack = getStack(woodType, block);
if (fireproof) {
slabsFireproof.put(woodType, itemStack);
} else {
slabs.put(woodType, itemStack);
}
}
public static void registerFence(Block block, EnumWoodType woodType, boolean fireproof) {
ItemStack itemStack = getStack(woodType, block);
if (fireproof) {
fencesFireproof.put(woodType, itemStack);
} else {
fences.put(woodType, itemStack);
}
}
public static void registerStairs(Block block, EnumWoodType woodType, boolean fireproof) {
ItemStack itemStack = getStack(woodType, block);
if (fireproof) {
stairsFireproof.put(woodType, itemStack);
} else {
stairs.put(woodType, itemStack);
}
}
@Override
public ItemStack getPlanks(EnumWoodType woodType, boolean fireproof) {
if (fireproof) {
return planksFireproof.get(woodType).copy();
} else {
return planks.get(woodType).copy();
}
}
@Override
public ItemStack getLog(EnumWoodType woodType, boolean fireproof) {
if (fireproof) {
return logsFireproof.get(woodType).copy();
} else {
return logs.get(woodType).copy();
}
}
@Override
public ItemStack getSlab(EnumWoodType woodType, boolean fireproof) {
if (fireproof) {
return slabsFireproof.get(woodType).copy();
} else {
return slabs.get(woodType).copy();
}
}
@Override
public ItemStack getFence(EnumWoodType woodType, boolean fireproof) {
if (fireproof) {
return fencesFireproof.get(woodType).copy();
} else {
return fences.get(woodType).copy();
}
}
@Override
public ItemStack getStairs(EnumWoodType woodType, boolean fireproof) {
if (fireproof) {
return stairsFireproof.get(woodType).copy();
} else {
return stairs.get(woodType).copy();
}
}
}
@@ -1,241 +0,0 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.arboriculture;
import java.util.Locale;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.core.render.TextureManager;
public enum WoodType {
LARCH, TEAK, ACACIA, LIME,
CHESTNUT, WENGE, BAOBAB, SEQUOIA(4.0f),
KAPOK, EBONY, MAHOGANY, BALSA(1.0f),
WILLOW, WALNUT, GREENHEART(7.5f), CHERRY,
MAHOE, POPLAR, PALM, PAPAYA,
PINE(3.0f), PLUM, MAPLE, CITRUS,
GIGANTEUM, IPE, PADAUK, COCOBOLO,
ZEBRAWOOD;
public static final float DEFAULT_HARDNESS = 2.0f;
public static final WoodType[] VALUES = values();
private final float hardness;
private ItemStack log;
private ItemStack logFireproof;
private ItemStack planks;
private ItemStack planksFireproof;
private ItemStack slab;
private ItemStack slabFireproof;
private ItemStack fence;
private ItemStack fenceFireproof;
private ItemStack stairs;
private ItemStack stairsFireproof;
WoodType() {
this(DEFAULT_HARDNESS);
}
WoodType(float hardness) {
this.hardness = hardness;
}
@SideOnly(Side.CLIENT)
private static IIcon[][] icons;
@SideOnly(Side.CLIENT)
public static void registerIcons(IIconRegister register) {
icons = new IIcon[3][VALUES.length];
for (int i = 0; i < VALUES.length; i++) {
WoodType woodType = VALUES[i];
String woodName = woodType.toString().toLowerCase(Locale.ENGLISH);
icons[0][i] = TextureManager.getInstance().registerTex(register, "wood/planks." + woodName);
icons[1][i] = TextureManager.getInstance().registerTex(register, "wood/bark." + woodName);
icons[2][i] = TextureManager.getInstance().registerTex(register, "wood/heart." + woodName);
}
}
@SideOnly(Side.CLIENT)
public IIcon getPlankIcon() {
return icons[0][ordinal()];
}
@SideOnly(Side.CLIENT)
public IIcon getBarkIcon() {
return icons[1][ordinal()];
}
@SideOnly(Side.CLIENT)
public IIcon getHeartIcon() {
return icons[2][ordinal()];
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int meta, int side) {
int oriented = meta & 12;
switch (oriented) {
case 4:
if (side > 3) {
return getHeartIcon();
} else {
return getBarkIcon();
}
case 8:
if (side == 2 || side == 3) {
return getHeartIcon();
} else {
return getBarkIcon();
}
case 0:
default:
if (side < 2) {
return getHeartIcon();
} else {
return getBarkIcon();
}
}
}
public float getHardness() {
return hardness;
}
public void saveToCompound(NBTTagCompound compound) {
compound.setInteger("WoodType", this.ordinal());
}
public static WoodType getFromCompound(NBTTagCompound compound) {
if (compound != null) {
int typeOrdinal = compound.getInteger("WoodType");
if (typeOrdinal < WoodType.VALUES.length) {
return WoodType.VALUES[typeOrdinal];
}
}
return WoodType.LARCH;
}
@Override
public String toString() {
return super.toString().toLowerCase(Locale.ENGLISH);
}
private ItemStack getStack(Block block) {
NBTTagCompound woodNBT = new NBTTagCompound();
saveToCompound(woodNBT);
ItemStack itemStack = new ItemStack(block);
itemStack.setTagCompound(woodNBT);
return itemStack;
}
public void registerLog(Block block, boolean fireproof) {
ItemStack itemStack = getStack(block);
if (fireproof) {
this.logFireproof = itemStack;
} else {
this.log = itemStack;
}
}
public void registerPlanks(Block block, boolean fireproof) {
ItemStack itemStack = getStack(block);
if (fireproof) {
this.planksFireproof = itemStack;
} else {
this.planks = itemStack;
}
}
public void registerSlab(Block block, boolean fireproof) {
ItemStack itemStack = getStack(block);
if (fireproof) {
this.slabFireproof = itemStack;
} else {
this.slab = itemStack;
}
}
public void registerFence(Block block, boolean fireproof) {
ItemStack itemStack = getStack(block);
if (fireproof) {
this.fenceFireproof = itemStack;
} else {
this.fence = itemStack;
}
}
public void registerStairs(Block block, boolean fireproof) {
ItemStack itemStack = getStack(block);
if (fireproof) {
this.stairsFireproof = itemStack;
} else {
this.stairs = itemStack;
}
}
public ItemStack getPlanks(boolean fireproof) {
if (fireproof) {
return planksFireproof.copy();
} else {
return planks.copy();
}
}
public ItemStack getLog(boolean fireproof) {
if (fireproof) {
return logFireproof.copy();
} else {
return log.copy();
}
}
public ItemStack getSlab(boolean fireproof) {
if (fireproof) {
return slabFireproof.copy();
} else {
return slab.copy();
}
}
public ItemStack getFence(boolean fireproof) {
if (fireproof) {
return fenceFireproof.copy();
} else {
return fence.copy();
}
}
public ItemStack getStairs(boolean fireproof) {
if (fireproof) {
return stairsFireproof.copy();
} else {
return stairs.copy();
}
}
public static WoodType getRandom(Random random) {
return VALUES[random.nextInt(VALUES.length)];
}
}
@@ -18,6 +18,7 @@ import net.minecraft.block.BlockFence;
import net.minecraft.block.BlockFenceGate;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
@@ -35,14 +36,18 @@ import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.arboriculture.EnumWoodType;
import forestry.api.arboriculture.TreeManager;
import forestry.api.core.Tabs;
import forestry.arboriculture.IWoodTyped;
import forestry.arboriculture.WoodType;
import forestry.arboriculture.render.IconProviderWood;
import forestry.arboriculture.tiles.TileWood;
import forestry.core.render.ParticleHelper;
import forestry.plugins.PluginArboriculture;
public class BlockArbFence extends BlockFence implements IWoodTyped, ITileEntityProvider {
private final ParticleHelper.Callback particleCallback;
private final boolean fireproof;
public BlockArbFence(boolean fireproof) {
@@ -55,13 +60,15 @@ public class BlockArbFence extends BlockFence implements IWoodTyped, ITileEntity
setHarvestLevel("axe", 0);
setStepSound(soundTypeWood);
setCreativeTab(Tabs.tabArboriculture);
this.particleCallback = new ParticleHelper.DefaultCallback(this);
}
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List list) {
for (WoodType woodType : WoodType.VALUES) {
list.add(woodType.getFence(fireproof));
for (EnumWoodType woodType : EnumWoodType.VALUES) {
list.add(TreeManager.woodItemAccess.getFence(woodType, fireproof));
}
}
@@ -88,20 +95,20 @@ public class BlockArbFence extends BlockFence implements IWoodTyped, ITileEntity
@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister register) {
WoodType.registerIcons(register);
IconProviderWood.registerIcons(register);
}
@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon(int side, int meta) {
return WoodType.ACACIA.getPlankIcon();
return IconProviderWood.getPlankIcon(EnumWoodType.LARCH);
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
TileWood wood = BlockWood.getWoodTile(world, x, y, z);
WoodType type = wood.getWoodType();
return type.getPlankIcon();
EnumWoodType woodType = wood.getWoodType();
return IconProviderWood.getPlankIcon(woodType);
}
private static boolean isFence(IBlockAccess world, int x, int y, int z) {
@@ -136,14 +143,14 @@ public class BlockArbFence extends BlockFence implements IWoodTyped, ITileEntity
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
return new ArrayList<ItemStack>();
return new ArrayList<>();
}
@Override
public final float getBlockHardness(World world, int x, int y, int z) {
TileWood wood = BlockWood.getWoodTile(world, x, y, z);
if (wood == null) {
return WoodType.DEFAULT_HARDNESS;
return EnumWoodType.DEFAULT_HARDNESS;
}
return wood.getWoodType().getHardness();
}
@@ -172,4 +179,17 @@ public class BlockArbFence extends BlockFence implements IWoodTyped, ITileEntity
public boolean isFireproof() {
return fireproof;
}
/* Particles */
@SideOnly(Side.CLIENT)
@Override
public boolean addHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
return ParticleHelper.addHitEffects(worldObj, this, target, effectRenderer, particleCallback);
}
@SideOnly(Side.CLIENT)
@Override
public boolean addDestroyEffects(World worldObj, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
return ParticleHelper.addDestroyEffects(worldObj, this, x, y, z, meta, effectRenderer, particleCallback);
}
}
@@ -16,6 +16,7 @@ import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.BlockStairs;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
@@ -31,13 +32,17 @@ import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.arboriculture.EnumWoodType;
import forestry.api.arboriculture.TreeManager;
import forestry.api.core.Tabs;
import forestry.arboriculture.IWoodTyped;
import forestry.arboriculture.WoodType;
import forestry.arboriculture.render.IconProviderWood;
import forestry.arboriculture.tiles.TileWood;
import forestry.core.render.ParticleHelper;
public class BlockArbStairs extends BlockStairs implements IWoodTyped, ITileEntityProvider {
private final ParticleHelper.Callback particleCallback;
private final boolean fireproof;
public BlockArbStairs(Block par2Block, boolean fireproof) {
@@ -49,14 +54,16 @@ public class BlockArbStairs extends BlockStairs implements IWoodTyped, ITileEnti
setHardness(2.0F);
setResistance(5.0F);
setHarvestLevel("axe", 0);
this.particleCallback = new ParticleHelper.DefaultCallback(this);
}
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
for (WoodType woodType : WoodType.VALUES) {
list.add(woodType.getStairs(fireproof));
for (EnumWoodType woodType : EnumWoodType.VALUES) {
list.add(TreeManager.woodItemAccess.getStairs(woodType, fireproof));
}
}
@@ -73,7 +80,7 @@ public class BlockArbStairs extends BlockStairs implements IWoodTyped, ITileEnti
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
return new ArrayList<ItemStack>();
return new ArrayList<>();
}
@Override
@@ -88,21 +95,21 @@ public class BlockArbStairs extends BlockStairs implements IWoodTyped, ITileEnti
@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister register) {
WoodType.registerIcons(register);
IconProviderWood.registerIcons(register);
}
/* ICONS */
@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon(int side, int meta) {
return WoodType.ACACIA.getPlankIcon();
return IconProviderWood.getPlankIcon(EnumWoodType.LARCH);
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
TileWood wood = BlockWood.getWoodTile(world, x, y, z);
WoodType type = wood.getWoodType();
return type.getPlankIcon();
EnumWoodType woodType = wood.getWoodType();
return IconProviderWood.getPlankIcon(woodType);
}
@Override
@@ -124,4 +131,17 @@ public class BlockArbStairs extends BlockStairs implements IWoodTyped, ITileEnti
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileWood();
}
/* Particles */
@SideOnly(Side.CLIENT)
@Override
public boolean addHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
return ParticleHelper.addHitEffects(worldObj, this, target, effectRenderer, particleCallback);
}
@SideOnly(Side.CLIENT)
@Override
public boolean addDestroyEffects(World worldObj, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
return ParticleHelper.addDestroyEffects(worldObj, this, x, y, z, meta, effectRenderer, particleCallback);
}
}
@@ -103,7 +103,7 @@ public class BlockForestryLeaves extends BlockNewLeaf implements ITileEntityProv
/* DROP HANDLING */
// Hack: When harvesting leaves we need to get the drops in onBlockHarvested,
// because Mojang destroys the block and tile before calling getDrops.
private final ThreadLocal<ArrayList<ItemStack>> drops = new ThreadLocal<ArrayList<ItemStack>>();
private final ThreadLocal<ArrayList<ItemStack>> drops = new ThreadLocal<>();
@Override
public void onBlockHarvested(World world, int x, int y, int z, int metadata, EntityPlayer player) {
@@ -144,7 +144,7 @@ public class BlockForestryLeaves extends BlockNewLeaf implements ITileEntityProv
}
private static ArrayList<ItemStack> getLeafDrop(World world, @Nullable GameProfile playerProfile, int x, int y, int z, float saplingModifier, int fortune) {
ArrayList<ItemStack> prod = new ArrayList<ItemStack>();
ArrayList<ItemStack> prod = new ArrayList<>();
TileLeaves tile = getLeafTile(world, x, y, z);
if (tile == null || tile.getTree() == null || tile.isDecorative()) {
@@ -80,7 +80,7 @@ public class BlockFruitPod extends BlockCocoa {
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
return new ArrayList<ItemStack>();
return new ArrayList<>();
}
@Override
@@ -25,7 +25,9 @@ import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.arboriculture.WoodType;
import forestry.api.arboriculture.EnumWoodType;
import forestry.api.arboriculture.TreeManager;
import forestry.arboriculture.render.IconProviderWood;
import forestry.arboriculture.tiles.TileWood;
public class BlockLog extends BlockWood {
@@ -84,8 +86,8 @@ public class BlockLog extends BlockWood {
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
for (WoodType woodType : WoodType.VALUES) {
list.add(woodType.getLog(isFireproof()));
for (EnumWoodType woodType : EnumWoodType.VALUES) {
list.add(TreeManager.woodItemAccess.getLog(woodType, isFireproof()));
}
}
@@ -93,18 +95,18 @@ public class BlockLog extends BlockWood {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
return WoodType.ACACIA.getIcon(meta, side);
return IconProviderWood.getLogIcon(EnumWoodType.LARCH, meta, side);
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
int meta = world.getBlockMetadata(x, y, z);
TileWood wood = getWoodTile(world, x, y, z);
WoodType type = wood.getWoodType();
EnumWoodType type = wood.getWoodType();
if (type == null) {
return getIcon(side, meta);
}
return type.getIcon(meta, side);
return IconProviderWood.getLogIcon(type, meta, side);
}
/* PROPERTIES */
@@ -20,7 +20,9 @@ import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.arboriculture.WoodType;
import forestry.api.arboriculture.EnumWoodType;
import forestry.api.arboriculture.TreeManager;
import forestry.arboriculture.render.IconProviderWood;
import forestry.arboriculture.tiles.TileWood;
public class BlockPlanks extends BlockWood {
@@ -34,8 +36,8 @@ public class BlockPlanks extends BlockWood {
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List list) {
for (WoodType woodType : WoodType.VALUES) {
list.add(woodType.getPlanks(isFireproof()));
for (EnumWoodType woodType : EnumWoodType.VALUES) {
list.add(TreeManager.woodItemAccess.getPlanks(woodType, isFireproof()));
}
}
@@ -43,14 +45,14 @@ public class BlockPlanks extends BlockWood {
@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon(int side, int meta) {
return WoodType.ACACIA.getPlankIcon();
return IconProviderWood.getPlankIcon(EnumWoodType.LARCH);
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
TileWood wood = getWoodTile(world, x, y, z);
WoodType type = wood.getWoodType();
return type.getPlankIcon();
EnumWoodType woodType = wood.getWoodType();
return IconProviderWood.getPlankIcon(woodType);
}
}
@@ -150,7 +150,7 @@ public class BlockSapling extends BlockTreeContainer implements IGrowable {
/* REMOVING */
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
return new ArrayList<ItemStack>();
return new ArrayList<>();
}
@Override
@@ -17,6 +17,7 @@ import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
@@ -35,13 +36,17 @@ import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.arboriculture.EnumWoodType;
import forestry.api.arboriculture.TreeManager;
import forestry.api.core.Tabs;
import forestry.arboriculture.IWoodTyped;
import forestry.arboriculture.WoodType;
import forestry.arboriculture.render.IconProviderWood;
import forestry.arboriculture.tiles.TileWood;
import forestry.core.render.ParticleHelper;
public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyped, ITileEntityProvider {
private final ParticleHelper.Callback particleCallback;
private final boolean fireproof;
public BlockSlab(boolean fireproof) {
@@ -55,6 +60,8 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
setResistance(5.0F);
setStepSound(soundTypeWood);
setHarvestLevel("axe", 0);
this.particleCallback = new ParticleHelper.DefaultCallback(this);
}
@Override
@@ -66,21 +73,21 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister register) {
WoodType.registerIcons(register);
IconProviderWood.registerIcons(register);
}
/* ICONS */
@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon(int side, int meta) {
return WoodType.ACACIA.getPlankIcon();
return IconProviderWood.getPlankIcon(EnumWoodType.LARCH);
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
TileWood wood = BlockWood.getWoodTile(world, x, y, z);
WoodType type = wood.getWoodType();
return type.getPlankIcon();
EnumWoodType woodType = wood.getWoodType();
return IconProviderWood.getPlankIcon(woodType);
}
@Override
@@ -101,8 +108,8 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List list) {
for (WoodType woodType : WoodType.VALUES) {
list.add(woodType.getSlab(fireproof));
for (EnumWoodType woodType : EnumWoodType.VALUES) {
list.add(TreeManager.woodItemAccess.getSlab(woodType, fireproof));
}
}
@@ -133,14 +140,14 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
return new ArrayList<ItemStack>();
return new ArrayList<>();
}
@Override
public final float getBlockHardness(World world, int x, int y, int z) {
TileWood wood = BlockWood.getWoodTile(world, x, y, z);
if (wood == null) {
return WoodType.DEFAULT_HARDNESS;
return EnumWoodType.DEFAULT_HARDNESS;
}
return wood.getWoodType().getHardness();
}
@@ -181,4 +188,17 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
public Item getItem(World world, int x, int y, int z) {
return Item.getItemFromBlock(this);
}
/* Particles */
@SideOnly(Side.CLIENT)
@Override
public boolean addHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
return ParticleHelper.addHitEffects(worldObj, this, target, effectRenderer, particleCallback);
}
@SideOnly(Side.CLIENT)
@Override
public boolean addDestroyEffects(World worldObj, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
return ParticleHelper.addDestroyEffects(worldObj, this, x, y, z, meta, effectRenderer, particleCallback);
}
}
@@ -15,6 +15,7 @@ import java.util.ArrayList;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@@ -30,14 +31,17 @@ import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.arboriculture.EnumWoodType;
import forestry.api.core.Tabs;
import forestry.arboriculture.IWoodTyped;
import forestry.arboriculture.WoodType;
import forestry.arboriculture.render.IconProviderWood;
import forestry.arboriculture.tiles.TileWood;
import forestry.core.render.ParticleHelper;
import forestry.core.tiles.TileUtil;
public abstract class BlockWood extends Block implements ITileEntityProvider, IWoodTyped {
private final ParticleHelper.Callback particleCallback;
private final String blockKind;
private final boolean fireproof;
@@ -48,6 +52,8 @@ public abstract class BlockWood extends Block implements ITileEntityProvider, IW
setStepSound(soundTypeWood);
setCreativeTab(Tabs.tabArboriculture);
particleCallback = new ParticleHelper.DefaultCallback(this);
}
@Override
@@ -70,7 +76,7 @@ public abstract class BlockWood extends Block implements ITileEntityProvider, IW
if (wood == null) {
return nbttagcompound;
}
WoodType woodType = wood.getWoodType();
EnumWoodType woodType = wood.getWoodType();
woodType.saveToCompound(nbttagcompound);
return nbttagcompound;
}
@@ -78,7 +84,7 @@ public abstract class BlockWood extends Block implements ITileEntityProvider, IW
@SideOnly(Side.CLIENT)
@Override
public final void registerBlockIcons(IIconRegister register) {
WoodType.registerIcons(register);
IconProviderWood.registerIcons(register);
}
@Override
@@ -107,14 +113,14 @@ public abstract class BlockWood extends Block implements ITileEntityProvider, IW
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
return new ArrayList<ItemStack>();
return new ArrayList<>();
}
@Override
public final float getBlockHardness(World world, int x, int y, int z) {
TileWood wood = getWoodTile(world, x, y, z);
if (wood == null) {
return WoodType.DEFAULT_HARDNESS;
return EnumWoodType.DEFAULT_HARDNESS;
}
return wood.getWoodType().getHardness();
}
@@ -137,4 +143,16 @@ public abstract class BlockWood extends Block implements ITileEntityProvider, IW
@SideOnly(Side.CLIENT)
public abstract IIcon getIcon(IBlockAccess world, int x, int y, int z, int side);
/* Particles */
@SideOnly(Side.CLIENT)
@Override
public boolean addHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
return ParticleHelper.addHitEffects(worldObj, this, target, effectRenderer, particleCallback);
}
@SideOnly(Side.CLIENT)
@Override
public boolean addDestroyEffects(World worldObj, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
return ParticleHelper.addDestroyEffects(worldObj, this, x, y, z, meta, effectRenderer, particleCallback);
}
}
@@ -73,7 +73,7 @@ public final class CommandTreeSpawn extends SubCommand {
}
private static String[] getSpecies() {
List<String> species = new ArrayList<String>();
List<String> species = new ArrayList<>();
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
if (allele instanceof IAlleleTreeSpecies) {
@@ -25,7 +25,7 @@ public class TreeModeHelper implements ICommandModeHelper {
public String[] getModeNames() {
ArrayList<ITreekeepingMode> treekeepingModes = TreeManager.treeRoot.getTreekeepingModes();
int modeStringCount = treekeepingModes.size();
List<String> modeStrings = new ArrayList<String>(modeStringCount);
List<String> modeStrings = new ArrayList<>(modeStringCount);
for (ITreekeepingMode mode : treekeepingModes) {
modeStrings.add(mode.getName());
}
@@ -38,7 +38,7 @@ public class TreeStatsSaveHelper implements IStatsSaveHelper {
@Override
public Collection<IAlleleSpecies> getSpecies() {
Collection<IAlleleSpecies> species = new ArrayList<IAlleleSpecies>();
Collection<IAlleleSpecies> species = new ArrayList<>();
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
if (allele instanceof IAlleleTreeSpecies) {
species.add((IAlleleTreeSpecies) allele);
@@ -335,7 +335,7 @@ public class Tree extends Individual implements ITree, IPlantable {
/* REPRODUCTION */
@Override
public ITree[] getSaplings(World world, GameProfile playerProfile, int x, int y, int z, float modifier) {
ArrayList<ITree> prod = new ArrayList<ITree>();
ArrayList<ITree> prod = new ArrayList<>();
float chance = genome.getFertility() * modifier;
@@ -27,6 +27,7 @@ import forestry.api.arboriculture.EnumFruitFamily;
import forestry.api.arboriculture.EnumGermlingType;
import forestry.api.arboriculture.EnumLeafType;
import forestry.api.arboriculture.EnumTreeChromosome;
import forestry.api.arboriculture.EnumWoodType;
import forestry.api.arboriculture.IAlleleTreeSpeciesCustom;
import forestry.api.arboriculture.IGermlingIconProvider;
import forestry.api.arboriculture.ILeafIconProvider;
@@ -39,7 +40,6 @@ import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.genetics.IAllele;
import forestry.api.world.ITreeGenData;
import forestry.arboriculture.WoodType;
import forestry.arboriculture.blocks.BlockForestryLeaves;
import forestry.arboriculture.render.IconProviderGermling;
import forestry.arboriculture.render.IconProviderGermlingVanilla;
@@ -156,7 +156,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
// vanilla
}
},
Lime(TreeBranchDefinition.TILIA, "silverLime", "pendula", true, EnumLeafType.DECIDUOUS, new Color(0x5ea107), new Color(0x5ea107).brighter(), WoodType.LIME) {
Lime(TreeBranchDefinition.TILIA, "silverLime", "pendula", true, EnumLeafType.DECIDUOUS, new Color(0x5ea107), new Color(0x5ea107).brighter(), EnumWoodType.LIME) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenLime(tree);
@@ -182,7 +182,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
registerMutation(Birch, Oak, 15);
}
},
Walnut(TreeBranchDefinition.JUGLANS, "commonWalnut", "regia", true, EnumLeafType.DECIDUOUS, new Color(0x798c55), new Color(0xb0c648), WoodType.WALNUT) {
Walnut(TreeBranchDefinition.JUGLANS, "commonWalnut", "regia", true, EnumLeafType.DECIDUOUS, new Color(0x798c55), new Color(0xb0c648), EnumWoodType.WALNUT) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenWalnut(tree);
@@ -210,7 +210,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
registerMutation(Lime, Cherry, 10);
}
},
Chestnut(TreeBranchDefinition.CASTANEA, "sweetChestnut", "sativa", true, EnumLeafType.DECIDUOUS, new Color(0x5ea107), new Color(0xb0c648), WoodType.CHESTNUT) {
Chestnut(TreeBranchDefinition.CASTANEA, "sweetChestnut", "sativa", true, EnumLeafType.DECIDUOUS, new Color(0x5ea107), new Color(0xb0c648), EnumWoodType.CHESTNUT) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenChestnut(tree);
@@ -238,7 +238,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
registerMutation(Walnut, Cherry, 10);
}
},
Cherry(TreeBranchDefinition.PRUNUS, "hillCherry", "serrulata", true, EnumLeafType.DECIDUOUS, new Color(0xe691da), new Color(0xe63e59), WoodType.CHERRY) {
Cherry(TreeBranchDefinition.PRUNUS, "hillCherry", "serrulata", true, EnumLeafType.DECIDUOUS, new Color(0xe691da), new Color(0xe63e59), EnumWoodType.CHERRY) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenCherry(tree);
@@ -265,7 +265,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
registerMutation(Lime, Birch, 10);
}
},
Lemon(TreeBranchDefinition.CITRUS, "lemon", "limon", true, EnumLeafType.DECIDUOUS, new Color(0x88af54), new Color(0xa3b850), WoodType.CITRUS) {
Lemon(TreeBranchDefinition.CITRUS, "lemon", "limon", true, EnumLeafType.DECIDUOUS, new Color(0x88af54), new Color(0xa3b850), EnumWoodType.CITRUS) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenLemon(tree);
@@ -290,7 +290,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
registerMutation(Lime, Cherry, 5);
}
},
Plum(TreeBranchDefinition.PRUNUS, "plum", "domestica", true, EnumLeafType.DECIDUOUS, new Color(0x589246), new Color(0xa3b850), WoodType.PLUM) {
Plum(TreeBranchDefinition.PRUNUS, "plum", "domestica", true, EnumLeafType.DECIDUOUS, new Color(0x589246), new Color(0xa3b850), EnumWoodType.PLUM) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenPlum(tree);
@@ -315,7 +315,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
registerMutation(Lemon, Cherry, 5);
}
},
Maple(TreeBranchDefinition.ACER, "sugarMaple", "saccharum", true, EnumLeafType.MAPLE, new Color(0xd4f425), new Color(0x619a3c), WoodType.MAPLE) {
Maple(TreeBranchDefinition.ACER, "sugarMaple", "saccharum", true, EnumLeafType.MAPLE, new Color(0xd4f425), new Color(0x619a3c), EnumWoodType.MAPLE) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenMaple(tree);
@@ -362,7 +362,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
// vanilla
}
},
Larch(TreeBranchDefinition.LARIX, "mundaneLarch", "decidua", true, EnumLeafType.CONIFERS, new Color(0x698f90), new Color(0x569896), WoodType.LARCH) {
Larch(TreeBranchDefinition.LARIX, "mundaneLarch", "decidua", true, EnumLeafType.CONIFERS, new Color(0x698f90), new Color(0x569896), EnumWoodType.LARCH) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenLarch(tree);
@@ -386,7 +386,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
registerMutation(Spruce, Oak, 10);
}
},
Pine(TreeBranchDefinition.PINUS, "bullPine", "sabiniana", true, EnumLeafType.CONIFERS, new Color(0xfeff8f), new Color(0xffd98f), WoodType.PINE) {
Pine(TreeBranchDefinition.PINUS, "bullPine", "sabiniana", true, EnumLeafType.CONIFERS, new Color(0xfeff8f), new Color(0xffd98f), EnumWoodType.PINE) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenPine(tree);
@@ -409,7 +409,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
registerMutation(Spruce, Larch, 10);
}
},
Sequioa(TreeBranchDefinition.SEQUOIA, "coastSequoia", "sempervirens", false, EnumLeafType.CONIFERS, new Color(0x418e71), new Color(0x569896), WoodType.SEQUOIA) {
Sequioa(TreeBranchDefinition.SEQUOIA, "coastSequoia", "sempervirens", false, EnumLeafType.CONIFERS, new Color(0x418e71), new Color(0x569896), EnumWoodType.SEQUOIA) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenSequoia(tree);
@@ -434,7 +434,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
registerMutation(Larch, Pine, 5);
}
},
Gigant(TreeBranchDefinition.SEQUOIADENDRON, "giantSequoia", "giganteum", false, EnumLeafType.CONIFERS, new Color(0x738434), new Color(0x738434).brighter(), WoodType.GIGANTEUM) {
Gigant(TreeBranchDefinition.SEQUOIADENDRON, "giantSequoia", "giganteum", false, EnumLeafType.CONIFERS, new Color(0x738434), new Color(0x738434).brighter(), EnumWoodType.GIGANTEUM) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenGiganteum(tree);
@@ -482,7 +482,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
// vanilla
}
},
Teak(TreeBranchDefinition.TECTONA, "teak", "grandis", true, EnumLeafType.JUNGLE, new Color(0xfeff8f), new Color(0xffd98f), WoodType.TEAK) {
Teak(TreeBranchDefinition.TECTONA, "teak", "grandis", true, EnumLeafType.JUNGLE, new Color(0xfeff8f), new Color(0xffd98f), EnumWoodType.TEAK) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenTeak(tree);
@@ -503,7 +503,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
registerMutation(DarkOak, Jungle, 10);
}
},
Ipe(TreeBranchDefinition.TABEBUIA, "ipe", "serratifolia", true, EnumLeafType.JUNGLE, new Color(0xfdd207), new Color(0xad8f04), WoodType.IPE) {
Ipe(TreeBranchDefinition.TABEBUIA, "ipe", "serratifolia", true, EnumLeafType.JUNGLE, new Color(0xfdd207), new Color(0xad8f04), EnumWoodType.IPE) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenIpe(tree);
@@ -526,7 +526,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
registerMutation(Teak, DarkOak, 10);
}
},
Kapok(TreeBranchDefinition.CEIBA, "kapok", "pentandra", true, EnumLeafType.JUNGLE, new Color(0x89987b), new Color(0x89aa9e), WoodType.KAPOK) {
Kapok(TreeBranchDefinition.CEIBA, "kapok", "pentandra", true, EnumLeafType.JUNGLE, new Color(0x89987b), new Color(0x89aa9e), EnumWoodType.KAPOK) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenKapok(tree);
@@ -550,7 +550,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
registerMutation(Jungle, Teak, 10);
}
},
Ebony(TreeBranchDefinition.EBONY, "myrtleEbony", "pentamera", true, EnumLeafType.JUNGLE, new Color(0xa2d24a), new Color(0xc4d24a), WoodType.EBONY) {
Ebony(TreeBranchDefinition.EBONY, "myrtleEbony", "pentamera", true, EnumLeafType.JUNGLE, new Color(0xa2d24a), new Color(0xc4d24a), EnumWoodType.EBONY) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenEbony(tree);
@@ -575,7 +575,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
registerMutation(DarkOak, Kapok, 10);
}
},
Zebrawood(TreeBranchDefinition.ASTRONIUM, "zebrawood", "graveolens", false, EnumLeafType.JUNGLE, new Color(0xa2d24a), new Color(0xc4d24a), WoodType.ZEBRAWOOD) {
Zebrawood(TreeBranchDefinition.ASTRONIUM, "zebrawood", "graveolens", false, EnumLeafType.JUNGLE, new Color(0xa2d24a), new Color(0xc4d24a), EnumWoodType.ZEBRAWOOD) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenZebrawood(tree);
@@ -597,7 +597,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
registerMutation(Ebony, Poplar, 5);
}
},
Mahogony(TreeBranchDefinition.MAHOGANY, "yellowMeranti", "gibbosa", true, EnumLeafType.JUNGLE, new Color(0x8ab154), new Color(0xa9b154), WoodType.MAHOGANY) {
Mahogony(TreeBranchDefinition.MAHOGANY, "yellowMeranti", "gibbosa", true, EnumLeafType.JUNGLE, new Color(0x8ab154), new Color(0xa9b154), EnumWoodType.MAHOGANY) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenMahogany(tree);
@@ -643,7 +643,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
// vanilla
}
},
Acacia(TreeBranchDefinition.ACACIA, "desertAcacia", "erioloba", true, EnumLeafType.DECIDUOUS, new Color(0x748C1C), new Color(0xb3b302), WoodType.ACACIA) {
Acacia(TreeBranchDefinition.ACACIA, "desertAcacia", "erioloba", true, EnumLeafType.DECIDUOUS, new Color(0x748C1C), new Color(0xb3b302), EnumWoodType.ACACIA) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenAcacia(tree);
@@ -665,7 +665,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
registerMutation(Teak, Balsa, 10);
}
},
Padauk(TreeBranchDefinition.PTEROCARPUS, "padauk", "soyauxii", true, EnumLeafType.DECIDUOUS, new Color(0xd0df8c), new Color(0x435c32), WoodType.PADAUK) {
Padauk(TreeBranchDefinition.PTEROCARPUS, "padauk", "soyauxii", true, EnumLeafType.DECIDUOUS, new Color(0xd0df8c), new Color(0x435c32), EnumWoodType.PADAUK) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenPadauk(tree);
@@ -687,7 +687,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
registerMutation(AcaciaVanilla, Jungle, 10);
}
},
Balsa(TreeBranchDefinition.OCHROMA, "balsa", "pyramidale", true, EnumLeafType.DECIDUOUS, new Color(0x59ac00), new Color(0xfeff8f), WoodType.BALSA) {
Balsa(TreeBranchDefinition.OCHROMA, "balsa", "pyramidale", true, EnumLeafType.DECIDUOUS, new Color(0x59ac00), new Color(0xfeff8f), EnumWoodType.BALSA) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenBalsa(tree);
@@ -711,7 +711,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
registerMutation(Teak, AcaciaVanilla, 10);
}
},
Cocobolo(TreeBranchDefinition.DALBERGIA, "cocobolo", "retusa", false, EnumLeafType.DECIDUOUS, new Color(0x6aa17a), new Color(0x487d4c), WoodType.COCOBOLO) {
Cocobolo(TreeBranchDefinition.DALBERGIA, "cocobolo", "retusa", false, EnumLeafType.DECIDUOUS, new Color(0x6aa17a), new Color(0x487d4c), EnumWoodType.COCOBOLO) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenCocobolo(tree);
@@ -732,7 +732,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
registerMutation(Acacia, DarkOak, 10);
}
},
Wenge(TreeBranchDefinition.MILLETTIA, "wenge", "laurentii", true, EnumLeafType.DECIDUOUS, new Color(0xada157), new Color(0xad8a57), WoodType.WENGE) {
Wenge(TreeBranchDefinition.MILLETTIA, "wenge", "laurentii", true, EnumLeafType.DECIDUOUS, new Color(0xada157), new Color(0xad8a57), EnumWoodType.WENGE) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenWenge(tree);
@@ -755,7 +755,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
registerMutation(Cocobolo, Balsa, 10);
}
},
Baobab(TreeBranchDefinition.ADANSONIA, "grandidierBaobab", "digitata", true, EnumLeafType.DECIDUOUS, new Color(0xfeff8f), new Color(0xffd98f), WoodType.BAOBAB) {
Baobab(TreeBranchDefinition.ADANSONIA, "grandidierBaobab", "digitata", true, EnumLeafType.DECIDUOUS, new Color(0xfeff8f), new Color(0xffd98f), EnumWoodType.BAOBAB) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenBaobab(tree);
@@ -781,7 +781,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
registerMutation(Balsa, Wenge, 10);
}
},
Mahoe(TreeBranchDefinition.TALIPARITI, "blueMahoe", "elatum", true, EnumLeafType.DECIDUOUS, new Color(0xa0ba1b), new Color(0x79a175), WoodType.MAHOE) {
Mahoe(TreeBranchDefinition.TALIPARITI, "blueMahoe", "elatum", true, EnumLeafType.DECIDUOUS, new Color(0xa0ba1b), new Color(0x79a175), EnumWoodType.MAHOE) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenMahoe(tree);
@@ -806,7 +806,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
registerMutation(Balsa, Acacia, 5);
}
},
Willow(TreeBranchDefinition.SALIX, "whiteWillow", "alba", true, EnumLeafType.WILLOW, new Color(0xa3b8a5), new Color(0xa3b850), WoodType.WILLOW) {
Willow(TreeBranchDefinition.SALIX, "whiteWillow", "alba", true, EnumLeafType.WILLOW, new Color(0xa3b8a5), new Color(0xa3b850), EnumWoodType.WILLOW) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenWillow(tree);
@@ -839,7 +839,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
.restrictHumidity(EnumHumidity.DAMP);
}
},
Sipiri(TreeBranchDefinition.CHLOROCARDIUM, "sipiri", "rodiei", true, EnumLeafType.DECIDUOUS, new Color(0x678911), new Color(0x79a175), WoodType.GREENHEART) {
Sipiri(TreeBranchDefinition.CHLOROCARDIUM, "sipiri", "rodiei", true, EnumLeafType.DECIDUOUS, new Color(0x678911), new Color(0x79a175), EnumWoodType.GREENHEART) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenGreenheart(tree);
@@ -865,7 +865,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
.restrictHumidity(EnumHumidity.DAMP);
}
},
Papaya(TreeBranchDefinition.CARICA, "papaya", "papaya", true, EnumLeafType.PALM, new Color(0x6d9f58), new Color(0x9ee67f), WoodType.PAPAYA) {
Papaya(TreeBranchDefinition.CARICA, "papaya", "papaya", true, EnumLeafType.PALM, new Color(0x6d9f58), new Color(0x9ee67f), EnumWoodType.PAPAYA) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenPapaya(tree);
@@ -890,7 +890,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
registerMutation(Jungle, Cherry, 5);
}
},
Date(TreeBranchDefinition.PHOENIX, "datePalm", "dactylifera", true, EnumLeafType.PALM, new Color(0xcbcd79), new Color(0xf0f38f), WoodType.PALM) {
Date(TreeBranchDefinition.PHOENIX, "datePalm", "dactylifera", true, EnumLeafType.PALM, new Color(0xcbcd79), new Color(0xf0f38f), EnumWoodType.PALM) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenDate(tree);
@@ -916,7 +916,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
registerMutation(Jungle, Papaya, 5);
}
},
Poplar(TreeBranchDefinition.POPULUS, "whitePoplar", "alba", true, EnumLeafType.DECIDUOUS, new Color(0xa3b8a5), new Color(0x539d12), WoodType.POPLAR) {
Poplar(TreeBranchDefinition.POPULUS, "whitePoplar", "alba", true, EnumLeafType.DECIDUOUS, new Color(0xa3b8a5), new Color(0x539d12), EnumWoodType.POPLAR) {
@Override
public WorldGenerator getWorldGenerator(ITreeGenData tree) {
return new WorldGenPoplar(tree);
@@ -946,7 +946,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
private final TreeBranchDefinition branch;
private final IAlleleTreeSpeciesCustom species;
private final WoodType woodType; // for forestry trees
private final EnumWoodType woodType; // for forestry trees
private final ItemStack vanillaWood; // for vanilla trees
private IAllele[] template;
@@ -969,7 +969,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
}
// forestry tree constructor
TreeDefinition(TreeBranchDefinition branch, String speciesName, String binomial, boolean dominant, EnumLeafType leafType, Color primary, Color secondary, WoodType woodType) {
TreeDefinition(TreeBranchDefinition branch, String speciesName, String binomial, boolean dominant, EnumLeafType leafType, Color primary, Color secondary, EnumWoodType woodType) {
String uid = "forestry.tree" + this.toString();
String unlocalizedDescription = "for.description.tree" + this.toString();
String unlocalizedName = "for.trees.species." + speciesName;
@@ -999,7 +999,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator {
} else {
AlleleBoolean fireproofAllele = (AlleleBoolean) genome.getActiveAllele(EnumTreeChromosome.FIREPROOF);
boolean fireproof = fireproofAllele.getValue();
ItemStack log = woodType.getLog(fireproof);
ItemStack log = TreeManager.woodItemAccess.getLog(woodType, fireproof);
BlockTypeLog logBlock = new BlockTypeLog(log);
logBlock.setDirection(facing);
@@ -63,9 +63,9 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot {
public static final String UID = "rootTrees";
private static int treeSpeciesCount = -1;
private static ITreekeepingMode activeTreekeepingMode;
public static final ArrayList<ITree> treeTemplates = new ArrayList<ITree>();
public static final ArrayList<ITree> treeTemplates = new ArrayList<>();
private final ArrayList<ITreekeepingMode> treekeepingModes = new ArrayList<ITreekeepingMode>();
private final ArrayList<ITreekeepingMode> treekeepingModes = new ArrayList<>();
public TreeHelper() {
setResearchSuitability(new ItemStack(Blocks.sapling, 1, OreDictionary.WILDCARD_VALUE), 1.0f);
@@ -343,7 +343,7 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot {
}
/* MUTATIONS */
private static final List<ITreeMutation> treeMutations = new ArrayList<ITreeMutation>();
private static final List<ITreeMutation> treeMutations = new ArrayList<>();
@Override
public List<ITreeMutation> getMutations(boolean shuffle) {
@@ -369,7 +369,7 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot {
}
/* ILEAFTICKHANDLER */
private final LinkedList<ILeafTickHandler> leafTickHandlers = new LinkedList<ILeafTickHandler>();
private final LinkedList<ILeafTickHandler> leafTickHandlers = new LinkedList<>();
@Override
public void registerLeafTickHandler(ILeafTickHandler handler) {
@@ -45,7 +45,7 @@ public class TreekeepingMode implements ITreekeepingMode {
@Override
public ArrayList<String> getDescription() {
ArrayList<String> ret = new ArrayList<String>();
ArrayList<String> ret = new ArrayList<>();
ret.add("treemode." + name.toLowerCase(Locale.ENGLISH) + ".desc");
return ret;
}
@@ -41,7 +41,7 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci
private final ITreeGenerator generator;
private final IGermlingIconProvider germlingIconProvider;
private final ILeafIconProvider leafIconProvider;
private final List<IFruitFamily> fruits = new ArrayList<IFruitFamily>();
private final List<IFruitFamily> fruits = new ArrayList<>();
private EnumPlantType nativeType = EnumPlantType.Plains;
@@ -47,7 +47,7 @@ public class GuiTreealyzer extends GuiAlyzer {
public GuiTreealyzer(EntityPlayer player, TreealyzerInventory inventory) {
super("rootTrees", player, new ContainerAlyzer(inventory, player), inventory, "gui.treealyzer");
ArrayList<ItemStack> treeList = new ArrayList<ItemStack>();
ArrayList<ItemStack> treeList = new ArrayList<>();
((ItemGermlingGE) ForestryItem.sapling.item()).addCreativeItems(treeList, false);
for (ItemStack treeStack : treeList) {
IAlleleTreeSpecies species = TreeGenome.getSpecies(treeStack);
@@ -189,12 +189,12 @@ public class GuiTreealyzer extends GuiAlyzer {
drawLine(StringUtil.localize("gui.tolerated"), COLUMN_0);
List<EnumPlantType> activeTolerated = new ArrayList<EnumPlantType>(tree.getGenome().getPlantTypes());
List<EnumPlantType> activeTolerated = new ArrayList<>(tree.getGenome().getPlantTypes());
List<EnumPlantType> inactiveTolerated = Collections.emptyList();
IAllele inactiveAllelePlant = tree.getGenome().getInactiveAllele(EnumTreeChromosome.PLANT);
if (inactiveAllelePlant instanceof AllelePlantType) {
inactiveTolerated = new ArrayList<EnumPlantType>(((AllelePlantType) inactiveAllelePlant).getPlantTypes());
inactiveTolerated = new ArrayList<>(((AllelePlantType) inactiveAllelePlant).getPlantTypes());
}
int max = Math.max(activeTolerated.size(), inactiveTolerated.size());
@@ -213,8 +213,8 @@ public class GuiTreealyzer extends GuiAlyzer {
// FRUITS
drawLine(StringUtil.localize("gui.supports"), COLUMN_0);
List<IFruitFamily> families0 = new ArrayList<IFruitFamily>(tree.getGenome().getPrimary().getSuitableFruit());
List<IFruitFamily> families1 = new ArrayList<IFruitFamily>(tree.getGenome().getSecondary().getSuitableFruit());
List<IFruitFamily> families0 = new ArrayList<>(tree.getGenome().getPrimary().getSuitableFruit());
List<IFruitFamily> families1 = new ArrayList<>(tree.getGenome().getSecondary().getSuitableFruit());
max = Math.max(families0.size(), families1.size());
for (int i = 0; i < max; i++) {
@@ -18,8 +18,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import forestry.api.arboriculture.EnumWoodType;
import forestry.arboriculture.IWoodTyped;
import forestry.arboriculture.WoodType;
import forestry.arboriculture.tiles.TileWood;
import forestry.core.config.Constants;
import forestry.core.items.ItemBlockForestry;
@@ -32,7 +32,7 @@ public class ItemBlockWood extends ItemBlockForestry {
}
public static boolean placeWood(ItemStack stack, @Nullable EntityPlayer player, World world, int x, int y, int z, int metadata) {
WoodType woodType = WoodType.getFromCompound(stack.getTagCompound());
EnumWoodType woodType = EnumWoodType.getFromCompound(stack.getTagCompound());
Block block = Block.getBlockFromItem(stack.getItem());
boolean placed = world.setBlock(x, y, z, block, metadata, Constants.FLAG_BLOCK_SYNCH_AND_UPDATE);
@@ -72,7 +72,7 @@ public class ItemBlockWood extends ItemBlockForestry {
return super.getItemStackDisplayName(itemstack);
}
WoodType woodType = getWood(itemstack);
EnumWoodType woodType = EnumWoodType.getFromCompound(itemstack.getTagCompound());
if (woodType == null) {
return super.getItemStackDisplayName(itemstack);
}
@@ -98,7 +98,4 @@ public class ItemBlockWood extends ItemBlockForestry {
return displayName;
}
private static WoodType getWood(ItemStack itemStack) {
return WoodType.getFromCompound(itemStack.getTagCompound());
}
}
@@ -12,13 +12,12 @@ package forestry.arboriculture.items;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import forestry.api.arboriculture.ITree;
import forestry.api.arboriculture.TreeManager;
import forestry.api.core.ForestryAPI;
import forestry.api.core.Tabs;
import forestry.api.genetics.ISpeciesRoot;
import forestry.core.config.Config;
import forestry.core.gui.IHintSource;
import forestry.core.items.ItemAlyzer;
@@ -50,52 +49,32 @@ public class ItemTreealyzer extends ItemAlyzer {
}
@Override
protected boolean isSpecimen(ItemStack itemStack) {
return GeneticsUtil.getGeneticEquivalent(itemStack) instanceof ITree;
protected ISpeciesRoot getSpeciesRoot() {
return TreeManager.treeRoot;
}
@Override
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
if (!TreeManager.treeRoot.isMember(itemStack)) {
ItemStack ersatz = GeneticsUtil.convertSaplingToGeneticEquivalent(itemStack);
if (ersatz != null) {
return super.canSlotAccept(slotIndex, ersatz);
}
}
return super.canSlotAccept(slotIndex, itemStack);
}
@Override
public void onSlotClick(EntityPlayer player) {
// Source slot to analyze empty
if (getStackInSlot(SLOT_SPECIMEN) == null) {
return;
}
if (!TreeManager.treeRoot.isMember(getStackInSlot(SLOT_SPECIMEN))) {
ItemStack ersatz = GeneticsUtil.convertSaplingToGeneticEquivalent(getStackInSlot(SLOT_SPECIMEN));
ItemStack specimen = getStackInSlot(SLOT_SPECIMEN);
if (!TreeManager.treeRoot.isMember(specimen)) {
ItemStack ersatz = GeneticsUtil.convertSaplingToGeneticEquivalent(specimen);
if (ersatz != null) {
setInventorySlotContents(SLOT_SPECIMEN, ersatz);
}
}
ITree tree = TreeManager.treeRoot.getMember(getStackInSlot(SLOT_SPECIMEN));
// No tree, abort
if (tree == null) {
return;
}
// Analyze if necessary
if (!tree.isAnalyzed()) {
// Requires energy
if (!isEnergy(getStackInSlot(SLOT_ENERGY))) {
return;
}
tree.analyze();
if (player != null) {
TreeManager.treeRoot.getBreedingTracker(player.worldObj, player.getGameProfile()).registerSpecies(tree.getGenome().getPrimary());
TreeManager.treeRoot.getBreedingTracker(player.worldObj, player.getGameProfile()).registerSpecies(tree.getGenome().getSecondary());
}
NBTTagCompound nbttagcompound = new NBTTagCompound();
tree.writeToNBT(nbttagcompound);
getStackInSlot(SLOT_SPECIMEN).setTagCompound(nbttagcompound);
// Decrease energy
decrStackSize(SLOT_ENERGY, 1);
}
setInventorySlotContents(SLOT_ANALYZE_1, getStackInSlot(SLOT_SPECIMEN));
setInventorySlotContents(SLOT_SPECIMEN, null);
super.onSlotClick(player);
}
// / IHINTSOURCE
@@ -0,0 +1,81 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.arboriculture.render;
import java.util.Locale;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.arboriculture.EnumWoodType;
import forestry.core.render.TextureManager;
public abstract class IconProviderWood {
@SideOnly(Side.CLIENT)
private static IIcon[][] icons;
@SideOnly(Side.CLIENT)
public static void registerIcons(IIconRegister register) {
icons = new IIcon[3][EnumWoodType.VALUES.length];
for (int i = 0; i < EnumWoodType.VALUES.length; i++) {
EnumWoodType woodType = EnumWoodType.VALUES[i];
String woodName = woodType.toString().toLowerCase(Locale.ENGLISH);
icons[0][i] = TextureManager.getInstance().registerTex(register, "wood/planks." + woodName);
icons[1][i] = TextureManager.getInstance().registerTex(register, "wood/bark." + woodName);
icons[2][i] = TextureManager.getInstance().registerTex(register, "wood/heart." + woodName);
}
}
@SideOnly(Side.CLIENT)
public static IIcon getPlankIcon(EnumWoodType woodType) {
return icons[0][woodType.ordinal()];
}
@SideOnly(Side.CLIENT)
public static IIcon getBarkIcon(EnumWoodType woodType) {
return icons[1][woodType.ordinal()];
}
@SideOnly(Side.CLIENT)
public static IIcon getHeartIcon(EnumWoodType woodType) {
return icons[2][woodType.ordinal()];
}
@SideOnly(Side.CLIENT)
public static IIcon getLogIcon(EnumWoodType woodType, int meta, int side) {
int oriented = meta & 12;
switch (oriented) {
case 4:
if (side > 3) {
return getHeartIcon(woodType);
} else {
return getBarkIcon(woodType);
}
case 8:
if (side == 2 || side == 3) {
return getHeartIcon(woodType);
} else {
return getBarkIcon(woodType);
}
case 0:
default:
if (side < 2) {
return getHeartIcon(woodType);
} else {
return getBarkIcon(woodType);
}
}
}
}
@@ -20,7 +20,7 @@ import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
import forestry.arboriculture.WoodType;
import forestry.api.arboriculture.EnumWoodType;
public class RenderFenceItem implements IItemRenderer {
@Override
@@ -61,8 +61,8 @@ public class RenderFenceItem implements IItemRenderer {
private static void renderItem(RenderBlocks renderer, ItemStack itemStack, float x, float y, float z) {
Tessellator tess = Tessellator.instance;
WoodType woodType = WoodType.getFromCompound(itemStack.getTagCompound());
IIcon plankIcon = woodType.getPlankIcon();
EnumWoodType woodType = EnumWoodType.getFromCompound(itemStack.getTagCompound());
IIcon plankIcon = IconProviderWood.getPlankIcon(woodType);
Block block = Block.getBlockFromItem(itemStack.getItem());
for (int i = 0; i < 4; ++i) {
@@ -49,6 +49,11 @@ public class RenderLeavesItem implements IItemRenderer {
@Override
public void renderItem(IItemRenderer.ItemRenderType type, ItemStack item, Object... data) {
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
switch (type) {
case ENTITY:
renderItem((RenderBlocks) data[0], item, 0f, 0f, 0f);
@@ -62,6 +67,8 @@ public class RenderLeavesItem implements IItemRenderer {
break;
default:
}
GL11.glPopAttrib();
}
private static void renderItem(RenderBlocks renderer, ItemStack itemStack, float x, float y, float z) {
@@ -79,8 +86,6 @@ public class RenderLeavesItem implements IItemRenderer {
leaves.setTree(TreeHelper.treeTemplates.get(0));
}
GL11.glEnable(GL11.GL_BLEND);
IIcon leavesIcon = leaves.getIcon(Proxies.render.fancyGraphicsEnabled());
if (leavesIcon == null) {
return;
@@ -20,7 +20,7 @@ import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
import forestry.arboriculture.WoodType;
import forestry.api.arboriculture.EnumWoodType;
import forestry.arboriculture.items.ItemBlockWood;
import forestry.core.utils.ItemStackUtil;
@@ -68,12 +68,10 @@ public class RenderLogItem implements IItemRenderer {
return;
}
WoodType woodType = WoodType.getFromCompound(itemStack.getTagCompound());
EnumWoodType woodType = EnumWoodType.getFromCompound(itemStack.getTagCompound());
GL11.glEnable(GL11.GL_BLEND);
IIcon barkIcon = woodType.getBarkIcon();
IIcon heartIcon = woodType.getHeartIcon();
IIcon barkIcon = IconProviderWood.getBarkIcon(woodType);
IIcon heartIcon = IconProviderWood.getHeartIcon(woodType);
if (barkIcon == null || heartIcon == null) {
return;
}
@@ -20,7 +20,7 @@ import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
import forestry.arboriculture.WoodType;
import forestry.api.arboriculture.EnumWoodType;
import forestry.arboriculture.items.ItemBlockWood;
import forestry.core.utils.ItemStackUtil;
@@ -68,11 +68,9 @@ public class RenderPlankItem implements IItemRenderer {
return;
}
WoodType woodType = WoodType.getFromCompound(itemStack.getTagCompound());
EnumWoodType woodType = EnumWoodType.getFromCompound(itemStack.getTagCompound());
GL11.glEnable(GL11.GL_BLEND);
IIcon plankIcon = woodType.getPlankIcon();
IIcon plankIcon = IconProviderWood.getPlankIcon(woodType);
if (plankIcon == null) {
return;
}
@@ -10,7 +10,7 @@ import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
import forestry.arboriculture.WoodType;
import forestry.api.arboriculture.EnumWoodType;
import forestry.arboriculture.items.ItemBlockWood;
import forestry.core.utils.ItemStackUtil;
@@ -58,11 +58,9 @@ public class RenderSlabItem implements IItemRenderer {
return;
}
WoodType woodType = WoodType.getFromCompound(itemStack.getTagCompound());
EnumWoodType woodType = EnumWoodType.getFromCompound(itemStack.getTagCompound());
GL11.glEnable(GL11.GL_BLEND);
IIcon plankIcon = woodType.getPlankIcon();
IIcon plankIcon = IconProviderWood.getPlankIcon(woodType);
if (plankIcon == null) {
return;
}
@@ -20,7 +20,8 @@ import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
import forestry.arboriculture.WoodType;
import forestry.api.arboriculture.EnumWoodType;
import forestry.arboriculture.items.ItemBlockWood;
import forestry.core.utils.ItemStackUtil;
public class RenderStairItem implements IItemRenderer {
@@ -60,12 +61,17 @@ public class RenderStairItem implements IItemRenderer {
}
}
private static void renderStairBlock(RenderBlocks renderBlocks, ItemStack item, float x, float y, float z) {
private static void renderStairBlock(RenderBlocks renderBlocks, ItemStack itemStack, float x, float y, float z) {
Tessellator tessellator = Tessellator.instance;
Block block = ItemStackUtil.getBlock(item);
Block block = ItemStackUtil.getBlock(itemStack);
IIcon texture = WoodType.getFromCompound(item.getTagCompound()).getPlankIcon();
if (!(itemStack.getItem() instanceof ItemBlockWood) || block == null) {
return;
}
EnumWoodType woodType = EnumWoodType.getFromCompound(itemStack.getTagCompound());
IIcon texture = IconProviderWood.getPlankIcon(woodType);
for (int i = 0; i < 2; ++i) {
if (i == 0) {
@@ -103,7 +109,6 @@ public class RenderStairItem implements IItemRenderer {
tessellator.draw();
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
}
}
}
@@ -21,7 +21,7 @@ import forestry.api.arboriculture.EnumLeafType;
import forestry.core.render.TextureManager;
public class TextureLeaves {
private static final Map<EnumLeafType, TextureLeaves> leafTextures = new EnumMap<EnumLeafType, TextureLeaves>(EnumLeafType.class);
private static final Map<EnumLeafType, TextureLeaves> leafTextures = new EnumMap<>(EnumLeafType.class);
static {
for (EnumLeafType leafType : EnumLeafType.values()) {
@@ -163,7 +163,7 @@ public class TileFruitPod extends TileEntity implements IFruitBearer, IStreamabl
@Override
public Collection<ItemStack> pickFruit(ItemStack tool) {
if (allele == null) {
return new ArrayList<ItemStack>();
return new ArrayList<>();
}
Collection<ItemStack> fruits = Arrays.asList(getDrop());
@@ -20,8 +20,8 @@ import net.minecraft.network.Packet;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import forestry.api.arboriculture.EnumWoodType;
import forestry.arboriculture.IWoodTyped;
import forestry.arboriculture.WoodType;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.IStreamable;
@@ -29,18 +29,18 @@ import forestry.core.network.PacketTileStream;
import forestry.core.utils.ItemStackUtil;
public class TileWood extends TileEntity implements IStreamable {
private WoodType woodType;
private EnumWoodType woodType;
public TileWood() {
this.woodType = WoodType.ACACIA;
this.woodType = EnumWoodType.LARCH;
}
public void setWoodType(WoodType woodType) {
public void setWoodType(EnumWoodType woodType) {
this.woodType = woodType;
markDirty();
}
public WoodType getWoodType() {
public EnumWoodType getWoodType() {
return woodType;
}
@@ -63,7 +63,7 @@ public class TileWood extends TileEntity implements IStreamable {
@Override
public void readData(DataInputStreamForestry data) throws IOException {
int ordinal = data.readVarInt();
woodType = WoodType.VALUES[ordinal];
woodType = EnumWoodType.VALUES[ordinal];
worldObj.func_147479_m(xCoord, yCoord, zCoord);
}
@@ -80,7 +80,7 @@ public class TileWood extends TileEntity implements IStreamable {
super.readFromNBT(nbt);
if (nbt.hasKey("WT")) {
int ordinal = nbt.getInteger("WT");
woodType = WoodType.VALUES[ordinal];
woodType = EnumWoodType.VALUES[ordinal];
}
}
@@ -50,7 +50,7 @@ import forestry.core.utils.PlayerUtil;
public class BlockBase extends BlockForestry {
private final List<MachineDefinition> definitions = new ArrayList<MachineDefinition>();
private final List<MachineDefinition> definitions = new ArrayList<>();
private final boolean hasTESR;
public BlockBase(Material material) {
@@ -49,7 +49,7 @@ public class BlockResourceOre extends Block {
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
ArrayList<ItemStack> drops = new ArrayList<>();
if (metadata == 0) {
int fortuneModifier = world.rand.nextInt(fortune + 2) - 1;
@@ -64,7 +64,7 @@ public class BlockSoil extends Block implements IItemTyped {
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
ArrayList<ItemStack> ret = new ArrayList<>();
SoilType type = getTypeFromMeta(metadata);
@@ -20,6 +20,7 @@ import forestry.api.circuits.ChipsetManager;
import forestry.api.circuits.ICircuit;
import forestry.api.circuits.ICircuitBoard;
import forestry.api.circuits.ICircuitLayout;
import forestry.api.circuits.ICircuitSocketType;
import forestry.core.proxy.Proxies;
import forestry.core.utils.StringUtil;
@@ -55,7 +56,7 @@ public class CircuitBoard<T> implements ICircuitBoard {
list.add(EnumChatFormatting.GOLD + layout.getUsage() + ":");
}
List<String> extendedTooltip = new ArrayList<String>();
List<String> extendedTooltip = new ArrayList<>();
for (ICircuit circuit : circuits) {
if (circuit != null) {
circuit.addTooltip(extendedTooltip);
@@ -82,11 +83,7 @@ public class CircuitBoard<T> implements ICircuitBoard {
ChipsetManager.circuitRegistry.getDefaultLayout();
}
List<ICircuit> readcircuits = new ArrayList<ICircuit>();
if (circuits != null) {
return;
}
circuits = new ICircuit[4];
for (int i = 0; i < 4; i++) {
if (!nbttagcompound.hasKey("CA.I" + i)) {
@@ -94,10 +91,9 @@ public class CircuitBoard<T> implements ICircuitBoard {
}
ICircuit circuit = ChipsetManager.circuitRegistry.getCircuit(nbttagcompound.getString("CA.I" + i));
if (circuit != null) {
readcircuits.add(circuit);
circuits[i] = circuit;
}
}
circuits = readcircuits.toArray(new ICircuit[readcircuits.size()]);
}
@Override
@@ -170,4 +166,9 @@ public class CircuitBoard<T> implements ICircuitBoard {
public ICircuit[] getCircuits() {
return circuits;
}
@Override
public ICircuitSocketType getSocketType() {
return layout.getSocketType();
}
}
@@ -11,14 +11,17 @@
package forestry.core.circuits;
import forestry.api.circuits.ICircuitLayout;
import forestry.api.circuits.ICircuitSocketType;
import forestry.core.utils.StringUtil;
public class CircuitLayout implements ICircuitLayout {
private final String uid;
private final ICircuitSocketType socketType;
public CircuitLayout(String uid) {
public CircuitLayout(String uid, ICircuitSocketType socketType) {
this.uid = uid;
this.socketType = socketType;
}
@Override
@@ -35,4 +38,9 @@ public class CircuitLayout implements ICircuitLayout {
public String getUsage() {
return StringUtil.localize("circuit.layout." + this.uid + ".usage");
}
@Override
public ICircuitSocketType getSocketType() {
return socketType;
}
}
@@ -17,6 +17,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import forestry.api.circuits.CircuitSocketType;
import forestry.api.circuits.ICircuit;
import forestry.api.circuits.ICircuitBoard;
import forestry.api.circuits.ICircuitLayout;
@@ -26,10 +27,10 @@ import forestry.core.config.ForestryItem;
public class CircuitRegistry implements ICircuitRegistry {
public static final ICircuitLayout DUMMY_LAYOUT = new CircuitLayout("dummy");
private static final Map<String, ICircuitLayout> DUMMY_MAP = new LinkedHashMap<String, ICircuitLayout>();
private final Map<String, ICircuitLayout> layoutMap = new LinkedHashMap<String, ICircuitLayout>();
private final Map<String, ICircuit> circuitMap = new LinkedHashMap<String, ICircuit>();
public static final ICircuitLayout DUMMY_LAYOUT = new CircuitLayout("dummy", CircuitSocketType.NONE);
private static final Map<String, ICircuitLayout> DUMMY_MAP = new LinkedHashMap<>();
private final Map<String, ICircuitLayout> layoutMap = new LinkedHashMap<>();
private final Map<String, ICircuit> circuitMap = new LinkedHashMap<>();
static {
DUMMY_MAP.put("dummy", DUMMY_LAYOUT);
@@ -10,10 +10,16 @@
******************************************************************************/
package forestry.core.circuits;
import java.util.Locale;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import forestry.api.circuits.CircuitSocketType;
import forestry.api.circuits.ICircuitLayout;
import forestry.api.circuits.ICircuitSocketType;
import forestry.api.farming.FarmDirection;
import forestry.core.circuits.ItemSolderingIron.CircuitRecipe;
import forestry.core.circuits.ItemSolderingIron.SolderingInventory;
import forestry.core.config.Constants;
@@ -37,17 +43,32 @@ public class GuiSolderingIron extends GuiForestry<ContainerSolderingIron, Solder
String title = layout.getName();
fontRendererObj.drawString(title, guiLeft + 8 + getCenteredOffset(title, 138), guiTop + 16, fontColor.get("gui.screen"));
for (int l = 2; l < inventory.getSizeInventory(); l++) {
for (int i = 0; i < 4; i++) {
String description;
CircuitRecipe recipe = ItemSolderingIron.SolderManager.getMatchingRecipe(layout, inventory.getStackInSlot(l));
ItemStack tube = inventory.getStackInSlot(i + 2);
CircuitRecipe recipe = ItemSolderingIron.SolderManager.getMatchingRecipe(layout, tube);
if (recipe == null) {
description = "(" + StringUtil.localize("gui.noeffect") + ")";
} else {
description = StringUtil.localize(recipe.circuit.getName()) + " (" + recipe.circuit.getLimit() + ")";
}
int row = (l - 2) * 20;
int row = i * 20;
fontRendererObj.drawString(description, guiLeft + 32, guiTop + 36 + row, fontColor.get("gui.screen"));
if (tube == null) {
try {
ICircuitSocketType socketType = layout.getSocketType();
if (CircuitSocketType.FARM.equals(socketType)) {
FarmDirection farmDirection = FarmDirection.values()[i];
String farmDirectionString = farmDirection.toString().toLowerCase(Locale.ENGLISH);
String localizedDirection = StringUtil.localize("gui.solder." + farmDirectionString);
fontRendererObj.drawString(localizedDirection, guiLeft + 17, guiTop + 36 + row, fontColor.get("gui.screen"));
}
} catch (Throwable ignored) {
// older circuit layouts do not have getSocketType()
}
}
}
}
@@ -12,10 +12,14 @@ package forestry.core.circuits;
import net.minecraft.item.ItemStack;
import forestry.api.circuits.ICircuitSocketType;
public interface ISocketable {
int getSocketCount();
ItemStack getSocket(int slot);
void setSocket(int slot, ItemStack stack);
ICircuitSocketType getSocketType();
}
@@ -58,7 +58,7 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron {
public static class SolderManager implements ISolderManager {
public static final ArrayList<CircuitRecipe> recipes = new ArrayList<CircuitRecipe>();
public static final ArrayList<CircuitRecipe> recipes = new ArrayList<>();
@Override
public void addRecipe(ICircuitLayout layout, ItemStack resource, ICircuit circuit) {
@@ -100,7 +100,7 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron {
// / INVENTORY MANAGMENT
public static class SolderingInventory extends ItemInventory implements IErrorSource {
private final RevolvingList<ICircuitLayout> layouts = new RevolvingList<ICircuitLayout>(ChipsetManager.circuitRegistry.getRegisteredLayouts().values());
private final RevolvingList<ICircuitLayout> layouts = new RevolvingList<>(ChipsetManager.circuitRegistry.getRegisteredLayouts().values());
private static final short blankSlot = 0;
private static final short finishedSlot = 1;
@@ -134,11 +134,11 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron {
layouts.rotateLeft();
}
private Collection<ICircuit> getCircuits(EnumCircuitBoardType type, boolean doConsume) {
private ICircuit[] getCircuits(boolean doConsume) {
ArrayList<ICircuit> circuits = new ArrayList<ICircuit>();
ICircuit[] circuits = new ICircuit[ingredientSlotCount];
for (short i = 0; i < type.sockets; i++) {
for (short i = 0; i < ingredientSlotCount; i++) {
ItemStack ingredient = getStackInSlot(ingredientSlot1 + i);
if (ingredient == null) {
continue;
@@ -157,7 +157,7 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron {
if (doConsume) {
decrStackSize(ingredientSlot1 + i, recipe.resource.stackSize);
}
circuits.add(recipe.circuit);
circuits[i] = recipe.circuit;
}
return circuits;
@@ -192,25 +192,33 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron {
}
EnumCircuitBoardType type = EnumCircuitBoardType.values()[blank.getItemDamage()];
Collection<ICircuit> circuits = getCircuits(type, false);
if (circuits.size() != type.sockets) {
if (getCircuitCount() != type.sockets) {
return;
}
circuits = getCircuits(type, true);
ICircuit[] circuits = getCircuits(true);
ICircuit[] circuitsArray = circuits.toArray(new ICircuit[circuits.size()]);
ItemStack circuitBoard = ItemCircuitBoard.createCircuitboard(type, layouts.getCurrent(), circuitsArray);
ItemStack circuitBoard = ItemCircuitBoard.createCircuitboard(type, layouts.getCurrent(), circuits);
setInventorySlotContents(finishedSlot, circuitBoard);
setInventorySlotContents(blankSlot, null);
}
public static int getCount(ICircuit circuit, ArrayList<ICircuit> circuits) {
private int getCircuitCount() {
ICircuit[] circuits = getCircuits(false);
int count = 0;
for (ICircuit circuit : circuits) {
if (circuit != null) {
count++;
}
}
return count;
}
public static int getCount(ICircuit circuit, ICircuit[] circuits) {
int count = 0;
for (ICircuit other : circuits) {
if (other.getUID().equals(circuit.getUID())) {
if (other != null && other.getUID().equals(circuit.getUID())) {
count++;
}
}
@@ -242,8 +250,8 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron {
if (circuitCount != type.sockets) {
errorStates.add(EnumErrorCode.CIRCUITMISMATCH);
} else {
Collection<ICircuit> circuits = getCircuits(type, false);
if (circuits.size() != type.sockets) {
int count = getCircuitCount();
if (count != type.sockets) {
errorStates.add(EnumErrorCode.NOCIRCUITLAYOUT);
}
}
@@ -170,7 +170,7 @@ public class CommandHelpers {
}
}
List<String> commandNames = new ArrayList<String>();
List<String> commandNames = new ArrayList<>();
for (SubCommand child : command.getChildren()) {
commandNames.add(child.getCommandName());
}
@@ -78,7 +78,7 @@ public final class CommandSaveStats extends SubCommand {
player = CommandHelpers.getPlayer(sender, sender.getCommandSenderName());
}
Collection<String> statistics = new ArrayList<String>();
Collection<String> statistics = new ArrayList<>();
String date = DateFormat.getInstance().format(new Date());
statistics.add(StatCollector.translateToLocalFormatted(saveHelper.getUnlocalizedSaveStatsString(), player.getDisplayName(), date));
@@ -27,7 +27,7 @@ public class RootCommand extends CommandBase implements IForestryCommand {
public static final String ROOT_COMMAND_NAME = "forestry";
public static final String ROOT_COMMAND_ALIAS = "for";
private final SortedSet<SubCommand> children = new TreeSet<SubCommand>(new Comparator<SubCommand>() {
private final SortedSet<SubCommand> children = new TreeSet<>(new Comparator<SubCommand>() {
@Override
public int compare(SubCommand o1, SubCommand o2) {
@@ -70,7 +70,7 @@ public class RootCommand extends CommandBase implements IForestryCommand {
@Override
public List<String> getCommandAliases() {
List<String> aliases = new ArrayList<String>();
List<String> aliases = new ArrayList<>();
aliases.add(ROOT_COMMAND_ALIAS);
return aliases;
}
@@ -37,10 +37,10 @@ public abstract class SubCommand implements IForestryCommand {
}
private final String name;
private final List<String> aliases = new ArrayList<String>();
private final List<String> aliases = new ArrayList<>();
private PermLevel permLevel = PermLevel.EVERYONE;
private IForestryCommand parent;
private final SortedSet<SubCommand> children = new TreeSet<SubCommand>(new Comparator<SubCommand>() {
private final SortedSet<SubCommand> children = new TreeSet<>(new Comparator<SubCommand>() {
@Override
public int compare(SubCommand o1, SubCommand o2) {
@@ -44,9 +44,9 @@ public class Config {
public static String gameMode;
private static final Set<String> disabledStructures = new HashSet<String>();
private static final Set<String> disabledFluids = new HashSet<String>();
private static final Set<String> disabledBlocks = new HashSet<String>();
private static final Set<String> disabledStructures = new HashSet<>();
private static final Set<String> disabledFluids = new HashSet<>();
private static final Set<String> disabledBlocks = new HashSet<>();
public static boolean isDebug = false;
@@ -83,7 +83,7 @@ public class Config {
private static boolean craftingBronzeEnabled = true;
public static boolean craftingStampsEnabled = true;
public static final ArrayList<String> collectorStamps = new ArrayList<String>();
public static final ArrayList<String> collectorStamps = new ArrayList<>();
public static int farmSize = 2;
public static boolean squareFarms = false;
@@ -98,7 +98,7 @@ public class Config {
// Hints
public static boolean enableHints = true;
public static final Map<String, String[]> hints = new HashMap<String, String[]>();
public static final Map<String, String[]> hints = new HashMap<>();
public static boolean enableEnergyStat = true;
public static boolean isStructureEnabled(String uid) {
@@ -29,7 +29,7 @@ public class ForestryGuiConfig extends GuiConfig {
}
private static List<IConfigElement> getConfigCategories() {
List<IConfigElement> configElements = new ArrayList<IConfigElement>();
List<IConfigElement> configElements = new ArrayList<>();
List<String> commonCategoryNames = Arrays.asList("crafting", "difficulty", "genetics", "performance", "structures", "tweaks", "world");
for (String categoryName : commonCategoryNames) {
@@ -37,10 +37,10 @@ public class GameMode implements IGameMode {
private String identifier = "EASY";
private final String category;
private final Map<String, Boolean> booleanSettings = new HashMap<String, Boolean>();
private final Map<String, Integer> integerSettings = new HashMap<String, Integer>();
private final Map<String, Float> floatSettings = new HashMap<String, Float>();
private final Map<String, ItemStack> stackSettings = new HashMap<String, ItemStack>();
private final Map<String, Boolean> booleanSettings = new HashMap<>();
private final Map<String, Integer> integerSettings = new HashMap<>();
private final Map<String, Float> floatSettings = new HashMap<>();
private final Map<String, ItemStack> stackSettings = new HashMap<>();
private static final float ENERGY_DEMAND_MODIFIER = 1.0f;
private static final float FUEL_MODIFIER = 1.0f;
@@ -14,7 +14,7 @@ import java.util.HashMap;
public class SessionVars {
private static final HashMap<String, String> stringVars = new HashMap<String, String>();
private static final HashMap<String, String> stringVars = new HashMap<>();
private static Class<?> openedLedger;
Loaded 100 of 244 files, more files were not shown because too many files have changed in this diff. Show more