mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 16:58:34 +01:00
Not everything is a BlockCrops
This commit is contained in:
parent
0b02277006
commit
c2209f0596
4 changed files with 53 additions and 53 deletions
|
@ -86,6 +86,6 @@ public class CactusFarmerBehavior implements IFarmerBehavior{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPriority(){
|
public int getPriority(){
|
||||||
return 0;
|
return 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,21 +43,15 @@ public class DefaultFarmerBehavior implements IFarmerBehavior{
|
||||||
IBlockState state = world.getBlockState(pos);
|
IBlockState state = world.getBlockState(pos);
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
|
|
||||||
if(world.isAirBlock(pos) || block.isReplaceable(world, pos)){
|
if(block.isReplaceable(world, pos)){
|
||||||
BlockPos farmland = pos.down();
|
BlockPos farmland = pos.down();
|
||||||
Block farmlandBlock = world.getBlockState(farmland).getBlock();
|
Block farmlandBlock = world.getBlockState(farmland).getBlock();
|
||||||
|
|
||||||
if(tryPlant(toPlant, world, pos)){
|
|
||||||
farmer.extractEnergy(use);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if(farmlandBlock instanceof BlockDirt || farmlandBlock instanceof BlockGrass){
|
if(farmlandBlock instanceof BlockDirt || farmlandBlock instanceof BlockGrass){
|
||||||
useHoeAt(world, pos.down());
|
|
||||||
world.setBlockToAir(pos);
|
world.setBlockToAir(pos);
|
||||||
|
useHoeAt(world, farmland);
|
||||||
world.playSound(null, farmland, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
world.playSound(null, farmland, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||||
|
|
||||||
farmer.extractEnergy(use);
|
farmer.extractEnergy(use);
|
||||||
|
}
|
||||||
|
|
||||||
if(tryPlant(toPlant, world, pos)){
|
if(tryPlant(toPlant, world, pos)){
|
||||||
farmer.extractEnergy(use);
|
farmer.extractEnergy(use);
|
||||||
|
@ -65,8 +59,6 @@ public class DefaultFarmerBehavior implements IFarmerBehavior{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,10 +90,21 @@ public class DefaultFarmerBehavior implements IFarmerBehavior{
|
||||||
|
|
||||||
if(block instanceof BlockCrops){
|
if(block instanceof BlockCrops){
|
||||||
if(((BlockCrops)block).isMaxAge(state)){
|
if(((BlockCrops)block).isMaxAge(state)){
|
||||||
List<ItemStack> seeds = new ArrayList<ItemStack>();
|
return doFarmerStuff(state, world, pos, farmer);
|
||||||
List<ItemStack> other = new ArrayList<ItemStack>();
|
}
|
||||||
|
}
|
||||||
|
else if((BlockCrops.AGE).equals(block.getBlockState().getProperty("age"))) {
|
||||||
|
if(state.getValue(BlockCrops.AGE) >= 7) return doFarmerStuff(state, world, pos, farmer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return FarmerResult.FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
private FarmerResult doFarmerStuff(IBlockState state, World world, BlockPos pos, IFarmer farmer) {
|
||||||
|
List<ItemStack> seeds = new ArrayList<>();
|
||||||
|
List<ItemStack> other = new ArrayList<>();
|
||||||
NonNullList<ItemStack> drops = NonNullList.create();
|
NonNullList<ItemStack> drops = NonNullList.create();
|
||||||
block.getDrops(drops, world, pos, state, 0);
|
state.getBlock().getDrops(drops, world, pos, state, 0);
|
||||||
for(ItemStack stack : drops){
|
for(ItemStack stack : drops){
|
||||||
if(this.getPlantableFromStack(stack) != null){
|
if(this.getPlantableFromStack(stack) != null){
|
||||||
seeds.add(stack);
|
seeds.add(stack);
|
||||||
|
@ -127,12 +130,9 @@ public class DefaultFarmerBehavior implements IFarmerBehavior{
|
||||||
world.playEvent(2001, pos, Block.getStateId(state));
|
world.playEvent(2001, pos, Block.getStateId(state));
|
||||||
world.setBlockToAir(pos);
|
world.setBlockToAir(pos);
|
||||||
|
|
||||||
farmer.extractEnergy(use);
|
farmer.extractEnergy(250);
|
||||||
return FarmerResult.SUCCESS;
|
return FarmerResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return FarmerResult.FAIL;
|
return FarmerResult.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ public class DefaultFarmerBehavior implements IFarmerBehavior{
|
||||||
IPlantable plantable = this.getPlantableFromStack(stack);
|
IPlantable plantable = this.getPlantableFromStack(stack);
|
||||||
if(plantable != null){
|
if(plantable != null){
|
||||||
IBlockState state = plantable.getPlant(world, pos);
|
IBlockState state = plantable.getPlant(world, pos);
|
||||||
if(state != null && state.getBlock() instanceof BlockCrops){
|
if(state != null && state.getBlock() instanceof IGrowable){
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,6 @@ public class NetherWartFarmerBehavior implements IFarmerBehavior{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPriority(){
|
public int getPriority(){
|
||||||
return 0;
|
return 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,6 @@ public class ReedFarmerBehavior implements IFarmerBehavior{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPriority(){
|
public int getPriority(){
|
||||||
return 0;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue