/
HarvestableNaturaCropPlant.java
80 lines (69 loc) · 2.04 KB
/
HarvestableNaturaCropPlant.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package mods.natura.plugins.minefactoryreloaded.harvestables;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import powercrystals.minefactoryreloaded.api.HarvestType;
import powercrystals.minefactoryreloaded.api.IFactoryHarvestable;
public class HarvestableNaturaCropPlant implements IFactoryHarvestable
{
private int _sourceId;
private int _cottonItemId;
public HarvestableNaturaCropPlant(int sourceId, int cottonItemId)
{
_sourceId = sourceId;
_cottonItemId = cottonItemId;
}
@Override
public int getPlantId ()
{
return _sourceId;
}
@Override
public HarvestType getHarvestType ()
{
return HarvestType.Normal;
}
@Override
public boolean breakBlock ()
{
return false;
}
@Override
public boolean canBeHarvested (World world, Map<String, Boolean> harvesterSettings, int x, int y, int z)
{
return world.getBlockMetadata(x, y, z) == 3 || world.getBlockMetadata(x, y, z) == 8;
}
@Override
public List<ItemStack> getDrops (World world, Random rand, Map<String, Boolean> harvesterSettings, int x, int y, int z)
{
if (world.getBlockMetadata(x, y, z) == 8)
{
ItemStack[] returnItems = { new ItemStack(_cottonItemId, 1, 3) };
return Arrays.asList(returnItems);
}
else
{
return Block.blocksList[_sourceId].getBlockDropped(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
}
}
@Override
public void preHarvest (World world, int x, int y, int z)
{
}
@Override
public void postHarvest (World world, int x, int y, int z)
{
if (world.getBlockMetadata(x, y, z) == 3)
{
world.setBlockToAir(x, y, z);
}
else if (world.getBlockMetadata(x, y, z) == 8)
{
world.setBlockMetadataWithNotify(x, y, z, 6, 2);
}
}
}