diff --git a/src/main/java/forestry/api/apiculture/IBeeGenome.java b/src/main/java/forestry/api/apiculture/IBeeGenome.java index 561d40852..05a0dc97f 100644 --- a/src/main/java/forestry/api/apiculture/IBeeGenome.java +++ b/src/main/java/forestry/api/apiculture/IBeeGenome.java @@ -5,6 +5,8 @@ ******************************************************************************/ package forestry.api.apiculture; +import net.minecraft.util.math.Vec3i; + import forestry.api.genetics.EnumTolerance; import forestry.api.genetics.IFlowerProvider; import forestry.api.genetics.IGenome; @@ -43,7 +45,7 @@ public interface IBeeGenome extends IGenome { int getFlowering(); - int[] getTerritory(); + Vec3i getTerritory(); IAlleleBeeEffect getEffect(); diff --git a/src/main/java/forestry/api/farming/FarmDirection.java b/src/main/java/forestry/api/farming/FarmDirection.java index 84101c92d..0d49e2657 100644 --- a/src/main/java/forestry/api/farming/FarmDirection.java +++ b/src/main/java/forestry/api/farming/FarmDirection.java @@ -19,7 +19,7 @@ public enum FarmDirection { this.forgeDirection = forgeDirection; } - public EnumFacing getForgeDirection() { + public EnumFacing getFacing() { return forgeDirection; } diff --git a/src/main/java/forestry/api/farming/IFarmHousing.java b/src/main/java/forestry/api/farming/IFarmHousing.java index 4cb8c9635..f4cd93991 100644 --- a/src/main/java/forestry/api/farming/IFarmHousing.java +++ b/src/main/java/forestry/api/farming/IFarmHousing.java @@ -6,6 +6,7 @@ package forestry.api.farming; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3i; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidStack; @@ -14,11 +15,11 @@ import forestry.api.core.IErrorLogicSource; public interface IFarmHousing extends IErrorLogicSource { - int[] getCoords(); + BlockPos getCoords(); - int[] getArea(); + Vec3i getArea(); - int[] getOffset(); + Vec3i getOffset(); World getWorld(); diff --git a/src/main/java/forestry/api/genetics/IAlleleArea.java b/src/main/java/forestry/api/genetics/IAlleleArea.java index 4d31e0144..14509c390 100644 --- a/src/main/java/forestry/api/genetics/IAlleleArea.java +++ b/src/main/java/forestry/api/genetics/IAlleleArea.java @@ -5,11 +5,13 @@ ******************************************************************************/ package forestry.api.genetics; +import net.minecraft.util.math.Vec3i; + /** * Simple interface to allow adding additional alleles containing float values. */ public interface IAlleleArea extends IAllele { - int[] getValue(); + Vec3i getValue(); } diff --git a/src/main/java/forestry/api/genetics/IAlleleFactory.java b/src/main/java/forestry/api/genetics/IAlleleFactory.java index 1344774cd..1fbc34f33 100644 --- a/src/main/java/forestry/api/genetics/IAlleleFactory.java +++ b/src/main/java/forestry/api/genetics/IAlleleFactory.java @@ -1,5 +1,7 @@ package forestry.api.genetics; +import net.minecraft.util.math.Vec3i; + /** * Creates new alleles with smart localization. * @@ -41,15 +43,13 @@ public interface IAlleleFactory { * @param modId mod prefix for uid and localization (i.e. "forestry") * @param category allele category for uid and localization (i.e. "territory") * @param valueName allele value name for uid and localization (i.e. "large") - * @param xDimValue allele area X Size - * @param yDimValue allele area Y Size - * @param zDimValue allele area Z Size + * @param value allele area x, y, z size * @param isDominant allele dominance * @param types allele chromosome type for registration (i.e. EnumBeeChromosome.TERRITORY) * @return a new IAlleleArea, registered with the allele registry. * @since Forestry 4.2 */ - IAlleleArea createArea(String modId, String category, String valueName, int xDimValue, int yDimValue, int zDimValue, boolean isDominant, IChromosomeType... types); + IAlleleArea createArea(String modId, String category, String valueName, Vec3i value, boolean isDominant, IChromosomeType... types); /** * @param modId mod prefix for uid and localization (i.e. "forestry") diff --git a/src/main/java/forestry/apiculture/HasFlowersCache.java b/src/main/java/forestry/apiculture/HasFlowersCache.java index 96c5af87f..a0cb03a4f 100644 --- a/src/main/java/forestry/apiculture/HasFlowersCache.java +++ b/src/main/java/forestry/apiculture/HasFlowersCache.java @@ -14,6 +14,7 @@ import java.util.Random; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3i; import net.minecraft.world.World; import forestry.api.apiculture.BeeManager; @@ -24,7 +25,7 @@ import forestry.api.apiculture.IBeeModifier; import forestry.api.core.INbtReadable; import forestry.api.core.INbtWritable; import forestry.api.genetics.IFlowerProvider; -import forestry.core.utils.vect.Vect; +import forestry.core.utils.VectUtil; public class HasFlowersCache implements INbtWritable, INbtReadable { private static final String nbtKey = "hasFlowerCache"; @@ -48,11 +49,11 @@ public class HasFlowersCache implements INbtWritable, INbtReadable { IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(beeHousing); BlockPos housingCoords = beeHousing.getCoordinates(); - int[] genomeTerritory = queen.getGenome().getTerritory(); + Vec3i genomeTerritory = queen.getGenome().getTerritory(); float housingModifier = beeModifier.getTerritoryModifier(queen.getGenome(), 1f); - Vect area = new Vect(genomeTerritory).multiply(housingModifier * 3.0f); - Vect min = new Vect(area).multiply(-0.5f).add(housingCoords); - Vect max = new Vect(area).multiply(0.5f).add(housingCoords); + Vec3i area = VectUtil.scale(genomeTerritory, housingModifier * 3.0f); + BlockPos min = VectUtil.scale(area, -0.5f).add(housingCoords); + BlockPos max = VectUtil.scale(area, 0.5f).add(housingCoords); if (isFlowerValid(world, flowerType, min, max)) { return true; @@ -72,14 +73,14 @@ public class HasFlowersCache implements INbtWritable, INbtReadable { return flowerCoords != null; } - private boolean isFlowerValid(World world, String flowerType, Vect min, Vect max) { + private boolean isFlowerValid(World world, String flowerType, BlockPos min, BlockPos max) { if (!isFlowerCoordInRange(flowerCoords, min, max)) { return false; } return FlowerManager.flowerRegistry.isAcceptedFlower(flowerType, world, flowerCoords); } - private static boolean isFlowerCoordInRange(BlockPos flowerCoords, Vect min, Vect max) { + private static boolean isFlowerCoordInRange(BlockPos flowerCoords, BlockPos min, BlockPos max) { return flowerCoords.getX() >= min.getX() && flowerCoords.getX() <= max.getX() && flowerCoords.getY() >= min.getY() && flowerCoords.getY() <= max.getY() && flowerCoords.getZ() >= min.getZ() && flowerCoords.getZ() <= max.getZ(); } diff --git a/src/main/java/forestry/apiculture/blocks/BlockStump.java b/src/main/java/forestry/apiculture/blocks/BlockStump.java index 46408456b..41f16aeb8 100644 --- a/src/main/java/forestry/apiculture/blocks/BlockStump.java +++ b/src/main/java/forestry/apiculture/blocks/BlockStump.java @@ -13,6 +13,7 @@ package forestry.apiculture.blocks; import java.util.List; import java.util.Random; +import net.minecraft.block.Block; import net.minecraft.block.BlockTorch; import net.minecraft.block.SoundType; import net.minecraft.block.state.IBlockState; @@ -34,7 +35,6 @@ import forestry.api.core.Tabs; import forestry.apiculture.PluginApiculture; import forestry.apiculture.tiles.TileCandle; import forestry.core.config.Constants; -import forestry.core.utils.BlockUtil; public class BlockStump extends BlockTorch implements IItemModelRegister { @@ -58,7 +58,10 @@ public class BlockStump extends BlockTorch implements IItemModelRegister { @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if (heldItem != null && BlockCandle.lightingItems.contains(heldItem.getItem())) { - worldIn.setBlockState(pos, PluginApiculture.blocks.candle.getStateFromMeta(BlockUtil.getBlockMetadata(worldIn, pos) | 0x08), Constants.FLAG_BLOCK_SYNCH); + IBlockState blockState = worldIn.getBlockState(pos); + Block block = blockState.getBlock(); + IBlockState activatedState = PluginApiculture.blocks.candle.getStateFromMeta(block.getMetaFromState(blockState) | 0x08); + worldIn.setBlockState(pos, activatedState, Constants.FLAG_BLOCK_SYNCH); TileCandle tc = new TileCandle(); tc.setColour(0); // default to white worldIn.setTileEntity(pos, tc); diff --git a/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java b/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java index 10bf27bce..d6ad79451 100644 --- a/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java +++ b/src/main/java/forestry/apiculture/flowers/FlowerRegistry.java @@ -25,11 +25,13 @@ import java.util.TreeMap; import net.minecraft.block.Block; import net.minecraft.block.BlockFlowerPot; +import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityFlowerPot; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3i; import net.minecraft.world.World; import net.minecraftforge.oredict.OreDictionary; @@ -46,9 +48,7 @@ import forestry.api.genetics.IFlowerGrowthRule; import forestry.api.genetics.IFlowerRegistry; import forestry.api.genetics.IIndividual; import forestry.core.config.Constants; -import forestry.core.utils.BlockUtil; -import forestry.core.utils.vect.MutableVect; -import forestry.core.utils.vect.Vect; +import forestry.core.utils.VectUtil; public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelper { @@ -133,10 +133,10 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe } } - private static Vect getArea(IBeeGenome genome, IBeeModifier beeModifier) { - int[] genomeTerritory = genome.getTerritory(); + private static Vec3i getArea(IBeeGenome genome, IBeeModifier beeModifier) { + Vec3i genomeTerritory = genome.getTerritory(); float housingModifier = beeModifier.getTerritoryModifier(genome, 1f); - return new Vect(genomeTerritory).multiply(housingModifier * 3.0f); + return VectUtil.scale(genomeTerritory, housingModifier * 3.0f); } @Override @@ -152,14 +152,11 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(beeHousing); - Vect area = getArea(bee.getGenome(), beeModifier); - Vect housingPos = new Vect(beeHousing.getCoordinates()).add(-area.getX() / 2, -area.getY() / 2, -area.getZ() / 2); - - MutableVect posCurrent = new MutableVect(0, 0, 0); - while (posCurrent.advancePositionInArea(area)) { - - Vect posBlock = Vect.add(housingPos, posCurrent); + Vec3i area = getArea(bee.getGenome(), beeModifier); + BlockPos minPos = beeHousing.getCoordinates().add(-area.getX() / 2, -area.getY() / 2, -area.getZ() / 2); + BlockPos maxPos = minPos.add(area); + for (BlockPos posBlock : BlockPos.getAllInBox(minPos, maxPos)) { for (IFlowerAcceptableRule acceptableRule : acceptableRules) { if (acceptableRule.isAcceptableFlower(flowerType, world, posBlock)) { return posBlock; @@ -194,7 +191,8 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe } private static boolean isAcceptedFlower(String flowerType, Set acceptedBlocks, Set acceptedFlowers, World world, BlockPos pos) { - Block block = BlockUtil.getBlock(world, pos); + IBlockState blockState = world.getBlockState(pos); + Block block = blockState.getBlock(); final int meta; @@ -208,7 +206,7 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe if (!acceptedBlocks.contains(block)) { return false; } - meta = block.getMetaFromState(world.getBlockState(pos)); + meta = block.getMetaFromState(blockState); } Flower flower = new Flower(block, meta, 0); diff --git a/src/main/java/forestry/apiculture/genetics/Bee.java b/src/main/java/forestry/apiculture/genetics/Bee.java index 79cf0fd56..001855bb6 100644 --- a/src/main/java/forestry/apiculture/genetics/Bee.java +++ b/src/main/java/forestry/apiculture/genetics/Bee.java @@ -24,6 +24,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3i; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; @@ -68,7 +69,7 @@ import forestry.core.genetics.IndividualLiving; import forestry.core.utils.GeneticsUtil; import forestry.core.utils.Log; import forestry.core.utils.Translator; -import forestry.core.utils.vect.Vect; +import forestry.core.utils.VectUtil; public class Bee extends IndividualLiving implements IBee { @@ -680,15 +681,15 @@ public class Bee extends IndividualLiving implements IBee { return null; } - Vect area = getArea(genome, beeModifier); - Vect offset = new Vect(-area.getX() / 2, -area.getY() / 4, -area.getZ() / 2); - Vect housingPos = new Vect(housing.getCoordinates()); + Vec3i area = getArea(genome, beeModifier); + Vec3i offset = new Vec3i(-area.getX() / 2, -area.getY() / 4, -area.getZ() / 2); + BlockPos housingPos = housing.getCoordinates(); ITree pollen = null; for (int i = 0; i < 20; i++) { - Vect randomPos = Vect.getRandomPositionInArea(random, area); - Vect blockPos = Vect.add(housingPos, randomPos, offset); + BlockPos randomPos = VectUtil.getRandomPositionInArea(random, area); + BlockPos blockPos = VectUtil.add(housingPos, randomPos, offset); TileEntity tile = world.getTileEntity(blockPos); if (tile instanceof IPollinatable) { @@ -723,14 +724,14 @@ public class Bee extends IndividualLiving implements IBee { return false; } - Vect area = getArea(genome, beeModifier); - Vect offset = new Vect(-area.getX() / 2, -area.getY() / 4, -area.getZ() / 2); - Vect housingPos = new Vect(housing.getCoordinates()); + Vec3i area = getArea(genome, beeModifier); + Vec3i offset = new Vec3i(-area.getX() / 2, -area.getY() / 4, -area.getZ() / 2); + BlockPos housingPos = housing.getCoordinates(); for (int i = 0; i < 30; i++) { - Vect randomPos = Vect.getRandomPositionInArea(random, area); - Vect posBlock = Vect.add(housingPos, randomPos, offset); + BlockPos randomPos = VectUtil.getRandomPositionInArea(random, area); + BlockPos posBlock = VectUtil.add(housingPos, randomPos, offset); ICheckPollinatable checkPollinatable = GeneticsUtil.getCheckPollinatable(world, posBlock); if (checkPollinatable == null) { @@ -772,13 +773,13 @@ public class Bee extends IndividualLiving implements IBee { // Gather required info IFlowerProvider provider = genome.getFlowerProvider(); - Vect area = getArea(genome, beeModifier); - Vect offset = new Vect(-area.getX() / 2, -area.getY() / 4, -area.getZ() / 2); - Vect housingPos = new Vect(housing.getCoordinates()); + Vec3i area = getArea(genome, beeModifier); + Vec3i offset = new Vec3i(-area.getX() / 2, -area.getY() / 4, -area.getZ() / 2); + BlockPos housingPos = housing.getCoordinates(); for (int i = 0; i < 10; i++) { - Vect randomPos = Vect.getRandomPositionInArea(random, area); - Vect posBlock = Vect.add(housingPos, randomPos, offset); + BlockPos randomPos = VectUtil.getRandomPositionInArea(random, area); + BlockPos posBlock = VectUtil.add(housingPos, randomPos, offset); if (FlowerManager.flowerRegistry.growFlower(provider.getFlowerType(), world, this, posBlock)) { break; @@ -786,9 +787,9 @@ public class Bee extends IndividualLiving implements IBee { } } - private static Vect getArea(IBeeGenome genome, IBeeModifier beeModifier) { - int[] genomeTerritory = genome.getTerritory(); + private static Vec3i getArea(IBeeGenome genome, IBeeModifier beeModifier) { + Vec3i genomeTerritory = genome.getTerritory(); float housingModifier = beeModifier.getTerritoryModifier(genome, 1f); - return new Vect(genomeTerritory).multiply(housingModifier * 3.0f); + return VectUtil.scale(genomeTerritory, housingModifier * 3.0f); } } diff --git a/src/main/java/forestry/apiculture/genetics/BeeGenome.java b/src/main/java/forestry/apiculture/genetics/BeeGenome.java index 92e26e95c..2494f87b9 100755 --- a/src/main/java/forestry/apiculture/genetics/BeeGenome.java +++ b/src/main/java/forestry/apiculture/genetics/BeeGenome.java @@ -19,6 +19,7 @@ import java.util.concurrent.TimeUnit; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.math.Vec3i; import forestry.api.apiculture.BeeManager; import forestry.api.apiculture.EnumBeeChromosome; @@ -37,7 +38,6 @@ import forestry.core.genetics.Genome; import forestry.core.genetics.alleles.AlleleArea; import forestry.core.genetics.alleles.AlleleBoolean; import forestry.core.genetics.alleles.AlleleTolerance; -import forestry.core.utils.vect.Vect; public class BeeGenome extends Genome implements IBeeGenome { /** @@ -160,9 +160,8 @@ public class BeeGenome extends Genome implements IBeeGenome { } @Override - public int[] getTerritory() { - Vect area = ((AlleleArea) getActiveAllele(EnumBeeChromosome.TERRITORY)).getArea(); - return area.toArray(); + public Vec3i getTerritory() { + return ((AlleleArea) getActiveAllele(EnumBeeChromosome.TERRITORY)).getArea(); } @Override diff --git a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffect.java b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffect.java index 35a52f58e..e48858f88 100644 --- a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffect.java +++ b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffect.java @@ -16,7 +16,9 @@ import java.util.List; import net.minecraft.entity.Entity; import net.minecraft.init.MobEffects; import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.Vec3i; import forestry.api.apiculture.BeeManager; import forestry.api.apiculture.EnumBeeChromosome; @@ -29,8 +31,7 @@ import forestry.api.genetics.IEffectData; import forestry.core.config.Constants; import forestry.core.genetics.alleles.AlleleCategorized; import forestry.core.proxy.Proxies; -import forestry.core.utils.vect.MutableVect; -import forestry.core.utils.vect.Vect; +import forestry.core.utils.VectUtil; public abstract class AlleleEffect extends AlleleCategorized implements IAlleleBeeEffect { @@ -108,36 +109,37 @@ public abstract class AlleleEffect extends AlleleCategorized implements IAlleleB return storedData; } - protected Vect getModifiedArea(IBeeGenome genome, IBeeHousing housing) { + protected Vec3i getModifiedArea(IBeeGenome genome, IBeeHousing housing) { IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing); float territoryModifier = beeModifier.getTerritoryModifier(genome, 1f); - MutableVect area = new MutableVect(genome.getTerritory()); - area.multiply(territoryModifier); + Vec3i area = VectUtil.scale(genome.getTerritory(), territoryModifier); + int x = area.getX(); + int y = area.getY(); + int z = area.getZ(); - if (area.x < 1) { - area.x = 1; + if (x < 1) { + x = 1; } - if (area.y < 1) { - area.y = 1; + if (y < 1) { + y = 1; } - if (area.z < 1) { - area.z = 1; + if (z < 1) { + z = 1; } - return new Vect(area); + return new Vec3i(x, y, z); } public static AxisAlignedBB getBounding(IBeeGenome genome, IBeeHousing housing) { IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing); float territoryModifier = beeModifier.getTerritoryModifier(genome, 1.0f); - MutableVect area = new MutableVect(genome.getTerritory()); - area.multiply(territoryModifier); - Vect offset = new Vect(area).multiply(-1 / 2.0f); + Vec3i area = VectUtil.scale(genome.getTerritory(), territoryModifier); + Vec3i offset = VectUtil.scale(area, -1 / 2.0f); - Vect min = new Vect(housing.getCoordinates()).add(offset); - Vect max = min.add(area); + BlockPos min = housing.getCoordinates().add(offset); + BlockPos max = min.add(area); return new AxisAlignedBB(min.getX(), min.getY(), min.getZ(), max.getX(), max.getY(), max.getZ()); } diff --git a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectFertile.java b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectFertile.java index 37b057b6f..20ff7761b 100644 --- a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectFertile.java +++ b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectFertile.java @@ -15,6 +15,7 @@ import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.IGrowable; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3i; import net.minecraft.world.World; import net.minecraftforge.common.IPlantable; @@ -22,7 +23,6 @@ import net.minecraftforge.common.IPlantable; import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; -import forestry.core.utils.vect.IVect; public class AlleleEffectFertile extends AlleleEffectThrottled { @@ -37,7 +37,7 @@ public class AlleleEffectFertile extends AlleleEffectThrottled { World world = housing.getWorld(); BlockPos housingCoordinates = housing.getCoordinates(); - IVect area = getModifiedArea(genome, housing); + Vec3i area = getModifiedArea(genome, housing); int blockX = getRandomOffset(world.rand, housingCoordinates.getX(), area.getX()); int blockZ = getRandomOffset(world.rand, housingCoordinates.getZ(), area.getZ()); diff --git a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectFungification.java b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectFungification.java index 03c76f1c1..fdac890f3 100644 --- a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectFungification.java +++ b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectFungification.java @@ -9,6 +9,7 @@ import net.minecraft.entity.passive.EntityMooshroom; import net.minecraft.init.Blocks; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3i; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenBigMushroom; @@ -16,7 +17,6 @@ import forestry.api.apiculture.IBeeGenome; import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; import forestry.core.genetics.EffectData; -import forestry.core.utils.vect.IVect; public class AlleleEffectFungification extends AlleleEffectThrottled { @@ -56,7 +56,7 @@ public class AlleleEffectFungification extends AlleleEffectThrottled { private void doBlockEffect(IBeeGenome genome, IBeeHousing housing) { World world = housing.getWorld(); BlockPos housingCoordinates = housing.getCoordinates(); - IVect area = getModifiedArea(genome, housing); + Vec3i area = getModifiedArea(genome, housing); int blockX = getRandomOffset(world.rand, housingCoordinates.getX(), area.getX()); int blockY = getRandomOffset(world.rand, housingCoordinates.getY(), area.getY()); diff --git a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectGlacial.java b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectGlacial.java index c9d196d1d..0fc159f5e 100644 --- a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectGlacial.java +++ b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectGlacial.java @@ -13,6 +13,7 @@ package forestry.apiculture.genetics.alleles; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3i; import net.minecraft.world.World; import forestry.api.apiculture.IBeeGenome; @@ -20,7 +21,7 @@ import forestry.api.apiculture.IBeeHousing; import forestry.api.core.EnumTemperature; import forestry.api.genetics.IEffectData; import forestry.core.config.Constants; -import forestry.core.utils.vect.Vect; +import forestry.core.utils.VectUtil; public class AlleleEffectGlacial extends AlleleEffectThrottled { @@ -42,15 +43,14 @@ public class AlleleEffectGlacial extends AlleleEffectThrottled { default: } - int[] areaAr = genome.getTerritory(); - Vect area = new Vect(areaAr); - Vect offset = area.multiply(-1 / 2.0f); - Vect housingCoords = new Vect(housing.getCoordinates()); + Vec3i area = genome.getTerritory(); + Vec3i offset = VectUtil.scale(area, -1 / 2.0f); + BlockPos housingCoords = housing.getCoordinates(); for (int i = 0; i < 10; i++) { - Vect randomPos = Vect.getRandomPositionInArea(world.rand, area); - Vect posBlock = Vect.add(randomPos, housingCoords, offset); + BlockPos randomPos = VectUtil.getRandomPositionInArea(world.rand, area); + BlockPos posBlock = VectUtil.add(randomPos, housingCoords, offset); // Freeze water Block block = world.getBlockState(posBlock).getBlock(); diff --git a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectRadioactive.java b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectRadioactive.java index ebb8af238..c4bf41de5 100644 --- a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectRadioactive.java +++ b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectRadioactive.java @@ -18,6 +18,8 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.DamageSource; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3i; import net.minecraft.world.World; import forestry.api.apiculture.BeeManager; @@ -26,7 +28,7 @@ import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IEffectData; import forestry.apiculture.blocks.BlockAlveary; import forestry.core.utils.DamageSourceForestry; -import forestry.core.utils.vect.Vect; +import forestry.core.utils.VectUtil; public class AlleleEffectRadioactive extends AlleleEffectThrottled { @@ -63,14 +65,13 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled { World world = housing.getWorld(); Random rand = world.rand; - int[] areaAr = genome.getTerritory(); - Vect area = new Vect(areaAr).multiply(2); - Vect offset = area.multiply(-1 / 2.0f); - Vect posHousing = new Vect(housing.getCoordinates()); + Vec3i area = VectUtil.scale(genome.getTerritory(), 2); + Vec3i offset = VectUtil.scale(area, -1 / 2.0f); + BlockPos posHousing = housing.getCoordinates(); for (int i = 0; i < 20; i++) { - Vect randomPos = Vect.getRandomPositionInArea(rand, area); - Vect posBlock = randomPos.add(posHousing); + BlockPos randomPos = VectUtil.getRandomPositionInArea(rand, area); + BlockPos posBlock = randomPos.add(posHousing); posBlock = posBlock.add(offset); if (posBlock.getY() <= 1 || posBlock.getY() >= housing.getWorld().getActualHeight()) { diff --git a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectSnowing.java b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectSnowing.java index 82b3ea194..2cd0c569f 100644 --- a/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectSnowing.java +++ b/src/main/java/forestry/apiculture/genetics/alleles/AlleleEffectSnowing.java @@ -13,8 +13,9 @@ package forestry.apiculture.genetics.alleles; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3i; import net.minecraft.world.World; import forestry.api.apiculture.IBeeGenome; @@ -23,7 +24,7 @@ import forestry.api.core.EnumTemperature; import forestry.api.genetics.IEffectData; import forestry.core.config.Constants; import forestry.core.proxy.Proxies; -import forestry.core.utils.vect.Vect; +import forestry.core.utils.VectUtil; public class AlleleEffectSnowing extends AlleleEffectThrottled { @@ -46,14 +47,14 @@ public class AlleleEffectSnowing extends AlleleEffectThrottled { default: } - Vect area = getModifiedArea(genome, housing); - Vect offset = area.multiply(-1 / 2.0f); + Vec3i area = getModifiedArea(genome, housing); + Vec3i offset = VectUtil.scale(area, -1 / 2.0f); for (int i = 0; i < 1; i++) { - Vect randomPos = Vect.getRandomPositionInArea(world.rand, area); + BlockPos randomPos = VectUtil.getRandomPositionInArea(world.rand, area); - Vect posBlock = randomPos.add(new Vect(housing.getCoordinates())); + BlockPos posBlock = randomPos.add(housing.getCoordinates()); posBlock = posBlock.add(offset); // Put snow on the ground @@ -80,13 +81,13 @@ public class AlleleEffectSnowing extends AlleleEffectThrottled { @Override public IEffectData doFX(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) { if (housing.getWorld().rand.nextInt(3) == 0) { - Vect area = getModifiedArea(genome, housing); - Vect offset = area.multiply(-0.5F); + Vec3i area = getModifiedArea(genome, housing); + Vec3i offset = VectUtil.scale(area, -0.5F); BlockPos coordinates = housing.getCoordinates(); World world = housing.getWorld(); - Vect spawn = Vect.getRandomPositionInArea(world.rand, area).add(coordinates).add(offset); + BlockPos spawn = VectUtil.getRandomPositionInArea(world.rand, area).add(coordinates).add(offset); Proxies.render.addEntitySnowFX(world, spawn.getX(), spawn.getY(), spawn.getZ()); return storedData; } else { diff --git a/src/main/java/forestry/apiculture/items/HabitatLocatorLogic.java b/src/main/java/forestry/apiculture/items/HabitatLocatorLogic.java index 523441317..7028e1898 100644 --- a/src/main/java/forestry/apiculture/items/HabitatLocatorLogic.java +++ b/src/main/java/forestry/apiculture/items/HabitatLocatorLogic.java @@ -27,7 +27,6 @@ import net.minecraftforge.common.BiomeDictionary; import forestry.api.apiculture.IBee; import forestry.apiculture.network.packets.PacketHabitatBiomePointer; import forestry.core.proxy.Proxies; -import forestry.core.utils.vect.Vect; public class HabitatLocatorLogic { private static final int maxChecksPerTick = 100; @@ -53,7 +52,7 @@ public class HabitatLocatorLogic { private boolean biomeFound = false; private int searchRadiusIteration = 0; private int searchAngleIteration = 0; - private Vect searchCenter; + private BlockPos searchCenter; public boolean isBiomeFound() { return biomeFound; @@ -68,7 +67,7 @@ public class HabitatLocatorLogic { this.searchAngleIteration = 0; this.searchRadiusIteration = 0; this.biomeFound = false; - this.searchCenter = new Vect(player); + this.searchCenter = player.getPosition(); BiomeGenBase currentBiome = player.worldObj.getBiomeGenForCoords(searchCenter); removeInvalidBiomes(currentBiome, targetBiomes); @@ -101,7 +100,7 @@ public class HabitatLocatorLogic { } private BlockPos findNearestBiome(Entity player, Collection biomesToSearch) { - Vect playerPos = new Vect(player); + BlockPos playerPos = player.getPosition(); // If we are in a valid spot, we point to ourselves. BlockPos coordinates = getChunkCoordinates(playerPos, player.worldObj, biomesToSearch); @@ -138,7 +137,7 @@ public class HabitatLocatorLogic { int xOffset = Math.round((float) (radius * Math.cos(angle))); int zOffset = Math.round((float) (radius * Math.sin(angle))); - Vect pos = searchCenter.add(xOffset, 0, zOffset); + BlockPos pos = searchCenter.add(xOffset, 0, zOffset); coordinates = getChunkCoordinates(pos, player.worldObj, biomesToSearch); if (coordinates != null) { @@ -151,7 +150,7 @@ public class HabitatLocatorLogic { return null; } - private static BlockPos getChunkCoordinates(Vect pos, World world, Collection biomesToSearch) { + private static BlockPos getChunkCoordinates(BlockPos pos, World world, Collection biomesToSearch) { BiomeGenBase biome; biome = world.getBiomeGenForCoords(pos); diff --git a/src/main/java/forestry/arboriculture/LeafDecayHelper.java b/src/main/java/forestry/arboriculture/LeafDecayHelper.java index 15ae8b6aa..5cac5916b 100644 --- a/src/main/java/forestry/arboriculture/LeafDecayHelper.java +++ b/src/main/java/forestry/arboriculture/LeafDecayHelper.java @@ -39,8 +39,8 @@ public abstract class LeafDecayHelper { for (int yOffset = -radius; yOffset <= radius; ++yOffset) { for (int zOffset = -radius; zOffset <= radius; ++zOffset) { BlockPos blockPos = pos.add(xOffset, yOffset, zOffset); - Block block = BlockUtil.getBlock(world, blockPos); IBlockState blockState = world.getBlockState(blockPos); + Block block = blockState.getBlock(); if (!block.canSustainLeaves(blockState, world, blockPos)) { if (block.isLeaves(blockState, world, blockPos)) { leafDecayValues[(xOffset + arrayOffset) * xArrayMult + (yOffset + arrayOffset) * yArrayMult + zOffset + arrayOffset] = IS_LEAVES; diff --git a/src/main/java/forestry/arboriculture/genetics/GrowthProvider.java b/src/main/java/forestry/arboriculture/genetics/GrowthProvider.java index 87f242e5e..5894554b7 100755 --- a/src/main/java/forestry/arboriculture/genetics/GrowthProvider.java +++ b/src/main/java/forestry/arboriculture/genetics/GrowthProvider.java @@ -13,6 +13,7 @@ package forestry.arboriculture.genetics; import net.minecraft.block.state.IBlockState; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3i; import net.minecraft.world.World; import forestry.api.arboriculture.EnumGrowthConditions; @@ -23,7 +24,6 @@ import forestry.api.core.ForestryAPI; import forestry.arboriculture.tiles.TileSapling; import forestry.core.utils.BlockUtil; import forestry.core.utils.Translator; -import forestry.core.utils.vect.Vect; public class GrowthProvider implements IGrowthProvider { @@ -95,13 +95,13 @@ public class GrowthProvider implements IGrowthProvider { int offset = (expectedGirth - 1) / 2; // if(offset <= 0) // offset = 1; - Vect start = new Vect(pos.getX() - offset, pos.getY() + 1, pos.getZ() + offset); - Vect area = new Vect(-offset + expectedGirth, expectedHeight + 1, -offset + expectedGirth); + BlockPos start = new BlockPos(pos.getX() - offset, pos.getY() + 1, pos.getZ() + offset); + Vec3i area = new Vec3i(-offset + expectedGirth, expectedHeight + 1, -offset + expectedGirth); return checkArea(world, start, area); } - private static boolean checkArea(World world, Vect start, Vect area) { + private static boolean checkArea(World world, BlockPos start, Vec3i area) { for (int x = start.getX(); x < start.getX() + area.getX(); x++) { for (int y = start.getY(); y < start.getY() + area.getY(); y++) { for (int z = start.getZ(); z < start.getZ() + area.getZ(); z++) { diff --git a/src/main/java/forestry/arboriculture/genetics/TreeDefinition.java b/src/main/java/forestry/arboriculture/genetics/TreeDefinition.java index 86c8b1040..7a73e4db0 100644 --- a/src/main/java/forestry/arboriculture/genetics/TreeDefinition.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeDefinition.java @@ -17,9 +17,9 @@ import java.util.Locale; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.IStringSerializable; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; @@ -91,7 +91,6 @@ import forestry.core.genetics.alleles.AlleleHelper; import forestry.core.genetics.alleles.AllelePlantType; import forestry.core.genetics.alleles.EnumAllele; import forestry.core.tiles.TileUtil; -import forestry.core.utils.BlockUtil; public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSerializable { Oak(TreeBranchDefinition.QUERCUS, "appleOak", "robur", false, EnumLeafType.DECIDUOUS, new Color(4764952), new Color(4764952).brighter(), 0, new ItemStack(Blocks.LOG, 1, 0)) { @@ -1042,7 +1041,7 @@ public enum TreeDefinition implements ITreeDefinition, ITreeGenerator, IStringSe return; } - Block block = BlockUtil.getBlock(world, pos); + Block block = world.getBlockState(pos).getBlock(); if (PluginArboriculture.blocks.leaves != block) { world.setBlockToAir(pos); return; diff --git a/src/main/java/forestry/arboriculture/genetics/TreeRoot.java b/src/main/java/forestry/arboriculture/genetics/TreeRoot.java index 883e0d05b..66f5bae12 100644 --- a/src/main/java/forestry/arboriculture/genetics/TreeRoot.java +++ b/src/main/java/forestry/arboriculture/genetics/TreeRoot.java @@ -26,8 +26,8 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import com.mojang.authlib.GameProfile; @@ -212,7 +212,7 @@ public class TreeRoot extends SpeciesRoot implements ITreeRoot { return false; } - Block block = BlockUtil.getBlock(world, pos); + Block block = world.getBlockState(pos).getBlock(); if (PluginArboriculture.blocks.saplingGE != block) { return false; } @@ -249,7 +249,7 @@ public class TreeRoot extends SpeciesRoot implements ITreeRoot { return false; } - Block block = BlockUtil.getBlock(world, pos); + Block block = world.getBlockState(pos).getBlock(); if (fruitPod != block) { return false; } diff --git a/src/main/java/forestry/arboriculture/genetics/alleles/AlleleLeafEffect.java b/src/main/java/forestry/arboriculture/genetics/alleles/AlleleLeafEffect.java index 1357cd01c..b8b7390a8 100644 --- a/src/main/java/forestry/arboriculture/genetics/alleles/AlleleLeafEffect.java +++ b/src/main/java/forestry/arboriculture/genetics/alleles/AlleleLeafEffect.java @@ -10,7 +10,6 @@ ******************************************************************************/ package forestry.arboriculture.genetics.alleles; -import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -22,11 +21,8 @@ import forestry.api.genetics.IEffectData; import forestry.core.config.Constants; import forestry.core.genetics.alleles.Allele; import forestry.core.genetics.alleles.AlleleCategorized; -import forestry.core.utils.vect.Vect; public class AlleleLeafEffect extends AlleleCategorized implements IAlleleLeafEffect { - private static final int[] DEFAULT_EFFECT_AREA = new int[]{12, 12, 12}; - public static Allele leavesNone; public static void createAlleles() { @@ -52,15 +48,4 @@ public class AlleleLeafEffect extends AlleleCategorized implements IAlleleLeafEf public IEffectData doEffect(ITreeGenome genome, IEffectData storedData, World world, BlockPos pos) { return storedData; } - - protected static AxisAlignedBB getBounding(int x, int y, int z, float modifier) { - int[] areaAr = DEFAULT_EFFECT_AREA; - Vect area = new Vect(areaAr).multiply(modifier); - Vect offset = area.multiply(-1 / 2.0f); - - Vect min = offset.add(x, y, z); - Vect max = min.add(area); - - return new AxisAlignedBB(min.getX(), min.getY(), min.getZ(), max.getX(), max.getY(), max.getZ()); - } } diff --git a/src/main/java/forestry/core/blocks/BlockSoil.java b/src/main/java/forestry/core/blocks/BlockSoil.java index 7f4bf4a0a..784735ab8 100644 --- a/src/main/java/forestry/core/blocks/BlockSoil.java +++ b/src/main/java/forestry/core/blocks/BlockSoil.java @@ -44,7 +44,6 @@ import forestry.api.core.IModelManager; import forestry.core.CreativeTabForestry; import forestry.core.PluginCore; import forestry.core.config.Constants; -import forestry.core.utils.BlockUtil; /** * Humus, bog earth, peat @@ -165,13 +164,15 @@ public class BlockSoil extends Block implements IItemModelRegister, IBlockWithMe /** * If a tree or sapling is in the vicinity, there is a chance, that the soil will degrade. */ - private static void degradeSoil(World world, BlockPos pos) { + private static void degradeSoil(World world, final BlockPos pos) { if (world.rand.nextInt(140) != 0) { return; } - int meta = BlockUtil.getBlockMetadata(world, pos); + IBlockState blockState = world.getBlockState(pos); + Block block = blockState.getBlock(); + int meta = block.getMetaFromState(blockState); // Unpack first int type = meta & 0x03; @@ -186,7 +187,7 @@ public class BlockSoil extends Block implements IItemModelRegister, IBlockWithMe if (grade >= degradeDelimiter) { world.setBlockState(pos, Blocks.SAND.getDefaultState(), Constants.FLAG_BLOCK_SYNCH); } else { - world.setBlockState(pos, BlockUtil.getBlock(world, pos).getStateFromMeta(meta), Constants.FLAG_BLOCK_SYNCH); + world.setBlockState(pos, block.getStateFromMeta(meta), Constants.FLAG_BLOCK_SYNCH); } world.markBlockRangeForRenderUpdate(pos, pos); } @@ -205,13 +206,15 @@ public class BlockSoil extends Block implements IItemModelRegister, IBlockWithMe return false; } - private static void matureBog(World world, BlockPos pos) { + private static void matureBog(World world, final BlockPos pos) { if (world.rand.nextInt(13) != 0) { return; } - int meta = BlockUtil.getBlockMetadata(world, pos); + IBlockState blockState = world.getBlockState(pos); + Block block = blockState.getBlock(); + int meta = block.getMetaFromState(blockState); // Unpack first @@ -226,7 +229,6 @@ public class BlockSoil extends Block implements IItemModelRegister, IBlockWithMe maturity++; meta = maturity << 2 | type; - Block block = BlockUtil.getBlock(world, pos); world.setBlockState(pos, block.getStateFromMeta(meta), Constants.FLAG_BLOCK_SYNCH); world.markBlockRangeForRenderUpdate(pos, pos); } @@ -248,6 +250,10 @@ public class BlockSoil extends Block implements IItemModelRegister, IBlockWithMe return false; } + public static SoilType getTypeFromState(IBlockState state) { + return state.getValue(SOIL); + } + public static SoilType getTypeFromMeta(int meta) { int type = meta & 0x03; int maturity = meta >> 2; diff --git a/src/main/java/forestry/core/config/Constants.java b/src/main/java/forestry/core/config/Constants.java index f488423d5..a6ff761c9 100644 --- a/src/main/java/forestry/core/config/Constants.java +++ b/src/main/java/forestry/core/config/Constants.java @@ -28,7 +28,6 @@ public class Constants implements IForestryConstants { public static final int BUCKET_VOLUME = 1000; public static final int FLUID_PER_HONEY_DROP = 100; - public static final int[] FACINGS = {0, 1, 2, 3, 4, 5}; public static final int[] SLOTS_NONE = new int[0]; public static final String[] EMPTY_STRINGS = new String[0]; diff --git a/src/main/java/forestry/core/fluids/BlockForestryFluid.java b/src/main/java/forestry/core/fluids/BlockForestryFluid.java index 978facdc5..18c445468 100644 --- a/src/main/java/forestry/core/fluids/BlockForestryFluid.java +++ b/src/main/java/forestry/core/fluids/BlockForestryFluid.java @@ -39,7 +39,6 @@ import net.minecraftforge.fml.relauncher.SideOnly; import forestry.api.core.IItemModelRegister; import forestry.api.core.IModelManager; import forestry.core.entities.EntityFXColoredDripParticle; -import forestry.core.utils.BlockUtil; public class BlockForestryFluid extends BlockFluidClassic implements IItemModelRegister { @@ -156,7 +155,9 @@ public class BlockForestryFluid extends BlockFluidClassic implements IItemModelR } private static boolean isFlammable(IBlockAccess world, BlockPos pos) { - return BlockUtil.getBlock(world, pos).isFlammable(world, pos, null); + IBlockState blockState = world.getBlockState(pos); + Block block = blockState.getBlock(); + return block.isFlammable(world, pos, null); } @Override @@ -227,8 +228,9 @@ public class BlockForestryFluid extends BlockFluidClassic implements IItemModelR x = startX + rand.nextInt(3) - 1; z = startZ + rand.nextInt(3) - 1; - if (world.isAirBlock(new BlockPos(pos.getX(), y + 1, z)) && isFlammable(world, new BlockPos(x, y, z))) { - world.setBlockState(new BlockPos(pos.getX(), y + 1, z), Blocks.FIRE.getDefaultState()); + BlockPos posAbove = new BlockPos(pos.getX(), y + 1, z); + if (world.isAirBlock(posAbove) && isFlammable(world, new BlockPos(x, y, z))) { + world.setBlockState(posAbove, Blocks.FIRE.getDefaultState()); } } } diff --git a/src/main/java/forestry/core/genetics/alleles/AlleleArea.java b/src/main/java/forestry/core/genetics/alleles/AlleleArea.java index b82ed259f..9b22aa989 100644 --- a/src/main/java/forestry/core/genetics/alleles/AlleleArea.java +++ b/src/main/java/forestry/core/genetics/alleles/AlleleArea.java @@ -10,24 +10,25 @@ ******************************************************************************/ package forestry.core.genetics.alleles; +import net.minecraft.util.math.Vec3i; + import forestry.api.genetics.IAlleleArea; -import forestry.core.utils.vect.Vect; public class AlleleArea extends AlleleCategorized implements IAlleleArea { - private final int[] area; + private final Vec3i area; - public AlleleArea(String modId, String category, String name, int[] value, boolean isDominant) { + public AlleleArea(String modId, String category, String name, Vec3i value, boolean isDominant) { super(modId, category, name, isDominant); this.area = value; } @Override - public int[] getValue() { + public Vec3i getValue() { return area; } - public Vect getArea() { - return new Vect(area); + public Vec3i getArea() { + return area; } } diff --git a/src/main/java/forestry/core/genetics/alleles/AlleleFactory.java b/src/main/java/forestry/core/genetics/alleles/AlleleFactory.java index aba8bacf5..fb7d1cb47 100644 --- a/src/main/java/forestry/core/genetics/alleles/AlleleFactory.java +++ b/src/main/java/forestry/core/genetics/alleles/AlleleFactory.java @@ -10,6 +10,8 @@ ******************************************************************************/ package forestry.core.genetics.alleles; +import net.minecraft.util.math.Vec3i; + import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAlleleArea; import forestry.api.genetics.IAlleleBoolean; @@ -31,8 +33,8 @@ public class AlleleFactory implements IAlleleFactory { } @Override - public IAlleleArea createArea(String modId, String category, String valueName, int xDimValue, int yDimValue, int zDimValue, boolean isDominant, IChromosomeType... types) { - IAlleleArea alleleArea = new AlleleArea(modId, category, valueName, new int[]{xDimValue, yDimValue, zDimValue}, isDominant); + public IAlleleArea createArea(String modId, String category, String valueName, Vec3i value, boolean isDominant, IChromosomeType... types) { + IAlleleArea alleleArea = new AlleleArea(modId, category, valueName, value, isDominant); AlleleManager.alleleRegistry.registerAllele(alleleArea, types); return alleleArea; } diff --git a/src/main/java/forestry/core/genetics/alleles/AlleleHelper.java b/src/main/java/forestry/core/genetics/alleles/AlleleHelper.java index 0170e6981..c8e643a48 100644 --- a/src/main/java/forestry/core/genetics/alleles/AlleleHelper.java +++ b/src/main/java/forestry/core/genetics/alleles/AlleleHelper.java @@ -15,6 +15,8 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; +import net.minecraft.util.math.Vec3i; + import forestry.api.apiculture.EnumBeeChromosome; import forestry.api.arboriculture.EnumTreeChromosome; import forestry.api.core.ForestryAPI; @@ -28,7 +30,6 @@ import forestry.api.genetics.IChromosomeType; import forestry.api.lepidopterology.EnumButterflyChromosome; import forestry.apiculture.flowers.FlowerProvider; import forestry.core.config.Constants; -import forestry.core.utils.vect.IVect; import forestry.plugins.ForestryPluginUids; public class AlleleHelper implements IAlleleHelper { @@ -180,9 +181,9 @@ public class AlleleHelper implements IAlleleHelper { return AlleleManager.alleleFactory.createFloat(modId, category, name, (Float) value, isDominant, types); } else if (Integer.class.isAssignableFrom(valueClass)) { return AlleleManager.alleleFactory.createInteger(modId, category, name, (Integer) value, isDominant, types); - } else if (IVect.class.isAssignableFrom(valueClass)) { - IVect area = (IVect) value; - return AlleleManager.alleleFactory.createArea(modId, category, name, area.getX(), area.getY(), area.getZ(), isDominant, types); + } else if (Vec3i.class.isAssignableFrom(valueClass)) { + Vec3i area = (Vec3i) value; + return AlleleManager.alleleFactory.createArea(modId, category, name, area, isDominant, types); } else if (Boolean.class.isAssignableFrom(valueClass)) { return AlleleManager.alleleFactory.createBoolean(modId, category, (Boolean) value, isDominant, types); } else if (EnumTolerance.class.isAssignableFrom(valueClass)) { diff --git a/src/main/java/forestry/core/genetics/alleles/EnumAllele.java b/src/main/java/forestry/core/genetics/alleles/EnumAllele.java index 138e16e53..ce7699e8f 100644 --- a/src/main/java/forestry/core/genetics/alleles/EnumAllele.java +++ b/src/main/java/forestry/core/genetics/alleles/EnumAllele.java @@ -2,11 +2,11 @@ package forestry.core.genetics.alleles; import java.util.Locale; +import net.minecraft.util.math.Vec3i; + import forestry.api.apiculture.FlowerManager; import forestry.api.genetics.EnumTolerance; import forestry.apiculture.flowers.FlowerProvider; -import forestry.core.utils.vect.IVect; -import forestry.core.utils.vect.Vect; public class EnumAllele { public enum Fertility implements IAlleleValue { @@ -360,13 +360,13 @@ public class EnumAllele { } } - public enum Territory implements IAlleleValue { + public enum Territory implements IAlleleValue { AVERAGE(9, 6, 9), LARGE(11, 8, 11), LARGER(13, 12, 13), LARGEST(15, 13, 15); - private final IVect area; + private final Vec3i area; private final boolean dominant; Territory(int x, int y, int z) { @@ -374,12 +374,12 @@ public class EnumAllele { } Territory(int x, int y, int z, boolean dominant) { - this.area = new Vect(x, y, z); + this.area = new Vec3i(x, y, z); this.dominant = dominant; } @Override - public IVect getValue() { + public Vec3i getValue() { return area; } diff --git a/src/main/java/forestry/core/genetics/mutations/MutationConditionRequiresResource.java b/src/main/java/forestry/core/genetics/mutations/MutationConditionRequiresResource.java index 3ba656d0f..18bcc0849 100644 --- a/src/main/java/forestry/core/genetics/mutations/MutationConditionRequiresResource.java +++ b/src/main/java/forestry/core/genetics/mutations/MutationConditionRequiresResource.java @@ -11,6 +11,7 @@ package forestry.core.genetics.mutations; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -19,7 +20,6 @@ import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IAllele; import forestry.api.genetics.IGenome; import forestry.api.genetics.IMutationCondition; -import forestry.core.utils.BlockUtil; import forestry.core.utils.ItemStackUtil; import forestry.core.utils.Translator; @@ -38,8 +38,9 @@ public class MutationConditionRequiresResource implements IMutationCondition { int i = 1; do { BlockPos blockPos = new BlockPos(pos.getX(), pos.getY() - i, pos.getY()); - block = BlockUtil.getBlock(world, blockPos); - meta = BlockUtil.getBlockMetadata(world, blockPos); + IBlockState blockState = world.getBlockState(blockPos); + block = blockState.getBlock(); + meta = block.getMetaFromState(blockState); i++; } while (block instanceof IBeeHousing); diff --git a/src/main/java/forestry/core/genetics/mutations/MutationConditionRequiresResourceOreDict.java b/src/main/java/forestry/core/genetics/mutations/MutationConditionRequiresResourceOreDict.java index e89b5efe2..479478671 100644 --- a/src/main/java/forestry/core/genetics/mutations/MutationConditionRequiresResourceOreDict.java +++ b/src/main/java/forestry/core/genetics/mutations/MutationConditionRequiresResourceOreDict.java @@ -13,6 +13,7 @@ package forestry.core.genetics.mutations; import java.util.List; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -23,7 +24,6 @@ import forestry.api.apiculture.IBeeHousing; import forestry.api.genetics.IAllele; import forestry.api.genetics.IGenome; import forestry.api.genetics.IMutationCondition; -import forestry.core.utils.BlockUtil; import forestry.core.utils.Translator; public class MutationConditionRequiresResourceOreDict implements IMutationCondition { @@ -49,8 +49,9 @@ public class MutationConditionRequiresResourceOreDict implements IMutationCondit int i = 1; do { BlockPos blockPos = new BlockPos(pos.getX(), pos.getY() - i, pos.getY()); - block = BlockUtil.getBlock(world, blockPos); - meta = BlockUtil.getBlockMetadata(world, blockPos); + IBlockState blockState = world.getBlockState(blockPos); + block = blockState.getBlock(); + meta = block.getMetaFromState(blockState); i++; } while (block instanceof IBeeHousing); diff --git a/src/main/java/forestry/core/inventory/InventoryAdapter.java b/src/main/java/forestry/core/inventory/InventoryAdapter.java index 168eeb700..17baadf60 100755 --- a/src/main/java/forestry/core/inventory/InventoryAdapter.java +++ b/src/main/java/forestry/core/inventory/InventoryAdapter.java @@ -173,8 +173,8 @@ public class InventoryAdapter implements IInventoryAdapter, IStreamable { slots[i] = i; } - for (int side : Constants.FACINGS) { - slotMap[side] = slots; + for (EnumFacing side : EnumFacing.VALUES) { + slotMap[side.getIndex()] = slots; } } diff --git a/src/main/java/forestry/core/multiblock/MultiblockControllerBase.java b/src/main/java/forestry/core/multiblock/MultiblockControllerBase.java index a7c5235c1..d5c4e1ef2 100644 --- a/src/main/java/forestry/core/multiblock/MultiblockControllerBase.java +++ b/src/main/java/forestry/core/multiblock/MultiblockControllerBase.java @@ -9,7 +9,6 @@ import java.util.List; import java.util.Random; import java.util.Set; -import forestry.core.utils.Translator; import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -21,6 +20,7 @@ import net.minecraft.world.chunk.IChunkProvider; import forestry.api.multiblock.IMultiblockComponent; import forestry.core.utils.BlockUtil; import forestry.core.utils.Log; +import forestry.core.utils.Translator; /** * This class contains the base logic for "multiblock controllers". Conceptually, they are @@ -471,7 +471,7 @@ public abstract class MultiblockControllerBase implements IMultiblockControllerI * @throws MultiblockValidationException if the tested block is not allowed on the machine's side faces */ protected void isBlockGoodForExteriorLevel(int level, World world, BlockPos pos) throws MultiblockValidationException { - Block block = BlockUtil.getBlock(world, pos); + Block block = world.getBlockState(pos).getBlock(); throw new MultiblockValidationException(Translator.translateToLocalFormatted("for.multiblock.error.invalid.interior", block.getLocalizedName())); } @@ -482,7 +482,7 @@ public abstract class MultiblockControllerBase implements IMultiblockControllerI * @throws MultiblockValidationException if the tested block is not allowed in the machine's interior */ protected void isBlockGoodForInterior(World world, BlockPos pos) throws MultiblockValidationException { - Block block = BlockUtil.getBlock(world, pos); + Block block = world.getBlockState(pos).getBlock(); throw new MultiblockValidationException(Translator.translateToLocalFormatted("for.multiblock.error.invalid.interior", block.getLocalizedName())); } diff --git a/src/main/java/forestry/core/tiles/TileForestry.java b/src/main/java/forestry/core/tiles/TileForestry.java index 0c6396079..5a1db1aad 100644 --- a/src/main/java/forestry/core/tiles/TileForestry.java +++ b/src/main/java/forestry/core/tiles/TileForestry.java @@ -48,7 +48,6 @@ import forestry.core.network.DataOutputStreamForestry; import forestry.core.network.IStreamable; import forestry.core.network.packets.PacketTileStream; import forestry.core.proxy.Proxies; -import forestry.core.utils.BlockUtil; //@Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements") public abstract class TileForestry extends TileEntity implements IStreamable, IErrorLogicSource, ISidedInventory, IFilterSlotDelegate, IRestrictedAccess, ITitled, ILocatable, IGuiHandlerTile, ITickable { @@ -225,7 +224,7 @@ public abstract class TileForestry extends TileEntity implements IStreamable, IE this.orientation = orientation; this.setNeedsNetworkUpdate(); BlockPos pos = getPos(); - worldObj.notifyBlockOfStateChange(pos, BlockUtil.getBlock(worldObj, pos)); + worldObj.notifyBlockOfStateChange(pos, worldObj.getBlockState(pos).getBlock()); worldObj.markBlockRangeForRenderUpdate(pos, pos); } diff --git a/src/main/java/forestry/core/utils/BlockUtil.java b/src/main/java/forestry/core/utils/BlockUtil.java index c0b86c2a3..15e615dfe 100644 --- a/src/main/java/forestry/core/utils/BlockUtil.java +++ b/src/main/java/forestry/core/utils/BlockUtil.java @@ -23,9 +23,9 @@ import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.EnumFacing; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; import net.minecraft.world.IBlockAccess; @@ -34,8 +34,6 @@ import net.minecraft.world.World; import net.minecraftforge.oredict.OreDictionary; import forestry.core.tiles.TileEngine; -import forestry.core.utils.vect.Vect; -import forestry.core.utils.vect.VectUtil; import cofh.api.energy.IEnergyConnection; import cofh.api.energy.IEnergyReceiver; @@ -44,35 +42,13 @@ public abstract class BlockUtil { private static final int slabWoodId = OreDictionary.getOreID("slabWood"); - public static List getBlockDrops(World world, Vect posBlock) { - IBlockState blockState = VectUtil.getBlockState(world, posBlock); + public static List getBlockDrops(World world, BlockPos posBlock) { + IBlockState blockState = world.getBlockState(posBlock); return blockState.getBlock().getDrops(world, posBlock, blockState, 0); } - /** - * @return The block state from the pos - */ - public static IBlockState getBlockState(IBlockAccess world, BlockPos posBlock) { - return world.getBlockState(posBlock); - } - - /** - * @return The block from the pos - */ - @Deprecated - public static Block getBlock(IBlockAccess world, BlockPos posBlock) { - return getBlockState(world, posBlock).getBlock(); - } - - /** - * @return The block metadata from the pos - */ - public static int getBlockMetadata(IBlockAccess world, BlockPos posBlock) { - return getBlock(world, posBlock).getMetaFromState(getBlockState(world, posBlock)); - } - public static boolean isEnergyReceiverOrEngine(EnumFacing side, TileEntity tile) { if (!(tile instanceof IEnergyReceiver) && !(tile instanceof TileEngine)) { return false; diff --git a/src/main/java/forestry/core/utils/VectUtil.java b/src/main/java/forestry/core/utils/VectUtil.java new file mode 100644 index 000000000..0e03f78f2 --- /dev/null +++ b/src/main/java/forestry/core/utils/VectUtil.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * 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; + +import java.util.Random; + +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3i; + +public final class VectUtil { + public static BlockPos getRandomPositionInArea(Random random, Vec3i area) { + int x = random.nextInt(area.getX()); + int y = random.nextInt(area.getY()); + int z = random.nextInt(area.getZ()); + return new BlockPos(x, y, z); + } + + public static BlockPos add(Vec3i... vects) { + int x = 0; + int y = 0; + int z = 0; + for (Vec3i vect : vects) { + x += vect.getX(); + y += vect.getY(); + z += vect.getZ(); + } + return new BlockPos(x, y, z); + } + + public static BlockPos scale(Vec3i vect, float factor) { + return new BlockPos(vect.getX() * factor, vect.getY() * factor, vect.getZ() * factor); + } +} diff --git a/src/main/java/forestry/core/utils/vect/IVect.java b/src/main/java/forestry/core/utils/vect/IVect.java deleted file mode 100644 index e48cb4054..000000000 --- a/src/main/java/forestry/core/utils/vect/IVect.java +++ /dev/null @@ -1,50 +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.core.utils.vect; - -import net.minecraft.entity.Entity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.EnumFacing; - -import forestry.api.farming.FarmDirection; - -/** - * Represents a position or dimensions. - */ -@Deprecated -public abstract class IVect extends BlockPos { - - public IVect(int x, int y, int z) { - super(x, y, z); - } - - public IVect(Entity source) { - super(source); - } - - public IVect(BlockPos pos) { - super(pos); - } - - public IVect(double x, double y, double z) { - super(x, y, z); - } - - abstract IVect add(IVect other); - - abstract IVect add(EnumFacing direction); - - abstract IVect add(FarmDirection direction); - - abstract IVect add(BlockPos coordinates); - - abstract int[] toArray(); -} diff --git a/src/main/java/forestry/core/utils/vect/MutableVect.java b/src/main/java/forestry/core/utils/vect/MutableVect.java deleted file mode 100644 index 1cbab646d..000000000 --- a/src/main/java/forestry/core/utils/vect/MutableVect.java +++ /dev/null @@ -1,152 +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.core.utils.vect; - -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.EnumFacing; - -import forestry.api.farming.FarmDirection; - -/** - * Represents changeable positions or dimensions. - */ -@Deprecated -public class MutableVect extends IVect { - public int x; - public int y; - public int z; - - public MutableVect(int x, int y, int z) { - super(0, 0, 0); - this.x = x; - this.y = y; - this.z = z; - } - - public MutableVect(EnumFacing direction) { - super(0, 0, 0); - this.x = direction.getFrontOffsetX(); - this.y = direction.getFrontOffsetY(); - this.z = direction.getFrontOffsetZ(); - } - - public MutableVect(int[] dim) { - super(0, 0, 0); - 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 MutableVect(BlockPos pos) { - super(0, 0, 0); - this.x = pos.getX(); - this.y = pos.getY(); - this.z = pos.getZ(); - } - - public MutableVect(IVect vect) { - super(0, 0, 0); - this.x = vect.getX(); - this.y = vect.getY(); - this.z = vect.getZ(); - } - - @Override - public MutableVect add(IVect other) { - x += other.getX(); - y += other.getY(); - z += other.getZ(); - return this; - } - - @Override - public MutableVect add(int x, int y, int z) { - this.x += x; - this.y += y; - this.z += z; - return this; - } - - @Override - public MutableVect add(EnumFacing direction) { - this.x += direction.getFrontOffsetX(); - this.y += direction.getFrontOffsetY(); - this.z += direction.getFrontOffsetZ(); - return this; - } - - @Override - public MutableVect add(FarmDirection direction) { - return add(direction.getForgeDirection()); - } - - @Override - public MutableVect add(BlockPos pos) { - this.x += pos.getX(); - this.y += pos.getY(); - this.z += pos.getZ(); - return this; - } - - @Override - public int[] toArray() { - return new int[]{x, y, z}; - } - - public MutableVect multiply(float factor) { - this.x *= factor; - this.y *= factor; - this.z *= factor; - return this; - } - - public boolean advancePositionInArea(Vect area) { - // Increment z first until end reached - if (z < area.getZ() - 1) { - z++; - } else { - z = 0; - - if (x < area.getX() - 1) { - x++; - } else { - x = 0; - - if (y < area.getY() - 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; - } -} diff --git a/src/main/java/forestry/core/utils/vect/Vect.java b/src/main/java/forestry/core/utils/vect/Vect.java deleted file mode 100644 index 749c3f2f4..000000000 --- a/src/main/java/forestry/core/utils/vect/Vect.java +++ /dev/null @@ -1,142 +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.core.utils.vect; - -import java.util.Random; - -import net.minecraft.entity.Entity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.EnumFacing; - -import forestry.api.farming.FarmDirection; - -/** - * Represents an unchangeable position or dimensions. - */ -@Deprecated -public class Vect extends IVect { - - public Vect(int[] dim) { - super(dim[0], dim[1], dim[2]); - if (dim.length != 3) { - throw new RuntimeException("Cannot instantiate a vector with less or more than 3 points."); - } - } - - public Vect(IVect vect) { - super(vect.getX(), vect.getY(), vect.getZ()); - } - - public Vect(EnumFacing direction) { - super(direction.getFrontOffsetX(), direction.getFrontOffsetY(), direction.getFrontOffsetZ()); - } - - public Vect(int x, int y, int z) { - super(x, y, z); - } - - public Vect(BlockPos pos) { - super(pos); - } - - public Vect(TileEntity entity) { - this(entity.getPos()); - } - - public Vect(Entity entity) { - super(entity); - } - - 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(getX() + other.getX(), getY() + other.getY(), getZ() + other.getZ()); - } - - @Override - public Vect add(int x, int y, int z) { - return new Vect(getX() + x, getY() + y, getZ() + z); - } - - @Override - public Vect add(EnumFacing direction) { - return add(direction.getFrontOffsetX(), direction.getFrontOffsetY(), direction.getFrontOffsetZ()); - } - - @Override - public Vect add(FarmDirection direction) { - return add(direction.getForgeDirection()); - } - - @Override - public Vect add(BlockPos pos) { - return add(pos.getX(), pos.getY(), pos.getZ()); - } - - @Override - public int[] toArray() { - return new int[]{getX(), getY(), getZ()}; - } - - public Vect multiply(int factor) { - return new Vect(getX() * factor, getY() * factor, getZ() * factor); - } - - public Vect multiply(float factor) { - return new Vect(Math.round(getX() * factor), Math.round(getY() * factor), Math.round(getZ() * factor)); - } - - @Override - public String toString() { - return String.format("%sx%sx%s", getX(), getY(), getZ()); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + getX(); - result = prime * result + getY(); - result = prime * result + getZ(); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof Vect)) { - return false; - } - Vect other = (Vect) obj; - return getX() == other.getX() && getY() == other.getY() && getZ() == other.getZ(); - } -} diff --git a/src/main/java/forestry/core/utils/vect/VectUtil.java b/src/main/java/forestry/core/utils/vect/VectUtil.java deleted file mode 100644 index bdccc1255..000000000 --- a/src/main/java/forestry/core/utils/vect/VectUtil.java +++ /dev/null @@ -1,57 +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.core.utils.vect; - -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -@Deprecated -public final class VectUtil { - @Deprecated - public static boolean isAirBlock(World world, BlockPos position) { - return world.isAirBlock(position); - } - - @Deprecated - public static boolean isWoodBlock(World world, BlockPos position) { - Block block = getBlock(world, position); - return block.isWood(world, position); - } - - @Deprecated - public static TileEntity getTile(World world, BlockPos position) { - return world.getTileEntity(position); - } - - @Deprecated - public static IBlockState getBlockState(World world, BlockPos position) { - return world.getBlockState(position); - } - - @Deprecated - public static Block getBlock(World world, BlockPos position) { - return getBlockState(world, position).getBlock(); - } - - @Deprecated - public static int getBlockMeta(World world, BlockPos position) { - return getBlock(world, position).getMetaFromState(getBlockState(world, position)); - } - - @Deprecated - public static ItemStack getAsItemStack(World world, BlockPos position) { - return new ItemStack(getBlock(world, position), 1, getBlockMeta(world, position)); - } -} diff --git a/src/main/java/forestry/farming/FarmHelper.java b/src/main/java/forestry/farming/FarmHelper.java index 89bfc5c5d..f898cccb6 100755 --- a/src/main/java/forestry/farming/FarmHelper.java +++ b/src/main/java/forestry/farming/FarmHelper.java @@ -15,13 +15,11 @@ import com.google.common.collect.ImmutableSet; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import forestry.api.farming.FarmDirection; import forestry.api.multiblock.IFarmComponent; -import forestry.core.utils.vect.MutableVect; -import forestry.core.utils.vect.Vect; -import forestry.core.utils.vect.VectUtil; public class FarmHelper { @@ -34,25 +32,26 @@ public class FarmHelper { ); private static FarmDirection getOpposite(FarmDirection farmDirection) { - EnumFacing forgeDirection = farmDirection.getForgeDirection(); + EnumFacing forgeDirection = farmDirection.getFacing(); EnumFacing forgeDirectionOpposite = forgeDirection.getOpposite(); return FarmDirection.getFarmDirection(forgeDirectionOpposite); } - public static Vect getFarmMultiblockCorner(World world, Vect start, FarmDirection farmSide, FarmDirection layoutDirection) { - Vect edge = getFarmMultiblockEdge(world, start, farmSide); + public static BlockPos getFarmMultiblockCorner(World world, BlockPos start, FarmDirection farmSide, FarmDirection layoutDirection) { + BlockPos edge = getFarmMultiblockEdge(world, start, farmSide); return getFarmMultiblockEdge(world, edge, getOpposite(layoutDirection)); } - private static Vect getFarmMultiblockEdge(World world, Vect start, FarmDirection direction) { - MutableVect edge = new MutableVect(start); + private static BlockPos getFarmMultiblockEdge(World world, BlockPos start, FarmDirection direction) { + BlockPos.MutableBlockPos edge = new BlockPos.MutableBlockPos(start); - while (VectUtil.getTile(world, edge) instanceof IFarmComponent) { - edge.add(direction); + while (world.getTileEntity(edge) instanceof IFarmComponent) { + edge.offsetMutable(direction.getFacing()); } - edge.add(getOpposite(direction)); - return new Vect(edge); + FarmDirection oppositeDirection = getOpposite(direction); + edge.offsetMutable(oppositeDirection.getFacing()); + return edge.toImmutable(); } } diff --git a/src/main/java/forestry/farming/FarmTarget.java b/src/main/java/forestry/farming/FarmTarget.java index a276bc708..614bab1be 100755 --- a/src/main/java/forestry/farming/FarmTarget.java +++ b/src/main/java/forestry/farming/FarmTarget.java @@ -11,29 +11,28 @@ package forestry.farming; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import forestry.api.farming.FarmDirection; -import forestry.core.utils.vect.MutableVect; -import forestry.core.utils.vect.Vect; -import forestry.core.utils.vect.VectUtil; public class FarmTarget { - private final Vect start; + private final BlockPos start; private final FarmDirection direction; private final int limit; private int yOffset; private int extent; - public FarmTarget(Vect start, FarmDirection direction, int limit) { + public FarmTarget(BlockPos start, FarmDirection direction, int limit) { this.start = start; this.direction = direction; this.limit = limit; } - public Vect getStart() { + public BlockPos getStart() { return start; } @@ -49,19 +48,20 @@ public class FarmTarget { return direction; } - public void setExtentAndYOffset(World world, Vect platformPosition) { + public void setExtentAndYOffset(World world, BlockPos platformPosition) { if (platformPosition == null) { extent = 0; return; } - MutableVect position = new MutableVect(platformPosition); + BlockPos.MutableBlockPos position = new BlockPos.MutableBlockPos(platformPosition); for (extent = 0; extent < limit; extent++) { - Block platform = VectUtil.getBlock(world, position); + IBlockState blockState = world.getBlockState(position); + Block platform = blockState.getBlock(); if (!FarmHelper.bricks.contains(platform)) { break; } - position.add(getDirection().getForgeDirection()); + position.offsetMutable(getDirection().getFacing()); } yOffset = platformPosition.getY() + 1 - getStart().getY(); diff --git a/src/main/java/forestry/farming/blocks/BlockFarm.java b/src/main/java/forestry/farming/blocks/BlockFarm.java index 6c4b2b4a0..01da7418b 100644 --- a/src/main/java/forestry/farming/blocks/BlockFarm.java +++ b/src/main/java/forestry/farming/blocks/BlockFarm.java @@ -45,7 +45,6 @@ import forestry.api.core.Tabs; import forestry.core.blocks.BlockStructure; import forestry.core.blocks.propertys.UnlistedBlockAccess; import forestry.core.blocks.propertys.UnlistedBlockPos; -import forestry.core.utils.BlockUtil; import forestry.core.utils.ItemStackUtil; import forestry.farming.models.EnumFarmBlockTexture; import forestry.farming.tiles.TileFarm; @@ -110,7 +109,7 @@ public class BlockFarm extends BlockStructure { @Override public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { - List drops = getDrops(world, pos, BlockUtil.getBlockState(world, pos), 0); + List drops = getDrops(world, pos, world.getBlockState(pos), 0); if (drops.isEmpty()) { return super.getPickBlock(state, target, world, pos, player); } @@ -132,7 +131,7 @@ public class BlockFarm extends BlockStructure { @Override public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) { if (!world.isRemote && canHarvestBlock(world, pos, player)) { - List drops = getDrops(world, pos, BlockUtil.getBlockState(world, pos), 0); + List drops = getDrops(world, pos, world.getBlockState(pos), 0); for (ItemStack drop : drops) { ItemStackUtil.dropItemStackAsEntity(drop, world, pos); } diff --git a/src/main/java/forestry/farming/blocks/BlockMushroom.java b/src/main/java/forestry/farming/blocks/BlockMushroom.java index f7aef1a52..77887e481 100644 --- a/src/main/java/forestry/farming/blocks/BlockMushroom.java +++ b/src/main/java/forestry/farming/blocks/BlockMushroom.java @@ -15,6 +15,7 @@ import java.util.List; import java.util.Locale; import java.util.Random; +import net.minecraft.block.Block; import net.minecraft.block.BlockBush; import net.minecraft.block.BlockDirt; import net.minecraft.block.IGrowable; @@ -39,7 +40,6 @@ import forestry.api.core.IItemModelRegister; import forestry.api.core.IModelManager; import forestry.core.blocks.IBlockWithMeta; import forestry.core.config.Constants; -import forestry.core.utils.BlockUtil; public class BlockMushroom extends BlockBush implements IItemModelRegister, IGrowable, IBlockWithMeta { @@ -124,7 +124,9 @@ public class BlockMushroom extends BlockBush implements IItemModelRegister, IGro return; } - int meta = BlockUtil.getBlockMetadata(world, pos); + IBlockState blockState = world.getBlockState(pos); + Block block = blockState.getBlock(); + int meta = block.getMetaFromState(blockState); MushroomType type = getTypeFromMeta(meta); int maturity = meta >> 2; @@ -150,7 +152,7 @@ public class BlockMushroom extends BlockBush implements IItemModelRegister, IGro } public void generateTree(World world, BlockPos pos, IBlockState state, Random rand) { - MushroomType type = getTypeFromMeta(BlockUtil.getBlockMetadata(world, pos)); + MushroomType type = state.getValue(MUSHROOM); world.setBlockToAir(pos); if (!generators[type.ordinal()].generate(world, rand, pos)) { diff --git a/src/main/java/forestry/farming/logic/Crop.java b/src/main/java/forestry/farming/logic/Crop.java index 5f3e1c939..d4bef3172 100755 --- a/src/main/java/forestry/farming/logic/Crop.java +++ b/src/main/java/forestry/farming/logic/Crop.java @@ -16,47 +16,46 @@ import java.util.Collection; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import forestry.api.farming.ICrop; import forestry.core.config.Constants; -import forestry.core.utils.BlockUtil; -import forestry.core.utils.vect.Vect; public abstract class Crop implements ICrop { protected final World world; - protected final Vect position; + protected final BlockPos position; - protected Crop(World world, Vect position) { + protected Crop(World world, BlockPos position) { this.world = world; this.position = position; } - protected final void setBlock(Vect position, IBlockState blockState) { + protected final void setBlock(BlockPos position, IBlockState blockState) { world.setBlockState(position, blockState, Constants.FLAG_BLOCK_SYNCH); } @Deprecated - protected final void setBlock(Vect position, Block block, int meta) { + protected final void setBlock(BlockPos position, Block block, int meta) { setBlock(position, block.getStateFromMeta(meta)); } - protected final Block getBlock(Vect position) { + protected final Block getBlock(BlockPos position) { return getBlockState(position).getBlock(); } - protected final IBlockState getBlockState(Vect position) { - return BlockUtil.getBlockState(world, position); + protected final IBlockState getBlockState(BlockPos position) { + return world.getBlockState(position); } - protected final int getBlockMeta(Vect position) { + protected final int getBlockMeta(BlockPos position) { return getBlock(position).getMetaFromState(getBlockState(position)); } - protected abstract boolean isCrop(Vect pos); + protected abstract boolean isCrop(BlockPos pos); - protected abstract Collection harvestBlock(Vect pos); + protected abstract Collection harvestBlock(BlockPos pos); @Nullable @Override diff --git a/src/main/java/forestry/farming/logic/CropBasicAgriCraft.java b/src/main/java/forestry/farming/logic/CropBasicAgriCraft.java index 9a82945bb..25c9f893b 100644 --- a/src/main/java/forestry/farming/logic/CropBasicAgriCraft.java +++ b/src/main/java/forestry/farming/logic/CropBasicAgriCraft.java @@ -16,30 +16,30 @@ import java.util.List; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import forestry.core.config.Constants; import forestry.core.proxy.Proxies; -import forestry.core.utils.vect.Vect; public class CropBasicAgriCraft extends Crop { private final Block block; private final int meta; - public CropBasicAgriCraft(World world, Block block, int meta, Vect position) { + public CropBasicAgriCraft(World world, Block block, int meta, BlockPos position) { super(world, position); this.block = block; this.meta = meta; } @Override - protected boolean isCrop(Vect pos) { + protected boolean isCrop(BlockPos pos) { return getBlock(pos) == block && getBlockMeta(pos) == meta; } @Override - protected Collection harvestBlock(Vect pos) { + protected Collection harvestBlock(BlockPos pos) { List harvest = block.getDrops(world, pos, block.getStateFromMeta(meta), 0); if (harvest.size() > 1) { harvest.remove(1); //AgriCraft returns cropsticks in 0, seeds in 1 in getDrops, removing since harvesting doesn't return them. diff --git a/src/main/java/forestry/farming/logic/CropBasicFruit.java b/src/main/java/forestry/farming/logic/CropBasicFruit.java index 8445bd1e1..f82fd0f76 100644 --- a/src/main/java/forestry/farming/logic/CropBasicFruit.java +++ b/src/main/java/forestry/farming/logic/CropBasicFruit.java @@ -14,30 +14,30 @@ import java.util.Collection; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import forestry.core.config.Constants; import forestry.core.proxy.Proxies; -import forestry.core.utils.vect.Vect; public class CropBasicFruit extends Crop { private final Block block; private final int meta; - public CropBasicFruit(World world, Block block, int meta, Vect position) { + public CropBasicFruit(World world, Block block, int meta, BlockPos position) { super(world, position); this.block = block; this.meta = meta; } @Override - protected boolean isCrop(Vect pos) { + protected boolean isCrop(BlockPos pos) { return getBlock(pos) == block && getBlockMeta(pos) == meta; } @Override - protected Collection harvestBlock(Vect pos) { + protected Collection harvestBlock(BlockPos pos) { Collection harvested = block.getDrops(world, pos, block.getStateFromMeta(meta), 0); Proxies.common.addBlockDestroyEffects(world, pos, block.getDefaultState()); world.setBlockState(pos, block.getDefaultState(), Constants.FLAG_BLOCK_SYNCH); diff --git a/src/main/java/forestry/farming/logic/CropBasicGrowthCraft.java b/src/main/java/forestry/farming/logic/CropBasicGrowthCraft.java index 04a640782..3b5bb00cf 100644 --- a/src/main/java/forestry/farming/logic/CropBasicGrowthCraft.java +++ b/src/main/java/forestry/farming/logic/CropBasicGrowthCraft.java @@ -15,11 +15,11 @@ import java.util.List; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import forestry.core.config.Constants; import forestry.core.proxy.Proxies; -import forestry.core.utils.vect.Vect; public class CropBasicGrowthCraft extends Crop { @@ -28,7 +28,7 @@ public class CropBasicGrowthCraft extends Crop { private final boolean isRice; private final boolean isGrape; - public CropBasicGrowthCraft(World world, Block block, int meta, Vect position, boolean isRice, boolean isGrape) { + public CropBasicGrowthCraft(World world, Block block, int meta, BlockPos position, boolean isRice, boolean isGrape) { super(world, position); this.block = block; this.meta = meta; @@ -37,12 +37,12 @@ public class CropBasicGrowthCraft extends Crop { } @Override - protected boolean isCrop(Vect pos) { + protected boolean isCrop(BlockPos pos) { return getBlock(pos) == block && getBlockMeta(pos) == meta; } @Override - protected Collection harvestBlock(Vect pos) { + protected Collection harvestBlock(BlockPos pos) { List harvest = block.getDrops(world, pos, block.getStateFromMeta(meta), 0); if (harvest.size() > 1) { harvest.remove(0); //Hops have rope as first drop. diff --git a/src/main/java/forestry/farming/logic/CropBlock.java b/src/main/java/forestry/farming/logic/CropBlock.java index 88df3f9aa..59f25366f 100755 --- a/src/main/java/forestry/farming/logic/CropBlock.java +++ b/src/main/java/forestry/farming/logic/CropBlock.java @@ -14,29 +14,29 @@ import java.util.Collection; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import forestry.core.proxy.Proxies; -import forestry.core.utils.vect.Vect; public class CropBlock extends Crop { protected final Block block; protected final int meta; - public CropBlock(World world, Block block, int meta, Vect position) { + public CropBlock(World world, Block block, int meta, BlockPos position) { super(world, position); this.block = block; this.meta = meta; } @Override - protected boolean isCrop(Vect pos) { + protected boolean isCrop(BlockPos pos) { return getBlock(pos) == block && getBlockMeta(pos) == meta; } @Override - protected Collection harvestBlock(Vect pos) { + protected Collection harvestBlock(BlockPos pos) { Collection harvested = block.getDrops(world, pos, block.getStateFromMeta(meta), 0); Proxies.common.addBlockDestroyEffects(world, pos, block.getDefaultState()); // Block.breakBlock() is called by vanilla itself, removing TEs. diff --git a/src/main/java/forestry/farming/logic/CropFruit.java b/src/main/java/forestry/farming/logic/CropFruit.java index fd8f2ed46..9c5971a18 100755 --- a/src/main/java/forestry/farming/logic/CropFruit.java +++ b/src/main/java/forestry/farming/logic/CropFruit.java @@ -15,21 +15,21 @@ import java.util.Collection; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import forestry.api.genetics.IFruitBearer; import forestry.core.network.packets.PacketFXSignal; import forestry.core.proxy.Proxies; -import forestry.core.utils.vect.Vect; public class CropFruit extends Crop { - public CropFruit(World world, Vect position) { + public CropFruit(World world, BlockPos position) { super(world, position); } @Override - protected boolean isCrop(Vect pos) { + protected boolean isCrop(BlockPos pos) { TileEntity tile = world.getTileEntity(pos); if (!(tile instanceof IFruitBearer)) { return false; @@ -46,7 +46,7 @@ public class CropFruit extends Crop { } @Override - protected Collection harvestBlock(Vect pos) { + protected Collection harvestBlock(BlockPos pos) { TileEntity tile = world.getTileEntity(pos); if (!(tile instanceof IFruitBearer)) { return new ArrayList<>(); diff --git a/src/main/java/forestry/farming/logic/CropPeat.java b/src/main/java/forestry/farming/logic/CropPeat.java index 222987bc2..516c49f3d 100755 --- a/src/main/java/forestry/farming/logic/CropPeat.java +++ b/src/main/java/forestry/farming/logic/CropPeat.java @@ -17,21 +17,21 @@ import java.util.List; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import forestry.core.PluginCore; import forestry.core.blocks.BlockSoil; import forestry.core.proxy.Proxies; -import forestry.core.utils.vect.Vect; public class CropPeat extends Crop { - public CropPeat(World world, Vect position) { + public CropPeat(World world, BlockPos position) { super(world, position); } @Override - protected boolean isCrop(Vect pos) { + protected boolean isCrop(BlockPos pos) { Block block = getBlock(pos); if (!(block instanceof BlockSoil)) { return false; @@ -43,12 +43,12 @@ public class CropPeat extends Crop { } @Override - protected Collection harvestBlock(Vect pos) { + protected Collection harvestBlock(BlockPos pos) { List drops = new ArrayList<>(); drops.add(PluginCore.items.peat.getItemStack()); Proxies.common.addBlockDestroyEffects(world, pos, getBlock(pos).getDefaultState()); - setBlock(pos, Blocks.DIRT, 0); + setBlock(pos, Blocks.DIRT.getDefaultState()); return drops; } diff --git a/src/main/java/forestry/farming/logic/CropRubber.java b/src/main/java/forestry/farming/logic/CropRubber.java index 17b5d592b..d55265ad6 100755 --- a/src/main/java/forestry/farming/logic/CropRubber.java +++ b/src/main/java/forestry/farming/logic/CropRubber.java @@ -15,21 +15,21 @@ import java.util.Collection; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import forestry.core.config.Constants; import forestry.core.proxy.Proxies; -import forestry.core.utils.vect.Vect; import forestry.plugins.compat.PluginIC2; public class CropRubber extends CropBlock { - public CropRubber(World world, Block block, int meta, Vect position) { + public CropRubber(World world, Block block, int meta, BlockPos position) { super(world, block, meta, position); } @Override - protected Collection harvestBlock(Vect pos) { + protected Collection harvestBlock(BlockPos pos) { Collection harvested = new ArrayList<>(); harvested.add(PluginIC2.resin.copy()); Proxies.common.addBlockDestroyEffects(world, pos, block.getDefaultState()); diff --git a/src/main/java/forestry/farming/logic/FarmLogic.java b/src/main/java/forestry/farming/logic/FarmLogic.java index a43abac8e..422203df1 100755 --- a/src/main/java/forestry/farming/logic/FarmLogic.java +++ b/src/main/java/forestry/farming/logic/FarmLogic.java @@ -15,16 +15,16 @@ import java.util.ArrayList; import java.util.List; import net.minecraft.block.Block; -import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.Vec3i; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; @@ -33,11 +33,9 @@ import net.minecraftforge.fml.relauncher.SideOnly; import forestry.api.farming.FarmDirection; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmLogic; -import forestry.arboriculture.blocks.BlockFruitPod; import forestry.core.config.Constants; import forestry.core.entities.EntitySelector; -import forestry.core.utils.BlockUtil; -import forestry.core.utils.vect.Vect; +import forestry.core.utils.VectUtil; public abstract class FarmLogic implements IFarmLogic { private final EntitySelectorFarm entitySelectorFarm = new EntitySelectorFarm(this); @@ -85,30 +83,27 @@ public abstract class FarmLogic implements IFarmLogic { return block.isAir(blockState, world, blockPos); } - protected final boolean isWaterSourceBlock(World world, Vect position) { - return BlockUtil.getBlock(world, position) == Blocks.WATER && - BlockUtil.getBlockMetadata(world, position) == 0; - } - - protected final Vect translateWithOffset(int x, int y, int z, FarmDirection farmDirection, int step) { - return new Vect(farmDirection.getForgeDirection()).multiply(step).add(x, y, z); + protected final boolean isWaterSourceBlock(World world, BlockPos position) { + IBlockState blockState = world.getBlockState(position); + Block block = blockState.getBlock(); + return block == Blocks.WATER && block.getMetaFromState(blockState) == 0; } - protected final Vect translateWithOffset(BlockPos pos, FarmDirection farmDirection, int step) { - return new Vect(farmDirection.getForgeDirection()).multiply(step).add(pos); + protected final BlockPos translateWithOffset(BlockPos pos, FarmDirection farmDirection, int step) { + return VectUtil.scale(farmDirection.getFacing().getDirectionVec(), step).add(pos); } - protected final void setBlock(Vect position, Block block, int meta) { + protected final void setBlock(BlockPos position, Block block, int meta) { getWorld().setBlockState(position, block.getStateFromMeta(meta), Constants.FLAG_BLOCK_SYNCH_AND_UPDATE); } private AxisAlignedBB getHarvestBox(IFarmHousing farmHousing, boolean toWorldHeight) { - Vect coords = new Vect(farmHousing.getCoords()); - Vect area = new Vect(farmHousing.getArea()); - Vect offset = new Vect(farmHousing.getOffset()); + BlockPos coords = farmHousing.getCoords(); + Vec3i area = farmHousing.getArea(); + Vec3i offset = farmHousing.getOffset(); - Vect min = coords.add(offset); - Vect max = min.add(area); + BlockPos min = coords.add(offset); + BlockPos max = min.add(area); int maxY = max.getY(); if (toWorldHeight) { diff --git a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java index 42177c9b4..f26082fd0 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java @@ -15,10 +15,13 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.List; +import java.util.Map; import java.util.Set; import java.util.Stack; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -35,8 +38,6 @@ import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; import forestry.core.PluginCore; import forestry.core.blocks.BlockSoil; -import forestry.core.utils.vect.Vect; -import forestry.core.utils.vect.VectUtil; public class FarmLogicArboreal extends FarmLogicHomogeneous { private static final int BRANCH_RANGE = 20; @@ -91,34 +92,33 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { return products; } - private final HashMap lastExtentsHarvest = new HashMap<>(); + private final Map lastExtentsHarvest = new HashMap<>(); @Override public Collection harvest(BlockPos pos, FarmDirection direction, int extent) { - Vect start = new Vect(pos); - if (!lastExtentsHarvest.containsKey(start)) { - lastExtentsHarvest.put(start, 0); + if (!lastExtentsHarvest.containsKey(pos)) { + lastExtentsHarvest.put(pos, 0); } - int lastExtent = lastExtentsHarvest.get(start); + int lastExtent = lastExtentsHarvest.get(pos); if (lastExtent > extent) { lastExtent = 0; } - Vect position = translateWithOffset(pos.add(0, 1, 0), direction, lastExtent); + BlockPos position = translateWithOffset(pos.up(), direction, lastExtent); Collection crops = getHarvestBlocks(position); lastExtent++; - lastExtentsHarvest.put(start, lastExtent); + lastExtentsHarvest.put(pos, lastExtent); return crops; } - private Collection getHarvestBlocks(Vect position) { + private Collection getHarvestBlocks(BlockPos position) { World world = getWorld(); - Set seen = new HashSet<>(); + Set seen = new HashSet<>(); Stack crops = new Stack<>(); // Determine what type we want to harvest. @@ -139,10 +139,10 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { return crops; } - ArrayList candidates = processHarvestBlock(germling, crops, seen, position, position); - ArrayList temp = new ArrayList<>(); + List candidates = processHarvestBlock(germling, crops, seen, position, position); + List temp = new ArrayList<>(); while (!candidates.isEmpty()) { - for (Vect candidate : candidates) { + for (BlockPos candidate : candidates) { temp.addAll(processHarvestBlock(germling, crops, seen, position, candidate)); } candidates.clear(); @@ -153,17 +153,17 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { return crops; } - private ArrayList processHarvestBlock(IFarmable germling, Stack crops, Set seen, Vect start, Vect position) { + private List processHarvestBlock(IFarmable germling, Stack crops, Set seen, BlockPos start, BlockPos position) { World world = getWorld(); - ArrayList candidates = new ArrayList<>(); + List candidates = new ArrayList<>(); // Get additional candidates to return for (int x = -1; x < 2; x++) { for (int y = -1; y < 2; y++) { for (int z = -1; z < 2; z++) { - Vect candidate = position.add(x, y, z); + BlockPos candidate = position.add(x, y, z); if (candidate.equals(position)) { continue; } @@ -198,11 +198,13 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { World world = getWorld(); for (int i = 0; i < extent; i++) { - Vect position = translateWithOffset(pos, direction, i); + BlockPos position = translateWithOffset(pos, direction, i); - if (VectUtil.isAirBlock(world, position)) { - Vect soilBelowPosition = new Vect(position.getX(), position.getY() - 1, position.getZ()); - ItemStack soilBelow = VectUtil.getAsItemStack(world, soilBelowPosition); + if (world.isAirBlock(position)) { + BlockPos soilPosition = position.down(); + IBlockState soilState = world.getBlockState(soilPosition); + Block soilBlock = soilState.getBlock(); + ItemStack soilBelow = soilBlock.getPickBlock(soilState, null, world, soilPosition, null); if (isAcceptedSoil(soilBelow)) { return plantSapling(position); } @@ -211,7 +213,7 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { return false; } - private boolean plantSapling(Vect position) { + private boolean plantSapling(BlockPos position) { World world = getWorld(); Collections.shuffle(germlings); for (IFarmable candidate : germlings) { diff --git a/src/main/java/forestry/farming/logic/FarmLogicCocoa.java b/src/main/java/forestry/farming/logic/FarmLogicCocoa.java index 276c5f013..c3e70fa17 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicCocoa.java +++ b/src/main/java/forestry/farming/logic/FarmLogicCocoa.java @@ -14,16 +14,19 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; +import java.util.List; +import java.util.Map; import java.util.Set; import java.util.Stack; import net.minecraft.block.Block; import net.minecraft.block.BlockPlanks; +import net.minecraft.block.state.IBlockState; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; @@ -33,10 +36,6 @@ import forestry.api.farming.FarmDirection; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; -import forestry.core.utils.BlockUtil; -import forestry.core.utils.vect.MutableVect; -import forestry.core.utils.vect.Vect; -import forestry.core.utils.vect.VectUtil; public class FarmLogicCocoa extends FarmLogic { @@ -87,87 +86,86 @@ public class FarmLogicCocoa extends FarmLogic { return null; } - private final HashMap lastExtentsCultivation = new HashMap<>(); + private final Map lastExtentsCultivation = new HashMap<>(); @Override public boolean cultivate(BlockPos pos, FarmDirection direction, int extent) { - Vect start = new Vect(pos); - if (!lastExtentsCultivation.containsKey(start)) { - lastExtentsCultivation.put(start, 0); + if (!lastExtentsCultivation.containsKey(pos)) { + lastExtentsCultivation.put(pos, 0); } - int lastExtent = lastExtentsCultivation.get(start); + int lastExtent = lastExtentsCultivation.get(pos); if (lastExtent > extent) { lastExtent = 0; } - Vect position = translateWithOffset(pos.add(0, 1, 0), direction, lastExtent); + BlockPos position = translateWithOffset(pos.add(0, 1, 0), direction, lastExtent); boolean result = tryPlantingCocoa(position); lastExtent++; - lastExtentsCultivation.put(start, lastExtent); + lastExtentsCultivation.put(pos, lastExtent); return result; } - private final HashMap lastExtentsHarvest = new HashMap<>(); + private final Map lastExtentsHarvest = new HashMap<>(); @Override public Collection harvest(BlockPos pos, FarmDirection direction, int extent) { - - Vect start = new Vect(pos); - if (!lastExtentsHarvest.containsKey(start)) { - lastExtentsHarvest.put(start, 0); + if (!lastExtentsHarvest.containsKey(pos)) { + lastExtentsHarvest.put(pos, 0); } - int lastExtent = lastExtentsHarvest.get(start); + int lastExtent = lastExtentsHarvest.get(pos); if (lastExtent > extent) { lastExtent = 0; } - Vect position = translateWithOffset(pos.add(0, 1, 0), direction, lastExtent); + BlockPos position = translateWithOffset(pos.add(0, 1, 0), direction, lastExtent); Collection crops = getHarvestBlocks(position); lastExtent++; - lastExtentsHarvest.put(start, lastExtent); + lastExtentsHarvest.put(pos, lastExtent); return crops; } - private boolean tryPlantingCocoa(Vect position) { + private boolean tryPlantingCocoa(BlockPos position) { World world = getWorld(); - MutableVect current = new MutableVect(position); - while (VectUtil.isWoodBlock(world, current) && BlockUtil.getBlockState(world, current).getValue(BlockPlanks.VARIANT) == BlockPlanks.EnumType.JUNGLE) { + BlockPos.MutableBlockPos current = new BlockPos.MutableBlockPos(position); + IBlockState blockState = world.getBlockState(current); + Block block = blockState.getBlock(); + while (block.isWood(world, current) && blockState.getValue(BlockPlanks.VARIANT) == BlockPlanks.EnumType.JUNGLE) { - for (EnumFacing direction : EnumFacing.values()) { - if (direction == EnumFacing.UP || direction == EnumFacing.DOWN) { - continue; - } - - Vect candidate = new Vect(current.x + direction.getFrontOffsetX(), current.y, current.z + direction.getFrontOffsetZ()); - if (VectUtil.isAirBlock(world, candidate)) { + for (EnumFacing direction : EnumFacing.HORIZONTALS) { + BlockPos candidate = new BlockPos(current.getX() + direction.getFrontOffsetX(), current.getY(), current.getZ() + direction.getFrontOffsetZ()); + if (world.isAirBlock(candidate)) { return housing.plantGermling(cocoa, world, candidate); } } - current.y++; + current.offsetMutable(EnumFacing.UP); if (current.getY() - position.getY() > 1) { break; } + + blockState = world.getBlockState(current); + blockState.getBlock(); } return false; } - private Collection getHarvestBlocks(Vect position) { + private Collection getHarvestBlocks(BlockPos position) { - Set seen = new HashSet<>(); + Set seen = new HashSet<>(); Stack crops = new Stack<>(); // Determine what type we want to harvest. - Block block = VectUtil.getBlock(getWorld(), position); + IBlockState blockState = getWorld().getBlockState(position); + Block block = blockState.getBlock(); ICrop crop = null; if (!block.isWood(getWorld(), position)) { @@ -181,10 +179,10 @@ public class FarmLogicCocoa extends FarmLogic { crops.add(crop); } - ArrayList candidates = processHarvestBlock(crops, seen, position, position); - ArrayList temp = new ArrayList<>(); + List candidates = processHarvestBlock(crops, seen, position, position); + List temp = new ArrayList<>(); while (!candidates.isEmpty() && crops.size() < 20) { - for (Vect candidate : candidates) { + for (BlockPos candidate : candidates) { temp.addAll(processHarvestBlock(crops, seen, position, candidate)); } candidates.clear(); @@ -196,17 +194,17 @@ public class FarmLogicCocoa extends FarmLogic { return crops; } - private ArrayList processHarvestBlock(Stack crops, Set seen, Vect start, Vect position) { + private List processHarvestBlock(Stack crops, Set seen, BlockPos start, BlockPos position) { World world = getWorld(); - ArrayList candidates = new ArrayList<>(); + List candidates = new ArrayList<>(); // Get additional candidates to return for (int i = -1; i < 2; i++) { for (int j = 0; j < 2; j++) { for (int k = -1; k < 2; k++) { - Vect candidate = position.add(i, j, k); + BlockPos candidate = position.add(i, j, k); if (candidate.equals(position)) { continue; } @@ -223,11 +221,13 @@ public class FarmLogicCocoa extends FarmLogic { } ICrop crop = cocoa.getCropAt(world, candidate); + IBlockState blockState = world.getBlockState(candidate); + Block block = blockState.getBlock(); if (crop != null) { crops.push(crop); candidates.add(candidate); seen.add(candidate); - } else if (VectUtil.isWoodBlock(world, candidate)) { + } else if (block.isWood(world, candidate)) { candidates.add(candidate); seen.add(candidate); } diff --git a/src/main/java/forestry/farming/logic/FarmLogicCrops.java b/src/main/java/forestry/farming/logic/FarmLogicCrops.java index 15acb41d3..c03321e6c 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicCrops.java +++ b/src/main/java/forestry/farming/logic/FarmLogicCrops.java @@ -13,6 +13,7 @@ package forestry.farming.logic; import java.util.Collection; import java.util.Stack; +import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; @@ -27,9 +28,6 @@ import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; import forestry.core.utils.BlockUtil; import forestry.core.utils.ItemStackUtil; -import forestry.core.utils.vect.IVect; -import forestry.core.utils.vect.Vect; -import forestry.core.utils.vect.VectUtil; public abstract class FarmLogicCrops extends FarmLogicWatered { private static final ItemStack farmland = new ItemStack(Blocks.FARMLAND, 1, OreDictionary.WILDCARD_VALUE); @@ -79,13 +77,16 @@ public abstract class FarmLogicCrops extends FarmLogicWatered { World world = getWorld(); for (int i = 0; i < extent; i++) { - Vect position = translateWithOffset(pos, direction, i); + BlockPos position = translateWithOffset(pos, direction, i); IBlockState state = world.getBlockState(position); - if (!VectUtil.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(state, world, position)) { + if (!world.isAirBlock(position) && !BlockUtil.isReplaceableBlock(state, world, position)) { continue; } - ItemStack below = VectUtil.getAsItemStack(world, position.down()); + BlockPos soilPosition = position.down(); + IBlockState blockState = world.getBlockState(soilPosition); + Block block = blockState.getBlock(); + ItemStack below = block.getPickBlock(blockState, null, world, soilPosition, null); if (ground.getItem() != below.getItem()) { continue; } @@ -99,7 +100,7 @@ public abstract class FarmLogicCrops extends FarmLogicWatered { return false; } - private boolean trySetCrop(IVect position) { + private boolean trySetCrop(BlockPos position) { World world = getWorld(); for (IFarmable candidate : seeds) { @@ -117,7 +118,7 @@ public abstract class FarmLogicCrops extends FarmLogicWatered { Stack crops = new Stack<>(); for (int i = 0; i < extent; i++) { - Vect position = translateWithOffset(pos.add(0, 1, 0), direction, i); + BlockPos position = translateWithOffset(pos.add(0, 1, 0), direction, i); for (IFarmable seed : seeds) { ICrop crop = seed.getCropAt(world, position); if (crop != null) { diff --git a/src/main/java/forestry/farming/logic/FarmLogicEnder.java b/src/main/java/forestry/farming/logic/FarmLogicEnder.java index 5fb98b303..491745a20 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicEnder.java +++ b/src/main/java/forestry/farming/logic/FarmLogicEnder.java @@ -13,6 +13,7 @@ package forestry.farming.logic; import java.util.Collection; import java.util.Stack; +import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -30,8 +31,6 @@ import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; import forestry.core.utils.BlockUtil; -import forestry.core.utils.vect.Vect; -import forestry.core.utils.vect.VectUtil; public class FarmLogicEnder extends FarmLogicHomogeneous { @@ -71,7 +70,7 @@ public class FarmLogicEnder extends FarmLogicHomogeneous { Stack crops = new Stack<>(); for (int i = 0; i < extent; i++) { - Vect position = translateWithOffset(pos.add(0, 1, 0), direction, i); + BlockPos position = translateWithOffset(pos.up(), direction, i); for (IFarmable farmable : germlings) { ICrop crop = farmable.getCropAt(world, position); if (crop != null) { @@ -89,13 +88,16 @@ public class FarmLogicEnder extends FarmLogicHomogeneous { World world = getWorld(); for (int i = 0; i < extent; i++) { - Vect position = translateWithOffset(pos, direction, i); + BlockPos position = translateWithOffset(pos, direction, i); IBlockState state = world.getBlockState(position); - if (!VectUtil.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(state, world, position)) { + if (!world.isAirBlock(position) && !BlockUtil.isReplaceableBlock(state, world, position)) { continue; } - ItemStack below = VectUtil.getAsItemStack(world, position.down()); + BlockPos soilPos = position.down(); + IBlockState blockState = world.getBlockState(soilPos); + Block block = blockState.getBlock(); + ItemStack below = block.getPickBlock(blockState, null, world, soilPos, null); if (!isAcceptedSoil(below)) { continue; } @@ -106,7 +108,7 @@ public class FarmLogicEnder extends FarmLogicHomogeneous { return false; } - private boolean trySetCrop(Vect position) { + private boolean trySetCrop(BlockPos position) { World world = getWorld(); for (IFarmable candidate : germlings) { diff --git a/src/main/java/forestry/farming/logic/FarmLogicGourd.java b/src/main/java/forestry/farming/logic/FarmLogicGourd.java index 93b7a572d..9ce0a935d 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicGourd.java +++ b/src/main/java/forestry/farming/logic/FarmLogicGourd.java @@ -27,7 +27,6 @@ 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.Vect; public class FarmLogicGourd extends FarmLogic { @@ -91,7 +90,7 @@ public class FarmLogicGourd extends FarmLogic { Stack crops = new Stack<>(); for (int i = 0; i < extent; i++) { - Vect position = translateWithOffset(pos.add(0, 1, 0), direction, i); + BlockPos position = translateWithOffset(pos.add(0, 1, 0), direction, i); for (IFarmable seed : seeds) { ICrop crop = seed.getCropAt(world, position); if (crop != null) { diff --git a/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java b/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java index 9322c1b5d..a7a4393cd 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java +++ b/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java @@ -14,6 +14,7 @@ import java.util.ArrayList; import java.util.List; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -23,8 +24,6 @@ import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; import forestry.core.utils.BlockUtil; import forestry.core.utils.ItemStackUtil; -import forestry.core.utils.vect.Vect; -import forestry.core.utils.vect.VectUtil; import forestry.farming.FarmHelper; public abstract class FarmLogicHomogeneous extends FarmLogic { @@ -93,20 +92,24 @@ public abstract class FarmLogicHomogeneous extends FarmLogic { World world = getWorld(); for (int i = 0; i < extent; i++) { - Vect position = translateWithOffset(pos, direction, i); - Block soil = VectUtil.getBlock(world, position); + BlockPos position = translateWithOffset(pos, direction, i); + IBlockState blockState1 = world.getBlockState(position); + Block soil = blockState1.getBlock(); if (FarmHelper.bricks.contains(soil)) { break; } - ItemStack soilStack = VectUtil.getAsItemStack(world, position); + IBlockState soilState = world.getBlockState(position); + Block soilBlock = soilState.getBlock(); + ItemStack soilStack = soilBlock.getPickBlock(soilState, null, world, position, null); if (isAcceptedSoil(soilStack)) { continue; } BlockPos platformPosition = position.down(); - Block platformBlock = VectUtil.getBlock(world, platformPosition); + IBlockState blockState = world.getBlockState(platformPosition); + Block platformBlock = blockState.getBlock(); if (!FarmHelper.bricks.contains(platformBlock)) { break; @@ -114,7 +117,7 @@ public abstract class FarmLogicHomogeneous extends FarmLogic { produce.addAll(BlockUtil.getBlockDrops(world, position)); - setBlock(position, ItemStackUtil.getBlock(soilBlock), soilBlock.getItemDamage()); + setBlock(position, ItemStackUtil.getBlock(this.soilBlock), this.soilBlock.getItemDamage()); housing.getFarmInventory().removeResources(resources); return true; } diff --git a/src/main/java/forestry/farming/logic/FarmLogicInfernal.java b/src/main/java/forestry/farming/logic/FarmLogicInfernal.java index e4354b74c..4d4bcedc9 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicInfernal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicInfernal.java @@ -13,6 +13,7 @@ package forestry.farming.logic; import java.util.Collection; import java.util.Stack; +import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -30,8 +31,6 @@ import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; import forestry.core.utils.BlockUtil; -import forestry.core.utils.vect.Vect; -import forestry.core.utils.vect.VectUtil; public class FarmLogicInfernal extends FarmLogicHomogeneous { @@ -71,7 +70,7 @@ public class FarmLogicInfernal extends FarmLogicHomogeneous { Stack crops = new Stack<>(); for (int i = 0; i < extent; i++) { - Vect position = translateWithOffset(pos.add(0, 1, 0), direction, i); + BlockPos position = translateWithOffset(pos.add(0, 1, 0), direction, i); for (IFarmable farmable : germlings) { ICrop crop = farmable.getCropAt(world, position); if (crop != null) { @@ -89,14 +88,17 @@ public class FarmLogicInfernal extends FarmLogicHomogeneous { World world = getWorld(); for (int i = 0; i < extent; i++) { - Vect position = translateWithOffset(pos, direction, i); + BlockPos position = translateWithOffset(pos, direction, i); IBlockState blockState = world.getBlockState(position); - if (!VectUtil.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(blockState, world, position)) { + if (!world.isAirBlock(position) && !BlockUtil.isReplaceableBlock(blockState, world, position)) { continue; } - ItemStack below = VectUtil.getAsItemStack(world, position.down()); - if (!isAcceptedSoil(below)) { + BlockPos soilPosition = position.down(); + IBlockState soilState = world.getBlockState(soilPosition); + Block soilBlock = soilState.getBlock(); + ItemStack soilStack = soilBlock.getPickBlock(soilState, null, world, soilPosition, null); + if (!isAcceptedSoil(soilStack)) { continue; } @@ -106,7 +108,7 @@ public class FarmLogicInfernal extends FarmLogicHomogeneous { return false; } - private boolean trySetCrop(Vect position) { + private boolean trySetCrop(BlockPos position) { World world = getWorld(); for (IFarmable candidate : germlings) { diff --git a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java index 46c374b42..f8c186d6a 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java +++ b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java @@ -21,6 +21,7 @@ import java.util.Set; import java.util.Stack; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -37,13 +38,11 @@ import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; import forestry.api.genetics.IFruitBearer; import forestry.core.PluginCore; -import forestry.core.utils.vect.Vect; -import forestry.core.utils.vect.VectUtil; public class FarmLogicOrchard extends FarmLogic { private final Collection farmables; - private final HashMap lastExtents = new HashMap<>(); + private final HashMap lastExtents = new HashMap<>(); private final ImmutableList traversalBlocks; public FarmLogicOrchard(IFarmHousing housing) { @@ -110,20 +109,19 @@ public class FarmLogicOrchard extends FarmLogic { @Override public Collection harvest(BlockPos pos, FarmDirection direction, int extent) { - Vect start = new Vect(pos); - if (!lastExtents.containsKey(start)) { - lastExtents.put(start, 0); + if (!lastExtents.containsKey(pos)) { + lastExtents.put(pos, 0); } - int lastExtent = lastExtents.get(start); + int lastExtent = lastExtents.get(pos); if (lastExtent > extent) { lastExtent = 0; } - Vect position = translateWithOffset(pos.add(0, 1, 0), direction, lastExtent); + BlockPos position = translateWithOffset(pos.up(), direction, lastExtent); Collection crops = getHarvestBlocks(position); lastExtent++; - lastExtents.put(start, lastExtent); + lastExtents.put(pos, lastExtent); return crops; } @@ -139,22 +137,24 @@ public class FarmLogicOrchard extends FarmLogic { return "Orchard"; } - private Collection getHarvestBlocks(Vect position) { + private Collection getHarvestBlocks(BlockPos position) { - Set seen = new HashSet<>(); + Set seen = new HashSet<>(); Stack crops = new Stack<>(); World world = getWorld(); // Determine what type we want to harvest. - if (!VectUtil.isWoodBlock(world, position) && !isBlockTraversable(world, position, traversalBlocks) && !isFruitBearer(world, position)) { + IBlockState blockState = world.getBlockState(position); + Block block = blockState.getBlock(); + if (!block.isWood(world, position) && !isBlockTraversable(blockState, world, position, traversalBlocks) && !isFruitBearer(world, position)) { return crops; } - List candidates = processHarvestBlock(crops, seen, position, position); - List temp = new ArrayList<>(); + List candidates = processHarvestBlock(crops, seen, position, position); + List temp = new ArrayList<>(); while (!candidates.isEmpty() && crops.size() < 20) { - for (Vect candidate : candidates) { + for (BlockPos candidate : candidates) { temp.addAll(processHarvestBlock(crops, seen, position, candidate)); } candidates.clear(); @@ -165,16 +165,16 @@ public class FarmLogicOrchard extends FarmLogic { return crops; } - private List processHarvestBlock(Stack crops, Set seen, Vect start, Vect position) { + private List processHarvestBlock(Stack crops, Set seen, BlockPos start, BlockPos position) { World world = getWorld(); - List candidates = new ArrayList<>(); + List candidates = new ArrayList<>(); // Get additional candidates to return for (int i = -2; i < 3; i++) { for (int j = 0; j < 2; j++) { for (int k = -1; k < 2; k++) { - Vect candidate = position.add(i, j, k); + BlockPos candidate = position.add(i, j, k); if (Math.abs(candidate.getX() - start.getX()) > 5) { continue; } @@ -186,10 +186,13 @@ public class FarmLogicOrchard extends FarmLogic { if (seen.contains(candidate)) { continue; } - if (VectUtil.isAirBlock(world, candidate)) { + if (world.isAirBlock(candidate)) { continue; } - if (VectUtil.isWoodBlock(world, candidate) || isBlockTraversable(world, candidate, traversalBlocks)) { + + IBlockState blockState = world.getBlockState(candidate); + Block block = blockState.getBlock(); + if (block.isWood(world, candidate) || isBlockTraversable(blockState, world, candidate, traversalBlocks)) { candidates.add(candidate); seen.add(candidate); } else if (isFruitBearer(world, candidate)) { @@ -208,7 +211,7 @@ public class FarmLogicOrchard extends FarmLogic { return candidates; } - private boolean isFruitBearer(World world, Vect position) { + private boolean isFruitBearer(World world, BlockPos position) { TileEntity tile = world.getTileEntity(position); if (tile instanceof IFruitBearer) { @@ -224,9 +227,8 @@ public class FarmLogicOrchard extends FarmLogic { return false; } - private static boolean isBlockTraversable(World world, Vect position, ImmutableList traversalBlocks) { - - Block candidate = VectUtil.getBlock(world, position); + private static boolean isBlockTraversable(IBlockState blockState, World world, BlockPos position, ImmutableList traversalBlocks) { + Block candidate = blockState.getBlock(); for (Block block : traversalBlocks) { if (block == candidate) { return true; @@ -235,7 +237,7 @@ public class FarmLogicOrchard extends FarmLogic { return false; } - private ICrop getCrop(World world, Vect position) { + private ICrop getCrop(World world, BlockPos position) { TileEntity tile = world.getTileEntity(position); diff --git a/src/main/java/forestry/farming/logic/FarmLogicPeat.java b/src/main/java/forestry/farming/logic/FarmLogicPeat.java index dbbc819ad..ccbd88773 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicPeat.java +++ b/src/main/java/forestry/farming/logic/FarmLogicPeat.java @@ -14,6 +14,7 @@ import java.util.Collection; import java.util.Stack; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; @@ -27,8 +28,6 @@ import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.core.PluginCore; import forestry.core.blocks.BlockSoil; -import forestry.core.utils.vect.Vect; -import forestry.core.utils.vect.VectUtil; public class FarmLogicPeat extends FarmLogicWatered { private static final ItemStack bogEarth = PluginCore.blocks.soil.get(BlockSoil.SoilType.BOG_EARTH, 1); @@ -82,20 +81,14 @@ public class FarmLogicPeat extends FarmLogicWatered { Stack crops = new Stack<>(); for (int i = 0; i < extent; i++) { - Vect position = translateWithOffset(pos, direction, i); - ItemStack occupant = VectUtil.getAsItemStack(world, position); - - if (occupant.getItem() == null) { - continue; - } - - Block block = Block.getBlockFromItem(occupant.getItem()); + BlockPos position = translateWithOffset(pos, direction, i); + IBlockState blockState = world.getBlockState(position); + Block block = blockState.getBlock(); if (!(block instanceof BlockSoil)) { continue; } - BlockSoil blockSoil = (BlockSoil) block; - BlockSoil.SoilType soilType = BlockSoil.getTypeFromMeta(occupant.getItemDamage()); + BlockSoil.SoilType soilType = BlockSoil.getTypeFromState(blockState); if (soilType == BlockSoil.SoilType.PEAT) { crops.push(new CropPeat(world, position)); diff --git a/src/main/java/forestry/farming/logic/FarmLogicReeds.java b/src/main/java/forestry/farming/logic/FarmLogicReeds.java index 4acd36568..7ae52bc96 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicReeds.java +++ b/src/main/java/forestry/farming/logic/FarmLogicReeds.java @@ -29,7 +29,6 @@ import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; import forestry.core.utils.ItemStackUtil; -import forestry.core.utils.vect.Vect; public class FarmLogicReeds extends FarmLogic { @@ -105,7 +104,7 @@ public class FarmLogicReeds extends FarmLogic { Stack crops = new Stack<>(); for (int i = 0; i < extent; i++) { - Vect position = translateWithOffset(pos.add(0, 1, 0), direction, i); + BlockPos position = translateWithOffset(pos.add(0, 1, 0), direction, i); for (IFarmable seed : germlings) { ICrop crop = seed.getCropAt(world, position); if (crop != null) { diff --git a/src/main/java/forestry/farming/logic/FarmLogicRubber.java b/src/main/java/forestry/farming/logic/FarmLogicRubber.java index 7cbdab2eb..88a430dbe 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicRubber.java +++ b/src/main/java/forestry/farming/logic/FarmLogicRubber.java @@ -14,10 +14,13 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; +import java.util.List; +import java.util.Map; import java.util.Set; import java.util.Stack; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -32,8 +35,6 @@ import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.core.utils.ItemStackUtil; import forestry.core.utils.Log; -import forestry.core.utils.vect.Vect; -import forestry.core.utils.vect.VectUtil; import forestry.plugins.compat.PluginIC2; public class FarmLogicRubber extends FarmLogic { @@ -98,7 +99,7 @@ public class FarmLogicRubber extends FarmLogic { return false; } - private final HashMap lastExtents = new HashMap<>(); + private final Map lastExtents = new HashMap<>(); @Override public Collection harvest(BlockPos pos, FarmDirection direction, int extent) { @@ -106,46 +107,46 @@ public class FarmLogicRubber extends FarmLogic { return null; } - Vect start = new Vect(pos); - if (!lastExtents.containsKey(start)) { - lastExtents.put(start, 0); + if (!lastExtents.containsKey(pos)) { + lastExtents.put(pos, 0); } - int lastExtent = lastExtents.get(start); + int lastExtent = lastExtents.get(pos); if (lastExtent > extent) { lastExtent = 0; } - Vect position = translateWithOffset(pos.add(0, 1, 0), direction, lastExtent); + BlockPos position = translateWithOffset(pos.add(0, 1, 0), direction, lastExtent); Collection crops = getHarvestBlocks(position); lastExtent++; - lastExtents.put(start, lastExtent); + lastExtents.put(pos, lastExtent); return crops; } - private Collection getHarvestBlocks(Vect position) { + private Collection getHarvestBlocks(BlockPos position) { - Set seen = new HashSet<>(); + Set seen = new HashSet<>(); Stack crops = new Stack<>(); World world = getWorld(); // Determine what type we want to harvest. - Block block = VectUtil.getBlock(world, position); + IBlockState blockState = world.getBlockState(position); + Block block = blockState.getBlock(); if (!ItemStackUtil.equals(block, PluginIC2.rubberWood)) { return crops; } - int meta = VectUtil.getBlockMeta(world, position); + int meta = block.getMetaFromState(blockState); if (meta >= 2 && meta <= 5) { crops.push(new CropRubber(getWorld(), block, meta, position)); } - ArrayList candidates = processHarvestBlock(crops, seen, position); - ArrayList temp = new ArrayList<>(); + List candidates = processHarvestBlock(crops, seen, position); + List temp = new ArrayList<>(); while (!candidates.isEmpty() && crops.size() < 100) { - for (Vect candidate : candidates) { + for (BlockPos candidate : candidates) { temp.addAll(processHarvestBlock(crops, seen, candidate)); } candidates.clear(); @@ -156,14 +157,14 @@ public class FarmLogicRubber extends FarmLogic { return crops; } - private ArrayList processHarvestBlock(Stack crops, Set seen, Vect position) { + private List processHarvestBlock(Stack crops, Set seen, BlockPos position) { World world = getWorld(); - ArrayList candidates = new ArrayList<>(); + List candidates = new ArrayList<>(); // Get additional candidates to return for (int j = 0; j < 2; j++) { - Vect candidate = new Vect(position.getX(), position.getY() + j, position.getZ()); + BlockPos candidate = position.add(0, j, 0); if (candidate.equals(position)) { continue; } @@ -173,9 +174,10 @@ public class FarmLogicRubber extends FarmLogic { continue; } - Block block = VectUtil.getBlock(world, candidate); + IBlockState blockState = world.getBlockState(candidate); + Block block = blockState.getBlock(); if (ItemStackUtil.equals(block, PluginIC2.rubberWood)) { - int meta = VectUtil.getBlockMeta(world, candidate); + int meta = block.getMetaFromState(blockState); if (meta >= 2 && meta <= 5) { crops.push(new CropRubber(world, block, meta, candidate)); } diff --git a/src/main/java/forestry/farming/logic/FarmLogicSucculent.java b/src/main/java/forestry/farming/logic/FarmLogicSucculent.java index f24174aa9..d16a4dba0 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicSucculent.java +++ b/src/main/java/forestry/farming/logic/FarmLogicSucculent.java @@ -29,7 +29,6 @@ import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; import forestry.core.utils.ItemStackUtil; -import forestry.core.utils.vect.Vect; public class FarmLogicSucculent extends FarmLogic { @@ -111,7 +110,7 @@ public class FarmLogicSucculent extends FarmLogic { Stack crops = new Stack<>(); for (int i = 0; i < extent; i++) { - Vect position = translateWithOffset(pos.add(0, 1, 0), direction, i); + BlockPos position = translateWithOffset(pos.up(), direction, i); for (IFarmable seed : germlings) { ICrop crop = seed.getCropAt(world, position); if (crop != null) { diff --git a/src/main/java/forestry/farming/logic/FarmLogicWatered.java b/src/main/java/forestry/farming/logic/FarmLogicWatered.java index 961837894..8a0720ca8 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicWatered.java +++ b/src/main/java/forestry/farming/logic/FarmLogicWatered.java @@ -28,8 +28,6 @@ import forestry.api.farming.IFarmHousing; import forestry.core.fluids.Fluids; import forestry.core.utils.BlockUtil; import forestry.core.utils.ItemStackUtil; -import forestry.core.utils.vect.Vect; -import forestry.core.utils.vect.VectUtil; import forestry.farming.FarmHelper; public abstract class FarmLogicWatered extends FarmLogic { @@ -97,22 +95,23 @@ public abstract class FarmLogicWatered extends FarmLogic { ItemStack[] resources = new ItemStack[]{resource}; for (int i = 0; i < extent; i++) { - Vect position = translateWithOffset(pos, direction, i); + BlockPos position = translateWithOffset(pos, direction, i); IBlockState state = world.getBlockState(position); Block soil = state.getBlock(); - ItemStack soilStack = VectUtil.getAsItemStack(world, position); + ItemStack soilStack = soil.getPickBlock(state, null, world, position, null); if (isAcceptedGround(soilStack) || !housing.getFarmInventory().hasResources(resources)) { continue; } BlockPos platformPosition = position.down(); - Block platformBlock = VectUtil.getBlock(world, platformPosition); + IBlockState blockState = world.getBlockState(platformPosition); + Block platformBlock = blockState.getBlock(); if (!FarmHelper.bricks.contains(platformBlock)) { break; } - if (!isAirBlock(soil, state, world, platformPosition) && !BlockUtil.isReplaceableBlock(state, world, platformPosition)) { + if (!soil.isAir(state, world, platformPosition) && !BlockUtil.isReplaceableBlock(state, world, platformPosition)) { produce.addAll(BlockUtil.getBlockDrops(getWorld(), position)); world.setBlockToAir(position); return trySetSoil(position); @@ -136,10 +135,11 @@ public abstract class FarmLogicWatered extends FarmLogic { // Still not done, check water then World world = getWorld(); for (int i = 0; i < extent; i++) { - Vect position = translateWithOffset(pos, direction, i); + BlockPos position = translateWithOffset(pos, direction, i); BlockPos platformPosition = position.down(); - Block platformBlock = VectUtil.getBlock(world, platformPosition); + IBlockState blockState = world.getBlockState(platformPosition); + Block platformBlock = blockState.getBlock(); if (!FarmHelper.bricks.contains(platformBlock)) { break; } @@ -156,7 +156,7 @@ public abstract class FarmLogicWatered extends FarmLogic { return false; } - private boolean trySetSoil(Vect position) { + private boolean trySetSoil(BlockPos position) { ItemStack[] resources = new ItemStack[]{resource}; if (!housing.getFarmInventory().hasResources(resources)) { return false; @@ -166,7 +166,7 @@ public abstract class FarmLogicWatered extends FarmLogic { return true; } - private boolean trySetWater(World world, Vect position) { + private boolean trySetWater(World world, BlockPos position) { if (isWaterSourceBlock(world, position) || !canPlaceWater(world, position)) { return false; } @@ -181,11 +181,11 @@ public abstract class FarmLogicWatered extends FarmLogic { return true; } - private boolean canPlaceWater(World world, Vect position) { + private boolean canPlaceWater(World world, BlockPos position) { // 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(x, 0, z); + BlockPos offsetPosition = position.add(x, 0, z); if (isWaterSourceBlock(world, offsetPosition)) { return false; } @@ -194,14 +194,14 @@ 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(x, 0, 0); - if (VectUtil.isAirBlock(world, offsetPosition)) { + BlockPos offsetPosition = position.add(x, 0, 0); + if (world.isAirBlock(offsetPosition)) { return false; } } for (int z = -1; z <= 1; z++) { - Vect offsetPosition = position.add(0, 0, z); - if (VectUtil.isAirBlock(world, offsetPosition)) { + BlockPos offsetPosition = position.add(0, 0, z); + if (world.isAirBlock(offsetPosition)) { return false; } } diff --git a/src/main/java/forestry/farming/logic/FarmableBasicAgricraft.java b/src/main/java/forestry/farming/logic/FarmableBasicAgricraft.java index c0c95a4ee..ab7261c34 100644 --- a/src/main/java/forestry/farming/logic/FarmableBasicAgricraft.java +++ b/src/main/java/forestry/farming/logic/FarmableBasicAgricraft.java @@ -11,6 +11,7 @@ package forestry.farming.logic; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; @@ -19,9 +20,7 @@ import net.minecraft.world.World; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; import forestry.core.config.Constants; -import forestry.core.utils.BlockUtil; import forestry.core.utils.ItemStackUtil; -import forestry.core.utils.vect.Vect; public class FarmableBasicAgricraft implements IFarmable { @@ -35,18 +34,22 @@ public class FarmableBasicAgricraft implements IFarmable { @Override public boolean isSaplingAt(World world, BlockPos pos) { - return BlockUtil.getBlock(world, pos) == block; + return world.getBlockState(pos).getBlock() == this.block; } @Override public ICrop getCropAt(World world, BlockPos pos) { - if (BlockUtil.getBlock(world, pos) != block) { + IBlockState blockState = world.getBlockState(pos); + Block block = blockState.getBlock(); + if (block != this.block) { return null; } - if (BlockUtil.getBlockMetadata(world, pos) != matureMeta) { + + int blockMetadata = block.getMetaFromState(blockState); + if (blockMetadata != matureMeta) { return null; } - return new CropBasicAgriCraft(world, block, matureMeta, new Vect(pos)); + return new CropBasicAgriCraft(world, this.block, matureMeta, pos); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmableBasicFruit.java b/src/main/java/forestry/farming/logic/FarmableBasicFruit.java index e8fcdb7b9..d539aa9ef 100644 --- a/src/main/java/forestry/farming/logic/FarmableBasicFruit.java +++ b/src/main/java/forestry/farming/logic/FarmableBasicFruit.java @@ -11,6 +11,7 @@ package forestry.farming.logic; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; @@ -19,9 +20,7 @@ import net.minecraft.world.World; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; import forestry.core.config.Constants; -import forestry.core.utils.BlockUtil; import forestry.core.utils.ItemStackUtil; -import forestry.core.utils.vect.Vect; public class FarmableBasicFruit implements IFarmable { @@ -35,18 +34,20 @@ public class FarmableBasicFruit implements IFarmable { @Override public boolean isSaplingAt(World world, BlockPos pos) { - return BlockUtil.getBlock(world, pos) == block; + return world.getBlockState(pos).getBlock() == block; } @Override public ICrop getCropAt(World world, BlockPos pos) { - if (BlockUtil.getBlock(world, pos) != block) { + IBlockState blockState = world.getBlockState(pos); + Block block = blockState.getBlock(); + if (block != this.block) { return null; } - if (BlockUtil.getBlockMetadata(world, pos) != matureMeta) { + if (block.getMetaFromState(blockState) != matureMeta) { return null; } - return new CropBasicFruit(world, block, matureMeta, new Vect(pos)); + return new CropBasicFruit(world, this.block, matureMeta, pos); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmableBasicGrowthCraft.java b/src/main/java/forestry/farming/logic/FarmableBasicGrowthCraft.java index 4244c0dff..5e05d5cf2 100644 --- a/src/main/java/forestry/farming/logic/FarmableBasicGrowthCraft.java +++ b/src/main/java/forestry/farming/logic/FarmableBasicGrowthCraft.java @@ -11,6 +11,7 @@ package forestry.farming.logic; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; @@ -19,9 +20,7 @@ import net.minecraft.world.World; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; import forestry.core.config.Constants; -import forestry.core.utils.BlockUtil; import forestry.core.utils.ItemStackUtil; -import forestry.core.utils.vect.Vect; public class FarmableBasicGrowthCraft implements IFarmable { @@ -39,18 +38,20 @@ public class FarmableBasicGrowthCraft implements IFarmable { @Override public boolean isSaplingAt(World world, BlockPos pos) { - return BlockUtil.getBlock(world, pos) == block; + return world.getBlockState(pos).getBlock() == block; } @Override public ICrop getCropAt(World world, BlockPos pos) { - if (BlockUtil.getBlock(world, pos) != block) { + IBlockState blockState = world.getBlockState(pos); + Block block = blockState.getBlock(); + if (block != this.block) { return null; } - if (BlockUtil.getBlockMetadata(world, pos) != matureMeta) { + if (block.getMetaFromState(blockState) != matureMeta) { return null; } - return new CropBasicGrowthCraft(world, block, matureMeta, new Vect(pos), isRice, isGrape); + return new CropBasicGrowthCraft(world, this.block, matureMeta, pos, isRice, isGrape); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmableCocoa.java b/src/main/java/forestry/farming/logic/FarmableCocoa.java index f4e355651..928adf8a7 100755 --- a/src/main/java/forestry/farming/logic/FarmableCocoa.java +++ b/src/main/java/forestry/farming/logic/FarmableCocoa.java @@ -12,6 +12,7 @@ package forestry.farming.logic; import net.minecraft.block.Block; import net.minecraft.block.BlockCocoa; +import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -23,7 +24,6 @@ import net.minecraft.world.World; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; import forestry.core.utils.BlockUtil; -import forestry.core.utils.vect.Vect; public class FarmableCocoa implements IFarmable { @@ -33,21 +33,22 @@ public class FarmableCocoa implements IFarmable { @Override public boolean isSaplingAt(World world, BlockPos pos) { - return BlockUtil.getBlock(world, pos) == COCOA_PLANT; + return world.getBlockState(pos).getBlock() == COCOA_PLANT; } @Override public ICrop getCropAt(World world, BlockPos pos) { - Block block = BlockUtil.getBlock(world, pos); + IBlockState blockState = world.getBlockState(pos); + Block block = blockState.getBlock(); if (block != COCOA_PLANT) { return null; } - int meta = BlockUtil.getBlockMetadata(world, pos); - if (BlockUtil.getBlockState(world, pos).getValue(BlockCocoa.AGE) < 2) { + int meta = block.getMetaFromState(blockState); + if (blockState.getValue(BlockCocoa.AGE) < 2) { return null; } - return new CropBlock(world, block, meta, new Vect(pos)); + return new CropBlock(world, block, meta, pos); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmableGE.java b/src/main/java/forestry/farming/logic/FarmableGE.java index 277bcd762..148491620 100755 --- a/src/main/java/forestry/farming/logic/FarmableGE.java +++ b/src/main/java/forestry/farming/logic/FarmableGE.java @@ -11,12 +11,13 @@ package forestry.farming.logic; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.EnumFacing; import net.minecraft.world.World; import forestry.api.arboriculture.IAlleleTreeSpecies; @@ -24,8 +25,6 @@ import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; import forestry.arboriculture.PluginArboriculture; import forestry.arboriculture.genetics.TreeGenome; -import forestry.core.utils.BlockUtil; -import forestry.core.utils.vect.Vect; public class FarmableGE implements IFarmable { @@ -36,19 +35,20 @@ public class FarmableGE implements IFarmable { return false; } - Block block = BlockUtil.getBlock(world, pos); + Block block = world.getBlockState(pos).getBlock(); return PluginArboriculture.blocks.saplingGE == block; } @Override public ICrop getCropAt(World world, BlockPos pos) { - Block block = BlockUtil.getBlock(world, pos); + IBlockState blockState = world.getBlockState(pos); + Block block = blockState.getBlock(); if (!block.isWood(world, pos)) { return null; } - return new CropBlock(world, block, BlockUtil.getBlockMetadata(world, pos), new Vect(pos)); + return new CropBlock(world, block, block.getMetaFromState(blockState), pos); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmableGenericCrop.java b/src/main/java/forestry/farming/logic/FarmableGenericCrop.java index 0d3f6f649..27b19c147 100755 --- a/src/main/java/forestry/farming/logic/FarmableGenericCrop.java +++ b/src/main/java/forestry/farming/logic/FarmableGenericCrop.java @@ -11,18 +11,17 @@ package forestry.farming.logic; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.EnumFacing; import net.minecraft.world.World; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; -import forestry.core.utils.BlockUtil; -import forestry.core.utils.vect.Vect; public class FarmableGenericCrop implements IFarmable { @@ -40,19 +39,21 @@ public class FarmableGenericCrop implements IFarmable { @Override public boolean isSaplingAt(World world, BlockPos pos) { - return BlockUtil.getBlock(world, pos) == block; + return world.getBlockState(pos).getBlock() == block; } @Override public ICrop getCropAt(World world, BlockPos pos) { - if (BlockUtil.getBlock(world, pos) != block) { + IBlockState blockState = world.getBlockState(pos); + Block block = blockState.getBlock(); + if (block != this.block) { return null; } - if (BlockUtil.getBlockMetadata(world, pos) != mature) { + if (block.getMetaFromState(blockState) != mature) { return null; } - return new CropBlock(world, block, mature, new Vect(pos)); + return new CropBlock(world, this.block, mature, pos); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmableGenericSapling.java b/src/main/java/forestry/farming/logic/FarmableGenericSapling.java index 6d7bf7b05..062b0af02 100755 --- a/src/main/java/forestry/farming/logic/FarmableGenericSapling.java +++ b/src/main/java/forestry/farming/logic/FarmableGenericSapling.java @@ -11,19 +11,18 @@ package forestry.farming.logic; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.EnumFacing; import net.minecraft.world.World; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; -import forestry.core.utils.BlockUtil; import forestry.core.utils.ItemStackUtil; -import forestry.core.utils.vect.Vect; public class FarmableGenericSapling implements IFarmable { @@ -44,12 +43,14 @@ public class FarmableGenericSapling implements IFarmable { return false; } - if (BlockUtil.getBlock(world, pos) == sapling) { + IBlockState blockState = world.getBlockState(pos); + Block block = blockState.getBlock(); + if (block == sapling) { return true; } if (saplingMeta >= 0) { - return BlockUtil.getBlockMetadata(world, pos) == saplingMeta; + return block.getMetaFromState(blockState) == saplingMeta; } else { return true; } @@ -58,12 +59,13 @@ public class FarmableGenericSapling implements IFarmable { @Override public ICrop getCropAt(World world, BlockPos pos) { - Block block = BlockUtil.getBlock(world, pos); + IBlockState blockState = world.getBlockState(pos); + Block block = blockState.getBlock(); if (!block.isWood(world, pos)) { return null; } - return new CropBlock(world, block, BlockUtil.getBlockMetadata(world, pos), new Vect(pos)); + return new CropBlock(world, block, block.getMetaFromState(blockState), pos); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmableGourd.java b/src/main/java/forestry/farming/logic/FarmableGourd.java index 6b4e38463..176e42bcb 100755 --- a/src/main/java/forestry/farming/logic/FarmableGourd.java +++ b/src/main/java/forestry/farming/logic/FarmableGourd.java @@ -10,6 +10,8 @@ ******************************************************************************/ package forestry.farming.logic; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; @@ -18,9 +20,7 @@ import net.minecraft.world.World; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; import forestry.core.config.Constants; -import forestry.core.utils.BlockUtil; import forestry.core.utils.ItemStackUtil; -import forestry.core.utils.vect.Vect; public class FarmableGourd implements IFarmable { @@ -40,7 +40,7 @@ public class FarmableGourd implements IFarmable { return false; } - return ItemStackUtil.equals(BlockUtil.getBlock(world, pos), stem); + return ItemStackUtil.equals(world.getBlockState(pos).getBlock(), stem); } @Override @@ -49,15 +49,17 @@ public class FarmableGourd implements IFarmable { return null; } - if (!ItemStackUtil.equals(BlockUtil.getBlock(world, pos), fruit)) { + IBlockState blockState = world.getBlockState(pos); + Block block = blockState.getBlock(); + if (!ItemStackUtil.equals(block, fruit)) { return null; } - if (BlockUtil.getBlockMetadata(world, pos) != fruit.getItemDamage()) { + if (block.getMetaFromState(blockState) != fruit.getItemDamage()) { return null; } - return new CropBlock(world, ItemStackUtil.getBlock(fruit), fruit.getItemDamage(), new Vect(pos)); + return new CropBlock(world, ItemStackUtil.getBlock(fruit), fruit.getItemDamage(), pos); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmableStacked.java b/src/main/java/forestry/farming/logic/FarmableStacked.java index 9d6c8e276..a5e2fc122 100755 --- a/src/main/java/forestry/farming/logic/FarmableStacked.java +++ b/src/main/java/forestry/farming/logic/FarmableStacked.java @@ -19,9 +19,7 @@ import net.minecraft.world.World; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; import forestry.core.config.Constants; -import forestry.core.utils.BlockUtil; import forestry.core.utils.ItemStackUtil; -import forestry.core.utils.vect.Vect; public class FarmableStacked implements IFarmable { @@ -37,15 +35,16 @@ public class FarmableStacked implements IFarmable { @Override public boolean isSaplingAt(World world, BlockPos pos) { - return BlockUtil.getBlock(world, pos) == block; + return world.getBlockState(pos).getBlock() == block; } @Override public ICrop getCropAt(World world, BlockPos pos) { - if (BlockUtil.getBlock(world, new BlockPos(pos.getX(), pos.getY() + matureHeight - 1, pos.getZ())) != block) { + BlockPos cropPos = new BlockPos(pos.getX(), pos.getY() + matureHeight - 1, pos.getZ()); + if (world.getBlockState(cropPos).getBlock() != block) { return null; } - return new CropBlock(world, block, matureMeta, new Vect(pos.getX(), pos.getY() + matureHeight - 1, pos.getZ())); + return new CropBlock(world, block, matureMeta, cropPos); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmableVanillaMushroom.java b/src/main/java/forestry/farming/logic/FarmableVanillaMushroom.java index 139a01ffe..c270da9b9 100644 --- a/src/main/java/forestry/farming/logic/FarmableVanillaMushroom.java +++ b/src/main/java/forestry/farming/logic/FarmableVanillaMushroom.java @@ -11,6 +11,7 @@ package forestry.farming.logic; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; @@ -20,9 +21,7 @@ import net.minecraft.world.World; import forestry.api.farming.ICrop; import forestry.core.config.Constants; import forestry.core.proxy.Proxies; -import forestry.core.utils.BlockUtil; import forestry.core.utils.ItemStackUtil; -import forestry.core.utils.vect.Vect; import forestry.farming.PluginFarming; public class FarmableVanillaMushroom extends FarmableGenericSapling { @@ -33,13 +32,14 @@ public class FarmableVanillaMushroom extends FarmableGenericSapling { @Override public ICrop getCropAt(World world, BlockPos pos) { - Block block = BlockUtil.getBlock(world, pos); + IBlockState blockState = world.getBlockState(pos); + Block block = blockState.getBlock(); if (block != Blocks.BROWN_MUSHROOM_BLOCK && block != Blocks.RED_MUSHROOM_BLOCK) { return null; } - return new CropBlock(world, block, BlockUtil.getBlockMetadata(world, pos), new Vect(pos)); + return new CropBlock(world, block, block.getMetaFromState(blockState), pos); } @Override diff --git a/src/main/java/forestry/farming/multiblock/FakeFarmController.java b/src/main/java/forestry/farming/multiblock/FakeFarmController.java index c3803180d..e0327603e 100644 --- a/src/main/java/forestry/farming/multiblock/FakeFarmController.java +++ b/src/main/java/forestry/farming/multiblock/FakeFarmController.java @@ -13,6 +13,7 @@ package forestry.farming.multiblock; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3i; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidStack; @@ -30,8 +31,6 @@ import forestry.core.inventory.IInventoryAdapter; import forestry.core.multiblock.FakeMultiblockController; import forestry.farming.gui.IFarmLedgerDelegate; -import io.netty.util.internal.EmptyArrays; - public class FakeFarmController extends FakeMultiblockController implements IFarmControllerInternal { public static final FakeFarmController instance = new FakeFarmController(); @@ -40,18 +39,18 @@ public class FakeFarmController extends FakeMultiblockController implements IFar } @Override - public int[] getCoords() { - return EmptyArrays.EMPTY_INTS; + public BlockPos getCoords() { + return BlockPos.ORIGIN; } @Override - public int[] getArea() { - return EmptyArrays.EMPTY_INTS; + public Vec3i getArea() { + return Vec3i.NULL_VECTOR; } @Override - public int[] getOffset() { - return EmptyArrays.EMPTY_INTS; + public Vec3i getOffset() { + return Vec3i.NULL_VECTOR; } @Override diff --git a/src/main/java/forestry/farming/multiblock/FarmController.java b/src/main/java/forestry/farming/multiblock/FarmController.java index 040e15c03..6b127ec19 100644 --- a/src/main/java/forestry/farming/multiblock/FarmController.java +++ b/src/main/java/forestry/farming/multiblock/FarmController.java @@ -24,11 +24,13 @@ import java.util.Set; import java.util.Stack; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3i; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; @@ -70,8 +72,6 @@ import forestry.core.network.DataOutputStreamForestry; import forestry.core.tiles.ILiquidTankTile; import forestry.core.utils.PlayerUtil; import forestry.core.utils.Translator; -import forestry.core.utils.vect.Vect; -import forestry.core.utils.vect.VectUtil; import forestry.farming.FarmHelper; import forestry.farming.FarmTarget; import forestry.farming.gui.IFarmLedgerDelegate; @@ -166,6 +166,7 @@ public class FarmController extends RectangularMultiblockControllerBase implemen } } + @Nonnull @Override public TankManager getTankManager() { return tankManager; @@ -409,31 +410,27 @@ public class FarmController extends RectangularMultiblockControllerBase implemen return ForestryAPI.climateManager.getHumidity(getWorld(), coords); } - private int[] coords; - private int[] offset; - private int[] area; + private Vec3i offset; + private Vec3i area; @Override - public int[] getCoords() { - if (coords == null) { - BlockPos centerCoord = getCenterCoord(); - coords = new int[]{centerCoord.getX(), centerCoord.getY(), centerCoord.getZ()}; - } - return coords; + public BlockPos getCoords() { + return getCenterCoord(); } @Override - public int[] getOffset() { + public Vec3i getOffset() { if (offset == null) { - offset = new int[]{-getArea()[0] / 2, -2, -getArea()[2] / 2}; + Vec3i area = getArea(); + offset = new Vec3i(-area.getX() / 2, -2, -area.getZ() / 2); } return offset; } @Override - public int[] getArea() { + public Vec3i getArea() { if (area == null) { - area = new int[]{7 + allowedExtent * 2, 13, 7 + allowedExtent * 2}; + area = new Vec3i(7 + allowedExtent * 2, 13, 7 + allowedExtent * 2); } return area; } @@ -529,7 +526,7 @@ public class FarmController extends RectangularMultiblockControllerBase implemen } private void setUpFarmlandTargets() { - Vect targetStart = new Vect(getCoords()); + BlockPos targetStart = getCoords(); BlockPos max = getMaximumCoord(); BlockPos min = getMinimumCoord(); @@ -544,7 +541,7 @@ public class FarmController extends RectangularMultiblockControllerBase implemen setExtents(worldObj, targets); } - private static void createTargets(World world, Map> targets, Vect targetStart, final int allowedExtent, final int farmSizeNorthSouth, final int farmSizeEastWest) { + private static void createTargets(World world, Map> targets, BlockPos targetStart, final int allowedExtent, final int farmSizeNorthSouth, final int farmSizeEastWest) { for (FarmDirection farmSide : FarmDirection.values()) { @@ -560,9 +557,9 @@ public class FarmController extends RectangularMultiblockControllerBase implemen FarmDirection layoutDirection = getLayoutDirection(farmSide); - Vect targetLocation = FarmHelper.getFarmMultiblockCorner(world, targetStart, farmSide, layoutDirection); - Vect firstLocation = targetLocation.add(farmSide); - Vect firstGroundPosition = getGroundPosition(world, firstLocation); + BlockPos targetLocation = FarmHelper.getFarmMultiblockCorner(world, targetStart, farmSide, layoutDirection); + BlockPos firstLocation = targetLocation.offset(farmSide.getFacing()); + BlockPos firstGroundPosition = getGroundPosition(world, firstLocation); if (firstGroundPosition == null) { continue; } @@ -570,15 +567,16 @@ public class FarmController extends RectangularMultiblockControllerBase implemen List farmSideTargets = new ArrayList<>(); for (int i = 0; i < allowedExtent; i++) { - targetLocation = targetLocation.add(farmSide); - Vect groundLocation = new Vect(targetLocation.getX(), groundHeight, targetLocation.getZ()); + targetLocation = targetLocation.offset(farmSide.getFacing()); + BlockPos groundLocation = new BlockPos(targetLocation.getX(), groundHeight, targetLocation.getZ()); int targetLimit = targetMaxLimit; if (!Config.squareFarms) { targetLimit = targetMaxLimit - i - 1; } - Block platform = VectUtil.getBlock(world, groundLocation); + IBlockState blockState = world.getBlockState(groundLocation); + Block platform = blockState.getBlock(); if (!FarmHelper.bricks.contains(platform)) { break; } @@ -591,10 +589,11 @@ public class FarmController extends RectangularMultiblockControllerBase implemen } } - private static Vect getGroundPosition(World world, Vect targetPosition) { + private static BlockPos getGroundPosition(World world, BlockPos targetPosition) { for (int yOffset = 2; yOffset > -4; yOffset--) { - Vect position = targetPosition.add(0, yOffset, 0); - Block ground = VectUtil.getBlock(world, position); + BlockPos position = targetPosition.add(0, yOffset, 0); + IBlockState blockState = world.getBlockState(position); + Block ground = blockState.getBlock(); if (FarmHelper.bricks.contains(ground)) { return position; } @@ -614,7 +613,7 @@ public class FarmController extends RectangularMultiblockControllerBase implemen private static void setExtents(World worldObj, Map> targets) { for (List targetsList : targets.values()) { if (!targetsList.isEmpty()) { - Vect groundPosition = getGroundPosition(worldObj, targetsList.get(0).getStart()); + BlockPos groundPosition = getGroundPosition(worldObj, targetsList.get(0).getStart()); for (FarmTarget target : targetsList) { target.setExtentAndYOffset(worldObj, groundPosition); @@ -671,7 +670,7 @@ public class FarmController extends RectangularMultiblockControllerBase implemen } private static boolean cultivateTarget(FarmTarget target, IFarmLogic logic, Iterable farmListeners) { - Vect targetPosition = target.getStart().add(0, target.getYOffset(), 0); + BlockPos targetPosition = target.getStart().add(0, target.getYOffset(), 0); if (logic.cultivate(targetPosition, target.getDirection(), target.getExtent())) { for (IFarmListener listener : farmListeners) { listener.hasCultivated(logic, targetPosition, target.getDirection(), target.getExtent()); diff --git a/src/main/java/forestry/farming/multiblock/IFarmControllerInternal.java b/src/main/java/forestry/farming/multiblock/IFarmControllerInternal.java index b5eea9497..36d6e2abc 100644 --- a/src/main/java/forestry/farming/multiblock/IFarmControllerInternal.java +++ b/src/main/java/forestry/farming/multiblock/IFarmControllerInternal.java @@ -10,6 +10,8 @@ ******************************************************************************/ package forestry.farming.multiblock; +import javax.annotation.Nonnull; + import forestry.api.multiblock.IFarmController; import forestry.core.access.IRestrictedAccess; import forestry.core.circuits.ISocketable; @@ -25,5 +27,6 @@ public interface IFarmControllerInternal extends IFarmController, IMultiblockCon IInventoryAdapter getInternalInventory(); + @Nonnull ITankManager getTankManager(); } diff --git a/src/main/java/forestry/farming/tiles/TileFarmControl.java b/src/main/java/forestry/farming/tiles/TileFarmControl.java index 611ea7549..56bfca889 100644 --- a/src/main/java/forestry/farming/tiles/TileFarmControl.java +++ b/src/main/java/forestry/farming/tiles/TileFarmControl.java @@ -11,6 +11,7 @@ package forestry.farming.tiles; import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import forestry.api.farming.DefaultFarmListener; @@ -18,7 +19,6 @@ import forestry.api.farming.FarmDirection; import forestry.api.farming.IFarmListener; import forestry.api.farming.IFarmLogic; import forestry.api.multiblock.IFarmComponent; -import forestry.core.utils.vect.Vect; public class TileFarmControl extends TileFarm implements IFarmComponent.Listener { @@ -42,11 +42,11 @@ public class TileFarmControl extends TileFarm implements IFarmComponent.Listener @Override public boolean cancelTask(IFarmLogic logic, FarmDirection direction) { - return hasRedstoneSignal(direction.getForgeDirection()) || hasRedstoneSignal(EnumFacing.UP) || hasRedstoneSignal(EnumFacing.DOWN); + return hasRedstoneSignal(direction.getFacing()) || hasRedstoneSignal(EnumFacing.UP) || hasRedstoneSignal(EnumFacing.DOWN); } private boolean hasRedstoneSignal(EnumFacing direction) { - Vect side = new Vect(tile).add(direction); + BlockPos side = tile.getPos().offset(direction); EnumFacing dir = direction.getOpposite(); World world = tile.getWorld(); diff --git a/src/main/java/forestry/greenhouse/tiles/TileGreenhouseControl.java b/src/main/java/forestry/greenhouse/tiles/TileGreenhouseControl.java index 1b87d2ddb..6895f301a 100644 --- a/src/main/java/forestry/greenhouse/tiles/TileGreenhouseControl.java +++ b/src/main/java/forestry/greenhouse/tiles/TileGreenhouseControl.java @@ -11,6 +11,7 @@ package forestry.greenhouse.tiles; import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import forestry.api.greenhouse.DefaultGreenhouseListener; @@ -18,7 +19,6 @@ import forestry.api.greenhouse.IGreenhouseHousing; import forestry.api.greenhouse.IGreenhouseListener; import forestry.api.multiblock.IGreenhouseComponent; import forestry.api.multiblock.IGreenhouseController; -import forestry.core.utils.vect.Vect; public class TileGreenhouseControl extends TileGreenhouse implements IGreenhouseComponent.Listener { @@ -47,7 +47,7 @@ public class TileGreenhouseControl extends TileGreenhouse implements IGreenhouse private boolean hasRedstoneSignal() { for (EnumFacing direction : EnumFacing.VALUES) { - Vect side = new Vect(tile).add(direction); + BlockPos side = tile.getPos().offset(direction); EnumFacing dir = direction.getOpposite(); World world = tile.getWorld(); if (world.getRedstonePower(side, dir) > 0 || world.getStrongPower(side, dir) > 0) { diff --git a/src/main/java/forestry/lepidopterology/genetics/ButterflyRoot.java b/src/main/java/forestry/lepidopterology/genetics/ButterflyRoot.java index 99cda8b9b..ab1cbac8b 100644 --- a/src/main/java/forestry/lepidopterology/genetics/ButterflyRoot.java +++ b/src/main/java/forestry/lepidopterology/genetics/ButterflyRoot.java @@ -17,7 +17,6 @@ import java.util.Collections; import java.util.Map.Entry; import net.minecraft.block.Block; -import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -186,7 +185,7 @@ public class ButterflyRoot extends SpeciesRoot implements IButterflyRoot { return false; } - Block block = BlockUtil.getBlock(world, pos); + Block block = world.getBlockState(pos).getBlock(); if (PluginLepidopterology.blocks.cocoon != block) { return false; }