Fix Harvest Moon not working with Pumpkins (#1432)

This commit is contained in:
Nicholas Ignoffo 2018-09-03 11:35:15 -07:00
parent 2b587e84af
commit d54c828fba
2 changed files with 14 additions and 11 deletions

View file

@ -10,6 +10,7 @@ import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import java.util.Collection;
import java.util.List;
/**
@ -29,19 +30,21 @@ public class HarvestHandlerStem implements IHarvestHandler {
@Override
public boolean harvest(World world, BlockPos pos, IBlockState state, List<ItemStack> drops) {
EnumFacing cropDir = state.getBlock().getActualState(state, world, pos).getValue(BlockStem.FACING);
EnumFacing cropDir = state.getActualState(world, pos).getValue(BlockStem.FACING);
if (cropDir != EnumFacing.UP) {
BlockPos cropPos = pos.offset(cropDir);
IBlockState probableCrop = world.getBlockState(cropPos);
IBlockState registeredCrop = HarvestRegistry.getStemCrops().get(state);
Collection<IBlockState> registeredCrops = HarvestRegistry.getStemCrops().get(state);
if (registeredCrop == probableCrop) {
NonNullList<ItemStack> blockDrops = NonNullList.create();
probableCrop.getBlock().getDrops(blockDrops, world, cropPos, probableCrop, 0);
drops.addAll(blockDrops);
world.destroyBlock(cropPos, false);
return true;
for (IBlockState registeredCrop : registeredCrops) {
if (registeredCrop == probableCrop) {
NonNullList<ItemStack> blockDrops = NonNullList.create();
probableCrop.getBlock().getDrops(blockDrops, world, cropPos, probableCrop, 0);
drops.addAll(blockDrops);
world.destroyBlock(cropPos, false);
return true;
}
}
}

View file

@ -14,7 +14,7 @@ public class HarvestRegistry {
private static final List<IHarvestHandler> HARVEST_HANDLERS = Lists.newArrayList();
private static final Map<Block, Integer> STANDARD_CROPS = Maps.newHashMap();
private static final Set<IBlockState> TALL_CROPS = Sets.newHashSet();
private static final Map<IBlockState, IBlockState> STEM_CROPS = Maps.newHashMap();
private static final Multimap<IBlockState, IBlockState> STEM_CROPS = ArrayListMultimap.create();
private static final Map<IBlockState, Integer> AMPLIFIERS = Maps.newHashMap();
/**
@ -95,8 +95,8 @@ public class HarvestRegistry {
return ImmutableSet.copyOf(TALL_CROPS);
}
public static Map<IBlockState, IBlockState> getStemCrops() {
return ImmutableMap.copyOf(STEM_CROPS);
public static Multimap<IBlockState, IBlockState> getStemCrops() {
return ImmutableMultimap.copyOf(STEM_CROPS);
}
public static Map<IBlockState, Integer> getAmplifiers() {