diff --git a/src/main/java/binnie/botany/Botany.java b/src/main/java/binnie/botany/Botany.java index 7a6ff1b9..1783ac12 100644 --- a/src/main/java/binnie/botany/Botany.java +++ b/src/main/java/binnie/botany/Botany.java @@ -102,25 +102,25 @@ public class Botany extends AbstractMod { public static Item botanistBackpack; @Mod.EventHandler - public void preInit(final FMLPreInitializationEvent evt) { - this.preInit(); + public void preInit(FMLPreInitializationEvent evt) { + preInit(); } @Mod.EventHandler - public void init(final FMLInitializationEvent evt) { - this.init(); + public void init(FMLInitializationEvent evt) { + init(); } @Mod.EventHandler - public void postInit(final FMLPostInitializationEvent evt) { - this.postInit(); + public void postInit(FMLPostInitializationEvent evt) { + postInit(); } @Override protected void registerModules() { - this.addModule(new ModuleCore()); - this.addModule(new ModuleGenetics()); - this.addModule(new ModuleGardening()); + addModule(new ModuleCore()); + addModule(new ModuleGenetics()); + addModule(new ModuleGardening()); } @Override @@ -164,7 +164,7 @@ public class Botany extends AbstractMod { } @SubscribeEvent - public void onShearFlower(final PlayerInteractEvent.RightClickBlock event) { + public void onShearFlower(PlayerInteractEvent.RightClickBlock event) { EntityPlayer player = event.getEntityPlayer(); if (player == null) { return; @@ -196,7 +196,7 @@ public class Botany extends AbstractMod { } @SubscribeEvent - public void onFertiliseSoil(final PlayerInteractEvent.RightClickBlock event) { + public void onFertiliseSoil(PlayerInteractEvent.RightClickBlock event) { World world = event.getWorld(); if (world == null) { return; @@ -212,7 +212,7 @@ public class Botany extends AbstractMod { if (heldItem.isEmpty()) { return; } - + IGardeningManager gardening = BotanyCore.getGardening(); Block block = world.getBlockState(event.getPos()).getBlock(); if (!gardening.isSoil(block)) { @@ -259,14 +259,14 @@ public class Botany extends AbstractMod { } @SubscribeEvent - public void plantVanilla(final BlockEvent.PlaceEvent event) { + public void plantVanilla(BlockEvent.PlaceEvent event) { World world = event.getWorld(); BlockPos pos = event.getPos(); Block block = world.getBlockState(pos.down()).getBlock(); - if (!BotanyCore.getGardening().isSoil(block)) { return; } + EntityPlayer player = event.getPlayer(); ItemStack heldItem = player.getHeldItem(event.getHand()); IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot(); @@ -277,7 +277,7 @@ public class Botany extends AbstractMod { } @Deprecated - public void onPlantVanilla(final PlayerInteractEvent.RightClickBlock event) { + public void onPlantVanilla(PlayerInteractEvent.RightClickBlock event) { BlockPos pos = event.getPos(); World world = event.getWorld(); EntityPlayer player = event.getEntityPlayer(); @@ -286,24 +286,28 @@ public class Botany extends AbstractMod { return; } - if (!heldItem.isEmpty()) { - Block block = world.getBlockState(pos).getBlock(); - int py = -1; - if (block instanceof IBlockSoil && (world.isAirBlock(pos.up()) || block.isReplaceable(world, pos))) { - py = 1; - } - if (py >= 0) { - IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot(); - IFlower flower = flowerRoot.getConversion(heldItem); - if (flower != null && flowerRoot.plant(world, pos.add(0, py, 0), flower, player.getGameProfile()) && !player.capabilities.isCreativeMode) { - heldItem.shrink(1); - } - } + if (heldItem.isEmpty()) { + return; + } + + Block block = world.getBlockState(pos).getBlock(); + int py = -1; + if (block instanceof IBlockSoil && (world.isAirBlock(pos.up()) || block.isReplaceable(world, pos))) { + py = 1; + } + if (py < 0) { + return; + } + + IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot(); + IFlower flower = flowerRoot.getConversion(heldItem); + if (flower != null && flowerRoot.plant(world, pos.add(0, py, 0), flower, player.getGameProfile()) && !player.capabilities.isCreativeMode) { + heldItem.shrink(1); } } @SubscribeEvent - public void onBonemeal(final BonemealEvent event) { + public void onBonemeal(BonemealEvent event) { BlockPos pos = event.getPos(); Block block = event.getBlock().getBlock(); if (BotanyCore.getGardening().isSoil(block)) { @@ -312,6 +316,7 @@ public class Botany extends AbstractMod { event.setResult(Event.Result.ALLOW); } } + TileEntity tile = event.getWorld().getTileEntity(pos); if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).onBonemeal()) { event.setResult(Event.Result.ALLOW); diff --git a/src/main/java/binnie/botany/CreativeTabBotany.java b/src/main/java/binnie/botany/CreativeTabBotany.java index 37cca468..4a9cded2 100644 --- a/src/main/java/binnie/botany/CreativeTabBotany.java +++ b/src/main/java/binnie/botany/CreativeTabBotany.java @@ -24,7 +24,7 @@ public class CreativeTabBotany extends CreativeTabs { @Override @SideOnly(Side.CLIENT) public String getTranslatedTabLabel() { - return this.getTabLabel(); + return getTabLabel(); } @Override diff --git a/src/main/java/binnie/botany/api/EnumAcidity.java b/src/main/java/binnie/botany/api/EnumAcidity.java index c8bf2e10..b54535d8 100644 --- a/src/main/java/binnie/botany/api/EnumAcidity.java +++ b/src/main/java/binnie/botany/api/EnumAcidity.java @@ -1,10 +1,11 @@ package binnie.botany.api; -import binnie.core.util.I18N; +import javax.annotation.Nullable; + import net.minecraft.util.IStringSerializable; import net.minecraft.util.text.TextFormatting; -import javax.annotation.Nullable; +import binnie.core.util.I18N; public enum EnumAcidity implements IStringSerializable { ACID(TextFormatting.RED), @@ -20,7 +21,7 @@ public enum EnumAcidity implements IStringSerializable { @Override public String getName() { - return this.name().toLowerCase(); + return name().toLowerCase(); } public String getLocalisedName(boolean withColor) { diff --git a/src/main/java/binnie/botany/api/EnumFlowerChromosome.java b/src/main/java/binnie/botany/api/EnumFlowerChromosome.java index 052bf478..96eb1960 100644 --- a/src/main/java/binnie/botany/api/EnumFlowerChromosome.java +++ b/src/main/java/binnie/botany/api/EnumFlowerChromosome.java @@ -1,5 +1,7 @@ package binnie.botany.api; +import java.util.Locale; + import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; import forestry.api.genetics.IAlleleArea; @@ -9,8 +11,6 @@ import forestry.api.genetics.IAlleleTolerance; import forestry.api.genetics.IChromosomeType; import forestry.api.genetics.ISpeciesRoot; -import java.util.Locale; - public enum EnumFlowerChromosome implements IChromosomeType { SPECIES(IAlleleFlowerSpecies.class), PRIMARY(IAlleleInteger.class), @@ -33,12 +33,12 @@ public enum EnumFlowerChromosome implements IChromosomeType { @Override public Class getAlleleClass() { - return this.cls; + return cls; } @Override public String getName() { - return this.toString().toLowerCase(Locale.ENGLISH); + return toString().toLowerCase(Locale.ENGLISH); } @Override diff --git a/src/main/java/binnie/botany/api/EnumFlowerStage.java b/src/main/java/binnie/botany/api/EnumFlowerStage.java index 15be3988..6e0e0edd 100644 --- a/src/main/java/binnie/botany/api/EnumFlowerStage.java +++ b/src/main/java/binnie/botany/api/EnumFlowerStage.java @@ -20,12 +20,12 @@ public enum EnumFlowerStage implements ISpeciesType { public static EnumFlowerStage getStage(int age) { return age == 0 - ? EnumFlowerStage.SEED - : EnumFlowerStage.FLOWER; + ? EnumFlowerStage.SEED + : EnumFlowerStage.FLOWER; } public String getName() { - return this.name; + return name; } } diff --git a/src/main/java/binnie/botany/api/EnumMoisture.java b/src/main/java/binnie/botany/api/EnumMoisture.java index b5cb471b..8faded8b 100644 --- a/src/main/java/binnie/botany/api/EnumMoisture.java +++ b/src/main/java/binnie/botany/api/EnumMoisture.java @@ -1,10 +1,11 @@ package binnie.botany.api; -import binnie.core.util.I18N; +import javax.annotation.Nullable; + import net.minecraft.util.IStringSerializable; import net.minecraft.util.text.TextFormatting; -import javax.annotation.Nullable; +import binnie.core.util.I18N; public enum EnumMoisture implements IStringSerializable { DRY(TextFormatting.YELLOW), diff --git a/src/main/java/binnie/botany/api/EnumSoilType.java b/src/main/java/binnie/botany/api/EnumSoilType.java index 4077da7e..b687427d 100644 --- a/src/main/java/binnie/botany/api/EnumSoilType.java +++ b/src/main/java/binnie/botany/api/EnumSoilType.java @@ -1,10 +1,11 @@ package binnie.botany.api; -import binnie.core.util.I18N; +import java.util.Locale; + import net.minecraft.util.IStringSerializable; import net.minecraft.util.text.TextFormatting; -import java.util.Locale; +import binnie.core.util.I18N; public enum EnumSoilType implements IStringSerializable { SOIL(TextFormatting.DARK_GRAY), @@ -19,7 +20,7 @@ public enum EnumSoilType implements IStringSerializable { @Override public String getName() { - return this.name().toLowerCase(Locale.ENGLISH); + return name().toLowerCase(Locale.ENGLISH); } public String getTranslated() { diff --git a/src/main/java/binnie/botany/api/IAlleleFlowerEffect.java b/src/main/java/binnie/botany/api/IAlleleFlowerEffect.java index ac6cd8c5..45c81950 100644 --- a/src/main/java/binnie/botany/api/IAlleleFlowerEffect.java +++ b/src/main/java/binnie/botany/api/IAlleleFlowerEffect.java @@ -1,8 +1,9 @@ package binnie.botany.api; +import net.minecraft.world.World; + import forestry.api.genetics.IAlleleEffect; import forestry.api.genetics.IEffectData; -import net.minecraft.world.World; public interface IAlleleFlowerEffect extends IAlleleEffect { IEffectData doEffect(IFlowerGenome genome, IEffectData effect, World world, int x, int y, int z); diff --git a/src/main/java/binnie/botany/api/IAlleleFlowerSpecies.java b/src/main/java/binnie/botany/api/IAlleleFlowerSpecies.java index 5cc30f58..a2ca4e48 100644 --- a/src/main/java/binnie/botany/api/IAlleleFlowerSpecies.java +++ b/src/main/java/binnie/botany/api/IAlleleFlowerSpecies.java @@ -1,12 +1,14 @@ package binnie.botany.api; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.item.Item; + +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + import forestry.api.core.IModelManager; import forestry.api.genetics.IAlleleProperty; import forestry.api.genetics.IAlleleSpecies; -import net.minecraft.client.renderer.block.model.ModelResourceLocation; -import net.minecraft.item.Item; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; public interface IAlleleFlowerSpecies extends IAlleleSpecies, IAlleleProperty { IFlowerType getType(); diff --git a/src/main/java/binnie/botany/api/IColorMix.java b/src/main/java/binnie/botany/api/IColorMix.java index ca9bbe0e..dd740274 100644 --- a/src/main/java/binnie/botany/api/IColorMix.java +++ b/src/main/java/binnie/botany/api/IColorMix.java @@ -1,13 +1,13 @@ package binnie.botany.api; public interface IColorMix { - IFlowerColour getColorFirst(); + IFlowerColor getColorFirst(); - IFlowerColour getColorSecond(); + IFlowerColor getColorSecond(); - boolean isMutation(IFlowerColour colorFirst, IFlowerColour colorSecond); + boolean isMutation(IFlowerColor colorFirst, IFlowerColor colorSecond); int getChance(); - IFlowerColour getResult(); + IFlowerColor getResult(); } diff --git a/src/main/java/binnie/botany/api/IFlower.java b/src/main/java/binnie/botany/api/IFlower.java index 2ce27dce..90a7f352 100644 --- a/src/main/java/binnie/botany/api/IFlower.java +++ b/src/main/java/binnie/botany/api/IFlower.java @@ -1,10 +1,11 @@ package binnie.botany.api; -import forestry.api.genetics.IIndividual; +import javax.annotation.Nullable; + import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import javax.annotation.Nullable; +import forestry.api.genetics.IIndividual; public interface IFlower extends IIndividual { @Override diff --git a/src/main/java/binnie/botany/api/IFlowerColour.java b/src/main/java/binnie/botany/api/IFlowerColor.java similarity index 84% rename from src/main/java/binnie/botany/api/IFlowerColour.java rename to src/main/java/binnie/botany/api/IFlowerColor.java index 61fecf37..c48f22e5 100644 --- a/src/main/java/binnie/botany/api/IFlowerColour.java +++ b/src/main/java/binnie/botany/api/IFlowerColor.java @@ -2,7 +2,7 @@ package binnie.botany.api; import forestry.api.genetics.IAlleleInteger; -public interface IFlowerColour { +public interface IFlowerColor { int getColor(boolean dis); IAlleleInteger getAllele(); diff --git a/src/main/java/binnie/botany/api/IFlowerDefinition.java b/src/main/java/binnie/botany/api/IFlowerDefinition.java index 87632611..4b9cdab4 100644 --- a/src/main/java/binnie/botany/api/IFlowerDefinition.java +++ b/src/main/java/binnie/botany/api/IFlowerDefinition.java @@ -1,8 +1,9 @@ package binnie.botany.api; -import forestry.core.genetics.IGeneticDefinition; import net.minecraft.item.ItemStack; +import forestry.core.genetics.IGeneticDefinition; + public interface IFlowerDefinition extends IGeneticDefinition { @Override IFlowerGenome getGenome(); diff --git a/src/main/java/binnie/botany/api/IFlowerGenome.java b/src/main/java/binnie/botany/api/IFlowerGenome.java index 7add46b5..a2d38c35 100644 --- a/src/main/java/binnie/botany/api/IFlowerGenome.java +++ b/src/main/java/binnie/botany/api/IFlowerGenome.java @@ -11,11 +11,11 @@ public interface IFlowerGenome extends IGenome { @Override IAlleleFlowerSpecies getSecondary(); - IFlowerColour getPrimaryColor(); + IFlowerColor getPrimaryColor(); - IFlowerColour getSecondaryColor(); + IFlowerColor getSecondaryColor(); - IFlowerColour getStemColor(); + IFlowerColor getStemColor(); int getFertility(); diff --git a/src/main/java/binnie/botany/api/IFlowerMutation.java b/src/main/java/binnie/botany/api/IFlowerMutation.java index 9ad60ed4..ba811675 100644 --- a/src/main/java/binnie/botany/api/IFlowerMutation.java +++ b/src/main/java/binnie/botany/api/IFlowerMutation.java @@ -1,9 +1,10 @@ package binnie.botany.api; -import forestry.api.genetics.IMutation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import forestry.api.genetics.IMutation; + public interface IFlowerMutation extends IMutation { @Override IFlowerRoot getRoot(); diff --git a/src/main/java/binnie/botany/api/IFlowerRoot.java b/src/main/java/binnie/botany/api/IFlowerRoot.java index af2a215f..bd127247 100644 --- a/src/main/java/binnie/botany/api/IFlowerRoot.java +++ b/src/main/java/binnie/botany/api/IFlowerRoot.java @@ -1,16 +1,18 @@ package binnie.botany.api; -import com.mojang.authlib.GameProfile; -import forestry.api.genetics.IAllele; -import forestry.api.genetics.ISpeciesRoot; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - import javax.annotation.Nullable; import java.util.Collection; import java.util.List; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import com.mojang.authlib.GameProfile; + +import forestry.api.genetics.IAllele; +import forestry.api.genetics.ISpeciesRoot; + public interface IFlowerRoot extends ISpeciesRoot { @Override @Nullable diff --git a/src/main/java/binnie/botany/api/IFlowerType.java b/src/main/java/binnie/botany/api/IFlowerType.java index 644bc31b..fb53071b 100644 --- a/src/main/java/binnie/botany/api/IFlowerType.java +++ b/src/main/java/binnie/botany/api/IFlowerType.java @@ -1,11 +1,13 @@ package binnie.botany.api; -import forestry.api.core.IModelManager; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; + import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import forestry.api.core.IModelManager; + public interface IFlowerType> extends Comparable { @SideOnly(Side.CLIENT) void registerModels(Item item, IModelManager manager, EnumFlowerStage type); diff --git a/src/main/java/binnie/botany/api/IGardeningManager.java b/src/main/java/binnie/botany/api/IGardeningManager.java index 44f3e5da..5742c470 100644 --- a/src/main/java/binnie/botany/api/IGardeningManager.java +++ b/src/main/java/binnie/botany/api/IGardeningManager.java @@ -1,14 +1,15 @@ package binnie.botany.api; -import forestry.api.core.EnumTemperature; +import javax.annotation.Nullable; +import java.util.Collection; + import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import javax.annotation.Nullable; -import java.util.Collection; +import forestry.api.core.EnumTemperature; public interface IGardeningManager { default boolean isSoil(Block block) { diff --git a/src/main/java/binnie/botany/api/package-info.java b/src/main/java/binnie/botany/api/package-info.java index d93958b7..25288c28 100644 --- a/src/main/java/binnie/botany/api/package-info.java +++ b/src/main/java/binnie/botany/api/package-info.java @@ -2,6 +2,6 @@ @MethodsReturnNonnullByDefault package binnie.botany.api; -import mcp.MethodsReturnNonnullByDefault; +import javax.annotation.ParametersAreNonnullByDefault; -import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file +import mcp.MethodsReturnNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/binnie/botany/ceramic/BlockCeramic.java b/src/main/java/binnie/botany/ceramic/BlockCeramic.java index b11ba105..8ad9ccd3 100644 --- a/src/main/java/binnie/botany/ceramic/BlockCeramic.java +++ b/src/main/java/binnie/botany/ceramic/BlockCeramic.java @@ -35,16 +35,16 @@ import binnie.core.util.TileUtil; public class BlockCeramic extends Block implements IColoredBlock, IItemModelRegister { public BlockCeramic() { super(Material.ROCK); - this.setHardness(1.0f); - this.setResistance(5.0f); - this.setRegistryName("ceramic"); - this.setCreativeTab(CreativeTabBotany.instance); + setHardness(1.0f); + setResistance(5.0f); + setRegistryName("ceramic"); + setCreativeTab(CreativeTabBotany.instance); } @Override @SideOnly(Side.CLIENT) public void registerModel(Item item, IModelManager manager) { - for (final EnumFlowerColor c : EnumFlowerColor.values()) { + for (EnumFlowerColor c : EnumFlowerColor.values()) { manager.registerItemModel(item, c.ordinal()); } } @@ -90,7 +90,7 @@ public class BlockCeramic extends Block implements IColoredBlock, IItemModelRegi @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(final Item item, final CreativeTabs tab, final NonNullList itemList) { + public void getSubBlocks(Item item, CreativeTabs tab, NonNullList itemList) { for (EnumFlowerColor c : EnumFlowerColor.values()) { itemList.add(new ItemStack(item, 1, c.getFlowerColorAllele().getID())); } diff --git a/src/main/java/binnie/botany/ceramic/BlockCeramicPatterned.java b/src/main/java/binnie/botany/ceramic/BlockCeramicPatterned.java index d3e52610..acd63776 100644 --- a/src/main/java/binnie/botany/ceramic/BlockCeramicPatterned.java +++ b/src/main/java/binnie/botany/ceramic/BlockCeramicPatterned.java @@ -14,19 +14,19 @@ import binnie.extratrees.carpentry.ModuleCarpentry; public class BlockCeramicPatterned extends BlockDesign { public BlockCeramicPatterned() { super(CeramicDesignSystem.instance, Material.ROCK); - this.setHardness(1.0f); - this.setResistance(5.0f); - this.setCreativeTab(CreativeTabBotany.instance); - this.setRegistryName("ceramicPattern"); + setHardness(1.0f); + setResistance(5.0f); + setCreativeTab(CreativeTabBotany.instance); + setRegistryName("ceramicPattern"); } @Override - public ItemStack getCreativeStack(final IDesign design) { + public ItemStack getCreativeStack(IDesign design) { return ModuleCarpentry.getItemStack(this, CeramicColor.get(EnumFlowerColor.White), CeramicColor.get(EnumFlowerColor.Black), design); } @Override - public String getBlockName(final DesignBlock design) { + public String getBlockName(DesignBlock design) { return I18N.localise("botany.ceramic.block.name", design.getDesign().getName()); } } diff --git a/src/main/java/binnie/botany/ceramic/BlockStainedGlass.java b/src/main/java/binnie/botany/ceramic/BlockStainedGlass.java index de22b64c..9cec2f06 100644 --- a/src/main/java/binnie/botany/ceramic/BlockStainedGlass.java +++ b/src/main/java/binnie/botany/ceramic/BlockStainedGlass.java @@ -1,6 +1,7 @@ package binnie.botany.ceramic; import javax.annotation.Nullable; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Random; @@ -44,17 +45,17 @@ import binnie.core.util.I18N; public class BlockStainedGlass extends Block implements IBlockMetadata, IColoredBlock, IItemModelRegister { public BlockStainedGlass() { super(Material.GLASS); - this.setCreativeTab(CreativeTabBotany.instance); - this.setRegistryName("stained"); - this.setSoundType(SoundType.GLASS); - this.setHardness(0.3F); + setCreativeTab(CreativeTabBotany.instance); + setRegistryName("stained"); + setSoundType(SoundType.GLASS); + setHardness(0.3F); } @Override - public int quantityDropped(final Random rand) { + public int quantityDropped(Random rand) { return 0; } - + @Override public boolean isOpaqueCube(IBlockState state) { return false; @@ -81,22 +82,22 @@ public class BlockStainedGlass extends Block implements IBlockMetadata, IColored Block block = iblockstate.getBlock(); return block != this; } - + @Override public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack stack) { player.addStat(StatList.getBlockStats(this)); player.addExhaustion(0.005F); - + if (EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, stack) > 0 && te instanceof TileEntityMetadata) { - java.util.List items = new java.util.ArrayList<>(); + List items = new ArrayList<>(); TileEntityMetadata tile = (TileEntityMetadata) te; int damage = getDroppedMeta(state, tile.getTileMetadata()); ItemStack itemstack = TileEntityMetadata.getItemStack(this, damage); - + if (!itemstack.isEmpty()) { items.add(itemstack); } - + ForgeEventFactory.fireBlockHarvesting(items, worldIn, pos, state, 0, 1.0f, true, player); for (ItemStack item : items) { spawnAsEntity(worldIn, pos, item); @@ -110,7 +111,7 @@ public class BlockStainedGlass extends Block implements IBlockMetadata, IColored } @Override - public TileEntity createNewTileEntity(final World var1, final int i) { + public TileEntity createNewTileEntity(World var1, int i) { return new TileEntityMetadata(); } @@ -126,7 +127,7 @@ public class BlockStainedGlass extends Block implements IBlockMetadata, IColored } @Override - public int getPlacedMeta(final ItemStack stack, final World world, final BlockPos pos, final EnumFacing clickedBlock) { + public int getPlacedMeta(ItemStack stack, World world, BlockPos pos, EnumFacing clickedBlock) { return TileEntityMetadata.getItemDamage(stack); } @@ -136,13 +137,13 @@ public class BlockStainedGlass extends Block implements IBlockMetadata, IColored } @Override - public String getDisplayName(final ItemStack itemStack) { + public String getDisplayName(ItemStack itemStack) { EnumFlowerColor color = EnumFlowerColor.get(TileEntityMetadata.getItemDamage(itemStack)); return I18N.localise("botany.pigmented.glass.name", color.getDisplayName()); } @Override - public void getSubBlocks(final Item itemIn, final CreativeTabs tab, final NonNullList itemList) { + public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList itemList) { for (EnumFlowerColor color : EnumFlowerColor.values()) { itemList.add(TileEntityMetadata.getItemStack(this, color.ordinal())); } diff --git a/src/main/java/binnie/botany/ceramic/CeramicColor.java b/src/main/java/binnie/botany/ceramic/CeramicColor.java index 330a7c77..28b79511 100644 --- a/src/main/java/binnie/botany/ceramic/CeramicColor.java +++ b/src/main/java/binnie/botany/ceramic/CeramicColor.java @@ -14,24 +14,24 @@ public class CeramicColor implements IDesignMaterial { private final static Map map = new LinkedHashMap<>(); static { - for (final EnumFlowerColor c : EnumFlowerColor.values()) { + for (EnumFlowerColor c : EnumFlowerColor.values()) { CeramicColor.map.put(c, new CeramicColor(c)); } } EnumFlowerColor color; - CeramicColor(final EnumFlowerColor color) { + CeramicColor(EnumFlowerColor color) { this.color = color; } - public static CeramicColor get(final EnumFlowerColor c) { + public static CeramicColor get(EnumFlowerColor c) { return CeramicColor.map.get(c); } @Override public ItemStack getStack() { - return TileEntityMetadata.getItemStack(Botany.ceramic, this.color.ordinal()); + return TileEntityMetadata.getItemStack(Botany.ceramic, color.ordinal()); } @Override @@ -41,11 +41,11 @@ public class CeramicColor implements IDesignMaterial { @Override public String getDesignMaterialName() { - return this.color.getName(); + return color.getName(); } @Override public int getColour() { - return this.color.getFlowerColorAllele().getColor(false); + return color.getFlowerColorAllele().getColor(false); } } diff --git a/src/main/java/binnie/botany/ceramic/CeramicDesignSystem.java b/src/main/java/binnie/botany/ceramic/CeramicDesignSystem.java index 46f3852e..e73497dd 100644 --- a/src/main/java/binnie/botany/ceramic/CeramicDesignSystem.java +++ b/src/main/java/binnie/botany/ceramic/CeramicDesignSystem.java @@ -30,8 +30,8 @@ public class CeramicDesignSystem implements IDesignSystem { Map secondary; CeramicDesignSystem() { - this.primary = new HashMap<>(); - this.secondary = new HashMap<>(); + primary = new HashMap<>(); + secondary = new HashMap<>(); DesignerManager.instance.registerDesignSystem(this); } @@ -46,12 +46,12 @@ public class CeramicDesignSystem implements IDesignSystem { } @Override - public IDesignMaterial getMaterial(final int id) { + public IDesignMaterial getMaterial(int id) { return CeramicColor.get(EnumFlowerColor.get(id)); } @Override - public int getMaterialIndex(final IDesignMaterial id) { + public int getMaterialIndex(IDesignMaterial id) { return ((CeramicColor) id).color.ordinal(); } @@ -64,7 +64,7 @@ public class CeramicDesignSystem implements IDesignSystem { @SideOnly(Side.CLIENT) public TextureAtlasSprite getPrimarySprite(IPattern pattern) { if (pattern instanceof EnumPattern) { - return this.primary.get(((EnumPattern) pattern).ordinal()); + return primary.get(((EnumPattern) pattern).ordinal()); } return null; } @@ -74,7 +74,7 @@ public class CeramicDesignSystem implements IDesignSystem { @SideOnly(Side.CLIENT) public TextureAtlasSprite getSecondarySprite(IPattern pattern) { if (pattern instanceof EnumPattern) { - return this.secondary.get(((EnumPattern) pattern).ordinal()); + return secondary.get(((EnumPattern) pattern).ordinal()); } return null; } @@ -86,8 +86,8 @@ public class CeramicDesignSystem implements IDesignSystem { for (EnumPattern pattern : EnumPattern.values()) { ResourceLocation primaryLocation = new ResourceLocation(getMod().getModID(), getTexturePath() + "/" + pattern.toString().toLowerCase() + ".0"); ResourceLocation secondaryLocation = new ResourceLocation(getMod().getModID(), getTexturePath() + "/" + pattern.toString().toLowerCase() + ".1"); - this.primary.put(pattern.ordinal(), textureMap.registerSprite(primaryLocation)); - this.secondary.put(pattern.ordinal(), textureMap.registerSprite(secondaryLocation)); + primary.put(pattern.ordinal(), textureMap.registerSprite(primaryLocation)); + secondary.put(pattern.ordinal(), textureMap.registerSprite(secondaryLocation)); } } @@ -97,12 +97,14 @@ public class CeramicDesignSystem implements IDesignSystem { @Override public ItemStack getAdhesive() { - return BotanyItems.Mortar.get(1); + return BotanyItems.MORTAR.get(1); } @Override @Nullable - public IDesignMaterial getMaterial(final ItemStack itemStack) { - return (itemStack.getItem() == Item.getItemFromBlock(Botany.ceramic)) ? this.getMaterial(itemStack.getItemDamage()) : null; + public IDesignMaterial getMaterial(ItemStack itemStack) { + return (itemStack.getItem() == Item.getItemFromBlock(Botany.ceramic)) + ? getMaterial(itemStack.getItemDamage()) + : null; } } diff --git a/src/main/java/binnie/botany/ceramic/CeramicTileRecipe.java b/src/main/java/binnie/botany/ceramic/CeramicTileRecipe.java index 21035f5a..17b5db57 100644 --- a/src/main/java/binnie/botany/ceramic/CeramicTileRecipe.java +++ b/src/main/java/binnie/botany/ceramic/CeramicTileRecipe.java @@ -19,25 +19,25 @@ public class CeramicTileRecipe implements IRecipe { private ItemStack cached = ItemStack.EMPTY; @Override - public boolean matches(final InventoryCrafting inv, final World world) { - this.cached = this.getCraftingResult(inv); - return !this.cached.isEmpty(); + public boolean matches(InventoryCrafting inv, World world) { + cached = getCraftingResult(inv); + return !cached.isEmpty(); } @Override - public ItemStack getCraftingResult(final InventoryCrafting inv) { - final Item ceramicBlock = Item.getItemFromBlock(Botany.ceramic); - final Item ceramicTile = Item.getItemFromBlock(Botany.ceramicTile); - final Item ceramicBrick = Item.getItemFromBlock(Botany.ceramicBrick); - final Item mortar = Botany.misc; - final List stacks = new ArrayList<>(); + public ItemStack getCraftingResult(InventoryCrafting inv) { + Item ceramicBlock = Item.getItemFromBlock(Botany.ceramic); + Item ceramicTile = Item.getItemFromBlock(Botany.ceramicTile); + Item ceramicBrick = Item.getItemFromBlock(Botany.ceramicBrick); + Item mortar = Botany.misc; + List stacks = new ArrayList<>(); int ix = -1; int iy = -1; for (int i = 0; i < inv.getSizeInventory(); ++i) { - final ItemStack stack = inv.getStackInSlot(i); + ItemStack stack = inv.getStackInSlot(i); if (!stack.isEmpty()) { - final int x = i / 3; - final int y = i % 3; + int x = i / 3; + int y = i % 3; if (ix == -1) { ix = x; iy = y; @@ -67,7 +67,7 @@ public class CeramicTileRecipe implements IRecipe { @Override public ItemStack getRecipeOutput() { - return this.cached; + return cached; } @Override diff --git a/src/main/java/binnie/botany/ceramic/ItemCeramic.java b/src/main/java/binnie/botany/ceramic/ItemCeramic.java index 05246c76..56c41c1b 100644 --- a/src/main/java/binnie/botany/ceramic/ItemCeramic.java +++ b/src/main/java/binnie/botany/ceramic/ItemCeramic.java @@ -17,7 +17,7 @@ public class ItemCeramic extends ItemBlock implements IColoredItem { } @Override - public int getMetadata(final int metadata) { + public int getMetadata(int metadata) { return metadata; } diff --git a/src/main/java/binnie/botany/ceramic/PigmentRecipe.java b/src/main/java/binnie/botany/ceramic/PigmentRecipe.java index c300138d..b5af86af 100644 --- a/src/main/java/binnie/botany/ceramic/PigmentRecipe.java +++ b/src/main/java/binnie/botany/ceramic/PigmentRecipe.java @@ -14,8 +14,8 @@ import binnie.botany.api.IFlower; public class PigmentRecipe implements IRecipe { @Override - public boolean matches(final InventoryCrafting crafting, final World world) { - return !this.getCraftingResult(crafting).isEmpty(); + public boolean matches(InventoryCrafting crafting, World world) { + return !getCraftingResult(crafting).isEmpty(); } @Override @@ -24,7 +24,7 @@ public class PigmentRecipe implements IRecipe { } @Override - public ItemStack getCraftingResult(final InventoryCrafting crafting) { + public ItemStack getCraftingResult(InventoryCrafting crafting) { int n = 0; ItemStack stack = ItemStack.EMPTY; for (int i = 0; i < crafting.getSizeInventory(); ++i) { @@ -34,7 +34,7 @@ public class PigmentRecipe implements IRecipe { return ItemStack.EMPTY; } if (Binnie.GENETICS.getFlowerRoot().isMember(stackInSlot)) { - final IFlower flower = Binnie.GENETICS.getFlowerRoot().getMember(stackInSlot); + IFlower flower = Binnie.GENETICS.getFlowerRoot().getMember(stackInSlot); if (flower != null && flower.getAge() >= 1) { stack = new ItemStack(Botany.pigment, 1, flower.getGenome().getPrimaryColor().getID()); } diff --git a/src/main/java/binnie/botany/ceramic/brick/BlockCeramicBrick.java b/src/main/java/binnie/botany/ceramic/brick/BlockCeramicBrick.java index ea778d7d..a25e88f3 100644 --- a/src/main/java/binnie/botany/ceramic/brick/BlockCeramicBrick.java +++ b/src/main/java/binnie/botany/ceramic/brick/BlockCeramicBrick.java @@ -66,10 +66,10 @@ public class BlockCeramicBrick extends Block implements IMultipassBlock itemList) { - for (final EnumFlowerColor color : EnumFlowerColor.values()) { - itemList.add(new CeramicBrickPair(color, color, CeramicBrickType.Tile).getStack(1)); + public void getSubBlocks(Item item, CreativeTabs tab, NonNullList itemList) { + for (EnumFlowerColor color : EnumFlowerColor.values()) { + itemList.add(new CeramicBrickPair(color, color, CeramicBrickType.TILE).getStack(1)); } for (CeramicBrickType type : CeramicBrickType.VALUES) { if (type.canDouble()) { itemList.add(new CeramicBrickPair(EnumFlowerColor.Brown, EnumFlowerColor.Gold, type).getStack(1)); } } - itemList.add(new CeramicBrickPair(EnumFlowerColor.Gold, EnumFlowerColor.Gold, CeramicBrickType.Split).getStack(1)); - itemList.add(new CeramicBrickPair(EnumFlowerColor.Brown, EnumFlowerColor.Brown, CeramicBrickType.Chequered).getStack(1)); - itemList.add(new CeramicBrickPair(EnumFlowerColor.Gold, EnumFlowerColor.Brown, CeramicBrickType.LargeBrick).getStack(1)); + itemList.add(new CeramicBrickPair(EnumFlowerColor.Gold, EnumFlowerColor.Gold, CeramicBrickType.SPLIT).getStack(1)); + itemList.add(new CeramicBrickPair(EnumFlowerColor.Brown, EnumFlowerColor.Brown, CeramicBrickType.CHEQUERED).getStack(1)); + itemList.add(new CeramicBrickPair(EnumFlowerColor.Gold, EnumFlowerColor.Brown, CeramicBrickType.LARGE_BRICK).getStack(1)); } @SideOnly(Side.CLIENT) @@ -125,9 +125,10 @@ public class BlockCeramicBrick extends Block implements IMultipassBlock(BlockCeramicBrick.class), this + new ModelResourceLocation(resourceLocation, "normal"), + new ModelResourceLocation(resourceLocation, "inventory"), + new ModelMutlipass<>(BlockCeramicBrick.class), + this )); } @@ -139,7 +140,14 @@ public class BlockCeramicBrick extends Block implements IMultipassBlock> 8 & 0xFF); - this.type = CeramicBrickType.get(id >> 16 & 0xFF); + colorFirst = EnumFlowerColor.get(id & 0xFF); + colorSecond = EnumFlowerColor.get(id >> 8 & 0xFF); + type = CeramicBrickType.get(id >> 16 & 0xFF); } public boolean isTwoColors() { - return this.type.canDouble() && this.colorSecond != this.colorFirst; + return type.canDouble() && colorSecond != colorFirst; } public ItemStack getStack(int i) { - return new ItemStack(Botany.ceramicBrick, i, this.ordinal()); + return new ItemStack(Botany.ceramicBrick, i, ordinal()); } public String getName() { - String name = this.colorFirst.getFlowerColorAllele().getColorName(); - if (this.type.canDouble() && this.colorSecond != this.colorFirst) { - name = name + " & " + this.colorSecond.getFlowerColorAllele().getColorName(); + String name = colorFirst.getFlowerColorAllele().getColorName(); + if (type.canDouble() && colorSecond != colorFirst) { + name = name + " & " + colorSecond.getFlowerColorAllele().getColorName(); } return I18N.localise("botany.ceramic.type." + type.id + ".name", name); } @@ -58,7 +59,7 @@ public class CeramicBrickPair { @SideOnly(Side.CLIENT) public TextureAtlasSprite getSprite(int pass) { - TextureAtlasSprite[] sprites = this.type.sprites; + TextureAtlasSprite[] sprites = type.sprites; Preconditions.checkState(sprites != null, "Sprites have not been registered."); return sprites[pass]; } @@ -71,6 +72,6 @@ public class CeramicBrickPair { @Override public boolean equals(Object obj) { return obj instanceof CeramicBrickPair - && ((CeramicBrickPair) obj).ordinal() == ordinal(); + && ((CeramicBrickPair) obj).ordinal() == ordinal(); } } diff --git a/src/main/java/binnie/botany/ceramic/brick/CeramicBrickType.java b/src/main/java/binnie/botany/ceramic/brick/CeramicBrickType.java index 1ec6508d..c2f0302c 100644 --- a/src/main/java/binnie/botany/ceramic/brick/CeramicBrickType.java +++ b/src/main/java/binnie/botany/ceramic/brick/CeramicBrickType.java @@ -2,7 +2,6 @@ package binnie.botany.ceramic.brick; import javax.annotation.Nullable; import java.util.List; -import java.util.Locale; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.item.Item; @@ -18,7 +17,7 @@ import binnie.botany.items.BotanyItems; import binnie.core.block.TileEntityMetadata; public enum CeramicBrickType implements IStringSerializable { - Tile("tile") { + TILE("tile") { @Override public ItemStack getRecipe(List stacks) { if (stacks.size() != 4) { @@ -27,15 +26,15 @@ public enum CeramicBrickType implements IStringSerializable { int mortars = 0; int blocks = 0; int blockColor = -1; - for (final ItemStack stack : stacks) { - if (this.isMortar(stack)) { + for (ItemStack stack : stacks) { + if (isMortar(stack)) { ++mortars; } else { if (stack.getItem() != Item.getItemFromBlock(Botany.ceramic)) { return ItemStack.EMPTY; } ++blocks; - final int color = TileEntityMetadata.getItemDamage(stack); + int color = TileEntityMetadata.getItemDamage(stack); if (blockColor == -1) { blockColor = color; } else { @@ -48,29 +47,29 @@ public enum CeramicBrickType implements IStringSerializable { if (mortars != 1) { return ItemStack.EMPTY; } - final EnumFlowerColor c = EnumFlowerColor.get(blockColor); - return new CeramicBrickPair(c, c, CeramicBrickType.Tile).getStack(3); + EnumFlowerColor c = EnumFlowerColor.get(blockColor); + return new CeramicBrickPair(c, c, CeramicBrickType.TILE).getStack(3); } }, - Brick("brick") { + BRICK("brick") { @Override public ItemStack getRecipe(List stacks) { return getBrickRecipe(this, stacks); } }, - StripeBrick("brickstripe") { + STRIPE_BRICK("brickstripe") { @Override public ItemStack getRecipe(List stacks) { return getBrickRecipe(this, stacks); } }, - LargeBrick("bricklarge") { + LARGE_BRICK("bricklarge") { @Override public ItemStack getRecipe(List stacks) { if (stacks.size() == 1) { - final ItemStack stack3 = stacks.get(0); - final CeramicBrickPair type3 = new CeramicBrickPair(stack3); - if (type3.type == CeramicBrickType.VerticalLargeBrick) { + ItemStack stack3 = stacks.get(0); + CeramicBrickPair type3 = new CeramicBrickPair(stack3); + if (type3.type == CeramicBrickType.VERTICAL_LARGE_BRICK) { type3.type = this; return type3.getStack(1); } @@ -79,58 +78,58 @@ public enum CeramicBrickType implements IStringSerializable { if (stacks.size() != 3) { return ItemStack.EMPTY; } - final int[] colors = {-1, -1}; + int[] colors = {-1, -1}; int a = 0; int b = 0; - for (final ItemStack stack4 : stacks) { + for (ItemStack stack4 : stacks) { if (stack4.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) { return ItemStack.EMPTY; } - final CeramicBrickPair type4 = new CeramicBrickPair(stack4); - if (type4.type != CeramicBrickType.Tile) { + CeramicBrickPair type4 = new CeramicBrickPair(stack4); + if (type4.type != CeramicBrickType.TILE) { return ItemStack.EMPTY; } - final int color5 = type4.colorFirst.ordinal(); + int color5 = type4.colorFirst.ordinal(); if (colors[0] == -1) { colors[0] = color5; - ++a; + a++; } else if (colors[0] == color5) { - ++a; + a++; } else if (colors[1] == -1) { colors[1] = color5; - ++b; + b++; } else { if (colors[1] != color5) { return ItemStack.EMPTY; } - ++b; + b++; } } if (colors[1] == -1) { colors[1] = colors[0]; } - return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), CeramicBrickType.LargeBrick).getStack(3); + return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), CeramicBrickType.LARGE_BRICK).getStack(3); } } }, - Split("split") { + SPLIT("split") { @Override public ItemStack getRecipe(List stacks) { if (stacks.size() != 4) { return ItemStack.EMPTY; } - final int[] colors = {-1, -1}; + int[] colors = {-1, -1}; int altCounter = 0; - for (final ItemStack stack2 : stacks) { - final int alt = (altCounter != 0 && altCounter != 3) ? 1 : 0; + for (ItemStack stack2 : stacks) { + int alt = (altCounter != 0 && altCounter != 3) ? 1 : 0; if (stack2.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) { return ItemStack.EMPTY; } - final CeramicBrickPair type = new CeramicBrickPair(stack2); - if (type.type != CeramicBrickType.Tile) { + CeramicBrickPair type = new CeramicBrickPair(stack2); + if (type.type != CeramicBrickType.TILE) { return ItemStack.EMPTY; } - final int color2 = type.colorFirst.ordinal(); + int color2 = type.colorFirst.ordinal(); if (colors[alt] == -1) { colors[alt] = color2; } else if (colors[alt] != color2) { @@ -138,26 +137,26 @@ public enum CeramicBrickType implements IStringSerializable { } ++altCounter; } - return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), CeramicBrickType.Split).getStack(4); + return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), CeramicBrickType.SPLIT).getStack(4); } }, - Chequered("cheque") { + CHEQUERED("cheque") { @Override public ItemStack getRecipe(List stacks) { if (stacks.size() != 4) { return ItemStack.EMPTY; } - final int[] colors = {-1, -1}; - for (final ItemStack stack2 : stacks) { + int[] colors = {-1, -1}; + for (ItemStack stack2 : stacks) { if (stack2.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) { return ItemStack.EMPTY; } - final CeramicBrickPair type2 = new CeramicBrickPair(stack2); - if (type2.type != CeramicBrickType.Split) { + CeramicBrickPair type2 = new CeramicBrickPair(stack2); + if (type2.type != CeramicBrickType.SPLIT) { return ItemStack.EMPTY; } - final int color3 = type2.colorFirst.ordinal(); - final int color4 = type2.colorSecond.ordinal(); + int color3 = type2.colorFirst.ordinal(); + int color4 = type2.colorSecond.ordinal(); if (colors[0] == -1) { colors[0] = color3; colors[1] = color4; @@ -167,32 +166,32 @@ public enum CeramicBrickType implements IStringSerializable { } } } - return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), CeramicBrickType.Chequered).getStack(4); + return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), CeramicBrickType.CHEQUERED).getStack(4); } }, - Mixed("mixed") { + MIXED("mixed") { @Override public ItemStack getRecipe(List stacks) { if (stacks.size() != 4) { return ItemStack.EMPTY; } - final int[] colors = {-1, -1}; - for (final ItemStack stack2 : stacks) { + int[] colors = {-1, -1}; + for (ItemStack stack2 : stacks) { if (stack2.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) { return ItemStack.EMPTY; } - final CeramicBrickPair type2 = new CeramicBrickPair(stack2); + CeramicBrickPair type2 = new CeramicBrickPair(stack2); if (type2.isTwoColors()) { return ItemStack.EMPTY; } - final int color3 = type2.colorFirst.ordinal(); - if (type2.type == CeramicBrickType.Split) { + int color3 = type2.colorFirst.ordinal(); + if (type2.type == CeramicBrickType.SPLIT) { if (colors[1] != -1) { return ItemStack.EMPTY; } colors[1] = color3; } else { - if (type2.type != CeramicBrickType.Chequered) { + if (type2.type != CeramicBrickType.CHEQUERED) { return ItemStack.EMPTY; } if (colors[0] == -1) { @@ -201,27 +200,27 @@ public enum CeramicBrickType implements IStringSerializable { return ItemStack.EMPTY; } } - final int color4 = type2.colorSecond.ordinal(); + int color4 = type2.colorSecond.ordinal(); } if (colors[0] == -1 || colors[1] == -1) { return ItemStack.EMPTY; } - return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), CeramicBrickType.Mixed).getStack(4); + return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), CeramicBrickType.MIXED).getStack(4); } }, - VerticalBrick("verticalbrick") { + VERTICAL_BRICK("verticalbrick") { @Override public ItemStack getRecipe(List stacks) { return getVerticalBrickRecipe(stacks); } }, - VerticalStripeBrick("verticalbrickstripe") { + VERTICAL_STRIPE_BRICK("verticalbrickstripe") { @Override public ItemStack getRecipe(List stacks) { return getVerticalBrickRecipe(stacks); } }, - VerticalLargeBrick("verticalbricklarge") { + VERTICAL_LARGE_BRICK("verticalbricklarge") { @Override public ItemStack getRecipe(List stacks) { return getVerticalBrickRecipe(stacks); @@ -230,7 +229,7 @@ public enum CeramicBrickType implements IStringSerializable { public static final CeramicBrickType[] VALUES = values(); - String id; + public String id; @SideOnly(Side.CLIENT) @Nullable @@ -240,12 +239,12 @@ public enum CeramicBrickType implements IStringSerializable { this.id = id; } - public static CeramicBrickType get(final int id) { + public static CeramicBrickType get(int id) { return VALUES[id % VALUES.length]; } public boolean canDouble() { - return this != CeramicBrickType.Tile; + return this != CeramicBrickType.TILE; } public abstract ItemStack getRecipe(List stacks); @@ -254,18 +253,20 @@ public enum CeramicBrickType implements IStringSerializable { if (stacks.size() != 1) { return ItemStack.EMPTY; } - final ItemStack stack5 = stacks.get(0); - final CeramicBrickPair type = new CeramicBrickPair(stack5); - if (type.type == CeramicBrickType.LargeBrick) { - type.type = CeramicBrickType.VerticalLargeBrick; + ItemStack stack5 = stacks.get(0); + CeramicBrickPair type = new CeramicBrickPair(stack5); + if (type.type == CeramicBrickType.LARGE_BRICK) { + type.type = CeramicBrickType.VERTICAL_LARGE_BRICK; return type.getStack(1); } - if (type.type == CeramicBrickType.Brick) { - type.type = CeramicBrickType.VerticalBrick; + + if (type.type == CeramicBrickType.BRICK) { + type.type = CeramicBrickType.VERTICAL_BRICK; return type.getStack(1); } - if (type.type == CeramicBrickType.StripeBrick) { - type.type = CeramicBrickType.VerticalStripeBrick; + + if (type.type == CeramicBrickType.STRIPE_BRICK) { + type.type = CeramicBrickType.VERTICAL_STRIPE_BRICK; return type.getStack(1); } return ItemStack.EMPTY; @@ -273,34 +274,38 @@ public enum CeramicBrickType implements IStringSerializable { protected ItemStack getBrickRecipe(CeramicBrickType ceramicType, List stacks) { if (stacks.size() == 1) { - final ItemStack stack5 = stacks.get(0); - final CeramicBrickPair type = new CeramicBrickPair(stack5); - if (type.type == CeramicBrickType.VerticalBrick) { + ItemStack stack5 = stacks.get(0); + CeramicBrickPair type = new CeramicBrickPair(stack5); + if (type.type == CeramicBrickType.VERTICAL_BRICK) { type.type = ceramicType; return type.getStack(1); } - if (type.type == CeramicBrickType.StripeBrick) { + + if (type.type == CeramicBrickType.STRIPE_BRICK) { type.type = ceramicType; return type.getStack(1); } return ItemStack.EMPTY; } else if (stacks.size() == 4) { - final int[] colors = {-1, -1}; + int[] colors = {-1, -1}; for (int index2 = 0; index2 < stacks.size(); ++index2) { - final ItemStack stack4 = stacks.get(index2); + ItemStack stack4 = stacks.get(index2); if (stack4.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) { return ItemStack.EMPTY; } - final CeramicBrickPair type4 = new CeramicBrickPair(stack4); - if (type4.type != CeramicBrickType.LargeBrick) { + + CeramicBrickPair type4 = new CeramicBrickPair(stack4); + if (type4.type != CeramicBrickType.LARGE_BRICK) { return ItemStack.EMPTY; } - final int color5 = type4.colorFirst.ordinal(); - final int color6 = type4.colorSecond.ordinal(); + + int color5 = type4.colorFirst.ordinal(); + int color6 = type4.colorSecond.ordinal(); int alt2 = (index2 != 0 && index2 != 3) ? 1 : 0; - if (ceramicType == CeramicBrickType.StripeBrick) { + if (ceramicType == CeramicBrickType.STRIPE_BRICK) { alt2 = 0; } + if (colors[alt2] == -1) { colors[alt2] = color5; colors[1 - alt2] = color6; @@ -309,17 +314,16 @@ public enum CeramicBrickType implements IStringSerializable { } } return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), ceramicType).getStack(4); - } else { - return ItemStack.EMPTY; } + return ItemStack.EMPTY; } - protected boolean isMortar(final ItemStack stack) { - return stack.getItem() == Botany.misc && stack.getItemDamage() == BotanyItems.Mortar.ordinal(); + protected boolean isMortar(ItemStack stack) { + return stack.getItem() == Botany.misc && stack.getItemDamage() == BotanyItems.MORTAR.ordinal(); } @Override public String getName() { - return name().toLowerCase(Locale.ENGLISH); + return id; } } diff --git a/src/main/java/binnie/botany/ceramic/brick/ItemCeramicBrick.java b/src/main/java/binnie/botany/ceramic/brick/ItemCeramicBrick.java index 9c2146c7..8dc38497 100644 --- a/src/main/java/binnie/botany/ceramic/brick/ItemCeramicBrick.java +++ b/src/main/java/binnie/botany/ceramic/brick/ItemCeramicBrick.java @@ -14,7 +14,7 @@ public class ItemCeramicBrick extends ItemBlock implements IColoredItem { } @Override - public int getMetadata(final int metadata) { + public int getMetadata(int metadata) { return metadata; } diff --git a/src/main/java/binnie/botany/ceramic/brick/TileCeramicBrick.java b/src/main/java/binnie/botany/ceramic/brick/TileCeramicBrick.java index 83fc1af2..7048739e 100644 --- a/src/main/java/binnie/botany/ceramic/brick/TileCeramicBrick.java +++ b/src/main/java/binnie/botany/ceramic/brick/TileCeramicBrick.java @@ -18,17 +18,17 @@ public class TileCeramicBrick extends TileEntity { } public boolean hasTwoColors() { - return CeramicBrickType.VALUES[getBlockMetadata()].canDouble() && this.colorSecond != this.colorFirst; + return CeramicBrickType.VALUES[getBlockMetadata()].canDouble() && colorSecond != colorFirst; } - public ItemStack getStack(final int i) { - final ItemStack s = TileEntityMetadata.getItemStack(Botany.ceramicBrick, this.ordinal()); + public ItemStack getStack(int i) { + ItemStack s = TileEntityMetadata.getItemStack(Botany.ceramicBrick, ordinal()); s.setCount(i); return s; } public int ordinal() { - return this.colorFirst.ordinal() + this.colorSecond.ordinal() * 256 + getBlockMetadata() * 256 * 256; + return colorFirst.ordinal() + colorSecond.ordinal() * 256 + getBlockMetadata() * 256 * 256; } public CeramicBrickPair pair() { @@ -61,6 +61,7 @@ public class TileCeramicBrick extends TileEntity { if (compound.hasKey("First")) { colorFirst = EnumFlowerColor.VALUES[compound.getInteger("First")]; } + if (compound.hasKey("Second")) { colorSecond = EnumFlowerColor.VALUES[compound.getInteger("Second")]; } diff --git a/src/main/java/binnie/botany/core/BotanyCore.java b/src/main/java/binnie/botany/core/BotanyCore.java index 10c52a95..b30389ea 100644 --- a/src/main/java/binnie/botany/core/BotanyCore.java +++ b/src/main/java/binnie/botany/core/BotanyCore.java @@ -15,8 +15,8 @@ public class BotanyCore { } return FlowerManager.flowerRoot; } - - public static IGardeningManager getGardening(){ + + public static IGardeningManager getGardening() { if (FlowerManager.gardening == null) { FlowerManager.gardening = new Gardening(); } diff --git a/src/main/java/binnie/botany/core/BotanyGUI.java b/src/main/java/binnie/botany/core/BotanyGUI.java index aeef3fae..e56dd489 100644 --- a/src/main/java/binnie/botany/core/BotanyGUI.java +++ b/src/main/java/binnie/botany/core/BotanyGUI.java @@ -13,21 +13,21 @@ import binnie.core.craftgui.minecraft.Window; import binnie.core.gui.IBinnieGUID; public enum BotanyGUI implements IBinnieGUID { - Database, - DatabaseNEI; + DATABASE, + DATABASE_NEI; @Override - public Window getWindow(final EntityPlayer player, final World world, final int x, final int y, final int z, final Side side) { + public Window getWindow(EntityPlayer player, World world, int x, int y, int z, Side side) { Window window = null; - final TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z)); + TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z)); IInventory object = null; if (tileEntity instanceof IInventory) { object = (IInventory) tileEntity; } switch (this) { - case Database: - case DatabaseNEI: { - window = WindowBotanistDatabase.create(player, side, this != BotanyGUI.Database); + case DATABASE: + case DATABASE_NEI: { + window = WindowBotanistDatabase.create(player, side, this != BotanyGUI.DATABASE); break; } } diff --git a/src/main/java/binnie/botany/core/BotanyTexture.java b/src/main/java/binnie/botany/core/BotanyTexture.java index c2782eb5..57538892 100644 --- a/src/main/java/binnie/botany/core/BotanyTexture.java +++ b/src/main/java/binnie/botany/core/BotanyTexture.java @@ -11,6 +11,7 @@ import binnie.core.resource.BinnieResource; import binnie.core.resource.IBinnieTexture; import binnie.core.resource.ResourceType; +// TODO unused enum? public enum BotanyTexture implements IBinnieTexture { ; String texture; @@ -20,16 +21,16 @@ public enum BotanyTexture implements IBinnieTexture { @Nullable private BinnieResource resource; - BotanyTexture(final ResourceType base, final String texture) { + BotanyTexture(ResourceType base, String texture) { this.texture = texture; - this.type = base; + type = base; } @Override @SideOnly(Side.CLIENT) public BinnieResource getTexture() { if (resource == null) { - resource = Binnie.RESOURCE.getPNG(Botany.instance, this.type, this.texture); + resource = Binnie.RESOURCE.getPNG(Botany.instance, type, texture); } return resource; } diff --git a/src/main/java/binnie/botany/core/ModuleCore.java b/src/main/java/binnie/botany/core/ModuleCore.java index 8377db43..9498a1e7 100644 --- a/src/main/java/binnie/botany/core/ModuleCore.java +++ b/src/main/java/binnie/botany/core/ModuleCore.java @@ -5,13 +5,16 @@ import binnie.core.IInitializable; public class ModuleCore implements IInitializable { @Override public void preInit() { + // ignored } @Override public void init() { + // ignored } @Override public void postInit() { + // ignored } } diff --git a/src/main/java/binnie/botany/craftgui/ControlColorDisplay.java b/src/main/java/binnie/botany/craftgui/ControlColorDisplay.java index 1721d438..279548bf 100644 --- a/src/main/java/binnie/botany/craftgui/ControlColorDisplay.java +++ b/src/main/java/binnie/botany/craftgui/ControlColorDisplay.java @@ -3,7 +3,7 @@ package binnie.botany.craftgui; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import binnie.botany.api.IFlowerColour; +import binnie.botany.api.IFlowerColor; import binnie.core.craftgui.Attribute; import binnie.core.craftgui.ITooltip; import binnie.core.craftgui.IWidget; @@ -12,35 +12,35 @@ import binnie.core.craftgui.controls.core.Control; import binnie.core.craftgui.controls.core.IControlValue; import binnie.core.craftgui.renderer.RenderUtil; -public class ControlColorDisplay extends Control implements IControlValue, ITooltip { - private IFlowerColour value; +public class ControlColorDisplay extends Control implements IControlValue, ITooltip { + private IFlowerColor value; - public ControlColorDisplay(final IWidget parent, final int x, final int y, final IFlowerColour value) { + public ControlColorDisplay(IWidget parent, int x, int y, IFlowerColor value) { super(parent, x, y, 16, 16); this.value = value; - this.addAttribute(Attribute.MouseOver); + addAttribute(Attribute.MouseOver); } @Override - public IFlowerColour getValue() { - return this.value; + public IFlowerColor getValue() { + return value; } @Override - public void setValue(final IFlowerColour value) { + public void setValue(IFlowerColor value) { this.value = value; } @Override @SideOnly(Side.CLIENT) public void onRenderBackground(int guiWidth, int guiHeight) { - RenderUtil.drawSolidRect(this.getArea(), -1); - RenderUtil.drawSolidRect(this.getArea().inset(1), -16777216 + this.getValue().getColor(false)); + RenderUtil.drawSolidRect(getArea(), -1); + RenderUtil.drawSolidRect(getArea().inset(1), 0xff000000 + getValue().getColor(false)); } @Override - public void getTooltip(final Tooltip tooltip) { + public void getTooltip(Tooltip tooltip) { super.getTooltip(tooltip); - tooltip.add(this.value.getColorName()); + tooltip.add(value.getColorName()); } } diff --git a/src/main/java/binnie/botany/craftgui/ControlColorMixBox.java b/src/main/java/binnie/botany/craftgui/ControlColorMixBox.java index d1965f62..d6001961 100644 --- a/src/main/java/binnie/botany/craftgui/ControlColorMixBox.java +++ b/src/main/java/binnie/botany/craftgui/ControlColorMixBox.java @@ -8,18 +8,18 @@ public class ControlColorMixBox extends ControlListBox { private int index; private Type type; - public ControlColorMixBox(final IWidget parent, final int x, final int y, final int width, final int height, final Type type) { + public ControlColorMixBox(IWidget parent, int x, int y, int width, int height, Type type) { super(parent, x, y, width, height, 12); this.type = type; } @Override - public IWidget createOption(final IColorMix value, final int y) { - return new ControlColorMixItem(this.getContent(), value, y); + public IWidget createOption(IColorMix value, int y) { + return new ControlColorMixItem(getContent(), value, y); } enum Type { - Resultant, - Further, + RESULTANT, + FURTHER, } } diff --git a/src/main/java/binnie/botany/craftgui/ControlColorMixItem.java b/src/main/java/binnie/botany/craftgui/ControlColorMixItem.java index 272fd22c..687cd28e 100644 --- a/src/main/java/binnie/botany/craftgui/ControlColorMixItem.java +++ b/src/main/java/binnie/botany/craftgui/ControlColorMixItem.java @@ -11,13 +11,13 @@ public class ControlColorMixItem extends ControlOption { private final ControlColorMixSymbol addSymbol; private final ControlColorMixSymbol arrowSymbol; - public ControlColorMixItem(final ControlList controlList, final IColorMix option, final int y) { + public ControlColorMixItem(ControlList controlList, IColorMix option, int y) { super(controlList, option, y); - IColorMix value = this.getValue(); - this.itemWidget1 = new ControlColorDisplay(this, 4, 4, value.getColorFirst()); - this.itemWidget2 = new ControlColorDisplay(this, 44, 4, value.getColorSecond()); - this.itemWidget3 = new ControlColorDisplay(this, 104, 4, value.getResult()); - this.addSymbol = new ControlColorMixSymbol(this, 24, 4, 0, value); - this.arrowSymbol = new ControlColorMixSymbol(this, 64, 4, 1, value); + IColorMix value = getValue(); + itemWidget1 = new ControlColorDisplay(this, 4, 4, value.getColorFirst()); + itemWidget2 = new ControlColorDisplay(this, 44, 4, value.getColorSecond()); + itemWidget3 = new ControlColorDisplay(this, 104, 4, value.getResult()); + addSymbol = new ControlColorMixSymbol(this, 24, 4, 0, value); + arrowSymbol = new ControlColorMixSymbol(this, 64, 4, 1, value); } } diff --git a/src/main/java/binnie/botany/craftgui/ControlColorMixSymbol.java b/src/main/java/binnie/botany/craftgui/ControlColorMixSymbol.java index edcf688c..84ec414e 100644 --- a/src/main/java/binnie/botany/craftgui/ControlColorMixSymbol.java +++ b/src/main/java/binnie/botany/craftgui/ControlColorMixSymbol.java @@ -22,33 +22,33 @@ public class ControlColorMixSymbol extends Control implements ITooltip { IColorMix value; int type; - protected ControlColorMixSymbol(final IWidget parent, final int x, final int y, final int type, final IColorMix value) { + protected ControlColorMixSymbol(IWidget parent, int x, int y, int type, IColorMix value) { super(parent, x, y, 16 + type * 16, 16); this.value = value; this.type = type; - this.addAttribute(Attribute.MouseOver); + addAttribute(Attribute.MouseOver); } @Override @SideOnly(Side.CLIENT) public void onRenderBackground(int guiWidth, int guiHeight) { super.onRenderBackground(guiWidth, guiHeight); - if (this.type == 0) { + if (type == 0) { CraftGUI.render.texture(ControlColorMixSymbol.MutationPlus, Point.ZERO); } else { CraftGUI.render.texture(ControlColorMixSymbol.MutationArrow, Point.ZERO); } } - public void setValue(final IColorMix value) { + public void setValue(IColorMix value) { this.value = value; - this.setColour(0xffffff); + setColour(0xffffff); } @Override - public void getTooltip(final Tooltip tooltip) { - if (this.type == 1) { - final float chance = this.value.getChance(); + public void getTooltip(Tooltip tooltip) { + if (type == 1) { + float chance = value.getChance(); tooltip.add(I18N.localise("botany.gui.controls.color_mix_symbol.chance", chance)); } } diff --git a/src/main/java/binnie/botany/craftgui/ControlColorOption.java b/src/main/java/binnie/botany/craftgui/ControlColorOption.java index 4e9482dd..a43dfbc5 100644 --- a/src/main/java/binnie/botany/craftgui/ControlColorOption.java +++ b/src/main/java/binnie/botany/craftgui/ControlColorOption.java @@ -3,7 +3,7 @@ package binnie.botany.craftgui; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import binnie.botany.api.IFlowerColour; +import binnie.botany.api.IFlowerColor; import binnie.core.craftgui.Attribute; import binnie.core.craftgui.CraftGUI; import binnie.core.craftgui.controls.listbox.ControlList; @@ -12,21 +12,21 @@ import binnie.core.craftgui.geometry.CraftGUIUtil; import binnie.core.craftgui.geometry.Point; @SideOnly(Side.CLIENT) -public class ControlColorOption extends ControlTextOption { - ControlColorDisplay controlBee; - Point boxPosition; +public class ControlColorOption extends ControlTextOption { + private ControlColorDisplay controlBee; + private Point boxPosition; - public ControlColorOption(final ControlList controlList, final IFlowerColour option, final int y) { + public ControlColorOption(ControlList controlList, IFlowerColor option, int y) { super(controlList, option, option.getColorName(), y); - this.setSize(new Point(this.getSize().x(), 20)); - this.controlBee = new ControlColorDisplay(this, 2, 2, option); - this.addAttribute(Attribute.MouseOver); - CraftGUIUtil.moveWidget(this.textWidget, new Point(22, 0)); - this.textWidget.setSize(this.textWidget.getSize().sub(new Point(24, 0))); - final int th = CraftGUI.render.textHeight(this.textWidget.getValue(), this.textWidget.getSize().x()); - final int height = Math.max(20, th + 6); - this.setSize(new Point(this.size().x(), height)); - this.textWidget.setSize(new Point(this.textWidget.getSize().x(), height)); - this.boxPosition = new Point(2, (height - 18) / 2); + setSize(new Point(getSize().x(), 20)); + controlBee = new ControlColorDisplay(this, 2, 2, option); + addAttribute(Attribute.MouseOver); + CraftGUIUtil.moveWidget(textWidget, new Point(22, 0)); + textWidget.setSize(textWidget.getSize().sub(new Point(24, 0))); + int th = CraftGUI.render.textHeight(textWidget.getValue(), textWidget.getSize().x()); + int height = Math.max(20, th + 6); + setSize(new Point(size().x(), height)); + textWidget.setSize(new Point(textWidget.getSize().x(), height)); + boxPosition = new Point(2, (height - 18) / 2); } } diff --git a/src/main/java/binnie/botany/craftgui/PageColorMix.java b/src/main/java/binnie/botany/craftgui/PageColorMix.java index 92bc8b31..f5d156ee 100644 --- a/src/main/java/binnie/botany/craftgui/PageColorMix.java +++ b/src/main/java/binnie/botany/craftgui/PageColorMix.java @@ -4,7 +4,7 @@ import java.util.ArrayList; import java.util.List; import binnie.botany.api.IColorMix; -import binnie.botany.api.IFlowerColour; +import binnie.botany.api.IFlowerColor; import binnie.botany.core.BotanyCore; import binnie.core.craftgui.IWidget; import binnie.core.craftgui.controls.ControlText; @@ -13,24 +13,24 @@ import binnie.core.craftgui.database.DatabaseTab; import binnie.core.craftgui.database.PageAbstract; import binnie.core.util.I18N; -public class PageColorMix extends PageAbstract { +public class PageColorMix extends PageAbstract { ControlText pageSpeciesFurther_Title; ControlColorMixBox pageSpeciesFurther_List; - public PageColorMix(final IWidget parent, final DatabaseTab tab) { + public PageColorMix(IWidget parent, DatabaseTab tab) { super(parent, tab); - this.pageSpeciesFurther_Title = new ControlTextCentered(this, 8, I18N.localise("botany.gui.controls.page.color_further.title")); - this.pageSpeciesFurther_List = new ControlColorMixBox(this, 4, 20, 136, 152, ControlColorMixBox.Type.Further); + pageSpeciesFurther_Title = new ControlTextCentered(this, 8, I18N.localise("botany.gui.controls.page.color_further.title")); + pageSpeciesFurther_List = new ControlColorMixBox(this, 4, 20, 136, 152, ControlColorMixBox.Type.FURTHER); } @Override - public void onValueChanged(final IFlowerColour colour) { - final List mixes = new ArrayList<>(); - for (final IColorMix mix : BotanyCore.getFlowerRoot().getColorMixes(false)) { + public void onValueChanged(IFlowerColor colour) { + List mixes = new ArrayList<>(); + for (IColorMix mix : BotanyCore.getFlowerRoot().getColorMixes(false)) { if (mix.getColorFirst() == colour || mix.getColorSecond() == colour) { mixes.add(mix); } } - this.pageSpeciesFurther_List.setOptions(mixes); + pageSpeciesFurther_List.setOptions(mixes); } } diff --git a/src/main/java/binnie/botany/craftgui/PageColorMixResultant.java b/src/main/java/binnie/botany/craftgui/PageColorMixResultant.java index c2f03342..bffce1ce 100644 --- a/src/main/java/binnie/botany/craftgui/PageColorMixResultant.java +++ b/src/main/java/binnie/botany/craftgui/PageColorMixResultant.java @@ -4,7 +4,7 @@ import java.util.ArrayList; import java.util.List; import binnie.botany.api.IColorMix; -import binnie.botany.api.IFlowerColour; +import binnie.botany.api.IFlowerColor; import binnie.botany.core.BotanyCore; import binnie.core.craftgui.IWidget; import binnie.core.craftgui.controls.ControlText; @@ -13,24 +13,24 @@ import binnie.core.craftgui.database.DatabaseTab; import binnie.core.craftgui.database.PageAbstract; import binnie.core.util.I18N; -public class PageColorMixResultant extends PageAbstract { +public class PageColorMixResultant extends PageAbstract { ControlText pageSpeciesFurther_Title; ControlColorMixBox pageSpeciesFurther_List; - public PageColorMixResultant(final IWidget parent, final DatabaseTab tab) { + public PageColorMixResultant(IWidget parent, DatabaseTab tab) { super(parent, tab); - this.pageSpeciesFurther_Title = new ControlTextCentered(this, 8, I18N.localise("botany.gui.controls.page.species_further.title")); - this.pageSpeciesFurther_List = new ControlColorMixBox(this, 4, 20, 136, 152, ControlColorMixBox.Type.Resultant); + pageSpeciesFurther_Title = new ControlTextCentered(this, 8, I18N.localise("botany.gui.controls.page.species_further.title")); + pageSpeciesFurther_List = new ControlColorMixBox(this, 4, 20, 136, 152, ControlColorMixBox.Type.RESULTANT); } @Override - public void onValueChanged(final IFlowerColour colour) { - final List mixes = new ArrayList<>(); - for (final IColorMix mix : BotanyCore.getFlowerRoot().getColorMixes(false)) { + public void onValueChanged(IFlowerColor colour) { + List mixes = new ArrayList<>(); + for (IColorMix mix : BotanyCore.getFlowerRoot().getColorMixes(false)) { if (mix.getResult() == colour) { mixes.add(mix); } } - this.pageSpeciesFurther_List.setOptions(mixes); + pageSpeciesFurther_List.setOptions(mixes); } } diff --git a/src/main/java/binnie/botany/craftgui/PageSpeciesFlowerGenome.java b/src/main/java/binnie/botany/craftgui/PageSpeciesFlowerGenome.java index ff0b4b7d..00ca7955 100644 --- a/src/main/java/binnie/botany/craftgui/PageSpeciesFlowerGenome.java +++ b/src/main/java/binnie/botany/craftgui/PageSpeciesFlowerGenome.java @@ -26,11 +26,11 @@ import binnie.core.craftgui.minecraft.control.ControlItemDisplay; import binnie.core.util.I18N; public class PageSpeciesFlowerGenome extends PageSpecies { - public PageSpeciesFlowerGenome(final IWidget parent, final DatabaseTab tab) { + public PageSpeciesFlowerGenome(IWidget parent, DatabaseTab tab) { super(parent, tab); } - public static String tolerated(final boolean t) { + public static String tolerated(boolean t) { if (t) { return "Tolerated"; } @@ -38,48 +38,52 @@ public class PageSpeciesFlowerGenome extends PageSpecies { } @Override - public void onValueChanged(final IAlleleSpecies species) { - this.deleteAllChildren(); + public void onValueChanged(IAlleleSpecies species) { + deleteAllChildren(); IAllele[] template = Binnie.GENETICS.getFlowerRoot().getTemplate(species.getUID()); if (template == null) { return; } + IFlower tree = Binnie.GENETICS.getFlowerRoot().templateAsIndividual(template); - if (tree == null) { - return; - } IFlowerGenome genome = tree.getGenome(); IAlleleFlowerSpecies treeSpecies = genome.getPrimary(); int w = 144; int h = 176; - new ControlText(this, new Area(0, 4, w, 16), I18N.localise("botany.gui.database.tab.genome"), TextJustification.MiddleCenter); + new ControlText(this, new Area(0, 4, w, 16), I18N.localise("botany.gui.database.tab.genome"), TextJustification.MIDDLE_CENTER); ControlScrollableContent scrollable = new ControlScrollableContent(this, 4, 20, w - 8, h - 8 - 16, 12); Control contents = new Control(scrollable, 0, 0, w - 8 - 12, h - 8 - 16); int tw = w - 8 - 12; int w2 = 55; int w3 = tw - 50; int y = 0; - final int th = 14; - final int th2 = 18; - new ControlText(contents, new Area(0, y, w2, th), I18N.localise("botany.gui.database.tab.genome.temp"), TextJustification.MiddleRight); - new ControlText(contents, new Area(w2, y, w3, th), treeSpecies.getTemperature().getName(), TextJustification.MIDDLE_LEFTt); + int th = 14; + int th2 = 18; + new ControlText(contents, new Area(0, y, w2, th), I18N.localise("botany.gui.database.tab.genome.temp"), TextJustification.MIDDLE_RIGHT); + new ControlText(contents, new Area(w2, y, w3, th), treeSpecies.getTemperature().getName(), TextJustification.MIDDLE_LEFT); + y += th; - new ControlText(contents, new Area(0, y, w2, th), I18N.localise("botany.gui.database.tab.genome.moist"), TextJustification.MiddleRight); - new ControlText(contents, new Area(w2, y, w3, th), treeSpecies.getMoisture().getLocalisedName(false), TextJustification.MIDDLE_LEFTt); + new ControlText(contents, new Area(0, y, w2, th), I18N.localise("botany.gui.database.tab.genome.moist"), TextJustification.MIDDLE_RIGHT); + new ControlText(contents, new Area(w2, y, w3, th), treeSpecies.getMoisture().getLocalisedName(false), TextJustification.MIDDLE_LEFT); + y += th; - new ControlText(contents, new Area(0, y, w2, th), I18N.localise("botany.gui.database.tab.genome.ph"), TextJustification.MiddleRight); - new ControlText(contents, new Area(w2, y, w3, th), treeSpecies.getPH().getLocalisedName(false), TextJustification.MIDDLE_LEFTt); + new ControlText(contents, new Area(0, y, w2, th), I18N.localise("botany.gui.database.tab.genome.ph"), TextJustification.MIDDLE_RIGHT); + new ControlText(contents, new Area(w2, y, w3, th), treeSpecies.getPH().getLocalisedName(false), TextJustification.MIDDLE_LEFT); + y += th; - new ControlText(contents, new Area(0, y, w2, th), I18N.localise("botany.gui.database.tab.genome.fertility"), TextJustification.MiddleRight); - new ControlText(contents, new Area(w2, y, w3, th), genome.getFertility() + "x", TextJustification.MIDDLE_LEFTt); + new ControlText(contents, new Area(0, y, w2, th), I18N.localise("botany.gui.database.tab.genome.fertility"), TextJustification.MIDDLE_RIGHT); + new ControlText(contents, new Area(w2, y, w3, th), genome.getFertility() + "x", TextJustification.MIDDLE_LEFT); + y += th; float lifespan = genome.getLifespan() * 68.27f / genome.getAgeChance() / 24000.0f; String lifespanValue = String.format("%.2f", lifespan); - new ControlText(contents, new Area(0, y, w2, th), I18N.localise("botany.gui.database.tab.genome.lifespan"), TextJustification.MiddleRight); - new ControlText(contents, new Area(w2, y, w3, th), I18N.localise("botany.gui.database.tab.genome.lifespan.value", lifespanValue), TextJustification.MIDDLE_LEFTt); + new ControlText(contents, new Area(0, y, w2, th), I18N.localise("botany.gui.database.tab.genome.lifespan"), TextJustification.MIDDLE_RIGHT); + new ControlText(contents, new Area(w2, y, w3, th), I18N.localise("botany.gui.database.tab.genome.lifespan.value", lifespanValue), TextJustification.MIDDLE_LEFT); + y += th; - new ControlText(contents, new Area(0, y, w2, th), I18N.localise("botany.gui.database.tab.genome.nectar"), TextJustification.MiddleRight); - new ControlText(contents, new Area(w2, y, w3, th), genome.getActiveAllele(EnumFlowerChromosome.SAPPINESS).getName(), TextJustification.MIDDLE_LEFTt); + new ControlText(contents, new Area(0, y, w2, th), I18N.localise("botany.gui.database.tab.genome.nectar"), TextJustification.MIDDLE_RIGHT); + new ControlText(contents, new Area(w2, y, w3, th), genome.getActiveAllele(EnumFlowerChromosome.SAPPINESS).getName(), TextJustification.MIDDLE_LEFT); + y += th; int x = w2; int tot = 0; @@ -96,8 +100,9 @@ public class PageSpeciesFlowerGenome extends PageSpecies { x += 18; } } + int numOfLines = 1 + (tot - 1) / 3; - new ControlText(contents, new Area(0, y - (numOfLines - 1) * 18, w2, 4 + 18 * numOfLines), I18N.localise("botany.gui.database.tab.genome.varieties"), TextJustification.MiddleRight); + new ControlText(contents, new Area(0, y - (numOfLines - 1) * 18, w2, 4 + 18 * numOfLines), I18N.localise("botany.gui.database.tab.genome.varieties"), TextJustification.MIDDLE_RIGHT); y += th; contents.setSize(new Point(contents.size().x(), y)); scrollable.setScrollableContent(contents); diff --git a/src/main/java/binnie/botany/craftgui/WindowBotanistDatabase.java b/src/main/java/binnie/botany/craftgui/WindowBotanistDatabase.java index 2055cae7..17c45635 100644 --- a/src/main/java/binnie/botany/craftgui/WindowBotanistDatabase.java +++ b/src/main/java/binnie/botany/craftgui/WindowBotanistDatabase.java @@ -11,7 +11,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; import binnie.Binnie; import binnie.botany.Botany; -import binnie.botany.api.IFlowerColour; +import binnie.botany.api.IFlowerColor; import binnie.botany.genetics.EnumFlowerColor; import binnie.core.AbstractMod; import binnie.core.craftgui.IWidget; @@ -31,30 +31,30 @@ import binnie.core.craftgui.minecraft.Window; import binnie.core.util.I18N; public class WindowBotanistDatabase extends WindowAbstractDatabase { - ControlListBox selectionBoxColors; + private ControlListBox selectionBoxColors; - public WindowBotanistDatabase(final EntityPlayer player, final Side side, final boolean nei) { + public WindowBotanistDatabase(EntityPlayer player, Side side, boolean nei) { super(player, side, nei, Binnie.GENETICS.flowerBreedingSystem, 130); } - public static Window create(final EntityPlayer player, final Side side, final boolean nei) { + public static Window create(EntityPlayer player, Side side, boolean nei) { return new WindowBotanistDatabase(player, side, nei); } @Override @SideOnly(Side.CLIENT) protected void addTabs() { - new PageSpeciesOverview(this.getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.overview", 0)); - new PageSpeciesFlowerGenome(this.getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "genome", 0)); - new PageSpeciesClassification(this.getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.classification", 0)); - new PageSpeciesResultant(this.getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.resultant", 0)); - new PageSpeciesMutations(this.getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.further", 0)); - new PageBranchOverview(this.getInfoPages(Mode.BRANCHES), new DatabaseTab(Botany.instance, "branches.overview", 0)); - new PageBranchSpecies(this.getInfoPages(Mode.BRANCHES), new DatabaseTab(Botany.instance, "branches.species", 0)); - this.createMode(FlowerMode.Color, new FlowerColorModeWidgets()); - new PageColorMixResultant(this.getInfoPages(FlowerMode.Color), new DatabaseTab(Botany.instance, "color.resultant", 0)); - new PageColorMix(this.getInfoPages(FlowerMode.Color), new DatabaseTab(Botany.instance, "color.further", 0)); - new PageBreeder(this.getInfoPages(Mode.BREEDER), this.getUsername(), new DatabaseTab(Botany.instance, "breeder", 0)); + new PageSpeciesOverview(getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.overview", 0)); + new PageSpeciesFlowerGenome(getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "genome", 0)); + new PageSpeciesClassification(getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.classification", 0)); + new PageSpeciesResultant(getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.resultant", 0)); + new PageSpeciesMutations(getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.further", 0)); + new PageBranchOverview(getInfoPages(Mode.BRANCHES), new DatabaseTab(Botany.instance, "branches.overview", 0)); + new PageBranchSpecies(getInfoPages(Mode.BRANCHES), new DatabaseTab(Botany.instance, "branches.species", 0)); + createMode(FlowerMode.Color, new FlowerColorModeWidgets()); + new PageColorMixResultant(getInfoPages(FlowerMode.Color), new DatabaseTab(Botany.instance, "color.resultant", 0)); + new PageColorMix(getInfoPages(FlowerMode.Color), new DatabaseTab(Botany.instance, "color.further", 0)); + new PageBreeder(getInfoPages(Mode.BREEDER), getUsername(), new DatabaseTab(Botany.instance, "breeder", 0)); } @Override @@ -72,7 +72,7 @@ public class WindowBotanistDatabase extends WindowAbstractDatabase { @Override public String getName() { - return I18N.localise("botany.gui.database.tab." + this.name().toLowerCase()); + return I18N.localise("botany.gui.database.tab." + name().toLowerCase()); } } @@ -83,15 +83,16 @@ public class WindowBotanistDatabase extends WindowAbstractDatabase { } @Override - public void createListBox(final Area area) { - this.listBox = new ControlListBox(this.modePage, area.xPos(), area.yPos(), area.width(), area.height(), 12) { + public void createListBox(Area area) { + listBox = new ControlListBox(modePage, area.xPos(), area.yPos(), area.width(), area.height(), 12) { @Override - public IWidget createOption(final IFlowerColour value, final int y) { - return new ControlColorOption(this.getContent(), value, y); + public IWidget createOption(IFlowerColor value, int y) { + return new ControlColorOption(getContent(), value, y); } }; - final List colors = Arrays.stream(EnumFlowerColor.values()).map( c -> c.getFlowerColorAllele()).collect(Collectors.toList()); - this.listBox.setOptions(colors); + + List colors = Arrays.stream(EnumFlowerColor.values()).map(c -> c.getFlowerColorAllele()).collect(Collectors.toList()); + listBox.setOptions(colors); } } } diff --git a/src/main/java/binnie/botany/farm/CircuitGarden.java b/src/main/java/binnie/botany/farm/CircuitGarden.java index f15f85ea..78d7edeb 100644 --- a/src/main/java/binnie/botany/farm/CircuitGarden.java +++ b/src/main/java/binnie/botany/farm/CircuitGarden.java @@ -23,15 +23,15 @@ public class CircuitGarden extends BinnieCircuit { public CircuitGarden(EnumMoisture moisture, @Nullable EnumAcidity ph, boolean manual, boolean fertilised, ItemStack recipe, ItemStack icon) { super(getName(moisture, ph, manual, fertilised), 4, getLayout(manual), recipe); - this.isManual = manual; - this.logic = new GardenLogic(moisture, ph, this.isManual, fertilised, icon, I18N.localise(this.getUnlocalizedName())); + isManual = manual; + logic = new GardenLogic(moisture, ph, isManual, fertilised, icon, I18N.localise(getUnlocalizedName())); String info = I18N.localise("botany.moisture") + ": " + moisture.getLocalisedName(true); - if(ph != null){ - info+= TextFormatting.GRAY + ", " + I18N.localise("botany.ph") + ": " + moisture.getLocalisedName(true); + if (ph != null) { + info += TextFormatting.GRAY + ", " + I18N.localise("botany.ph") + ": " + moisture.getLocalisedName(true); } String fertilizedKey = fertilised ? "for.binnie.circuit.garden.fertilized" : "for.binnie.circuit.garden.unfertilized"; - info+= TextFormatting.GRAY + " " + I18N.localise(fertilizedKey); - this.addTooltipString(I18N.localise("for.binnie.circuit.garden.info", info)); + info += TextFormatting.GRAY + " " + I18N.localise(fertilizedKey); + addTooltipString(I18N.localise("for.binnie.circuit.garden.info", info)); } private static ICircuitLayout getLayout(boolean manual) { @@ -102,5 +102,6 @@ public class CircuitGarden extends BinnieCircuit { @Override public void onTick(int slot, Object tile) { + // ignored } } diff --git a/src/main/java/binnie/botany/farm/FarmLogic.java b/src/main/java/binnie/botany/farm/FarmLogic.java index 4d30b8f4..701f5db9 100644 --- a/src/main/java/binnie/botany/farm/FarmLogic.java +++ b/src/main/java/binnie/botany/farm/FarmLogic.java @@ -13,8 +13,8 @@ public abstract class FarmLogic implements IFarmLogic { boolean isManual; @Override - public IFarmLogic setManual(final boolean flag) { - this.isManual = flag; + public IFarmLogic setManual(boolean flag) { + isManual = flag; return this; } @@ -43,7 +43,7 @@ public abstract class FarmLogic implements IFarmLogic { return getBlock(world, pos) == Blocks.WATER; } - protected final void setBlock(World world, BlockPos pos, final Block block, final int meta) { + protected final void setBlock(World world, BlockPos pos, Block block, int meta) { world.setBlockState(pos, block.getStateFromMeta(meta), 2); } } diff --git a/src/main/java/binnie/botany/farm/FarmableFlower.java b/src/main/java/binnie/botany/farm/FarmableFlower.java index bf9d048f..81761623 100644 --- a/src/main/java/binnie/botany/farm/FarmableFlower.java +++ b/src/main/java/binnie/botany/farm/FarmableFlower.java @@ -21,7 +21,7 @@ import binnie.botany.flower.TileEntityFlower; public class FarmableFlower implements IFarmable { @Override - public boolean isSaplingAt(final World world, final BlockPos pos) { + public boolean isSaplingAt(World world, BlockPos pos) { return world.getBlockState(pos) == Botany.flower; } @@ -32,7 +32,8 @@ public class FarmableFlower implements IFarmable { if (world.getTileEntity(pos) instanceof TileEntityFlower) { flower = ((TileEntityFlower) world.getTileEntity(pos)).getFlower(); } - // Look at TileEntityFlower::onShear logic + + // TODO Look at TileEntityFlower::onShear logic if (flower != null && flower.getAge() > 1) { IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot(); ItemStack mature = flowerRoot.getMemberStack(flower, EnumFlowerStage.FLOWER); @@ -42,23 +43,22 @@ public class FarmableFlower implements IFarmable { return new FlowerCrop(pos, mature, seed); } } - return null; } @Override - public boolean isGermling(final ItemStack itemstack) { - final EnumFlowerStage stage = BotanyCore.getFlowerRoot().getType(itemstack); + public boolean isGermling(ItemStack itemstack) { + EnumFlowerStage stage = BotanyCore.getFlowerRoot().getType(itemstack); return stage == EnumFlowerStage.FLOWER || stage == EnumFlowerStage.SEED; } @Override - public boolean isWindfall(final ItemStack itemstack) { + public boolean isWindfall(ItemStack itemstack) { return false; } @Override - public boolean plantSaplingAt(final EntityPlayer player, final ItemStack germling, final World world, final BlockPos pos) { + public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) { IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot(); IFlower flower = flowerRoot.getMember(germling); flowerRoot.plant(world, pos, flower, player.getGameProfile()); diff --git a/src/main/java/binnie/botany/farm/FarmableVanillaFlower.java b/src/main/java/binnie/botany/farm/FarmableVanillaFlower.java index 4de68a51..1fae23a0 100644 --- a/src/main/java/binnie/botany/farm/FarmableVanillaFlower.java +++ b/src/main/java/binnie/botany/farm/FarmableVanillaFlower.java @@ -11,12 +11,12 @@ import binnie.botany.core.BotanyCore; public class FarmableVanillaFlower extends FarmableFlower { @Override - public boolean isGermling(final ItemStack itemstack) { + public boolean isGermling(ItemStack itemstack) { return BotanyCore.getFlowerRoot().getConversion(itemstack) != null; } @Override - public boolean plantSaplingAt(final EntityPlayer player, final ItemStack germling, final World world, final BlockPos pos) { + public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) { IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot(); IFlower flower = flowerRoot.getConversion(germling); return flowerRoot.plant(world, pos, flower, player.getGameProfile()); diff --git a/src/main/java/binnie/botany/farm/GardenLogic.java b/src/main/java/binnie/botany/farm/GardenLogic.java index f51a2042..f52c918e 100644 --- a/src/main/java/binnie/botany/farm/GardenLogic.java +++ b/src/main/java/binnie/botany/farm/GardenLogic.java @@ -51,29 +51,31 @@ public class GardenLogic extends FarmLogic { private ItemStack icon; public GardenLogic(EnumMoisture moisture2, @Nullable EnumAcidity acidity2, boolean isManual, boolean isFertilised, ItemStack icon2, String name2) { - this.produce = NonNullList.create(); - (this.farmables = new ArrayList<>()).add(new FarmableFlower()); - this.farmables.add(new FarmableVanillaFlower()); - this.moisture = moisture2; - this.acidity = acidity2; this.isManual = isManual; - this.fertilised = isFertilised; - this.icon = icon2; - this.name = name2; + produce = NonNullList.create(); + farmables = new ArrayList<>(); + farmables.add(new FarmableFlower()); + farmables.add(new FarmableVanillaFlower()); + + moisture = moisture2; + acidity = acidity2; + fertilised = isFertilised; + icon = icon2; + name = name2; } @Override public int getFertilizerConsumption() { - return this.fertilised ? 8 : 2; + return fertilised ? 8 : 2; } @Override - public int getWaterConsumption(final float hydrationModifier) { - return (int) (this.moisture.ordinal() * 40 * hydrationModifier); + public int getWaterConsumption(float hydrationModifier) { + return (int) (moisture.ordinal() * 40 * hydrationModifier); } @Override - public boolean isAcceptedResource(final ItemStack itemstack) { + public boolean isAcceptedResource(ItemStack itemstack) { IGardeningManager gardening = BotanyCore.getGardening(); return gardening.isSoil(itemstack.getItem()) || itemstack.getItem() == Item.getItemFromBlock(Blocks.SAND) || @@ -84,19 +86,19 @@ public class GardenLogic extends FarmLogic { @Override public NonNullList collect(World world, IFarmHousing farmHousing) { - final NonNullList products = this.produce; - this.produce = NonNullList.create(); + NonNullList products = produce; + produce = NonNullList.create(); return products; } @Override public boolean cultivate(World world, IFarmHousing farmHousing, BlockPos pos, FarmDirection direction, int extent) { - return this.maintainSoil(world, pos, direction, extent, farmHousing) || - (!this.isManual && this.maintainWater(world, pos, direction, extent, farmHousing)) || - this.maintainCrops(world, pos.up(), direction, extent, farmHousing); + return maintainSoil(world, pos, direction, extent, farmHousing) || + (!isManual && maintainWater(world, pos, direction, extent, farmHousing)) || + maintainCrops(world, pos.up(), direction, extent, farmHousing); } - private boolean isWaste(final ItemStack stack) { + private boolean isWaste(ItemStack stack) { return stack.getItem() == Item.getItemFromBlock(Blocks.DIRT); } @@ -104,20 +106,21 @@ public class GardenLogic extends FarmLogic { IGardeningManager gardening = BotanyCore.getGardening(); for (int i = 0; i < extent; ++i) { BlockPos position = pos.offset(direction.getFacing(), i); - if (this.fertilised && gardening.isSoil(getBlock(world, position))) { + if (fertilised && gardening.isSoil(getBlock(world, position))) { IBlockSoil soil = (IBlockSoil) getBlock(world, position); if (soil.fertilise(world, position, EnumSoilType.FLOWERBED)) { continue; } } + if (getBlock(world, position.up()) == Botany.plant) { world.setBlockToAir(position.up()); } else { - if (this.acidity != null && gardening.isSoil(getBlock(world, position))) { + if (acidity != null && gardening.isSoil(getBlock(world, position))) { IBlockSoil soil = (IBlockSoil) getBlock(world, position); EnumAcidity pH = soil.getPH(world, position); - if (pH.ordinal() < this.acidity.ordinal()) { - ItemStack stack = this.getAvailableAlkaline(housing); + if (pH.ordinal() < acidity.ordinal()) { + ItemStack stack = getAvailableAlkaline(housing); if (!stack.isEmpty() && soil.setPH(world, position, EnumAcidity.values()[pH.ordinal() + 1])) { NonNullList resources = NonNullList.create(); resources.add(stack); @@ -125,8 +128,8 @@ public class GardenLogic extends FarmLogic { continue; } } - if (pH.ordinal() > this.acidity.ordinal()) { - final ItemStack stack = this.getAvailableAcid(housing); + if (pH.ordinal() > acidity.ordinal()) { + ItemStack stack = getAvailableAcid(housing); if (!stack.isEmpty() && soil.setPH(world, position, EnumAcidity.values()[pH.ordinal() - 1])) { NonNullList resources = NonNullList.create(); resources.add(stack); @@ -135,16 +138,17 @@ public class GardenLogic extends FarmLogic { } } } - if (!this.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(getBlockState(world, position), world, position)) { - ItemStack block = this.getAsItemStack(world, position); - ItemStack loam = this.getAvailableLoam(housing); - if (this.isWaste(block) && !loam.isEmpty()) { - this.produce.addAll(Blocks.DIRT.getDrops(world, position, Block.getBlockFromItem(block.getItem()).getStateFromMeta(block.getItemDamage()), 0)); - this.setBlock(world, position, Blocks.AIR, 0); + + if (!isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(getBlockState(world, position), world, position)) { + ItemStack block = getAsItemStack(world, position); + ItemStack loam = getAvailableLoam(housing); + if (isWaste(block) && !loam.isEmpty()) { + produce.addAll(Blocks.DIRT.getDrops(world, position, Block.getBlockFromItem(block.getItem()).getStateFromMeta(block.getItemDamage()), 0)); + setBlock(world, position, Blocks.AIR, 0); return trySetSoil(world, position, loam, housing); } - } else if (!this.isManual) { - if (!this.isWaterBlock(world, position)) { + } else if (!isManual) { + if (!isWaterBlock(world, position)) { if (i % 2 == 0) { return trySetSoil(world, position, housing); } @@ -157,9 +161,9 @@ public class GardenLogic extends FarmLogic { cclock = FarmDirection.SOUTH; } BlockPos previous = position.offset(cclock.getFacing()); - final ItemStack soil2 = this.getAsItemStack(world, previous); + ItemStack soil2 = getAsItemStack(world, previous); if (!gardening.isSoil(soil2.getItem())) { - this.trySetSoil(world, position, housing); + trySetSoil(world, position, housing); } } } @@ -171,23 +175,27 @@ public class GardenLogic extends FarmLogic { private boolean maintainWater(World world, BlockPos pos, FarmDirection direction, int extent, IFarmHousing housing) { for (int i = 0; i < extent; ++i) { BlockPos position = pos.offset(direction.getFacing(), i); - if (this.isAirBlock(world, position) || BlockUtil.isReplaceableBlock(getBlockState(world, position), world, position)) { - if (!this.isWaterBlock(world, position)) { - boolean isEnclosed = true; - if (world.isAirBlock(position.east())) { - isEnclosed = false; - } else if (world.isAirBlock(position.west())) { - isEnclosed = false; - } else if (world.isAirBlock(position.south())) { - isEnclosed = false; - } else if (world.isAirBlock(position.north())) { - isEnclosed = false; - } - isEnclosed = (isEnclosed || this.moisture != EnumMoisture.DAMP); - if (isEnclosed) { - return this.trySetWater(world, position, housing); - } - } + if (!isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(getBlockState(world, position), world, position)) { + continue; + } + if (isWaterBlock(world, position)) { + continue; + } + + boolean isEnclosed = true; + if (world.isAirBlock(position.east())) { + isEnclosed = false; + } else if (world.isAirBlock(position.west())) { + isEnclosed = false; + } else if (world.isAirBlock(position.south())) { + isEnclosed = false; + } else if (world.isAirBlock(position.north())) { + isEnclosed = false; + } + + isEnclosed = (isEnclosed || moisture != EnumMoisture.DAMP); + if (isEnclosed) { + return trySetWater(world, position, housing); } } return false; @@ -195,19 +203,37 @@ public class GardenLogic extends FarmLogic { private ItemStack getAvailableLoam(IFarmHousing housing) { EnumMoisture[] moistures; - if (this.moisture == EnumMoisture.DAMP) { - moistures = new EnumMoisture[]{EnumMoisture.DAMP, EnumMoisture.NORMAL, EnumMoisture.DRY}; - } else if (this.moisture == EnumMoisture.DRY) { - moistures = new EnumMoisture[]{EnumMoisture.DRY, EnumMoisture.DAMP, EnumMoisture.DRY}; + if (moisture == EnumMoisture.DAMP) { + moistures = new EnumMoisture[]{ + EnumMoisture.DAMP, + EnumMoisture.NORMAL, + EnumMoisture.DRY + }; + } else if (moisture == EnumMoisture.DRY) { + moistures = new EnumMoisture[]{ + EnumMoisture.DRY, + EnumMoisture.DAMP, + EnumMoisture.DRY + }; } else { - moistures = new EnumMoisture[]{EnumMoisture.DRY, EnumMoisture.NORMAL, EnumMoisture.DAMP}; + moistures = new EnumMoisture[]{ + EnumMoisture.DRY, + EnumMoisture.NORMAL, + EnumMoisture.DAMP + }; } - final EnumAcidity[] acidities = {EnumAcidity.NEUTRAL, EnumAcidity.ACID, EnumAcidity.ALKALINE}; - for (final EnumMoisture moist : moistures) { - for (final EnumAcidity acid : acidities) { - for (final Block type : new Block[]{Botany.flowerbed, Botany.loam, Botany.soil}) { - final int meta = acid.ordinal() * 3 + moist.ordinal(); - final NonNullList resources = NonNullList.create(); + + EnumAcidity[] acidities = { + EnumAcidity.NEUTRAL, + EnumAcidity.ACID, + EnumAcidity.ALKALINE + }; + + for (EnumMoisture moist : moistures) { + for (EnumAcidity acid : acidities) { + for (Block type : new Block[]{Botany.flowerbed, Botany.loam, Botany.soil}) { + int meta = acid.ordinal() * 3 + moist.ordinal(); + NonNullList resources = NonNullList.create(); ItemStack resourceStack = new ItemStack(type, 1, meta); resources.add(resourceStack); if (housing.getFarmInventory().hasResources(resources)) { @@ -216,7 +242,8 @@ public class GardenLogic extends FarmLogic { } } } - final NonNullList resources = NonNullList.create(); + + NonNullList resources = NonNullList.create(); ItemStack resourceStack = new ItemStack(Blocks.DIRT); resources.add(resourceStack); if (housing.getFarmInventory().hasResources(resources)) { @@ -226,56 +253,58 @@ public class GardenLogic extends FarmLogic { } private boolean trySetSoil(World world, BlockPos position, IFarmHousing housing) { - return this.trySetSoil(world, position, this.getAvailableLoam(housing), housing); + return trySetSoil(world, position, getAvailableLoam(housing), housing); } private boolean trySetSoil(World world, BlockPos position, ItemStack loam, IFarmHousing housing) { ItemStack copy = loam; - if (!loam.isEmpty()) { - if (loam.getItem() == Item.getItemFromBlock(Blocks.DIRT)) { - loam = new ItemStack(Botany.soil, 1, 4); - } - setBlock(world, position, ((ItemBlock) loam.getItem()).getBlock(), loam.getItemDamage()); - final NonNullList resources = NonNullList.create(); - resources.add(copy); - housing.getFarmInventory().removeResources(resources); - return true; + if (loam.isEmpty()) { + return false; } - return false; + + if (loam.getItem() == Item.getItemFromBlock(Blocks.DIRT)) { + loam = new ItemStack(Botany.soil, 1, 4); + } + + setBlock(world, position, ((ItemBlock) loam.getItem()).getBlock(), loam.getItemDamage()); + NonNullList resources = NonNullList.create(); + resources.add(copy); + housing.getFarmInventory().removeResources(resources); + return true; } private boolean trySetWater(World world, BlockPos position, IFarmHousing housing) { - final FluidStack water = Binnie.LIQUID.getFluidStack(ManagerLiquid.WATER, 1000); - if (this.moisture == EnumMoisture.DAMP) { + FluidStack water = Binnie.LIQUID.getFluidStack(ManagerLiquid.WATER, 1000); + if (moisture == EnumMoisture.DAMP) { if (water == null || !housing.hasLiquid(water)) { return false; } - this.setBlock(world, position, Blocks.WATER, 0); + setBlock(world, position, Blocks.WATER, 0); housing.removeLiquid(water); return true; - } else { - if (this.moisture != EnumMoisture.DRY) { - return trySetSoil(world, position, housing); - } - final ItemStack sand = new ItemStack(Blocks.SAND, 1); - final NonNullList resources = NonNullList.create(); - resources.add(sand); - if (!housing.getFarmInventory().hasResources(resources)) { - return false; - } - this.setBlock(world, position, Blocks.SAND, 0); - housing.getFarmInventory().removeResources(resources); - return true; } + + if (moisture != EnumMoisture.DRY) { + return trySetSoil(world, position, housing); + } + ItemStack sand = new ItemStack(Blocks.SAND, 1); + NonNullList resources = NonNullList.create(); + resources.add(sand); + if (!housing.getFarmInventory().hasResources(resources)) { + return false; + } + setBlock(world, position, Blocks.SAND, 0); + housing.getFarmInventory().removeResources(resources); + return true; } - public void setIcon(final ItemStack icon) { + public void setIcon(ItemStack icon) { this.icon = icon; } @Override - public boolean isAcceptedGermling(final ItemStack itemstack) { - for (final IFarmable farmable : this.farmables) { + public boolean isAcceptedGermling(ItemStack itemstack) { + for (IFarmable farmable : farmables) { if (farmable.isGermling(itemstack)) { return true; } @@ -287,10 +316,9 @@ public class GardenLogic extends FarmLogic { public Collection harvest(World world, BlockPos pos, FarmDirection direction, int extent) { if (isManual) { return Collections.emptyList(); - } else { - return farmables.stream().map(farmable -> farmable.getCropAt(world, pos.up(), world.getBlockState(pos.up()))) - .filter(Objects::nonNull).collect(Collectors.toList()); } + return farmables.stream().map(farmable -> farmable.getCropAt(world, pos.up(), world.getBlockState(pos.up()))) + .filter(Objects::nonNull).collect(Collectors.toList()); } @Override @@ -300,7 +328,7 @@ public class GardenLogic extends FarmLogic { @Override public String getName() { - return this.name; + return name; } @Override @@ -312,8 +340,8 @@ public class GardenLogic extends FarmLogic { IGardeningManager gardening = BotanyCore.getGardening(); for (int i = 0; i < extent; ++i) { BlockPos position = pos.offset(direction.getFacing(), i); - if (this.isAirBlock(world, position) || BlockUtil.isReplaceableBlock(getBlockState(world, position), world, position)) { - ItemStack below = this.getAsItemStack(world, position.down()); + if (isAirBlock(world, position) || BlockUtil.isReplaceableBlock(getBlockState(world, position), world, position)) { + ItemStack below = getAsItemStack(world, position.down()); if (gardening.isSoil(below.getItem())) { return trySetCrop(world, position, housing); } @@ -323,27 +351,29 @@ public class GardenLogic extends FarmLogic { } private boolean trySetCrop(World world, BlockPos position, IFarmHousing housing) { - for (IFarmable farmable : this.farmables) { - if (housing.plantGermling(farmable, world, position)) { - if (housing instanceof IOwnedTile) { - TileEntity tile = world.getTileEntity(position); - if (tile instanceof TileEntityFlower) { - TileEntityFlower flower = (TileEntityFlower) tile; - IOwnedTile owned = (IOwnedTile) housing; - - flower.setOwner(owned.getOwnerHandler().getOwner()); - } - } - return true; + for (IFarmable farmable : farmables) { + if (!housing.plantGermling(farmable, world, position)) { + continue; } + + if (housing instanceof IOwnedTile) { + TileEntity tile = world.getTileEntity(position); + if (tile instanceof TileEntityFlower) { + TileEntityFlower flower = (TileEntityFlower) tile; + IOwnedTile owned = (IOwnedTile) housing; + + flower.setOwner(owned.getOwnerHandler().getOwner()); + } + } + return true; } return false; } public ItemStack getAvailableAcid(IFarmHousing housing) { - for (final ItemStack stack : BotanyCore.getGardening().getAcidFertilisers()) { + for (ItemStack stack : BotanyCore.getGardening().getAcidFertilisers()) { if (!stack.isEmpty()) { - final NonNullList resources = NonNullList.create(); + NonNullList resources = NonNullList.create(); resources.add(stack); if (housing.getFarmInventory().hasResources(resources)) { return stack; @@ -354,9 +384,9 @@ public class GardenLogic extends FarmLogic { } public ItemStack getAvailableAlkaline(IFarmHousing housing) { - for (final ItemStack stack : BotanyCore.getGardening().getAlkalineFertilisers()) { + for (ItemStack stack : BotanyCore.getGardening().getAlkalineFertilisers()) { if (!stack.isEmpty()) { - final NonNullList resources = NonNullList.create(); + NonNullList resources = NonNullList.create(); resources.add(stack); if (housing.getFarmInventory().hasResources(resources)) { return stack; diff --git a/src/main/java/binnie/botany/flower/BlockFlower.java b/src/main/java/binnie/botany/flower/BlockFlower.java index 8248fb4f..c9ac0efd 100644 --- a/src/main/java/binnie/botany/flower/BlockFlower.java +++ b/src/main/java/binnie/botany/flower/BlockFlower.java @@ -53,7 +53,7 @@ import binnie.core.util.TileUtil; public class BlockFlower extends BlockContainer implements IColoredBlock, IStateMapperRegister { public static final AxisAlignedBB FLOWER_BLOCK_AABB = new AxisAlignedBB(0.3D, 0.0D, 0.3D, 0.7D, 0.6D, 0.7D); - /* PROPERTYS */ + /* PROPERTIES */ public static final PropertyFlower FLOWER = new PropertyFlower("flower", IFlowerType.class); public static final PropertyInteger SECTION = PropertyInteger.create("section", 0, EnumFlowerType.highestSection - 1); public static final PropertyBool FLOWERED = PropertyBool.create("flowered"); @@ -61,14 +61,13 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IState public BlockFlower() { super(Material.PLANTS); - final float f = 0.2f; - this.setTickRandomly(true); - this.setRegistryName("flower"); - this.setSoundType(SoundType.PLANT); + setTickRandomly(true); + setRegistryName("flower"); + setSoundType(SoundType.PLANT); } @Override - public TileEntity createNewTileEntity(final World var1, final int i) { + public TileEntity createNewTileEntity(World world, int meta) { return new TileEntityFlower(); } @@ -81,31 +80,36 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IState @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack heldItem = player.getHeldItemMainhand(); - if (!heldItem.isEmpty() && heldItem.getItem() == BinnieCore.getFieldKit() && player.isSneaking()) { - if (world.isRemote) { - return true; - } - TileEntity tile = world.getTileEntity(pos); - if (tile instanceof TileEntityFlower) { - TileEntityFlower tileFlower = (TileEntityFlower) tile; - IFlower flower = tileFlower.getFlower(); - if (flower != null) { - IFlowerGenome flowerGenome = flower.getGenome(); - NBTTagCompound info = new NBTTagCompound(); - info.setString("Species", flowerGenome.getPrimary().getUID()); - info.setString("Species2", flowerGenome.getSecondary().getUID()); - info.setFloat("Age", flower.getAge() / flowerGenome.getLifespan()); - info.setShort("Colour", (short) flowerGenome.getPrimaryColor().getID()); - info.setShort("Colour2", (short) flowerGenome.getSecondaryColor().getID()); - info.setBoolean("Wilting", flower.isWilted()); - info.setBoolean("Flowered", flower.hasFlowered()); - Botany.proxy.sendToPlayer(new MessageNBT(PacketID.FIELDKIT.ordinal(), info), player); - heldItem.damageItem(1, player); - } - } + if (heldItem.isEmpty() || heldItem.getItem() != BinnieCore.getFieldKit() || !player.isSneaking()) { + return false; + } + if (world.isRemote) { return true; } - return false; + + TileEntity tile = world.getTileEntity(pos); + if (!(tile instanceof TileEntityFlower)) { + return true; + } + + TileEntityFlower tileFlower = (TileEntityFlower) tile; + IFlower flower = tileFlower.getFlower(); + if (flower == null) { + return true; + } + + IFlowerGenome flowerGenome = flower.getGenome(); + NBTTagCompound info = new NBTTagCompound(); + info.setString("Species", flowerGenome.getPrimary().getUID()); + info.setString("Species2", flowerGenome.getSecondary().getUID()); + info.setFloat("Age", flower.getAge() / flowerGenome.getLifespan()); + info.setShort("Colour", (short) flowerGenome.getPrimaryColor().getID()); + info.setShort("Colour2", (short) flowerGenome.getSecondaryColor().getID()); + info.setBoolean("Wilting", flower.isWilted()); + info.setBoolean("Flowered", flower.hasFlowered()); + Botany.proxy.sendToPlayer(new MessageNBT(PacketID.FIELDKIT.ordinal(), info), player); + heldItem.damageItem(1, player); + return true; } @Override @@ -152,22 +156,23 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IState public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { super.onBlockPlacedBy(world, pos, state, placer, stack); IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot(); - final TileEntity flower = world.getTileEntity(pos); + TileEntity flower = world.getTileEntity(pos); if (!BinnieCore.getBinnieProxy().isSimulating(world)) { if (flower != null && flower instanceof TileEntityFlower) { - final IFlower f = flowerRoot.getMember(stack); + IFlower f = flowerRoot.getMember(stack); if (f != null) { ((TileEntityFlower) flower).setRender(new TileEntityFlower.RenderInfo(f, (TileEntityFlower) flower)); } } return; } - final TileEntity below = world.getTileEntity(pos.down()); + + TileEntity below = world.getTileEntity(pos.down()); if (flower != null && flower instanceof TileEntityFlower) { if (below instanceof TileEntityFlower) { ((TileEntityFlower) flower).setSection(((TileEntityFlower) below).getSection()); } else { - final GameProfile owner = (placer instanceof EntityPlayer) ? ((EntityPlayer) placer).getGameProfile() : null; + GameProfile owner = (placer instanceof EntityPlayer) ? ((EntityPlayer) placer).getGameProfile() : null; ((TileEntityFlower) flower).create(stack, owner); } } @@ -185,9 +190,8 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IState return flower.getStemColour(); } else if (tintIndex == 1) { return flower.getPrimaryColour(); - } else { - return flower.getSecondaryColour(); } + return flower.getSecondaryColour(); } } return 0xffffff; @@ -204,11 +208,14 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IState if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).getSection() > 0) { return downState.getBlock() == Botany.flower; } - return this.canPlaceBlockOn(downState.getBlock()); + return canPlaceBlockOn(downState.getBlock()); } - protected boolean canPlaceBlockOn(final Block block) { - return block == Blocks.GRASS || block == Blocks.DIRT || block == Blocks.FARMLAND || BotanyCore.getGardening().isSoil(block); + protected boolean canPlaceBlockOn(Block block) { + return block == Blocks.GRASS + || block == Blocks.DIRT + || block == Blocks.FARMLAND + || BotanyCore.getGardening().isSoil(block); } @Override @@ -257,12 +264,12 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IState @Override public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) { - this.checkAndDropBlock(worldIn, pos); - final TileEntity tile = worldIn.getTileEntity(pos); + checkAndDropBlock(worldIn, pos); + TileEntity tile = worldIn.getTileEntity(pos); if (tile instanceof TileEntityFlower) { - final TileEntityFlower flower = (TileEntityFlower) tile; + TileEntityFlower flower = (TileEntityFlower) tile; if (flower.getSection() == 0 && flower.getFlower() != null && flower.getFlower().getAge() > 0 && flower.getFlower().getGenome().getPrimary().getType().getSections() > 1 && worldIn.getBlockState(pos.up()).getBlock() != Botany.flower) { - this.dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0); + dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0); worldIn.setBlockToAir(pos); } } @@ -270,18 +277,18 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IState @Override public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) { - final TileEntity tile = world.getTileEntity(pos); + TileEntity tile = world.getTileEntity(pos); if (tile instanceof TileEntityFlower) { ((TileEntityFlower) tile).randomUpdate(rand); - this.checkAndDropBlock(world, pos); + checkAndDropBlock(world, pos); return; } world.setBlockToAir(pos); } - protected void checkAndDropBlock(final World world, final BlockPos pos) { - if (!this.canBlockStay(world, pos)) { - this.dropBlockAsItem(world, pos, world.getBlockState(pos), 0); + protected void checkAndDropBlock(World world, BlockPos pos) { + if (!canBlockStay(world, pos)) { + dropBlockAsItem(world, pos, world.getBlockState(pos), 0); world.setBlockToAir(pos); } } @@ -301,10 +308,10 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IState @Override public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) { - final List drops = this.getDrops(world, pos, world.getBlockState(pos), 0); - final boolean hasBeenBroken = world.setBlockToAir(pos); + List drops = getDrops(world, pos, world.getBlockState(pos), 0); + boolean hasBeenBroken = world.setBlockToAir(pos); if (hasBeenBroken && BinnieCore.getBinnieProxy().isSimulating(world) && drops.size() > 0 && (player == null || !player.capabilities.isCreativeMode)) { - for (final ItemStack drop : drops) { + for (ItemStack drop : drops) { spawnAsEntity(world, pos, drop); } } diff --git a/src/main/java/binnie/botany/flower/EnumTubeInsulate.java b/src/main/java/binnie/botany/flower/EnumTubeInsulate.java index 84823ef4..acdcecdd 100644 --- a/src/main/java/binnie/botany/flower/EnumTubeInsulate.java +++ b/src/main/java/binnie/botany/flower/EnumTubeInsulate.java @@ -6,19 +6,19 @@ import net.minecraft.item.ItemStack; import binnie.core.util.I18N; enum EnumTubeInsulate { - Clay(0xa1aacc, "clay"), - Cobble(0x7b7b7b, "cobblestone"), - Sand(0xefeab5, "sandstone"), - HardenedClay(0x935c43, "hardened_clay"), - Stone(0x6d6d6d, "stone"), - Sandstone(0xc1b989, "sandstone"); + CLAY(0xa1aacc, "clay"), + COBBLE(0x7b7b7b, "cobblestone"), + SAND(0xefeab5, "sandstone"), + HARDENED_CLAY(0x935c43, "hardened_clay"), + STONE(0x6d6d6d, "stone"), + SANDSTONE(0xc1b989, "sandstone"); public static final EnumTubeInsulate[] VALUES = values(); - + int color; String name; - EnumTubeInsulate(final int color, final String name) { + EnumTubeInsulate(int color, String name) { this.color = color; this.name = name; } @@ -28,7 +28,7 @@ enum EnumTubeInsulate { } public int getColor() { - return this.color; + return color; } public String getDisplayName() { @@ -37,27 +37,24 @@ enum EnumTubeInsulate { public ItemStack getStack() { switch (this) { - case Clay: { + case CLAY: return new ItemStack(Blocks.CLAY); - } - case Cobble: { + + case COBBLE: return new ItemStack(Blocks.COBBLESTONE); - } - case HardenedClay: { + + case HARDENED_CLAY: return new ItemStack(Blocks.HARDENED_CLAY); - } - case Sand: { + + case SAND: return new ItemStack(Blocks.SAND); - } - case Sandstone: { + + case SANDSTONE: return new ItemStack(Blocks.SANDSTONE); - } - case Stone: { + + case STONE: return new ItemStack(Blocks.STONE); - } - default: { - throw new IllegalStateException("Unknown insulated tube type: " + this); - } } + throw new IllegalStateException("Unknown insulated tube type: " + this); } } diff --git a/src/main/java/binnie/botany/flower/EnumTubeMaterial.java b/src/main/java/binnie/botany/flower/EnumTubeMaterial.java index 1a8d8405..cf6e31d6 100644 --- a/src/main/java/binnie/botany/flower/EnumTubeMaterial.java +++ b/src/main/java/binnie/botany/flower/EnumTubeMaterial.java @@ -3,17 +3,17 @@ package binnie.botany.flower; import binnie.core.util.I18N; enum EnumTubeMaterial { - Copper(0xe3b78e, "copper"), - Tin(0xe1eef4, "tin"), - Bronze(0xddc276, "bronze"), - Iron(0xd8d8d8, "iron"); + COPPER(0xe3b78e, "copper"), + TIN(0xe1eef4, "tin"), + BRONZE(0xddc276, "bronze"), + IRON(0xd8d8d8, "iron"); public static final EnumTubeMaterial[] VALUES = values(); - + int color; String name; - EnumTubeMaterial(final int color, final String name) { + EnumTubeMaterial(int color, String name) { this.color = color; this.name = name; } @@ -23,9 +23,9 @@ enum EnumTubeMaterial { } public int getColor() { - return this.color; + return color; } - + public String getDisplayName() { return I18N.localise("botany.tube.material." + name + ".name"); } diff --git a/src/main/java/binnie/botany/flower/FlowerSpriteManager.java b/src/main/java/binnie/botany/flower/FlowerSpriteManager.java index 5858f068..30c44abc 100644 --- a/src/main/java/binnie/botany/flower/FlowerSpriteManager.java +++ b/src/main/java/binnie/botany/flower/FlowerSpriteManager.java @@ -62,18 +62,18 @@ public class FlowerSpriteManager { private int sections; public FlowerSprites(IFlowerType type) { - this.sections = type.getSections(); - this.stem = new BinnieSprite[sections]; - this.petal = new BinnieSprite[sections]; - this.variant = new BinnieSprite[sections]; - this.unflowered = new BinnieSprite[sections]; + sections = type.getSections(); + stem = new BinnieSprite[sections]; + petal = new BinnieSprite[sections]; + variant = new BinnieSprite[sections]; + unflowered = new BinnieSprite[sections]; for (int section = 0; section < sections; ++section) { - final String suf = (section == 0) ? "" : ("" + (section + 1)); - final String pre = (sections == 1) ? "" : "double/"; - this.stem[section] = Binnie.RESOURCE.getBlockSprite(Botany.instance, "flowers/" + pre + type.toString().toLowerCase() + suf + ".0"); - this.petal[section] = Binnie.RESOURCE.getBlockSprite(Botany.instance, "flowers/" + pre + type.toString().toLowerCase() + suf + ".1"); - this.variant[section] = Binnie.RESOURCE.getBlockSprite(Botany.instance, "flowers/" + pre + type.toString().toLowerCase() + suf + ".2"); - this.unflowered[section] = Binnie.RESOURCE.getBlockSprite(Botany.instance, "flowers/" + pre + type.toString().toLowerCase() + suf + ".3"); + String suf = (section == 0) ? "" : ("" + (section + 1)); + String pre = (sections == 1) ? "" : "double/"; + stem[section] = Binnie.RESOURCE.getBlockSprite(Botany.instance, "flowers/" + pre + type.toString().toLowerCase() + suf + ".0"); + petal[section] = Binnie.RESOURCE.getBlockSprite(Botany.instance, "flowers/" + pre + type.toString().toLowerCase() + suf + ".1"); + variant[section] = Binnie.RESOURCE.getBlockSprite(Botany.instance, "flowers/" + pre + type.toString().toLowerCase() + suf + ".2"); + unflowered[section] = Binnie.RESOURCE.getBlockSprite(Botany.instance, "flowers/" + pre + type.toString().toLowerCase() + suf + ".3"); } } @@ -84,13 +84,13 @@ public class FlowerSpriteManager { @SideOnly(Side.CLIENT) public TextureAtlasSprite getPetal(IFlowerType type, int section, boolean flowered) { - return (flowered ? petal[section % this.sections] : this.unflowered[section % this.sections]).getSprite(); + return (flowered ? petal[section % sections] : unflowered[section % sections]).getSprite(); } @Nullable @SideOnly(Side.CLIENT) public TextureAtlasSprite getVariant(IFlowerType type, int section, boolean flowered) { - return flowered ? variant[section % this.sections].getSprite() : null; + return flowered ? variant[section % sections].getSprite() : null; } } } diff --git a/src/main/java/binnie/botany/flower/ItemBotany.java b/src/main/java/binnie/botany/flower/ItemBotany.java index 8b619a8e..cce76fa6 100644 --- a/src/main/java/binnie/botany/flower/ItemBotany.java +++ b/src/main/java/binnie/botany/flower/ItemBotany.java @@ -54,13 +54,13 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister private EnumFlowerStage type; private String tag; - public ItemBotany(final String name, EnumFlowerStage type, String tag) { - this.setCreativeTab(CreativeTabBotany.instance); - this.setUnlocalizedName(name); - setRegistryName(name); - this.hasSubtypes = true; + public ItemBotany(String name, EnumFlowerStage type, String tag) { this.type = type; this.tag = tag; + setCreativeTab(CreativeTabBotany.instance); + setUnlocalizedName(name); + setRegistryName(name); + hasSubtypes = true; } @Override @@ -79,22 +79,23 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister } @Override - public boolean hasEffect(final ItemStack itemstack) { + public boolean hasEffect(ItemStack itemstack) { if (!itemstack.hasTagCompound()) { return false; } - final IIndividual individual = this.getIndividual(itemstack); + IIndividual individual = getIndividual(itemstack); return individual != null && individual.hasEffect(); } @Override @SideOnly(Side.CLIENT) - public void addInformation(final ItemStack itemStack, final EntityPlayer player, final List list, final boolean flag) { - IFlower individual = (IFlower) this.getIndividual(itemStack); + public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean flag) { + IFlower individual = (IFlower) getIndividual(itemStack); if (individual == null) { list.add(TextFormatting.DARK_RED + I18N.localise("item.botany.flower.destroy")); return; } + IFlowerGenome genome = individual.getGenome(); //Colors String primaryColor = genome.getPrimaryColor().getColorName(); @@ -120,7 +121,7 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister } @Nullable - protected IIndividual getIndividual(final ItemStack itemstack) { + protected IIndividual getIndividual(ItemStack itemstack) { NBTTagCompound tagCompound = itemstack.getTagCompound(); if (tagCompound == null) { return null; @@ -128,8 +129,8 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister return new Flower(tagCompound); } - private IAlleleFlowerSpecies getPrimarySpecies(final ItemStack itemstack) { - final IFlower tree = BotanyCore.getFlowerRoot().getMember(itemstack); + private IAlleleFlowerSpecies getPrimarySpecies(ItemStack itemstack) { + IFlower tree = BotanyCore.getFlowerRoot().getMember(itemstack); if (tree == null) { return (IAlleleFlowerSpecies) BotanyCore.getFlowerRoot().getDefaultTemplate()[EnumFlowerChromosome.SPECIES.ordinal()]; } @@ -137,11 +138,11 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister } @Override - public String getItemStackDisplayName(final ItemStack itemstack) { + public String getItemStackDisplayName(ItemStack itemstack) { if (!itemstack.hasTagCompound()) { return I18N.localise("item.botany.flower.corrupted.name"); } - IIndividual individual = this.getIndividual(itemstack); + IIndividual individual = getIndividual(itemstack); if (individual != null) { return individual.getDisplayName() + (!tag.isEmpty() ? " " + I18N.localise("item.botany." + tag + ".name") : ""); } @@ -149,12 +150,12 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister } @Override - public void getSubItems(final Item item, final CreativeTabs tab, final NonNullList itemList) { - this.addCreativeItems(itemList, true); + public void getSubItems(Item item, CreativeTabs tab, NonNullList itemList) { + addCreativeItems(itemList, true); } - public void addCreativeItems(final NonNullList itemList, final boolean hideSecrets) { - for (final IIndividual individual : BotanyCore.getFlowerRoot().getIndividualTemplates()) { + public void addCreativeItems(NonNullList itemList, boolean hideSecrets) { + for (IIndividual individual : BotanyCore.getFlowerRoot().getIndividualTemplates()) { if (hideSecrets && individual.isSecret() && !Config.isDebug) { continue; } @@ -166,9 +167,14 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister public int getColorFromItemstack(ItemStack stack, int tintIndex) { IFlower flower = BotanyCore.getFlowerRoot().getMember(stack); if (flower == null) { - return 16777215; + return 0xffffff; } - return (tintIndex == 0) ? flower.getGenome().getStemColor().getColor(flower.isWilted()) : ((tintIndex == 1) ? flower.getGenome().getPrimaryColor().getColor(flower.isWilted()) : flower.getGenome().getSecondaryColor().getColor(flower.isWilted())); + if (tintIndex == 0) { + return flower.getGenome().getStemColor().getColor(flower.isWilted()); + } + return (tintIndex == 1) + ? flower.getGenome().getPrimaryColor().getColor(flower.isWilted()) + : flower.getGenome().getSecondaryColor().getColor(flower.isWilted()); } @Override @@ -184,12 +190,12 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); if (type == EnumFlowerStage.POLLEN) { - final IFlower flower = Binnie.GENETICS.getFlowerRoot().getMember(stack); - final TileEntity target = world.getTileEntity(pos); + IFlower flower = Binnie.GENETICS.getFlowerRoot().getMember(stack); + TileEntity target = world.getTileEntity(pos); if (!(target instanceof IPollinatable)) { return EnumActionResult.PASS; } - final IPollinatable pollinatable = (IPollinatable) target; + IPollinatable pollinatable = (IPollinatable) target; if (!pollinatable.canMateWith(flower)) { return EnumActionResult.FAIL; } @@ -198,29 +204,28 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister stack.shrink(1); } return EnumActionResult.SUCCESS; - } else { - IBlockState iblockstate = world.getBlockState(pos); - Block block = iblockstate.getBlock(); - - if (!block.isReplaceable(world, pos)) { - pos = pos.offset(facing); - } - - if (stack.getCount() != 0 && player.canPlayerEdit(pos, facing, stack) && world.mayPlace(Botany.flower, pos, false, facing, null)) { - int i = this.getMetadata(stack.getMetadata()); - IBlockState iblockstate1 = Botany.flower.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, i, player, hand); - - if (placeBlockAt(stack, player, world, pos, facing, hitX, hitY, hitZ, iblockstate1)) { - SoundType soundtype = world.getBlockState(pos).getBlock().getSoundType(world.getBlockState(pos), world, pos, player); - world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); - stack.shrink(1); - } - - return EnumActionResult.SUCCESS; - } else { - return EnumActionResult.FAIL; - } } + + IBlockState iblockstate = world.getBlockState(pos); + Block block = iblockstate.getBlock(); + + if (!block.isReplaceable(world, pos)) { + pos = pos.offset(facing); + } + + if (stack.getCount() != 0 && player.canPlayerEdit(pos, facing, stack) && world.mayPlace(Botany.flower, pos, false, facing, null)) { + int i = getMetadata(stack.getMetadata()); + IBlockState iblockstate1 = Botany.flower.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, i, player, hand); + + if (placeBlockAt(stack, player, world, pos, facing, hitX, hitY, hitZ, iblockstate1)) { + SoundType soundtype = world.getBlockState(pos).getBlock().getSoundType(world.getBlockState(pos), world, pos, player); + world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); + stack.shrink(1); + } + + return EnumActionResult.SUCCESS; + } + return EnumActionResult.FAIL; } public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) { diff --git a/src/main/java/binnie/botany/flower/ItemInsulatedTube.java b/src/main/java/binnie/botany/flower/ItemInsulatedTube.java index e09ebeed..db3a4cb9 100644 --- a/src/main/java/binnie/botany/flower/ItemInsulatedTube.java +++ b/src/main/java/binnie/botany/flower/ItemInsulatedTube.java @@ -112,6 +112,10 @@ public class ItemInsulatedTube extends ItemCore implements IColoredItem { @Override public String getItemStackDisplayName(ItemStack itemStack) { int meta = itemStack.getMetadata(); - return I18N.localise("item.botany.insulated_tube.name", EnumTubeMaterial.get(meta).getDisplayName(), EnumTubeInsulate.get(meta).getDisplayName()); + return I18N.localise( + "item.botany.insulated_tube.name", + EnumTubeMaterial.get(meta).getDisplayName(), + EnumTubeInsulate.get(meta).getDisplayName() + ); } } diff --git a/src/main/java/binnie/botany/flower/StateMapperFlower.java b/src/main/java/binnie/botany/flower/StateMapperFlower.java index d902785d..3e06d73a 100644 --- a/src/main/java/binnie/botany/flower/StateMapperFlower.java +++ b/src/main/java/binnie/botany/flower/StateMapperFlower.java @@ -19,13 +19,14 @@ import binnie.botany.api.IFlowerType; public class StateMapperFlower extends StateMapperBase { @Override protected ModelResourceLocation getModelResourceLocation(IBlockState state) { - final Map, Comparable> properties = Maps.newLinkedHashMap(state.getProperties()); + Map, Comparable> properties = Maps.newLinkedHashMap(state.getProperties()); IFlowerType flowerType = (IFlowerType) state.getValue(BlockFlower.FLOWER); if (flowerType.getSections() < 2) { properties.remove(BlockFlower.SECTION); } else if (flowerType.getSections() <= state.getValue(BlockFlower.SECTION)) { properties.put(BlockFlower.SECTION, flowerType.getSections() - 1); } + if (state.getValue(BlockFlower.SEED)) { properties.remove(BlockFlower.SECTION); properties.remove(BlockFlower.FLOWER); @@ -33,7 +34,6 @@ public class StateMapperFlower extends StateMapperBase { } else { properties.remove(BlockFlower.SEED); } - return new ModelResourceLocation(Constants.BOTANY_MOD_ID + ":flower", getPropertyString(properties)); } } diff --git a/src/main/java/binnie/botany/flower/TileEntityFlower.java b/src/main/java/binnie/botany/flower/TileEntityFlower.java index f87a5bae..0ad576dd 100644 --- a/src/main/java/binnie/botany/flower/TileEntityFlower.java +++ b/src/main/java/binnie/botany/flower/TileEntityFlower.java @@ -36,13 +36,13 @@ import binnie.botany.api.EnumFlowerStage; import binnie.botany.api.EnumSoilType; import binnie.botany.api.IAlleleFlowerSpecies; import binnie.botany.api.IFlower; -import binnie.botany.api.IFlowerColour; +import binnie.botany.api.IFlowerColor; import binnie.botany.api.IFlowerGenome; import binnie.botany.api.IFlowerRoot; import binnie.botany.api.IFlowerType; import binnie.botany.api.IGardeningManager; import binnie.botany.core.BotanyCore; -import binnie.botany.gardening.BlockPlant; +import binnie.botany.gardening.PlantType; import binnie.botany.genetics.EnumFlowerColor; import binnie.botany.genetics.EnumFlowerType; import binnie.botany.genetics.Flower; @@ -61,65 +61,73 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt int matureTime; public TileEntityFlower() { - this.flower = null; - this.section = 0; - this.renderInfo = null; - this.matureTime = 0; + flower = null; + section = 0; + renderInfo = null; + matureTime = 0; } @Override - public void readFromNBT(final NBTTagCompound nbtCompound) { + public void readFromNBT(NBTTagCompound nbtCompound) { if (nbtCompound.hasKey("Flower")) { - this.flower = new Flower(nbtCompound.getCompoundTag("Flower")); + flower = new Flower(nbtCompound.getCompoundTag("Flower")); if (flower.getAge() == 0) { flower.setFlowered(false); } } + if (nbtCompound.hasKey("section")) { - this.section = nbtCompound.getByte("section"); + section = nbtCompound.getByte("section"); } + if (nbtCompound.hasKey("owner")) { - this.owner = NBTUtil.readGameProfileFromNBT(nbtCompound.getCompoundTag("owner")); + owner = NBTUtil.readGameProfileFromNBT(nbtCompound.getCompoundTag("owner")); } + if (nbtCompound.hasKey("CATER") && BinnieCore.isLepidopteryActive()) { - this.matureTime = nbtCompound.getInteger("caterTime"); - this.caterpillar = Binnie.GENETICS.getButterflyRoot().getMember(nbtCompound.getCompoundTag("cater")); + matureTime = nbtCompound.getInteger("caterTime"); + caterpillar = Binnie.GENETICS.getButterflyRoot().getMember(nbtCompound.getCompoundTag("cater")); } + readRenderInfo(nbtCompound); super.readFromNBT(nbtCompound); } @Override - public NBTTagCompound writeToNBT(final NBTTagCompound nbtCompound) { - if (this.flower != null) { + public NBTTagCompound writeToNBT(NBTTagCompound nbtCompound) { + if (flower != null) { nbtCompound.setTag("Flower", flower.writeToNBT(new NBTTagCompound())); } - if (this.owner != null) { - final NBTTagCompound nbt = new NBTTagCompound(); - NBTUtil.writeGameProfile(nbt, this.owner); + + if (owner != null) { + NBTTagCompound nbt = new NBTTagCompound(); + NBTUtil.writeGameProfile(nbt, owner); nbtCompound.setTag("owner", nbt); } - if (this.caterpillar != null) { - nbtCompound.setInteger("caterTime", this.matureTime); - final NBTTagCompound subcompound = new NBTTagCompound(); - this.caterpillar.writeToNBT(subcompound); + + if (caterpillar != null) { + nbtCompound.setInteger("caterTime", matureTime); + NBTTagCompound subcompound = new NBTTagCompound(); + caterpillar.writeToNBT(subcompound); nbtCompound.setTag("cater", subcompound); } + nbtCompound.setByte("section", (byte) getSection()); return super.writeToNBT(nbtCompound); } - public void create(final ItemStack stack, @Nullable final GameProfile owner) { + public void create(ItemStack stack, @Nullable GameProfile owner) { IFlower flower = BotanyCore.getFlowerRoot().getMember(stack); - this.create(flower, owner); + create(flower, owner); } - public void create(final IFlower flower, @Nullable final GameProfile owner) { + public void create(IFlower flower, @Nullable GameProfile owner) { this.flower = flower; - if (this.flower.getAge() == 0) { - this.flower.setFlowered(false); + if (flower.getAge() == 0) { + flower.setFlowered(false); } - this.updateRender(true); + + updateRender(true); this.owner = owner; } @@ -131,33 +139,40 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt @Override @Nullable public IIndividual getPollen() { - return this.getFlower(); + return getFlower(); } @Override - public boolean canMateWith(final IIndividual individual) { - return this.isBreeding() && individual instanceof IFlower && this.getFlower() != null && this.getFlower().getMate() == null && this.getFlower().hasFlowered() && !this.getFlower().isGeneticEqual(individual); + public boolean canMateWith(IIndividual individual) { + return isBreeding() + && individual instanceof IFlower + && getFlower() != null + && getFlower().getMate() == null + && getFlower().hasFlowered() + && !getFlower().isGeneticEqual(individual); } @Override - public void mateWith(final IIndividual individual) { - if (this.getFlower() == null || !(individual instanceof IFlower)) { + public void mateWith(IIndividual individual) { + if (getFlower() == null || !(individual instanceof IFlower)) { return; } - final IAlleleFlowerSpecies primary = (IAlleleFlowerSpecies) individual.getGenome().getPrimary(); - final IAlleleFlowerSpecies primary2 = this.getFlower().getGenome().getPrimary(); - if (primary == primary2 || this.world.rand.nextInt(4) == 0) { - this.getFlower().mate((IFlower) individual); + + IAlleleFlowerSpecies primary = (IAlleleFlowerSpecies) individual.getGenome().getPrimary(); + IAlleleFlowerSpecies primary2 = getFlower().getGenome().getPrimary(); + if (primary == primary2 || world.rand.nextInt(4) == 0) { + getFlower().mate((IFlower) individual); world.markBlockRangeForRenderUpdate(pos, pos); } } @Nullable public IFlower getFlower() { - if (this.getSection() <= 0) { - return this.flower; + if (getSection() <= 0) { + return flower; } - TileEntity tile = this.world.getTileEntity(pos.down(getSection())); + + TileEntity tile = world.getTileEntity(pos.down(getSection())); if (tile instanceof TileEntityFlower) { return ((TileEntityFlower) tile).getFlower(); } @@ -165,73 +180,82 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt } public boolean isBreeding() { - final Block roots = this.getWorld().getBlockState(getPos().down()).getBlock(); + Block roots = getWorld().getBlockState(getPos().down()).getBlock(); return BotanyCore.getGardening().isSoil(roots); } - public void randomUpdate(final Random rand) { - if (this.world.getBlockState(pos).getBlock() != Botany.flower) { - this.invalidate(); + public void randomUpdate(Random rand) { + if (world.getBlockState(pos).getBlock() != Botany.flower) { + invalidate(); return; } - if (this.getSection() > 0) { + if (getSection() > 0) { return; } - if (this.flower == null) { + if (flower == null) { return; } - if (this.flower.getGenome() == null) { - this.invalidate(); + + // TODO always false? + if (flower.getGenome() == null) { + invalidate(); return; } - if (!this.isBreeding()) { + if (!isBreeding()) { return; } - float light = this.world.getLight(pos); + + float light = world.getLight(pos); if (light < 6.0f) { for (int dx = -2; dx <= 2; ++dx) { for (int dy = -2; dy <= 2; ++dy) { - light -= (this.world.canBlockSeeSky(pos) ? 0.0f : 0.5f); + light -= (world.canBlockSeeSky(pos) ? 0.0f : 0.5f); } } } + IGardeningManager gardening = BotanyCore.getGardening(); - final boolean canTolerate = gardening.canTolerate(this.getFlower(), this.world, pos); - final EnumSoilType soil = gardening.getSoilType(this.world, pos.down()); - if (rand.nextFloat() < this.getFlower().getGenome().getAgeChance()) { - if (this.flower.getAge() < 1) { + boolean canTolerate = gardening.canTolerate(getFlower(), world, pos); + EnumSoilType soil = gardening.getSoilType(world, pos.down()); + if (rand.nextFloat() < getFlower().getGenome().getAgeChance()) { + if (flower.getAge() < 1) { if (canTolerate && light > 6.0f) { - this.doFlowerAge(); + doFlowerAge(); } } else { - this.doFlowerAge(); + doFlowerAge(); } } - if (canTolerate && this.flower.getAge() > 1 && !this.flower.isWilted() && light > 6.0f) { - this.flower.setFlowered(true); + + if (canTolerate && flower.getAge() > 1 && !flower.isWilted() && light > 6.0f) { + flower.setFlowered(true); } - if (!canTolerate && this.flower.isWilted() && rand.nextInt(2 + Math.max(this.flower.getAge(), 2)) == 0) { - this.kill(); + + if (!canTolerate && flower.isWilted() && rand.nextInt(2 + Math.max(flower.getAge(), 2)) == 0) { + kill(); return; } - if (light < 2.0f && this.flower.isWilted()) { - this.kill(); + + if (light < 2.0f && flower.isWilted()) { + kill(); return; } + if (!canTolerate || light < 1.0f) { - this.flower.setWilted(true); + flower.setWilted(true); } else { - this.flower.setWilted(false); + flower.setWilted(false); } + float CHANCE_DISPERSAL = 0.8f; - CHANCE_DISPERSAL += 0.2f * this.flower.getGenome().getFertility(); + CHANCE_DISPERSAL += 0.2f * flower.getGenome().getFertility(); CHANCE_DISPERSAL *= 1.0f + soil.ordinal() * 0.5f; float CHANCE_POLLINATE = 1.0f; - CHANCE_POLLINATE += 0.25f * this.flower.getGenome().getFertility(); + CHANCE_POLLINATE += 0.25f * flower.getGenome().getFertility(); CHANCE_POLLINATE *= 1.0f + soil.ordinal() * 0.5f; - final float CHANCE_SELFPOLLINATE = 0.2f * CHANCE_POLLINATE; - if (this.world.rand.nextFloat() < CHANCE_DISPERSAL && this.flower.hasFlowered() && !this.flower.isWilted()) { - final IFlowerGenome mate = this.flower.getMate(); + float CHANCE_SELFPOLLINATE = 0.2f * CHANCE_POLLINATE; + if (world.rand.nextFloat() < CHANCE_DISPERSAL && flower.hasFlowered() && !flower.isWilted()) { + IFlowerGenome mate = flower.getMate(); if (mate != null) { boolean dispersed = false; for (int a = 0; a < 5 && !dispersed; ++a) { @@ -240,68 +264,70 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt for (dx2 = 0, dz = 0; dx2 == 0 && dz == 0; dx2 = rand.nextInt(3) - 1, dz = rand.nextInt(3) - 1) { } - final Block b2 = world.getBlockState(pos.add(dx2, -1, dz)).getBlock(); + Block b2 = world.getBlockState(pos.add(dx2, -1, dz)).getBlock(); if (world.isAirBlock(pos.add(dx2, 0, dz)) && BotanyCore.getGardening().isSoil(b2)) { - final IFlower offspring = this.flower.getOffspring(world, pos); + IFlower offspring = flower.getOffspring(world, pos); if (offspring != null) { - BotanyCore.getFlowerRoot().plant(world, pos.add(dx2, 0, dz), offspring, this.getOwner()); - this.flower.removeMate(); + BotanyCore.getFlowerRoot().plant(world, pos.add(dx2, 0, dz), offspring, getOwner()); + flower.removeMate(); dispersed = true; } } } } } - if (this.world.rand.nextFloat() < CHANCE_POLLINATE && this.flower.hasFlowered() && !this.flower.isWilted()) { + + if (world.rand.nextFloat() < CHANCE_POLLINATE && flower.hasFlowered() && !flower.isWilted()) { for (int a2 = 0; a2 < 4; ++a2) { int dx3; int dz2; for (dx3 = 0, dz2 = 0; dx3 == 0 && dz2 == 0; dx3 = rand.nextInt(5) - 2, dz2 = rand.nextInt(5) - 2) { } - final TileEntity tile = world.getTileEntity(pos.add(dx3, 0, dz2)); - if (tile instanceof IPollinatable && ((IPollinatable) tile).canMateWith(this.getFlower())) { - ((IPollinatable) tile).mateWith(this.getFlower()); + TileEntity tile = world.getTileEntity(pos.add(dx3, 0, dz2)); + if (tile instanceof IPollinatable && ((IPollinatable) tile).canMateWith(getFlower())) { + ((IPollinatable) tile).mateWith(getFlower()); } } } - if (this.world.rand.nextFloat() < CHANCE_SELFPOLLINATE && this.flower.hasFlowered() && this.flower.getMate() == null) { - this.mateWith(this.getFlower()); + + if (world.rand.nextFloat() < CHANCE_SELFPOLLINATE && flower.hasFlowered() && flower.getMate() == null) { + mateWith(getFlower()); } - this.spawnButterflies(); - this.matureCaterpillar(); - this.checkIfDead(false); - this.updateRender(true); + spawnButterflies(); + matureCaterpillar(); + checkIfDead(false); + updateRender(true); } private void doFlowerAge() { - this.getFlower().age(); - if (this.getFlower().getAge() == 1) { + getFlower().age(); + if (getFlower().getAge() == 1) { IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot(); - flowerRoot.onGrowFromSeed(this.world, pos); - if (this.getOwner() != null && this.getFlower() != null) { - flowerRoot.getBreedingTracker(world, this.getOwner()).registerBirth(this.getFlower()); + flowerRoot.onGrowFromSeed(world, pos); + if (getOwner() != null && getFlower() != null) { + flowerRoot.getBreedingTracker(world, getOwner()).registerBirth(getFlower()); } } } - private NBTTagCompound writeRenderInfo(NBTTagCompound tag){ - if(renderInfo!=null){ + private NBTTagCompound writeRenderInfo(NBTTagCompound tag) { + if (renderInfo != null) { NBTTagCompound nbtRenderInfo = new NBTTagCompound(); - nbtRenderInfo.setByte("primary",(byte)this.renderInfo.primary.getID()); - nbtRenderInfo.setByte("secondary",(byte)this.renderInfo.secondary.getID()); - nbtRenderInfo.setByte("stem",(byte)this.renderInfo.stem.getID()); - nbtRenderInfo.setByte("type",(byte)this.renderInfo.type.ordinal()); - nbtRenderInfo.setByte("age",this.renderInfo.age); - nbtRenderInfo.setByte("section",this.renderInfo.section); - nbtRenderInfo.setBoolean("wilted",this.renderInfo.wilted); - nbtRenderInfo.setBoolean("flowered",this.renderInfo.flowered); + nbtRenderInfo.setByte("primary", (byte) renderInfo.primary.getID()); + nbtRenderInfo.setByte("secondary", (byte) renderInfo.secondary.getID()); + nbtRenderInfo.setByte("stem", (byte) renderInfo.stem.getID()); + nbtRenderInfo.setByte("type", (byte) renderInfo.type.ordinal()); + nbtRenderInfo.setByte("age", renderInfo.age); + nbtRenderInfo.setByte("section", renderInfo.section); + nbtRenderInfo.setBoolean("wilted", renderInfo.wilted); + nbtRenderInfo.setBoolean("flowered", renderInfo.flowered); tag.setTag("renderinfo", nbtRenderInfo); } return tag; } - private void readRenderInfo(NBTTagCompound tag){ - if(tag.hasKey("renderinfo")){ + private void readRenderInfo(NBTTagCompound tag) { + if (tag.hasKey("renderinfo")) { NBTTagCompound infotag = tag.getCompoundTag("renderinfo"); RenderInfo info = new RenderInfo(); info.primary = EnumFlowerColor.values()[infotag.getByte("primary")].getFlowerColorAllele(); @@ -319,6 +345,7 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt @Override public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { super.onDataPacket(net, pkt); + // TODO client only call? readRenderInfo(pkt.getNbtCompound()); } @@ -330,38 +357,40 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt @Override public SPacketUpdateTileEntity getUpdatePacket() { - if (this.renderInfo == null && this.getFlower() != null && this.getFlower().getGenome() != null) { - this.renderInfo = new RenderInfo(this.getFlower(), this); + // TODO getFlower().getGenome() != null always true? + if (renderInfo == null && getFlower() != null && getFlower().getGenome() != null) { + renderInfo = new RenderInfo(getFlower(), this); } - return (this.renderInfo != null) ? new SPacketUpdateTileEntity(pos, 0, getUpdateTag()) : null; + return (renderInfo != null) ? new SPacketUpdateTileEntity(pos, 0, getUpdateTag()) : null; } - public void updateRender(final boolean update) { - if (update && this.getFlower() != null && this.getFlower().getGenome() != null) { - final RenderInfo newInfo = new RenderInfo(this.getFlower(), this); - if (this.renderInfo == null || !newInfo.equals(this.renderInfo)) { - this.setRender(newInfo); + public void updateRender(boolean update) { + if (update && getFlower() != null && getFlower().getGenome() != null) { + RenderInfo newInfo = new RenderInfo(getFlower(), this); + if (renderInfo == null || !newInfo.equals(renderInfo)) { + setRender(newInfo); } } - final TileEntity above = this.world.getTileEntity(pos.up()); + + TileEntity above = world.getTileEntity(pos.up()); if (above instanceof TileEntityFlower) { ((TileEntityFlower) above).updateRender(true); } } public int getSection() { - return this.section; + return section; } - public void setSection(final int i) { - this.section = i; - if (BinnieCore.getBinnieProxy().isSimulating(this.world)) { - this.updateRender(true); + public void setSection(int i) { + section = i; + if (BinnieCore.getBinnieProxy().isSimulating(world)) { + updateRender(true); } } public ItemStack getItemStack() { - IFlower flower = this.getFlower(); + IFlower flower = getFlower(); if (flower == null) { return ItemStack.EMPTY; } @@ -370,57 +399,61 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt @Nullable private TileEntityFlower getRoot() { - if (this.getSection() == 0) { + if (getSection() == 0) { return null; } - final TileEntity tile = this.world.getTileEntity(pos.down(getSection())); + TileEntity tile = world.getTileEntity(pos.down(getSection())); return (tile instanceof TileEntityFlower) ? ((TileEntityFlower) tile) : null; } public void onShear() { - if (this.getRoot() != null) { - this.getRoot().onShear(); + if (getRoot() != null) { + getRoot().onShear(); } - if (this.getFlower() != null && this.getFlower().getAge() > 1) { - final Random rand = new Random(); - final IFlower cutting = (IFlower) this.getFlower().copy(); - cutting.setAge(0); - final ItemStack cuttingStack = BotanyCore.getFlowerRoot().getMemberStack(cutting, EnumFlowerStage.SEED); - final float f = 0.7f; - final double d = rand.nextFloat() * f + (1.0f - f) * 0.5; - final double d2 = rand.nextFloat() * f + (1.0f - f) * 0.5; - final double d3 = rand.nextFloat() * f + (1.0f - f) * 0.5; - final EntityItem entityitem = new EntityItem(this.world, pos.getX() + d, pos.getY() + d2, pos.getZ() + d3, cuttingStack); - entityitem.setPickupDelay(10); - this.world.spawnEntity(entityitem); - for (int maxAge = this.getFlower().getMaxAge(), i = 0; i < maxAge; ++i) { - if (rand.nextBoolean()) { - this.getFlower().age(); - if (this.checkIfDead(true)) { - return; - } + + if (getFlower() == null || getFlower().getAge() <= 1) { + return; + } + + Random rand = new Random(); + IFlower cutting = (IFlower) getFlower().copy(); + cutting.setAge(0); + ItemStack cuttingStack = BotanyCore.getFlowerRoot().getMemberStack(cutting, EnumFlowerStage.SEED); + float f = 0.7f; + double d = rand.nextFloat() * f + (1.0f - f) * 0.5; + double d2 = rand.nextFloat() * f + (1.0f - f) * 0.5; + double d3 = rand.nextFloat() * f + (1.0f - f) * 0.5; + EntityItem entityitem = new EntityItem(world, pos.getX() + d, pos.getY() + d2, pos.getZ() + d3, cuttingStack); + entityitem.setPickupDelay(10); + world.spawnEntity(entityitem); + for (int maxAge = getFlower().getMaxAge(), i = 0; i < maxAge; ++i) { + if (rand.nextBoolean()) { + getFlower().age(); + if (checkIfDead(true)) { + return; } } } } - public boolean checkIfDead(final boolean wasCut) { - if (this.getSection() != 0) { - return this.getRoot().checkIfDead(wasCut); + public boolean checkIfDead(boolean wasCut) { + if (getSection() != 0) { + return getRoot().checkIfDead(wasCut); } - final EnumSoilType soil = BotanyCore.getGardening().getSoilType(this.world, pos); - final int maxAge = (int) (this.flower.getMaxAge() * (1.0f + soil.ordinal() * 0.25f)); - if (this.flower.getAge() > maxAge) { - if (!wasCut && this.flower.getMate() != null) { - this.world.setBlockToAir(pos); - final IFlower offspring = this.flower.getOffspring(this.world, pos.down()); - final TileEntity above = this.world.getTileEntity(pos.up()); + + EnumSoilType soil = BotanyCore.getGardening().getSoilType(world, pos); + int maxAge = (int) (flower.getMaxAge() * (1.0f + soil.ordinal() * 0.25f)); + if (flower.getAge() > maxAge) { + if (!wasCut && flower.getMate() != null) { + world.setBlockToAir(pos); + IFlower offspring = flower.getOffspring(world, pos.down()); + TileEntity above = world.getTileEntity(pos.up()); if (above instanceof TileEntityFlower) { - this.world.setBlockToAir(pos.up()); + world.setBlockToAir(pos.up()); } - BotanyCore.getFlowerRoot().plant(this.world, pos, offspring, this.getOwner()); + BotanyCore.getFlowerRoot().plant(world, pos, offspring, getOwner()); } else { - this.kill(); + kill(); } return true; } @@ -428,42 +461,44 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt } public void kill() { - if (this.flower.getAge() > 0) { - this.world.setBlockState(pos, Botany.plant.getStateFromMeta(BlockPlant.Type.DeadFlower.ordinal()), 2); + if (flower.getAge() > 0) { + world.setBlockState(pos, Botany.plant.getStateFromMeta(PlantType.DEAD_FLOWER.ordinal()), 2); } else { - this.world.setBlockToAir(pos); + world.setBlockToAir(pos); } - for (int i = 1; this.world.getTileEntity(pos.up(i)) instanceof TileEntityFlower; ++i) { - this.world.setBlockToAir(pos.up(i)); + + for (int i = 1; world.getTileEntity(pos.up(i)) instanceof TileEntityFlower; ++i) { + world.setBlockToAir(pos.up(i)); } } public boolean onBonemeal() { - if (this.getFlower() == null) { + if (getFlower() == null) { return false; } - if (!this.isBreeding()) { + if (!isBreeding()) { return false; } - if (this.getFlower().isWilted()) { + if (getFlower().isWilted()) { return false; } + //this.doFlowerAge(); - if (this.getFlower().getAge() > 1 && !this.getFlower().hasFlowered()) { - this.getFlower().setFlowered(true); + if (getFlower().getAge() > 1 && !getFlower().hasFlowered()) { + getFlower().setFlowered(true); } - this.checkIfDead(false); - this.updateRender(true); + checkIfDead(false); + updateRender(true); return true; } @Nullable public GameProfile getOwner() { - return this.owner; + return owner; } - public void setOwner(final GameProfile ownerName) { - this.owner = ownerName; + public void setOwner(GameProfile ownerName) { + owner = ownerName; } public void spawnButterflies() { @@ -510,57 +545,57 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt }*/ } - private void attemptButterflySpawn(final World world, final IButterfly butterfly, final double x, final double y, final double z) { + private void attemptButterflySpawn(World world, IButterfly butterfly, double x, double y, double z) { if (BinnieCore.isLepidopteryActive()) { Binnie.GENETICS.getButterflyRoot().spawnButterflyInWorld(world, butterfly.copy(), x, y + 0.10000000149011612, z); } } public GameProfile getOwnerName() { - return this.getOwner(); + return getOwner(); } @Override public EnumTemperature getTemperature() { - return EnumTemperature.getFromValue(this.world.getBiome(getPos()).getTemperature()); + return EnumTemperature.getFromValue(world.getBiome(getPos()).getTemperature()); } @Override public EnumHumidity getHumidity() { - return EnumHumidity.getFromValue(this.world.getBiome(getPos()).getRainfall()); + return EnumHumidity.getFromValue(world.getBiome(getPos()).getRainfall()); } - public void setErrorState(final int state) { + public void setErrorState(int state) { } public int getErrorOrdinal() { return 0; } - public boolean addProduct(final ItemStack product, final boolean all) { + public boolean addProduct(ItemStack product, boolean all) { return false; } @Override @Nullable public IButterfly getCaterpillar() { - return this.caterpillar; + return caterpillar; } @Override - public void setCaterpillar(@Nullable final IButterfly butterfly) { - this.caterpillar = butterfly; - this.matureTime = 0; + public void setCaterpillar(@Nullable IButterfly butterfly) { + caterpillar = butterfly; + matureTime = 0; } @Override public IIndividual getNanny() { - return this.getFlower(); + return getFlower(); } @Override - public boolean canNurse(final IButterfly butterfly) { - return this.getFlower() != null && !this.getFlower().isWilted() && this.getFlower().getAge() > 1; + public boolean canNurse(IButterfly butterfly) { + return getFlower() != null && !getFlower().isWilted() && getFlower().getAge() > 1; } private void matureCaterpillar() { @@ -589,9 +624,9 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt }*/ } - public void setRender(final RenderInfo render) { - this.renderInfo = render; - this.section = this.renderInfo.section; + public void setRender(RenderInfo render) { + renderInfo = render; + section = renderInfo.section; if (!world.isRemote) { IBlockState blockState = world.getBlockState(pos); world.notifyBlockUpdate(pos, blockState, blockState, 0); @@ -601,40 +636,48 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt } public int getAge() { - return (this.renderInfo == null) ? 1 : this.renderInfo.age; + return (renderInfo == null) ? 1 : renderInfo.age; } public int getRenderSection() { - return (this.renderInfo == null) ? 1 : this.renderInfo.section; + return (renderInfo == null) ? 1 : renderInfo.section; } public boolean isWilted() { - return this.renderInfo != null && this.renderInfo.wilted; + return renderInfo != null && renderInfo.wilted; } public boolean isFlowered() { - return this.renderInfo == null || this.renderInfo.flowered; + return renderInfo == null || renderInfo.flowered; } public int getPrimaryColour() { - return (this.renderInfo == null) ? EnumFlowerColor.Red.getFlowerColorAllele().getColor(false) : this.renderInfo.primary.getColor(this.isWilted()); + return (renderInfo == null) + ? EnumFlowerColor.Red.getFlowerColorAllele().getColor(false) + : renderInfo.primary.getColor(isWilted()); } public int getSecondaryColour() { - return (this.renderInfo == null) ? EnumFlowerColor.Red.getFlowerColorAllele().getColor(false) : this.renderInfo.secondary.getColor(this.isWilted()); + return (renderInfo == null) + ? EnumFlowerColor.Red.getFlowerColorAllele().getColor(false) + : renderInfo.secondary.getColor(isWilted()); } public int getStemColour() { - return (this.renderInfo == null) ? EnumFlowerColor.Green.getFlowerColorAllele().getColor(false) : this.renderInfo.stem.getColor(this.isWilted()); + return (renderInfo == null) + ? EnumFlowerColor.Green.getFlowerColorAllele().getColor(false) + : renderInfo.stem.getColor(isWilted()); } public IFlowerType getType() { - return (this.renderInfo == null) ? EnumFlowerType.Poppy : this.renderInfo.type; + return (renderInfo == null) + ? EnumFlowerType.Poppy + : renderInfo.type; } @Override public Biome getBiome() { - return this.getWorld().getBiome(getPos()); + return getWorld().getBiome(getPos()); } @Nullable @@ -642,10 +685,10 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt return null; } - public void setErrorState(final IErrorState state) { + public void setErrorState(IErrorState state) { } - public boolean setErrorCondition(final boolean condition, final IErrorState errorState) { + public boolean setErrorCondition(boolean condition, IErrorState errorState) { return false; } @@ -669,9 +712,9 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt } public static class RenderInfo { - public IFlowerColour primary; - public IFlowerColour secondary; - public IFlowerColour stem; + public IFlowerColor primary; + public IFlowerColor secondary; + public IFlowerColor stem; public IFlowerType type; public byte age; public boolean wilted; @@ -681,22 +724,22 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt public RenderInfo() { } - public RenderInfo(final IFlower flower, final TileEntityFlower tile) { - this.section = (byte) tile.getSection(); - this.primary = flower.getGenome().getPrimaryColor(); - this.secondary = flower.getGenome().getSecondaryColor(); - this.stem = flower.getGenome().getStemColor(); - this.age = (byte) flower.getAge(); - this.wilted = flower.isWilted(); - this.flowered = flower.hasFlowered(); - this.type = flower.getGenome().getType(); + public RenderInfo(IFlower flower, TileEntityFlower tile) { + section = (byte) tile.getSection(); + primary = flower.getGenome().getPrimaryColor(); + secondary = flower.getGenome().getSecondaryColor(); + stem = flower.getGenome().getStemColor(); + age = (byte) flower.getAge(); + wilted = flower.isWilted(); + flowered = flower.hasFlowered(); + type = flower.getGenome().getType(); } @Override - public boolean equals(final Object obj) { + public boolean equals(Object obj) { if (obj instanceof RenderInfo) { - final RenderInfo o = (RenderInfo) obj; - return o.age == this.age && o.wilted == this.wilted && o.flowered == this.flowered && o.primary == this.primary && o.secondary == this.secondary && o.stem == this.stem && o.type == this.type; + RenderInfo o = (RenderInfo) obj; + return o.age == age && o.wilted == wilted && o.flowered == flowered && o.primary == primary && o.secondary == secondary && o.stem == stem && o.type == type; } return super.equals(obj); } diff --git a/src/main/java/binnie/botany/gardening/BlockPlant.java b/src/main/java/binnie/botany/gardening/BlockPlant.java index 7cc62c70..091fc745 100644 --- a/src/main/java/binnie/botany/gardening/BlockPlant.java +++ b/src/main/java/binnie/botany/gardening/BlockPlant.java @@ -13,7 +13,6 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.IStringSerializable; import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; @@ -25,20 +24,19 @@ import net.minecraftforge.fml.relauncher.SideOnly; import forestry.api.core.IItemModelRegister; import forestry.api.core.IModelManager; -import binnie.botany.Botany; import binnie.botany.CreativeTabBotany; import binnie.botany.api.EnumSoilType; import binnie.botany.api.IBlockSoil; import binnie.botany.core.BotanyCore; public class BlockPlant extends BlockBush implements IItemModelRegister { - public static final PropertyEnum PLANT_TYPE = PropertyEnum.create("plant_type", Type.class); + public static final PropertyEnum PLANT_TYPE = PropertyEnum.create("plant_type", PlantType.class); public BlockPlant() { - this.setRegistryName("plant"); - this.setCreativeTab(CreativeTabBotany.instance); - this.setTickRandomly(true); - this.setSoundType(SoundType.PLANT); + setRegistryName("plant"); + setCreativeTab(CreativeTabBotany.instance); + setTickRandomly(true); + setSoundType(SoundType.PLANT); } public static boolean isWeed(IBlockAccess world, BlockPos pos) { @@ -46,7 +44,8 @@ public class BlockPlant extends BlockBush implements IItemModelRegister { if (!(blockState.getBlock() instanceof BlockPlant)) { return false; } - Type type = blockState.getValue(PLANT_TYPE); + + PlantType type = blockState.getValue(PLANT_TYPE); return type.isWeed(); } @@ -54,7 +53,7 @@ public class BlockPlant extends BlockBush implements IItemModelRegister { @SideOnly(Side.CLIENT) public void registerModel(Item item, IModelManager manager) { int index = 0; - for (Type type : Type.values()) { + for (PlantType type : PlantType.values()) { manager.registerItemModel(item, index, type.getName()); index++; } @@ -72,7 +71,7 @@ public class BlockPlant extends BlockBush implements IItemModelRegister { @Override public IBlockState getStateFromMeta(int meta) { - return getDefaultState().withProperty(PLANT_TYPE, Type.values()[meta]); + return getDefaultState().withProperty(PLANT_TYPE, PlantType.values()[meta]); } @Override @@ -92,49 +91,54 @@ public class BlockPlant extends BlockBush implements IItemModelRegister { @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(final Item p_149666_1_, final CreativeTabs p_149666_2_, final NonNullList subBlocks) { - for (final Type type : Type.values()) { + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, NonNullList subBlocks) { + for (PlantType type : PlantType.values()) { subBlocks.add(type.get()); } } @Override public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) { - final Type type = state.getValue(PLANT_TYPE); + PlantType type = state.getValue(PLANT_TYPE); if (rand.nextInt(4) == 0) { - if (type == Type.Weeds) { - world.setBlockState(pos, state.withProperty(PLANT_TYPE, Type.WeedsLong), 2); - } else if (type == Type.WeedsLong) { - world.setBlockState(pos, state.withProperty(PLANT_TYPE, Type.WeedsVeryLong), 2); - } else if (type == Type.DeadFlower) { - world.setBlockState(pos, state.withProperty(PLANT_TYPE, Type.DecayingFlower), 2); - } else if (type == Type.DecayingFlower) { + if (type == PlantType.WEEDS) { + world.setBlockState(pos, state.withProperty(PLANT_TYPE, PlantType.WEEDS_LONG), 2); + } else if (type == PlantType.WEEDS_LONG) { + world.setBlockState(pos, state.withProperty(PLANT_TYPE, PlantType.WEEDS_VERY_LONG), 2); + } else if (type == PlantType.DEAD_FLOWER) { + world.setBlockState(pos, state.withProperty(PLANT_TYPE, PlantType.DECAYING_FLOWER), 2); + } else if (type == PlantType.DECAYING_FLOWER) { world.setBlockToAir(pos); return; } } + if (rand.nextInt(6) == 0) { - if (type == Type.Weeds) { + if (type == PlantType.WEEDS) { world.setBlockToAir(pos); - } else if (type == Type.WeedsLong) { - world.setBlockState(pos, state.withProperty(PLANT_TYPE, Type.Weeds), 2); - } else if (type == Type.WeedsVeryLong) { - world.setBlockState(pos, state.withProperty(PLANT_TYPE, Type.WeedsLong), 2); + } else if (type == PlantType.WEEDS_LONG) { + world.setBlockState(pos, state.withProperty(PLANT_TYPE, PlantType.WEEDS), 2); + } else if (type == PlantType.WEEDS_VERY_LONG) { + world.setBlockState(pos, state.withProperty(PLANT_TYPE, PlantType.WEEDS_LONG), 2); } } + Block below = world.getBlockState(pos.down()).getBlock(); - if (BotanyCore.getGardening().isSoil(below)) { - IBlockSoil soil = (IBlockSoil) below; - if(rand.nextInt(3) != 0){ - return; - } - if (type.isWeed()) { - if (!soil.degrade(world, pos.down(), EnumSoilType.LOAM)) { - soil.degrade(world, pos.down(), EnumSoilType.SOIL); - } - } else if (type == Type.DecayingFlower && !soil.fertilise(world, pos.down(), EnumSoilType.LOAM)) { - soil.fertilise(world, pos.down(), EnumSoilType.FLOWERBED); + if (!BotanyCore.getGardening().isSoil(below)) { + return; + } + + IBlockSoil soil = (IBlockSoil) below; + if (rand.nextInt(3) != 0) { + return; + } + + if (type.isWeed()) { + if (!soil.degrade(world, pos.down(), EnumSoilType.LOAM)) { + soil.degrade(world, pos.down(), EnumSoilType.SOIL); } + } else if (type == PlantType.DECAYING_FLOWER && !soil.fertilise(world, pos.down(), EnumSoilType.LOAM)) { + soil.fertilise(world, pos.down(), EnumSoilType.FLOWERBED); } } @@ -147,41 +151,4 @@ public class BlockPlant extends BlockBush implements IItemModelRegister { public EnumOffsetType getOffsetType() { return EnumOffsetType.XZ; } - - public enum Type implements IStringSerializable { - Weeds("weeds", true), - WeedsLong("weeds_long", true), - WeedsVeryLong("weeds_very_long", true), - DeadFlower("dead_flower"), - DecayingFlower("decaying_flower"); - - String name; - boolean isWeed; - - Type(String name) { - this(name, false); - } - - Type(String name, boolean isWeed) { - this.name = name; - this.isWeed = isWeed; - } - - public static Type get(int id) { - return values()[id % values().length]; - } - - public ItemStack get() { - return new ItemStack(Botany.plant, 1, this.ordinal()); - } - - public boolean isWeed(){ - return isWeed; - } - - @Override - public String getName() { - return name; - } - } } diff --git a/src/main/java/binnie/botany/gardening/BlockSoil.java b/src/main/java/binnie/botany/gardening/BlockSoil.java index b42a249f..827a569c 100644 --- a/src/main/java/binnie/botany/gardening/BlockSoil.java +++ b/src/main/java/binnie/botany/gardening/BlockSoil.java @@ -47,18 +47,18 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister { public BlockSoil(EnumSoilType type, String blockName, boolean weedKilled) { super(Material.GROUND); + this.type = type; this.weedKilled = weedKilled; setUnlocalizedName("botany.soil." + type.getName()); - this.setCreativeTab(CreativeTabBotany.instance); - this.setRegistryName(blockName); - this.setTickRandomly(true); - this.setLightOpacity(255); - this.setHardness(0.5f); - this.setSoundType(SoundType.GROUND); - this.type = type; + setCreativeTab(CreativeTabBotany.instance); + setRegistryName(blockName); + setTickRandomly(true); + setLightOpacity(255); + setHardness(0.5f); + setSoundType(SoundType.GROUND); } - public static int getMeta(final EnumAcidity acid, final EnumMoisture moisture) { + public static int getMeta(EnumAcidity acid, EnumMoisture moisture) { return acid.ordinal() * 3 + moisture.ordinal(); } @@ -88,6 +88,7 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister { switch (side) { case UP: return true; + case NORTH: case SOUTH: case WEST: @@ -95,9 +96,8 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister { IBlockState iblockstate = blockAccess.getBlockState(pos.offset(side)); Block block = iblockstate.getBlock(); return !iblockstate.isOpaqueCube() && block != Blocks.FARMLAND && block != Blocks.GRASS_PATH && block != this; - default: - return super.shouldSideBeRendered(blockState, blockAccess, pos, side); } + return super.shouldSideBeRendered(blockState, blockAccess, pos, side); } /** @@ -136,7 +136,7 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister { @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(final Item itemIn, final CreativeTabs tab, final NonNullList list) { + public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList list) { for (int i = 0; i < 9; ++i) { list.add(new ItemStack(this, 1, i)); } @@ -151,16 +151,19 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister { if (acidity != EnumAcidity.NEUTRAL) { modelName += acidity.getName(); } + if (moisture != EnumMoisture.NORMAL) { if (!modelName.isEmpty()) { modelName += "_"; } modelName += moisture.getName(); } + if (modelName.isEmpty()) { modelName = "normal"; } - final String identifier; + + String identifier; if (weedKilled) { identifier = type.getName() + "_no_weed/" + modelName; } else { @@ -183,13 +186,13 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister { @Override public IBlockState getStateFromMeta(int meta) { - final EnumMoisture moisture = EnumMoisture.values()[meta % 3]; - final EnumAcidity acidity = EnumAcidity.values()[meta / 3]; + EnumMoisture moisture = EnumMoisture.values()[meta % 3]; + EnumAcidity acidity = EnumAcidity.values()[meta / 3]; return getDefaultState().withProperty(MOISTURE, moisture).withProperty(ACIDITY, acidity); } public EnumSoilType getType() { - return this.type; + return type; } @Override @@ -203,23 +206,24 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister { EnumMoisture desiredMoisture = BotanyCore.getGardening().getNaturalMoisture(world, pos); if (desiredMoisture.ordinal() > moisture.ordinal()) { moisture = ((moisture == EnumMoisture.DRY) ? EnumMoisture.NORMAL : EnumMoisture.DAMP); - } - if (desiredMoisture.ordinal() < moisture.ordinal()) { + } else if (desiredMoisture.ordinal() < moisture.ordinal()) { moisture = ((moisture == EnumMoisture.DAMP) ? EnumMoisture.NORMAL : EnumMoisture.DRY); } + IBlockState blockState = state.withProperty(MOISTURE, moisture); if (state != blockState) { world.setBlockState(pos, blockState, 2); } - if(!weedKilled){ - if(rand.nextInt(5 - getType(world, pos).ordinal()) != 0){ + + if (!weedKilled) { + if (rand.nextInt(5 - getType(world, pos).ordinal()) != 0) { return; } pos = pos.up(); - if(!world.isAirBlock(pos)){ + if (!world.isAirBlock(pos)) { return; } - world.setBlockState(pos, Botany.plant.getStateFromMeta(BlockPlant.Type.Weeds.ordinal()), 2); + world.setBlockState(pos, Botany.plant.getStateFromMeta(PlantType.WEEDS.ordinal()), 2); } } @@ -233,48 +237,48 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister { } @Override - public EnumAcidity getPH(final World world, final BlockPos pos) { + public EnumAcidity getPH(World world, BlockPos pos) { return world.getBlockState(pos).getValue(ACIDITY); } @Override - public EnumMoisture getMoisture(final World world, final BlockPos pos) { + public EnumMoisture getMoisture(World world, BlockPos pos) { return world.getBlockState(pos).getValue(MOISTURE); } @Override - public EnumSoilType getType(final World world, final BlockPos pos) { - return this.type; + public EnumSoilType getType(World world, BlockPos pos) { + return type; } @Override - public boolean fertilise(final World world, final BlockPos pos, final EnumSoilType maxLevel) { - final EnumSoilType type = this.getType(world, pos); + public boolean fertilise(World world, BlockPos pos, EnumSoilType maxLevel) { + EnumSoilType type = getType(world, pos); if (type.ordinal() >= maxLevel.ordinal()) { return false; } - final IBlockState old = world.getBlockState(pos); - return world.setBlockState(pos, BotanyCore.getGardening().getSoilBlock(maxLevel, this.weedKilled).getDefaultState().withProperty(ACIDITY, old.getValue(ACIDITY)).withProperty(MOISTURE, old.getValue(MOISTURE)), 2); + IBlockState old = world.getBlockState(pos); + return world.setBlockState(pos, BotanyCore.getGardening().getSoilBlock(maxLevel, weedKilled).getDefaultState().withProperty(ACIDITY, old.getValue(ACIDITY)).withProperty(MOISTURE, old.getValue(MOISTURE)), 2); } @Override - public boolean degrade(final World world, final BlockPos pos, final EnumSoilType minLevel) { - final EnumSoilType type = this.getType(world, pos); + public boolean degrade(World world, BlockPos pos, EnumSoilType minLevel) { + EnumSoilType type = getType(world, pos); if (type.ordinal() <= minLevel.ordinal()) { return false; } - final IBlockState old = world.getBlockState(pos); - return world.setBlockState(pos, BotanyCore.getGardening().getSoilBlock(minLevel, this.weedKilled).getDefaultState().withProperty(ACIDITY, old.getValue(ACIDITY)).withProperty(MOISTURE, old.getValue(MOISTURE)), 2); + IBlockState old = world.getBlockState(pos); + return world.setBlockState(pos, BotanyCore.getGardening().getSoilBlock(minLevel, weedKilled).getDefaultState().withProperty(ACIDITY, old.getValue(ACIDITY)).withProperty(MOISTURE, old.getValue(MOISTURE)), 2); } @Override - public boolean setPH(final World world, final BlockPos pos, final EnumAcidity pH) { + public boolean setPH(World world, BlockPos pos, EnumAcidity pH) { IBlockState blockState = world.getBlockState(pos); return world.setBlockState(pos, blockState.withProperty(ACIDITY, pH)); } @Override - public boolean setMoisture(final World world, final BlockPos pos, final EnumMoisture moisture) { + public boolean setMoisture(World world, BlockPos pos, EnumMoisture moisture) { IBlockState blockState = world.getBlockState(pos); return world.setBlockState(pos, blockState.withProperty(MOISTURE, moisture)); } @@ -293,15 +297,16 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister { if (plant.getBlock() == Botany.flower) { return true; } + if (plant.getBlock() == Botany.plant) { - return !this.weedKilled || !BlockPlant.isWeed(world, pos); + return !weedKilled || !BlockPlant.isWeed(world, pos); } return world instanceof World && Blocks.DIRT.canSustainPlant(state, world, pos, direction, plantable); } @Override - public boolean resistsWeeds(final World world, final BlockPos pos) { - return this.weedKilled; + public boolean resistsWeeds(World world, BlockPos pos) { + return weedKilled; } public boolean isWeedKilled() { diff --git a/src/main/java/binnie/botany/gardening/Gardening.java b/src/main/java/binnie/botany/gardening/Gardening.java index 18b9b7c5..f17c63c9 100644 --- a/src/main/java/binnie/botany/gardening/Gardening.java +++ b/src/main/java/binnie/botany/gardening/Gardening.java @@ -1,16 +1,11 @@ package binnie.botany.gardening; -import binnie.botany.Botany; -import binnie.botany.api.EnumAcidity; -import binnie.botany.api.EnumMoisture; -import binnie.botany.api.EnumSoilType; -import binnie.botany.api.IBlockSoil; -import binnie.botany.api.IFlower; -import binnie.botany.api.IGardeningManager; -import binnie.botany.items.BotanyItems; -import forestry.api.climate.IClimateInfo; -import forestry.api.core.EnumTemperature; -import forestry.api.core.ForestryAPI; +import javax.annotation.Nullable; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; + import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; @@ -21,35 +16,43 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; -import javax.annotation.Nullable; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.Map; +import forestry.api.climate.IClimateInfo; +import forestry.api.core.EnumTemperature; +import forestry.api.core.ForestryAPI; + +import binnie.botany.Botany; +import binnie.botany.api.EnumAcidity; +import binnie.botany.api.EnumMoisture; +import binnie.botany.api.EnumSoilType; +import binnie.botany.api.IBlockSoil; +import binnie.botany.api.IFlower; +import binnie.botany.api.IGardeningManager; +import binnie.botany.items.BotanyItems; public class Gardening implements IGardeningManager { private final Map fertiliserAcid = new LinkedHashMap<>(); private final Map fertiliserAlkaline = new LinkedHashMap<>(); private final Map fertiliserNutrient = new LinkedHashMap<>(); - + public Gardening() { + // ignored } - + @Override - public boolean isSoil(final Block block) { + public boolean isSoil(Block block) { return block instanceof IBlockSoil; } - + @Override - public boolean isSoil(final Item item) { + public boolean isSoil(Item item) { return item instanceof ItemBlock && isSoil(((ItemBlock) item).getBlock()); } - + @Override - public boolean isSoil(final ItemStack item) { + public boolean isSoil(ItemStack item) { return isSoil(item.getItem()); } - + @Override public EnumMoisture getNaturalMoisture(World world, BlockPos pos) { float bias = getBiomeMoisture(world, pos); @@ -64,9 +67,11 @@ public class Gardening implements IGardeningManager { } } } + if (world.isRaining() && world.canBlockSeeSky(pos.up()) && world.getPrecipitationHeight(pos).getY() <= pos.getY() + 1) { bias += 1.5; } + for (int dx = -1; dx < 2; ++dx) { for (int dz = -1; dz < 2; ++dz) { if (dx != 0 || dz != 0) { @@ -78,13 +83,16 @@ public class Gardening implements IGardeningManager { } return (bias <= -1.0f) ? EnumMoisture.DRY : ((bias >= 1.0f) ? EnumMoisture.DAMP : EnumMoisture.NORMAL); } - + @Override public EnumAcidity getNaturalPH(World world, BlockPos pos) { - final float bias = getBiomePH(world, pos); - return (bias <= -1.0f) ? EnumAcidity.ACID : ((bias >= 1.0f) ? EnumAcidity.ALKALINE : EnumAcidity.NEUTRAL); + float bias = getBiomePH(world, pos); + if (bias <= -1.0f) { + return EnumAcidity.ACID; + } + return (bias >= 1.0f) ? EnumAcidity.ALKALINE : EnumAcidity.NEUTRAL; } - + @Override public float getBiomeMoisture(World world, BlockPos pos) { IClimateInfo info = ForestryAPI.climateManager.getInfo(world, pos); @@ -93,7 +101,7 @@ public class Gardening implements IGardeningManager { double m = 3.2 * (humidity - 0.5) - 0.4 * (1.0 + temperature + 0.5 * temperature * temperature) + 1.1 - 1.6 * (temperature - 0.9) * (temperature - 0.9) - 0.002 * (pos.getY() - 64); return (float) ((m == 0.0) ? m : ((m < 0.0) ? (-Math.sqrt(m * m)) : Math.sqrt(m * m))); } - + @Override public float getBiomePH(World world, BlockPos pos) { IClimateInfo info = ForestryAPI.climateManager.getInfo(world, pos); @@ -101,153 +109,156 @@ public class Gardening implements IGardeningManager { double temperature = info.getTemperature(); return (float) (-3.0 * (humidity - 0.5) + 0.5 * (temperature - 0.699999988079071) * (temperature - 0.699999988079071) + 0.02f * (pos.getY() - 64) - 0.15000000596046448); } - + @Override - public void plantSoil(final World world, final BlockPos pos, final EnumSoilType soil, final EnumMoisture moisture, final EnumAcidity acidity) { - final int meta = moisture.ordinal() + acidity.ordinal() * 3; + public void plantSoil(World world, BlockPos pos, EnumSoilType soil, EnumMoisture moisture, EnumAcidity acidity) { + int meta = moisture.ordinal() + acidity.ordinal() * 3; world.setBlockState(pos, getSoilBlock(soil).getStateFromMeta(meta), 2); } - + @Override public Collection getAcidFertilisers() { return Collections.unmodifiableSet(fertiliserAcid.keySet()); } - + @Override public Collection getAlkalineFertilisers() { return Collections.unmodifiableSet(fertiliserAlkaline.keySet()); } - + @Override public Collection getNutrientFertilisers() { return Collections.unmodifiableSet(fertiliserNutrient.keySet()); } - + @Override public void registerAcidFertiliser(ItemStack stack, int strength) { ModuleGardening.queuedAcidFertilisers.put(stack, strength); fertiliserAcid.put(stack, strength); } - + @Override public void registerAlkalineFertiliser(ItemStack stack, int strength) { ModuleGardening.queuedAlkalineFertilisers.put(stack, strength); fertiliserAlkaline.put(stack, strength); } - + @Override public void registerNutrientFertiliser(ItemStack stack, int strength) { ModuleGardening.queuedNutrientFertilisers.put(stack, strength); fertiliserNutrient.put(stack, strength); } - + @Override - public boolean isAcidFertiliser(final ItemStack itemstack) { - for (final ItemStack stack : getAcidFertilisers()) { + public boolean isAcidFertiliser(ItemStack itemstack) { + for (ItemStack stack : getAcidFertilisers()) { if (!stack.isEmpty() && stack.isItemEqual(itemstack)) { return true; } } return false; } - + @Override - public boolean isAlkalineFertiliser(final ItemStack itemstack) { - for (final ItemStack stack : getAlkalineFertilisers()) { + public boolean isAlkalineFertiliser(ItemStack itemstack) { + for (ItemStack stack : getAlkalineFertilisers()) { if (!stack.isEmpty() && stack.isItemEqual(itemstack)) { return true; } } return false; } - + @Override - public boolean isNutrientFertiliser(final ItemStack itemstack) { - for (final ItemStack stack : getNutrientFertilisers()) { + public boolean isNutrientFertiliser(ItemStack itemstack) { + for (ItemStack stack : getNutrientFertilisers()) { if (!stack.isEmpty() && stack.isItemEqual(itemstack)) { return true; } } return false; } - + @Override - public int getFertiliserStrength(final ItemStack stack) { - for (final Map.Entry entry : fertiliserAcid.entrySet()) { + public int getFertiliserStrength(ItemStack stack) { + for (Map.Entry entry : fertiliserAcid.entrySet()) { if (entry.getKey().isItemEqual(stack)) { return entry.getValue(); } } - for (final Map.Entry entry : fertiliserAlkaline.entrySet()) { + for (Map.Entry entry : fertiliserAlkaline.entrySet()) { if (entry.getKey().isItemEqual(stack)) { return entry.getValue(); } } - for (final Map.Entry entry : fertiliserNutrient.entrySet()) { + for (Map.Entry entry : fertiliserNutrient.entrySet()) { if (entry.getKey().isItemEqual(stack)) { return entry.getValue(); } } return 1; } - + @Override - public boolean canTolerate(@Nullable final IFlower flower, final World world, final BlockPos pos) { + public boolean canTolerate(@Nullable IFlower flower, World world, BlockPos pos) { if (flower == null) { return false; } IBlockState soil = world.getBlockState(pos.down()); - final Block soilBlock = soil.getBlock(); - final int soilMeta = soilBlock.getMetaFromState(soil); - final Biome biome = world.getBiome(pos); - return canTolerate(flower, EnumAcidity.values()[soilMeta / 3 % 3], EnumMoisture.values()[soilMeta % 3], EnumTemperature.getFromValue(biome.getTemperature())); + Block soilBlock = soil.getBlock(); + int soilMeta = soilBlock.getMetaFromState(soil); + Biome biome = world.getBiome(pos); + return canTolerate( + flower, + EnumAcidity.values()[soilMeta / 3 % 3], + EnumMoisture.values()[soilMeta % 3], + EnumTemperature.getFromValue(biome.getTemperature()) + ); } @Override - public EnumSoilType getSoilType(final World world, final BlockPos pos) { + public EnumSoilType getSoilType(World world, BlockPos pos) { if (world.getBlockState(pos).getBlock() instanceof IBlockSoil) { return ((IBlockSoil) world.getBlockState(pos).getBlock()).getType(world, pos); } return EnumSoilType.SOIL; } - + @Override - public Block getSoilBlock(final EnumSoilType type) { + public Block getSoilBlock(EnumSoilType type) { return getSoilBlock(type, false); } - + @Override - public Block getSoilBlock(final EnumSoilType type, final boolean weedKill) { + public Block getSoilBlock(EnumSoilType type, boolean weedKill) { switch (type) { - case FLOWERBED: { + case FLOWERBED: return weedKill ? Botany.flowerbedNoWeed : Botany.flowerbed; - } - case LOAM: { + + case LOAM: return weedKill ? Botany.loamNoWeed : Botany.loam; - } - default: { - return weedKill ? Botany.soilNoWeed : Botany.soil; - } } + return weedKill ? Botany.soilNoWeed : Botany.soil; } - + @Override public boolean canTolerate(IFlower flower, EnumAcidity acidity, EnumMoisture moisture, EnumTemperature temperature) { return flower.getGenome().canTolerate(acidity) - && flower.getGenome().canTolerate(moisture) - && flower.getGenome().canTolerate(temperature); + && flower.getGenome().canTolerate(moisture) + && flower.getGenome().canTolerate(temperature); } - + @Override public boolean isWeedkiller(ItemStack heldItem) { - return heldItem.isItemEqual(BotanyItems.Weedkiller.get(1)); + return heldItem.isItemEqual(BotanyItems.WEEDKILLER.get(1)); } - + @Override public boolean addWeedKiller(World world, BlockPos pos) { if (!(world.getBlockState(pos).getBlock() instanceof IBlockSoil)) { return false; } + EnumSoilType type = getSoilType(world, pos); Block block = getSoilBlock(type, true); IBlockState oldState = world.getBlockState(pos); diff --git a/src/main/java/binnie/botany/gardening/ItemSoil.java b/src/main/java/binnie/botany/gardening/ItemSoil.java index 2a619c54..4f3a2646 100644 --- a/src/main/java/binnie/botany/gardening/ItemSoil.java +++ b/src/main/java/binnie/botany/gardening/ItemSoil.java @@ -19,35 +19,37 @@ public class ItemSoil extends ItemBlock { public ItemSoil(BlockSoil block) { super(block); - this.type = block.getType(); - this.noWeed = block.isWeedKilled(); - this.hasSubtypes = true; + type = block.getType(); + noWeed = block.isWeedKilled(); + hasSubtypes = true; } @Override @SideOnly(Side.CLIENT) - public void addInformation(final ItemStack stack, final EntityPlayer playerIn, final List tooltip, final boolean advanced) { + public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) { String info = ""; info += BlockSoil.getMoisture(stack, true, true); if (info.length() > 0) { info += ", "; } + info += BlockSoil.getPH(stack, true, true); if (info.length() > 0) { tooltip.add(info); } - if (this.noWeed) { + + if (noWeed) { tooltip.add(TextFormatting.GREEN + I18N.localise("botany.soil.weedkiller")); } } @Override public String getItemStackDisplayName(ItemStack stack) { - return this.getUnlocalizedNameInefficiently(stack).trim(); + return getUnlocalizedNameInefficiently(stack).trim(); } @Override - public int getMetadata(final int damage) { + public int getMetadata(int damage) { return damage; } } diff --git a/src/main/java/binnie/botany/gardening/ItemSoilMeter.java b/src/main/java/binnie/botany/gardening/ItemSoilMeter.java index eb17f6ec..6e45f29c 100644 --- a/src/main/java/binnie/botany/gardening/ItemSoilMeter.java +++ b/src/main/java/binnie/botany/gardening/ItemSoilMeter.java @@ -30,9 +30,9 @@ import binnie.core.util.I18N; public class ItemSoilMeter extends Item implements IItemModelRegister { public ItemSoilMeter() { - this.setCreativeTab(CreativeTabBotany.instance); - this.setUnlocalizedName("soil_meter"); - this.setMaxStackSize(1); + setCreativeTab(CreativeTabBotany.instance); + setUnlocalizedName("botany.soil_meter"); + setMaxStackSize(1); setRegistryName("soil_meter"); } @@ -70,26 +70,24 @@ public class ItemSoilMeter extends Item implements IItemModelRegister { pos = pos.down(); block = worldIn.getBlockState(pos).getBlock(); } + if (!gardening.isSoil(block)) { pos = pos.down(); block = worldIn.getBlockState(pos).getBlock(); } + if (gardening.isSoil(block) && !BinnieCore.getBinnieProxy().isSimulating(worldIn)) { IBlockSoil soil = (IBlockSoil) block; - String info = I18N.localise("botany.soil.type") + ": "; - info = info + soil.getType(worldIn, pos).getTranslated(); - info += ", " + TextFormatting.WHITE + I18N.localise("botany.moisture") + ": "; - info = info + soil.getMoisture(worldIn, pos).getLocalisedName(true); - info += ", " + TextFormatting.WHITE + I18N.localise("botany.ph") + ": "; - info = info + soil.getPH(worldIn, pos).getLocalisedName(true); + String info = I18N.localise("botany.soil.type") + ": " + + soil.getType(worldIn, pos).getTranslated() + ", " + + TextFormatting.WHITE + I18N.localise("botany.moisture") + ": " + + soil.getMoisture(worldIn, pos).getLocalisedName(true) + ", " + + TextFormatting.WHITE + I18N.localise("botany.ph") + ": " + + soil.getPH(worldIn, pos).getLocalisedName(true); + ITextComponent chat = new TextComponentString(info); player.sendStatusMessage(chat, false); } return EnumActionResult.SUCCESS; } - - @Override - public String getItemStackDisplayName(final ItemStack i) { - return "Soil Meter"; - } } diff --git a/src/main/java/binnie/botany/gardening/ItemTrowel.java b/src/main/java/binnie/botany/gardening/ItemTrowel.java index 891a42d7..7b5dfd5b 100644 --- a/src/main/java/binnie/botany/gardening/ItemTrowel.java +++ b/src/main/java/binnie/botany/gardening/ItemTrowel.java @@ -42,13 +42,13 @@ public class ItemTrowel extends Item implements IItemModelRegister { protected final String modelName; public ItemTrowel(ToolMaterial toolMaterial, String materialName) { - this.theToolMaterial = toolMaterial; - this.setMaxStackSize(1); - this.setMaxDamage(toolMaterial.getMaxUses()); - this.setCreativeTab(CreativeTabBotany.instance); - this.modelName = "trowel_" + materialName; - this.setUnlocalizedName("botany." + modelName); - this.setRegistryName(modelName); + theToolMaterial = toolMaterial; + setMaxStackSize(1); + setMaxDamage(toolMaterial.getMaxUses()); + setCreativeTab(CreativeTabBotany.instance); + modelName = "trowel_" + materialName; + setUnlocalizedName("botany." + modelName); + setRegistryName(modelName); } @SideOnly(Side.CLIENT) @@ -64,14 +64,17 @@ public class ItemTrowel extends Item implements IItemModelRegister { if (!player.canPlayerEdit(pos, facing, stack)) { return EnumActionResult.FAIL; } + Block block = worldIn.getBlockState(pos).getBlock(); if (facing == EnumFacing.DOWN || (!worldIn.isAirBlock(pos.up()) && worldIn.getBlockState(pos.up()).getBlock() != Botany.flower) || (block != Blocks.GRASS && block != Blocks.DIRT && block != Blocks.GRASS_PATH)) { return EnumActionResult.PASS; } + worldIn.playSound(player, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS, 1.0F, 1.0F); if (worldIn.isRemote) { return EnumActionResult.SUCCESS; } + IGardeningManager gardening = BotanyCore.getGardening(); EnumMoisture moisture = gardening.getNaturalMoisture(worldIn, pos); EnumAcidity acidity = gardening.getNaturalPH(worldIn, pos); @@ -99,7 +102,7 @@ public class ItemTrowel extends Item implements IItemModelRegister { } public String getToolMaterialName() { - return this.theToolMaterial.toString(); + return theToolMaterial.toString(); } @SideOnly(Side.CLIENT) diff --git a/src/main/java/binnie/botany/gardening/ItemWeed.java b/src/main/java/binnie/botany/gardening/ItemWeed.java index 4bd73ea5..dc6b73b6 100644 --- a/src/main/java/binnie/botany/gardening/ItemWeed.java +++ b/src/main/java/binnie/botany/gardening/ItemWeed.java @@ -9,13 +9,13 @@ import binnie.core.util.I18N; public class ItemWeed extends ItemBlock { public ItemWeed(Block block) { super(block); - this.setHasSubtypes(true); - this.hasSubtypes = true; + setHasSubtypes(true); + hasSubtypes = true; } @Override - public String getItemStackDisplayName(final ItemStack stack) { - return I18N.localise("botany.plant." + BlockPlant.Type.values()[stack.getItemDamage()].getName()); + public String getItemStackDisplayName(ItemStack stack) { + return I18N.localise("botany.plant." + PlantType.values()[stack.getItemDamage()].getName()); } @Override diff --git a/src/main/java/binnie/botany/gardening/ModuleGardening.java b/src/main/java/binnie/botany/gardening/ModuleGardening.java index 212dbf25..d89cb23d 100644 --- a/src/main/java/binnie/botany/gardening/ModuleGardening.java +++ b/src/main/java/binnie/botany/gardening/ModuleGardening.java @@ -53,54 +53,58 @@ public class ModuleGardening implements IInitializable { @Override public void preInit() { + // TODO migrate static into BotanyItems Botany.plant = new BlockPlant(); - Botany.proxy.registerBlock(Botany.plant, new ItemWeed(Botany.plant)); Botany.soil = new BlockSoil(EnumSoilType.SOIL, "soil", false); - Botany.proxy.registerBlock(Botany.soil, new ItemSoil(Botany.soil)); Botany.loam = new BlockSoil(EnumSoilType.LOAM, "loam", false); - Botany.proxy.registerBlock(Botany.loam, new ItemSoil(Botany.loam)); Botany.flowerbed = new BlockSoil(EnumSoilType.FLOWERBED, "flowerbed", false); - Botany.proxy.registerBlock(Botany.flowerbed, new ItemSoil(Botany.flowerbed)); Botany.soilNoWeed = new BlockSoil(EnumSoilType.SOIL, "soil_no_weed", true); - Botany.proxy.registerBlock(Botany.soilNoWeed, new ItemSoil(Botany.soilNoWeed)); Botany.loamNoWeed = new BlockSoil(EnumSoilType.LOAM, "loam_no_weed", true); - Botany.proxy.registerBlock(Botany.loamNoWeed, new ItemSoil(Botany.loamNoWeed)); Botany.flowerbedNoWeed = new BlockSoil(EnumSoilType.FLOWERBED, "flowerbed_no_weed", true); - Botany.proxy.registerBlock(Botany.flowerbedNoWeed, new ItemSoil(Botany.flowerbedNoWeed)); Botany.soilMeter = new ItemSoilMeter(); - Botany.proxy.registerItem(Botany.soilMeter); Botany.insulatedTube = new ItemInsulatedTube(); - Botany.proxy.registerItem(Botany.insulatedTube); Botany.trowelWood = new ItemTrowel(Item.ToolMaterial.WOOD, "wood"); - Botany.proxy.registerItem(Botany.trowelWood); Botany.trowelStone = new ItemTrowel(Item.ToolMaterial.STONE, "stone"); - Botany.proxy.registerItem(Botany.trowelStone); Botany.trowelIron = new ItemTrowel(Item.ToolMaterial.IRON, "iron"); - Botany.proxy.registerItem(Botany.trowelIron); Botany.trowelDiamond = new ItemTrowel(Item.ToolMaterial.DIAMOND, "diamond"); - Botany.proxy.registerItem(Botany.trowelDiamond); Botany.trowelGold = new ItemTrowel(Item.ToolMaterial.GOLD, "gold"); - Botany.proxy.registerItem(Botany.trowelGold); Botany.misc = new ItemMisc(CreativeTabBotany.instance, BotanyItems.values()); - Botany.proxy.registerItem(Botany.misc); Botany.pigment = new ItemPigment(); - Botany.proxy.registerItem(Botany.pigment); Botany.clay = new ItemClay(); - Botany.proxy.registerItem(Botany.clay); Botany.ceramic = new BlockCeramic(); + Botany.stained = new BlockStainedGlass(); + Botany.ceramicTile = new BlockCeramicPatterned(); + Botany.ceramicBrick = new BlockCeramicBrick(); + + Botany.proxy.registerBlock(Botany.plant, new ItemWeed(Botany.plant)); + Botany.proxy.registerBlock(Botany.soil, new ItemSoil(Botany.soil)); + Botany.proxy.registerBlock(Botany.loam, new ItemSoil(Botany.loam)); + Botany.proxy.registerBlock(Botany.flowerbed, new ItemSoil(Botany.flowerbed)); + Botany.proxy.registerBlock(Botany.soilNoWeed, new ItemSoil(Botany.soilNoWeed)); + Botany.proxy.registerBlock(Botany.loamNoWeed, new ItemSoil(Botany.loamNoWeed)); + Botany.proxy.registerBlock(Botany.flowerbedNoWeed, new ItemSoil(Botany.flowerbedNoWeed)); + Botany.proxy.registerItem(Botany.soilMeter); + Botany.proxy.registerItem(Botany.insulatedTube); + Botany.proxy.registerItem(Botany.trowelWood); + Botany.proxy.registerItem(Botany.trowelStone); + Botany.proxy.registerItem(Botany.trowelIron); + Botany.proxy.registerItem(Botany.trowelDiamond); + Botany.proxy.registerItem(Botany.trowelGold); + Botany.proxy.registerItem(Botany.misc); + Botany.proxy.registerItem(Botany.pigment); + Botany.proxy.registerItem(Botany.clay); Botany.proxy.registerBlock(Botany.ceramic, new ItemCeramic(Botany.ceramic)); + Botany.proxy.registerBlock(Botany.stained, new ItemStainedGlass(Botany.stained)); + Botany.proxy.registerBlock(Botany.ceramicTile, new ItemDesign(Botany.ceramicTile)); + Botany.proxy.registerBlock(Botany.ceramicBrick, new ItemCeramicBrick(Botany.ceramicBrick)); + BinnieCore.getBinnieProxy().registerTileEntity(TileCeramic.class, "botany.tile.ceramic"); //BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.ceramic), new ItemMetadataRenderer()); - Botany.stained = new BlockStainedGlass(); - Botany.proxy.registerBlock(Botany.stained, new ItemStainedGlass(Botany.stained)); //BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.stained), new ItemMetadataRenderer()); - Botany.ceramicTile = new BlockCeramicPatterned(); - Botany.proxy.registerBlock(Botany.ceramicTile, new ItemDesign(Botany.ceramicTile)); - Botany.ceramicBrick = new BlockCeramicBrick(); - Botany.proxy.registerBlock(Botany.ceramicBrick, new ItemCeramicBrick(Botany.ceramicBrick)); BinnieCore.getBinnieProxy().registerTileEntity(TileCeramicBrick.class, "botany.tile.ceramicBrick"); //BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.ceramicTile), new MultipassItemRenderer()); //BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.ceramicBrick), new MultipassItemRenderer()); + OreDictionary.registerOre("pigment", Botany.pigment); OreDictionary.registerOre("toolTrowel", Botany.trowelWood); OreDictionary.registerOre("toolTrowel", Botany.trowelStone); @@ -113,9 +117,9 @@ public class ModuleGardening implements IInitializable { public void init() { RecipeSorter.register("botany:ceramictile", CeramicTileRecipe.class, RecipeSorter.Category.SHAPED, ""); RecipeSorter.register("botany:pigment", PigmentRecipe.class, RecipeSorter.Category.SHAPED, ""); - final ItemStack yellow = new ItemStack(Blocks.YELLOW_FLOWER, 1); - final ItemStack red = new ItemStack(Blocks.RED_FLOWER, 1); - final ItemStack blue = new ItemStack(Blocks.RED_FLOWER, 1, 7); + ItemStack yellow = new ItemStack(Blocks.YELLOW_FLOWER, 1); + ItemStack red = new ItemStack(Blocks.RED_FLOWER, 1); + ItemStack blue = new ItemStack(Blocks.RED_FLOWER, 1, 7); for (boolean manual : new boolean[]{true, false}) { for (boolean fertilised : new boolean[]{true, false}) { for (EnumMoisture moist : EnumMoisture.values()) { @@ -131,7 +135,7 @@ public class ModuleGardening implements IInitializable { if (fertilised) { insulate += 3; } - new CircuitGarden(moist, null, manual, fertilised, new ItemStack(Botany.insulatedTube, 1, 0 + 128 * insulate), icon); + new CircuitGarden(moist, null, manual, fertilised, new ItemStack(Botany.insulatedTube, 1, 128 * insulate), icon); new CircuitGarden(moist, EnumAcidity.ACID, manual, fertilised, new ItemStack(Botany.insulatedTube, 1, 1 + 128 * insulate), icon); new CircuitGarden(moist, EnumAcidity.NEUTRAL, manual, fertilised, new ItemStack(Botany.insulatedTube, 1, 2 + 128 * insulate), icon); new CircuitGarden(moist, EnumAcidity.ALKALINE, manual, fertilised, new ItemStack(Botany.insulatedTube, 1, 3 + 128 * insulate), icon); @@ -146,80 +150,167 @@ public class ModuleGardening implements IInitializable { GameRegistry.addRecipe(new CeramicTileRecipe()); for (int mat = 0; mat < 4; ++mat) { for (int insulate = 0; insulate < 6; ++insulate) { - final ItemStack tubes = new ItemStack(Botany.insulatedTube, 2, mat + 128 * insulate); - final ItemStack insulateStack = ItemInsulatedTube.getInsulateStack(tubes); - final ItemStack forestryTube = new ItemStack(Mods.Forestry.item("thermionic_tubes"), 1, mat); + ItemStack tubes = new ItemStack(Botany.insulatedTube, 2, mat + 128 * insulate); + ItemStack insulateStack = ItemInsulatedTube.getInsulateStack(tubes); + ItemStack forestryTube = new ItemStack(Mods.Forestry.item("thermionic_tubes"), 1, mat); GameRegistry.addShapelessRecipe(tubes, forestryTube, forestryTube, insulateStack); } } - GameRegistry.addRecipe(new ShapedOreRecipe(Botany.trowelWood, "d ", " x ", " s", 'd', Blocks.DIRT, 's', "stickWood", 'x', "plankWood")); - GameRegistry.addRecipe(new ShapedOreRecipe(Botany.trowelStone, "d ", " x ", " s", 'd', Blocks.DIRT, 's', "stickWood", 'x', "cobblestone")); - GameRegistry.addRecipe(new ShapedOreRecipe(Botany.trowelIron, "d ", " x ", " s", 'd', Blocks.DIRT, 's', "stickWood", 'x', "ingotIron")); - GameRegistry.addRecipe(new ShapedOreRecipe(Botany.trowelGold, "d ", " x ", " s", 'd', Blocks.DIRT, 's', "stickWood", 'x', "ingotGold")); - GameRegistry.addRecipe(new ShapedOreRecipe(Botany.trowelDiamond, "d ", " x ", " s", 'd', Blocks.DIRT, 's', "stickWood", 'x', "gemDiamond")); - GameRegistry.addRecipe(new ShapedOreRecipe(Botany.soilMeter, " gg", " rg", "i ", 'g', "ingotGold", 'r', "dustRedstone", 'i', "ingotIron")); - GameRegistry.addShapelessRecipe(BotanyItems.Weedkiller.get(4), new ItemStack(Items.SPIDER_EYE), new ItemStack(Items.WHEAT_SEEDS), new ItemStack(Items.WHEAT_SEEDS), new ItemStack(Items.WHEAT_SEEDS)); - GameRegistry.addShapelessRecipe(BotanyItems.AshPowder.get(4), Mods.Forestry.stack("ash")); - GameRegistry.addShapelessRecipe(BotanyItems.MulchPowder.get(4), Mods.Forestry.stack("mulch")); - GameRegistry.addShapelessRecipe(BotanyItems.CompostPowder.get(4), Mods.Forestry.stack("fertilizer_bio")); - GameRegistry.addShapelessRecipe(BotanyItems.FertiliserPowder.get(4), Mods.Forestry.stack("fertilizer_compound")); - GameRegistry.addShapelessRecipe(BotanyItems.PulpPowder.get(4), Mods.Forestry.stack("wood_pulp")); - GameRegistry.addRecipe(new ShapelessOreRecipe(BotanyItems.SulphurPowder.get(4), "dustSulphur")); - GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(Botany.pigment, 2, EnumFlowerColor.Black.ordinal()), "pigment", "pigment", "dyeBlack")); - gardening.registerAcidFertiliser(BotanyItems.SulphurPowder.get(1), 1); - gardening.registerAcidFertiliser(BotanyItems.MulchPowder.get(1), 1); + + GameRegistry.addRecipe(new ShapedOreRecipe( + Botany.trowelWood, + "d ", " x ", " s", + 'd', Blocks.DIRT, + 's', "stickWood", + 'x', "plankWood") + ); + + GameRegistry.addRecipe(new ShapedOreRecipe( + Botany.trowelStone, + "d ", " x ", " s", + 'd', Blocks.DIRT, + 's', "stickWood", + 'x', "cobblestone" + )); + + GameRegistry.addRecipe(new ShapedOreRecipe( + Botany.trowelIron, + "d ", " x ", " s", + 'd', Blocks.DIRT, + 's', "stickWood", + 'x', "ingotIron" + )); + + GameRegistry.addRecipe(new ShapedOreRecipe( + Botany.trowelGold, + "d ", " x ", " s", + 'd', Blocks.DIRT, + 's', "stickWood", + 'x', "ingotGold" + )); + + GameRegistry.addRecipe(new ShapedOreRecipe( + Botany.trowelDiamond, + "d ", " x ", " s", + 'd', Blocks.DIRT, + 's', "stickWood", + 'x', "gemDiamond" + )); + + GameRegistry.addRecipe(new ShapedOreRecipe( + Botany.soilMeter, + " gg", " rg", "i ", + 'g', "ingotGold", + 'r', "dustRedstone", + 'i', "ingotIron" + )); + + GameRegistry.addShapelessRecipe( + BotanyItems.WEEDKILLER.get(4), + new ItemStack(Items.SPIDER_EYE), + new ItemStack(Items.WHEAT_SEEDS), + new ItemStack(Items.WHEAT_SEEDS), + new ItemStack(Items.WHEAT_SEEDS) + ); + + GameRegistry.addShapelessRecipe( + BotanyItems.POWDER_ASH.get(4), + Mods.Forestry.stack("ash") + ); + + GameRegistry.addShapelessRecipe( + BotanyItems.POWDER_MULCH.get(4), + Mods.Forestry.stack("mulch") + ); + + GameRegistry.addShapelessRecipe( + BotanyItems.POWDER_COMPOST.get(4), + Mods.Forestry.stack("fertilizer_bio") + ); + + GameRegistry.addShapelessRecipe( + BotanyItems.POWDER_FERTILISER.get(4), + Mods.Forestry.stack("fertilizer_compound") + ); + + GameRegistry.addShapelessRecipe( + BotanyItems.POWDER_PULP.get(4), + Mods.Forestry.stack("wood_pulp") + ); + + GameRegistry.addRecipe(new ShapelessOreRecipe( + BotanyItems.POWDER_SULPHUR.get(4), + "dustSulphur" + )); + + GameRegistry.addRecipe(new ShapelessOreRecipe( + new ItemStack(Botany.pigment, 2, EnumFlowerColor.Black.ordinal()), + "pigment", "pigment", "dyeBlack" + )); + + gardening.registerAcidFertiliser(BotanyItems.POWDER_SULPHUR.get(1), 1); + gardening.registerAcidFertiliser(BotanyItems.POWDER_MULCH.get(1), 1); gardening.registerAcidFertiliser(Mods.Forestry.stack("mulch"), 2); - for (final ItemStack stack : OreDictionary.getOres("dustSulfur")) { + for (ItemStack stack : OreDictionary.getOres("dustSulfur")) { gardening.registerAcidFertiliser(stack, 2); } - gardening.registerAlkalineFertiliser(BotanyItems.AshPowder.get(1), 1); - gardening.registerAlkalineFertiliser(BotanyItems.PulpPowder.get(1), 1); + + gardening.registerAlkalineFertiliser(BotanyItems.POWDER_ASH.get(1), 1); + gardening.registerAlkalineFertiliser(BotanyItems.POWDER_PULP.get(1), 1); gardening.registerAlkalineFertiliser(Mods.Forestry.stack("ash"), 2); gardening.registerAlkalineFertiliser(Mods.Forestry.stack("wood_pulp"), 2); - gardening.registerNutrientFertiliser(BotanyItems.CompostPowder.get(1), 1); - gardening.registerNutrientFertiliser(BotanyItems.FertiliserPowder.get(1), 1); + gardening.registerNutrientFertiliser(BotanyItems.POWDER_COMPOST.get(1), 1); + gardening.registerNutrientFertiliser(BotanyItems.POWDER_FERTILISER.get(1), 1); gardening.registerNutrientFertiliser(Mods.Forestry.stack("fertilizer_bio"), 2); gardening.registerNutrientFertiliser(Mods.Forestry.stack("fertilizer_compound"), 2); - for (final Map.Entry entry : ModuleGardening.queuedAcidFertilisers.entrySet()) { - this.addAcidFertiliserRecipe(entry.getKey(), entry.getValue()); + + for (Map.Entry entry : ModuleGardening.queuedAcidFertilisers.entrySet()) { + addAcidFertiliserRecipe(entry.getKey(), entry.getValue()); } - for (final Map.Entry entry : ModuleGardening.queuedAlkalineFertilisers.entrySet()) { - this.addAlkalineFertiliserRecipe(entry.getKey(), entry.getValue()); + for (Map.Entry entry : ModuleGardening.queuedAlkalineFertilisers.entrySet()) { + addAlkalineFertiliserRecipe(entry.getKey(), entry.getValue()); } - for (final Map.Entry entry : ModuleGardening.queuedNutrientFertilisers.entrySet()) { - this.addNutrientFertiliserRecipe(entry.getKey(), entry.getValue()); + for (Map.Entry entry : ModuleGardening.queuedNutrientFertilisers.entrySet()) { + addNutrientFertiliserRecipe(entry.getKey(), entry.getValue()); } - GameRegistry.addRecipe(BotanyItems.Mortar.get(6), " c ", "cgc", " c ", 'c', Items.CLAY_BALL, 'g', Blocks.GRAVEL); - for (final EnumFlowerColor c : EnumFlowerColor.values()) { - final ItemStack clay = new ItemStack(Botany.clay, 1, c.ordinal()); - final ItemStack pigment = new ItemStack(Botany.pigment, 1, c.ordinal()); + + GameRegistry.addRecipe(BotanyItems.MORTAR.get(6), " c ", "cgc", " c ", 'c', Items.CLAY_BALL, 'g', Blocks.GRAVEL); + for (EnumFlowerColor c : EnumFlowerColor.values()) { + ItemStack clay = new ItemStack(Botany.clay, 1, c.ordinal()); + ItemStack pigment = new ItemStack(Botany.pigment, 1, c.ordinal()); GameRegistry.addShapelessRecipe(clay, Items.CLAY_BALL, Items.CLAY_BALL, Items.CLAY_BALL, pigment); GameRegistry.addSmelting(clay, TileEntityMetadata.getItemStack(Botany.ceramic, c.ordinal()), 0.0f); - final ItemStack glass = TileEntityMetadata.getItemStack(Botany.stained, c.ordinal()); + ItemStack glass = TileEntityMetadata.getItemStack(Botany.stained, c.ordinal()); glass.setCount(4); - GameRegistry.addShapedRecipe(glass, " g ", "gpg", " g ", 'g', Blocks.GLASS, 'p', pigment); + + GameRegistry.addShapedRecipe( + glass, + " g ", "gpg", " g ", + 'g', Blocks.GLASS, + 'p', pigment + ); } GameRegistry.addRecipe(new PigmentRecipe()); } - private ItemStack getStack(final int type, final int pH, final int moisture) { + private ItemStack getStack(int type, int pH, int moisture) { if (type >= 0 && type <= 2 && pH >= 0 && pH <= 2 && moisture >= 0 && moisture <= 2) { return new ItemStack(BotanyCore.getGardening().getSoilBlock(EnumSoilType.values()[type]), 1, BlockSoil.getMeta(EnumAcidity.values()[pH], EnumMoisture.values()[moisture])); } return ItemStack.EMPTY; } - private void addAcidFertiliserRecipe(final ItemStack stack, final int strengthMax) { + private void addAcidFertiliserRecipe(ItemStack stack, int strengthMax) { for (int moisture = 0; moisture < 3; ++moisture) { for (int pH = 0; pH < 3; ++pH) { for (int type = 0; type < 3; ++type) { int numOfBlocks = strengthMax * strengthMax; for (int strength = 1; strength < strengthMax; ++strength) { - final ItemStack start = this.getStack(type, pH, moisture); - final ItemStack end = this.getStack(type, pH - strength, moisture); + ItemStack start = getStack(type, pH, moisture); + ItemStack end = getStack(type, pH - strength, moisture); if (!start.isEmpty() && !end.isEmpty()) { end.setCount(numOfBlocks); - final Object[] stacks = new Object[numOfBlocks + 1]; + Object[] stacks = new Object[numOfBlocks + 1]; for (int i = 0; i < numOfBlocks; ++i) { stacks[i] = start; } @@ -233,17 +324,17 @@ public class ModuleGardening implements IInitializable { } } - private void addAlkalineFertiliserRecipe(final ItemStack stack, final int strengthMax) { + private void addAlkalineFertiliserRecipe(ItemStack stack, int strengthMax) { for (int moisture = 0; moisture < 3; ++moisture) { for (int pH = 0; pH < 3; ++pH) { for (int type = 0; type < 3; ++type) { int numOfBlocks = strengthMax * strengthMax; for (int strength = 1; strength < strengthMax; ++strength) { - final ItemStack start = this.getStack(type, pH, moisture); - final ItemStack end = this.getStack(type, pH + strength, moisture); + ItemStack start = getStack(type, pH, moisture); + ItemStack end = getStack(type, pH + strength, moisture); if (!end.isEmpty()) { end.setCount(numOfBlocks); - final Object[] stacks = new Object[numOfBlocks + 1]; + Object[] stacks = new Object[numOfBlocks + 1]; for (int i = 0; i < numOfBlocks; ++i) { stacks[i] = start; } @@ -257,17 +348,17 @@ public class ModuleGardening implements IInitializable { } } - private void addNutrientFertiliserRecipe(final ItemStack stack, final int strengthMax) { + private void addNutrientFertiliserRecipe(ItemStack stack, int strengthMax) { for (int moisture = 0; moisture < 3; ++moisture) { for (int pH = 0; pH < 3; ++pH) { for (int type = 0; type < 3; ++type) { int numOfBlocks = strengthMax * strengthMax; for (int strength = 1; strength < strengthMax; ++strength) { - final ItemStack start = this.getStack(type, pH, moisture); - final ItemStack end = this.getStack(type + strength, pH, moisture); + ItemStack start = getStack(type, pH, moisture); + ItemStack end = getStack(type + strength, pH, moisture); if (!end.isEmpty()) { end.setCount(numOfBlocks); - final Object[] stacks = new Object[numOfBlocks + 1]; + Object[] stacks = new Object[numOfBlocks + 1]; for (int i = 0; i < numOfBlocks; ++i) { stacks[i] = start; } diff --git a/src/main/java/binnie/botany/gardening/PlantType.java b/src/main/java/binnie/botany/gardening/PlantType.java new file mode 100644 index 00000000..49696cbc --- /dev/null +++ b/src/main/java/binnie/botany/gardening/PlantType.java @@ -0,0 +1,43 @@ +package binnie.botany.gardening; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.IStringSerializable; + +import binnie.botany.Botany; + +public enum PlantType implements IStringSerializable { + WEEDS("weeds", true), + WEEDS_LONG("weeds_long", true), + WEEDS_VERY_LONG("weeds_very_long", true), + DEAD_FLOWER("dead_flower"), + DECAYING_FLOWER("decaying_flower"); + + String name; + boolean isWeed; + + PlantType(String name) { + this(name, false); + } + + PlantType(String name, boolean isWeed) { + this.name = name; + this.isWeed = isWeed; + } + + public static PlantType get(int id) { + return values()[id % values().length]; + } + + public ItemStack get() { + return new ItemStack(Botany.plant, 1, ordinal()); + } + + public boolean isWeed() { + return isWeed; + } + + @Override + public String getName() { + return name; + } +} diff --git a/src/main/java/binnie/botany/genetics/AlleleEffectNone.java b/src/main/java/binnie/botany/genetics/AlleleEffectNone.java index 0ded7726..a0ae1f28 100644 --- a/src/main/java/binnie/botany/genetics/AlleleEffectNone.java +++ b/src/main/java/binnie/botany/genetics/AlleleEffectNone.java @@ -14,7 +14,7 @@ public class AlleleEffectNone implements IAlleleFlowerEffect { } @Override - public IEffectData validateStorage(final IEffectData storedData) { + public IEffectData validateStorage(IEffectData storedData) { return storedData; } @@ -34,12 +34,12 @@ public class AlleleEffectNone implements IAlleleFlowerEffect { } @Override - public IEffectData doEffect(final IFlowerGenome genome, final IEffectData effect, final World world, final int x, final int y, final int z) { + public IEffectData doEffect(IFlowerGenome genome, IEffectData effect, World world, int x, int y, int z) { return effect; } @Override public String getUnlocalizedName() { - return this.getUID(); + return getUID(); } } diff --git a/src/main/java/binnie/botany/genetics/AlleleFlowerSpecies.java b/src/main/java/binnie/botany/genetics/AlleleFlowerSpecies.java index 884f0105..0e245043 100644 --- a/src/main/java/binnie/botany/genetics/AlleleFlowerSpecies.java +++ b/src/main/java/binnie/botany/genetics/AlleleFlowerSpecies.java @@ -27,14 +27,14 @@ public class AlleleFlowerSpecies extends AlleleSpecies implements IAlleleFlowerS private EnumMoisture moisture = EnumMoisture.NORMAL; public AlleleFlowerSpecies( - String uid, - String unlocalizedName, - String authority, - String unlocalizedDescription, - boolean isDominant, - IClassification branch, - String binomial, - IFlowerType flowerType) { + String uid, + String unlocalizedName, + String authority, + String unlocalizedDescription, + boolean isDominant, + IClassification branch, + String binomial, + IFlowerType flowerType) { super(uid, unlocalizedName, authority, unlocalizedDescription, isDominant, branch, binomial); this.flowerType = flowerType; } diff --git a/src/main/java/binnie/botany/genetics/BotanistTracker.java b/src/main/java/binnie/botany/genetics/BotanistTracker.java index 822a67c8..7379b86b 100644 --- a/src/main/java/binnie/botany/genetics/BotanistTracker.java +++ b/src/main/java/binnie/botany/genetics/BotanistTracker.java @@ -10,16 +10,16 @@ import binnie.Binnie; import binnie.botany.api.IBotanistTracker; public class BotanistTracker extends BreedingTracker implements IBotanistTracker { - public BotanistTracker(final String s) { + public BotanistTracker(String s) { super(s, "NORMAL"); } @Override - public void registerPickup(final IIndividual individual) { + public void registerPickup(IIndividual individual) { } @Override - protected IBreedingTracker getBreedingTracker(final EntityPlayer player) { + protected IBreedingTracker getBreedingTracker(EntityPlayer player) { return Binnie.GENETICS.getFlowerRoot().getBreedingTracker(player.world, player.getGameProfile()); } diff --git a/src/main/java/binnie/botany/genetics/ColorMix.java b/src/main/java/binnie/botany/genetics/ColorMix.java new file mode 100644 index 00000000..b320e30c --- /dev/null +++ b/src/main/java/binnie/botany/genetics/ColorMix.java @@ -0,0 +1,44 @@ +package binnie.botany.genetics; + +import binnie.botany.api.IColorMix; +import binnie.botany.api.IFlowerColor; + +public class ColorMix implements IColorMix { + IFlowerColor color1; + IFlowerColor color2; + IFlowerColor result; + int chance; + + public ColorMix(IFlowerColor color1, IFlowerColor color2, IFlowerColor result, int chance) { + this.color1 = color1; + this.color2 = color2; + this.result = result; + this.chance = chance; + } + + @Override + public IFlowerColor getColorFirst() { + return color1; + } + + @Override + public IFlowerColor getColorSecond() { + return color2; + } + + @Override + public boolean isMutation(IFlowerColor colorFirst, IFlowerColor colorSecond) { + return (colorFirst == color1 && colorSecond == color2) + || (colorFirst == color2 && colorSecond == color1); + } + + @Override + public int getChance() { + return chance; + } + + @Override + public IFlowerColor getResult() { + return result; + } +} diff --git a/src/main/java/binnie/botany/genetics/ColourMix.java b/src/main/java/binnie/botany/genetics/ColourMix.java deleted file mode 100644 index 193fe56a..00000000 --- a/src/main/java/binnie/botany/genetics/ColourMix.java +++ /dev/null @@ -1,43 +0,0 @@ -package binnie.botany.genetics; - -import binnie.botany.api.IColorMix; -import binnie.botany.api.IFlowerColour; - -public class ColourMix implements IColorMix { - IFlowerColour colour1; - IFlowerColour colour2; - IFlowerColour result; - int chance; - - public ColourMix(final IFlowerColour colour1, final IFlowerColour colour2, final IFlowerColour result, final int chance) { - this.colour1 = colour1; - this.colour2 = colour2; - this.result = result; - this.chance = chance; - } - - @Override - public IFlowerColour getColorFirst() { - return this.colour1; - } - - @Override - public IFlowerColour getColorSecond() { - return this.colour2; - } - - @Override - public boolean isMutation(final IFlowerColour colorFirst, final IFlowerColour colorSecond) { - return (colorFirst == this.colour1 && colorSecond == this.colour2) || (colorFirst == this.colour2 && colorSecond == this.colour1); - } - - @Override - public int getChance() { - return this.chance; - } - - @Override - public IFlowerColour getResult() { - return this.result; - } -} diff --git a/src/main/java/binnie/botany/genetics/EnumFlowerColor.java b/src/main/java/binnie/botany/genetics/EnumFlowerColor.java index 64c107e7..885b85b4 100644 --- a/src/main/java/binnie/botany/genetics/EnumFlowerColor.java +++ b/src/main/java/binnie/botany/genetics/EnumFlowerColor.java @@ -93,11 +93,11 @@ public enum EnumFlowerColor implements IStringSerializable { private FlowerColorAllele allele; - EnumFlowerColor(final String ident, final int c) { + EnumFlowerColor(String ident, int c) { this(c); } - EnumFlowerColor(final int color) { + EnumFlowerColor(int color) { int r = color >> 16 & 0xFF; int g = color >> 8 & 0xFF; int b = color & 0xFF; @@ -105,12 +105,12 @@ public enum EnumFlowerColor implements IStringSerializable { g = (int) (0.45 * (g + 174)); b = (int) (0.45 * (b + 131)); int colorDis = (r << 16) + (g << 8) + b; - String uid = "botany.color" + this.name(); + String uid = "botany.color" + name(); allele = new FlowerColorAllele(uid, ordinal(), color, colorDis, name().toLowerCase(), uid, true); } - public static void addMix(final EnumFlowerColor start1, final EnumFlowerColor start2, final EnumFlowerColor result, final int chance) { - BotanyCore.getFlowerRoot().registerColourMix(new ColourMix(start1.allele, start2.allele, result.allele, chance)); + public static void addMix(EnumFlowerColor start1, EnumFlowerColor start2, EnumFlowerColor result, int chance) { + BotanyCore.getFlowerRoot().registerColourMix(new ColorMix(start1.allele, start2.allele, result.allele, chance)); } public static void setupMutations() { @@ -2937,24 +2937,24 @@ public enum EnumFlowerColor implements IStringSerializable { } } - public static EnumFlowerColor get(final int i) { + public static EnumFlowerColor get(int i) { return values()[Math.max(0, i) % values().length]; } - public String getDisplayName(){ + public String getDisplayName() { return I18N.localise("botany.color." + getName()); } - + @Override public String getName() { return name().toLowerCase(); } public String getHTMLName() { - return this.name(); + return name(); } - public FlowerColorAllele getFlowerColorAllele(){ + public FlowerColorAllele getFlowerColorAllele() { return allele; } } diff --git a/src/main/java/binnie/botany/genetics/EnumFlowerType.java b/src/main/java/binnie/botany/genetics/EnumFlowerType.java index 6841e9bb..2e94311b 100644 --- a/src/main/java/binnie/botany/genetics/EnumFlowerType.java +++ b/src/main/java/binnie/botany/genetics/EnumFlowerType.java @@ -76,14 +76,14 @@ public enum EnumFlowerType implements IFlowerType { this(1); } - EnumFlowerType(final int sections) { + EnumFlowerType(int sections) { this.sections = sections; } @Override @SideOnly(Side.CLIENT) public void registerModels(Item item, IModelManager manager, EnumFlowerStage type) { - String pre = (this.sections == 1) ? "" : "double/"; + String pre = (sections == 1) ? "" : "double/"; flower = new ModelResourceLocation(Constants.BOTANY_MOD_ID + ":flowers/" + pre + getName(), "inventory"); seed = new ModelResourceLocation(Constants.BOTANY_MOD_ID + ":flowers/seed", "inventory"); pollen = new ModelResourceLocation(Constants.BOTANY_MOD_ID + ":flowers/pollen", "inventory"); @@ -97,19 +97,18 @@ public enum EnumFlowerType implements IFlowerType { return seed; } else if (type == EnumFlowerStage.POLLEN) { return pollen; - } else { - return flower; } + return flower; } @Override public int getID() { - return this.ordinal(); + return ordinal(); } @Override public int getSections() { - return this.sections; + return sections; } @Override diff --git a/src/main/java/binnie/botany/genetics/Flower.java b/src/main/java/binnie/botany/genetics/Flower.java index 4168b7fa..4ca3ef4d 100644 --- a/src/main/java/binnie/botany/genetics/Flower.java +++ b/src/main/java/binnie/botany/genetics/Flower.java @@ -19,96 +19,100 @@ import binnie.botany.api.EnumFlowerChromosome; import binnie.botany.api.IAlleleFlowerSpecies; import binnie.botany.api.IColorMix; import binnie.botany.api.IFlower; -import binnie.botany.api.IFlowerColour; +import binnie.botany.api.IFlowerColor; import binnie.botany.api.IFlowerGenome; import binnie.botany.api.IFlowerMutation; import binnie.botany.core.BotanyCore; public class Flower extends Individual implements IFlower { public IFlowerGenome genome; + @Nullable public IFlowerGenome mate; + private int age; private boolean wilting; private boolean flowered; - public Flower(final NBTTagCompound nbt) { + public Flower(NBTTagCompound nbt) { super(nbt); if (nbt.hasKey("Age")) { - this.age = nbt.getInteger("Age"); + age = nbt.getInteger("Age"); } else { - this.age = 0; + age = 0; } - this.wilting = nbt.hasKey("Wilt") && nbt.getBoolean("Wilt"); + wilting = nbt.hasKey("Wilt") && nbt.getBoolean("Wilt"); if (nbt.hasKey("Flowered")) { - this.flowered = nbt.getBoolean("Flowered"); + flowered = nbt.getBoolean("Flowered"); } else { - this.flowered = age > 0; + flowered = age > 0; } if (nbt.hasKey("Genome")) { - this.genome = new FlowerGenome(nbt.getCompoundTag("Genome")); + genome = new FlowerGenome(nbt.getCompoundTag("Genome")); } else { - this.genome = BotanyCore.getFlowerRoot().templateAsGenome(BotanyCore.getFlowerRoot().getDefaultTemplate()); + genome = BotanyCore.getFlowerRoot().templateAsGenome(BotanyCore.getFlowerRoot().getDefaultTemplate()); } if (nbt.hasKey("Mate")) { - this.mate = new FlowerGenome(nbt.getCompoundTag("Mate")); + mate = new FlowerGenome(nbt.getCompoundTag("Mate")); } } - public Flower(final IFlowerGenome genome, final int age) { + public Flower(IFlowerGenome genome, int age) { this.age = 0; - this.wilting = false; this.genome = genome; this.age = age; - this.flowered = age > 0; + wilting = false; + flowered = age > 0; } @Override public String getDisplayName() { - final IAlleleFlowerSpecies species = this.getGenome().getPrimary(); + IAlleleFlowerSpecies species = getGenome().getPrimary(); String name = species.getName(); - if (this.age == 0) { + if (age == 0) { name += ""; } return name; } @Override - public void addTooltip(final List list) { - final IAlleleFlowerSpecies primary = this.genome.getPrimary(); - final IAlleleFlowerSpecies secondary = this.genome.getSecondary(); - if (!this.isPureBred(EnumFlowerChromosome.SPECIES)) { + public void addTooltip(List list) { + IAlleleFlowerSpecies primary = genome.getPrimary(); + IAlleleFlowerSpecies secondary = genome.getSecondary(); + // TODO localize + if (!isPureBred(EnumFlowerChromosome.SPECIES)) { list.add(TextFormatting.BLUE + primary.getAlleleName() + "-" + secondary.getAlleleName() + " Hybrid"); } - list.add(TextFormatting.GOLD + "Age: " + this.getAge()); - list.add(TextFormatting.GOLD + "T: " + this.getGenome().getPrimary().getTemperature() + " / " + this.getGenome().getToleranceTemperature()); - list.add(TextFormatting.GOLD + "M: " + this.getGenome().getPrimary().getMoisture() + " / " + this.getGenome().getToleranceMoisture()); - list.add(TextFormatting.GOLD + "pH: " + this.getGenome().getPrimary().getHumidity() + " / " + this.getGenome().getTolerancePH()); - list.add(TextFormatting.GOLD + "Fert: " + this.getGenome().getFertility() + "x"); + + list.add(TextFormatting.GOLD + "Age: " + getAge()); + list.add(TextFormatting.GOLD + "T: " + getGenome().getPrimary().getTemperature() + " / " + getGenome().getToleranceTemperature()); + list.add(TextFormatting.GOLD + "M: " + getGenome().getPrimary().getMoisture() + " / " + getGenome().getToleranceMoisture()); + list.add(TextFormatting.GOLD + "pH: " + getGenome().getPrimary().getHumidity() + " / " + getGenome().getTolerancePH()); + list.add(TextFormatting.GOLD + "Fert: " + getGenome().getFertility() + "x"); } @Override public String getIdent() { - return this.getGenome().getPrimary().getUID(); + return getGenome().getPrimary().getUID(); } @Override - public NBTTagCompound writeToNBT(final NBTTagCompound nbttagcompound2) { + public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound2) { NBTTagCompound nbttagcompound = super.writeToNBT(nbttagcompound2); - nbttagcompound.setInteger("Age", this.age); - nbttagcompound.setBoolean("Wilt", this.wilting); - nbttagcompound.setBoolean("Flowered", this.flowered); - final NBTTagCompound nbtGenome = new NBTTagCompound(); - this.genome.writeToNBT(nbtGenome); + nbttagcompound.setInteger("Age", age); + nbttagcompound.setBoolean("Wilt", wilting); + nbttagcompound.setBoolean("Flowered", flowered); + NBTTagCompound nbtGenome = new NBTTagCompound(); + genome.writeToNBT(nbtGenome); nbttagcompound.setTag("Genome", nbtGenome); - if (this.mate != null) { - final NBTTagCompound nbtMate = new NBTTagCompound(); - this.mate.writeToNBT(nbtMate); + if (mate != null) { + NBTTagCompound nbtMate = new NBTTagCompound(); + mate.writeToNBT(nbtMate); nbttagcompound.setTag("Mate", nbtMate); } return nbttagcompound; @@ -116,7 +120,7 @@ public class Flower extends Individual implements IFlower { @Override public IFlowerGenome getGenome() { - return this.genome; + return genome; } private IChromosome inheritChromosome(Random rand, IChromosome parentFirst, IChromosome parentSecond) { @@ -140,91 +144,91 @@ public class Flower extends Individual implements IFlower { @Override public void mate(IFlower other) { - this.mate = new FlowerGenome(other.getGenome().getChromosomes()); + mate = new FlowerGenome(other.getGenome().getChromosomes()); } @Override @Nullable public IFlowerGenome getMate() { - return this.mate; + return mate; } @Override public IFlower copy() { - final NBTTagCompound nbttagcompound = new NBTTagCompound(); - this.writeToNBT(nbttagcompound); + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeToNBT(nbttagcompound); return new Flower(nbttagcompound); } @Override public int getAge() { - return this.age; + return age; } @Override - public void setAge(final int i) { - this.age = i; + public void setAge(int i) { + age = i; } @Override public void age() { - if (this.age < 15) { - ++this.age; + if (age < 15) { + age++; } } @Override public int getMaxAge() { - return this.getGenome().getLifespan(); + return getGenome().getLifespan(); } @Override public boolean isWilted() { - return this.wilting; + return wilting; } @Override - public void setWilted(final boolean wilted) { - this.wilting = wilted; + public void setWilted(boolean wilted) { + wilting = wilted; } @Override public boolean hasFlowered() { - return this.flowered; + return flowered; } @Override - public void setFlowered(final boolean flowered) { + public void setFlowered(boolean flowered) { this.flowered = flowered; } @Override public void removeMate() { - this.mate = null; + mate = null; } @Override - public IFlower getOffspring(final World world, final BlockPos pos) { - if (this.mate != null) { - final IChromosome[] chromosomes = new IChromosome[this.genome.getChromosomes().length]; - IChromosome[] parentFirst = this.mutateSpecies(world, pos, this.genome, this.mate); - IChromosome[] parentSecond = this.mutateSpecies(world, pos, this.mate, this.genome); + public IFlower getOffspring(World world, BlockPos pos) { + if (mate != null) { + IChromosome[] chromosomes = new IChromosome[genome.getChromosomes().length]; + IChromosome[] parentFirst = mutateSpecies(world, pos, genome, mate); + IChromosome[] parentSecond = mutateSpecies(world, pos, mate, genome); for (int i = 0; i < parentFirst.length; ++i) { if (parentFirst[i] != null && parentSecond[i] != null) { chromosomes[i] = Chromosome.inheritChromosome(world.rand, parentFirst[i], parentSecond[i]); } } return new Flower(new FlowerGenome(chromosomes), 0); - } else { - NBTTagCompound nbt = new NBTTagCompound(); - writeToNBT(nbt); - return new Flower(nbt); } + + NBTTagCompound nbt = new NBTTagCompound(); + writeToNBT(nbt); + return new Flower(nbt); } private IChromosome[] mutateSpecies(World world, BlockPos pos, IFlowerGenome genomeFirst, IFlowerGenome genomeSecond) { IChromosome[] parentFirst = genomeFirst.getChromosomes(); - final IChromosome[] parentSecond = genomeSecond.getChromosomes(); + IChromosome[] parentSecond = genomeSecond.getChromosomes(); IAlleleFlowerSpecies alleleFrist; IAlleleFlowerSpecies alleleSecond; IFlowerGenome genome0; @@ -240,40 +244,44 @@ public class Flower extends Individual implements IFlower { genome0 = genomeSecond; genome2 = genomeFirst; } - IFlowerColour colourFirst = genome0.getPrimaryColor(); - IFlowerColour colourSecond = genome2.getPrimaryColor(); - if (colourFirst != colourSecond) { - for (final IColorMix mutation : BotanyCore.getFlowerRoot().getColorMixes(true)) { - if (mutation.isMutation(colourFirst, colourSecond) && world.rand.nextFloat() * 100.0f < mutation.getChance()) { + + IFlowerColor colorFirst = genome0.getPrimaryColor(); + IFlowerColor colorSecond = genome2.getPrimaryColor(); + if (colorFirst != colorSecond) { + for (IColorMix mutation : BotanyCore.getFlowerRoot().getColorMixes(true)) { + if (mutation.isMutation(colorFirst, colorSecond) && world.rand.nextFloat() * 100.0f < mutation.getChance()) { parentFirst[EnumFlowerChromosome.PRIMARY.ordinal()] = new Chromosome(mutation.getResult().getAllele()); } } } - colourFirst = genome0.getSecondaryColor(); - colourSecond = genome2.getSecondaryColor(); - if (colourFirst != colourSecond) { - for (final IColorMix mutation : BotanyCore.getFlowerRoot().getColorMixes(true)) { - if (mutation.isMutation(colourFirst, colourSecond) && world.rand.nextFloat() * 100.0f < mutation.getChance()) { + + colorFirst = genome0.getSecondaryColor(); + colorSecond = genome2.getSecondaryColor(); + if (colorFirst != colorSecond) { + for (IColorMix mutation : BotanyCore.getFlowerRoot().getColorMixes(true)) { + if (mutation.isMutation(colorFirst, colorSecond) && world.rand.nextFloat() * 100.0f < mutation.getChance()) { parentFirst[EnumFlowerChromosome.SECONDARY.ordinal()] = new Chromosome(mutation.getResult().getAllele()); } } } - colourFirst = genome0.getStemColor(); - colourSecond = genome2.getStemColor(); - if (colourFirst != colourSecond) { - for (final IColorMix mutation : BotanyCore.getFlowerRoot().getColorMixes(true)) { - if (mutation.isMutation(colourFirst, colourSecond) && world.rand.nextFloat() * 100.0f < mutation.getChance()) { + colorFirst = genome0.getStemColor(); + colorSecond = genome2.getStemColor(); + if (colorFirst != colorSecond) { + for (IColorMix mutation : BotanyCore.getFlowerRoot().getColorMixes(true)) { + if (mutation.isMutation(colorFirst, colorSecond) && world.rand.nextFloat() * 100.0f < mutation.getChance()) { parentFirst[EnumFlowerChromosome.STEM.ordinal()] = new Chromosome(mutation.getResult().getAllele()); } } } + IChromosome[] template = null; - for (final IFlowerMutation mutation2 : BotanyCore.getFlowerRoot().getMutations(true)) { - final float chance = mutation2.getChance(world, pos, alleleFrist, alleleSecond, genome0, genome2); + for (IFlowerMutation mutation2 : BotanyCore.getFlowerRoot().getMutations(true)) { + float chance = mutation2.getChance(world, pos, alleleFrist, alleleSecond, genome0, genome2); if (chance > 0.0f && world.rand.nextFloat() * 100.0f < chance && template == null) { template = BotanyCore.getFlowerRoot().templateAsChromosomes(mutation2.getTemplate()); } } + if (template != null) { parentFirst = template; } diff --git a/src/main/java/binnie/botany/genetics/FlowerAlyzerPlugin.java b/src/main/java/binnie/botany/genetics/FlowerAlyzerPlugin.java index c28c715a..e27a82a7 100644 --- a/src/main/java/binnie/botany/genetics/FlowerAlyzerPlugin.java +++ b/src/main/java/binnie/botany/genetics/FlowerAlyzerPlugin.java @@ -32,12 +32,6 @@ public class FlowerAlyzerPlugin implements IAlyzerPlugin { public static final int COLUMN_0 = 12; public static final int COLUMN_1 = 90; public static final int COLUMN_2 = 155; - private int lastTopOffset; - private int rowSize = 12; - private int margin = 10; - private int guiLeft; - private int guiTop; - private HashMap iconStacks = new HashMap<>(); private static final EnumFlowerChromosome[] firstPageChromosome = new EnumFlowerChromosome[]{ EnumFlowerChromosome.SPECIES, EnumFlowerChromosome.SAPPINESS, @@ -46,39 +40,43 @@ public class FlowerAlyzerPlugin implements IAlyzerPlugin { EnumFlowerChromosome.EFFECT, EnumFlowerChromosome.LIFESPAN }; - private static final EnumFlowerChromosome[] secondPageColorChromosome = new EnumFlowerChromosome[]{ EnumFlowerChromosome.PRIMARY, EnumFlowerChromosome.SECONDARY, EnumFlowerChromosome.STEM, }; - private static final EnumFlowerChromosome[] secondPageToleranceChromosome = new EnumFlowerChromosome[]{ EnumFlowerChromosome.TEMPERATURE_TOLERANCE, EnumFlowerChromosome.HUMIDITY_TOLERANCE, EnumFlowerChromosome.PH_TOLERANCE }; + private int lastTopOffset; + private int rowSize = 12; + private int margin = 10; + private int guiLeft; + private int guiTop; + private HashMap iconStacks = new HashMap<>(); public FlowerAlyzerPlugin() { - for(FlowerDefinition def : FlowerDefinition.values()){ + for (FlowerDefinition def : FlowerDefinition.values()) { iconStacks.put(def.getSpecies().getUID(), def.getMemberStack(EnumFlowerStage.FLOWER)); } } - public void drawLine(GuiScreen gui, int xOffset, String msg, int color){ + public void drawLine(GuiScreen gui, int xOffset, String msg, int color) { gui.mc.fontRendererObj.drawString(msg, guiLeft + xOffset, guiTop + lastTopOffset + margin, color); } - public void drawChromosom(GuiScreen gui, EnumFlowerChromosome chromosome, IFlower flower){ + public void drawChromosom(GuiScreen gui, EnumFlowerChromosome chromosome, IFlower flower) { drawLine(gui, COLUMN_0, StringUtils.capitalize(chromosome.getName()), 0xEEEEEE); drawLine(gui, COLUMN_1, I18N.localise(flower.getGenome().getActiveAllele(chromosome).getUnlocalizedName()), 0xEEEEEE); drawLine(gui, COLUMN_2, I18N.localise(flower.getGenome().getInactiveAllele(chromosome).getUnlocalizedName()), 0xEEEEEE); lastTopOffset += rowSize; } - public void newLine(){ + public void newLine() { lastTopOffset += rowSize; } @@ -100,13 +98,13 @@ public class FlowerAlyzerPlugin implements IAlyzerPlugin { gui.mc.fontRendererObj.drawString("Active", guiLeft + 10 + COLUMN_1, guiTop + 10, 0xffffff); gui.mc.fontRendererObj.drawString("Inactive", guiLeft + 10 + COLUMN_2, guiTop + 10, 0xffffff); - if (renderP != null && renderS!=null){ + if (renderP != null && renderS != null) { RenderItem itemRender = Minecraft.getMinecraft().getRenderItem(); - itemRender.renderItemAndEffectIntoGUI(renderP, guiLeft + 10 + COLUMN_1, guiTop + 10 +12); + itemRender.renderItemAndEffectIntoGUI(renderP, guiLeft + 10 + COLUMN_1, guiTop + 10 + 12); itemRender.renderItemOverlayIntoGUI(gui.mc.fontRendererObj, renderP, guiLeft + 10 + COLUMN_1, guiTop + 10 + 12, null); - itemRender.renderItemAndEffectIntoGUI(renderS, guiLeft + 10 + COLUMN_2, guiTop +10 +12); - itemRender.renderItemOverlayIntoGUI(gui.mc.fontRendererObj, renderS, guiLeft + 10 + COLUMN_1, guiTop +10 + 12, null); + itemRender.renderItemAndEffectIntoGUI(renderS, guiLeft + 10 + COLUMN_2, guiTop + 10 + 12); + itemRender.renderItemOverlayIntoGUI(gui.mc.fontRendererObj, renderS, guiLeft + 10 + COLUMN_1, guiTop + 10 + 12, null); } guiTop += rowSize * 3; @@ -128,8 +126,8 @@ public class FlowerAlyzerPlugin implements IAlyzerPlugin { for (EnumFlowerChromosome chromosome : secondPageColorChromosome) { drawChromosom(gui, chromosome, f); - RenderUtil.drawSolidRect(new Area(guiLeft + COLUMN_1, guiTop + lastTopOffset + margin, 50, 10), ((IAlleleInteger)f.getGenome().getActiveAllele(chromosome)).getValue()); - RenderUtil.drawSolidRect(new Area(guiLeft + COLUMN_2, guiTop + lastTopOffset + margin, 50, 10), ((IAlleleInteger)f.getGenome().getInactiveAllele(chromosome)).getValue()); + RenderUtil.drawSolidRect(new Area(guiLeft + COLUMN_1, guiTop + lastTopOffset + margin, 50, 10), ((IAlleleInteger) f.getGenome().getActiveAllele(chromosome)).getValue()); + RenderUtil.drawSolidRect(new Area(guiLeft + COLUMN_2, guiTop + lastTopOffset + margin, 50, 10), ((IAlleleInteger) f.getGenome().getInactiveAllele(chromosome)).getValue()); newLine(); } diff --git a/src/main/java/binnie/botany/genetics/FlowerBreedingSystem.java b/src/main/java/binnie/botany/genetics/FlowerBreedingSystem.java index c406c8ba..7d02bbe5 100644 --- a/src/main/java/binnie/botany/genetics/FlowerBreedingSystem.java +++ b/src/main/java/binnie/botany/genetics/FlowerBreedingSystem.java @@ -26,12 +26,12 @@ import binnie.core.util.I18N; public class FlowerBreedingSystem extends BreedingSystem { public FlowerBreedingSystem() { - this.iconUndiscovered = Binnie.RESOURCE.getUndiscoveredBeeSprite(); - this.iconDiscovered = Binnie.RESOURCE.getDiscoveredBeeSprite(); + iconUndiscovered = Binnie.RESOURCE.getUndiscoveredBeeSprite(); + iconDiscovered = Binnie.RESOURCE.getDiscoveredBeeSprite(); } @Override - public float getChance(final IMutation mutation, final EntityPlayer player, final IAlleleSpecies species1, final IAlleleSpecies species2) { + public float getChance(IMutation mutation, EntityPlayer player, IAlleleSpecies species1, IAlleleSpecies species2) { return mutation.getBaseChance(); } @@ -51,7 +51,7 @@ public class FlowerBreedingSystem extends BreedingSystem { } @Override - public String getAlleleName(final IChromosomeType chromosome, final IAllele allele) { + public String getAlleleName(IChromosomeType chromosome, IAllele allele) { if (chromosome == EnumFlowerChromosome.FERTILITY) { if (allele.getUID().contains("Low")) { return I18N.localise("binniecore.allele.fertility.low"); @@ -70,8 +70,8 @@ public class FlowerBreedingSystem extends BreedingSystem { } @Override - public boolean isDNAManipulable(final ItemStack member) { - ISpeciesType type = this.getSpeciesRoot().getType(member); + public boolean isDNAManipulable(ItemStack member) { + ISpeciesType type = getSpeciesRoot().getType(member); return type != null && isDNAManipulable(type); } @@ -81,7 +81,7 @@ public class FlowerBreedingSystem extends BreedingSystem { } @Override - public IIndividual getConversion(final ItemStack stack) { + public IIndividual getConversion(ItemStack stack) { return BotanyCore.getFlowerRoot().getConversion(stack); } @@ -91,51 +91,47 @@ public class FlowerBreedingSystem extends BreedingSystem { } @Override - public void addExtraAlleles(final IChromosomeType chromosome, final TreeSet alleles) { + public void addExtraAlleles(IChromosomeType chromosome, TreeSet alleles) { switch ((EnumFlowerChromosome) chromosome) { - case FERTILITY: { - for (final ForestryAllele.Fertility a : ForestryAllele.Fertility.values()) { + case FERTILITY: + for (ForestryAllele.Fertility a : ForestryAllele.Fertility.values()) { alleles.add(a.getAllele()); } break; - } - case LIFESPAN: { - for (final ForestryAllele.Lifespan a2 : ForestryAllele.Lifespan.values()) { + + case LIFESPAN: + for (ForestryAllele.Lifespan a2 : ForestryAllele.Lifespan.values()) { alleles.add(a2.getAllele()); } break; - } + case HUMIDITY_TOLERANCE: case PH_TOLERANCE: - case TEMPERATURE_TOLERANCE: { - for (final Tolerance a3 : Tolerance.values()) { + case TEMPERATURE_TOLERANCE: + for (Tolerance a3 : Tolerance.values()) { alleles.add(a3.getAllele()); } break; - } + case PRIMARY: case SECONDARY: - case STEM: { - for (final EnumFlowerColor a4 : EnumFlowerColor.values()) { + case STEM: + for (EnumFlowerColor a4 : EnumFlowerColor.values()) { alleles.add(a4.getFlowerColorAllele()); } break; - } - case SAPPINESS: { - for (final ForestryAllele.Sappiness a5 : ForestryAllele.Sappiness.values()) { + + case SAPPINESS: + for (ForestryAllele.Sappiness a5 : ForestryAllele.Sappiness.values()) { alleles.add(a5.getAllele()); } break; - } - case TERRITORY: { - for (final ForestryAllele.Territory a6 : ForestryAllele.Territory.values()) { + + case TERRITORY: + for (ForestryAllele.Territory a6 : ForestryAllele.Territory.values()) { alleles.add(a6.getAllele()); } break; - } - default: { - break; - } } } } diff --git a/src/main/java/binnie/botany/genetics/FlowerColorAllele.java b/src/main/java/binnie/botany/genetics/FlowerColorAllele.java index d50237f5..e012d7a5 100644 --- a/src/main/java/binnie/botany/genetics/FlowerColorAllele.java +++ b/src/main/java/binnie/botany/genetics/FlowerColorAllele.java @@ -2,10 +2,10 @@ package binnie.botany.genetics; import forestry.api.genetics.IAlleleInteger; -import binnie.botany.api.IFlowerColour; +import binnie.botany.api.IFlowerColor; import binnie.core.util.I18N; -public class FlowerColorAllele implements IFlowerColour, IAlleleInteger { +public class FlowerColorAllele implements IFlowerColor, IAlleleInteger { private int color; private String uid; private boolean isDominant; @@ -51,7 +51,7 @@ public class FlowerColorAllele implements IFlowerColour, IAlleleInteger { @Override public int getColor(boolean dis) { - return dis ? this.colorDis : this.color; + return dis ? colorDis : color; } @Override diff --git a/src/main/java/binnie/botany/genetics/FlowerDefinition.java b/src/main/java/binnie/botany/genetics/FlowerDefinition.java index 93258b88..397e7392 100644 --- a/src/main/java/binnie/botany/genetics/FlowerDefinition.java +++ b/src/main/java/binnie/botany/genetics/FlowerDefinition.java @@ -954,34 +954,34 @@ public enum FlowerDefinition implements IFlowerDefinition { private IAllele[] template; private IFlowerGenome genome; - FlowerDefinition(final String name, final String branch, final String binomial, final IFlowerType type, final EnumFlowerColor colour) { + FlowerDefinition(String name, String branch, String binomial, IFlowerType type, EnumFlowerColor colour) { this(name, branch, binomial, type, false, colour, colour); } - FlowerDefinition(final String name, final String branch, final String binomial, final IFlowerType type, final EnumFlowerColor primaryColor, final EnumFlowerColor secondaryColor) { + FlowerDefinition(String name, String branch, String binomial, IFlowerType type, EnumFlowerColor primaryColor, EnumFlowerColor secondaryColor) { this(name, branch, binomial, type, true, primaryColor, secondaryColor); } - FlowerDefinition(final String name, final String branch, final String binomial, final IFlowerType type, final boolean isDominant, final EnumFlowerColor colour) { + FlowerDefinition(String name, String branch, String binomial, IFlowerType type, boolean isDominant, EnumFlowerColor colour) { this(name, branch, binomial, type, isDominant, colour, colour); } - FlowerDefinition(final String name, final String branch, final String binomial, final IFlowerType flowerType, final boolean isDominant, final EnumFlowerColor primaryColor, final EnumFlowerColor secondaryColor) { + FlowerDefinition(String name, String branch, String binomial, IFlowerType flowerType, boolean isDominant, EnumFlowerColor primaryColor, EnumFlowerColor secondaryColor) { String uid = Constants.BOTANY_MOD_ID + ".flower" + this; String unlocalizedDescription = "botany.description.flower" + this; String unlocalizedName = "botany.flowers.species." + name; - this.variantTemplates = new ArrayList<>(); + variantTemplates = new ArrayList<>(); this.name = name; this.binomial = binomial; - this.branchName = branch; - this.type = flowerType; + branchName = branch; + type = flowerType; this.primaryColor = primaryColor; this.secondaryColor = secondaryColor; IAlleleFlowerSpeciesBuilder speciesBuilder = FlowerManager.flowerFactory.createSpecies(uid, unlocalizedName, "Binnie's Mod Team", unlocalizedDescription, isDominant, getBranch(), binomial, flowerType); setSpeciesProperties(speciesBuilder); - this.species = speciesBuilder.build(); + species = speciesBuilder.build(); if (this.branch != null) { this.branch.addMemberSpecies(species); } @@ -1039,36 +1039,36 @@ public enum FlowerDefinition implements IFlowerDefinition { protected abstract void registerMutations(); - private IAllele[] addVariant(final EnumFlowerColor a, final EnumFlowerColor b) { - final IAllele[] template = this.getTemplate(); + private IAllele[] addVariant(EnumFlowerColor a, EnumFlowerColor b) { + IAllele[] template = getTemplate(); template[EnumFlowerChromosome.PRIMARY.ordinal()] = a.getFlowerColorAllele(); template[EnumFlowerChromosome.SECONDARY.ordinal()] = b.getFlowerColorAllele(); - this.variantTemplates.add(template); + variantTemplates.add(template); return template; } - private IAllele[] addVariant(final EnumFlowerColor a) { - return this.addVariant(a, a); + private IAllele[] addVariant(EnumFlowerColor a) { + return addVariant(a, a); } public List getVariants() { - return this.variantTemplates; + return variantTemplates; } public IClassification getBranch() { if (branch == null) { - final String scientific = branchName.substring(0, 1).toUpperCase() + branchName.substring(1).toLowerCase(); - final String uid = "flowers." + branchName.toLowerCase(); + String scientific = branchName.substring(0, 1).toUpperCase() + branchName.substring(1).toLowerCase(); + String uid = "flowers." + branchName.toLowerCase(); IClassification branch = AlleleManager.alleleRegistry.getClassification("genus." + uid); if (branch == null) { branch = AlleleManager.alleleRegistry.createAndRegisterClassification(IClassification.EnumClassLevel.GENUS, uid, scientific); } this.branch = branch; } - return this.branch; + return branch; } - public void setBranch(final IClassification branch) { + public void setBranch(IClassification branch) { this.branch = branch; } @@ -1121,7 +1121,7 @@ public enum FlowerDefinition implements IFlowerDefinition { } } - protected final IFlowerMutationBuilder registerMutation(final FlowerDefinition parent1, final FlowerDefinition parent2, final int chance) { + protected final IFlowerMutationBuilder registerMutation(FlowerDefinition parent1, FlowerDefinition parent2, int chance) { return FlowerManager.flowerFactory.createMutation(parent1.species, parent2.species, getTemplate(), chance); } } diff --git a/src/main/java/binnie/botany/genetics/FlowerGenome.java b/src/main/java/binnie/botany/genetics/FlowerGenome.java index 39893ae7..ed579db5 100644 --- a/src/main/java/binnie/botany/genetics/FlowerGenome.java +++ b/src/main/java/binnie/botany/genetics/FlowerGenome.java @@ -1,5 +1,20 @@ package binnie.botany.genetics; +import javax.annotation.Nullable; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import forestry.api.core.EnumTemperature; +import forestry.api.genetics.EnumTolerance; +import forestry.api.genetics.IAlleleFloat; +import forestry.api.genetics.IAlleleInteger; +import forestry.api.genetics.IAlleleSpecies; +import forestry.api.genetics.IAlleleTolerance; +import forestry.api.genetics.IChromosome; +import forestry.api.genetics.ISpeciesRoot; +import forestry.core.genetics.Genome; + import binnie.Binnie; import binnie.botany.api.EnumAcidity; import binnie.botany.api.EnumFlowerChromosome; @@ -9,26 +24,13 @@ import binnie.botany.api.IAlleleFlowerSpecies; import binnie.botany.api.IFlowerGenome; import binnie.botany.api.IFlowerType; import binnie.botany.core.BotanyCore; -import forestry.api.core.EnumTemperature; -import forestry.api.genetics.EnumTolerance; -import forestry.api.genetics.IAlleleFloat; -import forestry.api.genetics.IAlleleInteger; -import forestry.api.genetics.IAlleleSpecies; -import forestry.api.genetics.IAlleleTolerance; -import forestry.api.genetics.IChromosome; -import forestry.api.genetics.ISpeciesRoot; -import forestry.core.genetics.Genome; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -import javax.annotation.Nullable; public class FlowerGenome extends Genome implements IFlowerGenome { - public FlowerGenome(final NBTTagCompound nbttagcompound) { + public FlowerGenome(NBTTagCompound nbttagcompound) { super(nbttagcompound); } - public FlowerGenome(final IChromosome[] chromosomes) { + public FlowerGenome(IChromosome[] chromosomes) { super(chromosomes); } @@ -42,18 +44,17 @@ public class FlowerGenome extends Genome implements IFlowerGenome { if (species instanceof IAlleleFlowerSpecies) { return (IAlleleFlowerSpecies) species; } - return (IAlleleFlowerSpecies) getActiveAllele(itemStack, EnumFlowerChromosome.SPECIES, FlowerManager.flowerRoot); } @Override public IAlleleFlowerSpecies getPrimary() { - return (IAlleleFlowerSpecies) this.getChromosomes()[EnumFlowerChromosome.SPECIES.ordinal()].getPrimaryAllele(); + return (IAlleleFlowerSpecies) getChromosomes()[EnumFlowerChromosome.SPECIES.ordinal()].getPrimaryAllele(); } @Override public IAlleleFlowerSpecies getSecondary() { - return (IAlleleFlowerSpecies) this.getChromosomes()[EnumFlowerChromosome.SPECIES.ordinal()].getSecondaryAllele(); + return (IAlleleFlowerSpecies) getChromosomes()[EnumFlowerChromosome.SPECIES.ordinal()].getSecondaryAllele(); } @Override @@ -63,80 +64,80 @@ public class FlowerGenome extends Genome implements IFlowerGenome { @Override public FlowerColorAllele getPrimaryColor() { - return ((FlowerColorAllele) this.getActiveAllele(EnumFlowerChromosome.PRIMARY)); + return ((FlowerColorAllele) getActiveAllele(EnumFlowerChromosome.PRIMARY)); } @Override public FlowerColorAllele getSecondaryColor() { - return ((FlowerColorAllele) this.getActiveAllele(EnumFlowerChromosome.SECONDARY)); + return ((FlowerColorAllele) getActiveAllele(EnumFlowerChromosome.SECONDARY)); } @Override public FlowerColorAllele getStemColor() { - return ((FlowerColorAllele) this.getActiveAllele(EnumFlowerChromosome.STEM)); + return ((FlowerColorAllele) getActiveAllele(EnumFlowerChromosome.STEM)); } @Override public int getFertility() { - return ((IAlleleInteger) this.getActiveAllele(EnumFlowerChromosome.FERTILITY)).getValue(); + return ((IAlleleInteger) getActiveAllele(EnumFlowerChromosome.FERTILITY)).getValue(); } @Override public int getLifespan() { - return ((IAlleleInteger) this.getActiveAllele(EnumFlowerChromosome.LIFESPAN)).getValue() / 5; + return ((IAlleleInteger) getActiveAllele(EnumFlowerChromosome.LIFESPAN)).getValue() / 5; } @Override public IFlowerType getType() { - return this.getPrimary().getType(); + return getPrimary().getType(); } @Override public EnumTolerance getToleranceTemperature() { - return ((IAlleleTolerance) this.getActiveAllele(EnumFlowerChromosome.TEMPERATURE_TOLERANCE)).getValue(); + return ((IAlleleTolerance) getActiveAllele(EnumFlowerChromosome.TEMPERATURE_TOLERANCE)).getValue(); } @Override public EnumTolerance getToleranceMoisture() { - return ((IAlleleTolerance) this.getActiveAllele(EnumFlowerChromosome.HUMIDITY_TOLERANCE)).getValue(); + return ((IAlleleTolerance) getActiveAllele(EnumFlowerChromosome.HUMIDITY_TOLERANCE)).getValue(); } @Override public EnumTolerance getTolerancePH() { - return ((IAlleleTolerance) this.getActiveAllele(EnumFlowerChromosome.PH_TOLERANCE)).getValue(); + return ((IAlleleTolerance) getActiveAllele(EnumFlowerChromosome.PH_TOLERANCE)).getValue(); } @Override public float getAgeChance() { - return 1.0f * (float) Math.sqrt(2.0f / this.getLifespan()); + return 1.0f * (float) Math.sqrt(2.0f / getLifespan()); } @Override public float getSappiness() { - return ((IAlleleFloat) this.getActiveAllele(EnumFlowerChromosome.SAPPINESS)).getValue(); + return ((IAlleleFloat) getActiveAllele(EnumFlowerChromosome.SAPPINESS)).getValue(); } @Override - public boolean canTolerate(final EnumAcidity acidity) { - final int pH = acidity.ordinal(); - final int[] pHTol = Binnie.GENETICS.getTolerance(this.getTolerancePH()); - final int fPH = this.getPrimary().getPH().ordinal(); + public boolean canTolerate(EnumAcidity acidity) { + int pH = acidity.ordinal(); + int[] pHTol = Binnie.GENETICS.getTolerance(getTolerancePH()); + int fPH = getPrimary().getPH().ordinal(); return pH >= fPH + pHTol[0] && pH <= fPH + pHTol[1]; } @Override - public boolean canTolerate(final EnumMoisture moist) { - final int moisture = moist.ordinal(); - final int[] moistTol = Binnie.GENETICS.getTolerance(this.getToleranceMoisture()); - final int fMoisture = this.getPrimary().getMoisture().ordinal(); + public boolean canTolerate(EnumMoisture moist) { + int moisture = moist.ordinal(); + int[] moistTol = Binnie.GENETICS.getTolerance(getToleranceMoisture()); + int fMoisture = getPrimary().getMoisture().ordinal(); return moisture >= fMoisture + moistTol[0] && moisture <= fMoisture + moistTol[1]; } @Override - public boolean canTolerate(final EnumTemperature temperature) { - final int temp = temperature.ordinal(); - final int[] tempTol = Binnie.GENETICS.getTolerance(this.getToleranceTemperature()); - final int fTemp = this.getPrimary().getTemperature().ordinal(); + public boolean canTolerate(EnumTemperature temperature) { + int temp = temperature.ordinal(); + int[] tempTol = Binnie.GENETICS.getTolerance(getToleranceTemperature()); + int fTemp = getPrimary().getTemperature().ordinal(); return temp >= fTemp + tempTol[0] && temp <= fTemp + tempTol[1]; } } diff --git a/src/main/java/binnie/botany/genetics/FlowerMutation.java b/src/main/java/binnie/botany/genetics/FlowerMutation.java index 165a82bb..813926e3 100644 --- a/src/main/java/binnie/botany/genetics/FlowerMutation.java +++ b/src/main/java/binnie/botany/genetics/FlowerMutation.java @@ -32,7 +32,7 @@ public class FlowerMutation extends Mutation implements IFlowerMutation, IFlower @Override public float getChance(World world, BlockPos pos, IAlleleFlowerSpecies allele0, IAlleleFlowerSpecies allele1, IFlowerGenome genome0, IFlowerGenome genome1) { - float processedChance = super.getChance(world, pos, allele0, allele1, genome0, genome1, ForestryAPI.climateManager.getDefaultClimate(world, pos)); + float processedChance = getChance(world, pos, allele0, allele1, genome0, genome1, ForestryAPI.climateManager.getDefaultClimate(world, pos)); if (processedChance <= 0) { return 0; } diff --git a/src/main/java/binnie/botany/genetics/FlowerRoot.java b/src/main/java/binnie/botany/genetics/FlowerRoot.java index 0724fdaa..76d73c78 100644 --- a/src/main/java/binnie/botany/genetics/FlowerRoot.java +++ b/src/main/java/binnie/botany/genetics/FlowerRoot.java @@ -1,5 +1,31 @@ package binnie.botany.genetics; +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Random; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import com.mojang.authlib.GameProfile; + +import forestry.api.genetics.AlleleManager; +import forestry.api.genetics.IAllele; +import forestry.api.genetics.IAlyzerPlugin; +import forestry.api.genetics.IChromosomeType; +import forestry.api.genetics.IIndividual; +import forestry.api.genetics.IMutation; +import forestry.api.genetics.ISpeciesType; +import forestry.core.genetics.SpeciesRoot; + import binnie.botany.Botany; import binnie.botany.api.EnumFlowerChromosome; import binnie.botany.api.EnumFlowerStage; @@ -11,29 +37,6 @@ import binnie.botany.api.IFlowerGenome; import binnie.botany.api.IFlowerMutation; import binnie.botany.api.IFlowerRoot; import binnie.botany.flower.TileEntityFlower; -import com.mojang.authlib.GameProfile; -import forestry.api.genetics.AlleleManager; -import forestry.api.genetics.IAllele; -import forestry.api.genetics.IAlyzerPlugin; -import forestry.api.genetics.IChromosomeType; -import forestry.api.genetics.IIndividual; -import forestry.api.genetics.IMutation; -import forestry.api.genetics.ISpeciesType; -import forestry.core.genetics.SpeciesRoot; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Random; public class FlowerRoot extends SpeciesRoot implements IFlowerRoot { static final String UID = "rootFlowers"; @@ -44,7 +47,7 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot { Map conversions; public FlowerRoot() { - this.conversions = new HashMap<>(); + conversions = new HashMap<>(); } @Override @@ -56,7 +59,7 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot { public int getSpeciesCount() { if (FlowerRoot.flowerSpeciesCount < 0) { FlowerRoot.flowerSpeciesCount = 0; - for (final Map.Entry entry : AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet()) { + for (Map.Entry entry : AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet()) { if (entry.getValue() instanceof IAlleleFlowerSpecies && ((IAlleleFlowerSpecies) entry.getValue()).isCounted()) { ++FlowerRoot.flowerSpeciesCount; } @@ -66,17 +69,17 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot { } @Override - public boolean isMember(final ItemStack stack) { - return !stack.isEmpty() && this.getType(stack) != null; + public boolean isMember(ItemStack stack) { + return !stack.isEmpty() && getType(stack) != null; } @Override public boolean isMember(ItemStack stack, ISpeciesType type) { - return this.getType(stack) == type; + return getType(stack) == type; } @Override - public boolean isMember(final IIndividual individual) { + public boolean isMember(IIndividual individual) { return individual instanceof IFlower; } @@ -94,7 +97,6 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot { @Nullable public EnumFlowerStage getType(ItemStack stack) { Item item = stack.getItem(); - if (Botany.flowerItem == item) { return EnumFlowerStage.SEED; } else if (Botany.pollen == item) { @@ -102,64 +104,64 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot { } else if (Botany.seed == item) { return EnumFlowerStage.SEED; } - return null; } @Override public ItemStack getMemberStack(IIndividual flower, ISpeciesType type) { - if (!this.isMember(flower)) { + if (!isMember(flower)) { return ItemStack.EMPTY; } + Item flowerItem = Botany.flowerItem; if (type == EnumFlowerStage.SEED) { flowerItem = Botany.seed; - } - if (type == EnumFlowerStage.POLLEN) { + } else if (type == EnumFlowerStage.POLLEN) { flowerItem = Botany.pollen; } if (flowerItem != Botany.flowerItem) { ((IFlower) flower).setAge(0); } - final NBTTagCompound nbttagcompound = new NBTTagCompound(); + + NBTTagCompound nbttagcompound = new NBTTagCompound(); flower.writeToNBT(nbttagcompound); - final ItemStack flowerStack = new ItemStack(flowerItem); + ItemStack flowerStack = new ItemStack(flowerItem); flowerStack.setTagCompound(nbttagcompound); return flowerStack; } @Override @Nullable - public IFlower getMember(final ItemStack stack) { - if (!this.isMember(stack) || stack.getTagCompound() == null) { + public IFlower getMember(ItemStack stack) { + if (!isMember(stack) || stack.getTagCompound() == null) { return null; } return new Flower(stack.getTagCompound()); } @Override - public IFlower getFlower(final IFlowerGenome genome) { + public IFlower getFlower(IFlowerGenome genome) { return new Flower(genome, 2); } @Override - public IFlowerGenome templateAsGenome(final IAllele[] template) { - return new FlowerGenome(this.templateAsChromosomes(template)); + public IFlowerGenome templateAsGenome(IAllele[] template) { + return new FlowerGenome(templateAsChromosomes(template)); } @Override - public IFlowerGenome templateAsGenome(final IAllele[] templateActive, final IAllele[] templateInactive) { + public IFlowerGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive) { return new FlowerGenome(templateAsChromosomes(templateActive, templateInactive)); } @Override - public IFlower templateAsIndividual(final IAllele[] template) { - return new Flower(this.templateAsGenome(template), 2); + public IFlower templateAsIndividual(IAllele[] template) { + return new Flower(templateAsGenome(template), 2); } @Override - public IFlower templateAsIndividual(final IAllele[] templateActive, final IAllele[] templateInactive) { - return new Flower(this.templateAsGenome(templateActive, templateInactive), 2); + public IFlower templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive) { + return new Flower(templateAsGenome(templateActive, templateInactive), 2); } @Override @@ -168,21 +170,21 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot { } @Override - public void registerTemplate(final IAllele[] template) { - this.registerTemplate(template[0].getUID(), template); + public void registerTemplate(IAllele[] template) { + registerTemplate(template[0].getUID(), template); } @Override - public void registerTemplate(final String identifier, final IAllele[] template) { - FlowerRoot.flowerTemplates.add(new Flower(this.templateAsGenome(template), 2)); - if (!this.speciesTemplates.containsKey(identifier)) { - this.speciesTemplates.put(identifier, template); + public void registerTemplate(String identifier, IAllele[] template) { + FlowerRoot.flowerTemplates.add(new Flower(templateAsGenome(template), 2)); + if (!speciesTemplates.containsKey(identifier)) { + speciesTemplates.put(identifier, template); } } @Override - public IAllele[] getTemplate(final String identifier) { - return this.speciesTemplates.get(identifier); + public IAllele[] getTemplate(String identifier) { + return speciesTemplates.get(identifier); } @Override @@ -191,12 +193,12 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot { } @Override - public IAllele[] getRandomTemplate(final Random rand) { - return this.speciesTemplates.values().toArray(new IAllele[0][])[rand.nextInt(this.speciesTemplates.values().size())]; + public IAllele[] getRandomTemplate(Random rand) { + return speciesTemplates.values().toArray(new IAllele[0][])[rand.nextInt(speciesTemplates.values().size())]; } @Override - public ArrayList getMutations(final boolean shuffle) { + public ArrayList getMutations(boolean shuffle) { if (shuffle) { Collections.shuffle(FlowerRoot.flowerMutations); } @@ -204,7 +206,7 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot { } @Override - public void registerMutation(final IMutation mutation) { + public void registerMutation(IMutation mutation) { if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getTemplate()[0].getUID())) { return; } @@ -218,8 +220,8 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot { } @Override - public IBotanistTracker getBreedingTracker(final World world, @Nullable final GameProfile player) { - final String filename = "BotanistTracker." + ((player == null) ? "common" : player.getId()); + public IBotanistTracker getBreedingTracker(World world, @Nullable GameProfile player) { + String filename = "BotanistTracker." + ((player == null) ? "common" : player.getId()); BotanistTracker tracker = (BotanistTracker) world.loadData(BotanistTracker.class, filename); if (tracker == null) { tracker = new BotanistTracker(filename); @@ -229,7 +231,7 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot { } @Override - public IIndividual getMember(final NBTTagCompound compound) { + public IIndividual getMember(NBTTagCompound compound) { return new Flower(compound); } @@ -249,15 +251,15 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot { } @Override - public void addConversion(final ItemStack itemstack, final IAllele[] template) { - final IFlower flower = this.getFlower(this.templateAsGenome(template)); - this.conversions.put(itemstack, flower); + public void addConversion(ItemStack itemstack, IAllele[] template) { + IFlower flower = getFlower(templateAsGenome(template)); + conversions.put(itemstack, flower); } @Override @Nullable - public IFlower getConversion(final ItemStack itemstack) { - for (final Map.Entry entry : this.conversions.entrySet()) { + public IFlower getConversion(ItemStack itemstack) { + for (Map.Entry entry : conversions.entrySet()) { if (entry.getKey().isItemEqual(itemstack)) { return (IFlower) entry.getValue().copy(); } @@ -266,23 +268,24 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot { } @Override - public void registerColourMix(final IColorMix colorMix) { + public void registerColourMix(IColorMix colorMix) { FlowerRoot.colourMixes.add(colorMix); } @Override - public Collection getColorMixes(final boolean shuffle) { + public Collection getColorMixes(boolean shuffle) { if (shuffle) { Collections.shuffle(FlowerRoot.colourMixes); } return FlowerRoot.colourMixes; } - + public boolean plant(World world, BlockPos pos, IFlower flower, GameProfile owner) { boolean set = world.setBlockState(pos, Botany.flower.getDefaultState()); if (!set) { return false; } + TileEntity tile = world.getTileEntity(pos); TileEntity below = world.getTileEntity(pos.down()); if (tile != null && tile instanceof TileEntityFlower) { @@ -293,31 +296,35 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot { tileFlower.create(flower, owner); } } + tryGrowSection(world, pos); return true; } - + @Override public void tryGrowSection(World world, BlockPos pos) { if (world.isRemote) { return; } + TileEntity tileFlower = world.getTileEntity(pos); - if(tileFlower == null || !(tileFlower instanceof TileEntityFlower)){ + if (tileFlower == null || !(tileFlower instanceof TileEntityFlower)) { return; } + IFlower flower = ((TileEntityFlower) tileFlower).getFlower(); int section = ((TileEntityFlower) tileFlower).getSection(); - if(flower == null || section >= flower.getGenome().getPrimary().getType().getSections() - 1 || flower.getAge() <= 0){ + if (flower == null || section >= flower.getGenome().getPrimary().getType().getSections() - 1 || flower.getAge() <= 0) { return; } + world.setBlockState(pos.up(), Botany.flower.getDefaultState()); TileEntity flowerAbove = world.getTileEntity(pos.up()); if (flowerAbove != null && flowerAbove instanceof TileEntityFlower) { ((TileEntityFlower) flowerAbove).setSection(section + 1); } } - + @Override public void onGrowFromSeed(World world, BlockPos pos) { tryGrowSection(world, pos); diff --git a/src/main/java/binnie/botany/genetics/FlowerTemplates.java b/src/main/java/binnie/botany/genetics/FlowerTemplates.java index 198ab52b..e3d080e5 100644 --- a/src/main/java/binnie/botany/genetics/FlowerTemplates.java +++ b/src/main/java/binnie/botany/genetics/FlowerTemplates.java @@ -8,7 +8,7 @@ import binnie.botany.api.EnumFlowerChromosome; public class FlowerTemplates { public static IAllele[] getDefaultTemplate() { - final IAllele[] alleles = new IAllele[EnumFlowerChromosome.values().length]; + IAllele[] alleles = new IAllele[EnumFlowerChromosome.values().length]; //TODO: Test flower reset AlleleHelper.getInstance().set(alleles, EnumFlowerChromosome.SPECIES, FlowerDefinition.Poppy.getSpecies()); AlleleHelper.getInstance().set(alleles, EnumFlowerChromosome.PRIMARY, EnumFlowerColor.Red.getFlowerColorAllele()); diff --git a/src/main/java/binnie/botany/genetics/ItemDictionary.java b/src/main/java/binnie/botany/genetics/ItemDictionary.java index 614709a3..36e79978 100644 --- a/src/main/java/binnie/botany/genetics/ItemDictionary.java +++ b/src/main/java/binnie/botany/genetics/ItemDictionary.java @@ -22,15 +22,15 @@ import binnie.core.util.I18N; public class ItemDictionary extends Item implements IItemModelRegister { public ItemDictionary() { - this.setCreativeTab(CreativeTabBotany.instance); - this.setUnlocalizedName("database"); - this.setMaxStackSize(1); + setCreativeTab(CreativeTabBotany.instance); + setUnlocalizedName("database"); + setMaxStackSize(1); setRegistryName("database"); } @Override @SideOnly(Side.CLIENT) - public void getSubItems(final Item itemIn, final CreativeTabs tab, final NonNullList subItems) { + public void getSubItems(Item itemIn, CreativeTabs tab, NonNullList subItems) { super.getSubItems(itemIn, tab, subItems); subItems.add(new ItemStack(itemIn, 1, 1)); } @@ -46,15 +46,15 @@ public class ItemDictionary extends Item implements IItemModelRegister { public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { ItemStack itemStack = playerIn.getHeldItem(handIn); if (itemStack.getMetadata() == 0) { - Botany.proxy.openGui(BotanyGUI.Database, playerIn, playerIn.getPosition()); + Botany.proxy.openGui(BotanyGUI.DATABASE, playerIn, playerIn.getPosition()); } else { - Botany.proxy.openGui(BotanyGUI.DatabaseNEI, playerIn, playerIn.getPosition()); + Botany.proxy.openGui(BotanyGUI.DATABASE_NEI, playerIn, playerIn.getPosition()); } return super.onItemRightClick(worldIn, playerIn, handIn); } @Override - public String getItemStackDisplayName(final ItemStack i) { + public String getItemStackDisplayName(ItemStack i) { return I18N.localise("item.botany.database." + ((i.getItemDamage() == 0) ? "name" : "master.name")); } } diff --git a/src/main/java/binnie/botany/genetics/ModuleGenetics.java b/src/main/java/binnie/botany/genetics/ModuleGenetics.java index 5556d394..121b6f19 100644 --- a/src/main/java/binnie/botany/genetics/ModuleGenetics.java +++ b/src/main/java/binnie/botany/genetics/ModuleGenetics.java @@ -35,7 +35,7 @@ public class ModuleGenetics implements IInitializable { @Override public void preInit() { /* INIT API*/ - binnie.botany.api.FlowerManager.flowerFactory = new FlowerFactory(); + FlowerManager.flowerFactory = new FlowerFactory(); AlleleManager.alleleRegistry.registerSpeciesRoot(BotanyCore.getFlowerRoot()); AlleleManager.alleleRegistry.registerAllele(ModuleGenetics.alleleEffectNone); EnumFlowerColor.setupMutations(); @@ -43,7 +43,7 @@ public class ModuleGenetics implements IInitializable { /* BACKPACK*/ IBackpackInterface backpackInterface = BackpackManager.backpackInterface; - + if (ForestryAPI.enabledPlugins.contains("forestry.storage")) { Predicate filter = BackpackManager.backpackInterface.createNaturalistBackpackFilter("rootFlowers"); BackpackDefinition definition = new BackpackDefinition(new Color(0xf6e83e), Color.WHITE, filter); @@ -56,19 +56,19 @@ public class ModuleGenetics implements IInitializable { } /* ITEMS */ - Botany.flower = new BlockFlower(); - Botany.proxy.registerBlock(Botany.flower); - BinnieCore.getBinnieProxy().registerTileEntity(TileEntityFlower.class, "botany.tile.flower", null); - Botany.flowerItem = new ItemBotany("itemFlower", EnumFlowerStage.FLOWER, ""); Botany.pollen = new ItemBotany("pollen", EnumFlowerStage.POLLEN, "pollen"); Botany.seed = new ItemBotany("seed", EnumFlowerStage.SEED, "germling"); Botany.database = new ItemDictionary(); + + Botany.proxy.registerBlock(Botany.flower); Botany.proxy.registerItem(Botany.flowerItem); Botany.proxy.registerItem(Botany.pollen); Botany.proxy.registerItem(Botany.seed); Botany.proxy.registerItem(Botany.database); + + BinnieCore.getBinnieProxy().registerTileEntity(TileEntityFlower.class, "botany.tile.flower", null); } @Override @@ -80,25 +80,31 @@ public class ModuleGenetics implements IInitializable { @Override public void postInit() { forestry.api.apiculture.FlowerManager.flowerRegistry.registerAcceptableFlower(Botany.flower, "flowersVanilla"); - RecipeManagers.carpenterManager.addRecipe(100, Binnie.LIQUID.getFluidStack(ManagerLiquid.WATER, 2000), ItemStack.EMPTY, new ItemStack(Botany.database), - "X#X", - "YEY", - "RDR", - '#', Blocks.GLASS_PANE, - 'X', Items.GOLD_INGOT, - 'Y', Items.GOLD_NUGGET, - 'R', Items.REDSTONE, - 'D', Items.DIAMOND, - 'E', Items.EMERALD + RecipeManagers.carpenterManager.addRecipe( + 100, + Binnie.LIQUID.getFluidStack(ManagerLiquid.WATER, 2000), + ItemStack.EMPTY, + new ItemStack(Botany.database), + "X#X", + "YEY", + "RDR", + '#', Blocks.GLASS_PANE, + 'X', Items.GOLD_INGOT, + 'Y', Items.GOLD_NUGGET, + 'R', Items.REDSTONE, + 'D', Items.DIAMOND, + 'E', Items.EMERALD ); - RecipeUtil.addRecipe(Botany.botanistBackpack, - "X#X", - "VYZ", - "X#X", - '#', Blocks.WOOL, - 'X', Items.STRING, - 'V', Botany.soilMeter, - 'Z', "toolTrowel", - 'Y', "chestWood"); + RecipeUtil.addRecipe + (Botany.botanistBackpack, + "X#X", + "VYZ", + "X#X", + '#', Blocks.WOOL, + 'X', Items.STRING, + 'V', Botany.soilMeter, + 'Z', "toolTrowel", + 'Y', "chestWood" + ); } } diff --git a/src/main/java/binnie/botany/items/BotanyItems.java b/src/main/java/binnie/botany/items/BotanyItems.java index 81abd26c..19a74fc3 100644 --- a/src/main/java/binnie/botany/items/BotanyItems.java +++ b/src/main/java/binnie/botany/items/BotanyItems.java @@ -1,6 +1,7 @@ package binnie.botany.items; import java.util.List; +import java.util.Locale; import net.minecraft.item.ItemStack; @@ -9,23 +10,24 @@ import binnie.core.item.IItemMiscProvider; import binnie.core.util.I18N; public enum BotanyItems implements IItemMiscProvider { - AshPowder("powder_ash"), - PulpPowder("powder_pulp"), - MulchPowder("powder_mulch"), - SulphurPowder("powder_sulphur"), - FertiliserPowder("powder_fertiliser"), - CompostPowder("powder_compost"), - Mortar("mortar"), - Weedkiller("weedkiller"); + POWDER_ASH, + POWDER_PULP, + POWDER_MULCH, + POWDER_SULPHUR, + POWDER_FERTILISER, + POWDER_COMPOST, + MORTAR, + WEEDKILLER; String name; - BotanyItems(String name) { - this.name = name; + BotanyItems() { + name = name().toLowerCase(Locale.ENGLISH); } @Override public void addInformation(List tooltip) { + // ignored } @Override @@ -40,7 +42,7 @@ public enum BotanyItems implements IItemMiscProvider { @Override public ItemStack get(int size) { - return new ItemStack(Botany.misc, size, this.ordinal()); + return new ItemStack(Botany.misc, size, ordinal()); } @Override diff --git a/src/main/java/binnie/botany/items/ItemClay.java b/src/main/java/binnie/botany/items/ItemClay.java index c745526e..1e3893b8 100644 --- a/src/main/java/binnie/botany/items/ItemClay.java +++ b/src/main/java/binnie/botany/items/ItemClay.java @@ -18,10 +18,10 @@ import binnie.core.util.I18N; public class ItemClay extends Item implements IColoredItem, IItemModelRegister { public ItemClay() { - this.setUnlocalizedName("botany.clay"); - this.setHasSubtypes(true); - this.setCreativeTab(CreativeTabBotany.instance); - this.setRegistryName("clay"); + setUnlocalizedName("botany.clay"); + setHasSubtypes(true); + setCreativeTab(CreativeTabBotany.instance); + setRegistryName("clay"); } @SideOnly(Side.CLIENT) @@ -40,14 +40,14 @@ public class ItemClay extends Item implements IColoredItem, IItemModelRegister { } @Override - public String getItemStackDisplayName(final ItemStack stack) { + public String getItemStackDisplayName(ItemStack stack) { EnumFlowerColor color = EnumFlowerColor.get(stack.getItemDamage()); return I18N.localise("item.botany.clay.name", color.getFlowerColorAllele().getColorName()); -} + } @Override @SideOnly(Side.CLIENT) - public void getSubItems(final Item itemIn, final CreativeTabs tab, final NonNullList list) { + public void getSubItems(Item itemIn, CreativeTabs tab, NonNullList list) { for (EnumFlowerColor color : EnumFlowerColor.values()) { list.add(new ItemStack(this, 1, color.ordinal())); } diff --git a/src/main/java/binnie/botany/items/ItemPigment.java b/src/main/java/binnie/botany/items/ItemPigment.java index 98a5556d..51cc048a 100644 --- a/src/main/java/binnie/botany/items/ItemPigment.java +++ b/src/main/java/binnie/botany/items/ItemPigment.java @@ -18,10 +18,10 @@ import binnie.core.util.I18N; public class ItemPigment extends Item implements IItemModelRegister, IColoredItem { public ItemPigment() { - this.setUnlocalizedName("botany.pigment"); - this.setHasSubtypes(true); - this.setCreativeTab(CreativeTabBotany.instance); - this.setRegistryName("pigment"); + setUnlocalizedName("botany.pigment"); + setHasSubtypes(true); + setCreativeTab(CreativeTabBotany.instance); + setRegistryName("pigment"); } @SideOnly(Side.CLIENT) @@ -40,14 +40,14 @@ public class ItemPigment extends Item implements IItemModelRegister, IColoredIte } @Override - public String getItemStackDisplayName(final ItemStack stack) { + public String getItemStackDisplayName(ItemStack stack) { EnumFlowerColor color = EnumFlowerColor.get(stack.getItemDamage()); return I18N.localise("item.botany.pigment.name", color.getFlowerColorAllele().getColorName()); } @Override @SideOnly(Side.CLIENT) - public void getSubItems(final Item itemIn, final CreativeTabs tab, final NonNullList list) { + public void getSubItems(Item itemIn, CreativeTabs tab, NonNullList list) { for (EnumFlowerColor color : EnumFlowerColor.values()) { list.add(new ItemStack(this, 1, color.ordinal())); } diff --git a/src/main/java/binnie/botany/network/PacketFlowerUpdate.java b/src/main/java/binnie/botany/network/PacketFlowerUpdate.java index cb6a6f9b..00901678 100644 --- a/src/main/java/binnie/botany/network/PacketFlowerUpdate.java +++ b/src/main/java/binnie/botany/network/PacketFlowerUpdate.java @@ -11,10 +11,11 @@ import binnie.botany.flower.TileEntityFlower; import binnie.botany.genetics.EnumFlowerColor; import binnie.botany.genetics.EnumFlowerType; +// TODO unused class? public class PacketFlowerUpdate extends SPacketUpdateTileEntity { public TileEntityFlower.RenderInfo render; - public PacketFlowerUpdate(BlockPos blockPos, int metadata, NBTTagCompound compound, final TileEntityFlower.RenderInfo render) { + public PacketFlowerUpdate(BlockPos blockPos, int metadata, NBTTagCompound compound, TileEntityFlower.RenderInfo render) { super(blockPos, metadata, compound); this.render = render; } @@ -22,27 +23,27 @@ public class PacketFlowerUpdate extends SPacketUpdateTileEntity { @Override public void readPacketData(PacketBuffer buf) throws IOException { super.readPacketData(buf); - this.render = new TileEntityFlower.RenderInfo(); - this.render.primary = EnumFlowerColor.values()[buf.readByte()].getFlowerColorAllele(); - this.render.secondary = EnumFlowerColor.values()[buf.readByte()].getFlowerColorAllele(); - this.render.stem = EnumFlowerColor.values()[buf.readByte()].getFlowerColorAllele(); - this.render.type = EnumFlowerType.values()[buf.readByte()]; - this.render.age = buf.readByte(); - this.render.section = buf.readByte(); - this.render.wilted = buf.readBoolean(); - this.render.flowered = buf.readBoolean(); + render = new TileEntityFlower.RenderInfo(); + render.primary = EnumFlowerColor.values()[buf.readByte()].getFlowerColorAllele(); + render.secondary = EnumFlowerColor.values()[buf.readByte()].getFlowerColorAllele(); + render.stem = EnumFlowerColor.values()[buf.readByte()].getFlowerColorAllele(); + render.type = EnumFlowerType.values()[buf.readByte()]; + render.age = buf.readByte(); + render.section = buf.readByte(); + render.wilted = buf.readBoolean(); + render.flowered = buf.readBoolean(); } @Override public void writePacketData(PacketBuffer buf) throws IOException { super.writePacketData(buf); - buf.writeByte(this.render.primary.getID()); - buf.writeByte(this.render.secondary.getID()); - buf.writeByte(this.render.stem.getID()); - buf.writeByte(this.render.type.ordinal()); - buf.writeByte(this.render.age); - buf.writeByte(this.render.section); - buf.writeBoolean(this.render.wilted); - buf.writeBoolean(this.render.flowered); + buf.writeByte(render.primary.getID()); + buf.writeByte(render.secondary.getID()); + buf.writeByte(render.stem.getID()); + buf.writeByte(render.type.ordinal()); + buf.writeByte(render.age); + buf.writeByte(render.section); + buf.writeBoolean(render.wilted); + buf.writeBoolean(render.flowered); } } diff --git a/src/main/java/binnie/botany/network/PacketID.java b/src/main/java/binnie/botany/network/PacketID.java index ebfaf6e6..98971de4 100644 --- a/src/main/java/binnie/botany/network/PacketID.java +++ b/src/main/java/binnie/botany/network/PacketID.java @@ -31,7 +31,7 @@ public enum PacketID implements IPacketID { public void onUseFieldKit(NBTTagCompound data) { EntityPlayer player = BinnieCore.getBinnieProxy().getPlayer(); String info = ""; - if (data == null || data.hasNoTags()) { + if (data.hasNoTags()) { info += I18N.localise("botany.flowers.species.not.discover"); } else { IAlleleFlowerSpecies primary = (IAlleleFlowerSpecies) AlleleManager.alleleRegistry.getAllele(data.getString("Species")); @@ -42,6 +42,7 @@ public enum PacketID implements IPacketID { if (primary == null || secondary == null) { return; } + info += I18N.localise("botany.flowers.fielkit.a"); if (age == 0.0f) { info += ""; @@ -52,16 +53,19 @@ public enum PacketID implements IPacketID { } else { info += " " + I18N.localise("botany.flowers.fielkit.old"); } + if (color1 == color2) { info = info + " " + color1.getName(); } else { info = info + " " + color1.getName() + " & " + color2.getName(); } + if (primary == secondary) { info = info + " " + primary.getName(); } else { info = info + " " + primary.getName() + "-" + secondary.getName() + " " + I18N.localise("botany.flowers.species.hybrid"); } + if (age == 0.0f) { info += " " + I18N.localise("botany.flowers.species.germling"); } diff --git a/src/main/java/binnie/core/craftgui/WindowFieldKit.java b/src/main/java/binnie/core/craftgui/WindowFieldKit.java index c2608b27..f84c0d05 100644 --- a/src/main/java/binnie/core/craftgui/WindowFieldKit.java +++ b/src/main/java/binnie/core/craftgui/WindowFieldKit.java @@ -121,7 +121,7 @@ public class WindowFieldKit extends Window { new ControlSlot.Builder(this, handGlass.x() + 54, handGlass.y() + 26).assign(InventoryType.Window, 0); new ControlSlot.Builder(this, 208, 8).assign(InventoryType.Window, 1); (this.text = new ControlText(this, new Point(232, 13), "Paper")).setColour(2236962); - (this.text = new ControlText(this, new Area(0, 120, this.width(), 24), "", TextJustification.MiddleCenter)).setColour(2236962); + (this.text = new ControlText(this, new Area(0, 120, this.width(), 24), "", TextJustification.MIDDLE_CENTER)).setColour(2236962); this.chromo = new ControlChromosome(this, 150, 24); this.addEventHandler(new EventValueChanged.Handler() { @Override diff --git a/src/main/java/binnie/core/craftgui/controls/ControlCheckbox.java b/src/main/java/binnie/core/craftgui/controls/ControlCheckbox.java index 4fc1d366..a702c05b 100644 --- a/src/main/java/binnie/core/craftgui/controls/ControlCheckbox.java +++ b/src/main/java/binnie/core/craftgui/controls/ControlCheckbox.java @@ -29,7 +29,7 @@ public class ControlCheckbox extends Control implements IControlValue { this.text = text; this.value = bool; if (w > 16) { - new ControlText(this, new Area(16, 1, w - 16, 16), text, TextJustification.MiddleCenter).setColour(4473924); + new ControlText(this, new Area(16, 1, w - 16, 16), text, TextJustification.MIDDLE_CENTER).setColour(4473924); } this.addAttribute(Attribute.MouseOver); this.addEventHandler(new EventMouse.Down.Handler() { diff --git a/src/main/java/binnie/core/craftgui/controls/button/ControlButton.java b/src/main/java/binnie/core/craftgui/controls/button/ControlButton.java index 8c0e054c..1784405d 100644 --- a/src/main/java/binnie/core/craftgui/controls/button/ControlButton.java +++ b/src/main/java/binnie/core/craftgui/controls/button/ControlButton.java @@ -37,7 +37,7 @@ public class ControlButton extends Control { public ControlButton(final IWidget parent, final int x, final int y, final int width, final int height, final String text) { this(parent, x, y, width, height); this.text = text; - this.textWidget = new ControlText(this, this.getArea(), text, TextJustification.MiddleCenter); + this.textWidget = new ControlText(this, this.getArea(), text, TextJustification.MIDDLE_CENTER); } protected void onMouseClick(final EventMouse.Down event) { diff --git a/src/main/java/binnie/core/craftgui/controls/listbox/ControlTextOption.java b/src/main/java/binnie/core/craftgui/controls/listbox/ControlTextOption.java index 16df62d0..cbd72614 100644 --- a/src/main/java/binnie/core/craftgui/controls/listbox/ControlTextOption.java +++ b/src/main/java/binnie/core/craftgui/controls/listbox/ControlTextOption.java @@ -11,7 +11,7 @@ public class ControlTextOption extends ControlOption { public ControlTextOption(final ControlList controlList, final T option, final String optionName, final int y) { super(controlList, option, y); this.textWidget = null; - this.textWidget = new ControlText(this, this.getArea(), optionName, TextJustification.MiddleCenter); + this.textWidget = new ControlText(this, this.getArea(), optionName, TextJustification.MIDDLE_CENTER); this.addEventHandler(new EventWidget.ChangeColour.Handler() { @Override public void onEvent(final EventWidget.ChangeColour event) { diff --git a/src/main/java/binnie/core/craftgui/database/PageSpeciesOverview.java b/src/main/java/binnie/core/craftgui/database/PageSpeciesOverview.java index 9c1560ac..157a88b9 100644 --- a/src/main/java/binnie/core/craftgui/database/PageSpeciesOverview.java +++ b/src/main/java/binnie/core/craftgui/database/PageSpeciesOverview.java @@ -37,8 +37,8 @@ public class PageSpeciesOverview extends PageSpecies { this.controlScientific = new ControlTextCentered(this, 32, ""); this.controlAuthority = new ControlTextCentered(this, 44, ""); this.controlComplexity = new ControlTextCentered(this, 68, ""); - this.controlDescription = new ControlText(this, new Area(8, 84, this.getSize().x() - 16, 0), "", TextJustification.MiddleCenter); - this.controlSignature = new ControlText(this, new Area(8, 84, this.getSize().x() - 16, 0), "", TextJustification.BottomRight); + this.controlDescription = new ControlText(this, new Area(8, 84, this.getSize().x() - 16, 0), "", TextJustification.MIDDLE_CENTER); + this.controlSignature = new ControlText(this, new Area(8, 84, this.getSize().x() - 16, 0), "", TextJustification.BOTTOM_RIGHT); } @Override diff --git a/src/main/java/binnie/core/craftgui/geometry/CraftGUIUtil.java b/src/main/java/binnie/core/craftgui/geometry/CraftGUIUtil.java index aa946de3..11a5a25a 100644 --- a/src/main/java/binnie/core/craftgui/geometry/CraftGUIUtil.java +++ b/src/main/java/binnie/core/craftgui/geometry/CraftGUIUtil.java @@ -16,7 +16,7 @@ public class CraftGUIUtil { } public static void horizontalGrid(final int px, final int py, final IWidget... widgets) { - horizontalGrid(px, py, TextJustification.MiddleCenter, 0, widgets); + horizontalGrid(px, py, TextJustification.MIDDLE_CENTER, 0, widgets); } public static void horizontalGrid(final int px, final int py, final TextJustification just, final int spacing, final IWidget... widgets) { @@ -32,7 +32,7 @@ public class CraftGUIUtil { } public static void verticalGrid(final int px, final int py, final IWidget... widgets) { - horizontalGrid(px, py, TextJustification.MiddleCenter, 0, widgets); + horizontalGrid(px, py, TextJustification.MIDDLE_CENTER, 0, widgets); } public static void verticalGrid(final int px, final int py, final TextJustification just, final int spacing, final IWidget... widgets) { diff --git a/src/main/java/binnie/core/craftgui/geometry/TextJustification.java b/src/main/java/binnie/core/craftgui/geometry/TextJustification.java index 4ade7961..7cc8bb4c 100644 --- a/src/main/java/binnie/core/craftgui/geometry/TextJustification.java +++ b/src/main/java/binnie/core/craftgui/geometry/TextJustification.java @@ -4,26 +4,26 @@ public enum TextJustification { TOP_LEFT(0.0f, 0.0f), TOP_CENTER(0.5f, 0.0f), TOP_RIGHT(1.0f, 0.0f), - MIDDLE_LEFTt(0.0f, 0.5f), - MiddleCenter(0.5f, 0.5f), - MiddleRight(1.0f, 0.5f), - BottomLeft(0.0f, 1.0f), - BottomCenter(0.5f, 1.0f), - BottomRight(1.0f, 1.0f); + MIDDLE_LEFT(0.0f, 0.5f), + MIDDLE_CENTER(0.5f, 0.5f), + MIDDLE_RIGHT(1.0f, 0.5f), + BOTTOM_LEFT(0.0f, 1.0f), + BOTTOM_CENTER(0.5f, 1.0f), + BOTTOM_RIGHT(1.0f, 1.0f); private final float xOffset; private final float yOffset; - TextJustification(final float xOffset, final float yOffset) { + TextJustification(float xOffset, float yOffset) { this.xOffset = xOffset; this.yOffset = yOffset; } public float getXOffset() { - return this.xOffset; + return xOffset; } public float getYOffset() { - return this.yOffset; + return yOffset; } } diff --git a/src/main/java/binnie/core/craftgui/minecraft/control/ControlSlide.java b/src/main/java/binnie/core/craftgui/minecraft/control/ControlSlide.java index 65ee8cd2..8cf7fa2f 100644 --- a/src/main/java/binnie/core/craftgui/minecraft/control/ControlSlide.java +++ b/src/main/java/binnie/core/craftgui/minecraft/control/ControlSlide.java @@ -63,7 +63,7 @@ public class ControlSlide extends Control { if (this.anchor.y() > 0) { GlStateManager.translate(0.0f, -lh, 0.0f); } - RenderUtil.drawText(labelArea, TextJustification.MiddleCenter, this.label, 16777215); + RenderUtil.drawText(labelArea, TextJustification.MIDDLE_CENTER, this.label, 16777215); GlStateManager.popMatrix(); } CraftGUI.render.texture(CraftGUITexture.Window, this.getArea()); diff --git a/src/main/java/binnie/extratrees/machines/craftgui/PageFruit.java b/src/main/java/binnie/extratrees/machines/craftgui/PageFruit.java index db6ac765..b757446d 100644 --- a/src/main/java/binnie/extratrees/machines/craftgui/PageFruit.java +++ b/src/main/java/binnie/extratrees/machines/craftgui/PageFruit.java @@ -34,7 +34,7 @@ public class PageFruit extends PageAbstract { public void onValueChanged(final ItemStack species) { this.deleteAllChildren(); final WindowAbstractDatabase database = Window.get(this); - new ControlText(this, new Area(0, 0, this.size().x(), 24), I18N.localise("extratrees.gui.database.tab.fruit." + (this.treesThatBearFruit ? "natural" : "potential")), TextJustification.MiddleCenter); + new ControlText(this, new Area(0, 0, this.size().x(), 24), I18N.localise("extratrees.gui.database.tab.fruit." + (this.treesThatBearFruit ? "natural" : "potential")), TextJustification.MIDDLE_CENTER); final Collection trees = this.treesThatBearFruit ? ((TreeBreedingSystem) database.getBreedingSystem()).getTreesThatBearFruit(species, database.isNEI(), database.getWorld(), database.getUsername()) : ((TreeBreedingSystem) database.getBreedingSystem()).getTreesThatCanBearFruit(species, database.isNEI(), database.getWorld(), database.getUsername()); new ControlSpeciesBox(this, 4, 24, this.size().x() - 8, this.size().y() - 4 - 24).setOptions(trees); } diff --git a/src/main/java/binnie/extratrees/machines/craftgui/PagePlanksOverview.java b/src/main/java/binnie/extratrees/machines/craftgui/PagePlanksOverview.java index edbcf293..f78d68ac 100644 --- a/src/main/java/binnie/extratrees/machines/craftgui/PagePlanksOverview.java +++ b/src/main/java/binnie/extratrees/machines/craftgui/PagePlanksOverview.java @@ -31,8 +31,8 @@ public class PagePlanksOverview extends PageAbstract { public void onValueChanged(final ItemStack species) { this.deleteAllChildren(); final WindowAbstractDatabase database = Window.get(this); - new ControlText(this, new Area(0, 0, this.size().x(), 24), species.getDisplayName(), TextJustification.MiddleCenter); - new ControlText(this, new Area(12, 24, this.size().x() - 24, 24), I18N.localise("extratrees.gui.database.planks.use"), TextJustification.MIDDLE_LEFTt); + new ControlText(this, new Area(0, 0, this.size().x(), 24), species.getDisplayName(), TextJustification.MIDDLE_CENTER); + new ControlText(this, new Area(12, 24, this.size().x() - 24, 24), I18N.localise("extratrees.gui.database.planks.use"), TextJustification.MIDDLE_LEFT); final IPlankType type = WoodManager.getPlankType(species); int x = 12; if (type != null) { @@ -52,8 +52,8 @@ public class PagePlanksOverview extends PageAbstract { x += 22; } } - final ControlText controlDescription = new ControlText(this, new Area(8, 84, this.getSize().x() - 16, 0), "", TextJustification.MiddleCenter); - final ControlText controlSignature = new ControlText(this, new Area(8, 84, this.getSize().x() - 16, 0), "", TextJustification.BottomRight); + final ControlText controlDescription = new ControlText(this, new Area(8, 84, this.getSize().x() - 16, 0), "", TextJustification.MIDDLE_CENTER); + final ControlText controlSignature = new ControlText(this, new Area(8, 84, this.getSize().x() - 16, 0), "", TextJustification.BOTTOM_RIGHT); String desc = ""; if (type != null) { desc = type.getDescription(); diff --git a/src/main/java/binnie/extratrees/machines/craftgui/PagePlanksTrees.java b/src/main/java/binnie/extratrees/machines/craftgui/PagePlanksTrees.java index 1964f085..23eb2f6d 100644 --- a/src/main/java/binnie/extratrees/machines/craftgui/PagePlanksTrees.java +++ b/src/main/java/binnie/extratrees/machines/craftgui/PagePlanksTrees.java @@ -30,7 +30,7 @@ public class PagePlanksTrees extends PageAbstract { public void onValueChanged(final ItemStack species) { this.deleteAllChildren(); final WindowAbstractDatabase database = Window.get(this); - new ControlText(this, new Area(0, 0, this.size().x(), 24), species.getDisplayName(), TextJustification.MiddleCenter); + new ControlText(this, new Area(0, 0, this.size().x(), 24), species.getDisplayName(), TextJustification.MIDDLE_CENTER); final Collection trees = ((TreeBreedingSystem) database.getBreedingSystem()).getTreesThatMakePlanks(species, database.isNEI(), database.getWorld(), database.getUsername()); new ControlSpeciesBox(this, 4, 24, this.size().x() - 8, this.size().y() - 4 - 24).setOptions(trees); } diff --git a/src/main/java/binnie/extratrees/machines/craftgui/PageSpeciesTreeGenome.java b/src/main/java/binnie/extratrees/machines/craftgui/PageSpeciesTreeGenome.java index 5f84348f..0e57f9de 100644 --- a/src/main/java/binnie/extratrees/machines/craftgui/PageSpeciesTreeGenome.java +++ b/src/main/java/binnie/extratrees/machines/craftgui/PageSpeciesTreeGenome.java @@ -62,7 +62,7 @@ public class PageSpeciesTreeGenome extends PageSpecies { final IAlleleTreeSpecies treeSpecies = genome.getPrimary(); final int w = 144; final int h = 176; - new ControlText(this, new Area(0, 4, w, 16), this.getValue().toString(), TextJustification.MiddleCenter); + new ControlText(this, new Area(0, 4, w, 16), this.getValue().toString(), TextJustification.MIDDLE_CENTER); final ControlScrollableContent scrollable = new ControlScrollableContent(this, 4, 20, w - 8, h - 8 - 16, 12); final Control contents = new Control(scrollable, 0, 0, w - 8 - 12, h - 8 - 16); final int tw = w - 8 - 12; @@ -72,10 +72,10 @@ public class PageSpeciesTreeGenome extends PageSpecies { final int th = 14; final int th2 = 18; final BreedingSystem syst = Binnie.GENETICS.treeBreedingSystem; - new ControlText(contents, new Area(w2, y, w3, th), treeSpecies.getPlantType().toString(), TextJustification.MIDDLE_LEFTt); + new ControlText(contents, new Area(w2, y, w3, th), treeSpecies.getPlantType().toString(), TextJustification.MIDDLE_LEFT); y += th; - new ControlText(contents, new Area(0, y, w2, th), I18N.localise("binniecore.gui.temperature.short") + " : ", TextJustification.MiddleRight); - new ControlText(contents, new Area(w2, y, w3, th), treeSpecies.getTemperature().getName(), TextJustification.MIDDLE_LEFTt); + new ControlText(contents, new Area(0, y, w2, th), I18N.localise("binniecore.gui.temperature.short") + " : ", TextJustification.MIDDLE_RIGHT); + new ControlText(contents, new Area(w2, y, w3, th), treeSpecies.getTemperature().getName(), TextJustification.MIDDLE_LEFT); y += th; TextureMap map = Minecraft.getMinecraft().getTextureMapBlocks(); ILeafSpriteProvider spriteProvider = treeSpecies.getLeafSpriteProvider(); @@ -91,7 +91,7 @@ public class PageSpeciesTreeGenome extends PageSpecies { ex.printStackTrace(); } if (leaf != null) { - new ControlText(contents, new Area(0, y, w2, th2), I18N.localise("extratrees.gui.database.leaves") + " : ", TextJustification.MiddleRight); + new ControlText(contents, new Area(0, y, w2, th2), I18N.localise("extratrees.gui.database.leaves") + " : ", TextJustification.MIDDLE_RIGHT); new ControlBlockIconDisplay(contents, w2, y, leaf).setColour(leafColour); if (fruit != null && !treeSpecies.getUID().equals("forestry.treeOak")) { new ControlBlockIconDisplay(contents, w2, y, fruit).setColour(fruitColour); @@ -101,22 +101,22 @@ public class PageSpeciesTreeGenome extends PageSpecies { Map products = fruitProvider.getProducts(); ItemStack log = treeSpecies.getWoodProvider().getWoodStack(); if (log.isEmpty()) { - new ControlText(contents, new Area(0, y, w2, th2), I18N.localise("extratrees.gui.database.log") + " : ", TextJustification.MiddleRight); + new ControlText(contents, new Area(0, y, w2, th2), I18N.localise("extratrees.gui.database.log") + " : ", TextJustification.MIDDLE_RIGHT); final ControlItemDisplay display = new ControlItemDisplay(contents, w2, y); display.setItemStack(log); display.setTooltip(); y += th2; } - new ControlText(contents, new Area(0, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.HEIGHT) + " : ", TextJustification.MiddleRight); - new ControlText(contents, new Area(w2, y, w3, th), genome.getHeight() + "x", TextJustification.MIDDLE_LEFTt); + new ControlText(contents, new Area(0, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.HEIGHT) + " : ", TextJustification.MIDDLE_RIGHT); + new ControlText(contents, new Area(w2, y, w3, th), genome.getHeight() + "x", TextJustification.MIDDLE_LEFT); y += th; - new ControlText(contents, new Area(0, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.FERTILITY) + " : ", TextJustification.MiddleRight); - new ControlText(contents, new Area(w2, y, w3, th), genome.getFertility() + "x", TextJustification.MIDDLE_LEFTt); + new ControlText(contents, new Area(0, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.FERTILITY) + " : ", TextJustification.MIDDLE_RIGHT); + new ControlText(contents, new Area(w2, y, w3, th), genome.getFertility() + "x", TextJustification.MIDDLE_LEFT); y += th; List fruits = new ArrayList<>(); fruits.addAll(products.keySet()); if (!fruits.isEmpty()) { - new ControlText(contents, new Area(0, y, w2, th2), syst.getChromosomeShortName(EnumTreeChromosome.FRUITS) + " : ", TextJustification.MiddleRight); + new ControlText(contents, new Area(0, y, w2, th2), syst.getChromosomeShortName(EnumTreeChromosome.FRUITS) + " : ", TextJustification.MIDDLE_RIGHT); for (ItemStack fruitw : fruits) { final ControlItemDisplay display2 = new ControlItemDisplay(contents, w2, y); display2.setItemStack(fruitw); @@ -124,17 +124,17 @@ public class PageSpeciesTreeGenome extends PageSpecies { y += th2; } } - new ControlText(contents, new Area(0, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.YIELD) + " : ", TextJustification.MiddleRight); - new ControlText(contents, new Area(w2, y, w3, th), genome.getYield() + "x", TextJustification.MIDDLE_LEFTt); + new ControlText(contents, new Area(0, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.YIELD) + " : ", TextJustification.MIDDLE_RIGHT); + new ControlText(contents, new Area(w2, y, w3, th), genome.getYield() + "x", TextJustification.MIDDLE_LEFT); y += th; - new ControlText(contents, new Area(0, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.SAPPINESS) + " : ", TextJustification.MiddleRight); - new ControlText(contents, new Area(w2, y, w3, th), genome.getSappiness() + "x", TextJustification.MIDDLE_LEFTt); + new ControlText(contents, new Area(0, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.SAPPINESS) + " : ", TextJustification.MIDDLE_RIGHT); + new ControlText(contents, new Area(w2, y, w3, th), genome.getSappiness() + "x", TextJustification.MIDDLE_LEFT); y += th; - new ControlText(contents, new Area(0, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.MATURATION) + " : ", TextJustification.MiddleRight); - new ControlText(contents, new Area(w2, y, w3, th), genome.getMaturationTime() + "x", TextJustification.MIDDLE_LEFTt); + new ControlText(contents, new Area(0, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.MATURATION) + " : ", TextJustification.MIDDLE_RIGHT); + new ControlText(contents, new Area(w2, y, w3, th), genome.getMaturationTime() + "x", TextJustification.MIDDLE_LEFT); y += th; - new ControlText(contents, new Area(0, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.GIRTH) + " : ", TextJustification.MiddleRight); - new ControlText(contents, new Area(w2, y, w3, th), genome.getGirth() + "x" + genome.getGirth(), TextJustification.MIDDLE_LEFTt); + new ControlText(contents, new Area(0, y, w2, th), syst.getChromosomeShortName(EnumTreeChromosome.GIRTH) + " : ", TextJustification.MIDDLE_RIGHT); + new ControlText(contents, new Area(w2, y, w3, th), genome.getGirth() + "x" + genome.getGirth(), TextJustification.MIDDLE_LEFT); y += th; contents.setSize(new Point(contents.size().x(), y)); scrollable.setScrollableContent(contents); diff --git a/src/main/java/binnie/extratrees/machines/craftgui/PageWood.java b/src/main/java/binnie/extratrees/machines/craftgui/PageWood.java index 0e26acf1..6486e7ae 100644 --- a/src/main/java/binnie/extratrees/machines/craftgui/PageWood.java +++ b/src/main/java/binnie/extratrees/machines/craftgui/PageWood.java @@ -30,7 +30,7 @@ public class PageWood extends PageAbstract { public void onValueChanged(final ItemStack species) { this.deleteAllChildren(); final WindowAbstractDatabase database = Window.get(this); - new ControlText(this, new Area(0, 0, this.size().x(), 24), this.getValue().toString(), TextJustification.MiddleCenter); + new ControlText(this, new Area(0, 0, this.size().x(), 24), this.getValue().toString(), TextJustification.MIDDLE_CENTER); final Collection trees = ((TreeBreedingSystem) database.getBreedingSystem()).getTreesThatHaveWood(species, database.isNEI(), database.getWorld(), database.getUsername()); new ControlSpeciesBox(this, 4, 24, this.size().x() - 8, this.size().y() - 4 - 24).setOptions(trees); } diff --git a/src/main/java/binnie/genetics/gui/AnalystPageDatabase.java b/src/main/java/binnie/genetics/gui/AnalystPageDatabase.java index e834250f..50aada3d 100644 --- a/src/main/java/binnie/genetics/gui/AnalystPageDatabase.java +++ b/src/main/java/binnie/genetics/gui/AnalystPageDatabase.java @@ -109,7 +109,7 @@ public class AnalystPageDatabase extends ControlAnalystPage { @Override @SideOnly(Side.CLIENT) public void onRenderBackground(int guiWidth, int guiHeight) { - RenderUtil.drawText(this.getArea(), TextJustification.MiddleCenter, this.value.getName(), 16777215); + RenderUtil.drawText(this.getArea(), TextJustification.MIDDLE_CENTER, this.value.getName(), 16777215); } }; } diff --git a/src/main/java/binnie/genetics/gui/AnalystPageDescription.java b/src/main/java/binnie/genetics/gui/AnalystPageDescription.java index 7a2cfed8..b53e1a08 100644 --- a/src/main/java/binnie/genetics/gui/AnalystPageDescription.java +++ b/src/main/java/binnie/genetics/gui/AnalystPageDescription.java @@ -65,7 +65,7 @@ public class AnalystPageDescription extends ControlAnalystPage { new ControlTextCentered(this, y, I18N.localise("genetics.gui.analyst.desc.complexity") + ": " + species.getComplexity()).setColour(this.getColour()); y += 26; final ControlText descText = new ControlText(this, new Area(8, y, this.width() - 16, 0), descBody + "§r", TextJustification.TOP_CENTER); - final IWidget signatureText = new ControlText(this, new Area(8, y, this.width() - 16, 0), descSig + "§r", TextJustification.BottomRight); + final IWidget signatureText = new ControlText(this, new Area(8, y, this.width() - 16, 0), descSig + "§r", TextJustification.BOTTOM_RIGHT); descText.setColour(this.getColour()); signatureText.setColour(this.getColour()); final int descHeight = CraftGUI.render.textHeight(descText.getValue(), descText.getSize().x()); diff --git a/src/main/java/binnie/genetics/gui/AnalystPageMutations.java b/src/main/java/binnie/genetics/gui/AnalystPageMutations.java index 1cf31de1..fb5c43ef 100644 --- a/src/main/java/binnie/genetics/gui/AnalystPageMutations.java +++ b/src/main/java/binnie/genetics/gui/AnalystPageMutations.java @@ -275,7 +275,7 @@ public class AnalystPageMutations extends ControlAnalystPage { @Override @SideOnly(Side.CLIENT) public void onRenderBackground(int guiWidth, int guiHeight) { - RenderUtil.drawText(this.getArea(), TextJustification.MiddleCenter, I18N.localise("genetics.gui.analyst.mutations.unknown"), 11184810); + RenderUtil.drawText(this.getArea(), TextJustification.MIDDLE_CENTER, I18N.localise("genetics.gui.analyst.mutations.unknown"), 11184810); } } } diff --git a/src/main/java/binnie/genetics/gui/ControlGenesisOption.java b/src/main/java/binnie/genetics/gui/ControlGenesisOption.java index 124cb4a7..d33fb741 100644 --- a/src/main/java/binnie/genetics/gui/ControlGenesisOption.java +++ b/src/main/java/binnie/genetics/gui/ControlGenesisOption.java @@ -27,8 +27,8 @@ public class ControlGenesisOption extends ControlOption { @SideOnly(Side.CLIENT) public void onRenderBackground(int guiWidth, int guiHeight) { super.onRenderBackground(guiWidth, guiHeight); - RenderUtil.drawText(new Area(0, 0, 70, 22), TextJustification.MiddleCenter, this.getChromosomeName(), this.getColour()); - RenderUtil.drawText(new Area(75, 0, 80, 22), TextJustification.MiddleCenter, this.getAlleleName(), this.getColour()); + RenderUtil.drawText(new Area(0, 0, 70, 22), TextJustification.MIDDLE_CENTER, this.getChromosomeName(), this.getColour()); + RenderUtil.drawText(new Area(75, 0, 80, 22), TextJustification.MIDDLE_CENTER, this.getAlleleName(), this.getColour()); RenderUtil.drawSolidRect(new Area(70, 2, 1, 16), -16777216 + this.getColour()); } } diff --git a/src/main/java/binnie/genetics/gui/flower/AnalystPageSoil.java b/src/main/java/binnie/genetics/gui/flower/AnalystPageSoil.java index 41738127..1661cb22 100644 --- a/src/main/java/binnie/genetics/gui/flower/AnalystPageSoil.java +++ b/src/main/java/binnie/genetics/gui/flower/AnalystPageSoil.java @@ -36,15 +36,15 @@ public class AnalystPageSoil extends ControlAnalystPage { int y = 4; new ControlTextCentered(this, y, TextFormatting.UNDERLINE + getTitle()).setColour(this.getColour()); y += 16; - new ControlText(this, new Area(4, y, this.width() - 8, 14), I18N.localise("genetics.gui.analyst.soil.tolerance.moisture"), TextJustification.MiddleCenter).setColour(this.getColour()); + new ControlText(this, new Area(4, y, this.width() - 8, 14), I18N.localise("genetics.gui.analyst.soil.tolerance.moisture"), TextJustification.MIDDLE_CENTER).setColour(this.getColour()); y += 12; this.createMoisture(this, (this.width() - 100) / 2, y, 100, 10, moisture, moistureTol); y += 16; - new ControlText(this, new Area(4, y, this.width() - 8, 14), I18N.localise("genetics.gui.analyst.soil.tolerance.ph"), TextJustification.MiddleCenter).setColour(this.getColour()); + new ControlText(this, new Area(4, y, this.width() - 8, 14), I18N.localise("genetics.gui.analyst.soil.tolerance.ph"), TextJustification.MIDDLE_CENTER).setColour(this.getColour()); y += 12; this.createAcidity(this, (this.width() - 100) / 2, y, 100, 10, pH, pHTol); y += 16; - new ControlText(this, new Area(4, y, this.width() - 8, 14), I18N.localise("genetics.gui.analyst.soil.recommended"), TextJustification.MiddleCenter).setColour(this.getColour()); + new ControlText(this, new Area(4, y, this.width() - 8, 14), I18N.localise("genetics.gui.analyst.soil.recommended"), TextJustification.MIDDLE_CENTER).setColour(this.getColour()); y += 12; EnumMoisture recomMoisture = EnumMoisture.NORMAL; final boolean canTolNormal = Tolerance.canTolerate(moisture, EnumMoisture.NORMAL, moistureTol); @@ -87,7 +87,7 @@ public class AnalystPageSoil extends ControlAnalystPage { recomSoil.setItemStack(stack); recomSoil.setTooltip(); y += 32; - new ControlText(this, new Area(4, y, this.width() - 8, 14), I18N.localise("genetics.gui.analyst.soil.other"), TextJustification.MiddleCenter).setColour(this.getColour()); + new ControlText(this, new Area(4, y, this.width() - 8, 14), I18N.localise("genetics.gui.analyst.soil.other"), TextJustification.MIDDLE_CENTER).setColour(this.getColour()); y += 12; final List stacks = new ArrayList<>(); for (final EnumAcidity a : EnumSet.range(EnumAcidity.ACID, EnumAcidity.ALKALINE)) { diff --git a/src/main/java/binnie/genetics/gui/tree/AnalystPageClimate.java b/src/main/java/binnie/genetics/gui/tree/AnalystPageClimate.java index 195d48c6..0ad818ce 100644 --- a/src/main/java/binnie/genetics/gui/tree/AnalystPageClimate.java +++ b/src/main/java/binnie/genetics/gui/tree/AnalystPageClimate.java @@ -54,17 +54,17 @@ public class AnalystPageClimate extends ControlAnalystPage { int y = 4; new ControlTextCentered(this, y, TextFormatting.UNDERLINE + getTitle()).setColour(this.getColour()); y += 16; - new ControlText(this, new Area(4, y, this.width() - 8, 14), I18N.localise("genetics.gui.analyst.climate.temp"), TextJustification.MiddleCenter).setColour(this.getColour()); + new ControlText(this, new Area(4, y, this.width() - 8, 14), I18N.localise("genetics.gui.analyst.climate.temp"), TextJustification.MIDDLE_CENTER).setColour(this.getColour()); y += 12; this.createTemperatureBar(this, (this.width() - 100) / 2, y, 100, 10, temp, tempTol); y += 16; if (!(ind instanceof IFlower)) { - new ControlText(this, new Area(4, y, this.width() - 8, 14), I18N.localise("genetics.gui.analyst.climate.hum"), TextJustification.MiddleCenter).setColour(this.getColour()); + new ControlText(this, new Area(4, y, this.width() - 8, 14), I18N.localise("genetics.gui.analyst.climate.hum"), TextJustification.MIDDLE_CENTER).setColour(this.getColour()); y += 12; this.createHumidity(this, (this.width() - 100) / 2, y, 100, 10, humid, humidTol); y += 16; } - new ControlText(this, new Area(4, y, this.width() - 8, 14), I18N.localise("genetics.gui.analyst.climate.biomes"), TextJustification.MiddleCenter).setColour(this.getColour()); + new ControlText(this, new Area(4, y, this.width() - 8, 14), I18N.localise("genetics.gui.analyst.climate.biomes"), TextJustification.MIDDLE_CENTER).setColour(this.getColour()); y += 12; final List biomes = new ArrayList<>(); for (final Biome biome : Biome.EXPLORATION_BIOMES_LIST) { //TODO check diff --git a/src/main/java/binnie/genetics/machine/inoculator/WindowInoculator.java b/src/main/java/binnie/genetics/machine/inoculator/WindowInoculator.java index 5295a470..f27fbe3f 100644 --- a/src/main/java/binnie/genetics/machine/inoculator/WindowInoculator.java +++ b/src/main/java/binnie/genetics/machine/inoculator/WindowInoculator.java @@ -53,7 +53,7 @@ public class WindowInoculator extends WindowMachine { new ControlEnergyBar(this, 91, 118, 60, 16, Position.LEFT); new ControlErrorState(this, 161, 118); x += 142; - CraftGUIUtil.verticalGrid(x, y, TextJustification.MIDDLE_LEFTt, 8, + CraftGUIUtil.verticalGrid(x, y, TextJustification.MIDDLE_LEFT, 8, new ControlSlotArray.Builder(this, x, y, 4, 1).create(Inoculator.SLOT_RESERVE), new ControlSlot.Builder(this, x, y + 18 + 8).assign(9), new ControlSlotArray.Builder(this, x, y + 18 + 8 + 18 + 8, 4, 1).create(Inoculator.SLOT_FINISHED) diff --git a/src/main/java/binnie/genetics/machine/sequencer/ControlSequencerProgress.java b/src/main/java/binnie/genetics/machine/sequencer/ControlSequencerProgress.java index ff43c317..a37a2647 100644 --- a/src/main/java/binnie/genetics/machine/sequencer/ControlSequencerProgress.java +++ b/src/main/java/binnie/genetics/machine/sequencer/ControlSequencerProgress.java @@ -25,7 +25,7 @@ public class ControlSequencerProgress extends ControlProgressBase { public ControlSequencerProgress(final IWidget parent, final int x, final int y) { super(parent, x, y, 100, 52); final Panel panel = new Panel(this, 0, 0, 100, 52, MinecraftGUI.PanelType.Gray); - this.textControl = new ControlText(panel, new Area(4, 4, 92, 44), "", TextJustification.MiddleCenter); + this.textControl = new ControlText(panel, new Area(4, 4, 92, 44), "", TextJustification.MIDDLE_CENTER); } @Override diff --git a/src/main/java/binnie/genetics/machine/sequencer/WindowSequencer.java b/src/main/java/binnie/genetics/machine/sequencer/WindowSequencer.java index 8a59be08..214d6e19 100644 --- a/src/main/java/binnie/genetics/machine/sequencer/WindowSequencer.java +++ b/src/main/java/binnie/genetics/machine/sequencer/WindowSequencer.java @@ -53,7 +53,7 @@ public class WindowSequencer extends WindowMachine { super.initialiseClient(); int x = 16; int y = 32; - CraftGUIUtil.horizontalGrid(x, y, TextJustification.MiddleCenter, 2, + CraftGUIUtil.horizontalGrid(x, y, TextJustification.MIDDLE_CENTER, 2, new ControlSlotArray.Builder(this, 0, 0, 2, 2).create(Sequencer.SLOT_RESERVE), new ControlIconDisplay(this, 0, 0, GUIIcon.ARROW_RIGHT.getIcon().getResourceLocation()), new ControlSequencerProgress(this, 0, 0), @@ -63,7 +63,7 @@ public class WindowSequencer extends WindowMachine { final ControlSlot slotTarget = new ControlSlot.Builder(this, x + 96, y + 16).assign(5); x = 34; y = 92; - this.slotText = new ControlText(this, new Area(0, y, this.width(), 12), TextFormatting.DARK_GRAY + I18N.localise("genetics.machine.machine.sequencer.texts.userless"), TextJustification.MiddleCenter); + this.slotText = new ControlText(this, new Area(0, y, this.width(), 12), TextFormatting.DARK_GRAY + I18N.localise("genetics.machine.machine.sequencer.texts.userless"), TextJustification.MIDDLE_CENTER); y += 20; final ControlSlot slotDye = new ControlSlot.Builder(this, x, y).assign(0); x += 20; diff --git a/src/main/java/binnie/genetics/machine/splicer/WindowSplicer.java b/src/main/java/binnie/genetics/machine/splicer/WindowSplicer.java index 6b202f6b..91702b58 100644 --- a/src/main/java/binnie/genetics/machine/splicer/WindowSplicer.java +++ b/src/main/java/binnie/genetics/machine/splicer/WindowSplicer.java @@ -49,7 +49,7 @@ public class WindowSplicer extends WindowMachine { new ControlEnergyBar(this, 196, 64, 60, 16, Position.LEFT); new ControlErrorState(this, 218, 86); x += 142; - CraftGUIUtil.verticalGrid((this.width() - 72) / 2, 32, TextJustification.MiddleCenter, 4, + CraftGUIUtil.verticalGrid((this.width() - 72) / 2, 32, TextJustification.MIDDLE_CENTER, 4, new ControlSlotArray.Builder(this, 0, 0, 4, 1).create(Inoculator.SLOT_RESERVE), new ControlIconDisplay(this, 0, 0, GUIIcon.ARROW_DOWN.getIcon().getResourceLocation()), new ControlSlot.Builder(this, 0, 0).assign(9), diff --git a/src/main/resources/assets/botany/lang/en_US.lang b/src/main/resources/assets/botany/lang/en_US.lang index 62f2bc67..82176757 100644 --- a/src/main/resources/assets/botany/lang/en_US.lang +++ b/src/main/resources/assets/botany/lang/en_US.lang @@ -37,6 +37,7 @@ botany.ceramic.type.verticalbrick.name=%s Vertical Ceramic Bricks botany.ceramic.type.verticalbrickstripe.name=%s Vertical Striped Ceramic Bricks botany.ceramic.type.verticalbricklarge.name=%s Large Vertical Ceramic Bricks +item.botany.soil_meter.name=Soil Meter item.botany.germling.name=Germling item.botany.pollen.name=Pollen item.botany.flower.corrupted.name=Corrupted Flower