Compare commits

..
110 Commits
Author SHA1 Message Date
mezz 6ad9c979d6 Refactor Binnie's mods into separate modules (#260) 2017-08-11 22:52:39 -07:00
Nedelosk cd82361a39 Clean Up ModuleManager and remove unused parameter 2017-08-09 23:44:26 +02:00
mezz a502020e47 Fix #253 Additional fixes for game crashes when you open GUI on some blocks 2017-08-08 22:31:00 -07:00
mezz a9a2db67f4 Remove some dead code that is not related to unfinished features 2017-08-08 22:30:59 -07:00
mezz 5b1250ce8a Use lambdas for event handlers 2017-08-08 22:30:59 -07:00
mezz 6668392bd7 Fix bug with ceramic brick in debug world 2017-08-08 22:30:58 -07:00
mezz d3a93abb25 Cleanup 2017-08-08 22:30:50 -07:00
Nedelosk 8a2f686264 Fix #254 Mod Modules are not disabled if the mod is disabled 2017-08-08 16:53:06 +02:00
Nedelosk 2eca542f87 Refactoring Extra Tree Modules 2017-08-08 16:10:35 +02:00
Nedelosk 4421d2ce44 Refactoring Extra Tree Modules 2017-08-08 15:20:44 +02:00
mezz 78b98f07db Fix #253 Game crashes when you open GUI on some blocks 2017-08-07 21:37:31 -07:00
Nedelosk ad20fa2ffc Fix #252 Server startup Crash 2017-08-07 16:56:17 +02:00
Nedelosk b18c195aa9 Refactoring Botany Modules and Fix #252 2017-08-07 16:53:13 +02:00
mezz e2a49158f3 Update to 1.12 2017-08-06 19:41:48 -07:00
Nedelosk 235dfca751 Improve Modules 2017-08-06 23:19:40 +02:00
Nedelosk cb81d0ead4 Fix #246 Gene Database Issue 2017-08-04 22:12:08 +02:00
Nedelosk 21728bcab1 Add CraftTweaker Support for Extra Trees Machines 2017-08-04 21:21:52 +02:00
Nedelosk dbdb5478c2 Clean Up Flowers 2017-08-04 13:10:34 +02:00
Nedelosk 46c5b95d82 Remove FieldsAreNonnullByDefault Annotation from the api 2017-08-03 23:19:53 +02:00
Nedelosk e6547caacc Create Distillery and Fruit Press Recipe Api 2017-08-03 21:10:23 +02:00
Nedelosk f7b1805e95 Create Lumbermill Recipe Api 2017-08-03 19:54:47 +02:00
Nedelosk 123b47f038 Create Brewery Recipe Api 2017-08-03 19:09:40 +02:00
Nedelosk c96ab68f19 Fix Refresh Packet 2017-08-03 14:48:54 +02:00
Nedelosk 35d6304a96 Clean Up Biology Page 2017-08-02 18:22:47 +02:00
Nedelosk 8f69af62f8 Clean Up Fence Model 2017-08-02 16:50:31 +02:00
Nedelosk d2b14b6320 Fix #236 Extra Bees config incorrectly located and clean up honey combs 2017-08-02 16:36:49 +02:00
Nedelosk 65431e73d4 Clean Up Flower 2017-08-02 15:42:10 +02:00
Nedelosk fa4a5b0a17 Clean Up Flower TileEntity 2017-08-02 03:37:05 +02:00
Nedelosk 714ba830d7 Fix Analyst Window 2017-08-02 03:13:41 +02:00
Nedelosk ed3cfe12a1 Clean Up Analyst Window 2017-08-02 03:05:45 +02:00
Nedelosk d2a9e62cb2 Clean Up Mutation Page 2017-08-02 02:41:39 +02:00
Nedelosk cbfb25647a Clean Up Bee Effects 2017-08-02 01:39:55 +02:00
Nedelosk 6587200dd3 Fix NPE 2017-08-01 23:59:46 +02:00
Nedelosk b488570a5f Fix some Refactoring Fails 2017-08-01 23:37:26 +02:00
Nedelosk 40a1c94a86 Clean Up more Widget Code 2017-08-01 22:40:43 +02:00
Nedelosk 79c303b12d Fix Extra Trees error code 2017-08-01 17:03:32 +02:00
Nedelosk 065d795622 Refactoring some Gui Classes 2017-08-01 16:57:04 +02:00
Nedelosk 2b54db9342 Fix tolerance allele 2017-08-01 15:11:06 +02:00
Nedelosk 8f8e497f58 Clean Genesis Class 2017-08-01 14:32:41 +02:00
Nedelosk 34fda5ddd1 Clean Up More Gui Classes 2017-08-01 14:18:10 +02:00
Nedelosk ab1a2eeb89 Clean Up Point Code 2017-08-01 12:16:01 +02:00
Nedelosk 5c40de2eba Rename Widget some Methods 2017-08-01 12:08:46 +02:00
Nedelosk b0503fe523 Rename Widget some Methods 2017-08-01 00:43:43 +02:00
Nedelosk 3e3c9c30a4 Start Clean Up Gui 2017-08-01 00:37:15 +02:00
Nedelosk 1b338efca9 Fix machine fx rendering and add item cloning 2017-07-31 23:42:16 +02:00
Nedelosk ddc9764a23 Fix item rendering 2017-07-31 21:54:39 +02:00
Nedelosk f23e28deaf Fix Field Kit Animation 2017-07-31 20:32:12 +02:00
Nedelosk afb9a62686 Fix #235 Field Kit GUI missing 2017-07-31 20:09:58 +02:00
Nedelosk 79a49341e9 Fix Error States on Server 2017-07-31 16:36:57 +02:00
Nedelosk 5a93a3d0a9 Fix Extra Trees Machine Localisation 2017-07-31 16:05:52 +02:00
Nedelosk 2afb3c52f3 Improve Extra Trees Machine Localisation 2017-07-31 16:01:07 +02:00
Nedelosk cbe86e814f Fix #160 Ceramic Brick Block Meta 2017-07-31 13:32:58 +02:00
Nedelosk c5f2368e1d Move Botany Gardening Items 2017-07-31 12:27:36 +02:00
Nedelosk 7e4e518d7b Localise Analyst Title and Description 2017-07-31 12:14:16 +02:00
Nedelosk 21aa0c43a6 Clean Up Gui 2017-07-31 12:09:50 +02:00
Nedelosk 724c3d1fbd Fix item wrong lang key 2017-07-31 10:45:34 +02:00
Nedelosk 6c3d7d3bb0 Fix item rendering 2017-07-31 01:37:04 +02:00
Nedelosk afb9460ff9 Clean Up 2017-07-31 01:28:14 +02:00
Nedelosk 687c440c69 Change IAllele.getName() to IAllele.getAlleleName() 2017-07-30 23:40:19 +02:00
Nedelosk 1b722df37a More localisation 2017-07-30 23:34:07 +02:00
Nedelosk dcdf4b1cac Clean Up and Move some classes 2017-07-30 22:31:16 +02:00
Nedelosk 705581b9ac Fix #210 Database missed description 2017-07-30 22:04:25 +02:00
Nedelosk 2a451bc72e Fix item slot rendering 2017-07-30 21:01:59 +02:00
Nedelosk faf2b88ed8 Fix some bugs 2017-07-30 20:25:33 +02:00
Nedelosk fcef87b3da Fix #234 Analyst Eating Items 2017-07-30 19:58:20 +02:00
Nedelosk fcbbd06c63 Fix Mod Support and Fix #208 Added Tech Reborn Support 2017-07-30 19:17:54 +02:00
Nedelosk 1b3b452900 Refactoring bee species 2017-07-30 16:23:27 +02:00
Alexander Kornilov 0726954433 Feature/lang Simplify en_GB and add missing keys (#220) 2017-07-29 15:09:54 -07:00
Nedelosk 6ff11f4eea Fix jenkins link 2017-07-29 23:57:33 +02:00
Nedelosk 03eaa2510c Update README.md 2017-07-29 23:55:03 +02:00
Nedelosk a3103bce5e Update README.md 2017-07-29 23:44:46 +02:00
Nedelosk a9030ef60b Update README.md 2017-07-29 23:37:27 +02:00
Nedelosk 4062adee6c Fix possible NPE 2017-07-29 23:23:25 +02:00
Nedelosk 2ca2cef6a2 Merge remote-tracking branch 'origin/master-MC1.11.2' into master-MC1.11.2 2017-07-29 23:21:17 +02:00
Nedelosk 95dca83465 Fix #232 2017-07-29 23:21:02 +02:00
mezz f977a29ad6 Fix mcmod.info 2017-07-29 12:25:23 -07:00
Nedelosk 68ed8a1511 Fix #229 Game Crash from looking at wood in JEI 2017-07-29 21:07:41 +02:00
Nedelosk c9d3001b47 Merge remote-tracking branch 'origin/master-MC1.11.2' into master-MC1.11.2 2017-07-29 21:01:07 +02:00
Nedelosk 75c875868a Fix #230 Crash when opening a diamond compartment 2017-07-29 21:00:50 +02:00
mezz c51a9273f9 Fix gradle 2017-07-28 22:38:29 -07:00
mezz 4edd2e9d5d Update mcmodinfo 2017-07-28 22:11:49 -07:00
mezz bc310023df Fix version number in filename 2017-07-28 21:48:22 -07:00
mezz 703e99e916 Bump version for first 1.11.2 release 2017-07-28 21:47:08 -07:00
mezz f73667c173 Fix grade git changelog 2017-07-28 21:38:27 -07:00
mezz 0101eae8f8 Make gradlew executable 2017-07-28 20:56:54 -07:00
mezz 5be32a2a3a Set up gradle for jenkins and auto-upload to curse 2017-07-28 20:49:07 -07:00
Alexander Kornilov 3ff4957a10 Feature/code improve (#221)
* Code improvement for genetics.api
Code improvement for genetics.core
Fix missed localization for info of Lab Stand
* Code improvement for genetics.genetics package
2017-07-16 18:08:38 -07:00
Alexander Kornilov 9e1ec59b86 Feature/refactoring (#211)
* Some code improve readability for botany.ceramic package
* Code improvement for botany.core package
* Code improvement for botany.craftgui package
* Fixed TextJustification from all code files
* Code improvement for botany.farm package
* Code improvement for botany.flower
* Code improvement for root botany package
Code improvement for botany.network package
Code improvement for botany.proxypackage
* Code improvement for botany.gargdening package
Added missed localization for Soil Meter
* Code improvement for botany.genetic package
* Code improvement for botany.items package
* Removed "// TODO fix deprecated" comment
* Reformatted code by Forestry format settings
* Reformat code with new format settings
2017-07-15 12:27:20 -07:00
Alexander Kornilov 0aa9853da2 Feature/refactoring (#207)
* Fixed deprecated I18n usage
* Code improve readability for botany.api package
* Fix naming of templateAsGenome method params
2017-07-14 22:48:11 -07:00
mezz 96fe27e834 Cleanup 2017-07-13 23:35:09 -07:00
mezz 934bb3b8f9 Fix #162 Crash when hovering over drinks with AppleSkin and AppleCore 2017-07-13 23:25:53 -07:00
mezz 83d9da7797 Update gradle and dependencies 2017-07-13 23:11:57 -07:00
Nedelosk 1e0d11b1ac Merge branch 'master-MC1.11.2' of https://github.com/ForestryMC/Binnie into master-MC1.11.2 2017-07-10 00:48:04 +02:00
Nedelosk 808b04c3b8 More localisation 2017-07-10 00:47:53 +02:00
marcin212 2425ae959e Fixed recipe for Apiarist Database 2017-07-08 14:36:12 +02:00
marcin212 3679551882 Fixed SOF when machine has full inventory 2017-07-08 14:35:30 +02:00
marcin212 83fd00cad5 Fixed brewery recipes 2017-07-07 13:41:45 +02:00
marcin212 f3d93b47b9 Fixed shitf-click stack overflow #180 2017-07-07 12:34:32 +02:00
marcin212 62fc457808 Fixed second NPE in machines 2017-07-06 20:00:37 +02:00
marcin212 2811aabc2e Fixed NPE in machines 2017-07-06 15:04:19 +02:00
marcin212 8573f087eb Fixed blue/black background in machines GUI 2017-07-06 15:03:55 +02:00
marcin212 d0215ce0aa Color changed to hex 2017-07-06 15:00:40 +02:00
Nedelosk b6d5901f07 Star to rework Machine localisation 2017-06-28 19:10:09 +02:00
Nedelosk 18f30c8c0d Fix Farm Circuit Dictionary localisation 2017-06-28 16:07:19 +02:00
Nedelosk cf8634546c Fix Botany Dictionary localisation 2017-06-27 18:25:04 +02:00
Nedelosk 864e5e0dfc Add Botany Dictionary localisation 2017-06-27 17:42:13 +02:00
Nedelosk 6df4570bca Improve ceramic localization 2017-06-27 16:56:02 +02:00
Nedelosk e0d23ada41 Change colour to color 2017-06-27 16:35:15 +02:00
Nedelosk b7b663640d Improve insulated tube and color localization 2017-06-27 16:33:41 +02:00
Nedelosk 9989eef753 Improve flower localization 2017-06-27 16:01:25 +02:00
5026 changed files with 30041 additions and 28988 deletions

No files matched your search

+6 -22
View File
@@ -1,28 +1,12 @@
# everything
/*
.gradle
# IntelliJ
/build
/run
/out
.idea
.idea/
*.iml
*.ipr
*.iws
classes/
# folders
!/gradle/wrapper
!/src
# files
!/.gitignore
!/LICENSE.txt
!/license-header.txt
!/README.md
!/gradle.properties
!/build.gradle
!/gradlew
!/gradlew.bat
.gradle/
classes/
build/
run/
out/
+40 -1
View File
@@ -1,4 +1,43 @@
## Binnie mods
[Binnie mods](https://minecraft.curseforge.com/projects/binnies-mods/files)
====================================
### What is it?
Binnie’s Mods is a suite of mods designed to expand the [Forestry](https://github.com/ForestryMC/ForestryMC) mod.
It both extends the bee and tree breeding aspect by adding many new species with varied products,
along with new features such as fully breedable flowers and genetic manipulation.
### Homepage
[Wiki](https://binnie.mods.wiki/wiki/Main_Page)
[Latest Builds for 1.11 / 1.11.2](http://jenkins.ic2.player.to/job/Binnie's%201.11.2/)
### Mods
[![](https://binnie.mods.wiki/w/images/binnie/9/91/Extra_Bees_Header.png)](https://binnie.mods.wiki/wiki/Extra_Bees)
Extra Bees expands upon the bee breeding of Forestry by adding 107 new bee species to forestry. These bees cover a large spectrum of different effects and products, giving you the ability to produce everything from dyes to rare metal dusts purely from bees. It also adds the Apiarist Database, a tool to keep track of discovered species, mutations and traits. There are also new alveary components which help improve and streamline bee production.
[![](https://binnie.mods.wiki/w/images/binnie/5/59/Extra_Trees_Header.png)](https://binnie.mods.wiki/wiki/Extra_Trees)
Extra Trees both increases the number of tree species and adds many new aesthetic uses. There are 96 new tree species, such as Banana, Brazil nut and Douglas-fir. This comes with many new fruits as well as 35 new wooden planks. Extra Trees allows these, as well as Forestry and vanilla planks, to be combined to give doors, gates and various designs of fences. The woodworker allows planks to be combined to give patterned tiles, allowing you to build beautiful wooden floors, and the same can be done with stained glass. A group of machines such as the brewery and distillery allow you to use the fruits you grow to make a variety of wines, ciders and spirits.
[![](https://binnie.mods.wiki/w/images/binnie/3/34/Botany_Header.png)](https://binnie.mods.wiki/wiki/Botany)
Botany adds an entirely new breeding system to Forestry: flowers. There are 46 different species that can be bred, including both vanilla flowers and new ones such as Fuschia and Lilies. The colour of the flowers can be transferred and selectively bred, meaning that each flower can be one of a possible 80 different colours. These new flowers can be bred manually in small gardens using a trowel and fertiliser, with careful care taken to maintain the desired pH or moisture, or grown on the large scale in Forestry farms.
[![](https://binnie.mods.wiki/w/images/binnie/4/4e/Genetics_Header.png)](https://binnie.mods.wiki/wiki/Genetics)
Genetics is for those who want to eschew conventional breeding, and want to enter the realm of genetic manipulation. Here, genes can be isolated, sequenced and then inoculated back into different species, making it easier to obtain the perfect genome. Bees, trees, butterflies and flowers can all be manipulated in this way. They can also be acclimatised to different environments to build tolerance to hostile climates.
[![](https://binnie.mods.wiki/w/images/binnie/d/d7/Binnie_Core_Header.png)](https://binnie.mods.wiki/wiki/Binnie_Core)
Binnie Core is a mod which contains a lot of the core functionality such as networking and GUI's for the other mods. The only in game features it currently contains are the Compartments
### Building
The master branch will always contain the latest released version with possibly some bug fixes for that version that will eventually be released.
New versions will be created in branched named like {mc_version}-{mod_version}
+10
View File
@@ -0,0 +1,10 @@
archivesBaseName = 'all-' + mcversion
dependencies {
compile project(":api")
compile project(":botany")
compile project(":core")
compile project(":extrabees")
compile project(":extratrees")
compile project(":genetics")
}
+1
View File
@@ -0,0 +1 @@
archivesBaseName = 'api-' + mcversion
@@ -1,6 +1,10 @@
package binnie.botany.api;
public class FlowerManager {
import binnie.botany.api.gardening.IGardeningManager;
import binnie.botany.api.genetics.IFlowerFactory;
import binnie.botany.api.genetics.IFlowerRoot;
public class BotanyAPI {
/**
* Convenient access to AlleleManager.alleleRegistry.getSpeciesRoot("rootFlowers")
*/
@@ -10,7 +14,7 @@ public class FlowerManager {
* Used to create new flowers.
*/
public static IFlowerFactory flowerFactory;
/**
* Used to manager soil.
*/
@@ -1,4 +1,4 @@
package binnie.botany.api;
package binnie.botany.api.gardening;
import javax.annotation.Nullable;
@@ -20,14 +20,24 @@ public enum EnumAcidity implements IStringSerializable {
@Override
public String getName() {
return this.name().toLowerCase();
return name().toLowerCase();
}
public String getLocalisedName(boolean withColor) {
String localisedName = I18n.translateToLocal("botany.ph." + getName());
if(withColor && color != null){
localisedName +=color;
if (withColor && color != null) {
localisedName = color + localisedName;
}
return localisedName;
}
public static EnumAcidity getFromValue(float rawAcidity) {
if(rawAcidity <= -1.0f){
return EnumAcidity.ACID;
}else if(rawAcidity >= 1.0f){
return EnumAcidity.ALKALINE;
}else{
return EnumAcidity.NEUTRAL;
}
}
}
@@ -0,0 +1,5 @@
package binnie.botany.api.gardening;
public enum EnumFertiliserType {
ACID, ALKALINE, NUTRIENT
}
@@ -1,9 +1,10 @@
package binnie.botany.api;
package binnie.botany.api.gardening;
import javax.annotation.Nullable;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.translation.I18n;
public enum EnumMoisture implements IStringSerializable {
@@ -25,9 +26,19 @@ public enum EnumMoisture implements IStringSerializable {
public String getLocalisedName(boolean withColor) {
String localisedName = I18n.translateToLocal("botany.moisture." + getName());
if(withColor && color != null){
localisedName +=color;
if (withColor && color != null) {
localisedName = color + localisedName + TextFormatting.GRAY;
}
return localisedName;
}
public static EnumMoisture getFromValue(float rawMoisture) {
if(rawMoisture <= -1.0f){
return EnumMoisture.DRY;
}else if(rawMoisture >= 1.0f){
return EnumMoisture.DAMP;
}else{
return EnumMoisture.NORMAL;
}
}
}
@@ -1,10 +1,10 @@
package binnie.botany.api;
package binnie.botany.api.gardening;
import javax.annotation.Nullable;
import java.util.Locale;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.translation.I18n;
public enum EnumSoilType implements IStringSerializable {
@@ -12,19 +12,18 @@ public enum EnumSoilType implements IStringSerializable {
LOAM(TextFormatting.GOLD),
FLOWERBED(TextFormatting.LIGHT_PURPLE);
@Nullable
final TextFormatting color;
private final TextFormatting color;
EnumSoilType(@Nullable TextFormatting color) {
EnumSoilType(TextFormatting color) {
this.color = color;
}
@Override
public String getName() {
return this.name().toLowerCase(Locale.ENGLISH);
return name().toLowerCase(Locale.ENGLISH);
}
public String getTranslated(boolean withColor) {
return (withColor && color != null ? color : "") + I18n.translateToLocal("botany.soil." + getName());
public String getTranslated() {
return color + I18n.translateToLocal("botany.soil." + getName());
}
}
@@ -1,4 +1,4 @@
package binnie.botany.api;
package binnie.botany.api.gardening;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -1,9 +1,12 @@
package binnie.botany.api;
package binnie.botany.api.gardening;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Map;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
@@ -11,58 +14,54 @@ import net.minecraft.world.World;
import forestry.api.core.EnumTemperature;
import binnie.botany.api.genetics.IFlower;
public interface IGardeningManager {
default boolean isSoil(final Block block) {
default boolean isSoil(Block block) {
return block instanceof IBlockSoil;
}
boolean isSoil(Item item);
boolean isSoil(ItemStack item);
EnumMoisture getNaturalMoisture(World world, BlockPos pos);
EnumAcidity getNaturalPH(World world, BlockPos pos);
float getBiomeMoisture(World world, BlockPos pos);
float getBiomePH(World world, BlockPos pos);
IBlockState getSoil(EnumSoilType soil, boolean weedKill, EnumMoisture moisture, EnumAcidity acidity);
void plantSoil(World world, BlockPos pos, EnumSoilType soil, EnumMoisture moisture, EnumAcidity acidity);
Collection<ItemStack> getAcidFertilisers();
Collection<ItemStack> getAlkalineFertilisers();
Collection<ItemStack> getNutrientFertilisers();
void registerAcidFertiliser(ItemStack stack, int strength);
void registerAlkalineFertiliser(ItemStack stack, int strength);
void registerNutrientFertiliser(ItemStack stack, int strength);
boolean isAcidFertiliser(ItemStack stack);
boolean isAlkalineFertiliser(ItemStack stack);
boolean isNutrientFertiliser(ItemStack stack);
Collection<ItemStack> getFertilisers(EnumFertiliserType type);
Map<EnumFertiliserType, Map<ItemStack, Integer>> getFertilisers();
void registerFertiliser(EnumFertiliserType type, ItemStack stack, int strength);
boolean isFertiliser(EnumFertiliserType type, ItemStack stack);
int getFertiliserStrength(ItemStack stack);
boolean canTolerate(@Nullable IFlower flower, World world, BlockPos pos);
EnumSoilType getSoilType(World world, BlockPos pos);
default Block getSoilBlock(EnumSoilType type) {
return getSoilBlock(type, false);
}
Block getSoilBlock(EnumSoilType type, boolean weedkill);
boolean canTolerate(IFlower flower, EnumAcidity ePH, EnumMoisture eMoisture, EnumTemperature eTemp);
Block getSoilBlock(EnumSoilType type, boolean weedKill);
boolean canTolerate(IFlower flower, EnumAcidity acidity, EnumMoisture moisture, EnumTemperature temperature);
boolean isWeedkiller(ItemStack heldItem);
boolean addWeedKiller(World world, BlockPos pos);
boolean onFertiliseSoil(ItemStack heldItem, IBlockSoil soil, World world, BlockPos pos, EntityPlayer player);
}
@@ -0,0 +1,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package binnie.botany.api.gardening;
import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@@ -1,14 +1,10 @@
package binnie.botany.genetics;
package binnie.botany.api.genetics;
import forestry.api.genetics.IAlleleInteger;
import net.minecraft.util.text.translation.I18n;
import binnie.botany.api.IFlowerColour;
import binnie.core.util.I18N;
/**
* Created by Marcin on 03.06.2017.
*/
public class FlowerColorAllele implements IFlowerColour, IAlleleInteger {
// TODO: move out of API
public class AlleleFlowerColor implements IAlleleFlowerColor {
private int color;
private String uid;
private boolean isDominant;
@@ -17,7 +13,7 @@ public class FlowerColorAllele implements IFlowerColour, IAlleleInteger {
private int colorDis;
private int id;
public FlowerColorAllele(String uid, int id, int color, int colorDis, String name, String unlocalizedName, boolean isDominant) {
public AlleleFlowerColor(String uid, int id, int color, int colorDis, String name, String unlocalizedName, boolean isDominant) {
this.color = color;
this.uid = uid;
this.isDominant = isDominant;
@@ -47,14 +43,19 @@ public class FlowerColorAllele implements IFlowerColour, IAlleleInteger {
return name;
}
@Override
public String getAlleleName() {
return name;
}
@Override
public String getUnlocalizedName() {
return unlocalizedName;
}
@Override
public int getColor(final boolean dis) {
return dis ? this.colorDis : this.color;
public int getColor(boolean dis) {
return dis ? colorDis : color;
}
@Override
@@ -68,7 +69,7 @@ public class FlowerColorAllele implements IFlowerColour, IAlleleInteger {
}
@Override
public String getColourName() {
return I18N.localise("botany.colour." + getName());
public String getColorName() {
return I18n.translateToLocal("botany.color." + getAlleleName());
}
}
@@ -0,0 +1,40 @@
package binnie.botany.api.genetics;
public final class ColorMix implements IColorMix {
private final IFlowerColor colorFirst;
private final IFlowerColor colorSecond;
private final IFlowerColor result;
private final int chance;
public ColorMix(IFlowerColor colorFirst, IFlowerColor colorSecond, IFlowerColor result, int chance) {
this.colorFirst = colorFirst;
this.colorSecond = colorSecond;
this.result = result;
this.chance = chance;
}
@Override
public IFlowerColor getColorFirst() {
return colorFirst;
}
@Override
public IFlowerColor getColorSecond() {
return colorSecond;
}
@Override
public boolean isMutation(IFlowerColor colorFirst, IFlowerColor colorSecond) {
return (colorFirst == this.colorFirst && colorSecond == this.colorSecond) || (colorFirst == this.colorSecond && colorSecond == this.colorFirst);
}
@Override
public int getChance() {
return chance;
}
@Override
public IFlowerColor getResult() {
return result;
}
}
@@ -1,4 +1,4 @@
package binnie.botany.api;
package binnie.botany.api.genetics;
import java.util.Locale;
@@ -27,18 +27,18 @@ public enum EnumFlowerChromosome implements IChromosomeType {
private Class<? extends IAllele> cls;
EnumFlowerChromosome(final Class<? extends IAllele> cls) {
EnumFlowerChromosome(Class<? extends IAllele> cls) {
this.cls = cls;
}
@Override
public Class<? extends IAllele> getAlleleClass() {
return this.cls;
return cls;
}
@Override
public String getName() {
return this.toString().toLowerCase(Locale.ENGLISH);
return toString().toLowerCase(Locale.ENGLISH);
}
@Override
File diff suppressed because it is too large. Load diff
@@ -1,4 +1,4 @@
package binnie.botany.api;
package binnie.botany.api.genetics;
import forestry.api.genetics.ISpeciesType;
@@ -10,7 +10,7 @@ public enum EnumFlowerStage implements ISpeciesType {
public static final EnumFlowerStage[] VALUES = values();
String name;
EnumFlowerStage(final String name) {
EnumFlowerStage(String name) {
this.name = name;
}
@@ -19,13 +19,11 @@ public enum EnumFlowerStage implements ISpeciesType {
}
public static EnumFlowerStage getStage(int age) {
return age == 0
? EnumFlowerStage.SEED
: EnumFlowerStage.FLOWER;
return age == 0 ? EnumFlowerStage.SEED : EnumFlowerStage.FLOWER;
}
public String getName() {
return this.name;
return name;
}
}
@@ -0,0 +1,6 @@
package binnie.botany.api.genetics;
import forestry.api.genetics.IAlleleInteger;
public interface IAlleleFlowerColor extends IFlowerColor, IAlleleInteger {
}
@@ -1,4 +1,4 @@
package binnie.botany.api;
package binnie.botany.api.genetics;
import net.minecraft.world.World;
@@ -6,5 +6,5 @@ import forestry.api.genetics.IAlleleEffect;
import forestry.api.genetics.IEffectData;
public interface IAlleleFlowerEffect extends IAlleleEffect {
IEffectData doEffect(final IFlowerGenome p0, final IEffectData p1, final World p2, final int p3, final int p4, final int p5);
IEffectData doEffect(IFlowerGenome genome, IEffectData effect, World world, int x, int y, int z);
}
@@ -1,4 +1,4 @@
package binnie.botany.api;
package binnie.botany.api.genetics;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
@@ -10,6 +10,9 @@ import forestry.api.core.IModelManager;
import forestry.api.genetics.IAlleleProperty;
import forestry.api.genetics.IAlleleSpecies;
import binnie.botany.api.gardening.EnumAcidity;
import binnie.botany.api.gardening.EnumMoisture;
public interface IAlleleFlowerSpecies extends IAlleleSpecies, IAlleleProperty<IAlleleFlowerSpecies> {
IFlowerType getType();
@@ -18,7 +21,7 @@ public interface IAlleleFlowerSpecies extends IAlleleSpecies, IAlleleProperty<IA
EnumMoisture getMoisture();
@SideOnly(Side.CLIENT)
int getFlowerColour(EnumFlowerStage type, int renderPass);
int getFlowerColor(EnumFlowerStage type, int renderPass);
@SideOnly(Side.CLIENT)
ModelResourceLocation getFlowerModel(EnumFlowerStage type, boolean flowered);
@@ -1,7 +1,10 @@
package binnie.botany.api;
package binnie.botany.api.genetics;
import forestry.api.genetics.IAlleleSpeciesBuilder;
import binnie.botany.api.gardening.EnumAcidity;
import binnie.botany.api.gardening.EnumMoisture;
public interface IAlleleFlowerSpeciesBuilder extends IAlleleSpeciesBuilder {
@Override
IAlleleFlowerSpecies build();
@@ -1,4 +1,4 @@
package binnie.botany.api;
package binnie.botany.api.genetics;
import forestry.api.genetics.IBreedingTracker;
@@ -0,0 +1,13 @@
package binnie.botany.api.genetics;
public interface IColorMix {
IFlowerColor getColorFirst();
IFlowerColor getColorSecond();
boolean isMutation(IFlowerColor colorFirst, IFlowerColor colorSecond);
int getChance();
IFlowerColor getResult();
}
@@ -0,0 +1,76 @@
package binnie.botany.api.genetics;
import javax.annotation.Nullable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import forestry.api.genetics.IIndividual;
public interface IFlower extends IIndividual {
/**
* @return Flowers's genetic information.
*/
@Override
IFlowerGenome getGenome();
/**
* @return Genetic information of the flower's mate, null if unmated.
*/
@Nullable
IFlowerGenome getMate();
/**
* Mate with the given flower.
*
* @param flower the {@link IFlower} to mate this one with.
*/
void mate(IFlower flower);
/**
* Remove the mate of the flower.
*/
void removeMate();
IFlower getOffspring(World world, BlockPos pos);
/**
* @return The current age of the flower.
*/
int getAge();
/**
* Set the current age of the flower.
*/
void setAge(int age);
/**
* Age the flower.
*/
void age();
/**
* @return Maximum age of the flower.
*/
int getMaxAge();
/**
* @return true if the flower is wilted.
*/
boolean isWilted();
/**
* Set that the flower is wilted.
*/
void setWilted(boolean wilted);
/**
* @return true if the flower has flowered.
*/
boolean hasFlowered();
/**
* Set that the flower has flowered.
*/
void setFlowered(boolean flowered);
}
@@ -0,0 +1,13 @@
package binnie.botany.api.genetics;
import forestry.api.genetics.IAlleleInteger;
public interface IFlowerColor {
int getColor(boolean dis);
IAlleleInteger getAllele();
int getID();
String getColorName();
}
@@ -1,4 +1,4 @@
package binnie.botany.api;
package binnie.botany.api.genetics;
import net.minecraft.item.ItemStack;
@@ -1,4 +1,4 @@
package binnie.botany.api;
package binnie.botany.api.genetics;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IClassification;
@@ -6,5 +6,5 @@ import forestry.api.genetics.IClassification;
public interface IFlowerFactory {
IAlleleFlowerSpeciesBuilder createSpecies(String uid, String unlocalizedName, String authority, String unlocalizedDescription, boolean isDominant, IClassification branch, String binomial, IFlowerType flowerType);
IFlowerMutationBuilder createMutation(IAlleleFlowerSpecies parentFlower0, IAlleleFlowerSpecies parentFlower1, IAllele[] result, int chance);
IFlowerMutationBuilder createMutation(IAlleleFlowerSpecies allele0, IAlleleFlowerSpecies allele1, IAllele[] result, int chance);
}
@@ -1,9 +1,12 @@
package binnie.botany.api;
package binnie.botany.api.genetics;
import forestry.api.core.EnumTemperature;
import forestry.api.genetics.EnumTolerance;
import forestry.api.genetics.IGenome;
import binnie.botany.api.gardening.EnumAcidity;
import binnie.botany.api.gardening.EnumMoisture;
public interface IFlowerGenome extends IGenome {
@Override
IAlleleFlowerSpecies getPrimary();
@@ -11,11 +14,11 @@ public interface IFlowerGenome extends IGenome {
@Override
IAlleleFlowerSpecies getSecondary();
IFlowerColour getPrimaryColor();
IFlowerColor getPrimaryColor();
IFlowerColour getSecondaryColor();
IFlowerColor getSecondaryColor();
IFlowerColour getStemColor();
IFlowerColor getStemColor();
int getFertility();
@@ -33,9 +36,9 @@ public interface IFlowerGenome extends IGenome {
float getSappiness();
boolean canTolerate(final EnumAcidity p0);
boolean canTolerate(EnumAcidity acidity);
boolean canTolerate(final EnumMoisture p0);
boolean canTolerate(EnumMoisture moisture);
boolean canTolerate(final EnumTemperature p0);
boolean canTolerate(EnumTemperature temperature);
}
@@ -1,4 +1,4 @@
package binnie.botany.api;
package binnie.botany.api.genetics;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -9,5 +9,5 @@ public interface IFlowerMutation extends IMutation {
@Override
IFlowerRoot getRoot();
float getChance(final World world, final BlockPos pos, final IAlleleFlowerSpecies p0, final IAlleleFlowerSpecies p1, final IFlowerGenome p2, final IFlowerGenome p3);
float getChance(World world, BlockPos pos, IAlleleFlowerSpecies allele0, IAlleleFlowerSpecies allele1, IFlowerGenome genome0, IFlowerGenome genome1);
}
@@ -1,4 +1,4 @@
package binnie.botany.api;
package binnie.botany.api.genetics;
import forestry.api.genetics.IMutationBuilder;
@@ -1,4 +1,4 @@
package binnie.botany.api;
package binnie.botany.api.genetics;
import javax.annotation.Nullable;
import java.util.Collection;
@@ -28,7 +28,7 @@ public interface IFlowerRoot extends ISpeciesRoot {
IFlowerGenome templateAsGenome(IAllele[] template);
@Override
IFlowerGenome templateAsGenome(IAllele[] templateFrist, IAllele[] templateSecond);
IFlowerGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive);
@Override
IBotanistTracker getBreedingTracker(World world, @Nullable GameProfile profile);
@@ -47,13 +47,13 @@ public interface IFlowerRoot extends ISpeciesRoot {
@Nullable
IFlower getConversion(ItemStack memberStack);
Collection<IColourMix> getColourMixes(boolean p0);
Collection<IColorMix> getColorMixes(boolean shuffle);
void registerColourMix(IColorMix colorMix);
void registerColourMix(IColourMix colourMix);
boolean plant(World world, BlockPos pos, IFlower flower, GameProfile owner);
void tryGrowSection(World world, BlockPos pos);
void onGrowFromSeed(World world, BlockPos pos);
}
@@ -1,4 +1,4 @@
package binnie.botany.api;
package binnie.botany.api.genetics;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
@@ -17,8 +17,6 @@ public interface IFlowerType<I extends IFlowerType<I>> extends Comparable<I> {
String getName();
int getID();
int getSections();
int ordinal();
@@ -0,0 +1,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package binnie.botany.api.genetics;
import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@@ -0,0 +1,10 @@
package binnie.core.api;
import java.util.Collection;
public interface IBinnieRecipe {
Collection<Object> getInputs();
Collection<Object> getOutputs();
}
@@ -0,0 +1,24 @@
package binnie.core.api;
import java.util.Collection;
public interface ICraftingManager<T extends IBinnieRecipe> {
/**
* Add a new recipe to the crafting provider.
*
* @return <tt>true</tt> if this collection changed as a result of the call
*/
boolean addRecipe(T recipe);
/**
* Remove a specific recipe from the crafting provider.
*
* @return <tt>true</tt> if an element was removed as a result of this call
*/
boolean removeRecipe(T recipe);
/**
* @return an unmodifiable collection of all recipes registered to the crafting provider.
*/
Collection<T> recipes();
}
@@ -1,4 +1,4 @@
package binnie.core.block;
package binnie.core.api.block;
import javax.annotation.Nullable;
import java.util.ArrayList;
@@ -18,11 +18,8 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import binnie.core.BinnieCore;
// TODO: move out of API
public class BlockMetadata extends BlockContainer implements IBlockMetadata {
static int temporyMeta = -1;
public BlockMetadata(final Material material) {
super(material);
}
@@ -36,13 +33,11 @@ public class BlockMetadata extends BlockContainer implements IBlockMetadata {
return ItemStack.EMPTY;
}
public static NonNullList<ItemStack> getBlockDroppedAsList(IBlockMetadata block, IBlockAccess world, BlockPos pos) {
public static void getDrops(NonNullList<ItemStack> drops, IBlockMetadata block, IBlockAccess world, BlockPos pos) {
ItemStack drop = getBlockDropped(block, world, pos);
NonNullList<ItemStack> list = NonNullList.create();
if (!drop.isEmpty()) {
list.add(drop);
drops.add(drop);
}
return list;
}
public static boolean breakBlock(IBlockMetadata blockMetadata, @Nullable EntityPlayer player, World world, BlockPos pos) {
@@ -53,7 +48,7 @@ public class BlockMetadata extends BlockContainer implements IBlockMetadata {
drops = block.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)) {
if (hasBeenBroken && !world.isRemote && drops.size() > 0 && (player == null || !player.capabilities.isCreativeMode)) {
for (ItemStack drop : drops) {
spawnAsEntity(world, pos, drop);
}
@@ -70,8 +65,8 @@ public class BlockMetadata extends BlockContainer implements IBlockMetadata {
}
@Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
return getBlockDroppedAsList(this, world, pos);
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
getDrops(drops, this, world, pos);
}
@Override
@@ -1,4 +1,4 @@
package binnie.core.block;
package binnie.core.api.block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.state.IBlockState;
@@ -7,6 +7,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
// TODO: move out of API
public interface IBlockMetadata extends ITileEntityProvider {
int getPlacedMeta(ItemStack itemStack, World world, BlockPos pos, EnumFacing facing);
@@ -1,4 +1,4 @@
package binnie.core.block;
package binnie.core.api.block;
import com.google.common.base.Preconditions;
@@ -15,6 +15,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
// TODO: move out of API
public class TileEntityMetadata extends TileEntity {
private int meta;
private boolean droppedBlock;
@@ -0,0 +1,148 @@
package binnie.core.api.genetics;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.List;
import java.util.TreeSet;
import com.mojang.authlib.GameProfile;
import forestry.api.core.ForestryEvent;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IBreedingTracker;
import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.IClassification;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IMutation;
import forestry.api.genetics.ISpeciesRoot;
import forestry.api.genetics.ISpeciesType;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public interface IBreedingSystem {
ISpeciesRoot getSpeciesRoot();
Collection<IAlleleSpecies> getAllSpecies();
Collection<IAlleleSpecies> getDiscoveredSpecies(World world, GameProfile player);
List<IClassification> getAllBranches();
Collection<IClassification> getDiscoveredBranches(World world, GameProfile player);
List<IMutation> getDiscoveredMutations(World world, GameProfile player);
List<IMutation> getResultantMutations(final IAlleleSpecies species);
List<IMutation> getFurtherMutations(final IAlleleSpecies species);
boolean isMutationDiscovered(IMutation mutation, World world, GameProfile name);
float getChance(IMutation mutation, EntityPlayer player, IAlleleSpecies firstSpecies, IAlleleSpecies secondSpecies);
String getAlleleName(final IChromosomeType chromosome, final IAllele allele);
String getChromosomeName(final IChromosomeType chromo);
String getChromosomeShortName(final IChromosomeType chromo);
@Nullable
IIndividual getConversion(final ItemStack stack);
ItemStack getConversionStack(final ItemStack stack);
@Nullable
IIndividual getIndividual(String uid);
void calculateArrays();
void addExtraAlleles(final IChromosomeType p0, final TreeSet<IAllele> p1);
String getDescriptor();
String getIdent();
ItemStack getItemStackRepresentitive();
int getColour();
int getDiscoveredSpeciesCount();
int getTotalSpeciesCount();
float getDiscoveredSpeciesPercentage();
int getTotalSecretCount();
int getDiscoveredSecretCount();
float getDiscoveredBranchPercentage();
int getTotalBranchCount();
int getDiscoveredBranchCount();
String getEpitome();
String getEpitome(float discoveredPercentage);
Collection<IMutation> getAllMutations();
void calculateAlleles(ISpeciesRoot speciesRoot);
void calculateBranches(ISpeciesRoot speciesRoot);
void calculateMutations(ISpeciesRoot speciesRoot);
boolean isBlacklisted(IAllele allele);
boolean isMutationDiscovered(IMutation mutation, IBreedingTracker tracker);
boolean isSpeciesDiscovered(IAlleleSpecies species, World world, GameProfile name);
boolean isSpeciesDiscovered(IAlleleSpecies species, IBreedingTracker tracker);
boolean isSecret(IAlleleSpecies species);
boolean isSecret(IClassification branch);
Collection<IClassification> getDiscoveredBranches(IBreedingTracker tracker);
Collection<IAlleleSpecies> getDiscoveredSpecies(IBreedingTracker tracker);
@SideOnly(Side.CLIENT)
TextureAtlasSprite getUndiscoveredIcon();
@SideOnly(Side.CLIENT)
TextureAtlasSprite getDiscoveredIcon();
Class<? extends IBreedingTracker> getTrackerClass();
@SubscribeEvent
void onSyncBreedingTracker(ForestryEvent.SyncedBreedingTracker event);
void syncTracker(IBreedingTracker tracker);
void onSyncBreedingTracker(IBreedingTracker tracker);
String getName();
boolean isDNAManipulable(ItemStack stack);
boolean isDNAManipulable(ISpeciesType type);
IIndividual getDefaultIndividual();
ISpeciesType getDefaultType();
ISpeciesType[] getActiveTypes();
Collection<IChromosomeType> getActiveKaryotype();
ItemStack getDefaultMember(String uid);
}
@@ -0,0 +1,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package binnie.core.api;
import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@@ -0,0 +1,7 @@
package binnie.extrabees.api;
import binnie.core.api.genetics.IBreedingSystem;
public class ExtraBeesAPI {
public static IBreedingSystem beeBreedingSystem;
}
@@ -19,15 +19,11 @@ public interface ICarpentryInterface {
IDesign getDesign(final int p0);
ILayout getLayout(final IPattern p0, final boolean p1);
@Nullable
IDesignMaterial getWoodMaterial(final ItemStack stack);
boolean registerDesignCategory(final IDesignCategory p0);
IDesignCategory getDesignCategory(final String p0);
Collection<IDesignCategory> getAllDesignCategories();
List<IDesign> getSortedDesigns();
@@ -17,4 +17,6 @@ public interface IPattern extends ISpriteRegister {
ILayout getRotation();
ILayout getHorizontalFlip();
int getIndex();
}
@@ -1,4 +1,4 @@
package binnie.extratrees.carpentry;
package binnie.extratrees.api.carpentry;
import java.util.ArrayList;
import java.util.Collection;
@@ -6,12 +6,12 @@ import java.util.List;
import binnie.extratrees.api.IDesignSystem;
public class DesignerManager {
public final class DesignerManager {
public static DesignerManager instance = new DesignerManager();
List<IDesignSystem> systems;
private final List<IDesignSystem> systems;
public DesignerManager() {
private DesignerManager() {
this.systems = new ArrayList<>();
}
@@ -23,7 +23,7 @@ public class DesignerManager {
return this.systems;
}
public void addDesignSystem(final DesignSystem system) {
public void addDesignSystem(final IDesignSystem system) {
this.systems.add(system);
}
}
@@ -1,4 +1,4 @@
package binnie.extratrees.carpentry;
package binnie.extratrees.api.carpentry;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
@@ -11,6 +11,7 @@ import binnie.extratrees.api.IDesignSystem;
import binnie.extratrees.api.ILayout;
import binnie.extratrees.api.IPattern;
// TODO: move out of API
public enum EnumPattern implements IPattern {
Blank,
Octagon,
@@ -391,6 +392,11 @@ public enum EnumPattern implements IPattern {
return this.horizontalFlip;
}
@Override
public int getIndex() {
return ordinal();
}
protected void setLeftRotation(final EnumPattern pattern, final boolean inverted) {
this.leftRotation = Layout.get(pattern, inverted);
}
@@ -0,0 +1,7 @@
package binnie.extratrees.api.carpentry;
import binnie.extratrees.api.IDesignSystem;
public interface IBlockDesign {
IDesignSystem getDesignSystem();
}
@@ -0,0 +1,4 @@
package binnie.extratrees.api.carpentry;
public interface IBlockDesignProperties {
}
@@ -1,4 +1,4 @@
package binnie.extratrees.carpentry;
package binnie.extratrees.api.carpentry;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
@@ -18,10 +18,6 @@ public class Layout implements ILayout {
this.inverted = inverted;
}
private Layout(final IPattern pattern) {
this(pattern, false);
}
public static ILayout get(final IPattern pattern, final boolean inverted) {
return new Layout(pattern, inverted);
}
@@ -0,0 +1,15 @@
package binnie.extratrees.api.recipes;
import javax.annotation.Nullable;
public class ExtraTreesRecipeManager {
@Nullable
public static IBreweryManager breweryManager;
@Nullable
public static ILumbermillManager lumbermillManager;
@Nullable
public static IFruitPressManager fruitPressManager;
@Nullable
public static IDistilleryManager distilleryManager;
}
@@ -0,0 +1,22 @@
package binnie.extratrees.api.recipes;
import javax.annotation.Nullable;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
public interface IBreweryCrafting {
@Nullable
FluidStack getInputFluid();
@Nullable
ItemStack[] getInputGrains();
ItemStack getIngredient();
ItemStack getYeast();
boolean hasInputGrainsEmpty();
}
@@ -0,0 +1,22 @@
package binnie.extratrees.api.recipes;
import javax.annotation.Nullable;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import binnie.core.api.ICraftingManager;
public interface IBreweryManager extends ICraftingManager<IBreweryRecipe> {
void addRecipe(FluidStack input, FluidStack output);
void addRecipe(FluidStack input, FluidStack output, ItemStack yeast);
void addGrainRecipe(String grainOreName, FluidStack output);
void addGrainRecipe(String grainOreName, FluidStack output, String ingredientOreName);
void addGrainRecipe(String grainOreName, FluidStack output, @Nullable String ingredientOreName, ItemStack yeast);
}
@@ -1,4 +1,4 @@
package binnie.extratrees.machines.brewery;
package binnie.extratrees.api.recipes;
import javax.annotation.Nullable;
import java.util.List;
@@ -7,15 +7,17 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
public interface IBreweryRecipe {
import binnie.core.api.IBinnieRecipe;
public interface IBreweryRecipe extends IBinnieRecipe {
@Nullable
FluidStack getOutput(final BreweryCrafting crafting);
FluidStack getOutput(IBreweryCrafting crafting);
FluidStack getInput();
FluidStack getOutput();
boolean isIngredient(ItemStack itemstack);
boolean isIngredient(ItemStack itemStack);
List<ItemStack> getIngredients();
@@ -0,0 +1,14 @@
package binnie.extratrees.api.recipes;
import java.util.Collection;
import net.minecraftforge.fluids.FluidStack;
import binnie.core.api.ICraftingManager;
public interface IDistilleryManager extends ICraftingManager<IDistilleryRecipe> {
void addRecipe(FluidStack input, FluidStack output, int level);
Collection<IDistilleryRecipe> recipes(int level);
}
@@ -0,0 +1,14 @@
package binnie.extratrees.api.recipes;
import net.minecraftforge.fluids.FluidStack;
import binnie.core.api.IBinnieRecipe;
public interface IDistilleryRecipe extends IBinnieRecipe {
FluidStack getInput();
FluidStack getOutput();
int getLevel();
}
@@ -0,0 +1,12 @@
package binnie.extratrees.api.recipes;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import binnie.core.api.ICraftingManager;
public interface IFruitPressManager extends ICraftingManager<IFruitPressRecipe> {
void addRecipe(ItemStack input, FluidStack output);
}
@@ -0,0 +1,14 @@
package binnie.extratrees.api.recipes;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import binnie.core.api.IBinnieRecipe;
public interface IFruitPressRecipe extends IBinnieRecipe {
ItemStack getInput();
FluidStack getOutput();
}
@@ -0,0 +1,10 @@
package binnie.extratrees.api.recipes;
import net.minecraft.item.ItemStack;
import binnie.core.api.ICraftingManager;
public interface ILumbermillManager extends ICraftingManager<ILumbermillRecipe> {
void addRecipe(ItemStack input, ItemStack output);
}
@@ -0,0 +1,12 @@
package binnie.extratrees.api.recipes;
import net.minecraft.item.ItemStack;
import binnie.core.api.IBinnieRecipe;
public interface ILumbermillRecipe extends IBinnieRecipe {
ItemStack getOutput();
ItemStack getInput();
}
@@ -0,0 +1,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package binnie.extratrees.api.recipes;
import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@@ -0,0 +1,12 @@
package binnie.genetics.api;
import net.minecraft.item.ItemStack;
public interface IItemAnalysable {
boolean isAnalysed(ItemStack stack);
ItemStack analyse(ItemStack stack);
@Deprecated
float getAnalyseTimeMult(ItemStack stack);
}
@@ -7,10 +7,10 @@ import net.minecraft.item.ItemStack;
import forestry.api.genetics.ISpeciesRoot;
public interface IItemChargeable {
int getCharges(ItemStack itemStack);
int getCharges(ItemStack stack);
int getMaxCharges(ItemStack itemStack);
int getMaxCharges(ItemStack stack);
@Nullable
ISpeciesRoot getSpeciesRoot(ItemStack itemStack);
ISpeciesRoot getSpeciesRoot(ItemStack stack);
}
@@ -5,10 +5,10 @@ import javax.annotation.Nullable;
import net.minecraft.item.ItemStack;
public interface IItemSerum extends IItemChargeable {
IGene[] getGenes(final ItemStack p0);
IGene[] getGenes(ItemStack stack);
@Nullable
IGene getGene(final ItemStack p0, final int p1);
IGene getGene(ItemStack stack, int chromosome);
ItemStack addGene(final ItemStack p0, final IGene p1);
ItemStack addGene(ItemStack stack, IGene gene);
}
@@ -0,0 +1,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package binnie.genetics.api;
import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
+9
View File
@@ -0,0 +1,9 @@
archivesBaseName = 'botany-' + mcversion
dependencies {
compile project(":api")
compile project(":core")
// TODO: remove
compile project(":extratrees")
}
@@ -0,0 +1,105 @@
package binnie.botany;
import binnie.botany.genetics.FlowerBreedingSystem;
import binnie.core.Binnie;
import binnie.core.api.genetics.IBreedingSystem;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import binnie.core.Constants;
import binnie.botany.gui.BotanyGUI;
import binnie.botany.network.PacketID;
import binnie.botany.proxy.Proxy;
import binnie.core.BinnieCore;
import binnie.core.gui.IBinnieGUID;
import binnie.core.network.BinniePacketHandler;
import binnie.core.network.IPacketID;
import binnie.core.proxy.IProxyCore;
import binnie.core.modules.BlankModuleContainer;
@Mod(
modid = Constants.BOTANY_MOD_ID,
name = "Binnie's Botany",
dependencies = "required-after:" + Constants.CORE_MOD_ID
)
public class Botany extends BlankModuleContainer {
public static final float AGE_CHANCE = 0.2f;
@SuppressWarnings("NullableProblems")
@Mod.Instance(Constants.BOTANY_MOD_ID)
public static Botany instance;
@SuppressWarnings("NullableProblems")
@SidedProxy(clientSide = "binnie.botany.proxy.ProxyClient", serverSide = "binnie.botany.proxy.ProxyServer")
public static Proxy proxy;
public static IBreedingSystem flowerBreedingSystem;
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent evt) {
super.preInit(evt);
flowerBreedingSystem = new FlowerBreedingSystem();
Binnie.GENETICS.registerBreedingSystem(flowerBreedingSystem);
}
@Mod.EventHandler
public void init(FMLInitializationEvent evt) {
super.init(evt);
}
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent evt) {
super.postInit(evt);
}
@Override
protected void registerModules() {
}
@Override
public IBinnieGUID[] getGUIDs() {
return BotanyGUI.values();
}
@Override
public Class<?>[] getConfigs() {
return new Class[0];
}
@Override
public IPacketID[] getPacketIDs() {
return PacketID.values();
}
@Override
public IProxyCore getProxy() {
return Botany.proxy;
}
@Override
public String getChannel() {
return "BOT";
}
@Override
public String getModID() {
return Constants.BOTANY_MOD_ID;
}
@Override
protected Class<? extends BinniePacketHandler> getPacketHandler() {
return PacketHandler.class;
}
@Override
public boolean isAvailable() {
return BinnieCore.isBotanyActive();
}
public static class PacketHandler extends BinniePacketHandler {
public PacketHandler() {
super(Botany.instance);
}
}
}
@@ -16,15 +16,10 @@ public class CreativeTabBotany extends CreativeTabs {
super("Botany");
}
@Override
public ItemStack getIconItemStack() {
return new ItemStack(Blocks.RED_FLOWER, 1, 5);
}
@Override
@SideOnly(Side.CLIENT)
public String getTranslatedTabLabel() {
return this.getTabLabel();
return getTabLabel();
}
@Override
@@ -36,6 +31,6 @@ public class CreativeTabBotany extends CreativeTabs {
@Override
@SideOnly(Side.CLIENT)
public ItemStack getTabIconItem() {
return new ItemStack(Blocks.YELLOW_FLOWER);
return new ItemStack(Blocks.RED_FLOWER, 1, 5);
}
}
@@ -0,0 +1,274 @@
package binnie.botany;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import forestry.api.climate.IClimateInfo;
import forestry.api.core.EnumTemperature;
import forestry.api.core.ForestryAPI;
import binnie.botany.api.gardening.EnumAcidity;
import binnie.botany.api.gardening.EnumFertiliserType;
import binnie.botany.api.gardening.EnumMoisture;
import binnie.botany.api.gardening.EnumSoilType;
import binnie.botany.api.gardening.IBlockSoil;
import binnie.botany.api.gardening.IGardeningManager;
import binnie.botany.api.genetics.IFlower;
import binnie.botany.api.genetics.IFlowerGenome;
import binnie.botany.blocks.BlockPlant;
import binnie.botany.blocks.BlockSoil;
import binnie.botany.modules.ModuleGardening;
import binnie.core.util.OreDictionaryUtil;
public class GardeningManager implements IGardeningManager {
private final Map<EnumFertiliserType, Map<ItemStack, Integer>> fertilisers = new LinkedHashMap<>();
public GardeningManager() {
for(EnumFertiliserType type : EnumFertiliserType.values()){
fertilisers.put(type, new LinkedHashMap<>());
}
}
@Override
public boolean isSoil(Block block) {
return block instanceof IBlockSoil;
}
@Override
public boolean isSoil(Item item) {
return item instanceof ItemBlock && isSoil(((ItemBlock) item).getBlock());
}
@Override
public boolean isSoil(ItemStack item) {
return isSoil(item.getItem());
}
@Override
public EnumMoisture getNaturalMoisture(World world, BlockPos pos) {
float moisture = getBiomeMoisture(world, pos);
for (int offsetX = -1; offsetX < 2; ++offsetX) {
for (int offsetY = -1; offsetY < 2; ++offsetY) {
if (offsetX != 0 || offsetY != 0) {
Block block = world.getBlockState(pos.add(offsetX, 0, offsetY)).getBlock();
if (block == Blocks.SAND) {
moisture -= 1.5;
} else if (block == Blocks.WATER) {
moisture += 1.5;
}
}
}
}
if (world.isRainingAt(pos.up())) {
moisture += 1.5;
}
for (int offsetX = -1; offsetX < 2; ++offsetX) {
for (int offsetY = -1; offsetY < 2; ++offsetY) {
if (offsetX != 0 || offsetY != 0) {
Block block = world.getBlockState(pos.add(offsetX, 0, offsetY)).getBlock();
if (block == Blocks.GRAVEL && moisture > 0.0f) {
moisture *= 0.4f;
}
}
}
}
return EnumMoisture.getFromValue(moisture);
}
@Override
public EnumAcidity getNaturalPH(World world, BlockPos pos) {
float acidity = getBiomePH(world, pos);
return EnumAcidity.getFromValue(acidity);
}
@Override
public float getBiomeMoisture(World world, BlockPos pos) {
IClimateInfo info = ForestryAPI.climateManager.getInfo(world, pos);
double humidity = info.getHumidity();
double temperature = info.getTemperature();
double moisture = 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) ((moisture == 0.0) ? moisture : ((moisture < 0.0) ? (-Math.sqrt(moisture * moisture)) : Math.sqrt(moisture * moisture)));
}
@Override
public float getBiomePH(World world, BlockPos pos) {
IClimateInfo info = ForestryAPI.climateManager.getInfo(world, pos);
double humidity = info.getHumidity();
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 IBlockState getSoil(EnumSoilType soil, boolean weedKill, EnumMoisture moisture, EnumAcidity acidity) {
IBlockState blockState = getSoilBlock(soil, weedKill).getDefaultState();
return blockState.withProperty(BlockSoil.MOISTURE, moisture).withProperty(BlockSoil.ACIDITY, acidity);
}
@Override
public void plantSoil(World world, BlockPos pos, EnumSoilType soil, EnumMoisture moisture, EnumAcidity acidity) {
IBlockState blockState = getSoil(soil, false, moisture, acidity);
world.setBlockState(pos, blockState, 2);
}
public Map<EnumFertiliserType, Map<ItemStack, Integer>> getFertilisers() {
return fertilisers;
}
@Override
public Collection<ItemStack> getFertilisers(EnumFertiliserType type) {
Set<ItemStack> items = fertilisers.get(type).keySet();
return Collections.unmodifiableSet(items);
}
@Override
public boolean isFertiliser(EnumFertiliserType type, ItemStack stack) {
Collection<ItemStack> fertilisers = getFertilisers(type);
for (ItemStack fertiliser : fertilisers) {
if (!fertiliser.isEmpty() && fertiliser.isItemEqual(stack)) {
return true;
}
}
return false;
}
@Override
public void registerFertiliser(EnumFertiliserType type, ItemStack stack, int strength) {
fertilisers.get(type).put(stack, strength);
}
@Override
public int getFertiliserStrength(ItemStack stack) {
for(EnumFertiliserType type : EnumFertiliserType.values()) {
for (Map.Entry<ItemStack, Integer> entry : fertilisers.get(type).entrySet()) {
if (entry.getKey().isItemEqual(stack)) {
return entry.getValue();
}
}
}
return 1;
}
@Override
public boolean onFertiliseSoil(ItemStack heldItem, IBlockSoil soil, World world, BlockPos pos, EntityPlayer player) {
int fertiliserStrength = getFertiliserStrength(heldItem);
if (isFertiliser(EnumFertiliserType.NUTRIENT, heldItem) && soil.getType(world, pos) != EnumSoilType.FLOWERBED) {
EnumSoilType type = soil.getType(world, pos);
int next = Math.min(type.ordinal() + fertiliserStrength, 2);
if (soil.fertilise(world, pos, EnumSoilType.values()[next])) {
if(!player.capabilities.isCreativeMode) {
heldItem.shrink(1);
}
return true;
}
}
if (isFertiliser(EnumFertiliserType.ACID, heldItem) && soil.getPH(world, pos) != EnumAcidity.ACID) {
EnumAcidity pH = soil.getPH(world, pos);
int next = Math.max(pH.ordinal() - fertiliserStrength, 0);
if (soil.setPH(world, pos, EnumAcidity.values()[next])) {
if(!player.capabilities.isCreativeMode) {
heldItem.shrink(1);
}
return true;
}
}
if (isFertiliser(EnumFertiliserType.ALKALINE, heldItem) && soil.getPH(world, pos) != EnumAcidity.ALKALINE) {
EnumAcidity pH = soil.getPH(world, pos);
int next = Math.min(pH.ordinal() + fertiliserStrength, 2);
if (soil.setPH(world, pos, EnumAcidity.values()[next])) {
if(!player.capabilities.isCreativeMode) {
heldItem.shrink(1);
}
return true;
}
}
return false;
}
@Override
public boolean canTolerate(@Nullable IFlower flower, World world, BlockPos pos) {
if (flower == null) {
return false;
}
IBlockState soil = world.getBlockState(pos.down());
Biome biome = world.getBiome(pos);
EnumAcidity acidity = soil.getValue(BlockSoil.ACIDITY);
EnumMoisture moisture = soil.getValue(BlockSoil.MOISTURE);
EnumTemperature temperature = EnumTemperature.getFromValue(biome.getTemperature());
return canTolerate(flower, acidity, moisture, temperature);
}
@Override
public EnumSoilType getSoilType(World world, BlockPos pos) {
IBlockState blockState = world.getBlockState(pos);
if (blockState.getBlock() instanceof IBlockSoil) {
IBlockSoil soil = ((IBlockSoil) blockState.getBlock());
return soil.getType(world, pos);
}
return EnumSoilType.SOIL;
}
@Override
public Block getSoilBlock(EnumSoilType type) {
return getSoilBlock(type, false);
}
@Override
public Block getSoilBlock(EnumSoilType type, boolean weedKill) {
switch (type) {
case FLOWERBED:
return weedKill ? ModuleGardening.flowerbedNoWeed : ModuleGardening.flowerbed;
case LOAM:
return weedKill ? ModuleGardening.loamNoWeed : ModuleGardening.loam;
default:
return weedKill ? ModuleGardening.soilNoWeed : ModuleGardening.soil;
}
}
@Override
public boolean canTolerate(IFlower flower, EnumAcidity acidity, EnumMoisture moisture, EnumTemperature temperature) {
IFlowerGenome genome = flower.getGenome();
return genome.canTolerate(acidity) && genome.canTolerate(moisture) && genome.canTolerate(temperature);
}
@Override
public boolean isWeedkiller(ItemStack heldItem) {
return OreDictionaryUtil.hasOreName(heldItem, "weedkiller");
}
@Override
public boolean addWeedKiller(World world, BlockPos pos) {
IBlockState oldState = world.getBlockState(pos);
if (!(oldState.getBlock() instanceof IBlockSoil)) {
return false;
}
EnumSoilType type = getSoilType(world, pos);
IBlockState newState = getSoil(type, true, oldState.getValue(BlockSoil.MOISTURE), oldState.getValue(BlockSoil.ACIDITY));
boolean done = world.setBlockState(pos, newState, 2);
if (done && BlockPlant.isWeed(world, pos.up())) {
world.setBlockToAir(pos.up());
}
return done;
}
}
@@ -1,4 +1,4 @@
package binnie.botany.ceramic;
package binnie.botany.blocks;
import javax.annotation.Nullable;
import java.util.ArrayList;
@@ -28,30 +28,30 @@ import forestry.api.core.IModelManager;
import forestry.core.blocks.IColoredBlock;
import binnie.botany.CreativeTabBotany;
import binnie.botany.genetics.EnumFlowerColor;
import binnie.core.BinnieCore;
import binnie.botany.api.genetics.EnumFlowerColor;
import binnie.botany.tile.TileCeramic;
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());
}
}
@Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
return Collections.emptyList();
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
}
@Override
@@ -62,7 +62,7 @@ public class BlockCeramic extends Block implements IColoredBlock, IItemModelRegi
drops = Collections.singletonList(ceramic.getStack());
}
boolean hasBeenBroken = world.setBlockToAir(pos);
if (hasBeenBroken && BinnieCore.getBinnieProxy().isSimulating(world) && drops.size() > 0 && (player == null || !player.capabilities.isCreativeMode)) {
if (hasBeenBroken && !world.isRemote && drops.size() > 0 && (player == null || !player.capabilities.isCreativeMode)) {
for (ItemStack drop : drops) {
spawnAsEntity(world, pos, drop);
}
@@ -89,10 +89,9 @@ public class BlockCeramic extends Block implements IColoredBlock, IItemModelRegi
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(final Item item, final CreativeTabs tab, final NonNullList<ItemStack> itemList) {
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> itemList) {
for (EnumFlowerColor c : EnumFlowerColor.values()) {
itemList.add(new ItemStack(item, 1, c.getFlowerColorAllele().getID()));
itemList.add(new ItemStack(this, 1, c.getFlowerColorAllele().getID()));
}
}
@@ -1,4 +1,4 @@
package binnie.botany.ceramic.brick;
package binnie.botany.blocks;
import javax.annotation.Nullable;
import java.util.ArrayList;
@@ -50,11 +50,13 @@ import forestry.core.blocks.properties.UnlistedBlockAccess;
import forestry.core.blocks.properties.UnlistedBlockPos;
import forestry.core.models.BlockModelEntry;
import binnie.Constants;
import binnie.core.Constants;
import binnie.botany.CreativeTabBotany;
import binnie.botany.ceramic.TileCeramic;
import binnie.botany.genetics.EnumFlowerColor;
import binnie.core.BinnieCore;
import binnie.botany.ceramic.brick.CeramicBrickPair;
import binnie.botany.ceramic.brick.CeramicBrickType;
import binnie.botany.api.genetics.EnumFlowerColor;
import binnie.botany.tile.TileCeramic;
import binnie.botany.tile.TileCeramicBrick;
import binnie.core.block.IMultipassBlock;
import binnie.core.models.DefaultStateMapper;
import binnie.core.models.ModelManager;
@@ -66,15 +68,15 @@ public class BlockCeramicBrick extends Block implements IMultipassBlock<CeramicB
public BlockCeramicBrick() {
super(Material.ROCK);
this.setHardness(1.0f);
this.setResistance(5.0f);
this.setRegistryName("ceramicBrick");
this.setCreativeTab(CreativeTabBotany.instance);
setHardness(1.0f);
setResistance(5.0f);
setRegistryName("ceramicBrick");
setCreativeTab(CreativeTabBotany.instance);
}
@Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
return Collections.emptyList();
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
}
@Override
@@ -85,7 +87,7 @@ public class BlockCeramicBrick extends Block implements IMultipassBlock<CeramicB
drops = Collections.singletonList(ceramic.getStack());
}
boolean hasBeenBroken = world.setBlockToAir(pos);
if (hasBeenBroken && BinnieCore.getBinnieProxy().isSimulating(world) && drops.size() > 0 && (player == null || !player.capabilities.isCreativeMode)) {
if (hasBeenBroken && !world.isRemote && drops.size() > 0 && (player == null || !player.capabilities.isCreativeMode)) {
for (ItemStack drop : drops) {
spawnAsEntity(world, pos, drop);
}
@@ -103,20 +105,19 @@ public class BlockCeramicBrick extends Block implements IMultipassBlock<CeramicB
return true;
}
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(Item item, final CreativeTabs tab, final NonNullList<ItemStack> itemList) {
for (final EnumFlowerColor color : EnumFlowerColor.values()) {
itemList.add(new CeramicBrickPair(color, color, CeramicBrickType.Tile).getStack(1));
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> 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 +126,10 @@ public class BlockCeramicBrick extends Block implements IMultipassBlock<CeramicB
ResourceLocation resourceLocation = new ResourceLocation(Constants.BOTANY_MOD_ID, "ceramicBrick");
ModelLoader.setCustomStateMapper(this, new DefaultStateMapper(resourceLocation));
ModelManager.registerCustomBlockModel(new BlockModelEntry(
new ModelResourceLocation(resourceLocation, "normal"),
new ModelResourceLocation(resourceLocation, "inventory"),
new ModelMutlipass<>(BlockCeramicBrick.class), this
new ModelResourceLocation(resourceLocation, "normal"),
new ModelResourceLocation(resourceLocation, "inventory"),
new ModelMutlipass<>(BlockCeramicBrick.class),
this
));
}
@@ -139,7 +141,14 @@ public class BlockCeramicBrick extends Block implements IMultipassBlock<CeramicB
@Override
protected BlockStateContainer createBlockState() {
return new ExtendedBlockState(this, new IProperty[]{TYPE}, new IUnlistedProperty[]{UnlistedBlockPos.POS, UnlistedBlockAccess.BLOCKACCESS});
return new ExtendedBlockState(
this,
new IProperty[]{TYPE},
new IUnlistedProperty[]{
UnlistedBlockPos.POS,
UnlistedBlockAccess.BLOCKACCESS
}
);
}
@Override
@@ -159,15 +168,17 @@ public class BlockCeramicBrick extends Block implements IMultipassBlock<CeramicB
@Override
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) {
return getDefaultState().withProperty(TYPE, CeramicBrickType.get(meta >> 16 & 0xFF));
ItemStack stack = placer.getHeldItem(hand);
CeramicBrickPair pair = new CeramicBrickPair(stack);
return getDefaultState().withProperty(TYPE, pair.type);
}
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
TileCeramicBrick ceramic = TileUtil.getTile(worldIn, pos, TileCeramicBrick.class);
if (ceramic != null) {
int damage = stack.getItemDamage();
ceramic.setColors(EnumFlowerColor.get(damage & 0xFF), EnumFlowerColor.get(damage >> 8 & 0xFF));
CeramicBrickPair pair = new CeramicBrickPair(stack);
ceramic.setColors(pair.colorFirst, pair.colorSecond);
}
}
@@ -193,7 +204,7 @@ public class BlockCeramicBrick extends Block implements IMultipassBlock<CeramicB
}
}
}
return 16777215;
return 0xffffff;
}
@SideOnly(Side.CLIENT)
@@ -224,7 +235,7 @@ public class BlockCeramicBrick extends Block implements IMultipassBlock<CeramicB
if (ceramic != null) {
return ceramic.pair();
}
return null;
return CeramicBrickPair.EMPTY;
}
@Override
@@ -1,10 +1,12 @@
package binnie.botany.ceramic;
package binnie.botany.blocks;
import net.minecraft.block.material.Material;
import net.minecraft.item.ItemStack;
import binnie.botany.CreativeTabBotany;
import binnie.botany.genetics.EnumFlowerColor;
import binnie.botany.ceramic.CeramicColor;
import binnie.botany.ceramic.CeramicDesignSystem;
import binnie.botany.api.genetics.EnumFlowerColor;
import binnie.core.util.I18N;
import binnie.extratrees.api.IDesign;
import binnie.extratrees.carpentry.BlockDesign;
import binnie.extratrees.carpentry.DesignBlock;
@@ -13,19 +15,18 @@ 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);
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) {
return design.getDesign().getName() + " Ceramic Block";
public String getBlockName(DesignBlock design) {
return I18N.localise("botany.ceramic.block.name", design.getDesign().getName());
}
}
@@ -1,313 +1,310 @@
package binnie.botany.flower;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.IStateMapperRegister;
import forestry.core.blocks.IColoredBlock;
import binnie.botany.Botany;
import binnie.botany.api.IFlower;
import binnie.botany.api.IFlowerGenome;
import binnie.botany.api.IFlowerRoot;
import binnie.botany.api.IFlowerType;
import binnie.botany.core.BotanyCore;
import binnie.botany.genetics.EnumFlowerType;
import binnie.botany.genetics.FlowerDefinition;
import binnie.botany.network.PacketID;
import binnie.core.BinnieCore;
import binnie.core.network.packet.MessageNBT;
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 */
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");
public static final PropertyBool SEED = PropertyBool.create("seed");
public BlockFlower() {
super(Material.PLANTS);
final float f = 0.2f;
this.setTickRandomly(true);
this.setRegistryName("flower");
this.setSoundType(SoundType.PLANT);
}
@Override
public TileEntity createNewTileEntity(final World var1, final int i) {
return new TileEntityFlower();
}
@Override
@SideOnly(Side.CLIENT)
public void registerStateMapper() {
ModelLoader.setCustomStateMapper(this, new StateMapperFlower());
}
@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);
}
}
return true;
}
return false;
}
@Override
@Nullable
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) {
return null;
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
TileEntity tile = source.getTileEntity(pos);
if (tile instanceof TileEntityFlower) {
TileEntityFlower flower = (TileEntityFlower) tile;
if (flower.getType().getSections() > 1) {
return FULL_BLOCK_AABB;
}
}
return FLOWER_BLOCK_AABB;
}
@Override
public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityFlower) {
TileEntityFlower flower = (TileEntityFlower) tile;
if (flower.getType().getSections() > 1) {
return FULL_BLOCK_AABB.offset(pos);
}
}
return FLOWER_BLOCK_AABB.offset(pos);
}
@Override
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public boolean isFullCube(IBlockState state) {
return false;
}
@Override
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);
if (!BinnieCore.getBinnieProxy().isSimulating(world)) {
if (flower != null && flower instanceof TileEntityFlower) {
final 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());
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;
((TileEntityFlower) flower).create(stack, owner);
}
}
flowerRoot.tryGrowSection(world, pos);
}
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess world, @Nullable BlockPos pos, int tintIndex) {
if (world != null && pos != null) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityFlower) {
TileEntityFlower flower = (TileEntityFlower) tile;
if (tintIndex == 0) {
return flower.getStemColour();
} else if (tintIndex == 1) {
return flower.getPrimaryColour();
} else {
return flower.getSecondaryColour();
}
}
}
return 0xffffff;
}
@Override
public boolean canPlaceBlockAt(World world, BlockPos pos) {
return super.canPlaceBlockAt(world, pos) && canBlockStay(world, pos);
}
public boolean canBlockStay(World world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
IBlockState downState = world.getBlockState(pos.down());
if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).getSection() > 0) {
return downState.getBlock() == Botany.flower;
}
return this.canPlaceBlockOn(downState.getBlock());
}
protected boolean canPlaceBlockOn(final Block block) {
return block == Blocks.GRASS || block == Blocks.DIRT || block == Blocks.FARMLAND || BotanyCore.getGardening().isSoil(block);
}
@Override
@SideOnly(Side.CLIENT)
public EnumBlockRenderType getRenderType(IBlockState state) {
return EnumBlockRenderType.MODEL;
}
@Override
@SideOnly(Side.CLIENT)
public EnumOffsetType getOffsetType() {
return EnumOffsetType.XZ;
}
@Override
@SideOnly(Side.CLIENT)
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
TileEntityFlower flower = TileUtil.getTile(world, pos, TileEntityFlower.class);
if (flower != null && flower.getType() != null) {
state = state.withProperty(FLOWER, flower.getType());
state = state.withProperty(FLOWERED, flower.isFlowered());
state = state.withProperty(SECTION, flower.getRenderSection());
state = state.withProperty(SEED, flower.getAge() == 0);
} else {
state = state.withProperty(FLOWER, FlowerDefinition.Dandelion.getSpecies().getType());
state = state.withProperty(FLOWERED, false);
state = state.withProperty(SEED, false);
}
return state;
}
@Override
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, FLOWER, FLOWERED, SECTION, SEED);
}
@Override
public int getMetaFromState(IBlockState state) {
return 0;
}
@Override
public BlockRenderLayer getBlockLayer() {
return BlockRenderLayer.CUTOUT;
}
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
this.checkAndDropBlock(worldIn, pos);
final TileEntity tile = worldIn.getTileEntity(pos);
if (tile instanceof TileEntityFlower) {
final 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);
worldIn.setBlockToAir(pos);
}
}
}
@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
final TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityFlower) {
((TileEntityFlower) tile).randomUpdate(rand);
this.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);
world.setBlockToAir(pos);
}
}
@Override
public NonNullList<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
NonNullList<ItemStack> drops = NonNullList.create();
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).getSection() == 0) {
ItemStack flower = ((TileEntityFlower) tile).getItemStack();
if (!flower.isEmpty()) {
drops.add(flower);
}
}
return drops;
}
@Override
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) {
final List<ItemStack> drops = this.getDrops(world, pos, world.getBlockState(pos), 0);
final boolean hasBeenBroken = world.setBlockToAir(pos);
if (hasBeenBroken && BinnieCore.getBinnieProxy().isSimulating(world) && drops.size() > 0 && (player == null || !player.capabilities.isCreativeMode)) {
for (final ItemStack drop : drops) {
spawnAsEntity(world, pos, drop);
}
}
return hasBeenBroken;
}
}
package binnie.botany.blocks;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.IStateMapperRegister;
import forestry.core.blocks.IColoredBlock;
import binnie.botany.Botany;
import binnie.botany.api.genetics.IFlower;
import binnie.botany.api.genetics.IFlowerGenome;
import binnie.botany.api.genetics.IFlowerRoot;
import binnie.botany.api.genetics.IFlowerType;
import binnie.botany.blocks.properties.PropertyFlower;
import binnie.botany.core.BotanyCore;
import binnie.botany.genetics.EnumFlowerType;
import binnie.botany.genetics.FlowerDefinition;
import binnie.botany.models.StateMapperFlower;
import binnie.botany.modules.ModuleFlowers;
import binnie.botany.network.PacketID;
import binnie.botany.tile.TileEntityFlower;
import binnie.core.BinnieCore;
import binnie.core.network.packet.MessageNBT;
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);
/* 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");
public static final PropertyBool SEED = PropertyBool.create("seed");
public BlockFlower() {
super(Material.PLANTS);
setTickRandomly(true);
setRegistryName("flower");
setSoundType(SoundType.PLANT);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityFlower();
}
@Override
@SideOnly(Side.CLIENT)
public void registerStateMapper() {
ModelLoader.setCustomStateMapper(this, new StateMapperFlower());
}
@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()) {
return false;
}
if (world.isRemote) {
return true;
}
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
@Nullable
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) {
return null;
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
TileEntity tile = source.getTileEntity(pos);
if (tile instanceof TileEntityFlower) {
TileEntityFlower flower = (TileEntityFlower) tile;
if (flower.getType().getSections() > 1) {
return FULL_BLOCK_AABB;
}
}
return FLOWER_BLOCK_AABB.offset(getOffset(state, source, pos));
}
@Override
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public boolean isFullCube(IBlockState state) {
return false;
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
super.onBlockPlacedBy(world, pos, state, placer, stack);
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
TileEntity flower = world.getTileEntity(pos);
if (!!world.isRemote) {
if (flower != null && flower instanceof TileEntityFlower) {
IFlower f = flowerRoot.getMember(stack);
if (f != null) {
((TileEntityFlower) flower).setRender(new TileEntityFlower.RenderInfo(f, (TileEntityFlower) flower));
}
}
return;
}
TileEntity below = world.getTileEntity(pos.down());
if (flower != null && flower instanceof TileEntityFlower) {
if (below instanceof TileEntityFlower) {
((TileEntityFlower) flower).setSection(((TileEntityFlower) below).getSection());
} else {
GameProfile owner = (placer instanceof EntityPlayer) ? ((EntityPlayer) placer).getGameProfile() : null;
((TileEntityFlower) flower).create(stack, owner);
}
}
flowerRoot.tryGrowSection(world, pos);
}
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess world, @Nullable BlockPos pos, int tintIndex) {
if (world != null && pos != null) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityFlower) {
TileEntityFlower flower = (TileEntityFlower) tile;
if (tintIndex == 0) {
return flower.getStemColour();
} else if (tintIndex == 1) {
return flower.getPrimaryColour();
}
return flower.getSecondaryColour();
}
}
return 0xffffff;
}
@Override
public boolean canPlaceBlockAt(World world, BlockPos pos) {
return super.canPlaceBlockAt(world, pos) && canBlockStay(world, pos);
}
public boolean canBlockStay(World world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
IBlockState downState = world.getBlockState(pos.down());
if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).getSection() > 0) {
return downState.getBlock() == ModuleFlowers.flower;
}
return canPlaceBlockOn(downState.getBlock());
}
protected boolean canPlaceBlockOn(Block block) {
return block == Blocks.GRASS
|| block == Blocks.DIRT
|| block == Blocks.FARMLAND
|| BotanyCore.getGardening().isSoil(block);
}
@Override
@SideOnly(Side.CLIENT)
public EnumBlockRenderType getRenderType(IBlockState state) {
return EnumBlockRenderType.MODEL;
}
@Override
@SideOnly(Side.CLIENT)
public EnumOffsetType getOffsetType() {
return EnumOffsetType.XZ;
}
@Override
@SideOnly(Side.CLIENT)
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
TileEntityFlower flower = TileUtil.getTile(world, pos, TileEntityFlower.class);
if (flower != null && flower.getType() != null) {
state = state.withProperty(FLOWER, flower.getType());
state = state.withProperty(FLOWERED, flower.isFlowered());
state = state.withProperty(SECTION, flower.getRenderSection());
state = state.withProperty(SEED, flower.getAge() == 0);
} else {
state = state.withProperty(FLOWER, FlowerDefinition.Dandelion.getSpecies().getType());
state = state.withProperty(FLOWERED, false);
state = state.withProperty(SEED, false);
}
return state;
}
@Override
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, FLOWER, FLOWERED, SECTION, SEED);
}
@Override
public int getMetaFromState(IBlockState state) {
return 0;
}
@Override
public BlockRenderLayer getBlockLayer() {
return BlockRenderLayer.CUTOUT;
}
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
checkAndDropBlock(worldIn, pos);
TileEntity tile = worldIn.getTileEntity(pos);
if (tile instanceof TileEntityFlower) {
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() != ModuleFlowers.flower) {
dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0);
worldIn.setBlockToAir(pos);
}
}
}
@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityFlower) {
((TileEntityFlower) tile).randomUpdate(rand);
checkAndDropBlock(world, pos);
return;
}
world.setBlockToAir(pos);
}
protected void checkAndDropBlock(World world, BlockPos pos) {
if (!canBlockStay(world, pos)) {
dropBlockAsItem(world, pos, world.getBlockState(pos), 0);
world.setBlockToAir(pos);
}
}
@Override
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).getSection() == 0) {
ItemStack flower = ((TileEntityFlower) tile).getItemStack();
if (!flower.isEmpty()) {
drops.add(flower);
}
}
}
@Override
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) {
List<ItemStack> drops = getDrops(world, pos, world.getBlockState(pos), 0);
boolean hasBeenBroken = world.setBlockToAir(pos);
if (hasBeenBroken && !world.isRemote && drops.size() > 0 && (player == null || !player.capabilities.isCreativeMode)) {
for (ItemStack drop : drops) {
spawnAsEntity(world, pos, drop);
}
}
return hasBeenBroken;
}
}
@@ -0,0 +1,150 @@
package binnie.botany.blocks;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockBush;
import net.minecraft.block.SoundType;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
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.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import binnie.botany.CreativeTabBotany;
import binnie.botany.api.gardening.EnumSoilType;
import binnie.botany.api.gardening.IBlockSoil;
import binnie.botany.core.BotanyCore;
public class BlockPlant extends BlockBush implements IItemModelRegister {
public static final PropertyEnum<PlantType> PLANT_TYPE = PropertyEnum.create("plant_type", PlantType.class);
public BlockPlant() {
setRegistryName("plant");
setCreativeTab(CreativeTabBotany.instance);
setTickRandomly(true);
setSoundType(SoundType.PLANT);
}
public static boolean isWeed(IBlockAccess world, BlockPos pos) {
IBlockState blockState = world.getBlockState(pos);
if (!(blockState.getBlock() instanceof BlockPlant)) {
return false;
}
PlantType type = blockState.getValue(PLANT_TYPE);
return type.isWeed();
}
@Override
@SideOnly(Side.CLIENT)
public void registerModel(Item item, IModelManager manager) {
for (int i = 0;i < PlantType.values().length;i++) {
PlantType type = PlantType.getType(i);
manager.registerItemModel(item, i, type.getName());
}
}
@Override
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, PLANT_TYPE);
}
@Override
public int getMetaFromState(IBlockState state) {
return state.getValue(PLANT_TYPE).ordinal();
}
@Override
public IBlockState getStateFromMeta(int meta) {
return getDefaultState().withProperty(PLANT_TYPE, PlantType.getType(meta));
}
@Override
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
}
@Override
public boolean canPlaceBlockAt(World worldIn, BlockPos pos) {
return super.canPlaceBlockAt(worldIn, pos) || BotanyCore.getGardening().isSoil(worldIn.getBlockState(pos).getBlock());
}
@Override
public int damageDropped(IBlockState state) {
return getMetaFromState(state);
}
@Override
public void getSubBlocks(CreativeTabs p_149666_2_, NonNullList<ItemStack> subBlocks) {
for (PlantType type : PlantType.values()) {
subBlocks.add(type.get());
}
}
@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
PlantType type = state.getValue(PLANT_TYPE);
if (rand.nextInt(4) == 0) {
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 == PlantType.WEEDS) {
world.setBlockToAir(pos);
} 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)) {
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);
}
}
@Override
public boolean isReplaceable(IBlockAccess worldIn, BlockPos pos) {
return true;
}
@Override
public EnumOffsetType getOffsetType() {
return EnumOffsetType.XZ;
}
}
@@ -1,4 +1,4 @@
package binnie.botany.gardening;
package binnie.botany.blocks;
import javax.annotation.Nullable;
import java.util.Random;
@@ -29,14 +29,18 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.IItemModelRegister;
import forestry.api.core.IModelManager;
import binnie.botany.Botany;
import binnie.core.Constants;
import binnie.botany.CreativeTabBotany;
import binnie.botany.api.EnumAcidity;
import binnie.botany.api.EnumMoisture;
import binnie.botany.api.EnumSoilType;
import binnie.botany.api.IBlockSoil;
import binnie.botany.api.gardening.EnumAcidity;
import binnie.botany.api.gardening.EnumMoisture;
import binnie.botany.api.gardening.EnumSoilType;
import binnie.botany.api.gardening.IBlockSoil;
import binnie.botany.core.BotanyCore;
import binnie.core.modules.BotanyModuleUIDs;
import binnie.botany.modules.ModuleFlowers;
import binnie.botany.modules.ModuleGardening;
import binnie.core.util.I18N;
import binnie.core.modules.ModuleManager;
public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister {
public static final PropertyEnum<EnumMoisture> MOISTURE = PropertyEnum.create("moisture", EnumMoisture.class);
@@ -47,18 +51,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 +92,7 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister {
switch (side) {
case UP:
return true;
case NORTH:
case SOUTH:
case WEST:
@@ -95,9 +100,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);
}
/**
@@ -135,8 +139,7 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister {
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(final Item itemIn, final CreativeTabs tab, final NonNullList<ItemStack> list) {
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
for (int i = 0; i < 9; ++i) {
list.add(new ItemStack(this, 1, i));
}
@@ -151,16 +154,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 +189,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 +209,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, ModuleGardening.plant.getStateFromMeta(PlantType.WEEDS.ordinal()), 2);
}
}
@@ -233,48 +240,50 @@ 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);
IBlockState newState = BotanyCore.getGardening().getSoil(maxLevel, weedKilled, old.getValue(MOISTURE), old.getValue(ACIDITY));
return world.setBlockState(pos, newState, 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);
IBlockState newState = BotanyCore.getGardening().getSoil(minLevel, weedKilled, old.getValue(MOISTURE), old.getValue(ACIDITY));
return world.setBlockState(pos, newState, 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));
}
@@ -290,18 +299,21 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister {
@Override
public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable) {
IBlockState plant = plantable.getPlant(world, pos.up());
if (plant.getBlock() == Botany.flower) {
return true;
if(ModuleManager.isModuleEnabled(Constants.BOTANY_MOD_ID, BotanyModuleUIDs.FLOWERS)) {
if (plant.getBlock() == ModuleFlowers.flower) {
return true;
}
}
if (plant.getBlock() == Botany.plant) {
return !this.weedKilled || !BlockPlant.isWeed(world, pos);
if (plant.getBlock() == ModuleGardening.plant) {
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() {
@@ -1,7 +1,7 @@
package binnie.botany.ceramic;
package binnie.botany.blocks;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@@ -35,26 +35,26 @@ import forestry.api.core.IModelManager;
import forestry.core.blocks.IColoredBlock;
import binnie.botany.CreativeTabBotany;
import binnie.botany.genetics.EnumFlowerColor;
import binnie.core.block.BlockMetadata;
import binnie.core.block.IBlockMetadata;
import binnie.core.block.TileEntityMetadata;
import binnie.botany.api.genetics.EnumFlowerColor;
import binnie.core.api.block.BlockMetadata;
import binnie.core.api.block.IBlockMetadata;
import binnie.core.api.block.TileEntityMetadata;
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 +81,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<ItemStack> items = new java.util.ArrayList<ItemStack>();
List<ItemStack> 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);
@@ -105,12 +105,12 @@ public class BlockStainedGlass extends Block implements IBlockMetadata, IColored
}
@Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
return Collections.emptyList();
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
}
@Override
public TileEntity createNewTileEntity(final World var1, final int i) {
public TileEntity createNewTileEntity(World var1, int i) {
return new TileEntityMetadata();
}
@@ -126,7 +126,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,15 +136,15 @@ public class BlockStainedGlass extends Block implements IBlockMetadata, IColored
}
@Override
public String getDisplayName(final ItemStack itemStack) {
final int meta = TileEntityMetadata.getItemDamage(itemStack);
return EnumFlowerColor.get(meta).getFlowerColorAllele().getColourName() + " " + I18N.localise("tile.botany.pigmented.glass.name");
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<ItemStack> itemList) {
for (final EnumFlowerColor c : EnumFlowerColor.values()) {
itemList.add(TileEntityMetadata.getItemStack(this, c.ordinal()));
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> itemList) {
for (EnumFlowerColor color : EnumFlowerColor.values()) {
itemList.add(TileEntityMetadata.getItemStack(this, color.ordinal()));
}
}
@@ -178,6 +178,7 @@ public class BlockStainedGlass extends Block implements IBlockMetadata, IColored
if (worldIn == null || pos == null) {
return 0;
}
return EnumFlowerColor.get(TileEntityMetadata.getTileMetadata(worldIn, pos)).getFlowerColorAllele().getColor(false);
EnumFlowerColor color = EnumFlowerColor.get(TileEntityMetadata.getTileMetadata(worldIn, pos));
return color.getFlowerColorAllele().getColor(false);
}
}
@@ -0,0 +1,46 @@
package binnie.botany.blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IStringSerializable;
import binnie.botany.modules.ModuleGardening;
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 getType(int meta){
if(meta >= values().length){
meta = values().length-1;
}
return values()[meta];
}
public ItemStack get() {
return new ItemStack(ModuleGardening.plant, 1, ordinal());
}
public boolean isWeed() {
return isWeed;
}
@Override
public String getName() {
return name;
}
}
@@ -1,7 +1,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
@FieldsAreNonnullByDefault
package binnie.botany.flower;
package binnie.botany.blocks;
import javax.annotation.ParametersAreNonnullByDefault;
@@ -1,4 +1,4 @@
package binnie.botany.flower;
package binnie.botany.blocks.properties;
import com.google.common.base.Optional;
@@ -11,8 +11,8 @@ import net.minecraft.block.properties.PropertyHelper;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import binnie.botany.api.IAlleleFlowerSpecies;
import binnie.botany.api.IFlowerType;
import binnie.botany.api.genetics.IAlleleFlowerSpecies;
import binnie.botany.api.genetics.IFlowerType;
public class PropertyFlower<I extends IFlowerType<I>> extends PropertyHelper<I> {
public PropertyFlower(String name, Class<I> flowerTypeClass) {
@@ -0,0 +1,9 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
@FieldsAreNonnullByDefault
package binnie.botany.blocks.properties;
import javax.annotation.ParametersAreNonnullByDefault;
import binnie.core.util.FieldsAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;
@@ -5,33 +5,33 @@ import java.util.Map;
import net.minecraft.item.ItemStack;
import binnie.botany.Botany;
import binnie.botany.genetics.EnumFlowerColor;
import binnie.core.block.TileEntityMetadata;
import binnie.botany.api.genetics.EnumFlowerColor;
import binnie.botany.modules.ModuleCeramic;
import binnie.core.api.block.TileEntityMetadata;
import binnie.extratrees.api.IDesignMaterial;
public class CeramicColor implements IDesignMaterial {
private final static Map<EnumFlowerColor, CeramicColor> 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(ModuleCeramic.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);
}
}
@@ -4,6 +4,8 @@ import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;
import binnie.extratrees.api.carpentry.DesignerManager;
import binnie.extratrees.api.carpentry.EnumPattern;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
@@ -15,14 +17,13 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import binnie.botany.Botany;
import binnie.botany.genetics.EnumFlowerColor;
import binnie.botany.items.BotanyItems;
import binnie.botany.api.genetics.EnumFlowerColor;
import binnie.botany.items.CeramicItems;
import binnie.botany.modules.ModuleCeramic;
import binnie.core.AbstractMod;
import binnie.extratrees.api.IDesignMaterial;
import binnie.extratrees.api.IDesignSystem;
import binnie.extratrees.api.IPattern;
import binnie.extratrees.carpentry.DesignerManager;
import binnie.extratrees.carpentry.EnumPattern;
public class CeramicDesignSystem implements IDesignSystem {
public static CeramicDesignSystem instance = new CeramicDesignSystem();
@@ -30,8 +31,8 @@ public class CeramicDesignSystem implements IDesignSystem {
Map<Integer, TextureAtlasSprite> secondary;
CeramicDesignSystem() {
this.primary = new HashMap<>();
this.secondary = new HashMap<>();
primary = new HashMap<>();
secondary = new HashMap<>();
DesignerManager.instance.registerDesignSystem(this);
}
@@ -46,12 +47,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();
}
@@ -63,8 +64,9 @@ public class CeramicDesignSystem implements IDesignSystem {
@Nullable
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getPrimarySprite(IPattern pattern) {
if (pattern instanceof EnumPattern) {
return this.primary.get(((EnumPattern) pattern).ordinal());
int index = pattern.getIndex();
if (index > 0 && index < primary.size()) {
return primary.get(index);
}
return null;
}
@@ -73,8 +75,9 @@ public class CeramicDesignSystem implements IDesignSystem {
@Nullable
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getSecondarySprite(IPattern pattern) {
if (pattern instanceof EnumPattern) {
return this.secondary.get(((EnumPattern) pattern).ordinal());
int index = pattern.getIndex();
if (index > 0 && index < secondary.size()) {
return secondary.get(index);
}
return null;
}
@@ -86,8 +89,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.getIndex(), textureMap.registerSprite(primaryLocation));
secondary.put(pattern.getIndex(), textureMap.registerSprite(secondaryLocation));
}
}
@@ -97,12 +100,14 @@ public class CeramicDesignSystem implements IDesignSystem {
@Override
public ItemStack getAdhesive() {
return BotanyItems.Mortar.get(1);
return CeramicItems.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(ModuleCeramic.ceramic))
? getMaterial(itemStack.getItemDamage())
: null;
}
}
@@ -0,0 +1,90 @@
package binnie.botany.ceramic.brick;
import com.google.common.base.Preconditions;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagInt;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import binnie.botany.api.genetics.EnumFlowerColor;
import binnie.botany.modules.ModuleCeramic;
import binnie.core.util.I18N;
public class CeramicBrickPair {
public static final CeramicBrickPair EMPTY = new CeramicBrickPair(EnumFlowerColor.DarkSeaGreen, EnumFlowerColor.DarkSeaGreen, CeramicBrickType.TILE);
public final EnumFlowerColor colorFirst;
public final EnumFlowerColor colorSecond;
public CeramicBrickType type;
public int ordinal;
public CeramicBrickPair(EnumFlowerColor colorFirst, EnumFlowerColor colorSecond, CeramicBrickType type) {
this.colorFirst = colorFirst;
this.colorSecond = colorSecond;
this.type = type;
ordinal = colorFirst.ordinal() + colorSecond.ordinal() * 256 + type.ordinal() * 256 * 256;
}
public CeramicBrickPair(ItemStack stack) {
this(getId(stack));
}
public CeramicBrickPair(int id) {
colorFirst = EnumFlowerColor.get(id & 0xFF);
colorSecond = EnumFlowerColor.get(id >> 8 & 0xFF);
type = CeramicBrickType.get(id >> 16 & 0xFF);
}
public boolean isTwoColors() {
return type.canDouble() && colorSecond != colorFirst;
}
public static int getId(ItemStack stack){
if(!stack.hasTagCompound()){
return EMPTY.ordinal();
}
NBTTagCompound nbtTagCompound = stack.getTagCompound();
return nbtTagCompound.getInteger("id");
}
public ItemStack getStack(int i) {
ItemStack stack = new ItemStack(ModuleCeramic.ceramicBrick, i);
stack.setTagInfo("id", new NBTTagInt(ordinal()));
return stack;
}
public String getName() {
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);
}
public int ordinal() {
return ordinal;
}
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getSprite(int pass) {
TextureAtlasSprite[] sprites = type.sprites;
Preconditions.checkState(sprites != null, "Sprites have not been registered.");
return sprites[pass];
}
@Override
public int hashCode() {
return Integer.hashCode(type.ordinal());
}
@Override
public boolean equals(Object obj) {
return obj instanceof CeramicBrickPair
&& ((CeramicBrickPair) obj).type == type;
}
}
@@ -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;
@@ -12,13 +11,13 @@ import net.minecraft.util.IStringSerializable;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import binnie.botany.Botany;
import binnie.botany.genetics.EnumFlowerColor;
import binnie.botany.items.BotanyItems;
import binnie.core.block.TileEntityMetadata;
import binnie.botany.api.genetics.EnumFlowerColor;
import binnie.botany.items.CeramicItems;
import binnie.botany.modules.ModuleCeramic;
import binnie.core.api.block.TileEntityMetadata;
public enum CeramicBrickType implements IStringSerializable {
Tile("tile", "Ceramic Tile") {
TILE("tile") {
@Override
public ItemStack getRecipe(List<ItemStack> 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)) {
if (stack.getItem() != Item.getItemFromBlock(ModuleCeramic.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", "Ceramic Bricks") {
BRICK("brick") {
@Override
public ItemStack getRecipe(List<ItemStack> stacks) {
return getBrickRecipe(this, stacks);
}
},
StripeBrick("brickstripe", "Striped Ceramic Bricks") {
STRIPE_BRICK("brickstripe") {
@Override
public ItemStack getRecipe(List<ItemStack> stacks) {
return getBrickRecipe(this, stacks);
}
},
LargeBrick("bricklarge", "Large Ceramic Bricks") {
LARGE_BRICK("bricklarge") {
@Override
public ItemStack getRecipe(List<ItemStack> 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) {
if (stack4.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
for (ItemStack stack4 : stacks) {
if (stack4.getItem() != Item.getItemFromBlock(ModuleCeramic.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 Ceramic Tile") {
SPLIT("split") {
@Override
public ItemStack getRecipe(List<ItemStack> 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;
if (stack2.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
for (ItemStack stack2 : stacks) {
int alt = (altCounter != 0 && altCounter != 3) ? 1 : 0;
if (stack2.getItem() != Item.getItemFromBlock(ModuleCeramic.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 Ceramic Tile") {
CHEQUERED("cheque") {
@Override
public ItemStack getRecipe(List<ItemStack> stacks) {
if (stacks.size() != 4) {
return ItemStack.EMPTY;
}
final int[] colors = {-1, -1};
for (final ItemStack stack2 : stacks) {
if (stack2.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
int[] colors = {-1, -1};
for (ItemStack stack2 : stacks) {
if (stack2.getItem() != Item.getItemFromBlock(ModuleCeramic.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 Ceramic Tile") {
MIXED("mixed") {
@Override
public ItemStack getRecipe(List<ItemStack> stacks) {
if (stacks.size() != 4) {
return ItemStack.EMPTY;
}
final int[] colors = {-1, -1};
for (final ItemStack stack2 : stacks) {
if (stack2.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
int[] colors = {-1, -1};
for (ItemStack stack2 : stacks) {
if (stack2.getItem() != Item.getItemFromBlock(ModuleCeramic.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 Ceramic Bricks") {
VERTICAL_BRICK("verticalbrick") {
@Override
public ItemStack getRecipe(List<ItemStack> stacks) {
return getVerticalBrickRecipe(stacks);
}
},
VerticalStripeBrick("verticalbrickstripe", "Vertical Striped Ceramic Bricks") {
VERTICAL_STRIPE_BRICK("verticalbrickstripe") {
@Override
public ItemStack getRecipe(List<ItemStack> stacks) {
return getVerticalBrickRecipe(stacks);
}
},
VerticalLargeBrick("verticalbricklarge", "Large Vertical Ceramic Bricks") {
VERTICAL_LARGE_BRICK("verticalbricklarge") {
@Override
public ItemStack getRecipe(List<ItemStack> stacks) {
return getVerticalBrickRecipe(stacks);
@@ -230,24 +229,22 @@ public enum CeramicBrickType implements IStringSerializable {
public static final CeramicBrickType[] VALUES = values();
String id;
String name;
public String id;
@SideOnly(Side.CLIENT)
@Nullable
TextureAtlasSprite[] sprites;
public TextureAtlasSprite[] sprites;
CeramicBrickType(final String id, final String name) {
CeramicBrickType(String id) {
this.id = id;
this.name = name;
}
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<ItemStack> stacks);
@@ -256,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;
@@ -275,34 +274,38 @@ public enum CeramicBrickType implements IStringSerializable {
protected ItemStack getBrickRecipe(CeramicBrickType ceramicType, List<ItemStack> 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);
if (stack4.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
ItemStack stack4 = stacks.get(index2);
if (stack4.getItem() != Item.getItemFromBlock(ModuleCeramic.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;
@@ -311,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() == ModuleCeramic.misc && stack.getItemDamage() == CeramicItems.MORTAR.ordinal();
}
@Override
public String getName() {
return name().toLowerCase(Locale.ENGLISH);
return id;
}
}
@@ -0,0 +1,25 @@
package binnie.botany.core;
import binnie.botany.GardeningManager;
import binnie.botany.api.BotanyAPI;
import binnie.botany.api.gardening.IGardeningManager;
import binnie.botany.api.genetics.IFlowerRoot;
import binnie.botany.genetics.FlowerRoot;
public class BotanyCore {
public static final int CHANCE_INTERPOLLINATION = 20;
public static IFlowerRoot getFlowerRoot() {
if (BotanyAPI.flowerRoot == null) {
BotanyAPI.flowerRoot = new FlowerRoot();
}
return BotanyAPI.flowerRoot;
}
public static IGardeningManager getGardening() {
if (BotanyAPI.gardening == null) {
BotanyAPI.gardening = new GardeningManager();
}
return BotanyAPI.gardening;
}
}
@@ -1,4 +1,4 @@
package binnie.botany.farm;
package binnie.botany.farming;
import com.google.common.base.Preconditions;
@@ -12,8 +12,8 @@ import forestry.api.circuits.ICircuitLayout;
import forestry.api.farming.FarmDirection;
import forestry.api.farming.IFarmHousing;
import binnie.botany.api.EnumAcidity;
import binnie.botany.api.EnumMoisture;
import binnie.botany.api.gardening.EnumAcidity;
import binnie.botany.api.gardening.EnumMoisture;
import binnie.core.circuits.BinnieCircuit;
import binnie.core.util.I18N;
@@ -23,27 +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()));
StringBuilder info = new StringBuilder("Flowers (")
.append(TextFormatting.GRAY.toString())
.append(I18N.localise("botany.moisture"))
.append(": ")
.append(moisture.getLocalisedName(true));
isManual = manual;
logic = new GardenLogic(moisture, ph, isManual, fertilised, icon, I18N.localise(getUnlocalizedName()));
String info = I18N.localise("botany.moisture") + ": " + moisture.getLocalisedName(true) + TextFormatting.GRAY + ", ";
if (ph != null) {
info.append(TextFormatting.GRAY.toString())
.append(", ")
.append(I18N.localise("botany.ph"))
.append(": ")
.append(ph.getLocalisedName(true));
info += I18N.localise("botany.ph") + ": " + ph.getLocalisedName(true) + TextFormatting.GRAY + ", ";
}
String fertilizedKey = fertilised ? "for.binnie.circuit.garden.fertilized" : "for.binnie.circuit.garden.unfertilized";
info.append(TextFormatting.RESET.toString())
.append(" ")
.append(I18N.localise(fertilizedKey))
.append(")");
this.addTooltipString(info.toString());
info += (fertilised ? TextFormatting.GREEN : TextFormatting.RED) + I18N.localise(fertilizedKey) + TextFormatting.GRAY;
addTooltipString(I18N.localise("for.binnie.circuit.garden.info", info));
}
private static ICircuitLayout getLayout(boolean manual) {
@@ -114,5 +102,6 @@ public class CircuitGarden extends BinnieCircuit {
@Override
public void onTick(int slot, Object tile) {
// ignored
}
}
@@ -1,4 +1,4 @@
package binnie.botany.farm;
package binnie.botany.farming;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
@@ -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);
}
}
@@ -1,4 +1,4 @@
package binnie.botany.farm;
package binnie.botany.farming;
import javax.annotation.Nullable;
@@ -12,17 +12,17 @@ import net.minecraft.world.World;
import forestry.api.farming.ICrop;
import forestry.api.farming.IFarmable;
import binnie.botany.Botany;
import binnie.botany.api.EnumFlowerStage;
import binnie.botany.api.IFlower;
import binnie.botany.api.IFlowerRoot;
import binnie.botany.api.genetics.EnumFlowerStage;
import binnie.botany.api.genetics.IFlower;
import binnie.botany.api.genetics.IFlowerRoot;
import binnie.botany.core.BotanyCore;
import binnie.botany.flower.TileEntityFlower;
import binnie.botany.modules.ModuleFlowers;
import binnie.botany.tile.TileEntityFlower;
public class FarmableFlower implements IFarmable {
@Override
public boolean isSaplingAt(final World world, final BlockPos pos) {
return world.getBlockState(pos) == Botany.flower;
public boolean isSaplingAt(World world, BlockPos pos) {
return world.getBlockState(pos) == ModuleFlowers.flower;
}
@Nullable
@@ -32,33 +32,33 @@ 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);
ItemStack seed = flowerRoot.getMemberStack(flower, EnumFlowerStage.SEED);
if (mature != null && seed != null) {
if (!mature.isEmpty() && !seed.isEmpty()) {
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
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());
@@ -1,22 +1,22 @@
package binnie.botany.farm;
package binnie.botany.farming;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import binnie.botany.api.IFlower;
import binnie.botany.api.IFlowerRoot;
import binnie.botany.api.genetics.IFlower;
import binnie.botany.api.genetics.IFlowerRoot;
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());
Loaded 100 of 5026 files, more files were not shown because too many files have changed in this diff. Show more