Improve code readability in binnie.extrabees package and other packages

* Improve code readability in binnie.extrabees package and other packages
* Fix compile error after refactoring
This commit is contained in:
Alexander Kornilov authored and marcin212 committed 2017-04-29 13:43:35 +02:00
1 parent b609d6688f
commit c09ad04284
95 files changed
+3916 -3900

No files matched your search

@@ -1,49 +1,35 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.extrabees.genetics;
import forestry.api.apiculture.FlowerManager;
import forestry.api.genetics.IFlower;
import net.minecraft.item.Item;
import java.util.HashSet;
import java.util.List;
import java.util.ArrayList;
import java.util.Set;
import binnie.core.Mods;
import binnie.extrabees.ExtraBees;
import forestry.api.apiculture.FlowerManager;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleFlowers;
import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.IFlower;
import forestry.api.genetics.IFlowerProvider;
import forestry.api.genetics.IFruitBearer;
import net.minecraft.world.IBlockAccess;
import net.minecraft.block.material.Material;
import forestry.api.genetics.IIndividual;
import java.util.EnumSet;
import forestry.api.genetics.IPollinatable;
import forestry.api.genetics.ISpeciesRoot;
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;
import forestry.api.genetics.IPollinatable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.minecraft.world.World;
import net.minecraft.init.Items;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.ISpeciesRoot;
import binnie.extrabees.ExtraBees;
import forestry.api.genetics.IAlleleFlowers;
import forestry.api.genetics.IFlowerProvider;
public enum ExtraBeesFlowers implements IFlowerProvider, IAlleleFlowers, IChromosomeType
{
public enum ExtraBeesFlowers implements IFlowerProvider, IAlleleFlowers, IChromosomeType {
WATER,
SUGAR,
ROCK,
@@ -52,24 +38,30 @@ public enum ExtraBeesFlowers implements IFlowerProvider, IAlleleFlowers, IChromo
REDSTONE,
WOOD,
LEAVES,
Sapling,
Fruit,
Mystical;
SAPLING,
FRUIT,
MYSTICAL;
boolean dominant;
protected boolean dominant;
private ExtraBeesFlowers() {
this.dominant = true;
ExtraBeesFlowers() {
dominant = true;
}
public static void doInit() {
for (ExtraBeesFlowers effect : values()) {
effect.register();
}
}
@Override
public String getUID() {
return "extrabees.flower." + this.toString().toLowerCase();
return "extrabees.flower." + toString().toLowerCase();
}
@Override
public boolean isDominant() {
return this.dominant;
return dominant;
}
@Override
@@ -79,12 +71,11 @@ public enum ExtraBeesFlowers implements IFlowerProvider, IAlleleFlowers, IChromo
@Override
public String getDescription() {
return ExtraBees.proxy.localise("flowers." + this.name().toString().toLowerCase() + ".name");
return ExtraBees.proxy.localise("flowers." + name().toString().toLowerCase() + ".name");
}
public void register() {
// AlleleManager.alleleRegistry.registerAllele((IAllele)this);
for (ItemStack stack : getItemStacks()) {
FlowerManager.flowerRegistry.registerAcceptableFlower(Block.getBlockFromItem(stack.getItem()), getUID());
}
@@ -92,135 +83,125 @@ public enum ExtraBeesFlowers implements IFlowerProvider, IAlleleFlowers, IChromo
AlleleManager.alleleRegistry.registerAllele(this, this);
}
public static void doInit() {
for (final ExtraBeesFlowers effect : values()) {
effect.register();
}
}
public ItemStack[] getItemStacks() {
switch (this) {
case WATER: {
return new ItemStack[] { new ItemStack(Blocks.waterlily) };
}
case SUGAR: {
return new ItemStack[] { new ItemStack(Blocks.reeds) };
}
case ROCK: {
return new ItemStack[] { new ItemStack(Blocks.cobblestone) };
}
case BOOK: {
return new ItemStack[] { new ItemStack(Blocks.bookshelf) };
}
case REDSTONE: {
return new ItemStack[] { new ItemStack(Blocks.redstone_torch) };
}
case DEAD: {
return new ItemStack[] { new ItemStack(Blocks.deadbush) };
}
case Fruit: {
return new ItemStack[] { new ItemStack(Items.apple) };
}
case LEAVES: {
return new ItemStack[] { new ItemStack(Blocks.leaves) };
}
case Sapling: {
return new ItemStack[] { new ItemStack(Blocks.sapling) };
}
case WOOD: {
return new ItemStack[] { new ItemStack(Blocks.log) };
}
default: {
return new ItemStack[0];
}
case WATER:
return new ItemStack[]{new ItemStack(Blocks.waterlily)};
case SUGAR:
return new ItemStack[]{new ItemStack(Blocks.reeds)};
case ROCK:
return new ItemStack[]{new ItemStack(Blocks.cobblestone)};
case BOOK:
return new ItemStack[]{new ItemStack(Blocks.bookshelf)};
case REDSTONE:
return new ItemStack[]{new ItemStack(Blocks.redstone_torch)};
case DEAD:
return new ItemStack[]{new ItemStack(Blocks.deadbush)};
case FRUIT:
return new ItemStack[]{new ItemStack(Items.apple)};
case LEAVES:
return new ItemStack[]{new ItemStack(Blocks.leaves)};
case SAPLING:
return new ItemStack[]{new ItemStack(Blocks.sapling)};
case WOOD:
return new ItemStack[]{new ItemStack(Blocks.log)};
}
return new ItemStack[0];
}
@Override
public boolean isAcceptedPollinatable(final World world, final IPollinatable pollinatable) {
final EnumSet<EnumPlantType> types = pollinatable.getPlantType();
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
EnumSet<EnumPlantType> types = pollinatable.getPlantType();
return types.size() > 1 || !types.contains(EnumPlantType.Nether);
}
public boolean isAcceptedFlower(final World world, final IIndividual individual, final int x, final int y, final int z) {
final Block block = world.getBlock(x, y, z);
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 (this) {
case WATER: {
return block == Blocks.waterlily;
}
case ROCK: {
return block.getMaterial() == Material.rock;
}
case SUGAR: {
return block == Blocks.reeds;
}
case BOOK: {
return block == Blocks.bookshelf;
}
case REDSTONE: {
return block == Blocks.redstone_torch;
}
case DEAD: {
return block == Blocks.deadbush;
}
case WOOD: {
return block.isWood(world, x, y, z);
}
case Fruit: {
return world.getTileEntity(x, y, z) instanceof IFruitBearer;
}
case LEAVES: {
return block.isLeaves(world, x, y, z);
}
case Sapling: {
return block.getClass().getName().toLowerCase().contains("sapling");
}
case Mystical: {
return block == Mods.Botania.block("flower");
}
default: {
return false;
}
case WATER:
return block == Blocks.waterlily;
case ROCK:
return block.getMaterial() == Material.rock;
case SUGAR:
return block == Blocks.reeds;
case BOOK:
return block == Blocks.bookshelf;
case REDSTONE:
return block == Blocks.redstone_torch;
case DEAD:
return block == Blocks.deadbush;
case WOOD:
return block.isWood(world, x, y, z);
case FRUIT:
return world.getTileEntity(x, y, z) instanceof IFruitBearer;
case LEAVES:
return block.isLeaves(world, x, y, z);
case SAPLING:
return block.getClass().getName().toLowerCase().contains("sapling");
case MYSTICAL:
return block == Mods.Botania.block("flower");
}
return false;
}
@Override
public boolean growFlower(final World world, final IIndividual individual, final int x, final int y, final int z) {
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
switch (this) {
case WATER: {
return world.isAirBlock(x, y, z) && world.getBlock(x, y - 1, z) == Blocks.water && world.setBlock(x, y, z, Blocks.waterlily, 0, 2);
}
case SUGAR: {
return world.getBlock(x, y - 1, z) == Blocks.reeds && world.isAirBlock(x, y, z) && world.setBlock(x, y, z, Blocks.reeds, 0, 0);
}
default: {
return false;
}
case WATER:
return world.isAirBlock(x, y, z)
&& world.getBlock(x, y - 1, z) == Blocks.water
&& world.setBlock(x, y, z, Blocks.waterlily, 0, 2);
case SUGAR:
return world.getBlock(x, y - 1, z) == Blocks.reeds
&& world.isAirBlock(x, y, z)
&& world.setBlock(x, y, z, Blocks.reeds, 0, 0);
}
return false;
}
@Override
public ItemStack[] affectProducts(final World world, final IIndividual individual, final int x, final int y, final int z, final ItemStack[] products) {
if (this == ExtraBeesFlowers.Mystical) {
final List<ItemStack> prods = new ArrayList<ItemStack>();
for (final ItemStack stack : products) {
prods.add(stack);
}
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
if (this == ExtraBeesFlowers.MYSTICAL) {
List<ItemStack> prods = new ArrayList<>();
Collections.addAll(prods, products);
for (int k = 0; k < 50; ++k) {
final int tX = 7;
final int tY = 7;
final int tZ = 3;
final int x2 = x - tX + world.rand.nextInt(1 + 2 * tX);
final int y2 = y - tY + world.rand.nextInt(1 + 2 * tY);
final int z2 = z - tZ + world.rand.nextInt(1 + 2 * tZ);
final Block block = world.getBlock(x2, y2, z2);
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")) {
final int meta = world.getBlockMetadata(x2, y2, z2);
final Item item = Mods.Botania.item("petal");
int meta = world.getBlockMetadata(x2, y2, z2);
Item item = Mods.Botania.item("petal");
if (item != null) {
prods.add(new ItemStack(item, 1, meta));
}
@@ -234,22 +215,22 @@ public enum ExtraBeesFlowers implements IFlowerProvider, IAlleleFlowers, IChromo
@Override
public String getName() {
return this.getDescription();
return getDescription();
}
@Override
public String getUnlocalizedName() {
return this.getUID();
return getUID();
}
@Override
public String getFlowerType() {
return this.getUID();
return getUID();
}
@Override
public Set<IFlower> getFlowers() {
return new HashSet<IFlower>();
return new HashSet<>();
}
@Override