Merge pull request #1531 from hilburn/master

Mushroom Farming and fixed some typos
This commit is contained in:
tterrag1098 committed 2014-12-30 12:37:30 -05:00
commit 619348cb71
12 files changed
+57 -30

No files matched your search

@@ -78,7 +78,7 @@ public abstract class AbstractPoweredTaskEntity extends AbstractPowerConsumerEnt
if(lastCompletedRecipe == null) {
return 0;
}
return lastCompletedRecipe.getExperianceForOutput(output);
return lastCompletedRecipe.getExperienceForOutput(output);
}
public boolean getRedstoneChecksPassed() {
@@ -67,7 +67,7 @@ public interface IMachineRecipe {
* @param output
* @return
*/
float getExperianceForOutput(ItemStack output);
float getExperienceForOutput(ItemStack output);
/**
* Should return true if the specified parameter is can be used in this
@@ -113,7 +113,7 @@ public class VanillaSmeltingRecipe implements IMachineRecipe {
}
@Override
public float getExperianceForOutput(ItemStack output) {
public float getExperienceForOutput(ItemStack output) {
if(output == null) {
return 0;
}
@@ -27,6 +27,8 @@ public final class FarmersRegistry {
FarmersCommune.joinCommune(new StemFarmer(Blocks.cactus, new ItemStack(Blocks.cactus)));
FarmersCommune.joinCommune(new TreeFarmer(Blocks.sapling, Blocks.log));
FarmersCommune.joinCommune(new TreeFarmer(Blocks.sapling, Blocks.log2));
FarmersCommune.joinCommune(new TreeFarmer(true,Blocks.red_mushroom, Blocks.red_mushroom_block));
FarmersCommune.joinCommune(new TreeFarmer(true,Blocks.brown_mushroom, Blocks.brown_mushroom_block));
//special case of plantables to get spacing correct
FarmersCommune.joinCommune(new MelonFarmer(Blocks.melon_stem, Blocks.melon_block, new ItemStack(Items.melon_seeds)));
FarmersCommune.joinCommune(new MelonFarmer(Blocks.pumpkin_stem, Blocks.pumpkin, new ItemStack(Items.pumpkin_seeds)));
@@ -26,6 +26,7 @@ public class TreeFarmer implements IFarmerJoe {
protected Block[] woods;
protected TreeHarvestUtil harvester = new TreeHarvestUtil();
private boolean ignoreMeta;
public TreeFarmer(Block sapling, Block... wood) {
this.sapling = sapling;
@@ -35,11 +36,16 @@ public class TreeFarmer implements IFarmerJoe {
woods = wood;
}
public TreeFarmer(boolean ignoreMeta, Block sapling, Block... wood) {
this(sapling,wood);
this.ignoreMeta = ignoreMeta;
}
@Override
public boolean canHarvest(TileFarmStation farm, BlockCoord bc, Block block, int meta) {
return isWood(block);
}
protected boolean isWood(Block block) {
for(Block wood : woods) {
if(block == wood) {
@@ -144,6 +150,11 @@ public class TreeFarmer implements IFarmerJoe {
return res;
}
public boolean getIgnoreMeta()
{
return ignoreMeta;
}
private static class HeightComparator implements Comparator<BlockCoord> {
@Override
@@ -155,7 +166,6 @@ public class TreeFarmer implements IFarmerJoe {
public static int compare(int x, int y) {
return (x < y) ? -1 : ((x == y) ? 0 : 1);
}
}
}
@@ -1,9 +1,6 @@
package crazypants.enderio.machine.farm.farmers;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLeaves;
import net.minecraft.block.BlockNewLeaf;
import net.minecraft.block.BlockOldLeaf;
import net.minecraft.block.*;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import crazypants.enderio.machine.farm.TileFarmStation;
@@ -27,7 +24,7 @@ public class TreeHarvestUtil {
public void harvest(TileFarmStation farm, TreeFarmer farmer, BlockCoord bc, HarvestResult res) {
horizontalRange = farm.getFarmSize() + 7;
verticalRange = 30;
harvest(farm.getWorldObj(), farm.getLocation(), bc, res);
harvest(farm.getWorldObj(), farm.getLocation(), bc, res, farmer.getIgnoreMeta());
}
public void harvest(World world, BlockCoord bc, HarvestResult res) {
@@ -39,14 +36,21 @@ public class TreeHarvestUtil {
harvestUp(world, bc, res, new HarvestTarget(wood, woodMeta));
}
private void harvest(World world, BlockCoord origin, BlockCoord bc, HarvestResult res) {
private void harvest(World world, BlockCoord origin, BlockCoord bc, HarvestResult res, boolean ignoreMeta) {
this.origin = new BlockCoord(origin);
Block wood = world.getBlock(bc.x, bc.y, bc.z);
int woodMeta = world.getBlockMetadata(bc.x, bc.y, bc.z);
harvestUp(world, bc, res, new HarvestTarget(wood, woodMeta));
if (ignoreMeta)
{
harvestUp(world, bc, res, new BaseHarvestTarget(wood));
}
else
{
harvestUp(world, bc, res, new HarvestTarget(wood, woodMeta));
}
}
protected void harvestUp(World world, BlockCoord bc, HarvestResult res, HarvestTarget target) {
protected void harvestUp(World world, BlockCoord bc, HarvestResult res, BaseHarvestTarget target) {
if(!isInHarvestBounds(bc) || res.harvestedBlocks.contains(bc)) {
return;
@@ -78,7 +82,7 @@ public class TreeHarvestUtil {
}
private void harvestAdjacentWood(World world, BlockCoord bc, HarvestResult res, HarvestTarget target) {
private void harvestAdjacentWood(World world, BlockCoord bc, HarvestResult res, BaseHarvestTarget target) {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if(dir.offsetY == 0) {
BlockCoord loc = bc.getLocation(dir);
@@ -107,20 +111,31 @@ public class TreeHarvestUtil {
return true;
}
private static final class HarvestTarget {
private final Block wood;
private static final class HarvestTarget extends BaseHarvestTarget
{
private final int woodMeta;
HarvestTarget(Block wood, int woodMeta) {
this.wood = wood;
super(wood);
this.woodMeta = woodMeta;
}
boolean isTarget(Block blk, int meta) {
return blk == wood && ((meta & 3) == (woodMeta & 3));
return super.isTarget(blk,meta) && ((meta & 3) == (woodMeta & 3));
}
}
private static class BaseHarvestTarget
{
private final Block wood;
BaseHarvestTarget(Block wood) {
this.wood = wood;
}
boolean isTarget(Block blk, int meta) {
return blk == wood;
}
}
}
@@ -127,7 +127,7 @@ public abstract class BasicPainterTemplate implements IMachineRecipe {
}
@Override
public float getExperianceForOutput(ItemStack output) {
public float getExperienceForOutput(ItemStack output) {
return 0;
}
@@ -65,13 +65,13 @@ public abstract class AbstractMachineRecipe implements IMachineRecipe {
ItemStack availableStack = available.item;
ItemStack requiredStack = required.getInput();
ItemStack comsumedStack = requiredStack.copy();
comsumedStack.stackSize = Math.min(requiredStack.stackSize, availableStack.stackSize);
ItemStack consumedStack = requiredStack.copy();
consumedStack.stackSize = Math.min(requiredStack.stackSize, availableStack.stackSize);
requiredStack.stackSize -= comsumedStack.stackSize;
availableStack.stackSize -= comsumedStack.stackSize;
requiredStack.stackSize -= consumedStack.stackSize;
availableStack.stackSize -= consumedStack.stackSize;
consumedInputs.add(new MachineRecipeInput(available.slotNumber, comsumedStack));
consumedInputs.add(new MachineRecipeInput(available.slotNumber, consumedStack));
if(requiredStack.stackSize <= 0) {
//Fully met the requirement
@@ -93,7 +93,7 @@ public abstract class AbstractMachineRecipe implements IMachineRecipe {
}
@Override
public float getExperianceForOutput(ItemStack output) {
public float getExperienceForOutput(ItemStack output) {
return 0;
}
@@ -41,7 +41,7 @@ public class ManyToOneMachineRecipe extends AbstractMachineRecipe {
}
@Override
public float getExperianceForOutput(ItemStack output) {
public float getExperienceForOutput(ItemStack output) {
return recipeManager.getExperianceForOutput(output);
}
@@ -85,7 +85,7 @@ public abstract class AbstractSoulBinderRecipe implements IMachineRecipe, ISoulB
@Override
public float getExperianceForOutput(ItemStack output) {
public float getExperienceForOutput(ItemStack output) {
return 0;
}
@@ -64,7 +64,7 @@ public class SoulBinderSpawnerRecipe implements IMachineRecipe, ISoulBinderRecip
}
@Override
public float getExperianceForOutput(ItemStack output) {
public float getExperienceForOutput(ItemStack output) {
return 0;
}
@@ -32,7 +32,7 @@ public class DummyRecipe implements IMachineRecipe {
}
@Override
public float getExperianceForOutput(ItemStack output) {
public float getExperienceForOutput(ItemStack output) {
return 0;
}