mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-27 23:33:00 +00:00
Clean up Bee.java. Split Vect into MutableVect and (immutable) Vect.
This commit is contained in:
1 parent
90f80da4da
commit
08555326b2
53 files changed
+413
-320
No files matched your search
@@ -17,7 +17,7 @@ import forestry.core.gadgets.BlockStructure.EnumStructureState;
|
||||
import forestry.core.gadgets.StructureLogic;
|
||||
import forestry.core.utils.Schemata;
|
||||
import forestry.core.utils.Schemata.EnumStructureBlock;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import java.util.HashSet;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
||||
@@ -15,7 +15,7 @@ import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -17,7 +17,7 @@ import forestry.apiculture.gadgets.BlockAlveary;
|
||||
import forestry.apiculture.gadgets.TileAlveary;
|
||||
import forestry.apiculture.items.ItemArmorApiarist;
|
||||
import forestry.core.utils.DamageSourceForestry;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
@@ -15,7 +15,7 @@ import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
@@ -17,7 +17,7 @@ import forestry.api.genetics.IEffectData;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.genetics.Allele;
|
||||
import forestry.core.genetics.EffectData;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
|
||||
|
||||
@@ -10,6 +10,18 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.genetics;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.apiculture.IAlleleBeeEffect;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
@@ -31,27 +43,17 @@ import forestry.api.genetics.IFlowerProvider;
|
||||
import forestry.api.genetics.IGenome;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.core.utils.GeneticsUtil;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.genetics.Chromosome;
|
||||
import forestry.core.genetics.GenericRatings;
|
||||
import forestry.core.genetics.IndividualLiving;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.GeneticsUtil;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.MutableVect;
|
||||
import forestry.core.vect.Vect;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
public class Bee extends IndividualLiving implements IBee {
|
||||
|
||||
@@ -266,26 +268,16 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
|
||||
IFlowerProvider provider = genome.getFlowerProvider();
|
||||
|
||||
Vect coords = new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord());
|
||||
Vect posCurrent = new Vect(0, 0, 0);
|
||||
int[] areaAr = genome.getTerritory();
|
||||
Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]).multiply(housing.getTerritoryModifier(genome, 1f));
|
||||
|
||||
if (area.x < 1)
|
||||
area.x = 1;
|
||||
if (area.y < 1)
|
||||
area.y = 1;
|
||||
if (area.z < 1)
|
||||
area.z = 1;
|
||||
|
||||
Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 2), -Math.round(area.z / 2));
|
||||
Vect housingPos = new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord());
|
||||
Vect area = getArea(genome, housing);
|
||||
Vect offset = new Vect(-area.x / 2, -area.y / 2, -area.z / 2);
|
||||
|
||||
boolean hasFlower = false;
|
||||
|
||||
while (advancePosition(posCurrent, area)) {
|
||||
MutableVect posCurrent = new MutableVect(0, 0, 0);
|
||||
while (posCurrent.advancePositionInArea(area)) {
|
||||
|
||||
Vect posBlock = posCurrent.add(coords);
|
||||
posBlock = posBlock.add(offset);
|
||||
Vect posBlock = Vect.add(housingPos, posCurrent, offset);
|
||||
|
||||
if (provider.isAcceptedFlower(housing.getWorld(), this, posBlock.x, posBlock.y, posBlock.z)) {
|
||||
hasFlower = true;
|
||||
@@ -297,28 +289,6 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
return hasFlower;
|
||||
}
|
||||
|
||||
private boolean advancePosition(Vect posCurrent, Vect area) {
|
||||
// Increment z first until end reached
|
||||
if (posCurrent.z < area.z - 1)
|
||||
posCurrent.z++;
|
||||
else {
|
||||
posCurrent.z = 0;
|
||||
|
||||
if (posCurrent.x < area.x - 1)
|
||||
posCurrent.x++;
|
||||
else {
|
||||
posCurrent.x = 0;
|
||||
|
||||
if (posCurrent.y < area.y - 1)
|
||||
posCurrent.y++;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Integer> getSuitableBiomeIds() {
|
||||
ArrayList<Integer> suitableBiomes = new ArrayList<Integer>();
|
||||
@@ -571,14 +541,12 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
}
|
||||
|
||||
for (IBeeMutation mutation : PluginApiculture.beeInterface.getMutations(true)) {
|
||||
float chance = 0;
|
||||
|
||||
if ((chance = mutation.getChance(housing, allele0, allele1, genome0, genome1)) > 0)
|
||||
if (world.rand.nextFloat()*100 < chance) {
|
||||
IApiaristTracker breedingTracker = PluginApiculture.beeInterface.getBreedingTracker(world, housing.getOwnerName());
|
||||
breedingTracker.registerMutation(mutation);
|
||||
return PluginApiculture.beeInterface.templateAsChromosomes(mutation.getTemplate());
|
||||
}
|
||||
float chance = mutation.getChance(housing, allele0, allele1, genome0, genome1);
|
||||
if (chance > world.rand.nextFloat() * 100) {
|
||||
IApiaristTracker breedingTracker = PluginApiculture.beeInterface.getBreedingTracker(world, housing.getOwnerName());
|
||||
breedingTracker.registerMutation(mutation);
|
||||
return PluginApiculture.beeInterface.templateAsChromosomes(mutation.getTemplate());
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -588,33 +556,24 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
@Override
|
||||
public IIndividual retrievePollen(IBeeHousing housing) {
|
||||
|
||||
int chance = (int) (genome.getFlowering() * housing.getFloweringModifier(getGenome(), 1f));
|
||||
|
||||
// Correct speed
|
||||
if (housing.getWorld().rand.nextInt(100) >= chance)
|
||||
return null;
|
||||
|
||||
int[] areaAr = genome.getTerritory();
|
||||
Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]).multiply(housing.getTerritoryModifier(genome, 1f)).multiply(3.0f);
|
||||
Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 2), -Math.round(area.z / 2));
|
||||
|
||||
if (area.x < 1)
|
||||
area.x = 1;
|
||||
if (area.y < 1)
|
||||
area.y = 1;
|
||||
if (area.z < 1)
|
||||
area.z = 1;
|
||||
int chance = Math.round(genome.getFlowering() * housing.getFloweringModifier(getGenome(), 1f));
|
||||
|
||||
World world = housing.getWorld();
|
||||
Random random = world.rand;
|
||||
|
||||
// Correct speed
|
||||
if (random.nextInt(100) >= chance)
|
||||
return null;
|
||||
|
||||
Vect area = getArea(genome, housing);
|
||||
Vect offset = new Vect(-area.x / 2, -area.y / 4, -area.z / 2);
|
||||
Vect housingPos = new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord());
|
||||
|
||||
IIndividual pollen = null;
|
||||
|
||||
for (int i = 0; i < 20; i++) {
|
||||
Vect randomPos = new Vect(random.nextInt(area.x), random.nextInt(area.y), random.nextInt(area.z));
|
||||
Vect blockPos = housingPos.add(randomPos).add(offset);
|
||||
Vect randomPos = Vect.getRandomPositionInArea(random, area);
|
||||
Vect blockPos = Vect.add(housingPos, randomPos, offset);
|
||||
TileEntity tile = world.getTileEntity(blockPos.x, blockPos.y, blockPos.z);
|
||||
|
||||
if (tile instanceof IPollinatable) {
|
||||
@@ -637,33 +596,27 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
|
||||
int chance = (int) (genome.getFlowering() * housing.getFloweringModifier(getGenome(), 1f));
|
||||
|
||||
World world = housing.getWorld();
|
||||
Random random = world.rand;
|
||||
|
||||
// Correct speed
|
||||
if (housing.getWorld().rand.nextInt(100) >= chance)
|
||||
if (random.nextInt(100) >= chance)
|
||||
return false;
|
||||
|
||||
int[] areaAr = genome.getTerritory();
|
||||
Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]).multiply(housing.getTerritoryModifier(genome, 1f)).multiply(3.0f);
|
||||
Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 4), -Math.round(area.z / 2));
|
||||
|
||||
if (area.x < 1)
|
||||
area.x = 1;
|
||||
if (area.y < 1)
|
||||
area.y = 1;
|
||||
if (area.z < 1)
|
||||
area.z = 1;
|
||||
Vect area = getArea(genome, housing);
|
||||
Vect offset = new Vect(-area.x / 2, -area.y / 4, -area.z / 2);
|
||||
Vect housingPos = new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord());
|
||||
|
||||
for (int i = 0; i < 30; i++) {
|
||||
|
||||
Vect randomPos = new Vect(housing.getWorld().rand.nextInt(area.x), housing.getWorld().rand.nextInt(area.y), housing.getWorld().rand.nextInt(area.z));
|
||||
Vect randomPos = Vect.getRandomPositionInArea(random, area);
|
||||
Vect posBlock = Vect.add(housingPos, randomPos, offset);
|
||||
|
||||
Vect posBlock = randomPos.add(new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord()));
|
||||
posBlock = posBlock.add(offset);
|
||||
|
||||
IPollinatable receiver = GeneticsUtil.getOrCreatePollinatable(housing.getOwnerName(), housing.getWorld(), posBlock.x, posBlock.y, posBlock.z);
|
||||
IPollinatable receiver = GeneticsUtil.getOrCreatePollinatable(housing.getOwnerName(), world, posBlock.x, posBlock.y, posBlock.z);
|
||||
if(receiver == null)
|
||||
continue;
|
||||
|
||||
if (!genome.getFlowerProvider().isAcceptedPollinatable(housing.getWorld(), receiver))
|
||||
if (!genome.getFlowerProvider().isAcceptedPollinatable(world, receiver))
|
||||
continue;
|
||||
if (!receiver.canMateWith(pollen))
|
||||
continue;
|
||||
@@ -678,35 +631,33 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
@Override
|
||||
public void plantFlowerRandom(IBeeHousing housing) {
|
||||
|
||||
int chance = (int) (genome.getFlowering() * housing.getFloweringModifier(getGenome(), 1f));
|
||||
int chance = Math.round(genome.getFlowering() * housing.getFloweringModifier(getGenome(), 1f));
|
||||
|
||||
World world = housing.getWorld();
|
||||
Random random = world.rand;
|
||||
|
||||
// Correct speed
|
||||
if (housing.getWorld().rand.nextInt(100) >= chance)
|
||||
if (random.nextInt(100) >= chance)
|
||||
return;
|
||||
|
||||
// Gather required info
|
||||
IFlowerProvider provider = genome.getFlowerProvider();
|
||||
int[] areaAr = genome.getTerritory();
|
||||
Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]).multiply(housing.getTerritoryModifier(genome, 1f)).multiply(3.0f);
|
||||
Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 4), -Math.round(area.z / 2));
|
||||
Vect area = getArea(genome, housing);
|
||||
Vect offset = new Vect(-area.x / 2, -area.y / 4, -area.z / 2);
|
||||
Vect housingPos = new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord());
|
||||
|
||||
if (area.x < 1)
|
||||
area.x = 1;
|
||||
if (area.y < 1)
|
||||
area.y = 1;
|
||||
if (area.z < 1)
|
||||
area.z = 1;
|
||||
|
||||
// We have up to ten attempts
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Vect randomPos = Vect.getRandomPositionInArea(random, area);
|
||||
Vect posBlock = Vect.add(housingPos, randomPos, offset);
|
||||
|
||||
Vect randomPos = new Vect(housing.getWorld().rand.nextInt(area.x), housing.getWorld().rand.nextInt(area.y), housing.getWorld().rand.nextInt(area.z));
|
||||
|
||||
Vect posBlock = randomPos.add(new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord()));
|
||||
posBlock = posBlock.add(offset);
|
||||
|
||||
if (provider.growFlower(housing.getWorld(), this, posBlock.x, posBlock.y, posBlock.z))
|
||||
if (provider.growFlower(world, this, posBlock.x, posBlock.y, posBlock.z))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static Vect getArea(IBeeGenome genome, IBeeHousing housing) {
|
||||
int[] genomeTerritory = genome.getTerritory();
|
||||
float housingModifier = housing.getTerritoryModifier(genome, 1f);
|
||||
return new Vect(genomeTerritory).multiply(housingModifier * 3.0f);
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ import forestry.core.genetics.AlleleArea;
|
||||
import forestry.core.genetics.AlleleBoolean;
|
||||
import forestry.core.genetics.AlleleTolerance;
|
||||
import forestry.core.genetics.Genome;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@@ -15,7 +15,7 @@ import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IGenome;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import java.lang.reflect.Field;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
@@ -25,7 +25,7 @@ import forestry.core.genetics.AlleleArea;
|
||||
import forestry.core.genetics.AlleleBoolean;
|
||||
import forestry.core.gui.GuiAlyzer;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
@@ -25,7 +25,7 @@ import forestry.core.inventory.ItemInventory;
|
||||
import forestry.core.items.ItemInventoried;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
||||
@@ -14,7 +14,7 @@ import forestry.api.arboriculture.IAlleleLeafEffect;
|
||||
import forestry.api.arboriculture.ITreeGenome;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
import forestry.core.genetics.Allele;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import forestry.api.arboriculture.ITreeGenome;
|
||||
import forestry.arboriculture.gadgets.TileSapling;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.core.utils.Utils;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.world.ITreeGenData;
|
||||
import forestry.arboriculture.gadgets.TileSapling;
|
||||
import forestry.core.utils.Utils;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import forestry.core.worldgen.BlockType;
|
||||
import forestry.core.worldgen.WorldGenBase;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
||||
@@ -16,7 +16,7 @@ import forestry.core.config.Defaults;
|
||||
import forestry.core.gadgets.BlockStructure.EnumStructureState;
|
||||
import forestry.core.utils.Schemata;
|
||||
import forestry.core.utils.Schemata.EnumStructureBlock;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import java.util.HashMap;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
@@ -30,7 +30,7 @@ import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.AdjacentTileCache;
|
||||
import forestry.core.utils.EnumAccess;
|
||||
import forestry.core.utils.PlayerUtil;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import java.util.Collection;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
||||
@@ -12,7 +12,7 @@ package forestry.core.genetics;
|
||||
|
||||
import forestry.api.genetics.IAlleleArea;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
|
||||
public class AlleleArea extends Allele implements IAlleleArea {
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ import buildcraft.api.transport.IPipeTile;
|
||||
import buildcraft.api.transport.IPipeTile.PipeType;
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.vect.Vect;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.core.utils;
|
||||
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.vect.Vect;
|
||||
|
||||
public class Schemata {
|
||||
public enum EnumStructureBlock {
|
||||
|
||||
@@ -37,6 +37,7 @@ import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.ITileStructure;
|
||||
import forestry.core.gadgets.TileForestry;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.vect.Vect;
|
||||
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/*******************************************************************************
|
||||
* 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.core.vect;
|
||||
|
||||
/**
|
||||
* Represents a position or dimensions.
|
||||
*/
|
||||
public interface IVect {
|
||||
int getX();
|
||||
int getY();
|
||||
int getZ();
|
||||
|
||||
IVect add(IVect other);
|
||||
IVect add(int x, int y, int z);
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*******************************************************************************
|
||||
* 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.core.vect;
|
||||
|
||||
/**
|
||||
* Represents changeable positions or dimensions.
|
||||
*/
|
||||
public class MutableVect implements IVect {
|
||||
public int x;
|
||||
public int y;
|
||||
public int z;
|
||||
|
||||
public MutableVect(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public MutableVect(IVect vect) {
|
||||
this.x = vect.getX();
|
||||
this.y = vect.getY();
|
||||
this.z = vect.getZ();
|
||||
}
|
||||
|
||||
public MutableVect add(IVect other) {
|
||||
x += other.getX();
|
||||
y += other.getY();
|
||||
z += other.getZ();
|
||||
return this;
|
||||
}
|
||||
|
||||
public MutableVect add(int x, int y, int z) {
|
||||
this.x += x;
|
||||
this.y += y;
|
||||
this.z += z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean advancePositionInArea(Vect area) {
|
||||
// Increment z first until end reached
|
||||
if (z < area.z - 1)
|
||||
z++;
|
||||
else {
|
||||
z = 0;
|
||||
|
||||
if (x < area.x - 1)
|
||||
x++;
|
||||
else {
|
||||
x = 0;
|
||||
|
||||
if (y < area.y - 1)
|
||||
y++;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
}
|
||||
Executable → Regular
+110
-84
@@ -1,84 +1,110 @@
|
||||
/*******************************************************************************
|
||||
* 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.core.utils;
|
||||
|
||||
/**
|
||||
* Generic class to represent a position or dimensions.
|
||||
*/
|
||||
public class Vect {
|
||||
public int x;
|
||||
public int y;
|
||||
public int z;
|
||||
|
||||
public Vect(int[] dim) {
|
||||
if (dim.length != 3)
|
||||
throw new RuntimeException("Cannot instantiate a vector with less or more than 3 points.");
|
||||
|
||||
this.x = dim[0];
|
||||
this.y = dim[1];
|
||||
this.z = dim[2];
|
||||
}
|
||||
|
||||
public Vect(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public Vect add(Vect other) {
|
||||
Vect result = new Vect(x, y, z);
|
||||
result.x += other.x;
|
||||
result.y += other.y;
|
||||
result.z += other.z;
|
||||
return result;
|
||||
}
|
||||
|
||||
public Vect multiply(float factor) {
|
||||
Vect result = new Vect(x, y, z);
|
||||
result.x *= factor;
|
||||
result.y *= factor;
|
||||
result.z *= factor;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%sx%sx%s", x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + x;
|
||||
result = prime * result + y;
|
||||
result = prime * result + z;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Vect other = (Vect) obj;
|
||||
if (x != other.x)
|
||||
return false;
|
||||
if (y != other.y)
|
||||
return false;
|
||||
if (z != other.z)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
* 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.core.vect;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Represents an unchangeable position or dimensions.
|
||||
*/
|
||||
public class Vect implements IVect {
|
||||
public final int x;
|
||||
public final int y;
|
||||
public final int z;
|
||||
|
||||
public Vect(int[] dim) {
|
||||
if (dim.length != 3)
|
||||
throw new RuntimeException("Cannot instantiate a vector with less or more than 3 points.");
|
||||
|
||||
this.x = dim[0];
|
||||
this.y = dim[1];
|
||||
this.z = dim[2];
|
||||
}
|
||||
|
||||
public Vect(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public static Vect getRandomPositionInArea(Random random, IVect area) {
|
||||
int x = random.nextInt(area.getX());
|
||||
int y = random.nextInt(area.getY());
|
||||
int z = random.nextInt(area.getZ());
|
||||
return new Vect(x, y, z);
|
||||
}
|
||||
|
||||
public static Vect add(IVect... vects) {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int z = 0;
|
||||
for (IVect vect : vects) {
|
||||
x += vect.getX();
|
||||
y += vect.getY();
|
||||
z += vect.getZ();
|
||||
}
|
||||
return new Vect(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vect add(IVect other) {
|
||||
return new Vect(x + other.getX(), y + other.getY(), z + other.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vect add(int x, int y, int z) {
|
||||
return new Vect(this.x + x, this.y + y, this.z + z);
|
||||
}
|
||||
|
||||
public Vect multiply(float factor) {
|
||||
return new Vect(Math.round(x * factor), Math.round(y * factor), Math.round(z * factor));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%sx%sx%s", x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + x;
|
||||
result = prime * result + y;
|
||||
result = prime * result + z;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (!(obj instanceof Vect))
|
||||
return false;
|
||||
Vect other = (Vect) obj;
|
||||
return (x == other.x) && (y == other.y) && (z == other.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
}
|
||||
@@ -1,53 +1,53 @@
|
||||
/*******************************************************************************
|
||||
* 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.farming;
|
||||
|
||||
import forestry.core.utils.Vect;
|
||||
|
||||
public class FarmTarget {
|
||||
|
||||
private Vect start;
|
||||
private int yOffset;
|
||||
private int extent;
|
||||
private int limit;
|
||||
|
||||
public FarmTarget(Vect start) {
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
public void setYOffset(int yOffset) {
|
||||
this.yOffset = yOffset;
|
||||
}
|
||||
|
||||
public void setLimit(int limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
public void setExtent(int extent) {
|
||||
this.extent = extent;
|
||||
}
|
||||
|
||||
public Vect getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
public int getYOffset() {
|
||||
return this.yOffset;
|
||||
}
|
||||
|
||||
public int getLimit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
public int getExtent() {
|
||||
return extent;
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
* 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.farming;
|
||||
|
||||
import forestry.core.vect.Vect;
|
||||
|
||||
public class FarmTarget {
|
||||
|
||||
private Vect start;
|
||||
private int yOffset;
|
||||
private int extent;
|
||||
private int limit;
|
||||
|
||||
public FarmTarget(Vect start) {
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
public void setYOffset(int yOffset) {
|
||||
this.yOffset = yOffset;
|
||||
}
|
||||
|
||||
public void setLimit(int limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
public void setExtent(int extent) {
|
||||
this.extent = extent;
|
||||
}
|
||||
|
||||
public Vect getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
public int getYOffset() {
|
||||
return this.yOffset;
|
||||
}
|
||||
|
||||
public int getLimit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
public int getExtent() {
|
||||
return extent;
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import forestry.core.gadgets.BlockStructure.EnumStructureState;
|
||||
import forestry.core.gadgets.StructureLogic;
|
||||
import forestry.core.utils.Schemata;
|
||||
import forestry.core.utils.Schemata.EnumStructureBlock;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
@@ -15,7 +15,7 @@ import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmComponent;
|
||||
import forestry.api.farming.IFarmListener;
|
||||
import forestry.api.farming.IFarmLogic;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import java.util.Collection;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
@@ -38,7 +38,7 @@ import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.DelayTimer;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.Utils;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import forestry.farming.FarmTarget;
|
||||
import forestry.farming.logic.FarmLogicArboreal;
|
||||
import forestry.plugins.PluginFarming;
|
||||
|
||||
@@ -12,7 +12,7 @@ package forestry.farming.logic;
|
||||
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import java.util.Collection;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
package forestry.farming.logic;
|
||||
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import java.util.Collection;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -14,7 +14,7 @@ import forestry.api.genetics.IFruitBearer;
|
||||
import forestry.api.genetics.IFruitFamily;
|
||||
import forestry.core.network.PacketFXSignal;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -13,7 +13,7 @@ package forestry.farming.logic;
|
||||
import forestry.core.gadgets.BlockSoil;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
@@ -12,7 +12,7 @@ package forestry.farming.logic;
|
||||
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import forestry.plugins.PluginIC2;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -10,21 +10,25 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.logic;
|
||||
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
import forestry.api.farming.IFarmLogic;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.config.ForestryBlock;
|
||||
import forestry.core.render.SpriteSheet;
|
||||
import forestry.core.utils.Vect;
|
||||
import java.util.HashSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
import forestry.api.farming.IFarmLogic;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.config.ForestryBlock;
|
||||
import forestry.core.render.SpriteSheet;
|
||||
import forestry.core.vect.IVect;
|
||||
import forestry.core.vect.Vect;
|
||||
|
||||
public abstract class FarmLogic implements IFarmLogic {
|
||||
|
||||
IFarmHousing housing;
|
||||
@@ -67,8 +71,8 @@ public abstract class FarmLogic implements IFarmLogic {
|
||||
return SpriteSheet.ITEMS.getLocation();
|
||||
}
|
||||
|
||||
protected final boolean isAirBlock(Vect position) {
|
||||
return getWorld().isAirBlock(position.x, position.y, position.z);
|
||||
protected final boolean isAirBlock(IVect position) {
|
||||
return getWorld().isAirBlock(position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
protected final boolean isAirBlock(Block block) {
|
||||
@@ -80,20 +84,20 @@ public abstract class FarmLogic implements IFarmLogic {
|
||||
world.getBlockMetadata(position.x, position.y, position.z) == 0;
|
||||
}
|
||||
|
||||
protected final boolean isWoodBlock(Vect position) {
|
||||
protected final boolean isWoodBlock(IVect position) {
|
||||
Block block = getBlock(position);
|
||||
return block.isWood(getWorld(), position.x, position.y, position.z);
|
||||
return block.isWood(getWorld(), position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
protected final Block getBlock(Vect position) {
|
||||
return getWorld().getBlock(position.x, position.y, position.z);
|
||||
protected final Block getBlock(IVect position) {
|
||||
return getWorld().getBlock(position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
protected final int getBlockMeta(Vect position) {
|
||||
return getWorld().getBlockMetadata(position.x, position.y, position.z);
|
||||
protected final int getBlockMeta(IVect position) {
|
||||
return getWorld().getBlockMetadata(position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
protected final ItemStack getAsItemStack(Vect position) {
|
||||
protected final ItemStack getAsItemStack(IVect position) {
|
||||
return new ItemStack(getBlock(position), 1, getBlockMeta(position));
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import forestry.api.farming.IFarmable;
|
||||
import forestry.core.config.ForestryBlock;
|
||||
import forestry.core.gadgets.BlockSoil;
|
||||
import forestry.core.render.SpriteSheet;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@@ -101,7 +101,7 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous {
|
||||
Vect offset = new Vect(housing.getOffset());
|
||||
|
||||
Vect min = coords.add(offset);
|
||||
Vect max = coords.add(offset).add(area);
|
||||
Vect max = min.add(area);
|
||||
|
||||
AxisAlignedBB harvestBox = AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, getWorld().getHeight(), max.z);
|
||||
List<Entity> list = getWorld().getEntitiesWithinAABB(Entity.class, harvestBox);
|
||||
|
||||
@@ -15,7 +15,8 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.MutableVect;
|
||||
import forestry.core.vect.Vect;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@@ -123,7 +124,7 @@ public class FarmLogicCocoa extends FarmLogic {
|
||||
|
||||
World world = getWorld();
|
||||
|
||||
Vect current = position;
|
||||
MutableVect current = new MutableVect(position);
|
||||
while (isWoodBlock(current) && BlockLog.func_150165_c(getBlockMeta(current)) == 3) {
|
||||
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
|
||||
@@ -135,7 +136,7 @@ public class FarmLogicCocoa extends FarmLogic {
|
||||
return housing.plantGermling(cocoa, world, candidate.x, candidate.y, candidate.z);
|
||||
}
|
||||
|
||||
current = current.add(new Vect(0, 1, 0));
|
||||
current.y++;
|
||||
if (current.y - position.y > 1)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@ import forestry.api.farming.IFarmable;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.Utils;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.IVect;
|
||||
import forestry.core.vect.Vect;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -74,7 +75,7 @@ public abstract class FarmLogicCrops extends FarmLogicWatered {
|
||||
Vect offset = new Vect(housing.getOffset());
|
||||
|
||||
Vect min = coords.add(offset);
|
||||
Vect max = coords.add(offset).add(area);
|
||||
Vect max = min.add(area);
|
||||
|
||||
AxisAlignedBB harvestBox = AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, max.y, max.z);
|
||||
List<Entity> list = housing.getWorld().getEntitiesWithinAABB(Entity.class, harvestBox);
|
||||
@@ -106,7 +107,7 @@ public abstract class FarmLogicCrops extends FarmLogicWatered {
|
||||
if (!isAirBlock(position) && !Utils.isReplaceableBlock(getWorld(), position.x, position.y, position.z))
|
||||
continue;
|
||||
|
||||
ItemStack below = getAsItemStack(position.add(new Vect(0, -1, 0)));
|
||||
ItemStack below = getAsItemStack(position.add(0, -1, 0));
|
||||
if (ground.getItem() != below.getItem())
|
||||
continue;
|
||||
if (below.getItemDamage() <= 0)
|
||||
@@ -118,11 +119,11 @@ public abstract class FarmLogicCrops extends FarmLogicWatered {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean trySetCrop(Vect position) {
|
||||
private boolean trySetCrop(IVect position) {
|
||||
World world = getWorld();
|
||||
|
||||
for (IFarmable candidate : seeds)
|
||||
if (housing.plantGermling(candidate, world, position.x, position.y, position.z))
|
||||
if (housing.plantGermling(candidate, world, position.getX(), position.getY(), position.getZ()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
@@ -16,7 +16,7 @@ import forestry.api.farming.Farmables;
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import java.util.Collection;
|
||||
import java.util.Stack;
|
||||
import net.minecraft.init.Items;
|
||||
|
||||
@@ -14,7 +14,7 @@ import forestry.api.farming.IFarmHousing;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@@ -17,7 +17,7 @@ import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.utils.Utils;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import java.util.Collection;
|
||||
import java.util.Stack;
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -89,7 +89,7 @@ public class FarmLogicInfernal extends FarmLogicHomogeneous {
|
||||
if (!isAirBlock(position) && !Utils.isReplaceableBlock(world, position.x, position.y, position.z))
|
||||
continue;
|
||||
|
||||
ItemStack below = getAsItemStack(position.add(new Vect(0, -1, 0)));
|
||||
ItemStack below = getAsItemStack(position.add(0, -1, 0));
|
||||
if (!isAcceptedGround(below))
|
||||
continue;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
import forestry.api.genetics.IFruitBearer;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -17,7 +17,7 @@ import forestry.api.farming.IFarmHousing;
|
||||
import forestry.core.config.ForestryBlock;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.gadgets.BlockSoil;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import java.util.Collection;
|
||||
import java.util.Stack;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
@@ -17,7 +17,7 @@ import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import java.util.Collection;
|
||||
import java.util.Stack;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
||||
@@ -16,7 +16,7 @@ import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import forestry.plugins.PluginIC2;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -17,7 +17,7 @@ import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import java.util.Collection;
|
||||
import java.util.Stack;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
||||
@@ -15,7 +15,7 @@ import forestry.core.fluids.Fluids;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.Utils;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -154,7 +154,7 @@ public abstract class FarmLogicWatered extends FarmLogic {
|
||||
// don't place water close to other water
|
||||
for (int x = -2; x <= 2; x++) {
|
||||
for (int z = -2; z <= 2; z++) {
|
||||
Vect offsetPosition = position.add(new Vect(x, 0, z));
|
||||
Vect offsetPosition = position.add(x, 0, z);
|
||||
if (isWaterSourceBlock(world, offsetPosition))
|
||||
return false;
|
||||
}
|
||||
@@ -162,12 +162,12 @@ public abstract class FarmLogicWatered extends FarmLogic {
|
||||
|
||||
// don't place water if it can flow into blocks next to it
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
Vect offsetPosition = position.add(new Vect(x, 0, 0));
|
||||
Vect offsetPosition = position.add(x, 0, 0);
|
||||
if (isAirBlock(offsetPosition))
|
||||
return false;
|
||||
}
|
||||
for (int z = -1; z <= 1; z++) {
|
||||
Vect offsetPosition = position.add(new Vect(0, 0, z));
|
||||
Vect offsetPosition = position.add(0, 0, z);
|
||||
if (isAirBlock(offsetPosition))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ package forestry.farming.logic;
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
||||
@@ -13,7 +13,7 @@ package forestry.farming.logic;
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import forestry.plugins.PluginFarmCraftory;
|
||||
import java.util.Collection;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
@@ -15,7 +15,7 @@ import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.arboriculture.genetics.TreeGenome;
|
||||
import forestry.core.config.ForestryBlock;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -12,7 +12,7 @@ package forestry.farming.logic;
|
||||
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -13,7 +13,7 @@ package forestry.farming.logic;
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -14,7 +14,7 @@ import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -14,7 +14,7 @@ import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -15,7 +15,7 @@ import forestry.core.config.Defaults;
|
||||
import forestry.core.config.ForestryBlock;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
||||
Reference in new issue
Block a user