aboutsummaryrefslogtreecommitdiff
path: root/src/Java/binnie/extrabees/genetics/ExtraBeesFlowers.java
blob: 743c7a55a845360af2128b18b48fcc708cfdd2b9 (plain)
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
package binnie.extrabees.genetics;

import binnie.core.Mods;
import binnie.core.Mods.Mod;
import binnie.extrabees.ExtraBees;
import binnie.extrabees.proxy.ExtraBeesProxy;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAlleleFlowers;
import forestry.api.genetics.IAlleleRegistry;
import forestry.api.genetics.IFlower;
import forestry.api.genetics.IFlowerProvider;
import forestry.api.genetics.IFruitBearer;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IPollinatable;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;

public enum ExtraBeesFlowers
  implements IFlowerProvider, IAlleleFlowers
{
  WATER,  SUGAR,  ROCK,  BOOK,  DEAD,  REDSTONE,  WOOD,  LEAVES,  Sapling,  Fruit,  Mystical;
  
  boolean dominant = true;
  
  private ExtraBeesFlowers() {}
  
  public String getUID()
  {
    return "extrabees.flower." + toString().toLowerCase();
  }
  
  public boolean isDominant()
  {
    return this.dominant;
  }
  
  public IFlowerProvider getProvider()
  {
    return this;
  }
  
  public String getDescription()
  {
    return ExtraBees.proxy.localise("flowers." + name().toString().toLowerCase() + ".name");
  }
  
  public void register()
  {
    AlleleManager.alleleRegistry.registerAllele(this);
  }
  
  public static void doInit()
  {
    for (ExtraBeesFlowers effect : ) {
      effect.register();
    }
  }
  
  public ItemStack[] getItemStacks()
  {
    switch (1.$SwitchMap$binnie$extrabees$genetics$ExtraBeesFlowers[ordinal()])
    {
    case 1: 
      return new ItemStack[] { new ItemStack(Blocks.waterlily) };
    case 2: 
      return new ItemStack[] { new ItemStack(Blocks.reeds) };
    case 3: 
      return new ItemStack[] { new ItemStack(Blocks.cobblestone) };
    case 4: 
      return new ItemStack[] { new ItemStack(Blocks.bookshelf) };
    case 5: 
      return new ItemStack[] { new ItemStack(Blocks.redstone_torch) };
    case 6: 
      return new ItemStack[] { new ItemStack(Blocks.deadbush) };
    case 7: 
      return new ItemStack[] { new ItemStack(Items.apple) };
    case 8: 
      return new ItemStack[] { new ItemStack(Blocks.leaves) };
    case 9: 
      return new ItemStack[] { new ItemStack(Blocks.sapling) };
    case 10: 
      return new ItemStack[] { new ItemStack(Blocks.log) };
    }
    return new ItemStack[0];
  }
  
  public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable)
  {
    EnumSet<EnumPlantType> types = pollinatable.getPlantType();
    return (types.size() > 1) || (!types.contains(EnumPlantType.Nether));
  }
  
  public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z)
  {
    Block block = world.getBlock(x, y, z);
    if (block == null) {
      return false;
    }
    switch (1.$SwitchMap$binnie$extrabees$genetics$ExtraBeesFlowers[ordinal()])
    {
    case 1: 
      return block == Blocks.waterlily;
    case 3: 
      return block.getMaterial() == Material.rock;
    case 2: 
      return block == Blocks.reeds;
    case 4: 
      return block == Blocks.bookshelf;
    case 5: 
      return block == Blocks.redstone_torch;
    case 6: 
      return block == Blocks.deadbush;
    case 10: 
      return block.isWood(world, x, y, z);
    case 7: 
      return world.getTileEntity(x, y, z) instanceof IFruitBearer;
    case 8: 
      return block.isLeaves(world, x, y, z);
    case 9: 
      return block.getClass().getName().toLowerCase().contains("sapling");
    case 11: 
      return block == Mods.Botania.block("flower");
    }
    return false;
  }
  
  public boolean growFlower(World world, IIndividual individual, int x, int y, int z)
  {
    switch (1.$SwitchMap$binnie$extrabees$genetics$ExtraBeesFlowers[ordinal()])
    {
    case 1: 
      if ((world.isAirBlock(x, y, z)) && (world.getBlock(x, y - 1, z) == Blocks.water)) {
        return world.setBlock(x, y, z, Blocks.waterlily, 0, 2);
      }
      return false;
    case 2: 
      if ((world.getBlock(x, y - 1, z) == Blocks.reeds) && (world.isAirBlock(x, y, z))) {
        return world.setBlock(x, y, z, Blocks.reeds, 0, 0);
      }
      return false;
    }
    return false;
  }
  
  public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products)
  {
    if (this == Mystical)
    {
      List<ItemStack> prods = new ArrayList();
      for (ItemStack stack : products) {
        prods.add(stack);
      }
      for (int k = 0; k < 50; k++)
      {
        int tX = 7;
        int tY = 7;
        int tZ = 3;
        int x2 = x - tX + world.rand.nextInt(1 + 2 * tX);
        int y2 = y - tY + world.rand.nextInt(1 + 2 * tY);
        int z2 = z - tZ + world.rand.nextInt(1 + 2 * tZ);
        Block block = world.getBlock(x2, y2, z2);
        if (block != null) {
          if (block == Mods.Botania.block("flower"))
          {
            int meta = world.getBlockMetadata(x2, y2, z2);
            Item item = Mods.Botania.item("petal");
            if (item != null) {
              prods.add(new ItemStack(item, 1, meta));
            }
          }
        }
      }
      return (ItemStack[])prods.toArray(new ItemStack[0]);
    }
    return products;
  }
  
  public String getName()
  {
    return getDescription();
  }
  
  public String getUnlocalizedName()
  {
    return getUID();
  }
  
  public List<IFlower> getFlowers()
  {
    return new ArrayList();
  }
}