mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-14 17:24:53 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2a49158f3 | ||
|
|
cb81d0ead4 | ||
|
|
21728bcab1 | ||
|
|
dbdb5478c2 | ||
|
|
46c5b95d82 | ||
|
|
e6547caacc | ||
|
|
f7b1805e95 | ||
|
|
123b47f038 | ||
|
|
c96ab68f19 | ||
|
|
35d6304a96 | ||
|
|
8f69af62f8 | ||
|
|
d2b14b6320 | ||
|
|
65431e73d4 | ||
|
|
fa4a5b0a17 | ||
|
|
714ba830d7 | ||
|
|
ed3cfe12a1 | ||
|
|
d2a9e62cb2 | ||
|
|
cbfb25647a | ||
|
|
6587200dd3 | ||
|
|
b488570a5f | ||
|
|
40a1c94a86 | ||
|
|
79c303b12d | ||
|
|
065d795622 | ||
|
|
2b54db9342 | ||
|
|
8f8e497f58 | ||
|
|
34fda5ddd1 | ||
|
|
ab1a2eeb89 | ||
|
|
5c40de2eba | ||
|
|
b0503fe523 | ||
|
|
3e3c9c30a4 | ||
|
|
1b338efca9 | ||
|
|
ddc9764a23 | ||
|
|
f23e28deaf | ||
|
|
afb9a62686 | ||
|
|
79a49341e9 | ||
|
|
5a93a3d0a9 | ||
|
|
2afb3c52f3 | ||
|
|
cbe86e814f | ||
|
|
c5f2368e1d | ||
|
|
7e4e518d7b | ||
|
|
21aa0c43a6 | ||
|
|
724c3d1fbd | ||
|
|
6c3d7d3bb0 | ||
|
|
afb9460ff9 | ||
|
|
687c440c69 | ||
|
|
1b722df37a | ||
|
|
dcdf4b1cac | ||
|
|
705581b9ac | ||
|
|
2a451bc72e | ||
|
|
faf2b88ed8 | ||
|
|
fcef87b3da | ||
|
|
fcbbd06c63 | ||
|
|
1b3b452900 | ||
|
|
0726954433 | ||
|
|
6ff11f4eea | ||
|
|
03eaa2510c | ||
|
|
a3103bce5e | ||
|
|
a9030ef60b | ||
|
|
4062adee6c | ||
|
|
2ca2cef6a2 | ||
|
|
95dca83465 | ||
|
|
f977a29ad6 | ||
|
|
68ed8a1511 | ||
|
|
c9d3001b47 | ||
|
|
75c875868a | ||
|
|
c51a9273f9 | ||
|
|
4edd2e9d5d | ||
|
|
bc310023df | ||
|
|
703e99e916 | ||
|
|
f73667c173 | ||
|
|
0101eae8f8 | ||
|
|
5be32a2a3a | ||
|
|
3ff4957a10 | ||
|
|
9e1ec59b86 | ||
|
|
0aa9853da2 | ||
|
|
96fe27e834 | ||
|
|
934bb3b8f9 | ||
|
|
83d9da7797 | ||
|
|
1e0d11b1ac | ||
|
|
808b04c3b8 | ||
|
|
2425ae959e | ||
|
|
3679551882 | ||
|
|
83fd00cad5 | ||
|
|
f3d93b47b9 | ||
|
|
62fc457808 | ||
|
|
2811aabc2e | ||
|
|
8573f087eb | ||
|
|
d0215ce0aa | ||
|
|
b6d5901f07 | ||
|
|
18f30c8c0d | ||
|
|
cf8634546c | ||
|
|
864e5e0dfc | ||
|
|
6df4570bca | ||
|
|
e0d23ada41 | ||
|
|
b7b663640d | ||
|
|
9989eef753 |
No files matched your search
@@ -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/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/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/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/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/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}
|
||||
|
||||
+56
-13
@@ -7,26 +7,36 @@ buildscript {
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||
classpath "gradle.plugin.se.bjurr.gitchangelog:git-changelog-gradle-plugin:1.47"
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "com.matthewprenger.cursegradle" version "1.0.9"
|
||||
}
|
||||
|
||||
apply plugin: 'net.minecraftforge.gradle.forge'
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'maven'
|
||||
apply plugin: "se.bjurr.gitchangelog.git-changelog-gradle-plugin"
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
|
||||
version = version_major + '.' + version_minor + '.' + version_patch
|
||||
if (System.getenv("BUILD_NUMBER") != null) {
|
||||
version = version + "-" + System.getenv("BUILD_NUMBER")
|
||||
version = version + "." + System.getenv("BUILD_NUMBER")
|
||||
}
|
||||
group = "binnie" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = "binnie-mods-1.11.2"
|
||||
archivesBaseName = "binnie-mods-" + mcversion
|
||||
|
||||
minecraft {
|
||||
version = mcversion + "-" + forgeversion
|
||||
mappings = mcp_mappings
|
||||
runDir = "run"
|
||||
|
||||
replace '@VERSION@', project.version
|
||||
}
|
||||
|
||||
repositories {
|
||||
@@ -38,18 +48,26 @@ repositories {
|
||||
name = "ic2, forestry"
|
||||
url = "http://maven.ic2.player.to/"
|
||||
}
|
||||
ivy {
|
||||
name 'JEI Bees'
|
||||
artifactPattern "http://addons-origin.cursecdn.com/files/${jeibees_cf}/[module]-[revision]-[classifier].[ext]"
|
||||
maven {
|
||||
name = "CurseForge"
|
||||
url = "https://minecraft.curseforge.com/api/maven/"
|
||||
}
|
||||
maven {
|
||||
name "Jared"
|
||||
url "http://maven.blamejared.com/"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
deobfCompile "net.sengir.forestry:forestry_${mcversion}:${forestry_version}"
|
||||
deobfCompile "mezz.jei:jei_${mcversion}:${jei_version}:api"
|
||||
deobfCompile("net.sengir.forestry:forestry_${mcversion}:${forestry_version}") {
|
||||
transitive = false
|
||||
}
|
||||
deobfProvided "mezz.jei:jei_${mcversion}:${jei_version}:api"
|
||||
runtime "mezz.jei:jei_${mcversion}:${jei_version}"
|
||||
deobfCompile name: 'jeibees', version: jeibees_version, ext: 'jar', classifier: "dev"
|
||||
deobfCompile "net.industrial-craft:industrialcraft-2:${ic2_version}"
|
||||
runtime "jei-bees:jeibees:${jeibees_version}:mc${mcversion}"
|
||||
deobfProvided "net.industrial-craft:industrialcraft-2:${ic2_version}:api"
|
||||
runtime "net.industrial-craft:industrialcraft-2:${ic2_version}"
|
||||
deobfProvided "CraftTweaker2:CraftTweaker2-API:${minetweaker_version}"
|
||||
}
|
||||
|
||||
processResources {
|
||||
@@ -60,9 +78,9 @@ processResources {
|
||||
// replace stuff in mcmod.info, nothing else
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include 'mcmod.info'
|
||||
expand 'version': project.version,
|
||||
'mcversion': project.minecraft.version,
|
||||
'modid': "binniemods"
|
||||
|
||||
// replace version and mcversion
|
||||
expand 'version':project.version, 'mcversion':project.minecraft.version
|
||||
}
|
||||
|
||||
// copy everything else, thats not the mcmod.info
|
||||
@@ -89,3 +107,28 @@ uploadArchives {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task makeChangelog(type: se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) {
|
||||
filePath = "changelog.html"
|
||||
untaggedName = "Current release ${project.version}"
|
||||
fromCommit = "dbc5c1a564c39e4a9c042411d1bdbe450985ce2c"
|
||||
toRef = "HEAD"
|
||||
templateContent = file('changelog.mustache').getText('UTF-8')
|
||||
}
|
||||
|
||||
curseforge {
|
||||
apiKey = project.hasProperty('curseforge_apikey') ? project.curseforge_apikey : '0'
|
||||
project {
|
||||
id = curse_project_id
|
||||
changelog = file('changelog.html')
|
||||
changelogType = 'html'
|
||||
releaseType = 'alpha'
|
||||
relations {
|
||||
requiredLibrary 'forestry'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
tasks.curseforge223525.dependsOn.add(makeChangelog)
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
Alpha version. Do not create a world you care about with this version, it may break things severely.<br/>
|
||||
Please help the project by trying it out and <a href="https://github.com/ForestryMC/Binnie/issues">reporting issues here.</a><br/>
|
||||
{{#tags}}
|
||||
<h3>{{name}}</h3>
|
||||
<ul>
|
||||
{{#commits}}
|
||||
<li>{{{message}}} - {{authorName}}</li>
|
||||
{{/commits}}
|
||||
</ul>
|
||||
{{/tags}}
|
||||
+10
-9
@@ -2,17 +2,18 @@
|
||||
# This is required to provide enough memory for the Minecraft decompilation process.
|
||||
org.gradle.jvmargs=-Xmx3G
|
||||
|
||||
mcversion=1.11.2
|
||||
forgeversion=13.20.0.2315
|
||||
mcp_mappings=snapshot_20161220
|
||||
mcversion=1.12
|
||||
forgeversion=14.21.1.2443
|
||||
mcp_mappings=snapshot_20170806
|
||||
curse_project_id=223525
|
||||
|
||||
forestry_version=5.3.4.119
|
||||
ic2_version=2.7.71-ex111
|
||||
forestry_version=5.5.0.154
|
||||
ic2_version=2.8.14-ex112
|
||||
|
||||
version_major=2
|
||||
version_minor=0
|
||||
version_minor=2
|
||||
version_patch=0
|
||||
|
||||
jei_version=4.5.0.287
|
||||
jeibees_cf=2376/963
|
||||
jeibees_version=0.9.0.4-mc1.11.2
|
||||
jei_version=4.7.4.82
|
||||
jeibees_version=0.9.0.2
|
||||
minetweaker_version=4.0.3.239
|
||||
Vendored
BIN
Binary file not shown.
+2
-2
@@ -1,6 +1,6 @@
|
||||
#Mon Sep 14 12:28:28 PDT 2015
|
||||
#Thu Jul 13 23:08:17 PDT 2017
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.1-all.zip
|
||||
+1
-1
@@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=-d64 -Xmx2G
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package binnie.botany;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
@@ -30,37 +32,29 @@ import binnie.botany.api.IBlockSoil;
|
||||
import binnie.botany.api.IFlower;
|
||||
import binnie.botany.api.IFlowerRoot;
|
||||
import binnie.botany.api.IGardeningManager;
|
||||
import binnie.botany.ceramic.BlockCeramic;
|
||||
import binnie.botany.ceramic.BlockCeramicPatterned;
|
||||
import binnie.botany.ceramic.BlockStainedGlass;
|
||||
import binnie.botany.ceramic.brick.BlockCeramicBrick;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.botany.core.BotanyGUI;
|
||||
import binnie.botany.core.ModuleCore;
|
||||
import binnie.botany.flower.BlockFlower;
|
||||
import binnie.botany.flower.ItemBotany;
|
||||
import binnie.botany.flower.ItemInsulatedTube;
|
||||
import binnie.botany.flower.TileEntityFlower;
|
||||
import binnie.botany.gardening.BlockPlant;
|
||||
import binnie.botany.gardening.BlockSoil;
|
||||
import binnie.botany.gardening.ItemSoilMeter;
|
||||
import binnie.botany.gardening.ItemTrowel;
|
||||
import binnie.botany.gardening.ModuleGardening;
|
||||
import binnie.botany.genetics.ItemDictionary;
|
||||
import binnie.botany.genetics.ModuleGenetics;
|
||||
import binnie.botany.items.ItemClay;
|
||||
import binnie.botany.items.ItemPigment;
|
||||
import binnie.botany.network.PacketID;
|
||||
import binnie.botany.proxy.Proxy;
|
||||
import binnie.core.AbstractMod;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.gui.IBinnieGUID;
|
||||
import binnie.core.item.ItemMisc;
|
||||
import binnie.core.network.BinniePacketHandler;
|
||||
import binnie.core.network.IPacketID;
|
||||
import binnie.core.proxy.IProxyCore;
|
||||
|
||||
@Mod(modid = Constants.BOTANY_MOD_ID, name = "Binnie's Botany", useMetadata = true, dependencies = "required-after:" + Constants.CORE_MOD_ID)
|
||||
@Mod(
|
||||
modid = Constants.BOTANY_MOD_ID,
|
||||
name = "Binnie's Botany",
|
||||
dependencies = "required-after:" + Constants.CORE_MOD_ID
|
||||
)
|
||||
public class Botany extends AbstractMod {
|
||||
public static final float AGE_CHANCE = 0.2f;
|
||||
|
||||
@@ -76,51 +70,44 @@ public class Botany extends AbstractMod {
|
||||
public static ItemBotany seed;
|
||||
public static ItemBotany pollen;
|
||||
public static ItemDictionary database;
|
||||
/* MODULE GARDENING */
|
||||
public static BlockPlant plant;
|
||||
public static ItemTrowel trowelWood;
|
||||
public static ItemTrowel trowelStone;
|
||||
public static ItemTrowel trowelIron;
|
||||
public static ItemTrowel trowelDiamond;
|
||||
public static ItemTrowel trowelGold;
|
||||
public static BlockSoil soil;
|
||||
public static BlockSoil loam;
|
||||
public static BlockSoil flowerbed;
|
||||
public static BlockSoil soilNoWeed;
|
||||
public static BlockSoil loamNoWeed;
|
||||
public static BlockSoil flowerbedNoWeed;
|
||||
public static ItemInsulatedTube insulatedTube;
|
||||
public static ItemSoilMeter soilMeter;
|
||||
public static ItemMisc misc;
|
||||
public static ItemPigment pigment;
|
||||
public static ItemClay clay;
|
||||
public static BlockCeramic ceramic;
|
||||
public static BlockCeramicPatterned ceramicTile;
|
||||
public static BlockStainedGlass stained;
|
||||
public static BlockCeramicBrick ceramicBrick;
|
||||
@Nullable
|
||||
public static Item botanistBackpack;
|
||||
|
||||
@Nullable
|
||||
private static ModuleGardening gardening;
|
||||
@Nullable
|
||||
private static ModuleGenetics genetics;
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(final FMLPreInitializationEvent evt) {
|
||||
this.preInit();
|
||||
public void preInit(FMLPreInitializationEvent evt) {
|
||||
preInit();
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(final FMLInitializationEvent evt) {
|
||||
this.init();
|
||||
public void init(FMLInitializationEvent evt) {
|
||||
init();
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void postInit(final FMLPostInitializationEvent evt) {
|
||||
this.postInit();
|
||||
public void postInit(FMLPostInitializationEvent evt) {
|
||||
postInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerModules() {
|
||||
this.addModule(new ModuleCore());
|
||||
this.addModule(new ModuleGenetics());
|
||||
this.addModule(new ModuleGardening());
|
||||
addModule(new ModuleCore());
|
||||
addModule(genetics = new ModuleGenetics());
|
||||
addModule(gardening = new ModuleGardening());
|
||||
}
|
||||
|
||||
public static ModuleGardening gardening() {
|
||||
Preconditions.checkState(gardening != null);
|
||||
return gardening;
|
||||
}
|
||||
|
||||
public static ModuleGenetics genetics() {
|
||||
Preconditions.checkState(genetics != null);
|
||||
return genetics;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -159,12 +146,12 @@ public class Botany extends AbstractMod {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
public boolean isAvailable() {
|
||||
return BinnieCore.isBotanyActive();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onShearFlower(final PlayerInteractEvent.RightClickBlock event) {
|
||||
public void onShearFlower(PlayerInteractEvent.RightClickBlock event) {
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
if (player == null) {
|
||||
return;
|
||||
@@ -196,7 +183,7 @@ public class Botany extends AbstractMod {
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onFertiliseSoil(final PlayerInteractEvent.RightClickBlock event) {
|
||||
public void onFertiliseSoil(PlayerInteractEvent.RightClickBlock event) {
|
||||
World world = event.getWorld();
|
||||
if (world == null) {
|
||||
return;
|
||||
@@ -212,7 +199,7 @@ public class Botany extends AbstractMod {
|
||||
if (heldItem.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
IGardeningManager gardening = BotanyCore.getGardening();
|
||||
Block block = world.getBlockState(event.getPos()).getBlock();
|
||||
if (!gardening.isSoil(block)) {
|
||||
@@ -259,14 +246,14 @@ public class Botany extends AbstractMod {
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void plantVanilla(final BlockEvent.PlaceEvent event) {
|
||||
public void plantVanilla(BlockEvent.PlaceEvent event) {
|
||||
World world = event.getWorld();
|
||||
BlockPos pos = event.getPos();
|
||||
Block block = world.getBlockState(pos.down()).getBlock();
|
||||
|
||||
if (!BotanyCore.getGardening().isSoil(block)) {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer player = event.getPlayer();
|
||||
ItemStack heldItem = player.getHeldItem(event.getHand());
|
||||
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
|
||||
@@ -277,7 +264,7 @@ public class Botany extends AbstractMod {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void onPlantVanilla(final PlayerInteractEvent.RightClickBlock event) {
|
||||
public void onPlantVanilla(PlayerInteractEvent.RightClickBlock event) {
|
||||
BlockPos pos = event.getPos();
|
||||
World world = event.getWorld();
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
@@ -286,24 +273,28 @@ public class Botany extends AbstractMod {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!heldItem.isEmpty()) {
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
int py = -1;
|
||||
if (block instanceof IBlockSoil && (world.isAirBlock(pos.up()) || block.isReplaceable(world, pos))) {
|
||||
py = 1;
|
||||
}
|
||||
if (py >= 0) {
|
||||
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
|
||||
IFlower flower = flowerRoot.getConversion(heldItem);
|
||||
if (flower != null && flowerRoot.plant(world, pos.add(0, py, 0), flower, player.getGameProfile()) && !player.capabilities.isCreativeMode) {
|
||||
heldItem.shrink(1);
|
||||
}
|
||||
}
|
||||
if (heldItem.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
int py = -1;
|
||||
if (block instanceof IBlockSoil && (world.isAirBlock(pos.up()) || block.isReplaceable(world, pos))) {
|
||||
py = 1;
|
||||
}
|
||||
if (py < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
|
||||
IFlower flower = flowerRoot.getConversion(heldItem);
|
||||
if (flower != null && flowerRoot.plant(world, pos.add(0, py, 0), flower, player.getGameProfile()) && !player.capabilities.isCreativeMode) {
|
||||
heldItem.shrink(1);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onBonemeal(final BonemealEvent event) {
|
||||
public void onBonemeal(BonemealEvent event) {
|
||||
BlockPos pos = event.getPos();
|
||||
Block block = event.getBlock().getBlock();
|
||||
if (BotanyCore.getGardening().isSoil(block)) {
|
||||
@@ -312,6 +303,7 @@ public class Botany extends AbstractMod {
|
||||
event.setResult(Event.Result.ALLOW);
|
||||
}
|
||||
}
|
||||
|
||||
TileEntity tile = event.getWorld().getTileEntity(pos);
|
||||
if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).onBonemeal()) {
|
||||
event.setResult(Event.Result.ALLOW);
|
||||
|
||||
@@ -24,7 +24,7 @@ public class CreativeTabBotany extends CreativeTabs {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getTranslatedTabLabel() {
|
||||
return this.getTabLabel();
|
||||
return getTabLabel();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,7 +4,8 @@ import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public enum EnumAcidity implements IStringSerializable {
|
||||
ACID(TextFormatting.RED),
|
||||
@@ -20,13 +21,13 @@ 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;
|
||||
String localisedName = I18N.localise("botany.ph." + getName());
|
||||
if (withColor && color != null) {
|
||||
localisedName += color;
|
||||
}
|
||||
return localisedName;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -20,12 +20,12 @@ public enum EnumFlowerStage implements ISpeciesType {
|
||||
|
||||
public static EnumFlowerStage getStage(int age) {
|
||||
return age == 0
|
||||
? EnumFlowerStage.SEED
|
||||
: EnumFlowerStage.FLOWER;
|
||||
? EnumFlowerStage.SEED
|
||||
: EnumFlowerStage.FLOWER;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,7 +4,8 @@ import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public enum EnumMoisture implements IStringSerializable {
|
||||
DRY(TextFormatting.YELLOW),
|
||||
@@ -24,9 +25,9 @@ public enum EnumMoisture implements IStringSerializable {
|
||||
}
|
||||
|
||||
public String getLocalisedName(boolean withColor) {
|
||||
String localisedName = I18n.translateToLocal("botany.moisture." + getName());
|
||||
if(withColor && color != null){
|
||||
localisedName +=color;
|
||||
String localisedName = I18N.localise("botany.moisture." + getName());
|
||||
if (withColor && color != null) {
|
||||
localisedName += color;
|
||||
}
|
||||
return localisedName;
|
||||
}
|
||||
|
||||
@@ -1,30 +1,29 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
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;
|
||||
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public enum EnumSoilType implements IStringSerializable {
|
||||
SOIL(TextFormatting.DARK_GRAY),
|
||||
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.localise("botany.soil." + getName());
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ public class FlowerManager {
|
||||
* Used to create new flowers.
|
||||
*/
|
||||
public static IFlowerFactory flowerFactory;
|
||||
|
||||
|
||||
/**
|
||||
* Used to manager soil.
|
||||
*/
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -18,7 +18,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);
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
public interface IColorMix {
|
||||
IFlowerColor getColorFirst();
|
||||
|
||||
IFlowerColor getColorSecond();
|
||||
|
||||
boolean isMutation(IFlowerColor colorFirst, IFlowerColor colorSecond);
|
||||
|
||||
int getChance();
|
||||
|
||||
IFlowerColor getResult();
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
public interface IColourMix {
|
||||
IFlowerColour getColourFirst();
|
||||
|
||||
IFlowerColour getColourSecond();
|
||||
|
||||
boolean isMutation(IFlowerColour colourFirst, IFlowerColour colourSecond);
|
||||
|
||||
int getChance();
|
||||
|
||||
IFlowerColour getResult();
|
||||
}
|
||||
@@ -14,25 +14,25 @@ public interface IFlower extends IIndividual {
|
||||
@Nullable
|
||||
IFlowerGenome getMate();
|
||||
|
||||
void mate(final IFlower flower);
|
||||
void mate(IFlower flower);
|
||||
|
||||
int getAge();
|
||||
|
||||
void setAge(final int age);
|
||||
void setAge(int age);
|
||||
|
||||
void age();
|
||||
|
||||
IFlower getOffspring(final World world, final BlockPos pos);
|
||||
IFlower getOffspring(World world, BlockPos pos);
|
||||
|
||||
int getMaxAge();
|
||||
|
||||
boolean isWilted();
|
||||
|
||||
void setWilted(final boolean p0);
|
||||
void setWilted(boolean p0);
|
||||
|
||||
boolean hasFlowered();
|
||||
|
||||
void setFlowered(final boolean p0);
|
||||
void setFlowered(boolean p0);
|
||||
|
||||
void removeMate();
|
||||
}
|
||||
+3
-3
@@ -2,12 +2,12 @@ package binnie.botany.api;
|
||||
|
||||
import forestry.api.genetics.IAlleleInteger;
|
||||
|
||||
public interface IFlowerColour {
|
||||
int getColor(final boolean p0);
|
||||
public interface IFlowerColor {
|
||||
int getColor(boolean dis);
|
||||
|
||||
IAlleleInteger getAllele();
|
||||
|
||||
int getID();
|
||||
|
||||
String getColourName();
|
||||
String getColorName();
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -11,11 +11,11 @@ public interface IFlowerGenome extends IGenome {
|
||||
@Override
|
||||
IAlleleFlowerSpecies getSecondary();
|
||||
|
||||
IFlowerColour getPrimaryColor();
|
||||
IFlowerColor getPrimaryColor();
|
||||
|
||||
IFlowerColour getSecondaryColor();
|
||||
IFlowerColor getSecondaryColor();
|
||||
|
||||
IFlowerColour getStemColor();
|
||||
IFlowerColor getStemColor();
|
||||
|
||||
int getFertility();
|
||||
|
||||
@@ -33,9 +33,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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -12,57 +12,57 @@ import net.minecraft.world.World;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
|
||||
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);
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -35,16 +35,16 @@ import binnie.core.util.TileUtil;
|
||||
public class BlockCeramic extends Block implements IColoredBlock, IItemModelRegister {
|
||||
public BlockCeramic() {
|
||||
super(Material.ROCK);
|
||||
this.setHardness(1.0f);
|
||||
this.setResistance(5.0f);
|
||||
this.setRegistryName("ceramic");
|
||||
this.setCreativeTab(CreativeTabBotany.instance);
|
||||
setHardness(1.0f);
|
||||
setResistance(5.0f);
|
||||
setRegistryName("ceramic");
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
for (final EnumFlowerColor c : EnumFlowerColor.values()) {
|
||||
for (EnumFlowerColor c : EnumFlowerColor.values()) {
|
||||
manager.registerItemModel(item, c.ordinal());
|
||||
}
|
||||
}
|
||||
@@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
import binnie.botany.CreativeTabBotany;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.core.util.I18N;
|
||||
import binnie.extratrees.api.IDesign;
|
||||
import binnie.extratrees.carpentry.BlockDesign;
|
||||
import binnie.extratrees.carpentry.DesignBlock;
|
||||
@@ -13,19 +14,19 @@ import binnie.extratrees.carpentry.ModuleCarpentry;
|
||||
public class BlockCeramicPatterned extends BlockDesign {
|
||||
public BlockCeramicPatterned() {
|
||||
super(CeramicDesignSystem.instance, Material.ROCK);
|
||||
this.setHardness(1.0f);
|
||||
this.setResistance(5.0f);
|
||||
this.setCreativeTab(CreativeTabBotany.instance);
|
||||
this.setRegistryName("ceramicPattern");
|
||||
setHardness(1.0f);
|
||||
setResistance(5.0f);
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
setRegistryName("ceramicPattern");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCreativeStack(final IDesign design) {
|
||||
public ItemStack getCreativeStack(IDesign design) {
|
||||
return ModuleCarpentry.getItemStack(this, CeramicColor.get(EnumFlowerColor.White), CeramicColor.get(EnumFlowerColor.Black), design);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlockName(final DesignBlock design) {
|
||||
return design.getDesign().getName() + " Ceramic Block";
|
||||
public String getBlockName(DesignBlock design) {
|
||||
return I18N.localise("botany.ceramic.block.name", design.getDesign().getName());
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package binnie.botany.ceramic;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
@@ -44,17 +45,17 @@ import binnie.core.util.I18N;
|
||||
public class BlockStainedGlass extends Block implements IBlockMetadata, IColoredBlock, IItemModelRegister {
|
||||
public BlockStainedGlass() {
|
||||
super(Material.GLASS);
|
||||
this.setCreativeTab(CreativeTabBotany.instance);
|
||||
this.setRegistryName("stained");
|
||||
this.setSoundType(SoundType.GLASS);
|
||||
this.setHardness(0.3F);
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
setRegistryName("stained");
|
||||
setSoundType(SoundType.GLASS);
|
||||
setHardness(0.3F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(final Random rand) {
|
||||
public int quantityDropped(Random rand) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state) {
|
||||
return false;
|
||||
@@ -81,22 +82,22 @@ public class BlockStainedGlass extends Block implements IBlockMetadata, IColored
|
||||
Block block = iblockstate.getBlock();
|
||||
return block != this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack stack) {
|
||||
player.addStat(StatList.getBlockStats(this));
|
||||
player.addExhaustion(0.005F);
|
||||
|
||||
|
||||
if (EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, stack) > 0 && te instanceof TileEntityMetadata) {
|
||||
java.util.List<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);
|
||||
@@ -110,7 +111,7 @@ public class BlockStainedGlass extends Block implements IBlockMetadata, IColored
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(final World var1, final int i) {
|
||||
public TileEntity createNewTileEntity(World var1, int i) {
|
||||
return new TileEntityMetadata();
|
||||
}
|
||||
|
||||
@@ -126,7 +127,7 @@ public class BlockStainedGlass extends Block implements IBlockMetadata, IColored
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlacedMeta(final ItemStack stack, final World world, final BlockPos pos, final EnumFacing clickedBlock) {
|
||||
public int getPlacedMeta(ItemStack stack, World world, BlockPos pos, EnumFacing clickedBlock) {
|
||||
return TileEntityMetadata.getItemDamage(stack);
|
||||
}
|
||||
|
||||
@@ -136,15 +137,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 +179,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);
|
||||
}
|
||||
}
|
||||
@@ -14,24 +14,24 @@ 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(Botany.gardening().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);
|
||||
}
|
||||
}
|
||||
@@ -30,8 +30,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 +46,12 @@ public class CeramicDesignSystem implements IDesignSystem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDesignMaterial getMaterial(final int id) {
|
||||
public IDesignMaterial getMaterial(int id) {
|
||||
return CeramicColor.get(EnumFlowerColor.get(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaterialIndex(final IDesignMaterial id) {
|
||||
public int getMaterialIndex(IDesignMaterial id) {
|
||||
return ((CeramicColor) id).color.ordinal();
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class CeramicDesignSystem implements IDesignSystem {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getPrimarySprite(IPattern pattern) {
|
||||
if (pattern instanceof EnumPattern) {
|
||||
return this.primary.get(((EnumPattern) pattern).ordinal());
|
||||
return primary.get(((EnumPattern) pattern).ordinal());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -74,7 +74,7 @@ public class CeramicDesignSystem implements IDesignSystem {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getSecondarySprite(IPattern pattern) {
|
||||
if (pattern instanceof EnumPattern) {
|
||||
return this.secondary.get(((EnumPattern) pattern).ordinal());
|
||||
return secondary.get(((EnumPattern) pattern).ordinal());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -86,8 +86,8 @@ public class CeramicDesignSystem implements IDesignSystem {
|
||||
for (EnumPattern pattern : EnumPattern.values()) {
|
||||
ResourceLocation primaryLocation = new ResourceLocation(getMod().getModID(), getTexturePath() + "/" + pattern.toString().toLowerCase() + ".0");
|
||||
ResourceLocation secondaryLocation = new ResourceLocation(getMod().getModID(), getTexturePath() + "/" + pattern.toString().toLowerCase() + ".1");
|
||||
this.primary.put(pattern.ordinal(), textureMap.registerSprite(primaryLocation));
|
||||
this.secondary.put(pattern.ordinal(), textureMap.registerSprite(secondaryLocation));
|
||||
primary.put(pattern.ordinal(), textureMap.registerSprite(primaryLocation));
|
||||
secondary.put(pattern.ordinal(), textureMap.registerSprite(secondaryLocation));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,12 +97,14 @@ public class CeramicDesignSystem implements IDesignSystem {
|
||||
|
||||
@Override
|
||||
public ItemStack getAdhesive() {
|
||||
return BotanyItems.Mortar.get(1);
|
||||
return BotanyItems.MORTAR.get(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IDesignMaterial getMaterial(final ItemStack itemStack) {
|
||||
return (itemStack.getItem() == Item.getItemFromBlock(Botany.ceramic)) ? this.getMaterial(itemStack.getItemDamage()) : null;
|
||||
public IDesignMaterial getMaterial(ItemStack itemStack) {
|
||||
return (itemStack.getItem() == Item.getItemFromBlock(Botany.gardening().ceramic))
|
||||
? getMaterial(itemStack.getItemDamage())
|
||||
: null;
|
||||
}
|
||||
}
|
||||
@@ -3,41 +3,49 @@ package binnie.botany.ceramic;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import binnie.Constants;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.ceramic.brick.CeramicBrickType;
|
||||
import binnie.botany.gardening.ModuleGardening;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
|
||||
public class CeramicTileRecipe implements IRecipe {
|
||||
private ItemStack cached = ItemStack.EMPTY;
|
||||
public class CeramicTileRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe { private ItemStack cached = ItemStack.EMPTY;
|
||||
|
||||
@Override
|
||||
public boolean matches(final InventoryCrafting inv, final World world) {
|
||||
this.cached = this.getCraftingResult(inv);
|
||||
return !this.cached.isEmpty();
|
||||
public CeramicTileRecipe() {
|
||||
setRegistryName(new ResourceLocation(Constants.BOTANY_MOD_ID, "ceramic_tile"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(final InventoryCrafting inv) {
|
||||
final Item ceramicBlock = Item.getItemFromBlock(Botany.ceramic);
|
||||
final Item ceramicTile = Item.getItemFromBlock(Botany.ceramicTile);
|
||||
final Item ceramicBrick = Item.getItemFromBlock(Botany.ceramicBrick);
|
||||
final Item mortar = Botany.misc;
|
||||
final List<ItemStack> stacks = new ArrayList<>();
|
||||
public boolean matches(InventoryCrafting inv, World world) {
|
||||
cached = getCraftingResult(inv);
|
||||
return !cached.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(InventoryCrafting inv) {
|
||||
ModuleGardening gardening = Botany.gardening();
|
||||
Item ceramicBlock = Item.getItemFromBlock(gardening.ceramic);
|
||||
Item ceramicTile = Item.getItemFromBlock(gardening.ceramicTile);
|
||||
Item ceramicBrick = Item.getItemFromBlock(gardening.ceramicBrick);
|
||||
Item mortar = gardening.misc;
|
||||
List<ItemStack> stacks = new ArrayList<>();
|
||||
int ix = -1;
|
||||
int iy = -1;
|
||||
for (int i = 0; i < inv.getSizeInventory(); ++i) {
|
||||
final ItemStack stack = inv.getStackInSlot(i);
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
if (!stack.isEmpty()) {
|
||||
final int x = i / 3;
|
||||
final int y = i % 3;
|
||||
int x = i / 3;
|
||||
int y = i % 3;
|
||||
if (ix == -1) {
|
||||
ix = x;
|
||||
iy = y;
|
||||
@@ -61,13 +69,13 @@ public class CeramicTileRecipe implements IRecipe {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeSize() {
|
||||
return 2;
|
||||
public boolean canFit(int width, int height) {
|
||||
return width >= 2 && height >= 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return this.cached;
|
||||
return cached;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,7 +2,6 @@ package binnie.botany.ceramic;
|
||||
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@@ -10,6 +9,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import forestry.core.items.IColoredItem;
|
||||
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public class ItemCeramic extends ItemBlock implements IColoredItem {
|
||||
public ItemCeramic(BlockCeramic block) {
|
||||
@@ -17,19 +17,21 @@ public class ItemCeramic extends ItemBlock implements IColoredItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(final int metadata) {
|
||||
public int getMetadata(int metadata) {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
|
||||
return EnumFlowerColor.get(stack.getMetadata()).getFlowerColorAllele().getColor(false);
|
||||
EnumFlowerColor color = EnumFlowerColor.get(stack.getItemDamage());
|
||||
return color.getFlowerColorAllele().getColor(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getItemStackDisplayName(ItemStack itemStack) {
|
||||
return EnumFlowerColor.get(itemStack.getItemDamage()).getFlowerColorAllele().getColourName() + " " + I18n.translateToLocal("tile.botany.ceramic.name").trim();
|
||||
EnumFlowerColor color = EnumFlowerColor.get(itemStack.getItemDamage());
|
||||
return I18N.localise("botany.ceramic.name", color.getDisplayName());
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ public class ItemStainedGlass extends ItemMetadata implements IColoredItem {
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
|
||||
return EnumFlowerColor.get(TileEntityMetadata.getItemDamage(stack)).getFlowerColorAllele().getColor(false);
|
||||
EnumFlowerColor color = EnumFlowerColor.get(TileEntityMetadata.getItemDamage(stack));
|
||||
return color.getFlowerColorAllele().getColor(false);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,24 @@
|
||||
package binnie.botany.ceramic;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.Constants;
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.api.IFlower;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
public class PigmentRecipe extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe {
|
||||
public PigmentRecipe() {
|
||||
setRegistryName(new ResourceLocation(Constants.BOTANY_MOD_ID, "pigment"));
|
||||
}
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.api.IFlower;
|
||||
|
||||
public class PigmentRecipe implements IRecipe {
|
||||
@Override
|
||||
public boolean matches(final InventoryCrafting crafting, final World world) {
|
||||
return !this.getCraftingResult(crafting).isEmpty();
|
||||
public boolean matches(InventoryCrafting crafting, World world) {
|
||||
return !getCraftingResult(crafting).isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -24,7 +27,7 @@ public class PigmentRecipe implements IRecipe {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(final InventoryCrafting crafting) {
|
||||
public ItemStack getCraftingResult(InventoryCrafting crafting) {
|
||||
int n = 0;
|
||||
ItemStack stack = ItemStack.EMPTY;
|
||||
for (int i = 0; i < crafting.getSizeInventory(); ++i) {
|
||||
@@ -34,9 +37,9 @@ public class PigmentRecipe implements IRecipe {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
if (Binnie.GENETICS.getFlowerRoot().isMember(stackInSlot)) {
|
||||
final IFlower flower = Binnie.GENETICS.getFlowerRoot().getMember(stackInSlot);
|
||||
IFlower flower = Binnie.GENETICS.getFlowerRoot().getMember(stackInSlot);
|
||||
if (flower != null && flower.getAge() >= 1) {
|
||||
stack = new ItemStack(Botany.pigment, 1, flower.getGenome().getPrimaryColor().getID());
|
||||
stack = new ItemStack(Botany.gardening().pigment, 1, flower.getGenome().getPrimaryColor().getID());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,12 +48,7 @@ public class PigmentRecipe implements IRecipe {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeSize() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) {
|
||||
return ForgeHooks.defaultRecipeGetRemainingItems(inv);
|
||||
public boolean canFit(int width, int height) {
|
||||
return width >= 1 && height >= 1;
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,6 @@ public class TileCeramic extends TileEntity {
|
||||
if (color != null) {
|
||||
ID = color.getFlowerColorAllele().getID();
|
||||
}
|
||||
return new ItemStack(Botany.ceramic, amount, ID);
|
||||
return new ItemStack(Botany.gardening().ceramic, amount, ID);
|
||||
}
|
||||
}
|
||||
@@ -66,10 +66,10 @@ 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
|
||||
@@ -103,20 +103,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 +124,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 +139,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 +166,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 +202,7 @@ public class BlockCeramicBrick extends Block implements IMultipassBlock<CeramicB
|
||||
}
|
||||
}
|
||||
}
|
||||
return 16777215;
|
||||
return 0xffffff;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -4,51 +4,66 @@ 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.Botany;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.core.block.TileEntityMetadata;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public class CeramicBrickPair {
|
||||
EnumFlowerColor colorFirst;
|
||||
EnumFlowerColor colorSecond;
|
||||
CeramicBrickType type;
|
||||
int ordinal;
|
||||
public static final CeramicBrickPair EMPTY = new CeramicBrickPair(EnumFlowerColor.DarkSeaGreen, EnumFlowerColor.DarkSeaGreen, CeramicBrickType.TILE);
|
||||
|
||||
CeramicBrickPair(final EnumFlowerColor colorFirst, final EnumFlowerColor colorSecond, CeramicBrickType type) {
|
||||
public final EnumFlowerColor colorFirst;
|
||||
public final EnumFlowerColor colorSecond;
|
||||
|
||||
public CeramicBrickType type;
|
||||
public int ordinal;
|
||||
|
||||
CeramicBrickPair(EnumFlowerColor colorFirst, EnumFlowerColor colorSecond, CeramicBrickType type) {
|
||||
this.colorFirst = colorFirst;
|
||||
this.colorSecond = colorSecond;
|
||||
this.type = type;
|
||||
this.ordinal = colorFirst.ordinal() + colorSecond.ordinal() * 256 + type.ordinal() * 256 * 256;
|
||||
ordinal = colorFirst.ordinal() + colorSecond.ordinal() * 256 + type.ordinal() * 256 * 256;
|
||||
}
|
||||
|
||||
public CeramicBrickPair(ItemStack stack) {
|
||||
this(TileEntityMetadata.getItemDamage(stack));
|
||||
this(getId(stack));
|
||||
}
|
||||
|
||||
public CeramicBrickPair(int id) {
|
||||
this.colorFirst = EnumFlowerColor.get(id & 0xFF);
|
||||
this.colorSecond = EnumFlowerColor.get(id >> 8 & 0xFF);
|
||||
this.type = CeramicBrickType.get(id >> 16 & 0xFF);
|
||||
colorFirst = EnumFlowerColor.get(id & 0xFF);
|
||||
colorSecond = EnumFlowerColor.get(id >> 8 & 0xFF);
|
||||
type = CeramicBrickType.get(id >> 16 & 0xFF);
|
||||
}
|
||||
|
||||
public boolean isTwoColors() {
|
||||
return this.type.canDouble() && this.colorSecond != this.colorFirst;
|
||||
return type.canDouble() && colorSecond != colorFirst;
|
||||
}
|
||||
|
||||
public static int getId(ItemStack stack){
|
||||
if(!stack.hasTagCompound()){
|
||||
return EMPTY.ordinal();
|
||||
}
|
||||
NBTTagCompound nbtTagCompound = stack.getTagCompound();
|
||||
return nbtTagCompound.getInteger("id");
|
||||
}
|
||||
|
||||
public ItemStack getStack(int i) {
|
||||
return new ItemStack(Botany.ceramicBrick, i, this.ordinal());
|
||||
ItemStack stack = new ItemStack(Botany.gardening().ceramicBrick, i);
|
||||
stack.setTagInfo("id", new NBTTagInt(ordinal()));
|
||||
return stack;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
String name = this.colorFirst.getFlowerColorAllele().getColourName();
|
||||
if (this.type.canDouble() && this.colorSecond != this.colorFirst) {
|
||||
name = name + " & " + this.colorSecond.getFlowerColorAllele().getColourName();
|
||||
String name = colorFirst.getFlowerColorAllele().getColorName();
|
||||
if (type.canDouble() && colorSecond != colorFirst) {
|
||||
name = name + " & " + colorSecond.getFlowerColorAllele().getColorName();
|
||||
}
|
||||
return name + " " + this.type.name;
|
||||
return I18N.localise("botany.ceramic.type." + type.id + ".name", name);
|
||||
}
|
||||
|
||||
public int ordinal() {
|
||||
@@ -57,19 +72,19 @@ public class CeramicBrickPair {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getSprite(int pass) {
|
||||
TextureAtlasSprite[] sprites = this.type.sprites;
|
||||
TextureAtlasSprite[] sprites = type.sprites;
|
||||
Preconditions.checkState(sprites != null, "Sprites have not been registered.");
|
||||
return sprites[pass];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Integer.hashCode(ordinal());
|
||||
return Integer.hashCode(type.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof CeramicBrickPair
|
||||
&& ((CeramicBrickPair) obj).ordinal() == ordinal();
|
||||
&& ((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;
|
||||
@@ -18,7 +17,7 @@ import binnie.botany.items.BotanyItems;
|
||||
import binnie.core.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(Botany.gardening().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(Botany.gardening().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(Botany.gardening().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(Botany.gardening().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(Botany.gardening().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;
|
||||
|
||||
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(Botany.gardening().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() == Botany.gardening().misc && stack.getItemDamage() == BotanyItems.MORTAR.ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -14,14 +14,14 @@ public class ItemCeramicBrick extends ItemBlock implements IColoredItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(final int metadata) {
|
||||
public int getMetadata(int metadata) {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
|
||||
CeramicBrickPair ceramic = new CeramicBrickPair(stack.getItemDamage());
|
||||
CeramicBrickPair ceramic = new CeramicBrickPair(stack);
|
||||
if (tintIndex == 1) {
|
||||
return ceramic.colorFirst.getFlowerColorAllele().getColor(false);
|
||||
} else if (tintIndex == 2) {
|
||||
@@ -33,6 +33,6 @@ public class ItemCeramicBrick extends ItemBlock implements IColoredItem {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getItemStackDisplayName(ItemStack itemStack) {
|
||||
return new CeramicBrickPair(itemStack.getItemDamage()).getName();
|
||||
return new CeramicBrickPair(itemStack).getName();
|
||||
}
|
||||
}
|
||||
@@ -18,26 +18,17 @@ public class TileCeramicBrick extends TileEntity {
|
||||
}
|
||||
|
||||
public boolean hasTwoColors() {
|
||||
return CeramicBrickType.VALUES[getBlockMetadata()].canDouble() && this.colorSecond != this.colorFirst;
|
||||
return CeramicBrickType.VALUES[getBlockMetadata()].canDouble() && colorSecond != colorFirst;
|
||||
}
|
||||
|
||||
public ItemStack getStack(final int i) {
|
||||
final ItemStack s = TileEntityMetadata.getItemStack(Botany.ceramicBrick, this.ordinal());
|
||||
public ItemStack getStack(int i) {
|
||||
ItemStack s = TileEntityMetadata.getItemStack(Botany.gardening().ceramicBrick, ordinal());
|
||||
s.setCount(i);
|
||||
return s;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
CeramicBrickType type = CeramicBrickType.VALUES[getBlockMetadata()];
|
||||
String name = this.colorFirst.getFlowerColorAllele().getColourName();
|
||||
if (type.canDouble() && this.colorSecond != this.colorFirst) {
|
||||
name = name + " & " + this.colorSecond.getFlowerColorAllele().getColourName();
|
||||
}
|
||||
return name + " " + type.name;
|
||||
}
|
||||
|
||||
public int ordinal() {
|
||||
return this.colorFirst.ordinal() + this.colorSecond.ordinal() * 256 + getBlockMetadata() * 256 * 256;
|
||||
return colorFirst.ordinal() + colorSecond.ordinal() * 256 + getBlockMetadata() * 256 * 256;
|
||||
}
|
||||
|
||||
public CeramicBrickPair pair() {
|
||||
@@ -70,6 +61,7 @@ public class TileCeramicBrick extends TileEntity {
|
||||
if (compound.hasKey("First")) {
|
||||
colorFirst = EnumFlowerColor.VALUES[compound.getInteger("First")];
|
||||
}
|
||||
|
||||
if (compound.hasKey("Second")) {
|
||||
colorSecond = EnumFlowerColor.VALUES[compound.getInteger("Second")];
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ public class BotanyCore {
|
||||
}
|
||||
return FlowerManager.flowerRoot;
|
||||
}
|
||||
|
||||
public static IGardeningManager getGardening(){
|
||||
|
||||
public static IGardeningManager getGardening() {
|
||||
if (FlowerManager.gardening == null) {
|
||||
FlowerManager.gardening = new Gardening();
|
||||
}
|
||||
|
||||
@@ -8,26 +8,26 @@ import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import binnie.botany.craftgui.WindowBotanistDatabase;
|
||||
import binnie.core.craftgui.minecraft.Window;
|
||||
import binnie.botany.gui.database.WindowBotanistDatabase;
|
||||
import binnie.core.gui.IBinnieGUID;
|
||||
import binnie.core.gui.minecraft.Window;
|
||||
|
||||
public enum BotanyGUI implements IBinnieGUID {
|
||||
Database,
|
||||
DatabaseNEI;
|
||||
DATABASE,
|
||||
DATABASE_NEI;
|
||||
|
||||
@Override
|
||||
public Window getWindow(final EntityPlayer player, final World world, final int x, final int y, final int z, final Side side) {
|
||||
public Window getWindow(EntityPlayer player, World world, int x, int y, int z, Side side) {
|
||||
Window window = null;
|
||||
final TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z));
|
||||
TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z));
|
||||
IInventory object = null;
|
||||
if (tileEntity instanceof IInventory) {
|
||||
object = (IInventory) tileEntity;
|
||||
}
|
||||
switch (this) {
|
||||
case Database:
|
||||
case DatabaseNEI: {
|
||||
window = WindowBotanistDatabase.create(player, side, this != BotanyGUI.Database);
|
||||
case DATABASE:
|
||||
case DATABASE_NEI: {
|
||||
window = WindowBotanistDatabase.create(player, side, this != BotanyGUI.DATABASE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
package binnie.botany.core;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.botany.Botany;
|
||||
import binnie.core.resource.BinnieResource;
|
||||
import binnie.core.resource.IBinnieTexture;
|
||||
import binnie.core.resource.ResourceType;
|
||||
|
||||
public enum BotanyTexture implements IBinnieTexture {
|
||||
;
|
||||
String texture;
|
||||
ResourceType type;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Nullable
|
||||
private BinnieResource resource;
|
||||
|
||||
BotanyTexture(final ResourceType base, final String texture) {
|
||||
this.texture = texture;
|
||||
this.type = base;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public BinnieResource getTexture() {
|
||||
if (resource == null) {
|
||||
resource = Binnie.RESOURCE.getPNG(Botany.instance, this.type, this.texture);
|
||||
}
|
||||
return resource;
|
||||
}
|
||||
}
|
||||
@@ -5,13 +5,16 @@ import binnie.core.IInitializable;
|
||||
public class ModuleCore implements IInitializable {
|
||||
@Override
|
||||
public void preInit() {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import binnie.botany.api.IFlowerColour;
|
||||
import binnie.core.craftgui.Attribute;
|
||||
import binnie.core.craftgui.ITooltip;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.Tooltip;
|
||||
import binnie.core.craftgui.controls.core.Control;
|
||||
import binnie.core.craftgui.controls.core.IControlValue;
|
||||
import binnie.core.craftgui.renderer.RenderUtil;
|
||||
|
||||
public class ControlColourDisplay extends Control implements IControlValue<IFlowerColour>, ITooltip {
|
||||
private IFlowerColour value;
|
||||
|
||||
public ControlColourDisplay(final IWidget parent, final int x, final int y, final IFlowerColour value) {
|
||||
super(parent, x, y, 16, 16);
|
||||
this.value = value;
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlowerColour getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(final IFlowerColour value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onRenderBackground(int guiWidth, int guiHeight) {
|
||||
RenderUtil.drawSolidRect(this.getArea(), -1);
|
||||
RenderUtil.drawSolidRect(this.getArea().inset(1), -16777216 + this.getValue().getColor(false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
super.getTooltip(tooltip);
|
||||
tooltip.add(this.value.getColourName());
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import binnie.botany.api.IColourMix;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.controls.listbox.ControlListBox;
|
||||
|
||||
public class ControlColourMixBox extends ControlListBox<IColourMix> {
|
||||
private int index;
|
||||
private Type type;
|
||||
|
||||
public ControlColourMixBox(final IWidget parent, final int x, final int y, final int width, final int height, final Type type) {
|
||||
super(parent, x, y, width, height, 12);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWidget createOption(final IColourMix value, final int y) {
|
||||
return new ControlColourMixItem(this.getContent(), value, y);
|
||||
}
|
||||
|
||||
enum Type {
|
||||
Resultant,
|
||||
Further,
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import binnie.botany.api.IColourMix;
|
||||
import binnie.core.craftgui.controls.listbox.ControlList;
|
||||
import binnie.core.craftgui.controls.listbox.ControlOption;
|
||||
|
||||
public class ControlColourMixItem extends ControlOption<IColourMix> {
|
||||
private final ControlColourDisplay itemWidget1;
|
||||
private final ControlColourDisplay itemWidget2;
|
||||
private final ControlColourDisplay itemWidget3;
|
||||
private final ControlColourMixSymbol addSymbol;
|
||||
private final ControlColourMixSymbol arrowSymbol;
|
||||
|
||||
public ControlColourMixItem(final ControlList<IColourMix> controlList, final IColourMix option, final int y) {
|
||||
super(controlList, option, y);
|
||||
IColourMix value = this.getValue();
|
||||
this.itemWidget1 = new ControlColourDisplay(this, 4, 4, value.getColourFirst());
|
||||
this.itemWidget2 = new ControlColourDisplay(this, 44, 4, value.getColourSecond());
|
||||
this.itemWidget3 = new ControlColourDisplay(this, 104, 4, value.getResult());
|
||||
this.addSymbol = new ControlColourMixSymbol(this, 24, 4, 0, value);
|
||||
this.arrowSymbol = new ControlColourMixSymbol(this, 64, 4, 1, value);
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import binnie.botany.api.IColourMix;
|
||||
import binnie.core.craftgui.Attribute;
|
||||
import binnie.core.craftgui.CraftGUI;
|
||||
import binnie.core.craftgui.ITooltip;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.Tooltip;
|
||||
import binnie.core.craftgui.controls.core.Control;
|
||||
import binnie.core.craftgui.geometry.Point;
|
||||
import binnie.core.craftgui.resource.Texture;
|
||||
import binnie.core.craftgui.resource.minecraft.CraftGUITextureSheet;
|
||||
import binnie.core.craftgui.resource.minecraft.StandardTexture;
|
||||
|
||||
public class ControlColourMixSymbol extends Control implements ITooltip {
|
||||
static Texture MutationPlus = new StandardTexture(2, 94, 16, 16, CraftGUITextureSheet.Controls2);
|
||||
static Texture MutationArrow = new StandardTexture(20, 94, 32, 16, CraftGUITextureSheet.Controls2);
|
||||
IColourMix value;
|
||||
int type;
|
||||
|
||||
protected ControlColourMixSymbol(final IWidget parent, final int x, final int y, final int type, final IColourMix value) {
|
||||
super(parent, x, y, 16 + type * 16, 16);
|
||||
this.value = value;
|
||||
this.type = type;
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onRenderBackground(int guiWidth, int guiHeight) {
|
||||
super.onRenderBackground(guiWidth, guiHeight);
|
||||
if (this.type == 0) {
|
||||
CraftGUI.render.texture(ControlColourMixSymbol.MutationPlus, Point.ZERO);
|
||||
} else {
|
||||
CraftGUI.render.texture(ControlColourMixSymbol.MutationArrow, Point.ZERO);
|
||||
}
|
||||
}
|
||||
|
||||
public void setValue(final IColourMix value) {
|
||||
this.value = value;
|
||||
this.setColour(0xffffff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
if (this.type == 1) {
|
||||
final float chance = this.value.getChance();
|
||||
tooltip.add("Current Chance - " + chance + "%");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import binnie.botany.api.IFlowerColour;
|
||||
import binnie.core.craftgui.Attribute;
|
||||
import binnie.core.craftgui.CraftGUI;
|
||||
import binnie.core.craftgui.controls.listbox.ControlList;
|
||||
import binnie.core.craftgui.controls.listbox.ControlTextOption;
|
||||
import binnie.core.craftgui.geometry.CraftGUIUtil;
|
||||
import binnie.core.craftgui.geometry.Point;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ControlColourOption extends ControlTextOption<IFlowerColour> {
|
||||
ControlColourDisplay controlBee;
|
||||
Point boxPosition;
|
||||
|
||||
public ControlColourOption(final ControlList<IFlowerColour> controlList, final IFlowerColour option, final int y) {
|
||||
super(controlList, option, option.getColourName(), y);
|
||||
this.setSize(new Point(this.getSize().x(), 20));
|
||||
this.controlBee = new ControlColourDisplay(this, 2, 2, option);
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
CraftGUIUtil.moveWidget(this.textWidget, new Point(22, 0));
|
||||
this.textWidget.setSize(this.textWidget.getSize().sub(new Point(24, 0)));
|
||||
final int th = CraftGUI.render.textHeight(this.textWidget.getValue(), this.textWidget.getSize().x());
|
||||
final int height = Math.max(20, th + 6);
|
||||
this.setSize(new Point(this.size().x(), height));
|
||||
this.textWidget.setSize(new Point(this.textWidget.getSize().x(), height));
|
||||
this.boxPosition = new Point(2, (height - 18) / 2);
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import binnie.botany.api.IColourMix;
|
||||
import binnie.botany.api.IFlowerColour;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.controls.ControlText;
|
||||
import binnie.core.craftgui.controls.ControlTextCentered;
|
||||
import binnie.core.craftgui.database.DatabaseTab;
|
||||
import binnie.core.craftgui.database.PageAbstract;
|
||||
|
||||
public class PageColourMix extends PageAbstract<IFlowerColour> {
|
||||
ControlText pageSpeciesFurther_Title;
|
||||
ControlColourMixBox pageSpeciesFurther_List;
|
||||
|
||||
public PageColourMix(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
this.pageSpeciesFurther_Title = new ControlTextCentered(this, 8, "Further Mixes");
|
||||
this.pageSpeciesFurther_List = new ControlColourMixBox(this, 4, 20, 136, 152, ControlColourMixBox.Type.Further);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(final IFlowerColour colour) {
|
||||
final List<IColourMix> mixes = new ArrayList<>();
|
||||
for (final IColourMix mix : BotanyCore.getFlowerRoot().getColourMixes(false)) {
|
||||
if (mix.getColourFirst() == colour || mix.getColourSecond() == colour) {
|
||||
mixes.add(mix);
|
||||
}
|
||||
}
|
||||
this.pageSpeciesFurther_List.setOptions(mixes);
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import binnie.botany.api.IColourMix;
|
||||
import binnie.botany.api.IFlowerColour;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.controls.ControlText;
|
||||
import binnie.core.craftgui.controls.ControlTextCentered;
|
||||
import binnie.core.craftgui.database.DatabaseTab;
|
||||
import binnie.core.craftgui.database.PageAbstract;
|
||||
|
||||
public class PageColourMixResultant extends PageAbstract<IFlowerColour> {
|
||||
ControlText pageSpeciesFurther_Title;
|
||||
ControlColourMixBox pageSpeciesFurther_List;
|
||||
|
||||
public PageColourMixResultant(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
this.pageSpeciesFurther_Title = new ControlTextCentered(this, 8, "Resultant Mixes");
|
||||
this.pageSpeciesFurther_List = new ControlColourMixBox(this, 4, 20, 136, 152, ControlColourMixBox.Type.Resultant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(final IFlowerColour colour) {
|
||||
final List<IColourMix> mixes = new ArrayList<>();
|
||||
for (final IColourMix mix : BotanyCore.getFlowerRoot().getColourMixes(false)) {
|
||||
if (mix.getResult() == colour) {
|
||||
mixes.add(mix);
|
||||
}
|
||||
}
|
||||
this.pageSpeciesFurther_List.setOptions(mixes);
|
||||
}
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.botany.api.EnumFlowerChromosome;
|
||||
import binnie.botany.api.EnumFlowerStage;
|
||||
import binnie.botany.api.IAlleleFlowerSpecies;
|
||||
import binnie.botany.api.IFlower;
|
||||
import binnie.botany.api.IFlowerGenome;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.controls.ControlText;
|
||||
import binnie.core.craftgui.controls.core.Control;
|
||||
import binnie.core.craftgui.controls.scroll.ControlScrollableContent;
|
||||
import binnie.core.craftgui.database.DatabaseTab;
|
||||
import binnie.core.craftgui.database.PageSpecies;
|
||||
import binnie.core.craftgui.geometry.Area;
|
||||
import binnie.core.craftgui.geometry.Point;
|
||||
import binnie.core.craftgui.geometry.TextJustification;
|
||||
import binnie.core.craftgui.minecraft.control.ControlItemDisplay;
|
||||
|
||||
public class PageSpeciesFlowerGenome extends PageSpecies {
|
||||
public PageSpeciesFlowerGenome(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
}
|
||||
|
||||
public static String tolerated(final boolean t) {
|
||||
if (t) {
|
||||
return "Tolerated";
|
||||
}
|
||||
return "Not Tolerated";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(final IAlleleSpecies species) {
|
||||
this.deleteAllChildren();
|
||||
final IAllele[] template = Binnie.GENETICS.getFlowerRoot().getTemplate(species.getUID());
|
||||
if (template == null) {
|
||||
return;
|
||||
}
|
||||
final IFlower tree = Binnie.GENETICS.getFlowerRoot().templateAsIndividual(template);
|
||||
if (tree == null) {
|
||||
return;
|
||||
}
|
||||
final IFlowerGenome genome = tree.getGenome();
|
||||
final IAlleleFlowerSpecies treeSpecies = genome.getPrimary();
|
||||
final int w = 144;
|
||||
final int h = 176;
|
||||
new ControlText(this, new Area(0, 4, w, 16), "Genome", TextJustification.MiddleCenter);
|
||||
final ControlScrollableContent scrollable = new ControlScrollableContent(this, 4, 20, w - 8, h - 8 - 16, 12);
|
||||
final Control contents = new Control(scrollable, 0, 0, w - 8 - 12, h - 8 - 16);
|
||||
final int tw = w - 8 - 12;
|
||||
final int w2 = 55;
|
||||
final int w3 = tw - 50;
|
||||
int y = 0;
|
||||
final int th = 14;
|
||||
final int th2 = 18;
|
||||
new ControlText(contents, new Area(0, y, w2, th), "Temp. : ", TextJustification.MiddleRight);
|
||||
new ControlText(contents, new Area(w2, y, w3, th), treeSpecies.getTemperature().getName(), TextJustification.MIDDLE_LEFTt);
|
||||
y += th;
|
||||
new ControlText(contents, new Area(0, y, w2, th), "Moist. : ", TextJustification.MiddleRight);
|
||||
new ControlText(contents, new Area(w2, y, w3, th), treeSpecies.getMoisture().getLocalisedName(false), TextJustification.MIDDLE_LEFTt);
|
||||
y += th;
|
||||
new ControlText(contents, new Area(0, y, w2, th), "pH. : ", TextJustification.MiddleRight);
|
||||
new ControlText(contents, new Area(w2, y, w3, th), treeSpecies.getPH().getLocalisedName(false), TextJustification.MIDDLE_LEFTt);
|
||||
y += th;
|
||||
new ControlText(contents, new Area(0, y, w2, th), "Fertility : ", TextJustification.MiddleRight);
|
||||
new ControlText(contents, new Area(w2, y, w3, th), genome.getFertility() + "x", TextJustification.MIDDLE_LEFTt);
|
||||
y += th;
|
||||
final float lifespan = genome.getLifespan() * 68.27f / genome.getAgeChance() / 24000.0f;
|
||||
new ControlText(contents, new Area(0, y, w2, th), "Lifespan : ", TextJustification.MiddleRight);
|
||||
new ControlText(contents, new Area(w2, y, w3, th), "" + String.format("%.2f", lifespan) + " days", TextJustification.MIDDLE_LEFTt);
|
||||
y += th;
|
||||
new ControlText(contents, new Area(0, y, w2, th), "Nectar : ", TextJustification.MiddleRight);
|
||||
new ControlText(contents, new Area(w2, y, w3, th), genome.getActiveAllele(EnumFlowerChromosome.SAPPINESS).getName(), TextJustification.MIDDLE_LEFTt);
|
||||
y += th;
|
||||
int x = w2;
|
||||
int tot = 0;
|
||||
for (final IIndividual vid : BotanyCore.getFlowerRoot().getIndividualTemplates()) {
|
||||
if (vid.getGenome().getPrimary() == treeSpecies) {
|
||||
if (tot > 0 && tot % 3 == 0) {
|
||||
x -= 54;
|
||||
y += 18;
|
||||
}
|
||||
final ItemStack stack = BotanyCore.getFlowerRoot().getMemberStack(vid, EnumFlowerStage.FLOWER);
|
||||
final ControlItemDisplay display = new ControlItemDisplay(contents, x, y);
|
||||
display.setItemStack(stack);
|
||||
++tot;
|
||||
x += 18;
|
||||
}
|
||||
}
|
||||
final int numOfLines = 1 + (tot - 1) / 3;
|
||||
new ControlText(contents, new Area(0, y - (numOfLines - 1) * 18, w2, 4 + 18 * numOfLines), "Varieties : ", TextJustification.MiddleRight);
|
||||
y += th;
|
||||
contents.setSize(new Point(contents.size().x(), y));
|
||||
scrollable.setScrollableContent(contents);
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.api.IFlowerColour;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.core.AbstractMod;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.controls.listbox.ControlListBox;
|
||||
import binnie.core.craftgui.database.DatabaseTab;
|
||||
import binnie.core.craftgui.database.IDatabaseMode;
|
||||
import binnie.core.craftgui.database.PageBranchOverview;
|
||||
import binnie.core.craftgui.database.PageBranchSpecies;
|
||||
import binnie.core.craftgui.database.PageBreeder;
|
||||
import binnie.core.craftgui.database.PageSpeciesClassification;
|
||||
import binnie.core.craftgui.database.PageSpeciesMutations;
|
||||
import binnie.core.craftgui.database.PageSpeciesOverview;
|
||||
import binnie.core.craftgui.database.PageSpeciesResultant;
|
||||
import binnie.core.craftgui.database.WindowAbstractDatabase;
|
||||
import binnie.core.craftgui.geometry.Area;
|
||||
import binnie.core.craftgui.minecraft.Window;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public class WindowBotanistDatabase extends WindowAbstractDatabase {
|
||||
ControlListBox<EnumFlowerColor> selectionBoxColors;
|
||||
|
||||
public WindowBotanistDatabase(final EntityPlayer player, final Side side, final boolean nei) {
|
||||
super(player, side, nei, Binnie.GENETICS.flowerBreedingSystem, 130);
|
||||
}
|
||||
|
||||
public static Window create(final EntityPlayer player, final Side side, final boolean nei) {
|
||||
return new WindowBotanistDatabase(player, side, nei);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected void addTabs() {
|
||||
new PageSpeciesOverview(this.getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.overview", 0));
|
||||
new PageSpeciesFlowerGenome(this.getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.genome", 0));
|
||||
new PageSpeciesClassification(this.getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.classification", 0));
|
||||
new PageSpeciesResultant(this.getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.resultant", 0));
|
||||
new PageSpeciesMutations(this.getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.further", 0));
|
||||
new PageBranchOverview(this.getInfoPages(Mode.BRANCHES), new DatabaseTab(Botany.instance, "branches.overview", 0));
|
||||
new PageBranchSpecies(this.getInfoPages(Mode.BRANCHES), new DatabaseTab(Botany.instance, "branches.species", 0));
|
||||
this.createMode(FlowerMode.Colour, new FlowerColourModeWidgets());
|
||||
new PageColourMixResultant(this.getInfoPages(FlowerMode.Colour), new DatabaseTab(Botany.instance, "colour.resultant", 0));
|
||||
new PageColourMix(this.getInfoPages(FlowerMode.Colour), new DatabaseTab(Botany.instance, "colour.further", 0));
|
||||
new PageBreeder(this.getInfoPages(Mode.BREEDER), this.getUsername(), new DatabaseTab(Botany.instance, "breeder", 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractMod getMod() {
|
||||
return Botany.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackgroundTextureName() {
|
||||
return "FlowerDatabase";
|
||||
}
|
||||
|
||||
enum FlowerMode implements IDatabaseMode {
|
||||
Colour;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return I18N.localise("botany.gui.database.mode." + this.name().toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private class FlowerColourModeWidgets extends ModeWidgets {
|
||||
public FlowerColourModeWidgets() {
|
||||
super(FlowerMode.Colour, WindowBotanistDatabase.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createListBox(final Area area) {
|
||||
this.listBox = new ControlListBox<IFlowerColour>(this.modePage, area.xPos(), area.yPos(), area.width(), area.height(), 12) {
|
||||
@Override
|
||||
public IWidget createOption(final IFlowerColour value, final int y) {
|
||||
return new ControlColourOption(this.getContent(), value, y);
|
||||
}
|
||||
};
|
||||
final List<IFlowerColour> colors = Arrays.stream(EnumFlowerColor.values()).map( c -> c.getFlowerColorAllele()).collect(Collectors.toList());
|
||||
this.listBox.setOptions(colors);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
if (ph != null) {
|
||||
info.append(TextFormatting.GRAY.toString())
|
||||
.append(", ")
|
||||
.append(I18N.localise("botany.ph"))
|
||||
.append(": ")
|
||||
.append(ph.getLocalisedName(true));
|
||||
info += TextFormatting.GRAY + ", " + I18N.localise("botany.ph") + ": " + moisture.getLocalisedName(true);
|
||||
}
|
||||
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 += TextFormatting.GRAY + " " + I18N.localise(fertilizedKey);
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ import binnie.botany.flower.TileEntityFlower;
|
||||
|
||||
public class FarmableFlower implements IFarmable {
|
||||
@Override
|
||||
public boolean isSaplingAt(final World world, final BlockPos pos) {
|
||||
public boolean isSaplingAt(World world, BlockPos pos) {
|
||||
return world.getBlockState(pos) == Botany.flower;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,8 @@ public class FarmableFlower implements IFarmable {
|
||||
if (world.getTileEntity(pos) instanceof TileEntityFlower) {
|
||||
flower = ((TileEntityFlower) world.getTileEntity(pos)).getFlower();
|
||||
}
|
||||
// Look at TileEntityFlower::onShear logic
|
||||
|
||||
// TODO Look at TileEntityFlower::onShear logic
|
||||
if (flower != null && flower.getAge() > 1) {
|
||||
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
|
||||
ItemStack mature = flowerRoot.getMemberStack(flower, EnumFlowerStage.FLOWER);
|
||||
@@ -42,23 +43,22 @@ public class FarmableFlower implements IFarmable {
|
||||
return new FlowerCrop(pos, mature, seed);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGermling(final ItemStack itemstack) {
|
||||
final EnumFlowerStage stage = BotanyCore.getFlowerRoot().getType(itemstack);
|
||||
public boolean isGermling(ItemStack itemstack) {
|
||||
EnumFlowerStage stage = BotanyCore.getFlowerRoot().getType(itemstack);
|
||||
return stage == EnumFlowerStage.FLOWER || stage == EnumFlowerStage.SEED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWindfall(final ItemStack itemstack) {
|
||||
public boolean isWindfall(ItemStack itemstack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(final EntityPlayer player, final ItemStack germling, final World world, final BlockPos pos) {
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
|
||||
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
|
||||
IFlower flower = flowerRoot.getMember(germling);
|
||||
flowerRoot.plant(world, pos, flower, player.getGameProfile());
|
||||
|
||||
@@ -11,12 +11,12 @@ import binnie.botany.core.BotanyCore;
|
||||
|
||||
public class FarmableVanillaFlower extends FarmableFlower {
|
||||
@Override
|
||||
public boolean isGermling(final ItemStack itemstack) {
|
||||
public boolean isGermling(ItemStack itemstack) {
|
||||
return BotanyCore.getFlowerRoot().getConversion(itemstack) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(final EntityPlayer player, final ItemStack germling, final World world, final BlockPos pos) {
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
|
||||
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
|
||||
IFlower flower = flowerRoot.getConversion(germling);
|
||||
return flowerRoot.plant(world, pos, flower, player.getGameProfile());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package binnie.botany.farm;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
@@ -14,7 +14,7 @@ public class FlowerCrop implements ICrop {
|
||||
BlockPos position;
|
||||
|
||||
public FlowerCrop(BlockPos pos, ItemStack... drops) {
|
||||
Arrays.stream(drops).forEach(drop -> this.drops.add(drop));
|
||||
Collections.addAll(this.drops, drops);
|
||||
position = pos;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,29 +51,31 @@ public class GardenLogic extends FarmLogic {
|
||||
private ItemStack icon;
|
||||
|
||||
public GardenLogic(EnumMoisture moisture2, @Nullable EnumAcidity acidity2, boolean isManual, boolean isFertilised, ItemStack icon2, String name2) {
|
||||
this.produce = NonNullList.create();
|
||||
(this.farmables = new ArrayList<>()).add(new FarmableFlower());
|
||||
this.farmables.add(new FarmableVanillaFlower());
|
||||
this.moisture = moisture2;
|
||||
this.acidity = acidity2;
|
||||
this.isManual = isManual;
|
||||
this.fertilised = isFertilised;
|
||||
this.icon = icon2;
|
||||
this.name = name2;
|
||||
produce = NonNullList.create();
|
||||
farmables = new ArrayList<>();
|
||||
farmables.add(new FarmableFlower());
|
||||
farmables.add(new FarmableVanillaFlower());
|
||||
|
||||
moisture = moisture2;
|
||||
acidity = acidity2;
|
||||
fertilised = isFertilised;
|
||||
icon = icon2;
|
||||
name = name2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFertilizerConsumption() {
|
||||
return this.fertilised ? 8 : 2;
|
||||
return fertilised ? 8 : 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWaterConsumption(final float hydrationModifier) {
|
||||
return (int) (this.moisture.ordinal() * 40 * hydrationModifier);
|
||||
public int getWaterConsumption(float hydrationModifier) {
|
||||
return (int) (moisture.ordinal() * 40 * hydrationModifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedResource(final ItemStack itemstack) {
|
||||
public boolean isAcceptedResource(ItemStack itemstack) {
|
||||
IGardeningManager gardening = BotanyCore.getGardening();
|
||||
return gardening.isSoil(itemstack.getItem()) ||
|
||||
itemstack.getItem() == Item.getItemFromBlock(Blocks.SAND) ||
|
||||
@@ -84,19 +86,19 @@ public class GardenLogic extends FarmLogic {
|
||||
|
||||
@Override
|
||||
public NonNullList<ItemStack> collect(World world, IFarmHousing farmHousing) {
|
||||
final NonNullList<ItemStack> products = this.produce;
|
||||
this.produce = NonNullList.create();
|
||||
NonNullList<ItemStack> products = produce;
|
||||
produce = NonNullList.create();
|
||||
return products;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cultivate(World world, IFarmHousing farmHousing, BlockPos pos, FarmDirection direction, int extent) {
|
||||
return this.maintainSoil(world, pos, direction, extent, farmHousing) ||
|
||||
(!this.isManual && this.maintainWater(world, pos, direction, extent, farmHousing)) ||
|
||||
this.maintainCrops(world, pos.up(), direction, extent, farmHousing);
|
||||
return maintainSoil(world, pos, direction, extent, farmHousing) ||
|
||||
(!isManual && maintainWater(world, pos, direction, extent, farmHousing)) ||
|
||||
maintainCrops(world, pos.up(), direction, extent, farmHousing);
|
||||
}
|
||||
|
||||
private boolean isWaste(final ItemStack stack) {
|
||||
private boolean isWaste(ItemStack stack) {
|
||||
return stack.getItem() == Item.getItemFromBlock(Blocks.DIRT);
|
||||
}
|
||||
|
||||
@@ -104,20 +106,21 @@ public class GardenLogic extends FarmLogic {
|
||||
IGardeningManager gardening = BotanyCore.getGardening();
|
||||
for (int i = 0; i < extent; ++i) {
|
||||
BlockPos position = pos.offset(direction.getFacing(), i);
|
||||
if (this.fertilised && gardening.isSoil(getBlock(world, position))) {
|
||||
if (fertilised && gardening.isSoil(getBlock(world, position))) {
|
||||
IBlockSoil soil = (IBlockSoil) getBlock(world, position);
|
||||
if (soil.fertilise(world, position, EnumSoilType.FLOWERBED)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (getBlock(world, position.up()) == Botany.plant) {
|
||||
|
||||
if (getBlock(world, position.up()) == Botany.gardening().plant) {
|
||||
world.setBlockToAir(position.up());
|
||||
} else {
|
||||
if (this.acidity != null && gardening.isSoil(getBlock(world, position))) {
|
||||
if (acidity != null && gardening.isSoil(getBlock(world, position))) {
|
||||
IBlockSoil soil = (IBlockSoil) getBlock(world, position);
|
||||
EnumAcidity pH = soil.getPH(world, position);
|
||||
if (pH.ordinal() < this.acidity.ordinal()) {
|
||||
ItemStack stack = this.getAvailableAlkaline(housing);
|
||||
if (pH.ordinal() < acidity.ordinal()) {
|
||||
ItemStack stack = getAvailableAlkaline(housing);
|
||||
if (!stack.isEmpty() && soil.setPH(world, position, EnumAcidity.values()[pH.ordinal() + 1])) {
|
||||
NonNullList<ItemStack> resources = NonNullList.create();
|
||||
resources.add(stack);
|
||||
@@ -125,8 +128,8 @@ public class GardenLogic extends FarmLogic {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (pH.ordinal() > this.acidity.ordinal()) {
|
||||
final ItemStack stack = this.getAvailableAcid(housing);
|
||||
if (pH.ordinal() > acidity.ordinal()) {
|
||||
ItemStack stack = getAvailableAcid(housing);
|
||||
if (!stack.isEmpty() && soil.setPH(world, position, EnumAcidity.values()[pH.ordinal() - 1])) {
|
||||
NonNullList<ItemStack> resources = NonNullList.create();
|
||||
resources.add(stack);
|
||||
@@ -135,16 +138,17 @@ public class GardenLogic extends FarmLogic {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!this.isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(getBlockState(world, position), world, position)) {
|
||||
ItemStack block = this.getAsItemStack(world, position);
|
||||
ItemStack loam = this.getAvailableLoam(housing);
|
||||
if (this.isWaste(block) && !loam.isEmpty()) {
|
||||
this.produce.addAll(Blocks.DIRT.getDrops(world, position, Block.getBlockFromItem(block.getItem()).getStateFromMeta(block.getItemDamage()), 0));
|
||||
this.setBlock(world, position, Blocks.AIR, 0);
|
||||
|
||||
if (!isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(getBlockState(world, position), world, position)) {
|
||||
ItemStack block = getAsItemStack(world, position);
|
||||
ItemStack loam = getAvailableLoam(housing);
|
||||
if (isWaste(block) && !loam.isEmpty()) {
|
||||
produce.addAll(Blocks.DIRT.getDrops(world, position, Block.getBlockFromItem(block.getItem()).getStateFromMeta(block.getItemDamage()), 0));
|
||||
setBlock(world, position, Blocks.AIR, 0);
|
||||
return trySetSoil(world, position, loam, housing);
|
||||
}
|
||||
} else if (!this.isManual) {
|
||||
if (!this.isWaterBlock(world, position)) {
|
||||
} else if (!isManual) {
|
||||
if (!isWaterBlock(world, position)) {
|
||||
if (i % 2 == 0) {
|
||||
return trySetSoil(world, position, housing);
|
||||
}
|
||||
@@ -157,9 +161,9 @@ public class GardenLogic extends FarmLogic {
|
||||
cclock = FarmDirection.SOUTH;
|
||||
}
|
||||
BlockPos previous = position.offset(cclock.getFacing());
|
||||
final ItemStack soil2 = this.getAsItemStack(world, previous);
|
||||
ItemStack soil2 = getAsItemStack(world, previous);
|
||||
if (!gardening.isSoil(soil2.getItem())) {
|
||||
this.trySetSoil(world, position, housing);
|
||||
trySetSoil(world, position, housing);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -171,23 +175,27 @@ public class GardenLogic extends FarmLogic {
|
||||
private boolean maintainWater(World world, BlockPos pos, FarmDirection direction, int extent, IFarmHousing housing) {
|
||||
for (int i = 0; i < extent; ++i) {
|
||||
BlockPos position = pos.offset(direction.getFacing(), i);
|
||||
if (this.isAirBlock(world, position) || BlockUtil.isReplaceableBlock(getBlockState(world, position), world, position)) {
|
||||
if (!this.isWaterBlock(world, position)) {
|
||||
boolean isEnclosed = true;
|
||||
if (world.isAirBlock(position.east())) {
|
||||
isEnclosed = false;
|
||||
} else if (world.isAirBlock(position.west())) {
|
||||
isEnclosed = false;
|
||||
} else if (world.isAirBlock(position.south())) {
|
||||
isEnclosed = false;
|
||||
} else if (world.isAirBlock(position.north())) {
|
||||
isEnclosed = false;
|
||||
}
|
||||
isEnclosed = (isEnclosed || this.moisture != EnumMoisture.DAMP);
|
||||
if (isEnclosed) {
|
||||
return this.trySetWater(world, position, housing);
|
||||
}
|
||||
}
|
||||
if (!isAirBlock(world, position) && !BlockUtil.isReplaceableBlock(getBlockState(world, position), world, position)) {
|
||||
continue;
|
||||
}
|
||||
if (isWaterBlock(world, position)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean isEnclosed = true;
|
||||
if (world.isAirBlock(position.east())) {
|
||||
isEnclosed = false;
|
||||
} else if (world.isAirBlock(position.west())) {
|
||||
isEnclosed = false;
|
||||
} else if (world.isAirBlock(position.south())) {
|
||||
isEnclosed = false;
|
||||
} else if (world.isAirBlock(position.north())) {
|
||||
isEnclosed = false;
|
||||
}
|
||||
|
||||
isEnclosed = (isEnclosed || moisture != EnumMoisture.DAMP);
|
||||
if (isEnclosed) {
|
||||
return trySetWater(world, position, housing);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -195,19 +203,37 @@ public class GardenLogic extends FarmLogic {
|
||||
|
||||
private ItemStack getAvailableLoam(IFarmHousing housing) {
|
||||
EnumMoisture[] moistures;
|
||||
if (this.moisture == EnumMoisture.DAMP) {
|
||||
moistures = new EnumMoisture[]{EnumMoisture.DAMP, EnumMoisture.NORMAL, EnumMoisture.DRY};
|
||||
} else if (this.moisture == EnumMoisture.DRY) {
|
||||
moistures = new EnumMoisture[]{EnumMoisture.DRY, EnumMoisture.DAMP, EnumMoisture.DRY};
|
||||
if (moisture == EnumMoisture.DAMP) {
|
||||
moistures = new EnumMoisture[]{
|
||||
EnumMoisture.DAMP,
|
||||
EnumMoisture.NORMAL,
|
||||
EnumMoisture.DRY
|
||||
};
|
||||
} else if (moisture == EnumMoisture.DRY) {
|
||||
moistures = new EnumMoisture[]{
|
||||
EnumMoisture.DRY,
|
||||
EnumMoisture.DAMP,
|
||||
EnumMoisture.DRY
|
||||
};
|
||||
} else {
|
||||
moistures = new EnumMoisture[]{EnumMoisture.DRY, EnumMoisture.NORMAL, EnumMoisture.DAMP};
|
||||
moistures = new EnumMoisture[]{
|
||||
EnumMoisture.DRY,
|
||||
EnumMoisture.NORMAL,
|
||||
EnumMoisture.DAMP
|
||||
};
|
||||
}
|
||||
final EnumAcidity[] acidities = {EnumAcidity.NEUTRAL, EnumAcidity.ACID, EnumAcidity.ALKALINE};
|
||||
for (final EnumMoisture moist : moistures) {
|
||||
for (final EnumAcidity acid : acidities) {
|
||||
for (final Block type : new Block[]{Botany.flowerbed, Botany.loam, Botany.soil}) {
|
||||
final int meta = acid.ordinal() * 3 + moist.ordinal();
|
||||
final NonNullList<ItemStack> resources = NonNullList.create();
|
||||
|
||||
EnumAcidity[] acidities = {
|
||||
EnumAcidity.NEUTRAL,
|
||||
EnumAcidity.ACID,
|
||||
EnumAcidity.ALKALINE
|
||||
};
|
||||
|
||||
for (EnumMoisture moist : moistures) {
|
||||
for (EnumAcidity acid : acidities) {
|
||||
for (Block type : new Block[]{Botany.gardening().flowerbed, Botany.gardening().loam, Botany.gardening().soil}) {
|
||||
int meta = acid.ordinal() * 3 + moist.ordinal();
|
||||
NonNullList<ItemStack> resources = NonNullList.create();
|
||||
ItemStack resourceStack = new ItemStack(type, 1, meta);
|
||||
resources.add(resourceStack);
|
||||
if (housing.getFarmInventory().hasResources(resources)) {
|
||||
@@ -216,7 +242,8 @@ public class GardenLogic extends FarmLogic {
|
||||
}
|
||||
}
|
||||
}
|
||||
final NonNullList<ItemStack> resources = NonNullList.create();
|
||||
|
||||
NonNullList<ItemStack> resources = NonNullList.create();
|
||||
ItemStack resourceStack = new ItemStack(Blocks.DIRT);
|
||||
resources.add(resourceStack);
|
||||
if (housing.getFarmInventory().hasResources(resources)) {
|
||||
@@ -226,56 +253,58 @@ public class GardenLogic extends FarmLogic {
|
||||
}
|
||||
|
||||
private boolean trySetSoil(World world, BlockPos position, IFarmHousing housing) {
|
||||
return this.trySetSoil(world, position, this.getAvailableLoam(housing), housing);
|
||||
return trySetSoil(world, position, getAvailableLoam(housing), housing);
|
||||
}
|
||||
|
||||
private boolean trySetSoil(World world, BlockPos position, ItemStack loam, IFarmHousing housing) {
|
||||
ItemStack copy = loam;
|
||||
if (!loam.isEmpty()) {
|
||||
if (loam.getItem() == Item.getItemFromBlock(Blocks.DIRT)) {
|
||||
loam = new ItemStack(Botany.soil, 1, 4);
|
||||
}
|
||||
setBlock(world, position, ((ItemBlock) loam.getItem()).getBlock(), loam.getItemDamage());
|
||||
final NonNullList<ItemStack> resources = NonNullList.create();
|
||||
resources.add(copy);
|
||||
housing.getFarmInventory().removeResources(resources);
|
||||
return true;
|
||||
if (loam.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
if (loam.getItem() == Item.getItemFromBlock(Blocks.DIRT)) {
|
||||
loam = new ItemStack(Botany.gardening().soil, 1, 4);
|
||||
}
|
||||
|
||||
setBlock(world, position, ((ItemBlock) loam.getItem()).getBlock(), loam.getItemDamage());
|
||||
NonNullList<ItemStack> resources = NonNullList.create();
|
||||
resources.add(copy);
|
||||
housing.getFarmInventory().removeResources(resources);
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean trySetWater(World world, BlockPos position, IFarmHousing housing) {
|
||||
final FluidStack water = Binnie.LIQUID.getFluidStack(ManagerLiquid.WATER, 1000);
|
||||
if (this.moisture == EnumMoisture.DAMP) {
|
||||
FluidStack water = Binnie.LIQUID.getFluidStack(ManagerLiquid.WATER, 1000);
|
||||
if (moisture == EnumMoisture.DAMP) {
|
||||
if (water == null || !housing.hasLiquid(water)) {
|
||||
return false;
|
||||
}
|
||||
this.setBlock(world, position, Blocks.WATER, 0);
|
||||
setBlock(world, position, Blocks.WATER, 0);
|
||||
housing.removeLiquid(water);
|
||||
return true;
|
||||
} else {
|
||||
if (this.moisture != EnumMoisture.DRY) {
|
||||
return trySetSoil(world, position, housing);
|
||||
}
|
||||
final ItemStack sand = new ItemStack(Blocks.SAND, 1);
|
||||
final NonNullList<ItemStack> resources = NonNullList.create();
|
||||
resources.add(sand);
|
||||
if (!housing.getFarmInventory().hasResources(resources)) {
|
||||
return false;
|
||||
}
|
||||
this.setBlock(world, position, Blocks.SAND, 0);
|
||||
housing.getFarmInventory().removeResources(resources);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (moisture != EnumMoisture.DRY) {
|
||||
return trySetSoil(world, position, housing);
|
||||
}
|
||||
ItemStack sand = new ItemStack(Blocks.SAND, 1);
|
||||
NonNullList<ItemStack> resources = NonNullList.create();
|
||||
resources.add(sand);
|
||||
if (!housing.getFarmInventory().hasResources(resources)) {
|
||||
return false;
|
||||
}
|
||||
setBlock(world, position, Blocks.SAND, 0);
|
||||
housing.getFarmInventory().removeResources(resources);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setIcon(final ItemStack icon) {
|
||||
public void setIcon(ItemStack icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedGermling(final ItemStack itemstack) {
|
||||
for (final IFarmable farmable : this.farmables) {
|
||||
public boolean isAcceptedGermling(ItemStack itemstack) {
|
||||
for (IFarmable farmable : farmables) {
|
||||
if (farmable.isGermling(itemstack)) {
|
||||
return true;
|
||||
}
|
||||
@@ -287,10 +316,9 @@ public class GardenLogic extends FarmLogic {
|
||||
public Collection<ICrop> harvest(World world, BlockPos pos, FarmDirection direction, int extent) {
|
||||
if (isManual) {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
return farmables.stream().map(farmable -> farmable.getCropAt(world, pos.up(), world.getBlockState(pos.up())))
|
||||
.filter(Objects::nonNull).collect(Collectors.toList());
|
||||
}
|
||||
return farmables.stream().map(farmable -> farmable.getCropAt(world, pos.up(), world.getBlockState(pos.up())))
|
||||
.filter(Objects::nonNull).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -300,7 +328,7 @@ public class GardenLogic extends FarmLogic {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -312,8 +340,8 @@ public class GardenLogic extends FarmLogic {
|
||||
IGardeningManager gardening = BotanyCore.getGardening();
|
||||
for (int i = 0; i < extent; ++i) {
|
||||
BlockPos position = pos.offset(direction.getFacing(), i);
|
||||
if (this.isAirBlock(world, position) || BlockUtil.isReplaceableBlock(getBlockState(world, position), world, position)) {
|
||||
ItemStack below = this.getAsItemStack(world, position.down());
|
||||
if (isAirBlock(world, position) || BlockUtil.isReplaceableBlock(getBlockState(world, position), world, position)) {
|
||||
ItemStack below = getAsItemStack(world, position.down());
|
||||
if (gardening.isSoil(below.getItem())) {
|
||||
return trySetCrop(world, position, housing);
|
||||
}
|
||||
@@ -323,27 +351,29 @@ public class GardenLogic extends FarmLogic {
|
||||
}
|
||||
|
||||
private boolean trySetCrop(World world, BlockPos position, IFarmHousing housing) {
|
||||
for (IFarmable farmable : this.farmables) {
|
||||
if (housing.plantGermling(farmable, world, position)) {
|
||||
if (housing instanceof IOwnedTile) {
|
||||
TileEntity tile = world.getTileEntity(position);
|
||||
if (tile instanceof TileEntityFlower) {
|
||||
TileEntityFlower flower = (TileEntityFlower) tile;
|
||||
IOwnedTile owned = (IOwnedTile) housing;
|
||||
|
||||
flower.setOwner(owned.getOwnerHandler().getOwner());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
for (IFarmable farmable : farmables) {
|
||||
if (!housing.plantGermling(farmable, world, position)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (housing instanceof IOwnedTile) {
|
||||
TileEntity tile = world.getTileEntity(position);
|
||||
if (tile instanceof TileEntityFlower) {
|
||||
TileEntityFlower flower = (TileEntityFlower) tile;
|
||||
IOwnedTile owned = (IOwnedTile) housing;
|
||||
|
||||
flower.setOwner(owned.getOwnerHandler().getOwner());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ItemStack getAvailableAcid(IFarmHousing housing) {
|
||||
for (final ItemStack stack : BotanyCore.getGardening().getAcidFertilisers()) {
|
||||
for (ItemStack stack : BotanyCore.getGardening().getAcidFertilisers()) {
|
||||
if (!stack.isEmpty()) {
|
||||
final NonNullList<ItemStack> resources = NonNullList.create();
|
||||
NonNullList<ItemStack> resources = NonNullList.create();
|
||||
resources.add(stack);
|
||||
if (housing.getFarmInventory().hasResources(resources)) {
|
||||
return stack;
|
||||
@@ -354,9 +384,9 @@ public class GardenLogic extends FarmLogic {
|
||||
}
|
||||
|
||||
public ItemStack getAvailableAlkaline(IFarmHousing housing) {
|
||||
for (final ItemStack stack : BotanyCore.getGardening().getAlkalineFertilisers()) {
|
||||
for (ItemStack stack : BotanyCore.getGardening().getAlkalineFertilisers()) {
|
||||
if (!stack.isEmpty()) {
|
||||
final NonNullList<ItemStack> resources = NonNullList.create();
|
||||
NonNullList<ItemStack> resources = NonNullList.create();
|
||||
resources.add(stack);
|
||||
if (housing.getFarmInventory().hasResources(resources)) {
|
||||
return stack;
|
||||
|
||||
@@ -53,7 +53,7 @@ import binnie.core.util.TileUtil;
|
||||
|
||||
public class BlockFlower extends BlockContainer implements IColoredBlock, IStateMapperRegister {
|
||||
public static final AxisAlignedBB FLOWER_BLOCK_AABB = new AxisAlignedBB(0.3D, 0.0D, 0.3D, 0.7D, 0.6D, 0.7D);
|
||||
/* PROPERTYS */
|
||||
/* PROPERTIES */
|
||||
public static final PropertyFlower FLOWER = new PropertyFlower("flower", IFlowerType.class);
|
||||
public static final PropertyInteger SECTION = PropertyInteger.create("section", 0, EnumFlowerType.highestSection - 1);
|
||||
public static final PropertyBool FLOWERED = PropertyBool.create("flowered");
|
||||
@@ -61,14 +61,13 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IState
|
||||
|
||||
public BlockFlower() {
|
||||
super(Material.PLANTS);
|
||||
final float f = 0.2f;
|
||||
this.setTickRandomly(true);
|
||||
this.setRegistryName("flower");
|
||||
this.setSoundType(SoundType.PLANT);
|
||||
setTickRandomly(true);
|
||||
setRegistryName("flower");
|
||||
setSoundType(SoundType.PLANT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(final World var1, final int i) {
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityFlower();
|
||||
}
|
||||
|
||||
@@ -81,31 +80,36 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IState
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
ItemStack heldItem = player.getHeldItemMainhand();
|
||||
if (!heldItem.isEmpty() && heldItem.getItem() == BinnieCore.getFieldKit() && player.isSneaking()) {
|
||||
if (world.isRemote) {
|
||||
return true;
|
||||
}
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileEntityFlower) {
|
||||
TileEntityFlower tileFlower = (TileEntityFlower) tile;
|
||||
IFlower flower = tileFlower.getFlower();
|
||||
if (flower != null) {
|
||||
IFlowerGenome flowerGenome = flower.getGenome();
|
||||
NBTTagCompound info = new NBTTagCompound();
|
||||
info.setString("Species", flowerGenome.getPrimary().getUID());
|
||||
info.setString("Species2", flowerGenome.getSecondary().getUID());
|
||||
info.setFloat("Age", flower.getAge() / flowerGenome.getLifespan());
|
||||
info.setShort("Colour", (short) flowerGenome.getPrimaryColor().getID());
|
||||
info.setShort("Colour2", (short) flowerGenome.getSecondaryColor().getID());
|
||||
info.setBoolean("Wilting", flower.isWilted());
|
||||
info.setBoolean("Flowered", flower.hasFlowered());
|
||||
Botany.proxy.sendToPlayer(new MessageNBT(PacketID.FIELDKIT.ordinal(), info), player);
|
||||
heldItem.damageItem(1, player);
|
||||
}
|
||||
}
|
||||
if (heldItem.isEmpty() || heldItem.getItem() != BinnieCore.getFieldKit() || !player.isSneaking()) {
|
||||
return false;
|
||||
}
|
||||
if (world.isRemote) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (!(tile instanceof TileEntityFlower)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
TileEntityFlower tileFlower = (TileEntityFlower) tile;
|
||||
IFlower flower = tileFlower.getFlower();
|
||||
if (flower == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
IFlowerGenome flowerGenome = flower.getGenome();
|
||||
NBTTagCompound info = new NBTTagCompound();
|
||||
info.setString("Species", flowerGenome.getPrimary().getUID());
|
||||
info.setString("Species2", flowerGenome.getSecondary().getUID());
|
||||
info.setFloat("Age", flower.getAge() / flowerGenome.getLifespan());
|
||||
info.setShort("Colour", (short) flowerGenome.getPrimaryColor().getID());
|
||||
info.setShort("Colour2", (short) flowerGenome.getSecondaryColor().getID());
|
||||
info.setBoolean("Wilting", flower.isWilted());
|
||||
info.setBoolean("Flowered", flower.hasFlowered());
|
||||
Botany.proxy.sendToPlayer(new MessageNBT(PacketID.FIELDKIT.ordinal(), info), player);
|
||||
heldItem.damageItem(1, player);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -152,22 +156,23 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IState
|
||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
|
||||
super.onBlockPlacedBy(world, pos, state, placer, stack);
|
||||
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
|
||||
final TileEntity flower = world.getTileEntity(pos);
|
||||
TileEntity flower = world.getTileEntity(pos);
|
||||
if (!BinnieCore.getBinnieProxy().isSimulating(world)) {
|
||||
if (flower != null && flower instanceof TileEntityFlower) {
|
||||
final IFlower f = flowerRoot.getMember(stack);
|
||||
IFlower f = flowerRoot.getMember(stack);
|
||||
if (f != null) {
|
||||
((TileEntityFlower) flower).setRender(new TileEntityFlower.RenderInfo(f, (TileEntityFlower) flower));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
final TileEntity below = world.getTileEntity(pos.down());
|
||||
|
||||
TileEntity below = world.getTileEntity(pos.down());
|
||||
if (flower != null && flower instanceof TileEntityFlower) {
|
||||
if (below instanceof TileEntityFlower) {
|
||||
((TileEntityFlower) flower).setSection(((TileEntityFlower) below).getSection());
|
||||
} else {
|
||||
final GameProfile owner = (placer instanceof EntityPlayer) ? ((EntityPlayer) placer).getGameProfile() : null;
|
||||
GameProfile owner = (placer instanceof EntityPlayer) ? ((EntityPlayer) placer).getGameProfile() : null;
|
||||
((TileEntityFlower) flower).create(stack, owner);
|
||||
}
|
||||
}
|
||||
@@ -185,9 +190,8 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IState
|
||||
return flower.getStemColour();
|
||||
} else if (tintIndex == 1) {
|
||||
return flower.getPrimaryColour();
|
||||
} else {
|
||||
return flower.getSecondaryColour();
|
||||
}
|
||||
return flower.getSecondaryColour();
|
||||
}
|
||||
}
|
||||
return 0xffffff;
|
||||
@@ -204,11 +208,14 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IState
|
||||
if (tile instanceof TileEntityFlower && ((TileEntityFlower) tile).getSection() > 0) {
|
||||
return downState.getBlock() == Botany.flower;
|
||||
}
|
||||
return this.canPlaceBlockOn(downState.getBlock());
|
||||
return canPlaceBlockOn(downState.getBlock());
|
||||
}
|
||||
|
||||
protected boolean canPlaceBlockOn(final Block block) {
|
||||
return block == Blocks.GRASS || block == Blocks.DIRT || block == Blocks.FARMLAND || BotanyCore.getGardening().isSoil(block);
|
||||
protected boolean canPlaceBlockOn(Block block) {
|
||||
return block == Blocks.GRASS
|
||||
|| block == Blocks.DIRT
|
||||
|| block == Blocks.FARMLAND
|
||||
|| BotanyCore.getGardening().isSoil(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -257,12 +264,12 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IState
|
||||
|
||||
@Override
|
||||
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
|
||||
this.checkAndDropBlock(worldIn, pos);
|
||||
final TileEntity tile = worldIn.getTileEntity(pos);
|
||||
checkAndDropBlock(worldIn, pos);
|
||||
TileEntity tile = worldIn.getTileEntity(pos);
|
||||
if (tile instanceof TileEntityFlower) {
|
||||
final TileEntityFlower flower = (TileEntityFlower) tile;
|
||||
TileEntityFlower flower = (TileEntityFlower) tile;
|
||||
if (flower.getSection() == 0 && flower.getFlower() != null && flower.getFlower().getAge() > 0 && flower.getFlower().getGenome().getPrimary().getType().getSections() > 1 && worldIn.getBlockState(pos.up()).getBlock() != Botany.flower) {
|
||||
this.dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0);
|
||||
dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0);
|
||||
worldIn.setBlockToAir(pos);
|
||||
}
|
||||
}
|
||||
@@ -270,18 +277,18 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IState
|
||||
|
||||
@Override
|
||||
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
|
||||
final TileEntity tile = world.getTileEntity(pos);
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileEntityFlower) {
|
||||
((TileEntityFlower) tile).randomUpdate(rand);
|
||||
this.checkAndDropBlock(world, pos);
|
||||
checkAndDropBlock(world, pos);
|
||||
return;
|
||||
}
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
|
||||
protected void checkAndDropBlock(final World world, final BlockPos pos) {
|
||||
if (!this.canBlockStay(world, pos)) {
|
||||
this.dropBlockAsItem(world, pos, world.getBlockState(pos), 0);
|
||||
protected void checkAndDropBlock(World world, BlockPos pos) {
|
||||
if (!canBlockStay(world, pos)) {
|
||||
dropBlockAsItem(world, pos, world.getBlockState(pos), 0);
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
}
|
||||
@@ -301,10 +308,10 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IState
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) {
|
||||
final List<ItemStack> drops = this.getDrops(world, pos, world.getBlockState(pos), 0);
|
||||
final boolean hasBeenBroken = world.setBlockToAir(pos);
|
||||
List<ItemStack> drops = getDrops(world, pos, world.getBlockState(pos), 0);
|
||||
boolean hasBeenBroken = world.setBlockToAir(pos);
|
||||
if (hasBeenBroken && BinnieCore.getBinnieProxy().isSimulating(world) && drops.size() > 0 && (player == null || !player.capabilities.isCreativeMode)) {
|
||||
for (final ItemStack drop : drops) {
|
||||
for (ItemStack drop : drops) {
|
||||
spawnAsEntity(world, pos, drop);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,57 +3,62 @@ package binnie.botany.flower;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
enum EnumTubeInsulate {
|
||||
Clay(0xa1aacc, "Clay"),
|
||||
Cobble(0x7b7b7b, "Cobblestone"),
|
||||
Sand(0xefeab5, "Sand"),
|
||||
HardenedClay(0x935c43, "Hardened Clay"),
|
||||
Stone(0x6d6d6d, "Smooth Stone"),
|
||||
Sandstone(0xc1b989, "Sandstone");
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public enum EnumTubeInsulate {
|
||||
CLAY(0xa1aacc, "clay"),
|
||||
COBBLE(0x7b7b7b, "cobblestone"),
|
||||
SAND(0xefeab5, "sandstone"),
|
||||
HARDENED_CLAY(0x935c43, "hardened_clay"),
|
||||
STONE(0x6d6d6d, "stone"),
|
||||
SANDSTONE(0xc1b989, "sandstone");
|
||||
|
||||
public static final EnumTubeInsulate[] VALUES = values();
|
||||
|
||||
int color;
|
||||
String name;
|
||||
String uid;
|
||||
|
||||
EnumTubeInsulate(final int color, final String name) {
|
||||
EnumTubeInsulate(int color, String uid) {
|
||||
this.color = color;
|
||||
this.name = name;
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public static EnumTubeInsulate get(final int i) {
|
||||
return values()[i / 128 % values().length];
|
||||
public static EnumTubeInsulate get(int meta) {
|
||||
return VALUES[meta / 128 % VALUES.length];
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return this.color;
|
||||
return color;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
public String getDisplayName() {
|
||||
return I18N.localise("botany.tube.insulate." + uid + ".name");
|
||||
}
|
||||
|
||||
public String getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public ItemStack getStack() {
|
||||
switch (this) {
|
||||
case Clay: {
|
||||
case CLAY:
|
||||
return new ItemStack(Blocks.CLAY);
|
||||
}
|
||||
case Cobble: {
|
||||
|
||||
case COBBLE:
|
||||
return new ItemStack(Blocks.COBBLESTONE);
|
||||
}
|
||||
case HardenedClay: {
|
||||
|
||||
case HARDENED_CLAY:
|
||||
return new ItemStack(Blocks.HARDENED_CLAY);
|
||||
}
|
||||
case Sand: {
|
||||
|
||||
case SAND:
|
||||
return new ItemStack(Blocks.SAND);
|
||||
}
|
||||
case Sandstone: {
|
||||
|
||||
case SANDSTONE:
|
||||
return new ItemStack(Blocks.SANDSTONE);
|
||||
}
|
||||
case Stone: {
|
||||
|
||||
case STONE:
|
||||
return new ItemStack(Blocks.STONE);
|
||||
}
|
||||
default: {
|
||||
throw new IllegalStateException("Unknown insulated tube type: " + this);
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("Unknown insulated tube type: " + this);
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,36 @@
|
||||
package binnie.botany.flower;
|
||||
|
||||
enum EnumTubeMaterial {
|
||||
Copper(0xe3b78e, "Copper"),
|
||||
Tin(0xe1eef4, "Tin"),
|
||||
Bronze(0xddc276, "Bronze"),
|
||||
Iron(0xd8d8d8, "Iron");
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public enum EnumTubeMaterial {
|
||||
COPPER(0xe3b78e, "copper"),
|
||||
TIN(0xe1eef4, "tin"),
|
||||
BRONZE(0xddc276, "bronze"),
|
||||
IRON(0xd8d8d8, "iron");
|
||||
|
||||
public static final EnumTubeMaterial[] VALUES = values();
|
||||
|
||||
int color;
|
||||
String name;
|
||||
String uid;
|
||||
|
||||
EnumTubeMaterial(final int color, final String name) {
|
||||
EnumTubeMaterial(int color, String uid) {
|
||||
this.color = color;
|
||||
this.name = name;
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public static EnumTubeMaterial get(final int i) {
|
||||
return values()[i % values().length];
|
||||
public static EnumTubeMaterial get(int meta) {
|
||||
return VALUES[meta % VALUES.length];
|
||||
}
|
||||
|
||||
public String getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return this.color;
|
||||
return color;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
public String getDisplayName() {
|
||||
return I18N.localise("botany.tube.material." + uid + ".name");
|
||||
}
|
||||
}
|
||||
@@ -62,18 +62,18 @@ public class FlowerSpriteManager {
|
||||
private int sections;
|
||||
|
||||
public FlowerSprites(IFlowerType type) {
|
||||
this.sections = type.getSections();
|
||||
this.stem = new BinnieSprite[sections];
|
||||
this.petal = new BinnieSprite[sections];
|
||||
this.variant = new BinnieSprite[sections];
|
||||
this.unflowered = new BinnieSprite[sections];
|
||||
sections = type.getSections();
|
||||
stem = new BinnieSprite[sections];
|
||||
petal = new BinnieSprite[sections];
|
||||
variant = new BinnieSprite[sections];
|
||||
unflowered = new BinnieSprite[sections];
|
||||
for (int section = 0; section < sections; ++section) {
|
||||
final String suf = (section == 0) ? "" : ("" + (section + 1));
|
||||
final String pre = (sections == 1) ? "" : "double/";
|
||||
this.stem[section] = Binnie.RESOURCE.getBlockSprite(Botany.instance, "flowers/" + pre + type.toString().toLowerCase() + suf + ".0");
|
||||
this.petal[section] = Binnie.RESOURCE.getBlockSprite(Botany.instance, "flowers/" + pre + type.toString().toLowerCase() + suf + ".1");
|
||||
this.variant[section] = Binnie.RESOURCE.getBlockSprite(Botany.instance, "flowers/" + pre + type.toString().toLowerCase() + suf + ".2");
|
||||
this.unflowered[section] = Binnie.RESOURCE.getBlockSprite(Botany.instance, "flowers/" + pre + type.toString().toLowerCase() + suf + ".3");
|
||||
String suf = (section == 0) ? "" : ("" + (section + 1));
|
||||
String pre = (sections == 1) ? "" : "double/";
|
||||
stem[section] = Binnie.RESOURCE.getBlockSprite(Botany.instance, "flowers/" + pre + type.toString().toLowerCase() + suf + ".0");
|
||||
petal[section] = Binnie.RESOURCE.getBlockSprite(Botany.instance, "flowers/" + pre + type.toString().toLowerCase() + suf + ".1");
|
||||
variant[section] = Binnie.RESOURCE.getBlockSprite(Botany.instance, "flowers/" + pre + type.toString().toLowerCase() + suf + ".2");
|
||||
unflowered[section] = Binnie.RESOURCE.getBlockSprite(Botany.instance, "flowers/" + pre + type.toString().toLowerCase() + suf + ".3");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,13 +84,13 @@ public class FlowerSpriteManager {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getPetal(IFlowerType type, int section, boolean flowered) {
|
||||
return (flowered ? petal[section % this.sections] : this.unflowered[section % this.sections]).getSprite();
|
||||
return (flowered ? petal[section % sections] : unflowered[section % sections]).getSprite();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getVariant(IFlowerType type, int section, boolean flowered) {
|
||||
return flowered ? variant[section % this.sections].getSprite() : null;
|
||||
return flowered ? variant[section % sections].getSprite() : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -54,13 +55,13 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
|
||||
private EnumFlowerStage type;
|
||||
private String tag;
|
||||
|
||||
public ItemBotany(final String name, EnumFlowerStage type, String tag) {
|
||||
this.setCreativeTab(CreativeTabBotany.instance);
|
||||
this.setUnlocalizedName(name);
|
||||
setRegistryName(name);
|
||||
this.hasSubtypes = true;
|
||||
public ItemBotany(String name, EnumFlowerStage type, String tag) {
|
||||
this.type = type;
|
||||
this.tag = tag;
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
setUnlocalizedName(name);
|
||||
setRegistryName(name);
|
||||
hasSubtypes = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,35 +80,33 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasEffect(final ItemStack itemstack) {
|
||||
public boolean hasEffect(ItemStack itemstack) {
|
||||
if (!itemstack.hasTagCompound()) {
|
||||
return false;
|
||||
}
|
||||
final IIndividual individual = this.getIndividual(itemstack);
|
||||
IIndividual individual = getIndividual(itemstack);
|
||||
return individual != null && individual.hasEffect();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(final ItemStack itemStack, final EntityPlayer player, final List<String> list, final boolean flag) {
|
||||
if (!itemStack.hasTagCompound()) {
|
||||
return;
|
||||
}
|
||||
IFlower individual = (IFlower) this.getIndividual(itemStack);
|
||||
public void addInformation(ItemStack itemStack, @Nullable World worldIn, List<String> list, ITooltipFlag flagIn) {
|
||||
IFlower individual = (IFlower) getIndividual(itemStack);
|
||||
if (individual == null) {
|
||||
list.add(TextFormatting.DARK_RED + I18N.localise("botany.flower.destroy"));
|
||||
list.add(TextFormatting.DARK_RED + I18N.localise("item.botany.flower.destroy"));
|
||||
return;
|
||||
}
|
||||
|
||||
IFlowerGenome genome = individual.getGenome();
|
||||
//Colors
|
||||
String primaryColor = genome.getPrimaryColor().getColourName();
|
||||
String secondaryColor = genome.getSecondaryColor().getColourName();
|
||||
String stemColor = genome.getStemColor().getColourName();
|
||||
String primaryColor = genome.getPrimaryColor().getColorName();
|
||||
String secondaryColor = genome.getSecondaryColor().getColorName();
|
||||
String stemColor = genome.getStemColor().getColorName();
|
||||
String colorInfo;
|
||||
if (!primaryColor.equals(secondaryColor)) {
|
||||
colorInfo = I18N.localise("botany.grammar.flower.secondary");
|
||||
colorInfo = I18N.localise("item.botany.grammar.flower.secondary");
|
||||
} else {
|
||||
colorInfo = I18N.localise("botany.grammar.flower");
|
||||
colorInfo = I18N.localise("item.botany.grammar.flower");
|
||||
}
|
||||
list.add(TextFormatting.YELLOW + colorInfo.replaceAll("%PRIMARY", primaryColor).replaceAll("%SECONDARY", secondaryColor).replaceAll("%STEM", stemColor));
|
||||
|
||||
@@ -123,7 +122,7 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected IIndividual getIndividual(final ItemStack itemstack) {
|
||||
protected IIndividual getIndividual(ItemStack itemstack) {
|
||||
NBTTagCompound tagCompound = itemstack.getTagCompound();
|
||||
if (tagCompound == null) {
|
||||
return null;
|
||||
@@ -131,8 +130,8 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
|
||||
return new Flower(tagCompound);
|
||||
}
|
||||
|
||||
private IAlleleFlowerSpecies getPrimarySpecies(final ItemStack itemstack) {
|
||||
final IFlower tree = BotanyCore.getFlowerRoot().getMember(itemstack);
|
||||
private IAlleleFlowerSpecies getPrimarySpecies(ItemStack itemstack) {
|
||||
IFlower tree = BotanyCore.getFlowerRoot().getMember(itemstack);
|
||||
if (tree == null) {
|
||||
return (IAlleleFlowerSpecies) BotanyCore.getFlowerRoot().getDefaultTemplate()[EnumFlowerChromosome.SPECIES.ordinal()];
|
||||
}
|
||||
@@ -140,11 +139,11 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack itemstack) {
|
||||
public String getItemStackDisplayName(ItemStack itemstack) {
|
||||
if (!itemstack.hasTagCompound()) {
|
||||
return I18N.localise("item.botany.flower.corrupted.name");
|
||||
}
|
||||
IIndividual individual = this.getIndividual(itemstack);
|
||||
IIndividual individual = getIndividual(itemstack);
|
||||
if (individual != null) {
|
||||
return individual.getDisplayName() + (!tag.isEmpty() ? " " + I18N.localise("item.botany." + tag + ".name") : "");
|
||||
}
|
||||
@@ -152,12 +151,14 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(final Item item, final CreativeTabs tab, final NonNullList<ItemStack> itemList) {
|
||||
this.addCreativeItems(itemList, true);
|
||||
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
|
||||
if (this.isInCreativeTab(tab)) {
|
||||
addCreativeItems(items, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void addCreativeItems(final NonNullList<ItemStack> itemList, final boolean hideSecrets) {
|
||||
for (final IIndividual individual : BotanyCore.getFlowerRoot().getIndividualTemplates()) {
|
||||
public void addCreativeItems(NonNullList<ItemStack> itemList, boolean hideSecrets) {
|
||||
for (IIndividual individual : BotanyCore.getFlowerRoot().getIndividualTemplates()) {
|
||||
if (hideSecrets && individual.isSecret() && !Config.isDebug) {
|
||||
continue;
|
||||
}
|
||||
@@ -169,9 +170,14 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
|
||||
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
|
||||
IFlower flower = BotanyCore.getFlowerRoot().getMember(stack);
|
||||
if (flower == null) {
|
||||
return 16777215;
|
||||
return 0xffffff;
|
||||
}
|
||||
return (tintIndex == 0) ? flower.getGenome().getStemColor().getColor(flower.isWilted()) : ((tintIndex == 1) ? flower.getGenome().getPrimaryColor().getColor(flower.isWilted()) : flower.getGenome().getSecondaryColor().getColor(flower.isWilted()));
|
||||
if (tintIndex == 0) {
|
||||
return flower.getGenome().getStemColor().getColor(flower.isWilted());
|
||||
}
|
||||
return (tintIndex == 1)
|
||||
? flower.getGenome().getPrimaryColor().getColor(flower.isWilted())
|
||||
: flower.getGenome().getSecondaryColor().getColor(flower.isWilted());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -187,43 +193,49 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (type == EnumFlowerStage.POLLEN) {
|
||||
final IFlower flower = Binnie.GENETICS.getFlowerRoot().getMember(stack);
|
||||
final TileEntity target = world.getTileEntity(pos);
|
||||
if (!(target instanceof IPollinatable)) {
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
final IPollinatable pollinatable = (IPollinatable) target;
|
||||
if (!pollinatable.canMateWith(flower)) {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
pollinatable.mateWith(flower);
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
return pollinateFlower(world, pos, player, stack);
|
||||
}
|
||||
return placeFlower(player, stack, world, pos, hand, facing, hitX, hitY, hitZ);
|
||||
}
|
||||
|
||||
private EnumActionResult pollinateFlower(World world, BlockPos pos, EntityPlayer player, ItemStack stack){
|
||||
IFlower flower = Binnie.GENETICS.getFlowerRoot().getMember(stack);
|
||||
TileEntity target = world.getTileEntity(pos);
|
||||
if (!(target instanceof IPollinatable)) {
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
IPollinatable pollinatable = (IPollinatable) target;
|
||||
if (!pollinatable.canMateWith(flower)) {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
pollinatable.mateWith(flower);
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
stack.shrink(1);
|
||||
}
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
private EnumActionResult placeFlower(EntityPlayer player, ItemStack stack, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
Block block = blockState.getBlock();
|
||||
|
||||
if (!block.isReplaceable(world, pos)) {
|
||||
pos = pos.offset(facing);
|
||||
}
|
||||
|
||||
if (stack.getCount() != 0 && player.canPlayerEdit(pos, facing, stack) && world.mayPlace(Botany.flower, pos, false, facing, null)) {
|
||||
int i = getMetadata(stack.getMetadata());
|
||||
IBlockState stateForPlacement = Botany.flower.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, i, player, hand);
|
||||
|
||||
if (placeBlockAt(stack, player, world, pos, facing, hitX, hitY, hitZ, stateForPlacement)) {
|
||||
SoundType soundType = block.getSoundType(stateForPlacement, world, pos, player);
|
||||
world.playSound(player, pos, soundType.getPlaceSound(), SoundCategory.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F, soundType.getPitch() * 0.8F);
|
||||
stack.shrink(1);
|
||||
}
|
||||
|
||||
return EnumActionResult.SUCCESS;
|
||||
} else {
|
||||
IBlockState iblockstate = world.getBlockState(pos);
|
||||
Block block = iblockstate.getBlock();
|
||||
|
||||
if (!block.isReplaceable(world, pos)) {
|
||||
pos = pos.offset(facing);
|
||||
}
|
||||
|
||||
if (stack.getCount() != 0 && player.canPlayerEdit(pos, facing, stack) && world.mayPlace(Botany.flower, pos, false, facing, null)) {
|
||||
int i = this.getMetadata(stack.getMetadata());
|
||||
IBlockState iblockstate1 = Botany.flower.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, i, player, hand);
|
||||
|
||||
if (placeBlockAt(stack, player, world, pos, facing, hitX, hitY, hitZ, iblockstate1)) {
|
||||
SoundType soundtype = world.getBlockState(pos).getBlock().getSoundType(world.getBlockState(pos), world, pos, player);
|
||||
world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
|
||||
stack.shrink(1);
|
||||
}
|
||||
|
||||
return EnumActionResult.SUCCESS;
|
||||
} else {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
}
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package binnie.botany.flower;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
@@ -7,6 +9,7 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -14,6 +17,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -27,11 +31,12 @@ import forestry.core.utils.Translator;
|
||||
|
||||
import binnie.botany.CreativeTabBotany;
|
||||
import binnie.core.item.ItemCore;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public class ItemInsulatedTube extends ItemCore implements IColoredItem {
|
||||
public ItemInsulatedTube() {
|
||||
super("insulated_tube");
|
||||
setUnlocalizedName("insulated_tube");
|
||||
setUnlocalizedName("botany.insulated_tube");
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
@@ -49,7 +54,7 @@ public class ItemInsulatedTube extends ItemCore implements IColoredItem {
|
||||
}
|
||||
|
||||
public static String getInsulate(ItemStack stack) {
|
||||
return EnumTubeInsulate.get(stack.getItemDamage()).getName();
|
||||
return EnumTubeInsulate.get(stack.getItemDamage()).getDisplayName();
|
||||
}
|
||||
|
||||
public static ItemStack getInsulateStack(ItemStack stack) {
|
||||
@@ -57,11 +62,12 @@ public class ItemInsulatedTube extends ItemCore implements IColoredItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item item, CreativeTabs tab, NonNullList<ItemStack> subItems) {
|
||||
for (EnumTubeMaterial mat : EnumTubeMaterial.values()) {
|
||||
for (EnumTubeInsulate ins : EnumTubeInsulate.values()) {
|
||||
subItems.add(new ItemStack(this, 1, mat.ordinal() + ins.ordinal() * 128));
|
||||
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
|
||||
if (this.isInCreativeTab(tab)) {
|
||||
for (EnumTubeMaterial mat : EnumTubeMaterial.values()) {
|
||||
for (EnumTubeInsulate ins : EnumTubeInsulate.values()) {
|
||||
items.add(new ItemStack(this, 1, mat.ordinal() + ins.ordinal() * 128));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,8 +94,8 @@ public class ItemInsulatedTube extends ItemCore implements IColoredItem {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack itemstack, EntityPlayer player, List<String> list, boolean flag) {
|
||||
super.addInformation(itemstack, player, list, flag);
|
||||
public void addInformation(ItemStack itemstack, @Nullable World worldIn, List<String> list, ITooltipFlag flagIn) {
|
||||
super.addInformation(itemstack, worldIn, list, flagIn);
|
||||
Multimap<ICircuitLayout, ICircuit> circuits = getCircuits(itemstack);
|
||||
if (!circuits.isEmpty()) {
|
||||
if (GuiScreen.isShiftKeyDown()) {
|
||||
@@ -111,6 +117,10 @@ public class ItemInsulatedTube extends ItemCore implements IColoredItem {
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack itemStack) {
|
||||
int meta = itemStack.getMetadata();
|
||||
return EnumTubeMaterial.get(meta).getName() + " " + EnumTubeInsulate.get(meta).getName() + " " + super.getItemStackDisplayName(itemStack);
|
||||
return I18N.localise(
|
||||
"item.botany.insulated_tube.name",
|
||||
EnumTubeMaterial.get(meta).getDisplayName(),
|
||||
EnumTubeInsulate.get(meta).getDisplayName()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -19,13 +19,14 @@ import binnie.botany.api.IFlowerType;
|
||||
public class StateMapperFlower extends StateMapperBase {
|
||||
@Override
|
||||
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
|
||||
final Map<IProperty<?>, Comparable<?>> properties = Maps.newLinkedHashMap(state.getProperties());
|
||||
Map<IProperty<?>, Comparable<?>> properties = Maps.newLinkedHashMap(state.getProperties());
|
||||
IFlowerType flowerType = (IFlowerType) state.getValue(BlockFlower.FLOWER);
|
||||
if (flowerType.getSections() < 2) {
|
||||
properties.remove(BlockFlower.SECTION);
|
||||
} else if (flowerType.getSections() <= state.getValue(BlockFlower.SECTION)) {
|
||||
properties.put(BlockFlower.SECTION, flowerType.getSections() - 1);
|
||||
}
|
||||
|
||||
if (state.getValue(BlockFlower.SEED)) {
|
||||
properties.remove(BlockFlower.SECTION);
|
||||
properties.remove(BlockFlower.FLOWER);
|
||||
@@ -33,7 +34,6 @@ public class StateMapperFlower extends StateMapperBase {
|
||||
} else {
|
||||
properties.remove(BlockFlower.SEED);
|
||||
}
|
||||
|
||||
return new ModelResourceLocation(Constants.BOTANY_MOD_ID + ":flower", getPropertyString(properties));
|
||||
}
|
||||
}
|
||||
@@ -36,13 +36,13 @@ import binnie.botany.api.EnumFlowerStage;
|
||||
import binnie.botany.api.EnumSoilType;
|
||||
import binnie.botany.api.IAlleleFlowerSpecies;
|
||||
import binnie.botany.api.IFlower;
|
||||
import binnie.botany.api.IFlowerColour;
|
||||
import binnie.botany.api.IFlowerColor;
|
||||
import binnie.botany.api.IFlowerGenome;
|
||||
import binnie.botany.api.IFlowerRoot;
|
||||
import binnie.botany.api.IFlowerType;
|
||||
import binnie.botany.api.IGardeningManager;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.botany.gardening.BlockPlant;
|
||||
import binnie.botany.gardening.PlantType;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.botany.genetics.EnumFlowerType;
|
||||
import binnie.botany.genetics.Flower;
|
||||
@@ -61,65 +61,73 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
int matureTime;
|
||||
|
||||
public TileEntityFlower() {
|
||||
this.flower = null;
|
||||
this.section = 0;
|
||||
this.renderInfo = null;
|
||||
this.matureTime = 0;
|
||||
flower = null;
|
||||
section = 0;
|
||||
renderInfo = null;
|
||||
matureTime = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound nbtCompound) {
|
||||
public void readFromNBT(NBTTagCompound nbtCompound) {
|
||||
if (nbtCompound.hasKey("Flower")) {
|
||||
this.flower = new Flower(nbtCompound.getCompoundTag("Flower"));
|
||||
flower = new Flower(nbtCompound.getCompoundTag("Flower"));
|
||||
if (flower.getAge() == 0) {
|
||||
flower.setFlowered(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (nbtCompound.hasKey("section")) {
|
||||
this.section = nbtCompound.getByte("section");
|
||||
section = nbtCompound.getByte("section");
|
||||
}
|
||||
|
||||
if (nbtCompound.hasKey("owner")) {
|
||||
this.owner = NBTUtil.readGameProfileFromNBT(nbtCompound.getCompoundTag("owner"));
|
||||
owner = NBTUtil.readGameProfileFromNBT(nbtCompound.getCompoundTag("owner"));
|
||||
}
|
||||
|
||||
if (nbtCompound.hasKey("CATER") && BinnieCore.isLepidopteryActive()) {
|
||||
this.matureTime = nbtCompound.getInteger("caterTime");
|
||||
this.caterpillar = Binnie.GENETICS.getButterflyRoot().getMember(nbtCompound.getCompoundTag("cater"));
|
||||
matureTime = nbtCompound.getInteger("caterTime");
|
||||
caterpillar = Binnie.GENETICS.getButterflyRoot().getMember(nbtCompound.getCompoundTag("cater"));
|
||||
}
|
||||
|
||||
readRenderInfo(nbtCompound);
|
||||
super.readFromNBT(nbtCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(final NBTTagCompound nbtCompound) {
|
||||
if (this.flower != null) {
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbtCompound) {
|
||||
if (flower != null) {
|
||||
nbtCompound.setTag("Flower", flower.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
if (this.owner != null) {
|
||||
final NBTTagCompound nbt = new NBTTagCompound();
|
||||
NBTUtil.writeGameProfile(nbt, this.owner);
|
||||
|
||||
if (owner != null) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
NBTUtil.writeGameProfile(nbt, owner);
|
||||
nbtCompound.setTag("owner", nbt);
|
||||
}
|
||||
if (this.caterpillar != null) {
|
||||
nbtCompound.setInteger("caterTime", this.matureTime);
|
||||
final NBTTagCompound subcompound = new NBTTagCompound();
|
||||
this.caterpillar.writeToNBT(subcompound);
|
||||
|
||||
if (caterpillar != null) {
|
||||
nbtCompound.setInteger("caterTime", matureTime);
|
||||
NBTTagCompound subcompound = new NBTTagCompound();
|
||||
caterpillar.writeToNBT(subcompound);
|
||||
nbtCompound.setTag("cater", subcompound);
|
||||
}
|
||||
|
||||
nbtCompound.setByte("section", (byte) getSection());
|
||||
return super.writeToNBT(nbtCompound);
|
||||
}
|
||||
|
||||
public void create(final ItemStack stack, @Nullable final GameProfile owner) {
|
||||
public void create(ItemStack stack, @Nullable GameProfile owner) {
|
||||
IFlower flower = BotanyCore.getFlowerRoot().getMember(stack);
|
||||
this.create(flower, owner);
|
||||
create(flower, owner);
|
||||
}
|
||||
|
||||
public void create(final IFlower flower, @Nullable final GameProfile owner) {
|
||||
public void create(IFlower flower, @Nullable GameProfile owner) {
|
||||
this.flower = flower;
|
||||
if (this.flower.getAge() == 0) {
|
||||
this.flower.setFlowered(false);
|
||||
if (flower.getAge() == 0) {
|
||||
flower.setFlowered(false);
|
||||
}
|
||||
this.updateRender(true);
|
||||
|
||||
updateRender(true);
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
@@ -131,33 +139,40 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
@Override
|
||||
@Nullable
|
||||
public IIndividual getPollen() {
|
||||
return this.getFlower();
|
||||
return getFlower();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMateWith(final IIndividual individual) {
|
||||
return this.isBreeding() && individual instanceof IFlower && this.getFlower() != null && this.getFlower().getMate() == null && this.getFlower().hasFlowered() && !this.getFlower().isGeneticEqual(individual);
|
||||
public boolean canMateWith(IIndividual individual) {
|
||||
return isBreeding()
|
||||
&& individual instanceof IFlower
|
||||
&& getFlower() != null
|
||||
&& getFlower().getMate() == null
|
||||
&& getFlower().hasFlowered()
|
||||
&& !getFlower().isGeneticEqual(individual);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mateWith(final IIndividual individual) {
|
||||
if (this.getFlower() == null || !(individual instanceof IFlower)) {
|
||||
public void mateWith(IIndividual individual) {
|
||||
if (getFlower() == null || !(individual instanceof IFlower)) {
|
||||
return;
|
||||
}
|
||||
final IAlleleFlowerSpecies primary = (IAlleleFlowerSpecies) individual.getGenome().getPrimary();
|
||||
final IAlleleFlowerSpecies primary2 = this.getFlower().getGenome().getPrimary();
|
||||
if (primary == primary2 || this.world.rand.nextInt(4) == 0) {
|
||||
this.getFlower().mate((IFlower) individual);
|
||||
|
||||
IAlleleFlowerSpecies primary = (IAlleleFlowerSpecies) individual.getGenome().getPrimary();
|
||||
IAlleleFlowerSpecies primary2 = getFlower().getGenome().getPrimary();
|
||||
if (primary == primary2 || world.rand.nextInt(4) == 0) {
|
||||
getFlower().mate((IFlower) individual);
|
||||
world.markBlockRangeForRenderUpdate(pos, pos);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public IFlower getFlower() {
|
||||
if (this.getSection() <= 0) {
|
||||
return this.flower;
|
||||
if (getSection() <= 0) {
|
||||
return flower;
|
||||
}
|
||||
TileEntity tile = this.world.getTileEntity(pos.down(getSection()));
|
||||
|
||||
TileEntity tile = world.getTileEntity(pos.down(getSection()));
|
||||
if (tile instanceof TileEntityFlower) {
|
||||
return ((TileEntityFlower) tile).getFlower();
|
||||
}
|
||||
@@ -165,73 +180,70 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
}
|
||||
|
||||
public boolean isBreeding() {
|
||||
final Block roots = this.getWorld().getBlockState(getPos().down()).getBlock();
|
||||
Block roots = getWorld().getBlockState(getPos().down()).getBlock();
|
||||
return BotanyCore.getGardening().isSoil(roots);
|
||||
}
|
||||
|
||||
public void randomUpdate(final Random rand) {
|
||||
if (this.world.getBlockState(pos).getBlock() != Botany.flower) {
|
||||
this.invalidate();
|
||||
public void randomUpdate(Random rand) {
|
||||
if (world.getBlockState(pos).getBlock() != Botany.flower) {
|
||||
invalidate();
|
||||
return;
|
||||
}
|
||||
if (this.getSection() > 0) {
|
||||
if (getSection() > 0) {
|
||||
return;
|
||||
}
|
||||
if (this.flower == null) {
|
||||
if (flower == null) {
|
||||
return;
|
||||
}
|
||||
if (this.flower.getGenome() == null) {
|
||||
this.invalidate();
|
||||
|
||||
if (!isBreeding()) {
|
||||
return;
|
||||
}
|
||||
if (!this.isBreeding()) {
|
||||
|
||||
if(updateState(rand)){
|
||||
return;
|
||||
}
|
||||
float light = this.world.getLight(pos);
|
||||
if (light < 6.0f) {
|
||||
for (int dx = -2; dx <= 2; ++dx) {
|
||||
for (int dy = -2; dy <= 2; ++dy) {
|
||||
light -= (this.world.canBlockSeeSky(pos) ? 0.0f : 0.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IGardeningManager gardening = BotanyCore.getGardening();
|
||||
final boolean canTolerate = gardening.canTolerate(this.getFlower(), this.world, pos);
|
||||
final EnumSoilType soil = gardening.getSoilType(this.world, pos.down());
|
||||
if (rand.nextFloat() < this.getFlower().getGenome().getAgeChance()) {
|
||||
if (this.flower.getAge() < 1) {
|
||||
if (canTolerate && light > 6.0f) {
|
||||
this.doFlowerAge();
|
||||
EnumSoilType soil = gardening.getSoilType(world, pos.down());
|
||||
float chanceDispersal = 0.8f;
|
||||
chanceDispersal += 0.2f * flower.getGenome().getFertility();
|
||||
chanceDispersal *= 1.0f + soil.ordinal() * 0.5f;
|
||||
float chancePollinate = 1.0f;
|
||||
chancePollinate += 0.25f * flower.getGenome().getFertility();
|
||||
chancePollinate *= 1.0f + soil.ordinal() * 0.5f;
|
||||
float chanceSelfPollinate = 0.2f * chancePollinate;
|
||||
plantOffspring(rand, chanceDispersal);
|
||||
|
||||
mateFlower(rand, chancePollinate, chanceSelfPollinate);
|
||||
spawnButterflies();
|
||||
matureCaterpillar();
|
||||
checkIfDead(false);
|
||||
updateRender(true);
|
||||
}
|
||||
|
||||
private void mateFlower(Random rand, float chancePollinate, float chanceSelfPollinate){
|
||||
if (world.rand.nextFloat() < chancePollinate && flower.hasFlowered() && !flower.isWilted()) {
|
||||
for (int a2 = 0; a2 < 4; ++a2) {
|
||||
int dx3;
|
||||
int dz2;
|
||||
for (dx3 = 0, dz2 = 0; dx3 == 0 && dz2 == 0; dx3 = rand.nextInt(5) - 2, dz2 = rand.nextInt(5) - 2) {
|
||||
}
|
||||
TileEntity tile = world.getTileEntity(pos.add(dx3, 0, dz2));
|
||||
if (tile instanceof IPollinatable && ((IPollinatable) tile).canMateWith(getFlower())) {
|
||||
((IPollinatable) tile).mateWith(getFlower());
|
||||
}
|
||||
} else {
|
||||
this.doFlowerAge();
|
||||
}
|
||||
}
|
||||
if (canTolerate && this.flower.getAge() > 1 && !this.flower.isWilted() && light > 6.0f) {
|
||||
this.flower.setFlowered(true);
|
||||
|
||||
if (world.rand.nextFloat() < chanceSelfPollinate && flower.hasFlowered() && flower.getMate() == null) {
|
||||
mateWith(getFlower());
|
||||
}
|
||||
if (!canTolerate && this.flower.isWilted() && rand.nextInt(2 + Math.max(this.flower.getAge(), 2)) == 0) {
|
||||
this.kill();
|
||||
return;
|
||||
}
|
||||
if (light < 2.0f && this.flower.isWilted()) {
|
||||
this.kill();
|
||||
return;
|
||||
}
|
||||
if (!canTolerate || light < 1.0f) {
|
||||
this.flower.setWilted(true);
|
||||
} else {
|
||||
this.flower.setWilted(false);
|
||||
}
|
||||
float CHANCE_DISPERSAL = 0.8f;
|
||||
CHANCE_DISPERSAL += 0.2f * this.flower.getGenome().getFertility();
|
||||
CHANCE_DISPERSAL *= 1.0f + soil.ordinal() * 0.5f;
|
||||
float CHANCE_POLLINATE = 1.0f;
|
||||
CHANCE_POLLINATE += 0.25f * this.flower.getGenome().getFertility();
|
||||
CHANCE_POLLINATE *= 1.0f + soil.ordinal() * 0.5f;
|
||||
final float CHANCE_SELFPOLLINATE = 0.2f * CHANCE_POLLINATE;
|
||||
if (this.world.rand.nextFloat() < CHANCE_DISPERSAL && this.flower.hasFlowered() && !this.flower.isWilted()) {
|
||||
final IFlowerGenome mate = this.flower.getMate();
|
||||
}
|
||||
|
||||
private void plantOffspring(Random rand, float chanceDispersal){
|
||||
if (world.rand.nextFloat() < chanceDispersal && flower.hasFlowered() && !flower.isWilted()) {
|
||||
IFlowerGenome mate = flower.getMate();
|
||||
if (mate != null) {
|
||||
boolean dispersed = false;
|
||||
for (int a = 0; a < 5 && !dispersed; ++a) {
|
||||
@@ -240,68 +252,94 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
for (dx2 = 0, dz = 0; dx2 == 0 && dz == 0; dx2 = rand.nextInt(3) - 1, dz = rand.nextInt(3) - 1) {
|
||||
}
|
||||
|
||||
final Block b2 = world.getBlockState(pos.add(dx2, -1, dz)).getBlock();
|
||||
Block b2 = world.getBlockState(pos.add(dx2, -1, dz)).getBlock();
|
||||
if (world.isAirBlock(pos.add(dx2, 0, dz)) && BotanyCore.getGardening().isSoil(b2)) {
|
||||
final IFlower offspring = this.flower.getOffspring(world, pos);
|
||||
IFlower offspring = flower.getOffspring(world, pos);
|
||||
if (offspring != null) {
|
||||
BotanyCore.getFlowerRoot().plant(world, pos.add(dx2, 0, dz), offspring, this.getOwner());
|
||||
this.flower.removeMate();
|
||||
BotanyCore.getFlowerRoot().plant(world, pos.add(dx2, 0, dz), offspring, getOwner());
|
||||
flower.removeMate();
|
||||
dispersed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.world.rand.nextFloat() < CHANCE_POLLINATE && this.flower.hasFlowered() && !this.flower.isWilted()) {
|
||||
for (int a2 = 0; a2 < 4; ++a2) {
|
||||
int dx3;
|
||||
int dz2;
|
||||
for (dx3 = 0, dz2 = 0; dx3 == 0 && dz2 == 0; dx3 = rand.nextInt(5) - 2, dz2 = rand.nextInt(5) - 2) {
|
||||
}
|
||||
final TileEntity tile = world.getTileEntity(pos.add(dx3, 0, dz2));
|
||||
if (tile instanceof IPollinatable && ((IPollinatable) tile).canMateWith(this.getFlower())) {
|
||||
((IPollinatable) tile).mateWith(this.getFlower());
|
||||
}
|
||||
|
||||
private boolean updateState(Random rand){
|
||||
float light = world.getLight(pos);
|
||||
if (light < 6.0f) {
|
||||
for (int offsetX = -2; offsetX <= 2; ++offsetX) {
|
||||
for (int offsetY = -2; offsetY <= 2; ++offsetY) {
|
||||
light -= (world.canBlockSeeSky(pos.add(offsetX, 0, offsetY)) ? 0.0f : 0.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.world.rand.nextFloat() < CHANCE_SELFPOLLINATE && this.flower.hasFlowered() && this.flower.getMate() == null) {
|
||||
this.mateWith(this.getFlower());
|
||||
|
||||
IGardeningManager gardening = BotanyCore.getGardening();
|
||||
boolean canTolerate = gardening.canTolerate(getFlower(), world, pos);
|
||||
if (rand.nextFloat() < getFlower().getGenome().getAgeChance()) {
|
||||
if (flower.getAge() < 1) {
|
||||
if (canTolerate && light > 6.0f) {
|
||||
doFlowerAge();
|
||||
}
|
||||
} else {
|
||||
doFlowerAge();
|
||||
}
|
||||
}
|
||||
this.spawnButterflies();
|
||||
this.matureCaterpillar();
|
||||
this.checkIfDead(false);
|
||||
this.updateRender(true);
|
||||
|
||||
if (canTolerate && flower.getAge() > 1 && !flower.isWilted() && light > 6.0f) {
|
||||
flower.setFlowered(true);
|
||||
}
|
||||
|
||||
if (!canTolerate && flower.isWilted() && rand.nextInt(2 + Math.max(flower.getAge(), 2)) == 0) {
|
||||
kill();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (light < 2.0f && flower.isWilted()) {
|
||||
kill();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!canTolerate || light < 1.0f) {
|
||||
flower.setWilted(true);
|
||||
} else {
|
||||
flower.setWilted(false);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void doFlowerAge() {
|
||||
this.getFlower().age();
|
||||
if (this.getFlower().getAge() == 1) {
|
||||
getFlower().age();
|
||||
if (getFlower().getAge() == 1) {
|
||||
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
|
||||
flowerRoot.onGrowFromSeed(this.world, pos);
|
||||
if (this.getOwner() != null && this.getFlower() != null) {
|
||||
flowerRoot.getBreedingTracker(world, this.getOwner()).registerBirth(this.getFlower());
|
||||
flowerRoot.onGrowFromSeed(world, pos);
|
||||
if (getOwner() != null && getFlower() != null) {
|
||||
flowerRoot.getBreedingTracker(world, getOwner()).registerBirth(getFlower());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private NBTTagCompound writeRenderInfo(NBTTagCompound tag){
|
||||
if(renderInfo!=null){
|
||||
private NBTTagCompound writeRenderInfo(NBTTagCompound tag) {
|
||||
if (renderInfo != null) {
|
||||
NBTTagCompound nbtRenderInfo = new NBTTagCompound();
|
||||
nbtRenderInfo.setByte("primary",(byte)this.renderInfo.primary.getID());
|
||||
nbtRenderInfo.setByte("secondary",(byte)this.renderInfo.secondary.getID());
|
||||
nbtRenderInfo.setByte("stem",(byte)this.renderInfo.stem.getID());
|
||||
nbtRenderInfo.setByte("type",(byte)this.renderInfo.type.ordinal());
|
||||
nbtRenderInfo.setByte("age",this.renderInfo.age);
|
||||
nbtRenderInfo.setByte("section",this.renderInfo.section);
|
||||
nbtRenderInfo.setBoolean("wilted",this.renderInfo.wilted);
|
||||
nbtRenderInfo.setBoolean("flowered",this.renderInfo.flowered);
|
||||
nbtRenderInfo.setByte("primary", (byte) renderInfo.primary.getID());
|
||||
nbtRenderInfo.setByte("secondary", (byte) renderInfo.secondary.getID());
|
||||
nbtRenderInfo.setByte("stem", (byte) renderInfo.stem.getID());
|
||||
nbtRenderInfo.setByte("type", (byte) renderInfo.type.ordinal());
|
||||
nbtRenderInfo.setByte("age", renderInfo.age);
|
||||
nbtRenderInfo.setByte("section", renderInfo.section);
|
||||
nbtRenderInfo.setBoolean("wilted", renderInfo.wilted);
|
||||
nbtRenderInfo.setBoolean("flowered", renderInfo.flowered);
|
||||
tag.setTag("renderinfo", nbtRenderInfo);
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
private void readRenderInfo(NBTTagCompound tag){
|
||||
if(tag.hasKey("renderinfo")){
|
||||
private void readRenderInfo(NBTTagCompound tag) {
|
||||
if (tag.hasKey("renderinfo")) {
|
||||
NBTTagCompound infotag = tag.getCompoundTag("renderinfo");
|
||||
RenderInfo info = new RenderInfo();
|
||||
info.primary = EnumFlowerColor.values()[infotag.getByte("primary")].getFlowerColorAllele();
|
||||
@@ -319,6 +357,7 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
|
||||
super.onDataPacket(net, pkt);
|
||||
// TODO client only call?
|
||||
readRenderInfo(pkt.getNbtCompound());
|
||||
}
|
||||
|
||||
@@ -330,38 +369,39 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
|
||||
@Override
|
||||
public SPacketUpdateTileEntity getUpdatePacket() {
|
||||
if (this.renderInfo == null && this.getFlower() != null && this.getFlower().getGenome() != null) {
|
||||
this.renderInfo = new RenderInfo(this.getFlower(), this);
|
||||
if (renderInfo == null && getFlower() != null) {
|
||||
renderInfo = new RenderInfo(getFlower(), this);
|
||||
}
|
||||
return (this.renderInfo != null) ? new SPacketUpdateTileEntity(pos, 0, getUpdateTag()) : null;
|
||||
return (renderInfo != null) ? new SPacketUpdateTileEntity(pos, 0, getUpdateTag()) : null;
|
||||
}
|
||||
|
||||
public void updateRender(final boolean update) {
|
||||
if (update && this.getFlower() != null && this.getFlower().getGenome() != null) {
|
||||
final RenderInfo newInfo = new RenderInfo(this.getFlower(), this);
|
||||
if (this.renderInfo == null || !newInfo.equals(this.renderInfo)) {
|
||||
this.setRender(newInfo);
|
||||
public void updateRender(boolean update) {
|
||||
if (update && getFlower() != null && getFlower().getGenome() != null) {
|
||||
RenderInfo newInfo = new RenderInfo(getFlower(), this);
|
||||
if (renderInfo == null || !newInfo.equals(renderInfo)) {
|
||||
setRender(newInfo);
|
||||
}
|
||||
}
|
||||
final TileEntity above = this.world.getTileEntity(pos.up());
|
||||
|
||||
TileEntity above = world.getTileEntity(pos.up());
|
||||
if (above instanceof TileEntityFlower) {
|
||||
((TileEntityFlower) above).updateRender(true);
|
||||
}
|
||||
}
|
||||
|
||||
public int getSection() {
|
||||
return this.section;
|
||||
return section;
|
||||
}
|
||||
|
||||
public void setSection(final int i) {
|
||||
this.section = i;
|
||||
if (BinnieCore.getBinnieProxy().isSimulating(this.world)) {
|
||||
this.updateRender(true);
|
||||
public void setSection(int i) {
|
||||
section = i;
|
||||
if (BinnieCore.getBinnieProxy().isSimulating(world)) {
|
||||
updateRender(true);
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getItemStack() {
|
||||
IFlower flower = this.getFlower();
|
||||
IFlower flower = getFlower();
|
||||
if (flower == null) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
@@ -370,57 +410,61 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
|
||||
@Nullable
|
||||
private TileEntityFlower getRoot() {
|
||||
if (this.getSection() == 0) {
|
||||
if (getSection() == 0) {
|
||||
return null;
|
||||
}
|
||||
final TileEntity tile = this.world.getTileEntity(pos.down(getSection()));
|
||||
TileEntity tile = world.getTileEntity(pos.down(getSection()));
|
||||
return (tile instanceof TileEntityFlower) ? ((TileEntityFlower) tile) : null;
|
||||
}
|
||||
|
||||
public void onShear() {
|
||||
if (this.getRoot() != null) {
|
||||
this.getRoot().onShear();
|
||||
if (getRoot() != null) {
|
||||
getRoot().onShear();
|
||||
}
|
||||
if (this.getFlower() != null && this.getFlower().getAge() > 1) {
|
||||
final Random rand = new Random();
|
||||
final IFlower cutting = (IFlower) this.getFlower().copy();
|
||||
cutting.setAge(0);
|
||||
final ItemStack cuttingStack = BotanyCore.getFlowerRoot().getMemberStack(cutting, EnumFlowerStage.SEED);
|
||||
final float f = 0.7f;
|
||||
final double d = rand.nextFloat() * f + (1.0f - f) * 0.5;
|
||||
final double d2 = rand.nextFloat() * f + (1.0f - f) * 0.5;
|
||||
final double d3 = rand.nextFloat() * f + (1.0f - f) * 0.5;
|
||||
final EntityItem entityitem = new EntityItem(this.world, pos.getX() + d, pos.getY() + d2, pos.getZ() + d3, cuttingStack);
|
||||
entityitem.setPickupDelay(10);
|
||||
this.world.spawnEntity(entityitem);
|
||||
for (int maxAge = this.getFlower().getMaxAge(), i = 0; i < maxAge; ++i) {
|
||||
if (rand.nextBoolean()) {
|
||||
this.getFlower().age();
|
||||
if (this.checkIfDead(true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (getFlower() == null || getFlower().getAge() <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
Random rand = new Random();
|
||||
IFlower cutting = (IFlower) getFlower().copy();
|
||||
cutting.setAge(0);
|
||||
ItemStack cuttingStack = BotanyCore.getFlowerRoot().getMemberStack(cutting, EnumFlowerStage.SEED);
|
||||
float f = 0.7f;
|
||||
double xPos = rand.nextFloat() * f + (1.0f - f) * 0.5;
|
||||
double yPos = rand.nextFloat() * f + (1.0f - f) * 0.5;
|
||||
double zPos = rand.nextFloat() * f + (1.0f - f) * 0.5;
|
||||
EntityItem entityItem = new EntityItem(world, pos.getX() + xPos, pos.getY() + yPos, pos.getZ() + zPos, cuttingStack);
|
||||
entityItem.setPickupDelay(10);
|
||||
world.spawnEntity(entityItem);
|
||||
for (int maxAge = getFlower().getMaxAge(), i = 0; i < maxAge; ++i) {
|
||||
if (rand.nextBoolean()) {
|
||||
getFlower().age();
|
||||
if (checkIfDead(true)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkIfDead(final boolean wasCut) {
|
||||
if (this.getSection() != 0) {
|
||||
return this.getRoot().checkIfDead(wasCut);
|
||||
public boolean checkIfDead(boolean wasCut) {
|
||||
if (getSection() != 0) {
|
||||
return getRoot().checkIfDead(wasCut);
|
||||
}
|
||||
final EnumSoilType soil = BotanyCore.getGardening().getSoilType(this.world, pos);
|
||||
final int maxAge = (int) (this.flower.getMaxAge() * (1.0f + soil.ordinal() * 0.25f));
|
||||
if (this.flower.getAge() > maxAge) {
|
||||
if (!wasCut && this.flower.getMate() != null) {
|
||||
this.world.setBlockToAir(pos);
|
||||
final IFlower offspring = this.flower.getOffspring(this.world, pos.down());
|
||||
final TileEntity above = this.world.getTileEntity(pos.up());
|
||||
|
||||
EnumSoilType soil = BotanyCore.getGardening().getSoilType(world, pos);
|
||||
int maxAge = (int) (flower.getMaxAge() * (1.0f + soil.ordinal() * 0.25f));
|
||||
if (flower.getAge() > maxAge) {
|
||||
if (!wasCut && flower.getMate() != null) {
|
||||
world.setBlockToAir(pos);
|
||||
IFlower offspring = flower.getOffspring(world, pos.down());
|
||||
TileEntity above = world.getTileEntity(pos.up());
|
||||
if (above instanceof TileEntityFlower) {
|
||||
this.world.setBlockToAir(pos.up());
|
||||
world.setBlockToAir(pos.up());
|
||||
}
|
||||
BotanyCore.getFlowerRoot().plant(this.world, pos, offspring, this.getOwner());
|
||||
BotanyCore.getFlowerRoot().plant(world, pos, offspring, getOwner());
|
||||
} else {
|
||||
this.kill();
|
||||
kill();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -428,42 +472,44 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
}
|
||||
|
||||
public void kill() {
|
||||
if (this.flower.getAge() > 0) {
|
||||
this.world.setBlockState(pos, Botany.plant.getStateFromMeta(BlockPlant.Type.DeadFlower.ordinal()), 2);
|
||||
if (flower.getAge() > 0) {
|
||||
world.setBlockState(pos, Botany.gardening().plant.getStateFromMeta(PlantType.DEAD_FLOWER.ordinal()), 2);
|
||||
} else {
|
||||
this.world.setBlockToAir(pos);
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
for (int i = 1; this.world.getTileEntity(pos.up(i)) instanceof TileEntityFlower; ++i) {
|
||||
this.world.setBlockToAir(pos.up(i));
|
||||
|
||||
for (int i = 1; world.getTileEntity(pos.up(i)) instanceof TileEntityFlower; ++i) {
|
||||
world.setBlockToAir(pos.up(i));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onBonemeal() {
|
||||
if (this.getFlower() == null) {
|
||||
if (getFlower() == null) {
|
||||
return false;
|
||||
}
|
||||
if (!this.isBreeding()) {
|
||||
if (!isBreeding()) {
|
||||
return false;
|
||||
}
|
||||
if (this.getFlower().isWilted()) {
|
||||
if (getFlower().isWilted()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//this.doFlowerAge();
|
||||
if (this.getFlower().getAge() > 1 && !this.getFlower().hasFlowered()) {
|
||||
this.getFlower().setFlowered(true);
|
||||
if (getFlower().getAge() > 1 && !getFlower().hasFlowered()) {
|
||||
getFlower().setFlowered(true);
|
||||
}
|
||||
this.checkIfDead(false);
|
||||
this.updateRender(true);
|
||||
checkIfDead(false);
|
||||
updateRender(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GameProfile getOwner() {
|
||||
return this.owner;
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(final GameProfile ownerName) {
|
||||
this.owner = ownerName;
|
||||
public void setOwner(GameProfile ownerName) {
|
||||
owner = ownerName;
|
||||
}
|
||||
|
||||
public void spawnButterflies() {
|
||||
@@ -510,57 +556,57 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
}*/
|
||||
}
|
||||
|
||||
private void attemptButterflySpawn(final World world, final IButterfly butterfly, final double x, final double y, final double z) {
|
||||
private void attemptButterflySpawn(World world, IButterfly butterfly, double x, double y, double z) {
|
||||
if (BinnieCore.isLepidopteryActive()) {
|
||||
Binnie.GENETICS.getButterflyRoot().spawnButterflyInWorld(world, butterfly.copy(), x, y + 0.10000000149011612, z);
|
||||
}
|
||||
}
|
||||
|
||||
public GameProfile getOwnerName() {
|
||||
return this.getOwner();
|
||||
return getOwner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumTemperature getTemperature() {
|
||||
return EnumTemperature.getFromValue(this.world.getBiome(getPos()).getTemperature());
|
||||
return EnumTemperature.getFromValue(world.getBiome(getPos()).getTemperature());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumHumidity getHumidity() {
|
||||
return EnumHumidity.getFromValue(this.world.getBiome(getPos()).getRainfall());
|
||||
return EnumHumidity.getFromValue(world.getBiome(getPos()).getRainfall());
|
||||
}
|
||||
|
||||
public void setErrorState(final int state) {
|
||||
public void setErrorState(int state) {
|
||||
}
|
||||
|
||||
public int getErrorOrdinal() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean addProduct(final ItemStack product, final boolean all) {
|
||||
public boolean addProduct(ItemStack product, boolean all) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IButterfly getCaterpillar() {
|
||||
return this.caterpillar;
|
||||
return caterpillar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCaterpillar(@Nullable final IButterfly butterfly) {
|
||||
this.caterpillar = butterfly;
|
||||
this.matureTime = 0;
|
||||
public void setCaterpillar(@Nullable IButterfly butterfly) {
|
||||
caterpillar = butterfly;
|
||||
matureTime = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndividual getNanny() {
|
||||
return this.getFlower();
|
||||
return getFlower();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canNurse(final IButterfly butterfly) {
|
||||
return this.getFlower() != null && !this.getFlower().isWilted() && this.getFlower().getAge() > 1;
|
||||
public boolean canNurse(IButterfly butterfly) {
|
||||
return getFlower() != null && !getFlower().isWilted() && getFlower().getAge() > 1;
|
||||
}
|
||||
|
||||
private void matureCaterpillar() {
|
||||
@@ -589,9 +635,9 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
}*/
|
||||
}
|
||||
|
||||
public void setRender(final RenderInfo render) {
|
||||
this.renderInfo = render;
|
||||
this.section = this.renderInfo.section;
|
||||
public void setRender(RenderInfo render) {
|
||||
renderInfo = render;
|
||||
section = renderInfo.section;
|
||||
if (!world.isRemote) {
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
world.notifyBlockUpdate(pos, blockState, blockState, 0);
|
||||
@@ -601,40 +647,48 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return (this.renderInfo == null) ? 1 : this.renderInfo.age;
|
||||
return (renderInfo == null) ? 1 : renderInfo.age;
|
||||
}
|
||||
|
||||
public int getRenderSection() {
|
||||
return (this.renderInfo == null) ? 1 : this.renderInfo.section;
|
||||
return (renderInfo == null) ? 1 : renderInfo.section;
|
||||
}
|
||||
|
||||
public boolean isWilted() {
|
||||
return this.renderInfo != null && this.renderInfo.wilted;
|
||||
return renderInfo != null && renderInfo.wilted;
|
||||
}
|
||||
|
||||
public boolean isFlowered() {
|
||||
return this.renderInfo == null || this.renderInfo.flowered;
|
||||
return renderInfo == null || renderInfo.flowered;
|
||||
}
|
||||
|
||||
public int getPrimaryColour() {
|
||||
return (this.renderInfo == null) ? EnumFlowerColor.Red.getFlowerColorAllele().getColor(false) : this.renderInfo.primary.getColor(this.isWilted());
|
||||
return (renderInfo == null)
|
||||
? EnumFlowerColor.Red.getFlowerColorAllele().getColor(false)
|
||||
: renderInfo.primary.getColor(isWilted());
|
||||
}
|
||||
|
||||
public int getSecondaryColour() {
|
||||
return (this.renderInfo == null) ? EnumFlowerColor.Red.getFlowerColorAllele().getColor(false) : this.renderInfo.secondary.getColor(this.isWilted());
|
||||
return (renderInfo == null)
|
||||
? EnumFlowerColor.Red.getFlowerColorAllele().getColor(false)
|
||||
: renderInfo.secondary.getColor(isWilted());
|
||||
}
|
||||
|
||||
public int getStemColour() {
|
||||
return (this.renderInfo == null) ? EnumFlowerColor.Green.getFlowerColorAllele().getColor(false) : this.renderInfo.stem.getColor(this.isWilted());
|
||||
return (renderInfo == null)
|
||||
? EnumFlowerColor.Green.getFlowerColorAllele().getColor(false)
|
||||
: renderInfo.stem.getColor(isWilted());
|
||||
}
|
||||
|
||||
public IFlowerType getType() {
|
||||
return (this.renderInfo == null) ? EnumFlowerType.Poppy : this.renderInfo.type;
|
||||
return (renderInfo == null)
|
||||
? EnumFlowerType.Poppy
|
||||
: renderInfo.type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome getBiome() {
|
||||
return this.getWorld().getBiome(getPos());
|
||||
return getWorld().getBiome(getPos());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -642,10 +696,10 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setErrorState(final IErrorState state) {
|
||||
public void setErrorState(IErrorState state) {
|
||||
}
|
||||
|
||||
public boolean setErrorCondition(final boolean condition, final IErrorState errorState) {
|
||||
public boolean setErrorCondition(boolean condition, IErrorState errorState) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -669,9 +723,9 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
}
|
||||
|
||||
public static class RenderInfo {
|
||||
public IFlowerColour primary;
|
||||
public IFlowerColour secondary;
|
||||
public IFlowerColour stem;
|
||||
public IFlowerColor primary;
|
||||
public IFlowerColor secondary;
|
||||
public IFlowerColor stem;
|
||||
public IFlowerType type;
|
||||
public byte age;
|
||||
public boolean wilted;
|
||||
@@ -681,22 +735,22 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
public RenderInfo() {
|
||||
}
|
||||
|
||||
public RenderInfo(final IFlower flower, final TileEntityFlower tile) {
|
||||
this.section = (byte) tile.getSection();
|
||||
this.primary = flower.getGenome().getPrimaryColor();
|
||||
this.secondary = flower.getGenome().getSecondaryColor();
|
||||
this.stem = flower.getGenome().getStemColor();
|
||||
this.age = (byte) flower.getAge();
|
||||
this.wilted = flower.isWilted();
|
||||
this.flowered = flower.hasFlowered();
|
||||
this.type = flower.getGenome().getType();
|
||||
public RenderInfo(IFlower flower, TileEntityFlower tile) {
|
||||
section = (byte) tile.getSection();
|
||||
primary = flower.getGenome().getPrimaryColor();
|
||||
secondary = flower.getGenome().getSecondaryColor();
|
||||
stem = flower.getGenome().getStemColor();
|
||||
age = (byte) flower.getAge();
|
||||
wilted = flower.isWilted();
|
||||
flowered = flower.hasFlowered();
|
||||
type = flower.getGenome().getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof RenderInfo) {
|
||||
final RenderInfo o = (RenderInfo) obj;
|
||||
return o.age == this.age && o.wilted == this.wilted && o.flowered == this.flowered && o.primary == this.primary && o.secondary == this.secondary && o.stem == this.stem && o.type == this.type;
|
||||
RenderInfo o = (RenderInfo) obj;
|
||||
return o.age == age && o.wilted == wilted && o.flowered == flowered && o.primary == primary && o.secondary == secondary && o.stem == stem && o.type == type;
|
||||
}
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
@@ -25,20 +24,19 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.CreativeTabBotany;
|
||||
import binnie.botany.api.EnumSoilType;
|
||||
import binnie.botany.api.IBlockSoil;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
|
||||
public class BlockPlant extends BlockBush implements IItemModelRegister {
|
||||
public static final PropertyEnum<Type> PLANT_TYPE = PropertyEnum.create("plant_type", Type.class);
|
||||
public static final PropertyEnum<PlantType> PLANT_TYPE = PropertyEnum.create("plant_type", PlantType.class);
|
||||
|
||||
public BlockPlant() {
|
||||
this.setRegistryName("plant");
|
||||
this.setCreativeTab(CreativeTabBotany.instance);
|
||||
this.setTickRandomly(true);
|
||||
this.setSoundType(SoundType.PLANT);
|
||||
setRegistryName("plant");
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
setTickRandomly(true);
|
||||
setSoundType(SoundType.PLANT);
|
||||
}
|
||||
|
||||
public static boolean isWeed(IBlockAccess world, BlockPos pos) {
|
||||
@@ -46,7 +44,8 @@ public class BlockPlant extends BlockBush implements IItemModelRegister {
|
||||
if (!(blockState.getBlock() instanceof BlockPlant)) {
|
||||
return false;
|
||||
}
|
||||
Type type = blockState.getValue(PLANT_TYPE);
|
||||
|
||||
PlantType type = blockState.getValue(PLANT_TYPE);
|
||||
return type.isWeed();
|
||||
}
|
||||
|
||||
@@ -54,7 +53,7 @@ public class BlockPlant extends BlockBush implements IItemModelRegister {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
int index = 0;
|
||||
for (Type type : Type.values()) {
|
||||
for (PlantType type : PlantType.values()) {
|
||||
manager.registerItemModel(item, index, type.getName());
|
||||
index++;
|
||||
}
|
||||
@@ -72,7 +71,7 @@ public class BlockPlant extends BlockBush implements IItemModelRegister {
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return getDefaultState().withProperty(PLANT_TYPE, Type.values()[meta]);
|
||||
return getDefaultState().withProperty(PLANT_TYPE, PlantType.values()[meta]);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,50 +90,54 @@ public class BlockPlant extends BlockBush implements IItemModelRegister {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(final Item p_149666_1_, final CreativeTabs p_149666_2_, final NonNullList<ItemStack> subBlocks) {
|
||||
for (final Type type : Type.values()) {
|
||||
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) {
|
||||
final Type type = state.getValue(PLANT_TYPE);
|
||||
PlantType type = state.getValue(PLANT_TYPE);
|
||||
if (rand.nextInt(4) == 0) {
|
||||
if (type == Type.Weeds) {
|
||||
world.setBlockState(pos, state.withProperty(PLANT_TYPE, Type.WeedsLong), 2);
|
||||
} else if (type == Type.WeedsLong) {
|
||||
world.setBlockState(pos, state.withProperty(PLANT_TYPE, Type.WeedsVeryLong), 2);
|
||||
} else if (type == Type.DeadFlower) {
|
||||
world.setBlockState(pos, state.withProperty(PLANT_TYPE, Type.DecayingFlower), 2);
|
||||
} else if (type == Type.DecayingFlower) {
|
||||
if (type == PlantType.WEEDS) {
|
||||
world.setBlockState(pos, state.withProperty(PLANT_TYPE, PlantType.WEEDS_LONG), 2);
|
||||
} else if (type == PlantType.WEEDS_LONG) {
|
||||
world.setBlockState(pos, state.withProperty(PLANT_TYPE, PlantType.WEEDS_VERY_LONG), 2);
|
||||
} else if (type == PlantType.DEAD_FLOWER) {
|
||||
world.setBlockState(pos, state.withProperty(PLANT_TYPE, PlantType.DECAYING_FLOWER), 2);
|
||||
} else if (type == PlantType.DECAYING_FLOWER) {
|
||||
world.setBlockToAir(pos);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (rand.nextInt(6) == 0) {
|
||||
if (type == Type.Weeds) {
|
||||
if (type == PlantType.WEEDS) {
|
||||
world.setBlockToAir(pos);
|
||||
} else if (type == Type.WeedsLong) {
|
||||
world.setBlockState(pos, state.withProperty(PLANT_TYPE, Type.Weeds), 2);
|
||||
} else if (type == Type.WeedsVeryLong) {
|
||||
world.setBlockState(pos, state.withProperty(PLANT_TYPE, Type.WeedsLong), 2);
|
||||
} else if (type == PlantType.WEEDS_LONG) {
|
||||
world.setBlockState(pos, state.withProperty(PLANT_TYPE, PlantType.WEEDS), 2);
|
||||
} else if (type == PlantType.WEEDS_VERY_LONG) {
|
||||
world.setBlockState(pos, state.withProperty(PLANT_TYPE, PlantType.WEEDS_LONG), 2);
|
||||
}
|
||||
}
|
||||
|
||||
Block below = world.getBlockState(pos.down()).getBlock();
|
||||
if (BotanyCore.getGardening().isSoil(below)) {
|
||||
IBlockSoil soil = (IBlockSoil) below;
|
||||
if(rand.nextInt(3) != 0){
|
||||
return;
|
||||
}
|
||||
if (type.isWeed()) {
|
||||
if (!soil.degrade(world, pos.down(), EnumSoilType.LOAM)) {
|
||||
soil.degrade(world, pos.down(), EnumSoilType.SOIL);
|
||||
}
|
||||
} else if (type == Type.DecayingFlower && !soil.fertilise(world, pos.down(), EnumSoilType.LOAM)) {
|
||||
soil.fertilise(world, pos.down(), EnumSoilType.FLOWERBED);
|
||||
if (!BotanyCore.getGardening().isSoil(below)) {
|
||||
return;
|
||||
}
|
||||
|
||||
IBlockSoil soil = (IBlockSoil) below;
|
||||
if (rand.nextInt(3) != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (type.isWeed()) {
|
||||
if (!soil.degrade(world, pos.down(), EnumSoilType.LOAM)) {
|
||||
soil.degrade(world, pos.down(), EnumSoilType.SOIL);
|
||||
}
|
||||
} else if (type == PlantType.DECAYING_FLOWER && !soil.fertilise(world, pos.down(), EnumSoilType.LOAM)) {
|
||||
soil.fertilise(world, pos.down(), EnumSoilType.FLOWERBED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,41 +150,4 @@ public class BlockPlant extends BlockBush implements IItemModelRegister {
|
||||
public EnumOffsetType getOffsetType() {
|
||||
return EnumOffsetType.XZ;
|
||||
}
|
||||
|
||||
public enum Type implements IStringSerializable {
|
||||
Weeds("weeds", true),
|
||||
WeedsLong("weeds_long", true),
|
||||
WeedsVeryLong("weeds_very_long", true),
|
||||
DeadFlower("dead_flower"),
|
||||
DecayingFlower("decaying_flower");
|
||||
|
||||
String name;
|
||||
boolean isWeed;
|
||||
|
||||
Type(String name) {
|
||||
this(name, false);
|
||||
}
|
||||
|
||||
Type(String name, boolean isWeed) {
|
||||
this.name = name;
|
||||
this.isWeed = isWeed;
|
||||
}
|
||||
|
||||
public static Type get(int id) {
|
||||
return values()[id % values().length];
|
||||
}
|
||||
|
||||
public ItemStack get() {
|
||||
return new ItemStack(Botany.plant, 1, this.ordinal());
|
||||
}
|
||||
|
||||
public boolean isWeed(){
|
||||
return isWeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,18 +47,18 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister {
|
||||
|
||||
public BlockSoil(EnumSoilType type, String blockName, boolean weedKilled) {
|
||||
super(Material.GROUND);
|
||||
this.type = type;
|
||||
this.weedKilled = weedKilled;
|
||||
setUnlocalizedName("botany.soil." + type.getName());
|
||||
this.setCreativeTab(CreativeTabBotany.instance);
|
||||
this.setRegistryName(blockName);
|
||||
this.setTickRandomly(true);
|
||||
this.setLightOpacity(255);
|
||||
this.setHardness(0.5f);
|
||||
this.setSoundType(SoundType.GROUND);
|
||||
this.type = type;
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
setRegistryName(blockName);
|
||||
setTickRandomly(true);
|
||||
setLightOpacity(255);
|
||||
setHardness(0.5f);
|
||||
setSoundType(SoundType.GROUND);
|
||||
}
|
||||
|
||||
public static int getMeta(final EnumAcidity acid, final EnumMoisture moisture) {
|
||||
public static int getMeta(EnumAcidity acid, EnumMoisture moisture) {
|
||||
return acid.ordinal() * 3 + moisture.ordinal();
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister {
|
||||
switch (side) {
|
||||
case UP:
|
||||
return true;
|
||||
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
case WEST:
|
||||
@@ -95,9 +96,8 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister {
|
||||
IBlockState iblockstate = blockAccess.getBlockState(pos.offset(side));
|
||||
Block block = iblockstate.getBlock();
|
||||
return !iblockstate.isOpaqueCube() && block != Blocks.FARMLAND && block != Blocks.GRASS_PATH && block != this;
|
||||
default:
|
||||
return super.shouldSideBeRendered(blockState, blockAccess, pos, side);
|
||||
}
|
||||
return super.shouldSideBeRendered(blockState, blockAccess, pos, side);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,8 +135,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 +150,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 +185,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 +205,24 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister {
|
||||
EnumMoisture desiredMoisture = BotanyCore.getGardening().getNaturalMoisture(world, pos);
|
||||
if (desiredMoisture.ordinal() > moisture.ordinal()) {
|
||||
moisture = ((moisture == EnumMoisture.DRY) ? EnumMoisture.NORMAL : EnumMoisture.DAMP);
|
||||
}
|
||||
if (desiredMoisture.ordinal() < moisture.ordinal()) {
|
||||
} else if (desiredMoisture.ordinal() < moisture.ordinal()) {
|
||||
moisture = ((moisture == EnumMoisture.DAMP) ? EnumMoisture.NORMAL : EnumMoisture.DRY);
|
||||
}
|
||||
|
||||
IBlockState blockState = state.withProperty(MOISTURE, moisture);
|
||||
if (state != blockState) {
|
||||
world.setBlockState(pos, blockState, 2);
|
||||
}
|
||||
if(!weedKilled){
|
||||
if(rand.nextInt(5 - getType(world, pos).ordinal()) != 0){
|
||||
|
||||
if (!weedKilled) {
|
||||
if (rand.nextInt(5 - getType(world, pos).ordinal()) != 0) {
|
||||
return;
|
||||
}
|
||||
pos = pos.up();
|
||||
if(!world.isAirBlock(pos)){
|
||||
if (!world.isAirBlock(pos)) {
|
||||
return;
|
||||
}
|
||||
world.setBlockState(pos, Botany.plant.getStateFromMeta(BlockPlant.Type.Weeds.ordinal()), 2);
|
||||
world.setBlockState(pos, Botany.gardening().plant.getStateFromMeta(PlantType.WEEDS.ordinal()), 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,48 +236,48 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAcidity getPH(final World world, final BlockPos pos) {
|
||||
public EnumAcidity getPH(World world, BlockPos pos) {
|
||||
return world.getBlockState(pos).getValue(ACIDITY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumMoisture getMoisture(final World world, final BlockPos pos) {
|
||||
public EnumMoisture getMoisture(World world, BlockPos pos) {
|
||||
return world.getBlockState(pos).getValue(MOISTURE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSoilType getType(final World world, final BlockPos pos) {
|
||||
return this.type;
|
||||
public EnumSoilType getType(World world, BlockPos pos) {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fertilise(final World world, final BlockPos pos, final EnumSoilType maxLevel) {
|
||||
final EnumSoilType type = this.getType(world, pos);
|
||||
public boolean fertilise(World world, BlockPos pos, EnumSoilType maxLevel) {
|
||||
EnumSoilType type = getType(world, pos);
|
||||
if (type.ordinal() >= maxLevel.ordinal()) {
|
||||
return false;
|
||||
}
|
||||
final IBlockState old = world.getBlockState(pos);
|
||||
return world.setBlockState(pos, BotanyCore.getGardening().getSoilBlock(maxLevel, this.weedKilled).getDefaultState().withProperty(ACIDITY, old.getValue(ACIDITY)).withProperty(MOISTURE, old.getValue(MOISTURE)), 2);
|
||||
IBlockState old = world.getBlockState(pos);
|
||||
return world.setBlockState(pos, BotanyCore.getGardening().getSoilBlock(maxLevel, weedKilled).getDefaultState().withProperty(ACIDITY, old.getValue(ACIDITY)).withProperty(MOISTURE, old.getValue(MOISTURE)), 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean degrade(final World world, final BlockPos pos, final EnumSoilType minLevel) {
|
||||
final EnumSoilType type = this.getType(world, pos);
|
||||
public boolean degrade(World world, BlockPos pos, EnumSoilType minLevel) {
|
||||
EnumSoilType type = getType(world, pos);
|
||||
if (type.ordinal() <= minLevel.ordinal()) {
|
||||
return false;
|
||||
}
|
||||
final IBlockState old = world.getBlockState(pos);
|
||||
return world.setBlockState(pos, BotanyCore.getGardening().getSoilBlock(minLevel, this.weedKilled).getDefaultState().withProperty(ACIDITY, old.getValue(ACIDITY)).withProperty(MOISTURE, old.getValue(MOISTURE)), 2);
|
||||
IBlockState old = world.getBlockState(pos);
|
||||
return world.setBlockState(pos, BotanyCore.getGardening().getSoilBlock(minLevel, weedKilled).getDefaultState().withProperty(ACIDITY, old.getValue(ACIDITY)).withProperty(MOISTURE, old.getValue(MOISTURE)), 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setPH(final World world, final BlockPos pos, final EnumAcidity pH) {
|
||||
public boolean setPH(World world, BlockPos pos, EnumAcidity pH) {
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
return world.setBlockState(pos, blockState.withProperty(ACIDITY, pH));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setMoisture(final World world, final BlockPos pos, final EnumMoisture moisture) {
|
||||
public boolean setMoisture(World world, BlockPos pos, EnumMoisture moisture) {
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
return world.setBlockState(pos, blockState.withProperty(MOISTURE, moisture));
|
||||
}
|
||||
@@ -293,15 +296,16 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister {
|
||||
if (plant.getBlock() == Botany.flower) {
|
||||
return true;
|
||||
}
|
||||
if (plant.getBlock() == Botany.plant) {
|
||||
return !this.weedKilled || !BlockPlant.isWeed(world, pos);
|
||||
|
||||
if (plant.getBlock() == Botany.gardening().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() {
|
||||
|
||||
@@ -33,25 +33,26 @@ public class Gardening implements IGardeningManager {
|
||||
private final Map<ItemStack, Integer> fertiliserAcid = new LinkedHashMap<>();
|
||||
private final Map<ItemStack, Integer> fertiliserAlkaline = new LinkedHashMap<>();
|
||||
private final Map<ItemStack, Integer> fertiliserNutrient = new LinkedHashMap<>();
|
||||
|
||||
|
||||
public Gardening() {
|
||||
// ignored
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isSoil(final Block block) {
|
||||
public boolean isSoil(Block block) {
|
||||
return block instanceof IBlockSoil;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isSoil(final Item item) {
|
||||
public boolean isSoil(Item item) {
|
||||
return item instanceof ItemBlock && isSoil(((ItemBlock) item).getBlock());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isSoil(final ItemStack item) {
|
||||
public boolean isSoil(ItemStack item) {
|
||||
return isSoil(item.getItem());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EnumMoisture getNaturalMoisture(World world, BlockPos pos) {
|
||||
float bias = getBiomeMoisture(world, pos);
|
||||
@@ -66,9 +67,11 @@ public class Gardening implements IGardeningManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (world.isRaining() && world.canBlockSeeSky(pos.up()) && world.getPrecipitationHeight(pos).getY() <= pos.getY() + 1) {
|
||||
bias += 1.5;
|
||||
}
|
||||
|
||||
for (int dx = -1; dx < 2; ++dx) {
|
||||
for (int dz = -1; dz < 2; ++dz) {
|
||||
if (dx != 0 || dz != 0) {
|
||||
@@ -80,13 +83,16 @@ public class Gardening implements IGardeningManager {
|
||||
}
|
||||
return (bias <= -1.0f) ? EnumMoisture.DRY : ((bias >= 1.0f) ? EnumMoisture.DAMP : EnumMoisture.NORMAL);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EnumAcidity getNaturalPH(World world, BlockPos pos) {
|
||||
final float bias = getBiomePH(world, pos);
|
||||
return (bias <= -1.0f) ? EnumAcidity.ACID : ((bias >= 1.0f) ? EnumAcidity.ALKALINE : EnumAcidity.NEUTRAL);
|
||||
float bias = getBiomePH(world, pos);
|
||||
if (bias <= -1.0f) {
|
||||
return EnumAcidity.ACID;
|
||||
}
|
||||
return (bias >= 1.0f) ? EnumAcidity.ALKALINE : EnumAcidity.NEUTRAL;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public float getBiomeMoisture(World world, BlockPos pos) {
|
||||
IClimateInfo info = ForestryAPI.climateManager.getInfo(world, pos);
|
||||
@@ -95,7 +101,7 @@ public class Gardening implements IGardeningManager {
|
||||
double m = 3.2 * (humidity - 0.5) - 0.4 * (1.0 + temperature + 0.5 * temperature * temperature) + 1.1 - 1.6 * (temperature - 0.9) * (temperature - 0.9) - 0.002 * (pos.getY() - 64);
|
||||
return (float) ((m == 0.0) ? m : ((m < 0.0) ? (-Math.sqrt(m * m)) : Math.sqrt(m * m)));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public float getBiomePH(World world, BlockPos pos) {
|
||||
IClimateInfo info = ForestryAPI.climateManager.getInfo(world, pos);
|
||||
@@ -103,151 +109,156 @@ public class Gardening implements IGardeningManager {
|
||||
double temperature = info.getTemperature();
|
||||
return (float) (-3.0 * (humidity - 0.5) + 0.5 * (temperature - 0.699999988079071) * (temperature - 0.699999988079071) + 0.02f * (pos.getY() - 64) - 0.15000000596046448);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void plantSoil(final World world, final BlockPos pos, final EnumSoilType soil, final EnumMoisture moisture, final EnumAcidity acidity) {
|
||||
final int meta = moisture.ordinal() + acidity.ordinal() * 3;
|
||||
public void plantSoil(World world, BlockPos pos, EnumSoilType soil, EnumMoisture moisture, EnumAcidity acidity) {
|
||||
int meta = moisture.ordinal() + acidity.ordinal() * 3;
|
||||
world.setBlockState(pos, getSoilBlock(soil).getStateFromMeta(meta), 2);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Collection<ItemStack> getAcidFertilisers() {
|
||||
return Collections.unmodifiableSet(fertiliserAcid.keySet());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Collection<ItemStack> getAlkalineFertilisers() {
|
||||
return Collections.unmodifiableSet(fertiliserAlkaline.keySet());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Collection<ItemStack> getNutrientFertilisers() {
|
||||
return Collections.unmodifiableSet(fertiliserNutrient.keySet());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void registerAcidFertiliser(ItemStack stack, int strength) {
|
||||
ModuleGardening.queuedAcidFertilisers.put(stack, strength);
|
||||
fertiliserAcid.put(stack, strength);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void registerAlkalineFertiliser(ItemStack stack, int strength) {
|
||||
ModuleGardening.queuedAlkalineFertilisers.put(stack, strength);
|
||||
fertiliserAlkaline.put(stack, strength);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void registerNutrientFertiliser(ItemStack stack, int strength) {
|
||||
ModuleGardening.queuedNutrientFertilisers.put(stack, strength);
|
||||
fertiliserNutrient.put(stack, strength);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isAcidFertiliser(final ItemStack itemstack) {
|
||||
for (final ItemStack stack : getAcidFertilisers()) {
|
||||
public boolean isAcidFertiliser(ItemStack itemstack) {
|
||||
for (ItemStack stack : getAcidFertilisers()) {
|
||||
if (!stack.isEmpty() && stack.isItemEqual(itemstack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isAlkalineFertiliser(final ItemStack itemstack) {
|
||||
for (final ItemStack stack : getAlkalineFertilisers()) {
|
||||
public boolean isAlkalineFertiliser(ItemStack itemstack) {
|
||||
for (ItemStack stack : getAlkalineFertilisers()) {
|
||||
if (!stack.isEmpty() && stack.isItemEqual(itemstack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isNutrientFertiliser(final ItemStack itemstack) {
|
||||
for (final ItemStack stack : getNutrientFertilisers()) {
|
||||
public boolean isNutrientFertiliser(ItemStack itemstack) {
|
||||
for (ItemStack stack : getNutrientFertilisers()) {
|
||||
if (!stack.isEmpty() && stack.isItemEqual(itemstack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getFertiliserStrength(final ItemStack stack) {
|
||||
for (final Map.Entry<ItemStack, Integer> entry : fertiliserAcid.entrySet()) {
|
||||
public int getFertiliserStrength(ItemStack stack) {
|
||||
for (Map.Entry<ItemStack, Integer> entry : fertiliserAcid.entrySet()) {
|
||||
if (entry.getKey().isItemEqual(stack)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
for (final Map.Entry<ItemStack, Integer> entry : fertiliserAlkaline.entrySet()) {
|
||||
for (Map.Entry<ItemStack, Integer> entry : fertiliserAlkaline.entrySet()) {
|
||||
if (entry.getKey().isItemEqual(stack)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
for (final Map.Entry<ItemStack, Integer> entry : fertiliserNutrient.entrySet()) {
|
||||
for (Map.Entry<ItemStack, Integer> entry : fertiliserNutrient.entrySet()) {
|
||||
if (entry.getKey().isItemEqual(stack)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canTolerate(@Nullable final IFlower flower, final World world, final BlockPos pos) {
|
||||
public boolean canTolerate(@Nullable IFlower flower, World world, BlockPos pos) {
|
||||
if (flower == null) {
|
||||
return false;
|
||||
}
|
||||
IBlockState soil = world.getBlockState(pos.down());
|
||||
final Block soilBlock = soil.getBlock();
|
||||
final int soilMeta = soilBlock.getMetaFromState(soil);
|
||||
final Biome biome = world.getBiome(pos);
|
||||
return canTolerate(flower, EnumAcidity.values()[soilMeta / 3 % 3], EnumMoisture.values()[soilMeta % 3], EnumTemperature.getFromValue(biome.getTemperature()));
|
||||
Block soilBlock = soil.getBlock();
|
||||
int soilMeta = soilBlock.getMetaFromState(soil);
|
||||
Biome biome = world.getBiome(pos);
|
||||
return canTolerate(
|
||||
flower,
|
||||
EnumAcidity.values()[soilMeta / 3 % 3],
|
||||
EnumMoisture.values()[soilMeta % 3],
|
||||
EnumTemperature.getFromValue(biome.getTemperature())
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSoilType getSoilType(final World world, final BlockPos pos) {
|
||||
public EnumSoilType getSoilType(World world, BlockPos pos) {
|
||||
if (world.getBlockState(pos).getBlock() instanceof IBlockSoil) {
|
||||
return ((IBlockSoil) world.getBlockState(pos).getBlock()).getType(world, pos);
|
||||
}
|
||||
return EnumSoilType.SOIL;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Block getSoilBlock(final EnumSoilType type) {
|
||||
public Block getSoilBlock(EnumSoilType type) {
|
||||
return getSoilBlock(type, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Block getSoilBlock(final EnumSoilType type, final boolean weedkill) {
|
||||
public Block getSoilBlock(EnumSoilType type, boolean weedKill) {
|
||||
switch (type) {
|
||||
case FLOWERBED: {
|
||||
return weedkill ? Botany.flowerbedNoWeed : Botany.flowerbed;
|
||||
}
|
||||
case LOAM: {
|
||||
return weedkill ? Botany.loamNoWeed : Botany.loam;
|
||||
}
|
||||
default: {
|
||||
return weedkill ? Botany.soilNoWeed : Botany.soil;
|
||||
}
|
||||
case FLOWERBED:
|
||||
return weedKill ? Botany.gardening().flowerbedNoWeed : Botany.gardening().flowerbed;
|
||||
|
||||
case LOAM:
|
||||
return weedKill ? Botany.gardening().loamNoWeed : Botany.gardening().loam;
|
||||
}
|
||||
return weedKill ? Botany.gardening().soilNoWeed : Botany.gardening().soil;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canTolerate(IFlower flower, EnumAcidity ePH, EnumMoisture eMoisture, EnumTemperature eTemp) {
|
||||
return flower.getGenome().canTolerate(ePH) && flower.getGenome().canTolerate(eMoisture) && flower.getGenome().canTolerate(eTemp);
|
||||
public boolean canTolerate(IFlower flower, EnumAcidity acidity, EnumMoisture moisture, EnumTemperature temperature) {
|
||||
return flower.getGenome().canTolerate(acidity)
|
||||
&& flower.getGenome().canTolerate(moisture)
|
||||
&& flower.getGenome().canTolerate(temperature);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isWeedkiller(ItemStack heldItem) {
|
||||
return heldItem.isItemEqual(BotanyItems.Weedkiller.get(1));
|
||||
return heldItem.isItemEqual(BotanyItems.WEEDKILLER.get(1));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean addWeedKiller(World world, BlockPos pos) {
|
||||
if (!(world.getBlockState(pos).getBlock() instanceof IBlockSoil)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
EnumSoilType type = getSoilType(world, pos);
|
||||
Block block = getSoilBlock(type, true);
|
||||
IBlockState oldState = world.getBlockState(pos);
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package binnie.botany.gardening;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -19,35 +22,36 @@ public class ItemSoil extends ItemBlock {
|
||||
|
||||
public ItemSoil(BlockSoil block) {
|
||||
super(block);
|
||||
this.type = block.getType();
|
||||
this.noWeed = block.isWeedKilled();
|
||||
this.hasSubtypes = true;
|
||||
type = block.getType();
|
||||
noWeed = block.isWeedKilled();
|
||||
hasSubtypes = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(final ItemStack stack, final EntityPlayer playerIn, final List<String> tooltip, final boolean advanced) {
|
||||
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
|
||||
String info = "";
|
||||
info += BlockSoil.getMoisture(stack, true, true);
|
||||
if (info.length() > 0) {
|
||||
info += ", ";
|
||||
}
|
||||
|
||||
info += BlockSoil.getPH(stack, true, true);
|
||||
if (info.length() > 0) {
|
||||
tooltip.add(info);
|
||||
}
|
||||
if (this.noWeed) {
|
||||
|
||||
if (noWeed) {
|
||||
tooltip.add(TextFormatting.GREEN + I18N.localise("botany.soil.weedkiller"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
return this.getUnlocalizedNameInefficiently(stack).trim();
|
||||
return getUnlocalizedNameInefficiently(stack).trim();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(final int damage) {
|
||||
public int getMetadata(int damage) {
|
||||
return damage;
|
||||
}
|
||||
}
|
||||
@@ -30,9 +30,9 @@ import binnie.core.util.I18N;
|
||||
|
||||
public class ItemSoilMeter extends Item implements IItemModelRegister {
|
||||
public ItemSoilMeter() {
|
||||
this.setCreativeTab(CreativeTabBotany.instance);
|
||||
this.setUnlocalizedName("soil_meter");
|
||||
this.setMaxStackSize(1);
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
setUnlocalizedName("botany.soil_meter");
|
||||
setMaxStackSize(1);
|
||||
setRegistryName("soil_meter");
|
||||
}
|
||||
|
||||
@@ -70,26 +70,24 @@ public class ItemSoilMeter extends Item implements IItemModelRegister {
|
||||
pos = pos.down();
|
||||
block = worldIn.getBlockState(pos).getBlock();
|
||||
}
|
||||
|
||||
if (!gardening.isSoil(block)) {
|
||||
pos = pos.down();
|
||||
block = worldIn.getBlockState(pos).getBlock();
|
||||
}
|
||||
|
||||
if (gardening.isSoil(block) && !BinnieCore.getBinnieProxy().isSimulating(worldIn)) {
|
||||
IBlockSoil soil = (IBlockSoil) block;
|
||||
String info = I18N.localise("botany.soil.type") + ": ";
|
||||
info = info + soil.getType(worldIn, pos).getTranslated(true);
|
||||
info += ", " + TextFormatting.WHITE + I18N.localise("botany.moisture") + ": ";
|
||||
info = info + soil.getMoisture(worldIn, pos).getLocalisedName(true);
|
||||
info += ", " + TextFormatting.WHITE + I18N.localise("botany.ph") + ": ";
|
||||
info = info + soil.getPH(worldIn, pos).getLocalisedName(true);
|
||||
String info = I18N.localise("botany.soil.type") + ": "
|
||||
+ soil.getType(worldIn, pos).getTranslated() + ", "
|
||||
+ TextFormatting.WHITE + I18N.localise("botany.moisture") + ": "
|
||||
+ soil.getMoisture(worldIn, pos).getLocalisedName(true) + ", "
|
||||
+ TextFormatting.WHITE + I18N.localise("botany.ph") + ": "
|
||||
+ soil.getPH(worldIn, pos).getLocalisedName(true);
|
||||
|
||||
ITextComponent chat = new TextComponentString(info);
|
||||
player.sendStatusMessage(chat, false);
|
||||
}
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack i) {
|
||||
return "Soil Meter";
|
||||
}
|
||||
}
|
||||
@@ -39,23 +39,23 @@ import binnie.botany.core.BotanyCore;
|
||||
|
||||
public class ItemTrowel extends Item implements IItemModelRegister {
|
||||
protected final ToolMaterial theToolMaterial;
|
||||
protected final String locName;
|
||||
protected final String modelName;
|
||||
|
||||
public ItemTrowel(ToolMaterial p_i45343_1_, final String material) {
|
||||
this.theToolMaterial = p_i45343_1_;
|
||||
this.maxStackSize = 1;
|
||||
this.setMaxDamage(p_i45343_1_.getMaxUses());
|
||||
this.setCreativeTab(CreativeTabBotany.instance);
|
||||
this.setUnlocalizedName("trowel_" + material);
|
||||
this.locName = "trowel_" + material;
|
||||
setRegistryName("trowel_" + material);
|
||||
public ItemTrowel(ToolMaterial toolMaterial, String materialName) {
|
||||
theToolMaterial = toolMaterial;
|
||||
setMaxStackSize(1);
|
||||
setMaxDamage(toolMaterial.getMaxUses());
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
modelName = "trowel_" + materialName;
|
||||
setUnlocalizedName("botany." + modelName);
|
||||
setRegistryName(modelName);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
manager.registerItemModel(item, new ItemTrowelMeshDefinition());
|
||||
ModelBakery.registerItemVariants(item, new ResourceLocation(Constants.BOTANY_MOD_ID + ":tools/" + locName));
|
||||
ModelBakery.registerItemVariants(item, new ResourceLocation(Constants.BOTANY_MOD_ID + ":tools/" + modelName));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,14 +64,17 @@ public class ItemTrowel extends Item implements IItemModelRegister {
|
||||
if (!player.canPlayerEdit(pos, facing, stack)) {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
Block block = worldIn.getBlockState(pos).getBlock();
|
||||
if (facing == EnumFacing.DOWN || (!worldIn.isAirBlock(pos.up()) && worldIn.getBlockState(pos.up()).getBlock() != Botany.flower) || (block != Blocks.GRASS && block != Blocks.DIRT && block != Blocks.GRASS_PATH)) {
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
|
||||
worldIn.playSound(player, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
if (worldIn.isRemote) {
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
IGardeningManager gardening = BotanyCore.getGardening();
|
||||
EnumMoisture moisture = gardening.getNaturalMoisture(worldIn, pos);
|
||||
EnumAcidity acidity = gardening.getNaturalPH(worldIn, pos);
|
||||
@@ -99,14 +102,14 @@ public class ItemTrowel extends Item implements IItemModelRegister {
|
||||
}
|
||||
|
||||
public String getToolMaterialName() {
|
||||
return this.theToolMaterial.toString();
|
||||
return theToolMaterial.toString();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private class ItemTrowelMeshDefinition implements ItemMeshDefinition {
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack) {
|
||||
return new ModelResourceLocation(Constants.BOTANY_MOD_ID + ":tools/" + locName, "inventory");
|
||||
return new ModelResourceLocation(Constants.BOTANY_MOD_ID + ":tools/" + modelName, "inventory");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,13 +9,13 @@ import binnie.core.util.I18N;
|
||||
public class ItemWeed extends ItemBlock {
|
||||
public ItemWeed(Block block) {
|
||||
super(block);
|
||||
this.setHasSubtypes(true);
|
||||
this.hasSubtypes = true;
|
||||
setHasSubtypes(true);
|
||||
hasSubtypes = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack stack) {
|
||||
return I18N.localise("botany.plant." + BlockPlant.Type.values()[stack.getItemDamage()].getName());
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
return I18N.localise("botany.plant." + PlantType.values()[stack.getItemDamage()].getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,11 +3,16 @@ package binnie.botany.gardening;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import binnie.Constants;
|
||||
import binnie.botany.flower.EnumTubeInsulate;
|
||||
import binnie.botany.flower.EnumTubeMaterial;
|
||||
import binnie.core.util.RecipeUtil;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.RecipeSorter;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
@@ -51,71 +56,96 @@ public class ModuleGardening implements IInitializable {
|
||||
public static final HashMap<ItemStack, Integer> queuedAlkalineFertilisers = new HashMap<>();
|
||||
public static final HashMap<ItemStack, Integer> queuedNutrientFertilisers = new HashMap<>();
|
||||
|
||||
public BlockPlant plant;
|
||||
public ItemTrowel trowelWood;
|
||||
public ItemTrowel trowelStone;
|
||||
public ItemTrowel trowelIron;
|
||||
public ItemTrowel trowelDiamond;
|
||||
public ItemTrowel trowelGold;
|
||||
public BlockSoil soil;
|
||||
public BlockSoil loam;
|
||||
public BlockSoil flowerbed;
|
||||
public BlockSoil soilNoWeed;
|
||||
public BlockSoil loamNoWeed;
|
||||
public BlockSoil flowerbedNoWeed;
|
||||
public ItemInsulatedTube insulatedTube;
|
||||
public ItemSoilMeter soilMeter;
|
||||
public ItemMisc misc;
|
||||
public ItemPigment pigment;
|
||||
public ItemClay clay;
|
||||
public BlockCeramic ceramic;
|
||||
public BlockCeramicPatterned ceramicTile;
|
||||
public BlockStainedGlass stained;
|
||||
public BlockCeramicBrick ceramicBrick;
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
Botany.plant = new BlockPlant();
|
||||
Botany.proxy.registerBlock(Botany.plant, new ItemWeed(Botany.plant));
|
||||
Botany.soil = new BlockSoil(EnumSoilType.SOIL, "soil", false);
|
||||
Botany.proxy.registerBlock(Botany.soil, new ItemSoil(Botany.soil));
|
||||
Botany.loam = new BlockSoil(EnumSoilType.LOAM, "loam", false);
|
||||
Botany.proxy.registerBlock(Botany.loam, new ItemSoil(Botany.loam));
|
||||
Botany.flowerbed = new BlockSoil(EnumSoilType.FLOWERBED, "flowerbed", false);
|
||||
Botany.proxy.registerBlock(Botany.flowerbed, new ItemSoil(Botany.flowerbed));
|
||||
Botany.soilNoWeed = new BlockSoil(EnumSoilType.SOIL, "soil_no_weed", true);
|
||||
Botany.proxy.registerBlock(Botany.soilNoWeed, new ItemSoil(Botany.soilNoWeed));
|
||||
Botany.loamNoWeed = new BlockSoil(EnumSoilType.LOAM, "loam_no_weed", true);
|
||||
Botany.proxy.registerBlock(Botany.loamNoWeed, new ItemSoil(Botany.loamNoWeed));
|
||||
Botany.flowerbedNoWeed = new BlockSoil(EnumSoilType.FLOWERBED, "flowerbed_no_weed", true);
|
||||
Botany.proxy.registerBlock(Botany.flowerbedNoWeed, new ItemSoil(Botany.flowerbedNoWeed));
|
||||
Botany.soilMeter = new ItemSoilMeter();
|
||||
Botany.proxy.registerItem(Botany.soilMeter);
|
||||
Botany.insulatedTube = new ItemInsulatedTube();
|
||||
Botany.proxy.registerItem(Botany.insulatedTube);
|
||||
Botany.trowelWood = new ItemTrowel(Item.ToolMaterial.WOOD, "wood");
|
||||
Botany.proxy.registerItem(Botany.trowelWood);
|
||||
Botany.trowelStone = new ItemTrowel(Item.ToolMaterial.STONE, "stone");
|
||||
Botany.proxy.registerItem(Botany.trowelStone);
|
||||
Botany.trowelIron = new ItemTrowel(Item.ToolMaterial.IRON, "iron");
|
||||
Botany.proxy.registerItem(Botany.trowelIron);
|
||||
Botany.trowelDiamond = new ItemTrowel(Item.ToolMaterial.DIAMOND, "diamond");
|
||||
Botany.proxy.registerItem(Botany.trowelDiamond);
|
||||
Botany.trowelGold = new ItemTrowel(Item.ToolMaterial.GOLD, "gold");
|
||||
Botany.proxy.registerItem(Botany.trowelGold);
|
||||
Botany.misc = new ItemMisc(CreativeTabBotany.instance, BotanyItems.values());
|
||||
Botany.proxy.registerItem(Botany.misc);
|
||||
Botany.pigment = new ItemPigment();
|
||||
Botany.proxy.registerItem(Botany.pigment);
|
||||
Botany.clay = new ItemClay();
|
||||
Botany.proxy.registerItem(Botany.clay);
|
||||
Botany.ceramic = new BlockCeramic();
|
||||
Botany.proxy.registerBlock(Botany.ceramic, new ItemCeramic(Botany.ceramic));
|
||||
plant = new BlockPlant();
|
||||
soil = new BlockSoil(EnumSoilType.SOIL, "soil", false);
|
||||
loam = new BlockSoil(EnumSoilType.LOAM, "loam", false);
|
||||
flowerbed = new BlockSoil(EnumSoilType.FLOWERBED, "flowerbed", false);
|
||||
soilNoWeed = new BlockSoil(EnumSoilType.SOIL, "soil_no_weed", true);
|
||||
loamNoWeed = new BlockSoil(EnumSoilType.LOAM, "loam_no_weed", true);
|
||||
flowerbedNoWeed = new BlockSoil(EnumSoilType.FLOWERBED, "flowerbed_no_weed", true);
|
||||
soilMeter = new ItemSoilMeter();
|
||||
insulatedTube = new ItemInsulatedTube();
|
||||
trowelWood = new ItemTrowel(Item.ToolMaterial.WOOD, "wood");
|
||||
trowelStone = new ItemTrowel(Item.ToolMaterial.STONE, "stone");
|
||||
trowelIron = new ItemTrowel(Item.ToolMaterial.IRON, "iron");
|
||||
trowelDiamond = new ItemTrowel(Item.ToolMaterial.DIAMOND, "diamond");
|
||||
trowelGold = new ItemTrowel(Item.ToolMaterial.GOLD, "gold");
|
||||
misc = new ItemMisc(CreativeTabBotany.instance, BotanyItems.values());
|
||||
pigment = new ItemPigment();
|
||||
clay = new ItemClay();
|
||||
ceramic = new BlockCeramic();
|
||||
stained = new BlockStainedGlass();
|
||||
ceramicTile = new BlockCeramicPatterned();
|
||||
ceramicBrick = new BlockCeramicBrick();
|
||||
|
||||
Botany.proxy.registerBlock(plant, new ItemWeed(plant));
|
||||
Botany.proxy.registerBlock(soil, new ItemSoil(soil));
|
||||
Botany.proxy.registerBlock(loam, new ItemSoil(loam));
|
||||
Botany.proxy.registerBlock(flowerbed, new ItemSoil(flowerbed));
|
||||
Botany.proxy.registerBlock(soilNoWeed, new ItemSoil(soilNoWeed));
|
||||
Botany.proxy.registerBlock(loamNoWeed, new ItemSoil(loamNoWeed));
|
||||
Botany.proxy.registerBlock(flowerbedNoWeed, new ItemSoil(flowerbedNoWeed));
|
||||
Botany.proxy.registerItem(soilMeter);
|
||||
Botany.proxy.registerItem(insulatedTube);
|
||||
Botany.proxy.registerItem(trowelWood);
|
||||
Botany.proxy.registerItem(trowelStone);
|
||||
Botany.proxy.registerItem(trowelIron);
|
||||
Botany.proxy.registerItem(trowelDiamond);
|
||||
Botany.proxy.registerItem(trowelGold);
|
||||
Botany.proxy.registerItem(misc);
|
||||
Botany.proxy.registerItem(pigment);
|
||||
Botany.proxy.registerItem(clay);
|
||||
Botany.proxy.registerBlock(ceramic, new ItemCeramic(ceramic));
|
||||
Botany.proxy.registerBlock(stained, new ItemStainedGlass(stained));
|
||||
Botany.proxy.registerBlock(ceramicTile, new ItemDesign(ceramicTile));
|
||||
Botany.proxy.registerBlock(ceramicBrick, new ItemCeramicBrick(ceramicBrick));
|
||||
|
||||
BinnieCore.getBinnieProxy().registerTileEntity(TileCeramic.class, "botany.tile.ceramic");
|
||||
//BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.ceramic), new ItemMetadataRenderer());
|
||||
Botany.stained = new BlockStainedGlass();
|
||||
Botany.proxy.registerBlock(Botany.stained, new ItemStainedGlass(Botany.stained));
|
||||
//BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.stained), new ItemMetadataRenderer());
|
||||
Botany.ceramicTile = new BlockCeramicPatterned();
|
||||
Botany.proxy.registerBlock(Botany.ceramicTile, new ItemDesign(Botany.ceramicTile));
|
||||
Botany.ceramicBrick = new BlockCeramicBrick();
|
||||
Botany.proxy.registerBlock(Botany.ceramicBrick, new ItemCeramicBrick(Botany.ceramicBrick));
|
||||
//BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(ceramic), new ItemMetadataRenderer());
|
||||
//BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(stained), new ItemMetadataRenderer());
|
||||
BinnieCore.getBinnieProxy().registerTileEntity(TileCeramicBrick.class, "botany.tile.ceramicBrick");
|
||||
//BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.ceramicTile), new MultipassItemRenderer());
|
||||
//BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.ceramicBrick), new MultipassItemRenderer());
|
||||
OreDictionary.registerOre("pigment", Botany.pigment);
|
||||
OreDictionary.registerOre("toolTrowel", Botany.trowelWood);
|
||||
OreDictionary.registerOre("toolTrowel", Botany.trowelStone);
|
||||
OreDictionary.registerOre("toolTrowel", Botany.trowelIron);
|
||||
OreDictionary.registerOre("toolTrowel", Botany.trowelGold);
|
||||
OreDictionary.registerOre("toolTrowel", Botany.trowelDiamond);
|
||||
//BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(ceramicTile), new MultipassItemRenderer());
|
||||
//BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(ceramicBrick), new MultipassItemRenderer());
|
||||
|
||||
OreDictionary.registerOre("pigment", pigment);
|
||||
OreDictionary.registerOre("toolTrowel", trowelWood);
|
||||
OreDictionary.registerOre("toolTrowel", trowelStone);
|
||||
OreDictionary.registerOre("toolTrowel", trowelIron);
|
||||
OreDictionary.registerOre("toolTrowel", trowelGold);
|
||||
OreDictionary.registerOre("toolTrowel", trowelDiamond);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
RecipeSorter.register("botany:ceramictile", CeramicTileRecipe.class, RecipeSorter.Category.SHAPED, "");
|
||||
RecipeSorter.register("botany:pigment", PigmentRecipe.class, RecipeSorter.Category.SHAPED, "");
|
||||
final ItemStack yellow = new ItemStack(Blocks.YELLOW_FLOWER, 1);
|
||||
final ItemStack red = new ItemStack(Blocks.RED_FLOWER, 1);
|
||||
final ItemStack blue = new ItemStack(Blocks.RED_FLOWER, 1, 7);
|
||||
ItemStack yellow = new ItemStack(Blocks.YELLOW_FLOWER, 1);
|
||||
ItemStack red = new ItemStack(Blocks.RED_FLOWER, 1);
|
||||
ItemStack blue = new ItemStack(Blocks.RED_FLOWER, 1, 7);
|
||||
for (boolean manual : new boolean[]{true, false}) {
|
||||
for (boolean fertilised : new boolean[]{true, false}) {
|
||||
for (EnumMoisture moist : EnumMoisture.values()) {
|
||||
@@ -131,10 +161,10 @@ public class ModuleGardening implements IInitializable {
|
||||
if (fertilised) {
|
||||
insulate += 3;
|
||||
}
|
||||
new CircuitGarden(moist, null, manual, fertilised, new ItemStack(Botany.insulatedTube, 1, 0 + 128 * insulate), icon);
|
||||
new CircuitGarden(moist, EnumAcidity.ACID, manual, fertilised, new ItemStack(Botany.insulatedTube, 1, 1 + 128 * insulate), icon);
|
||||
new CircuitGarden(moist, EnumAcidity.NEUTRAL, manual, fertilised, new ItemStack(Botany.insulatedTube, 1, 2 + 128 * insulate), icon);
|
||||
new CircuitGarden(moist, EnumAcidity.ALKALINE, manual, fertilised, new ItemStack(Botany.insulatedTube, 1, 3 + 128 * insulate), icon);
|
||||
new CircuitGarden(moist, null, manual, fertilised, new ItemStack(insulatedTube, 1, 128 * insulate), icon);
|
||||
new CircuitGarden(moist, EnumAcidity.ACID, manual, fertilised, new ItemStack(insulatedTube, 1, 1 + 128 * insulate), icon);
|
||||
new CircuitGarden(moist, EnumAcidity.NEUTRAL, manual, fertilised, new ItemStack(insulatedTube, 1, 2 + 128 * insulate), icon);
|
||||
new CircuitGarden(moist, EnumAcidity.ALKALINE, manual, fertilised, new ItemStack(insulatedTube, 1, 3 + 128 * insulate), icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -142,89 +172,179 @@ public class ModuleGardening implements IInitializable {
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
RecipeUtil recipeUtil = new RecipeUtil(Constants.BOTANY_MOD_ID);
|
||||
IGardeningManager gardening = BotanyCore.getGardening();
|
||||
GameRegistry.addRecipe(new CeramicTileRecipe());
|
||||
for (int mat = 0; mat < 4; ++mat) {
|
||||
for (int insulate = 0; insulate < 6; ++insulate) {
|
||||
final ItemStack tubes = new ItemStack(Botany.insulatedTube, 2, mat + 128 * insulate);
|
||||
final ItemStack insulateStack = ItemInsulatedTube.getInsulateStack(tubes);
|
||||
final ItemStack forestryTube = new ItemStack(Mods.Forestry.item("thermionic_tubes"), 1, mat);
|
||||
GameRegistry.addShapelessRecipe(tubes, forestryTube, forestryTube, insulateStack);
|
||||
ForgeRegistries.RECIPES.register(new CeramicTileRecipe());
|
||||
for (EnumTubeMaterial mat: EnumTubeMaterial.VALUES) {
|
||||
for (EnumTubeInsulate insulate : EnumTubeInsulate.VALUES) {
|
||||
ItemStack tubes = new ItemStack(insulatedTube, 2, mat.ordinal() + 128 * insulate.ordinal());
|
||||
ItemStack insulateStack = ItemInsulatedTube.getInsulateStack(tubes);
|
||||
ItemStack forestryTube = new ItemStack(Mods.Forestry.item("thermionic_tubes"), 1, mat.ordinal());
|
||||
String recipeName = "thermionic_tubes_" + insulate.getUid() + "_" + mat.getUid();
|
||||
recipeUtil.addShapelessRecipe(recipeName, tubes, forestryTube, forestryTube, insulateStack);
|
||||
}
|
||||
}
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(Botany.trowelWood, "d ", " x ", " s", 'd', Blocks.DIRT, 's', "stickWood", 'x', "plankWood"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(Botany.trowelStone, "d ", " x ", " s", 'd', Blocks.DIRT, 's', "stickWood", 'x', "cobblestone"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(Botany.trowelIron, "d ", " x ", " s", 'd', Blocks.DIRT, 's', "stickWood", 'x', "ingotIron"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(Botany.trowelGold, "d ", " x ", " s", 'd', Blocks.DIRT, 's', "stickWood", 'x', "ingotGold"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(Botany.trowelDiamond, "d ", " x ", " s", 'd', Blocks.DIRT, 's', "stickWood", 'x', "gemDiamond"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(Botany.soilMeter, " gg", " rg", "i ", 'g', "ingotGold", 'r', "dustRedstone", 'i', "ingotIron"));
|
||||
GameRegistry.addShapelessRecipe(BotanyItems.Weedkiller.get(4), new ItemStack(Items.SPIDER_EYE), new ItemStack(Items.WHEAT_SEEDS), new ItemStack(Items.WHEAT_SEEDS), new ItemStack(Items.WHEAT_SEEDS));
|
||||
GameRegistry.addShapelessRecipe(BotanyItems.AshPowder.get(4), Mods.Forestry.stack("ash"));
|
||||
GameRegistry.addShapelessRecipe(BotanyItems.MulchPowder.get(4), Mods.Forestry.stack("mulch"));
|
||||
GameRegistry.addShapelessRecipe(BotanyItems.CompostPowder.get(4), Mods.Forestry.stack("fertilizer_bio"));
|
||||
GameRegistry.addShapelessRecipe(BotanyItems.FertiliserPowder.get(4), Mods.Forestry.stack("fertilizer_compound"));
|
||||
GameRegistry.addShapelessRecipe(BotanyItems.PulpPowder.get(4), Mods.Forestry.stack("wood_pulp"));
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(BotanyItems.SulphurPowder.get(4), "dustSulphur"));
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(Botany.pigment, 2, EnumFlowerColor.Black.ordinal()), "pigment", "pigment", "dyeBlack"));
|
||||
gardening.registerAcidFertiliser(BotanyItems.SulphurPowder.get(1), 1);
|
||||
gardening.registerAcidFertiliser(BotanyItems.MulchPowder.get(1), 1);
|
||||
|
||||
recipeUtil.addRecipe("trowel_wood",
|
||||
trowelWood,
|
||||
"d ", " x ", " s",
|
||||
'd', Blocks.DIRT,
|
||||
's', "stickWood",
|
||||
'x', "plankWood"
|
||||
);
|
||||
|
||||
recipeUtil.addRecipe("trowel_stone",
|
||||
trowelStone,
|
||||
"d ", " x ", " s",
|
||||
'd', Blocks.DIRT,
|
||||
's', "stickWood",
|
||||
'x', "cobblestone"
|
||||
);
|
||||
|
||||
recipeUtil.addRecipe("trowel_iron",
|
||||
trowelIron,
|
||||
"d ", " x ", " s",
|
||||
'd', Blocks.DIRT,
|
||||
's', "stickWood",
|
||||
'x', "ingotIron"
|
||||
);
|
||||
|
||||
recipeUtil.addRecipe("trowel_gold",
|
||||
trowelGold,
|
||||
"d ", " x ", " s",
|
||||
'd', Blocks.DIRT,
|
||||
's', "stickWood",
|
||||
'x', "ingotGold"
|
||||
);
|
||||
|
||||
recipeUtil.addRecipe("trowel_diamond",
|
||||
trowelDiamond,
|
||||
"d ", " x ", " s",
|
||||
'd', Blocks.DIRT,
|
||||
's', "stickWood",
|
||||
'x', "gemDiamond"
|
||||
);
|
||||
|
||||
recipeUtil.addRecipe("soil_meter",
|
||||
soilMeter,
|
||||
" gg", " rg", "i ",
|
||||
'g', "ingotGold",
|
||||
'r', "dustRedstone",
|
||||
'i', "ingotIron"
|
||||
);
|
||||
|
||||
recipeUtil.addShapelessRecipe("weed_killer",
|
||||
BotanyItems.WEEDKILLER.get(4),
|
||||
new ItemStack(Items.SPIDER_EYE),
|
||||
new ItemStack(Items.WHEAT_SEEDS),
|
||||
new ItemStack(Items.WHEAT_SEEDS),
|
||||
new ItemStack(Items.WHEAT_SEEDS)
|
||||
);
|
||||
|
||||
recipeUtil.addShapelessRecipe("powder_ash",
|
||||
BotanyItems.POWDER_ASH.get(4),
|
||||
Mods.Forestry.stack("ash")
|
||||
);
|
||||
|
||||
recipeUtil.addShapelessRecipe("powder_mulch",
|
||||
BotanyItems.POWDER_MULCH.get(4),
|
||||
Mods.Forestry.stack("mulch")
|
||||
);
|
||||
|
||||
recipeUtil.addShapelessRecipe("powder_compost",
|
||||
BotanyItems.POWDER_COMPOST.get(4),
|
||||
Mods.Forestry.stack("fertilizer_bio")
|
||||
);
|
||||
|
||||
recipeUtil.addShapelessRecipe("powder_fertilizer",
|
||||
BotanyItems.POWDER_FERTILISER.get(4),
|
||||
Mods.Forestry.stack("fertilizer_compound")
|
||||
);
|
||||
|
||||
recipeUtil.addShapelessRecipe("powder_pulp",
|
||||
BotanyItems.POWDER_PULP.get(4),
|
||||
Mods.Forestry.stack("wood_pulp")
|
||||
);
|
||||
|
||||
recipeUtil.addShapelessRecipe("powder_sulphur",
|
||||
BotanyItems.POWDER_SULPHUR.get(4),
|
||||
"dustSulphur"
|
||||
);
|
||||
|
||||
recipeUtil.addShapelessRecipe("pigment_black",
|
||||
new ItemStack(pigment, 2, EnumFlowerColor.Black.ordinal()),
|
||||
"pigment", "pigment", "dyeBlack"
|
||||
);
|
||||
|
||||
gardening.registerAcidFertiliser(BotanyItems.POWDER_SULPHUR.get(1), 1);
|
||||
gardening.registerAcidFertiliser(BotanyItems.POWDER_MULCH.get(1), 1);
|
||||
gardening.registerAcidFertiliser(Mods.Forestry.stack("mulch"), 2);
|
||||
for (final ItemStack stack : OreDictionary.getOres("dustSulfur")) {
|
||||
for (ItemStack stack : OreDictionary.getOres("dustSulfur")) {
|
||||
gardening.registerAcidFertiliser(stack, 2);
|
||||
}
|
||||
gardening.registerAlkalineFertiliser(BotanyItems.AshPowder.get(1), 1);
|
||||
gardening.registerAlkalineFertiliser(BotanyItems.PulpPowder.get(1), 1);
|
||||
|
||||
gardening.registerAlkalineFertiliser(BotanyItems.POWDER_ASH.get(1), 1);
|
||||
gardening.registerAlkalineFertiliser(BotanyItems.POWDER_PULP.get(1), 1);
|
||||
gardening.registerAlkalineFertiliser(Mods.Forestry.stack("ash"), 2);
|
||||
gardening.registerAlkalineFertiliser(Mods.Forestry.stack("wood_pulp"), 2);
|
||||
gardening.registerNutrientFertiliser(BotanyItems.CompostPowder.get(1), 1);
|
||||
gardening.registerNutrientFertiliser(BotanyItems.FertiliserPowder.get(1), 1);
|
||||
gardening.registerNutrientFertiliser(BotanyItems.POWDER_COMPOST.get(1), 1);
|
||||
gardening.registerNutrientFertiliser(BotanyItems.POWDER_FERTILISER.get(1), 1);
|
||||
gardening.registerNutrientFertiliser(Mods.Forestry.stack("fertilizer_bio"), 2);
|
||||
gardening.registerNutrientFertiliser(Mods.Forestry.stack("fertilizer_compound"), 2);
|
||||
for (final Map.Entry<ItemStack, Integer> entry : ModuleGardening.queuedAcidFertilisers.entrySet()) {
|
||||
this.addAcidFertiliserRecipe(entry.getKey(), entry.getValue());
|
||||
|
||||
for (Map.Entry<ItemStack, Integer> entry : ModuleGardening.queuedAcidFertilisers.entrySet()) {
|
||||
addAcidFertiliserRecipe(recipeUtil, entry.getKey(), entry.getValue());
|
||||
}
|
||||
for (final Map.Entry<ItemStack, Integer> entry : ModuleGardening.queuedAlkalineFertilisers.entrySet()) {
|
||||
this.addAlkalineFertiliserRecipe(entry.getKey(), entry.getValue());
|
||||
for (Map.Entry<ItemStack, Integer> entry : ModuleGardening.queuedAlkalineFertilisers.entrySet()) {
|
||||
addAlkalineFertiliserRecipe(recipeUtil, entry.getKey(), entry.getValue());
|
||||
}
|
||||
for (final Map.Entry<ItemStack, Integer> entry : ModuleGardening.queuedNutrientFertilisers.entrySet()) {
|
||||
this.addNutrientFertiliserRecipe(entry.getKey(), entry.getValue());
|
||||
for (Map.Entry<ItemStack, Integer> entry : ModuleGardening.queuedNutrientFertilisers.entrySet()) {
|
||||
addNutrientFertiliserRecipe(recipeUtil, entry.getKey(), entry.getValue());
|
||||
}
|
||||
GameRegistry.addRecipe(BotanyItems.Mortar.get(6), " c ", "cgc", " c ", 'c', Items.CLAY_BALL, 'g', Blocks.GRAVEL);
|
||||
for (final EnumFlowerColor c : EnumFlowerColor.values()) {
|
||||
final ItemStack clay = new ItemStack(Botany.clay, 1, c.ordinal());
|
||||
final ItemStack pigment = new ItemStack(Botany.pigment, 1, c.ordinal());
|
||||
GameRegistry.addShapelessRecipe(clay, Items.CLAY_BALL, Items.CLAY_BALL, Items.CLAY_BALL, pigment);
|
||||
GameRegistry.addSmelting(clay, TileEntityMetadata.getItemStack(Botany.ceramic, c.ordinal()), 0.0f);
|
||||
final ItemStack glass = TileEntityMetadata.getItemStack(Botany.stained, c.ordinal());
|
||||
|
||||
recipeUtil.addRecipe("mortar", BotanyItems.MORTAR.get(6), " c ", "cgc", " c ", 'c', Items.CLAY_BALL, 'g', Blocks.GRAVEL);
|
||||
for (EnumFlowerColor c : EnumFlowerColor.values()) {
|
||||
ItemStack clay = new ItemStack(this.clay, 1, c.ordinal());
|
||||
ItemStack pigment = new ItemStack(this.pigment, 1, c.ordinal());
|
||||
recipeUtil.addShapelessRecipe("clay_" + c.getIdent(), clay, Items.CLAY_BALL, Items.CLAY_BALL, Items.CLAY_BALL, pigment);
|
||||
GameRegistry.addSmelting(clay, TileEntityMetadata.getItemStack(ceramic, c.ordinal()), 0.0f);
|
||||
ItemStack glass = TileEntityMetadata.getItemStack(stained, c.ordinal());
|
||||
glass.setCount(4);
|
||||
GameRegistry.addShapedRecipe(glass, " g ", "gpg", " g ", 'g', Blocks.GLASS, 'p', pigment);
|
||||
|
||||
recipeUtil.addRecipe("mortar_" + c.getIdent(),
|
||||
glass,
|
||||
" g ", "gpg", " g ",
|
||||
'g', Blocks.GLASS,
|
||||
'p', pigment
|
||||
);
|
||||
}
|
||||
GameRegistry.addRecipe(new PigmentRecipe());
|
||||
ForgeRegistries.RECIPES.register(new PigmentRecipe());
|
||||
}
|
||||
|
||||
private ItemStack getStack(final int type, final int pH, final int moisture) {
|
||||
private ItemStack getStack(int type, int pH, int moisture) {
|
||||
if (type >= 0 && type <= 2 && pH >= 0 && pH <= 2 && moisture >= 0 && moisture <= 2) {
|
||||
return new ItemStack(BotanyCore.getGardening().getSoilBlock(EnumSoilType.values()[type]), 1, BlockSoil.getMeta(EnumAcidity.values()[pH], EnumMoisture.values()[moisture]));
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
private void addAcidFertiliserRecipe(final ItemStack stack, final int strengthMax) {
|
||||
private void addAcidFertiliserRecipe(RecipeUtil recipeUtil, ItemStack stack, int strengthMax) {
|
||||
for (int moisture = 0; moisture < 3; ++moisture) {
|
||||
for (int pH = 0; pH < 3; ++pH) {
|
||||
for (int type = 0; type < 3; ++type) {
|
||||
int numOfBlocks = strengthMax * strengthMax;
|
||||
for (int strength = 1; strength < strengthMax; ++strength) {
|
||||
final ItemStack start = this.getStack(type, pH, moisture);
|
||||
final ItemStack end = this.getStack(type, pH - strength, moisture);
|
||||
ItemStack start = getStack(type, pH, moisture);
|
||||
ItemStack end = getStack(type, pH - strength, moisture);
|
||||
if (!start.isEmpty() && !end.isEmpty()) {
|
||||
end.setCount(numOfBlocks);
|
||||
final Object[] stacks = new Object[numOfBlocks + 1];
|
||||
Object[] stacks = new Object[numOfBlocks + 1];
|
||||
for (int i = 0; i < numOfBlocks; ++i) {
|
||||
stacks[i] = start;
|
||||
}
|
||||
stacks[numOfBlocks] = stack.copy();
|
||||
GameRegistry.addShapelessRecipe(end, stacks);
|
||||
String recipeName = "acid_fertiliser_moisture" + moisture + "_ph" + pH + "_type" + type + "_strength" + strength;
|
||||
recipeUtil.addShapelessRecipe(recipeName, end, stacks);
|
||||
}
|
||||
numOfBlocks /= 2;
|
||||
}
|
||||
@@ -233,22 +353,23 @@ public class ModuleGardening implements IInitializable {
|
||||
}
|
||||
}
|
||||
|
||||
private void addAlkalineFertiliserRecipe(final ItemStack stack, final int strengthMax) {
|
||||
private void addAlkalineFertiliserRecipe(RecipeUtil recipeUtil, ItemStack stack, int strengthMax) {
|
||||
for (int moisture = 0; moisture < 3; ++moisture) {
|
||||
for (int pH = 0; pH < 3; ++pH) {
|
||||
for (int type = 0; type < 3; ++type) {
|
||||
int numOfBlocks = strengthMax * strengthMax;
|
||||
for (int strength = 1; strength < strengthMax; ++strength) {
|
||||
final ItemStack start = this.getStack(type, pH, moisture);
|
||||
final ItemStack end = this.getStack(type, pH + strength, moisture);
|
||||
ItemStack start = getStack(type, pH, moisture);
|
||||
ItemStack end = getStack(type, pH + strength, moisture);
|
||||
if (!end.isEmpty()) {
|
||||
end.setCount(numOfBlocks);
|
||||
final Object[] stacks = new Object[numOfBlocks + 1];
|
||||
Object[] stacks = new Object[numOfBlocks + 1];
|
||||
for (int i = 0; i < numOfBlocks; ++i) {
|
||||
stacks[i] = start;
|
||||
}
|
||||
stacks[numOfBlocks] = stack.copy();
|
||||
GameRegistry.addShapelessRecipe(end, stacks);
|
||||
String recipeName = "alkaline_fertiliser_moisture" + moisture + "_ph" + pH + "_type" + type + "_strength" + strength;
|
||||
recipeUtil.addShapelessRecipe(recipeName, end, stacks);
|
||||
}
|
||||
numOfBlocks /= 2;
|
||||
}
|
||||
@@ -257,22 +378,23 @@ public class ModuleGardening implements IInitializable {
|
||||
}
|
||||
}
|
||||
|
||||
private void addNutrientFertiliserRecipe(final ItemStack stack, final int strengthMax) {
|
||||
private void addNutrientFertiliserRecipe(RecipeUtil recipeUtil, ItemStack stack, int strengthMax) {
|
||||
for (int moisture = 0; moisture < 3; ++moisture) {
|
||||
for (int pH = 0; pH < 3; ++pH) {
|
||||
for (int type = 0; type < 3; ++type) {
|
||||
int numOfBlocks = strengthMax * strengthMax;
|
||||
for (int strength = 1; strength < strengthMax; ++strength) {
|
||||
final ItemStack start = this.getStack(type, pH, moisture);
|
||||
final ItemStack end = this.getStack(type + strength, pH, moisture);
|
||||
ItemStack start = getStack(type, pH, moisture);
|
||||
ItemStack end = getStack(type + strength, pH, moisture);
|
||||
if (!end.isEmpty()) {
|
||||
end.setCount(numOfBlocks);
|
||||
final Object[] stacks = new Object[numOfBlocks + 1];
|
||||
Object[] stacks = new Object[numOfBlocks + 1];
|
||||
for (int i = 0; i < numOfBlocks; ++i) {
|
||||
stacks[i] = start;
|
||||
}
|
||||
stacks[numOfBlocks] = stack.copy();
|
||||
GameRegistry.addShapelessRecipe(end, stacks);
|
||||
String recipeName = "nutrient_fertiliser_moisture" + moisture + "_ph" + pH + "_type" + type + "_strength" + strength;
|
||||
recipeUtil.addShapelessRecipe(recipeName, end, stacks);
|
||||
}
|
||||
numOfBlocks /= 2;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package binnie.botany.gardening;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
|
||||
public enum PlantType implements IStringSerializable {
|
||||
WEEDS("weeds", true),
|
||||
WEEDS_LONG("weeds_long", true),
|
||||
WEEDS_VERY_LONG("weeds_very_long", true),
|
||||
DEAD_FLOWER("dead_flower"),
|
||||
DECAYING_FLOWER("decaying_flower");
|
||||
|
||||
String name;
|
||||
boolean isWeed;
|
||||
|
||||
PlantType(String name) {
|
||||
this(name, false);
|
||||
}
|
||||
|
||||
PlantType(String name, boolean isWeed) {
|
||||
this.name = name;
|
||||
this.isWeed = isWeed;
|
||||
}
|
||||
|
||||
public static PlantType get(int id) {
|
||||
return values()[id % values().length];
|
||||
}
|
||||
|
||||
public ItemStack get() {
|
||||
return new ItemStack(Botany.gardening().plant, 1, ordinal());
|
||||
}
|
||||
|
||||
public boolean isWeed() {
|
||||
return isWeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ public class AlleleEffectNone implements IAlleleFlowerEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEffectData validateStorage(final IEffectData storedData) {
|
||||
public IEffectData validateStorage(IEffectData storedData) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
@@ -34,12 +34,12 @@ public class AlleleEffectNone implements IAlleleFlowerEffect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEffectData doEffect(final IFlowerGenome genome, final IEffectData storedData, final World world, final int x, final int y, final int z) {
|
||||
return storedData;
|
||||
public IEffectData doEffect(IFlowerGenome genome, IEffectData effect, World world, int x, int y, int z) {
|
||||
return effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName() {
|
||||
return this.getUID();
|
||||
return getUID();
|
||||
}
|
||||
}
|
||||
@@ -27,14 +27,14 @@ public class AlleleFlowerSpecies extends AlleleSpecies implements IAlleleFlowerS
|
||||
private EnumMoisture moisture = EnumMoisture.NORMAL;
|
||||
|
||||
public AlleleFlowerSpecies(
|
||||
String uid,
|
||||
String unlocalizedName,
|
||||
String authority,
|
||||
String unlocalizedDescription,
|
||||
boolean isDominant,
|
||||
IClassification branch,
|
||||
String binomial,
|
||||
IFlowerType flowerType) {
|
||||
String uid,
|
||||
String unlocalizedName,
|
||||
String authority,
|
||||
String unlocalizedDescription,
|
||||
boolean isDominant,
|
||||
IClassification branch,
|
||||
String binomial,
|
||||
IFlowerType flowerType) {
|
||||
super(uid, unlocalizedName, authority, unlocalizedDescription, isDominant, branch, binomial);
|
||||
this.flowerType = flowerType;
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class AlleleFlowerSpecies extends AlleleSpecies implements IAlleleFlowerS
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlowerColour(EnumFlowerStage type, int renderPass) {
|
||||
public int getFlowerColor(EnumFlowerStage type, int renderPass) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,16 +10,16 @@ import binnie.Binnie;
|
||||
import binnie.botany.api.IBotanistTracker;
|
||||
|
||||
public class BotanistTracker extends BreedingTracker implements IBotanistTracker {
|
||||
public BotanistTracker(final String s) {
|
||||
public BotanistTracker(String s) {
|
||||
super(s, "NORMAL");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPickup(final IIndividual individual) {
|
||||
public void registerPickup(IIndividual individual) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IBreedingTracker getBreedingTracker(final EntityPlayer player) {
|
||||
protected IBreedingTracker getBreedingTracker(EntityPlayer player) {
|
||||
return Binnie.GENETICS.getFlowerRoot().getBreedingTracker(player.world, player.getGameProfile());
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package binnie.botany.genetics;
|
||||
|
||||
import binnie.botany.api.IColorMix;
|
||||
import binnie.botany.api.IFlowerColor;
|
||||
|
||||
public class ColorMix implements IColorMix {
|
||||
IFlowerColor color1;
|
||||
IFlowerColor color2;
|
||||
IFlowerColor result;
|
||||
int chance;
|
||||
|
||||
public ColorMix(IFlowerColor color1, IFlowerColor color2, IFlowerColor result, int chance) {
|
||||
this.color1 = color1;
|
||||
this.color2 = color2;
|
||||
this.result = result;
|
||||
this.chance = chance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlowerColor getColorFirst() {
|
||||
return color1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlowerColor getColorSecond() {
|
||||
return color2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMutation(IFlowerColor colorFirst, IFlowerColor colorSecond) {
|
||||
return (colorFirst == color1 && colorSecond == color2)
|
||||
|| (colorFirst == color2 && colorSecond == color1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChance() {
|
||||
return chance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlowerColor getResult() {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package binnie.botany.genetics;
|
||||
|
||||
import binnie.botany.api.IColourMix;
|
||||
import binnie.botany.api.IFlowerColour;
|
||||
|
||||
public class ColourMix implements IColourMix {
|
||||
IFlowerColour colour1;
|
||||
IFlowerColour colour2;
|
||||
IFlowerColour result;
|
||||
int chance;
|
||||
|
||||
public ColourMix(final IFlowerColour colour1, final IFlowerColour colour2, final IFlowerColour result, final int chance) {
|
||||
this.colour1 = colour1;
|
||||
this.colour2 = colour2;
|
||||
this.result = result;
|
||||
this.chance = chance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlowerColour getColourFirst() {
|
||||
return this.colour1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlowerColour getColourSecond() {
|
||||
return this.colour2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMutation(final IFlowerColour a, final IFlowerColour b) {
|
||||
return (a == this.colour1 && b == this.colour2) || (a == this.colour2 && b == this.colour1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChance() {
|
||||
return this.chance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlowerColour getResult() {
|
||||
return this.result;
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,9 @@ import net.minecraft.util.IStringSerializable;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
//TODO: Clean Up
|
||||
public enum EnumFlowerColor implements IStringSerializable {
|
||||
Aquamarine("aquamarine", 8388564),
|
||||
Black("black", 2631720),
|
||||
@@ -90,13 +92,11 @@ public enum EnumFlowerColor implements IStringSerializable {
|
||||
|
||||
public static final EnumFlowerColor[] VALUES = values();
|
||||
|
||||
private final String ident;
|
||||
private FlowerColorAllele allele;
|
||||
|
||||
EnumFlowerColor(final String ident, final int c) {
|
||||
this(c);
|
||||
}
|
||||
|
||||
EnumFlowerColor(final int color) {
|
||||
EnumFlowerColor(String ident, int color) {
|
||||
this.ident = ident;
|
||||
int r = color >> 16 & 0xFF;
|
||||
int g = color >> 8 & 0xFF;
|
||||
int b = color & 0xFF;
|
||||
@@ -104,12 +104,16 @@ public enum EnumFlowerColor implements IStringSerializable {
|
||||
g = (int) (0.45 * (g + 174));
|
||||
b = (int) (0.45 * (b + 131));
|
||||
int colorDis = (r << 16) + (g << 8) + b;
|
||||
String uid = "botany.color" + this.name();
|
||||
String uid = "botany.color" + name();
|
||||
allele = new FlowerColorAllele(uid, ordinal(), color, colorDis, name().toLowerCase(), uid, true);
|
||||
}
|
||||
|
||||
public static void addMix(final EnumFlowerColor start1, final EnumFlowerColor start2, final EnumFlowerColor result, final int chance) {
|
||||
BotanyCore.getFlowerRoot().registerColourMix(new ColourMix(start1.allele, start2.allele, result.allele, chance));
|
||||
public String getIdent() {
|
||||
return ident;
|
||||
}
|
||||
|
||||
public static void addMix(EnumFlowerColor start1, EnumFlowerColor start2, EnumFlowerColor result, int chance) {
|
||||
BotanyCore.getFlowerRoot().registerColourMix(new ColorMix(start1.allele, start2.allele, result.allele, chance));
|
||||
}
|
||||
|
||||
public static void setupMutations() {
|
||||
@@ -2936,20 +2940,24 @@ public enum EnumFlowerColor implements IStringSerializable {
|
||||
}
|
||||
}
|
||||
|
||||
public static EnumFlowerColor get(final int i) {
|
||||
public static EnumFlowerColor get(int i) {
|
||||
return values()[Math.max(0, i) % values().length];
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return I18N.localise("botany.color." + getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase();
|
||||
}
|
||||
|
||||
public String getHTMLName() {
|
||||
return this.name();
|
||||
return name();
|
||||
}
|
||||
|
||||
public FlowerColorAllele getFlowerColorAllele(){
|
||||
public FlowerColorAllele getFlowerColorAllele() {
|
||||
return allele;
|
||||
}
|
||||
}
|
||||
@@ -76,14 +76,14 @@ public enum EnumFlowerType implements IFlowerType<EnumFlowerType> {
|
||||
this(1);
|
||||
}
|
||||
|
||||
EnumFlowerType(final int sections) {
|
||||
EnumFlowerType(int sections) {
|
||||
this.sections = sections;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerModels(Item item, IModelManager manager, EnumFlowerStage type) {
|
||||
String pre = (this.sections == 1) ? "" : "double/";
|
||||
String pre = (sections == 1) ? "" : "double/";
|
||||
flower = new ModelResourceLocation(Constants.BOTANY_MOD_ID + ":flowers/" + pre + getName(), "inventory");
|
||||
seed = new ModelResourceLocation(Constants.BOTANY_MOD_ID + ":flowers/seed", "inventory");
|
||||
pollen = new ModelResourceLocation(Constants.BOTANY_MOD_ID + ":flowers/pollen", "inventory");
|
||||
@@ -97,19 +97,18 @@ public enum EnumFlowerType implements IFlowerType<EnumFlowerType> {
|
||||
return seed;
|
||||
} else if (type == EnumFlowerStage.POLLEN) {
|
||||
return pollen;
|
||||
} else {
|
||||
return flower;
|
||||
}
|
||||
return flower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getID() {
|
||||
return this.ordinal();
|
||||
return ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSections() {
|
||||
return this.sections;
|
||||
return sections;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,101 +14,105 @@ import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IChromosome;
|
||||
import forestry.core.genetics.Chromosome;
|
||||
import forestry.core.genetics.Individual;
|
||||
import forestry.core.utils.Translator;
|
||||
|
||||
import binnie.botany.api.EnumFlowerChromosome;
|
||||
import binnie.botany.api.IAlleleFlowerSpecies;
|
||||
import binnie.botany.api.IColourMix;
|
||||
import binnie.botany.api.IColorMix;
|
||||
import binnie.botany.api.IFlower;
|
||||
import binnie.botany.api.IFlowerColour;
|
||||
import binnie.botany.api.IFlowerColor;
|
||||
import binnie.botany.api.IFlowerGenome;
|
||||
import binnie.botany.api.IFlowerMutation;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public class Flower extends Individual implements IFlower {
|
||||
public IFlowerGenome genome;
|
||||
|
||||
@Nullable
|
||||
public IFlowerGenome mate;
|
||||
|
||||
private int age;
|
||||
private boolean wilting;
|
||||
private boolean flowered;
|
||||
|
||||
public Flower(final NBTTagCompound nbt) {
|
||||
public Flower(NBTTagCompound nbt) {
|
||||
super(nbt);
|
||||
|
||||
if (nbt.hasKey("Age")) {
|
||||
this.age = nbt.getInteger("Age");
|
||||
age = nbt.getInteger("Age");
|
||||
} else {
|
||||
this.age = 0;
|
||||
age = 0;
|
||||
}
|
||||
|
||||
this.wilting = nbt.hasKey("Wilt") && nbt.getBoolean("Wilt");
|
||||
wilting = nbt.hasKey("Wilt") && nbt.getBoolean("Wilt");
|
||||
|
||||
if (nbt.hasKey("Flowered")) {
|
||||
this.flowered = nbt.getBoolean("Flowered");
|
||||
flowered = nbt.getBoolean("Flowered");
|
||||
} else {
|
||||
this.flowered = age > 0;
|
||||
flowered = age > 0;
|
||||
}
|
||||
|
||||
if (nbt.hasKey("Genome")) {
|
||||
this.genome = new FlowerGenome(nbt.getCompoundTag("Genome"));
|
||||
genome = new FlowerGenome(nbt.getCompoundTag("Genome"));
|
||||
} else {
|
||||
this.genome = BotanyCore.getFlowerRoot().templateAsGenome(BotanyCore.getFlowerRoot().getDefaultTemplate());
|
||||
genome = BotanyCore.getFlowerRoot().templateAsGenome(BotanyCore.getFlowerRoot().getDefaultTemplate());
|
||||
}
|
||||
|
||||
if (nbt.hasKey("Mate")) {
|
||||
this.mate = new FlowerGenome(nbt.getCompoundTag("Mate"));
|
||||
mate = new FlowerGenome(nbt.getCompoundTag("Mate"));
|
||||
}
|
||||
}
|
||||
|
||||
public Flower(final IFlowerGenome genome, final int age) {
|
||||
this.age = 0;
|
||||
this.wilting = false;
|
||||
public Flower(IFlowerGenome genome, int age) {
|
||||
this.genome = genome;
|
||||
this.age = age;
|
||||
this.flowered = age > 0;
|
||||
wilting = false;
|
||||
flowered = age > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
final IAlleleFlowerSpecies species = this.getGenome().getPrimary();
|
||||
String name = species.getName();
|
||||
if (this.age == 0) {
|
||||
IAlleleFlowerSpecies species = getGenome().getPrimary();
|
||||
String name = species.getAlleleName();
|
||||
if (age == 0) {
|
||||
name += "";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTooltip(final List<String> list) {
|
||||
final IAlleleFlowerSpecies primary = this.genome.getPrimary();
|
||||
final IAlleleFlowerSpecies secondary = this.genome.getSecondary();
|
||||
if (!this.isPureBred(EnumFlowerChromosome.SPECIES)) {
|
||||
list.add(TextFormatting.BLUE + primary.getAlleleName() + "-" + secondary.getAlleleName() + " Hybrid");
|
||||
public void addTooltip(List<String> list) {
|
||||
IAlleleFlowerSpecies primary = genome.getPrimary();
|
||||
IAlleleFlowerSpecies secondary = genome.getSecondary();
|
||||
if (!isPureBred(EnumFlowerChromosome.SPECIES)) {
|
||||
list.add(TextFormatting.BLUE + Translator.translateToLocal("for.bees.hybrid").replaceAll("%PRIMARY", primary.getAlleleName()).replaceAll("%SECONDARY", secondary.getAlleleName()));
|
||||
}
|
||||
list.add(TextFormatting.GOLD + "Age: " + this.getAge());
|
||||
list.add(TextFormatting.GOLD + "T: " + this.getGenome().getPrimary().getTemperature() + " / " + this.getGenome().getToleranceTemperature());
|
||||
list.add(TextFormatting.GOLD + "M: " + this.getGenome().getPrimary().getMoisture() + " / " + this.getGenome().getToleranceMoisture());
|
||||
list.add(TextFormatting.GOLD + "pH: " + this.getGenome().getPrimary().getHumidity() + " / " + this.getGenome().getTolerancePH());
|
||||
list.add(TextFormatting.GOLD + "Fert: " + this.getGenome().getFertility() + "x");
|
||||
|
||||
list.add(TextFormatting.GOLD + I18N.localise("item.botany.flower.age", getAge()));
|
||||
list.add(TextFormatting.GREEN + "T: " + getGenome().getPrimary().getTemperature() + " / " + getGenome().getToleranceTemperature());
|
||||
list.add(TextFormatting.AQUA + "M: " + getGenome().getPrimary().getMoisture() + " / " + getGenome().getToleranceMoisture());
|
||||
list.add(TextFormatting.AQUA + "pH: " + getGenome().getPrimary().getHumidity() + " / " + getGenome().getTolerancePH());
|
||||
list.add(TextFormatting.GOLD + "Fert: " + getGenome().getFertility() + "x");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdent() {
|
||||
return this.getGenome().getPrimary().getUID();
|
||||
return getGenome().getPrimary().getUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(final NBTTagCompound nbttagcompound2) {
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound2) {
|
||||
NBTTagCompound nbttagcompound = super.writeToNBT(nbttagcompound2);
|
||||
nbttagcompound.setInteger("Age", this.age);
|
||||
nbttagcompound.setBoolean("Wilt", this.wilting);
|
||||
nbttagcompound.setBoolean("Flowered", this.flowered);
|
||||
final NBTTagCompound nbtGenome = new NBTTagCompound();
|
||||
this.genome.writeToNBT(nbtGenome);
|
||||
nbttagcompound.setInteger("Age", age);
|
||||
nbttagcompound.setBoolean("Wilt", wilting);
|
||||
nbttagcompound.setBoolean("Flowered", flowered);
|
||||
NBTTagCompound nbtGenome = new NBTTagCompound();
|
||||
genome.writeToNBT(nbtGenome);
|
||||
nbttagcompound.setTag("Genome", nbtGenome);
|
||||
if (this.mate != null) {
|
||||
final NBTTagCompound nbtMate = new NBTTagCompound();
|
||||
this.mate.writeToNBT(nbtMate);
|
||||
if (mate != null) {
|
||||
NBTTagCompound nbtMate = new NBTTagCompound();
|
||||
mate.writeToNBT(nbtMate);
|
||||
nbttagcompound.setTag("Mate", nbtMate);
|
||||
}
|
||||
return nbttagcompound;
|
||||
@@ -116,7 +120,7 @@ public class Flower extends Individual implements IFlower {
|
||||
|
||||
@Override
|
||||
public IFlowerGenome getGenome() {
|
||||
return this.genome;
|
||||
return genome;
|
||||
}
|
||||
|
||||
private IChromosome inheritChromosome(Random rand, IChromosome parentFirst, IChromosome parentSecond) {
|
||||
@@ -140,91 +144,91 @@ public class Flower extends Individual implements IFlower {
|
||||
|
||||
@Override
|
||||
public void mate(IFlower other) {
|
||||
this.mate = new FlowerGenome(other.getGenome().getChromosomes());
|
||||
mate = new FlowerGenome(other.getGenome().getChromosomes());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IFlowerGenome getMate() {
|
||||
return this.mate;
|
||||
return mate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlower copy() {
|
||||
final NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
this.writeToNBT(nbttagcompound);
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
writeToNBT(nbttagcompound);
|
||||
return new Flower(nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAge() {
|
||||
return this.age;
|
||||
return age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAge(final int i) {
|
||||
this.age = i;
|
||||
public void setAge(int i) {
|
||||
age = i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void age() {
|
||||
if (this.age < 15) {
|
||||
++this.age;
|
||||
if (age < 15) {
|
||||
age++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxAge() {
|
||||
return this.getGenome().getLifespan();
|
||||
return getGenome().getLifespan();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWilted() {
|
||||
return this.wilting;
|
||||
return wilting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWilted(final boolean wilted) {
|
||||
this.wilting = wilted;
|
||||
public void setWilted(boolean wilted) {
|
||||
wilting = wilted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFlowered() {
|
||||
return this.flowered;
|
||||
return flowered;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlowered(final boolean flowered) {
|
||||
public void setFlowered(boolean flowered) {
|
||||
this.flowered = flowered;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMate() {
|
||||
this.mate = null;
|
||||
mate = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlower getOffspring(final World world, final BlockPos pos) {
|
||||
if (this.mate != null) {
|
||||
final IChromosome[] chromosomes = new IChromosome[this.genome.getChromosomes().length];
|
||||
IChromosome[] parentFirst = this.mutateSpecies(world, pos, this.genome, this.mate);
|
||||
IChromosome[] parentSecond = this.mutateSpecies(world, pos, this.mate, this.genome);
|
||||
public IFlower getOffspring(World world, BlockPos pos) {
|
||||
if (mate != null) {
|
||||
IChromosome[] chromosomes = new IChromosome[genome.getChromosomes().length];
|
||||
IChromosome[] parentFirst = mutateSpecies(world, pos, genome, mate);
|
||||
IChromosome[] parentSecond = mutateSpecies(world, pos, mate, genome);
|
||||
for (int i = 0; i < parentFirst.length; ++i) {
|
||||
if (parentFirst[i] != null && parentSecond[i] != null) {
|
||||
chromosomes[i] = Chromosome.inheritChromosome(world.rand, parentFirst[i], parentSecond[i]);
|
||||
}
|
||||
}
|
||||
return new Flower(new FlowerGenome(chromosomes), 0);
|
||||
} else {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
return new Flower(nbt);
|
||||
}
|
||||
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
return new Flower(nbt);
|
||||
}
|
||||
|
||||
private IChromosome[] mutateSpecies(World world, BlockPos pos, IFlowerGenome genomeFirst, IFlowerGenome genomeSecond) {
|
||||
IChromosome[] parentFirst = genomeFirst.getChromosomes();
|
||||
final IChromosome[] parentSecond = genomeSecond.getChromosomes();
|
||||
IChromosome[] parentSecond = genomeSecond.getChromosomes();
|
||||
IAlleleFlowerSpecies alleleFrist;
|
||||
IAlleleFlowerSpecies alleleSecond;
|
||||
IFlowerGenome genome0;
|
||||
@@ -240,40 +244,44 @@ public class Flower extends Individual implements IFlower {
|
||||
genome0 = genomeSecond;
|
||||
genome2 = genomeFirst;
|
||||
}
|
||||
IFlowerColour colourFirst = genome0.getPrimaryColor();
|
||||
IFlowerColour colourSecond = genome2.getPrimaryColor();
|
||||
if (colourFirst != colourSecond) {
|
||||
for (final IColourMix mutation : BotanyCore.getFlowerRoot().getColourMixes(true)) {
|
||||
if (mutation.isMutation(colourFirst, colourSecond) && world.rand.nextFloat() * 100.0f < mutation.getChance()) {
|
||||
|
||||
IFlowerColor colorFirst = genome0.getPrimaryColor();
|
||||
IFlowerColor colorSecond = genome2.getPrimaryColor();
|
||||
if (colorFirst != colorSecond) {
|
||||
for (IColorMix mutation : BotanyCore.getFlowerRoot().getColorMixes(true)) {
|
||||
if (mutation.isMutation(colorFirst, colorSecond) && world.rand.nextFloat() * 100.0f < mutation.getChance()) {
|
||||
parentFirst[EnumFlowerChromosome.PRIMARY.ordinal()] = new Chromosome(mutation.getResult().getAllele());
|
||||
}
|
||||
}
|
||||
}
|
||||
colourFirst = genome0.getSecondaryColor();
|
||||
colourSecond = genome2.getSecondaryColor();
|
||||
if (colourFirst != colourSecond) {
|
||||
for (final IColourMix mutation : BotanyCore.getFlowerRoot().getColourMixes(true)) {
|
||||
if (mutation.isMutation(colourFirst, colourSecond) && world.rand.nextFloat() * 100.0f < mutation.getChance()) {
|
||||
|
||||
colorFirst = genome0.getSecondaryColor();
|
||||
colorSecond = genome2.getSecondaryColor();
|
||||
if (colorFirst != colorSecond) {
|
||||
for (IColorMix mutation : BotanyCore.getFlowerRoot().getColorMixes(true)) {
|
||||
if (mutation.isMutation(colorFirst, colorSecond) && world.rand.nextFloat() * 100.0f < mutation.getChance()) {
|
||||
parentFirst[EnumFlowerChromosome.SECONDARY.ordinal()] = new Chromosome(mutation.getResult().getAllele());
|
||||
}
|
||||
}
|
||||
}
|
||||
colourFirst = genome0.getStemColor();
|
||||
colourSecond = genome2.getStemColor();
|
||||
if (colourFirst != colourSecond) {
|
||||
for (final IColourMix mutation : BotanyCore.getFlowerRoot().getColourMixes(true)) {
|
||||
if (mutation.isMutation(colourFirst, colourSecond) && world.rand.nextFloat() * 100.0f < mutation.getChance()) {
|
||||
colorFirst = genome0.getStemColor();
|
||||
colorSecond = genome2.getStemColor();
|
||||
if (colorFirst != colorSecond) {
|
||||
for (IColorMix mutation : BotanyCore.getFlowerRoot().getColorMixes(true)) {
|
||||
if (mutation.isMutation(colorFirst, colorSecond) && world.rand.nextFloat() * 100.0f < mutation.getChance()) {
|
||||
parentFirst[EnumFlowerChromosome.STEM.ordinal()] = new Chromosome(mutation.getResult().getAllele());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IChromosome[] template = null;
|
||||
for (final IFlowerMutation mutation2 : BotanyCore.getFlowerRoot().getMutations(true)) {
|
||||
final float chance = mutation2.getChance(world, pos, alleleFrist, alleleSecond, genome0, genome2);
|
||||
for (IFlowerMutation mutation2 : BotanyCore.getFlowerRoot().getMutations(true)) {
|
||||
float chance = mutation2.getChance(world, pos, alleleFrist, alleleSecond, genome0, genome2);
|
||||
if (chance > 0.0f && world.rand.nextFloat() * 100.0f < chance && template == null) {
|
||||
template = BotanyCore.getFlowerRoot().templateAsChromosomes(mutation2.getTemplate());
|
||||
}
|
||||
}
|
||||
|
||||
if (template != null) {
|
||||
parentFirst = template;
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ import binnie.botany.api.EnumFlowerChromosome;
|
||||
import binnie.botany.api.EnumFlowerStage;
|
||||
import binnie.botany.api.FlowerManager;
|
||||
import binnie.botany.api.IFlower;
|
||||
import binnie.core.craftgui.geometry.Area;
|
||||
import binnie.core.craftgui.renderer.RenderUtil;
|
||||
import binnie.core.gui.geometry.Area;
|
||||
import binnie.core.gui.renderer.RenderUtil;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
// TODO write flower alyzer plugin
|
||||
@@ -32,12 +32,6 @@ public class FlowerAlyzerPlugin implements IAlyzerPlugin {
|
||||
public static final int COLUMN_0 = 12;
|
||||
public static final int COLUMN_1 = 90;
|
||||
public static final int COLUMN_2 = 155;
|
||||
private int lastTopOffset;
|
||||
private int rowSize = 12;
|
||||
private int margin = 10;
|
||||
private int guiLeft;
|
||||
private int guiTop;
|
||||
private HashMap<String, ItemStack> iconStacks = new HashMap<>();
|
||||
private static final EnumFlowerChromosome[] firstPageChromosome = new EnumFlowerChromosome[]{
|
||||
EnumFlowerChromosome.SPECIES,
|
||||
EnumFlowerChromosome.SAPPINESS,
|
||||
@@ -46,39 +40,43 @@ public class FlowerAlyzerPlugin implements IAlyzerPlugin {
|
||||
EnumFlowerChromosome.EFFECT,
|
||||
EnumFlowerChromosome.LIFESPAN
|
||||
};
|
||||
|
||||
private static final EnumFlowerChromosome[] secondPageColorChromosome = new EnumFlowerChromosome[]{
|
||||
EnumFlowerChromosome.PRIMARY,
|
||||
EnumFlowerChromosome.SECONDARY,
|
||||
EnumFlowerChromosome.STEM,
|
||||
};
|
||||
|
||||
private static final EnumFlowerChromosome[] secondPageToleranceChromosome = new EnumFlowerChromosome[]{
|
||||
EnumFlowerChromosome.TEMPERATURE_TOLERANCE,
|
||||
EnumFlowerChromosome.HUMIDITY_TOLERANCE,
|
||||
EnumFlowerChromosome.PH_TOLERANCE
|
||||
};
|
||||
private int lastTopOffset;
|
||||
private int rowSize = 12;
|
||||
private int margin = 10;
|
||||
private int guiLeft;
|
||||
private int guiTop;
|
||||
private HashMap<String, ItemStack> iconStacks = new HashMap<>();
|
||||
|
||||
|
||||
public FlowerAlyzerPlugin() {
|
||||
for(FlowerDefinition def : FlowerDefinition.values()){
|
||||
for (FlowerDefinition def : FlowerDefinition.values()) {
|
||||
iconStacks.put(def.getSpecies().getUID(), def.getMemberStack(EnumFlowerStage.FLOWER));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void drawLine(GuiScreen gui, int xOffset, String msg, int color){
|
||||
gui.mc.fontRendererObj.drawString(msg, guiLeft + xOffset, guiTop + lastTopOffset + margin, color);
|
||||
public void drawLine(GuiScreen gui, int xOffset, String msg, int color) {
|
||||
gui.mc.fontRenderer.drawString(msg, guiLeft + xOffset, guiTop + lastTopOffset + margin, color);
|
||||
}
|
||||
|
||||
public void drawChromosom(GuiScreen gui, EnumFlowerChromosome chromosome, IFlower flower){
|
||||
public void drawChromosom(GuiScreen gui, EnumFlowerChromosome chromosome, IFlower flower) {
|
||||
drawLine(gui, COLUMN_0, StringUtils.capitalize(chromosome.getName()), 0xEEEEEE);
|
||||
drawLine(gui, COLUMN_1, I18N.localise(flower.getGenome().getActiveAllele(chromosome).getUnlocalizedName()), 0xEEEEEE);
|
||||
drawLine(gui, COLUMN_2, I18N.localise(flower.getGenome().getInactiveAllele(chromosome).getUnlocalizedName()), 0xEEEEEE);
|
||||
lastTopOffset += rowSize;
|
||||
}
|
||||
|
||||
public void newLine(){
|
||||
public void newLine() {
|
||||
lastTopOffset += rowSize;
|
||||
}
|
||||
|
||||
@@ -97,16 +95,16 @@ public class FlowerAlyzerPlugin implements IAlyzerPlugin {
|
||||
ItemStack renderS = getIconStacks().get(flower.getGenome().getSecondary().getUID());
|
||||
|
||||
|
||||
gui.mc.fontRendererObj.drawString("Active", guiLeft + 10 + COLUMN_1, guiTop + 10, 0xffffff);
|
||||
gui.mc.fontRendererObj.drawString("Inactive", guiLeft + 10 + COLUMN_2, guiTop + 10, 0xffffff);
|
||||
gui.mc.fontRenderer.drawString("Active", guiLeft + 10 + COLUMN_1, guiTop + 10, 0xffffff);
|
||||
gui.mc.fontRenderer.drawString("Inactive", guiLeft + 10 + COLUMN_2, guiTop + 10, 0xffffff);
|
||||
|
||||
if (renderP != null && renderS!=null){
|
||||
if (renderP != null && renderS != null) {
|
||||
RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
|
||||
itemRender.renderItemAndEffectIntoGUI(renderP, guiLeft + 10 + COLUMN_1, guiTop + 10 +12);
|
||||
itemRender.renderItemOverlayIntoGUI(gui.mc.fontRendererObj, renderP, guiLeft + 10 + COLUMN_1, guiTop + 10 + 12, null);
|
||||
itemRender.renderItemAndEffectIntoGUI(renderP, guiLeft + 10 + COLUMN_1, guiTop + 10 + 12);
|
||||
itemRender.renderItemOverlayIntoGUI(gui.mc.fontRenderer, renderP, guiLeft + 10 + COLUMN_1, guiTop + 10 + 12, null);
|
||||
|
||||
itemRender.renderItemAndEffectIntoGUI(renderS, guiLeft + 10 + COLUMN_2, guiTop +10 +12);
|
||||
itemRender.renderItemOverlayIntoGUI(gui.mc.fontRendererObj, renderS, guiLeft + 10 + COLUMN_1, guiTop +10 + 12, null);
|
||||
itemRender.renderItemAndEffectIntoGUI(renderS, guiLeft + 10 + COLUMN_2, guiTop + 10 + 12);
|
||||
itemRender.renderItemOverlayIntoGUI(gui.mc.fontRenderer, renderS, guiLeft + 10 + COLUMN_1, guiTop + 10 + 12, null);
|
||||
}
|
||||
|
||||
guiTop += rowSize * 3;
|
||||
@@ -128,8 +126,8 @@ public class FlowerAlyzerPlugin implements IAlyzerPlugin {
|
||||
|
||||
for (EnumFlowerChromosome chromosome : secondPageColorChromosome) {
|
||||
drawChromosom(gui, chromosome, f);
|
||||
RenderUtil.drawSolidRect(new Area(guiLeft + COLUMN_1, guiTop + lastTopOffset + margin, 50, 10), ((IAlleleInteger)f.getGenome().getActiveAllele(chromosome)).getValue());
|
||||
RenderUtil.drawSolidRect(new Area(guiLeft + COLUMN_2, guiTop + lastTopOffset + margin, 50, 10), ((IAlleleInteger)f.getGenome().getInactiveAllele(chromosome)).getValue());
|
||||
RenderUtil.drawSolidRect(new Area(guiLeft + COLUMN_1, guiTop + lastTopOffset + margin, 50, 10), ((IAlleleInteger) f.getGenome().getActiveAllele(chromosome)).getValue());
|
||||
RenderUtil.drawSolidRect(new Area(guiLeft + COLUMN_2, guiTop + lastTopOffset + margin, 50, 10), ((IAlleleInteger) f.getGenome().getInactiveAllele(chromosome)).getValue());
|
||||
newLine();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,12 +26,12 @@ import binnie.core.util.I18N;
|
||||
|
||||
public class FlowerBreedingSystem extends BreedingSystem {
|
||||
public FlowerBreedingSystem() {
|
||||
this.iconUndiscovered = Binnie.RESOURCE.getUndiscoveredBeeSprite();
|
||||
this.iconDiscovered = Binnie.RESOURCE.getDiscoveredBeeSprite();
|
||||
iconUndiscovered = Binnie.RESOURCE.getUndiscoveredBeeSprite();
|
||||
iconDiscovered = Binnie.RESOURCE.getDiscoveredBeeSprite();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getChance(final IMutation mutation, final EntityPlayer player, final IAlleleSpecies species1, final IAlleleSpecies species2) {
|
||||
public float getChance(IMutation mutation, EntityPlayer player, IAlleleSpecies firstSpecies, IAlleleSpecies secondSpecies) {
|
||||
return mutation.getBaseChance();
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class FlowerBreedingSystem extends BreedingSystem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAlleleName(final IChromosomeType chromosome, final IAllele allele) {
|
||||
public String getAlleleName(IChromosomeType chromosome, IAllele allele) {
|
||||
if (chromosome == EnumFlowerChromosome.FERTILITY) {
|
||||
if (allele.getUID().contains("Low")) {
|
||||
return I18N.localise("binniecore.allele.fertility.low");
|
||||
@@ -70,8 +70,8 @@ public class FlowerBreedingSystem extends BreedingSystem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDNAManipulable(final ItemStack member) {
|
||||
ISpeciesType type = this.getSpeciesRoot().getType(member);
|
||||
public boolean isDNAManipulable(ItemStack member) {
|
||||
ISpeciesType type = getSpeciesRoot().getType(member);
|
||||
return type != null && isDNAManipulable(type);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class FlowerBreedingSystem extends BreedingSystem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndividual getConversion(final ItemStack stack) {
|
||||
public IIndividual getConversion(ItemStack stack) {
|
||||
return BotanyCore.getFlowerRoot().getConversion(stack);
|
||||
}
|
||||
|
||||
@@ -91,51 +91,47 @@ public class FlowerBreedingSystem extends BreedingSystem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addExtraAlleles(final IChromosomeType chromosome, final TreeSet<IAllele> alleles) {
|
||||
public void addExtraAlleles(IChromosomeType chromosome, TreeSet<IAllele> alleles) {
|
||||
switch ((EnumFlowerChromosome) chromosome) {
|
||||
case FERTILITY: {
|
||||
for (final ForestryAllele.Fertility a : ForestryAllele.Fertility.values()) {
|
||||
case FERTILITY:
|
||||
for (ForestryAllele.Fertility a : ForestryAllele.Fertility.values()) {
|
||||
alleles.add(a.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LIFESPAN: {
|
||||
for (final ForestryAllele.Lifespan a2 : ForestryAllele.Lifespan.values()) {
|
||||
|
||||
case LIFESPAN:
|
||||
for (ForestryAllele.Lifespan a2 : ForestryAllele.Lifespan.values()) {
|
||||
alleles.add(a2.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case HUMIDITY_TOLERANCE:
|
||||
case PH_TOLERANCE:
|
||||
case TEMPERATURE_TOLERANCE: {
|
||||
for (final Tolerance a3 : Tolerance.values()) {
|
||||
case TEMPERATURE_TOLERANCE:
|
||||
for (Tolerance a3 : Tolerance.values()) {
|
||||
alleles.add(a3.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case PRIMARY:
|
||||
case SECONDARY:
|
||||
case STEM: {
|
||||
for (final EnumFlowerColor a4 : EnumFlowerColor.values()) {
|
||||
case STEM:
|
||||
for (EnumFlowerColor a4 : EnumFlowerColor.values()) {
|
||||
alleles.add(a4.getFlowerColorAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SAPPINESS: {
|
||||
for (final ForestryAllele.Sappiness a5 : ForestryAllele.Sappiness.values()) {
|
||||
|
||||
case SAPPINESS:
|
||||
for (ForestryAllele.Sappiness a5 : ForestryAllele.Sappiness.values()) {
|
||||
alleles.add(a5.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TERRITORY: {
|
||||
for (final ForestryAllele.Territory a6 : ForestryAllele.Territory.values()) {
|
||||
|
||||
case TERRITORY:
|
||||
for (ForestryAllele.Territory a6 : ForestryAllele.Territory.values()) {
|
||||
alleles.add(a6.getAllele());
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,10 @@ package binnie.botany.genetics;
|
||||
|
||||
import forestry.api.genetics.IAlleleInteger;
|
||||
|
||||
import binnie.botany.api.IFlowerColour;
|
||||
import binnie.botany.api.IFlowerColor;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
/**
|
||||
* Created by Marcin on 03.06.2017.
|
||||
*/
|
||||
public class FlowerColorAllele implements IFlowerColour, IAlleleInteger {
|
||||
public class FlowerColorAllele implements IFlowerColor, IAlleleInteger {
|
||||
private int color;
|
||||
private String uid;
|
||||
private boolean isDominant;
|
||||
@@ -47,14 +44,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 +70,7 @@ public class FlowerColorAllele implements IFlowerColour, IAlleleInteger {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColourName() {
|
||||
return I18N.localise("botany.colour." + getName());
|
||||
public String getColorName() {
|
||||
return I18N.localise("botany.color." + getAlleleName());
|
||||
}
|
||||
}
|
||||
@@ -954,34 +954,34 @@ public enum FlowerDefinition implements IFlowerDefinition {
|
||||
private IAllele[] template;
|
||||
private IFlowerGenome genome;
|
||||
|
||||
FlowerDefinition(final String name, final String branch, final String binomial, final IFlowerType<EnumFlowerType> type, final EnumFlowerColor colour) {
|
||||
FlowerDefinition(String name, String branch, String binomial, IFlowerType<EnumFlowerType> type, EnumFlowerColor colour) {
|
||||
this(name, branch, binomial, type, false, colour, colour);
|
||||
}
|
||||
|
||||
FlowerDefinition(final String name, final String branch, final String binomial, final IFlowerType<EnumFlowerType> type, final EnumFlowerColor primaryColor, final EnumFlowerColor secondaryColor) {
|
||||
FlowerDefinition(String name, String branch, String binomial, IFlowerType<EnumFlowerType> type, EnumFlowerColor primaryColor, EnumFlowerColor secondaryColor) {
|
||||
this(name, branch, binomial, type, true, primaryColor, secondaryColor);
|
||||
}
|
||||
|
||||
FlowerDefinition(final String name, final String branch, final String binomial, final IFlowerType<EnumFlowerType> type, final boolean isDominant, final EnumFlowerColor colour) {
|
||||
FlowerDefinition(String name, String branch, String binomial, IFlowerType<EnumFlowerType> type, boolean isDominant, EnumFlowerColor colour) {
|
||||
this(name, branch, binomial, type, isDominant, colour, colour);
|
||||
}
|
||||
|
||||
FlowerDefinition(final String name, final String branch, final String binomial, final IFlowerType<EnumFlowerType> flowerType, final boolean isDominant, final EnumFlowerColor primaryColor, final EnumFlowerColor secondaryColor) {
|
||||
FlowerDefinition(String name, String branch, String binomial, IFlowerType<EnumFlowerType> flowerType, boolean isDominant, EnumFlowerColor primaryColor, EnumFlowerColor secondaryColor) {
|
||||
String uid = Constants.BOTANY_MOD_ID + ".flower" + this;
|
||||
String unlocalizedDescription = "botany.description.flower" + this;
|
||||
String unlocalizedName = "botany.flowers.species." + name;
|
||||
|
||||
this.variantTemplates = new ArrayList<>();
|
||||
variantTemplates = new ArrayList<>();
|
||||
this.name = name;
|
||||
this.binomial = binomial;
|
||||
this.branchName = branch;
|
||||
this.type = flowerType;
|
||||
branchName = branch;
|
||||
type = flowerType;
|
||||
this.primaryColor = primaryColor;
|
||||
this.secondaryColor = secondaryColor;
|
||||
|
||||
IAlleleFlowerSpeciesBuilder speciesBuilder = FlowerManager.flowerFactory.createSpecies(uid, unlocalizedName, "Binnie's Mod Team", unlocalizedDescription, isDominant, getBranch(), binomial, flowerType);
|
||||
setSpeciesProperties(speciesBuilder);
|
||||
this.species = speciesBuilder.build();
|
||||
species = speciesBuilder.build();
|
||||
if (this.branch != null) {
|
||||
this.branch.addMemberSpecies(species);
|
||||
}
|
||||
@@ -1039,36 +1039,36 @@ public enum FlowerDefinition implements IFlowerDefinition {
|
||||
|
||||
protected abstract void registerMutations();
|
||||
|
||||
private IAllele[] addVariant(final EnumFlowerColor a, final EnumFlowerColor b) {
|
||||
final IAllele[] template = this.getTemplate();
|
||||
private IAllele[] addVariant(EnumFlowerColor a, EnumFlowerColor b) {
|
||||
IAllele[] template = getTemplate();
|
||||
template[EnumFlowerChromosome.PRIMARY.ordinal()] = a.getFlowerColorAllele();
|
||||
template[EnumFlowerChromosome.SECONDARY.ordinal()] = b.getFlowerColorAllele();
|
||||
this.variantTemplates.add(template);
|
||||
variantTemplates.add(template);
|
||||
return template;
|
||||
}
|
||||
|
||||
private IAllele[] addVariant(final EnumFlowerColor a) {
|
||||
return this.addVariant(a, a);
|
||||
private IAllele[] addVariant(EnumFlowerColor a) {
|
||||
return addVariant(a, a);
|
||||
}
|
||||
|
||||
public List<IAllele[]> getVariants() {
|
||||
return this.variantTemplates;
|
||||
return variantTemplates;
|
||||
}
|
||||
|
||||
public IClassification getBranch() {
|
||||
if (branch == null) {
|
||||
final String scientific = branchName.substring(0, 1).toUpperCase() + branchName.substring(1).toLowerCase();
|
||||
final String uid = "flowers." + branchName.toLowerCase();
|
||||
String scientific = branchName.substring(0, 1).toUpperCase() + branchName.substring(1).toLowerCase();
|
||||
String uid = "flowers." + branchName.toLowerCase();
|
||||
IClassification branch = AlleleManager.alleleRegistry.getClassification("genus." + uid);
|
||||
if (branch == null) {
|
||||
branch = AlleleManager.alleleRegistry.createAndRegisterClassification(IClassification.EnumClassLevel.GENUS, uid, scientific);
|
||||
}
|
||||
this.branch = branch;
|
||||
}
|
||||
return this.branch;
|
||||
return branch;
|
||||
}
|
||||
|
||||
public void setBranch(final IClassification branch) {
|
||||
public void setBranch(IClassification branch) {
|
||||
this.branch = branch;
|
||||
}
|
||||
|
||||
@@ -1121,7 +1121,7 @@ public enum FlowerDefinition implements IFlowerDefinition {
|
||||
}
|
||||
}
|
||||
|
||||
protected final IFlowerMutationBuilder registerMutation(final FlowerDefinition parent1, final FlowerDefinition parent2, final int chance) {
|
||||
protected final IFlowerMutationBuilder registerMutation(FlowerDefinition parent1, FlowerDefinition parent2, int chance) {
|
||||
return FlowerManager.flowerFactory.createMutation(parent1.species, parent2.species, getTemplate(), chance);
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,8 @@ public class FlowerFactory implements IFlowerFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlowerMutationBuilder createMutation(IAlleleFlowerSpecies parentFlower0, IAlleleFlowerSpecies parentFlower1, IAllele[] result, int chance) {
|
||||
FlowerMutation mutation = new FlowerMutation(parentFlower0, parentFlower1, result, chance);
|
||||
public IFlowerMutationBuilder createMutation(IAlleleFlowerSpecies allele0, IAlleleFlowerSpecies allele1, IAllele[] result, int chance) {
|
||||
FlowerMutation mutation = new FlowerMutation(allele0, allele1, result, chance);
|
||||
FlowerManager.flowerRoot.registerMutation(mutation);
|
||||
return mutation;
|
||||
}
|
||||
|
||||
@@ -26,11 +26,11 @@ import binnie.botany.api.IFlowerType;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
|
||||
public class FlowerGenome extends Genome implements IFlowerGenome {
|
||||
public FlowerGenome(final NBTTagCompound nbttagcompound) {
|
||||
public FlowerGenome(NBTTagCompound nbttagcompound) {
|
||||
super(nbttagcompound);
|
||||
}
|
||||
|
||||
public FlowerGenome(final IChromosome[] chromosomes) {
|
||||
public FlowerGenome(IChromosome[] chromosomes) {
|
||||
super(chromosomes);
|
||||
}
|
||||
|
||||
@@ -44,18 +44,17 @@ public class FlowerGenome extends Genome implements IFlowerGenome {
|
||||
if (species instanceof IAlleleFlowerSpecies) {
|
||||
return (IAlleleFlowerSpecies) species;
|
||||
}
|
||||
|
||||
return (IAlleleFlowerSpecies) getActiveAllele(itemStack, EnumFlowerChromosome.SPECIES, FlowerManager.flowerRoot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAlleleFlowerSpecies getPrimary() {
|
||||
return (IAlleleFlowerSpecies) this.getChromosomes()[EnumFlowerChromosome.SPECIES.ordinal()].getPrimaryAllele();
|
||||
return (IAlleleFlowerSpecies) getChromosomes()[EnumFlowerChromosome.SPECIES.ordinal()].getPrimaryAllele();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAlleleFlowerSpecies getSecondary() {
|
||||
return (IAlleleFlowerSpecies) this.getChromosomes()[EnumFlowerChromosome.SPECIES.ordinal()].getSecondaryAllele();
|
||||
return (IAlleleFlowerSpecies) getChromosomes()[EnumFlowerChromosome.SPECIES.ordinal()].getSecondaryAllele();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,80 +64,80 @@ public class FlowerGenome extends Genome implements IFlowerGenome {
|
||||
|
||||
@Override
|
||||
public FlowerColorAllele getPrimaryColor() {
|
||||
return ((FlowerColorAllele) this.getActiveAllele(EnumFlowerChromosome.PRIMARY));
|
||||
return ((FlowerColorAllele) getActiveAllele(EnumFlowerChromosome.PRIMARY));
|
||||
}
|
||||
|
||||
@Override
|
||||
public FlowerColorAllele getSecondaryColor() {
|
||||
return ((FlowerColorAllele) this.getActiveAllele(EnumFlowerChromosome.SECONDARY));
|
||||
return ((FlowerColorAllele) getActiveAllele(EnumFlowerChromosome.SECONDARY));
|
||||
}
|
||||
|
||||
@Override
|
||||
public FlowerColorAllele getStemColor() {
|
||||
return ((FlowerColorAllele) this.getActiveAllele(EnumFlowerChromosome.STEM));
|
||||
return ((FlowerColorAllele) getActiveAllele(EnumFlowerChromosome.STEM));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFertility() {
|
||||
return ((IAlleleInteger) this.getActiveAllele(EnumFlowerChromosome.FERTILITY)).getValue();
|
||||
return ((IAlleleInteger) getActiveAllele(EnumFlowerChromosome.FERTILITY)).getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLifespan() {
|
||||
return ((IAlleleInteger) this.getActiveAllele(EnumFlowerChromosome.LIFESPAN)).getValue() / 5;
|
||||
return ((IAlleleInteger) getActiveAllele(EnumFlowerChromosome.LIFESPAN)).getValue() / 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlowerType getType() {
|
||||
return this.getPrimary().getType();
|
||||
return getPrimary().getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumTolerance getToleranceTemperature() {
|
||||
return ((IAlleleTolerance) this.getActiveAllele(EnumFlowerChromosome.TEMPERATURE_TOLERANCE)).getValue();
|
||||
return ((IAlleleTolerance) getActiveAllele(EnumFlowerChromosome.TEMPERATURE_TOLERANCE)).getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumTolerance getToleranceMoisture() {
|
||||
return ((IAlleleTolerance) this.getActiveAllele(EnumFlowerChromosome.HUMIDITY_TOLERANCE)).getValue();
|
||||
return ((IAlleleTolerance) getActiveAllele(EnumFlowerChromosome.HUMIDITY_TOLERANCE)).getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumTolerance getTolerancePH() {
|
||||
return ((IAlleleTolerance) this.getActiveAllele(EnumFlowerChromosome.PH_TOLERANCE)).getValue();
|
||||
return ((IAlleleTolerance) getActiveAllele(EnumFlowerChromosome.PH_TOLERANCE)).getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAgeChance() {
|
||||
return 1.0f * (float) Math.sqrt(2.0f / this.getLifespan());
|
||||
return 1.0f * (float) Math.sqrt(2.0f / getLifespan());
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSappiness() {
|
||||
return ((IAlleleFloat) this.getActiveAllele(EnumFlowerChromosome.SAPPINESS)).getValue();
|
||||
return ((IAlleleFloat) getActiveAllele(EnumFlowerChromosome.SAPPINESS)).getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTolerate(final EnumAcidity ePH) {
|
||||
final int pH = ePH.ordinal();
|
||||
final int[] pHTol = Binnie.GENETICS.getTolerance(this.getTolerancePH());
|
||||
final int fPH = this.getPrimary().getPH().ordinal();
|
||||
public boolean canTolerate(EnumAcidity acidity) {
|
||||
int pH = acidity.ordinal();
|
||||
int[] pHTol = Binnie.GENETICS.getTolerance(getTolerancePH());
|
||||
int fPH = getPrimary().getPH().ordinal();
|
||||
return pH >= fPH + pHTol[0] && pH <= fPH + pHTol[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTolerate(final EnumMoisture eMoisture) {
|
||||
final int moisture = eMoisture.ordinal();
|
||||
final int[] moistTol = Binnie.GENETICS.getTolerance(this.getToleranceMoisture());
|
||||
final int fMoisture = this.getPrimary().getMoisture().ordinal();
|
||||
public boolean canTolerate(EnumMoisture moist) {
|
||||
int moisture = moist.ordinal();
|
||||
int[] moistTol = Binnie.GENETICS.getTolerance(getToleranceMoisture());
|
||||
int fMoisture = getPrimary().getMoisture().ordinal();
|
||||
return moisture >= fMoisture + moistTol[0] && moisture <= fMoisture + moistTol[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTolerate(final EnumTemperature eTemp) {
|
||||
final int temp = eTemp.ordinal();
|
||||
final int[] tempTol = Binnie.GENETICS.getTolerance(this.getToleranceTemperature());
|
||||
final int fTemp = this.getPrimary().getTemperature().ordinal();
|
||||
public boolean canTolerate(EnumTemperature temperature) {
|
||||
int temp = temperature.ordinal();
|
||||
int[] tempTol = Binnie.GENETICS.getTolerance(getToleranceTemperature());
|
||||
int fTemp = getPrimary().getTemperature().ordinal();
|
||||
return temp >= fTemp + tempTol[0] && temp <= fTemp + tempTol[1];
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import binnie.botany.api.IFlowerRoot;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
|
||||
public class FlowerMutation extends Mutation implements IFlowerMutation, IFlowerMutationBuilder {
|
||||
public FlowerMutation(final IAlleleFlowerSpecies allele0, final IAlleleFlowerSpecies allele1, final IAllele[] template, final int chance) {
|
||||
public FlowerMutation(IAlleleFlowerSpecies allele0, IAlleleFlowerSpecies allele1, IAllele[] template, int chance) {
|
||||
super(allele0, allele1, template, chance);
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ public class FlowerMutation extends Mutation implements IFlowerMutation, IFlower
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getChance(World world, BlockPos pos, IAlleleFlowerSpecies a0, IAlleleFlowerSpecies a1, IFlowerGenome g0, IFlowerGenome g1) {
|
||||
float processedChance = super.getChance(world, pos, a0, a1, g0, g1, ForestryAPI.climateManager.getDefaultClimate(world, pos));
|
||||
public float getChance(World world, BlockPos pos, IAlleleFlowerSpecies allele0, IAlleleFlowerSpecies allele1, IFlowerGenome genome0, IFlowerGenome genome1) {
|
||||
float processedChance = getChance(world, pos, allele0, allele1, genome0, genome1, ForestryAPI.climateManager.getDefaultClimate(world, pos));
|
||||
if (processedChance <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import binnie.botany.api.EnumFlowerChromosome;
|
||||
import binnie.botany.api.EnumFlowerStage;
|
||||
import binnie.botany.api.IAlleleFlowerSpecies;
|
||||
import binnie.botany.api.IBotanistTracker;
|
||||
import binnie.botany.api.IColourMix;
|
||||
import binnie.botany.api.IColorMix;
|
||||
import binnie.botany.api.IFlower;
|
||||
import binnie.botany.api.IFlowerGenome;
|
||||
import binnie.botany.api.IFlowerMutation;
|
||||
@@ -43,11 +43,11 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot {
|
||||
public static int flowerSpeciesCount = -1;
|
||||
public static ArrayList<IFlower> flowerTemplates = new ArrayList<>();
|
||||
private static ArrayList<IFlowerMutation> flowerMutations = new ArrayList<>();
|
||||
private static ArrayList<IColourMix> colourMixes = new ArrayList<>();
|
||||
private static ArrayList<IColorMix> colourMixes = new ArrayList<>();
|
||||
Map<ItemStack, IFlower> conversions;
|
||||
|
||||
public FlowerRoot() {
|
||||
this.conversions = new HashMap<>();
|
||||
conversions = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,7 +59,7 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot {
|
||||
public int getSpeciesCount() {
|
||||
if (FlowerRoot.flowerSpeciesCount < 0) {
|
||||
FlowerRoot.flowerSpeciesCount = 0;
|
||||
for (final Map.Entry<String, IAllele> entry : AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet()) {
|
||||
for (Map.Entry<String, IAllele> entry : AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet()) {
|
||||
if (entry.getValue() instanceof IAlleleFlowerSpecies && ((IAlleleFlowerSpecies) entry.getValue()).isCounted()) {
|
||||
++FlowerRoot.flowerSpeciesCount;
|
||||
}
|
||||
@@ -69,17 +69,17 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMember(final ItemStack stack) {
|
||||
return !stack.isEmpty() && this.getType(stack) != null;
|
||||
public boolean isMember(ItemStack stack) {
|
||||
return !stack.isEmpty() && getType(stack) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMember(ItemStack stack, ISpeciesType type) {
|
||||
return this.getType(stack) == type;
|
||||
return getType(stack) == type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMember(final IIndividual individual) {
|
||||
public boolean isMember(IIndividual individual) {
|
||||
return individual instanceof IFlower;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,6 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot {
|
||||
@Nullable
|
||||
public EnumFlowerStage getType(ItemStack stack) {
|
||||
Item item = stack.getItem();
|
||||
|
||||
if (Botany.flowerItem == item) {
|
||||
return EnumFlowerStage.SEED;
|
||||
} else if (Botany.pollen == item) {
|
||||
@@ -105,64 +104,64 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot {
|
||||
} else if (Botany.seed == item) {
|
||||
return EnumFlowerStage.SEED;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getMemberStack(IIndividual flower, ISpeciesType type) {
|
||||
if (!this.isMember(flower)) {
|
||||
if (!isMember(flower)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
Item flowerItem = Botany.flowerItem;
|
||||
if (type == EnumFlowerStage.SEED) {
|
||||
flowerItem = Botany.seed;
|
||||
}
|
||||
if (type == EnumFlowerStage.POLLEN) {
|
||||
} else if (type == EnumFlowerStage.POLLEN) {
|
||||
flowerItem = Botany.pollen;
|
||||
}
|
||||
if (flowerItem != Botany.flowerItem) {
|
||||
((IFlower) flower).setAge(0);
|
||||
}
|
||||
final NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
flower.writeToNBT(nbttagcompound);
|
||||
final ItemStack flowerStack = new ItemStack(flowerItem);
|
||||
ItemStack flowerStack = new ItemStack(flowerItem);
|
||||
flowerStack.setTagCompound(nbttagcompound);
|
||||
return flowerStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IFlower getMember(final ItemStack stack) {
|
||||
if (!this.isMember(stack) || stack.getTagCompound() == null) {
|
||||
public IFlower getMember(ItemStack stack) {
|
||||
if (!isMember(stack) || stack.getTagCompound() == null) {
|
||||
return null;
|
||||
}
|
||||
return new Flower(stack.getTagCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlower getFlower(final IFlowerGenome genome) {
|
||||
public IFlower getFlower(IFlowerGenome genome) {
|
||||
return new Flower(genome, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlowerGenome templateAsGenome(final IAllele[] template) {
|
||||
return new FlowerGenome(this.templateAsChromosomes(template));
|
||||
public IFlowerGenome templateAsGenome(IAllele[] template) {
|
||||
return new FlowerGenome(templateAsChromosomes(template));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlowerGenome templateAsGenome(final IAllele[] templateActive, final IAllele[] templateInactive) {
|
||||
return new FlowerGenome(this.templateAsChromosomes(templateActive, templateInactive));
|
||||
public IFlowerGenome templateAsGenome(IAllele[] templateActive, IAllele[] templateInactive) {
|
||||
return new FlowerGenome(templateAsChromosomes(templateActive, templateInactive));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlower templateAsIndividual(final IAllele[] template) {
|
||||
return new Flower(this.templateAsGenome(template), 2);
|
||||
public IFlower templateAsIndividual(IAllele[] template) {
|
||||
return new Flower(templateAsGenome(template), 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlower templateAsIndividual(final IAllele[] templateActive, final IAllele[] templateInactive) {
|
||||
return new Flower(this.templateAsGenome(templateActive, templateInactive), 2);
|
||||
public IFlower templateAsIndividual(IAllele[] templateActive, IAllele[] templateInactive) {
|
||||
return new Flower(templateAsGenome(templateActive, templateInactive), 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -171,21 +170,21 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTemplate(final IAllele[] template) {
|
||||
this.registerTemplate(template[0].getUID(), template);
|
||||
public void registerTemplate(IAllele[] template) {
|
||||
registerTemplate(template[0].getUID(), template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTemplate(final String identifier, final IAllele[] template) {
|
||||
FlowerRoot.flowerTemplates.add(new Flower(this.templateAsGenome(template), 2));
|
||||
if (!this.speciesTemplates.containsKey(identifier)) {
|
||||
this.speciesTemplates.put(identifier, template);
|
||||
public void registerTemplate(String identifier, IAllele[] template) {
|
||||
FlowerRoot.flowerTemplates.add(new Flower(templateAsGenome(template), 2));
|
||||
if (!speciesTemplates.containsKey(identifier)) {
|
||||
speciesTemplates.put(identifier, template);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAllele[] getTemplate(final String identifier) {
|
||||
return this.speciesTemplates.get(identifier);
|
||||
public IAllele[] getTemplate(String identifier) {
|
||||
return speciesTemplates.get(identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -194,12 +193,12 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAllele[] getRandomTemplate(final Random rand) {
|
||||
return this.speciesTemplates.values().toArray(new IAllele[0][])[rand.nextInt(this.speciesTemplates.values().size())];
|
||||
public IAllele[] getRandomTemplate(Random rand) {
|
||||
return speciesTemplates.values().toArray(new IAllele[0][])[rand.nextInt(speciesTemplates.values().size())];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<IFlowerMutation> getMutations(final boolean shuffle) {
|
||||
public ArrayList<IFlowerMutation> getMutations(boolean shuffle) {
|
||||
if (shuffle) {
|
||||
Collections.shuffle(FlowerRoot.flowerMutations);
|
||||
}
|
||||
@@ -207,7 +206,7 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerMutation(final IMutation mutation) {
|
||||
public void registerMutation(IMutation mutation) {
|
||||
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getTemplate()[0].getUID())) {
|
||||
return;
|
||||
}
|
||||
@@ -221,8 +220,8 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBotanistTracker getBreedingTracker(final World world, @Nullable final GameProfile player) {
|
||||
final String filename = "BotanistTracker." + ((player == null) ? "common" : player.getId());
|
||||
public IBotanistTracker getBreedingTracker(World world, @Nullable GameProfile player) {
|
||||
String filename = "BotanistTracker." + ((player == null) ? "common" : player.getId());
|
||||
BotanistTracker tracker = (BotanistTracker) world.loadData(BotanistTracker.class, filename);
|
||||
if (tracker == null) {
|
||||
tracker = new BotanistTracker(filename);
|
||||
@@ -232,7 +231,7 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndividual getMember(final NBTTagCompound compound) {
|
||||
public IIndividual getMember(NBTTagCompound compound) {
|
||||
return new Flower(compound);
|
||||
}
|
||||
|
||||
@@ -252,15 +251,15 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addConversion(final ItemStack itemstack, final IAllele[] template) {
|
||||
final IFlower flower = this.getFlower(this.templateAsGenome(template));
|
||||
this.conversions.put(itemstack, flower);
|
||||
public void addConversion(ItemStack itemstack, IAllele[] template) {
|
||||
IFlower flower = getFlower(templateAsGenome(template));
|
||||
conversions.put(itemstack, flower);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IFlower getConversion(final ItemStack itemstack) {
|
||||
for (final Map.Entry<ItemStack, IFlower> entry : this.conversions.entrySet()) {
|
||||
public IFlower getConversion(ItemStack itemstack) {
|
||||
for (Map.Entry<ItemStack, IFlower> entry : conversions.entrySet()) {
|
||||
if (entry.getKey().isItemEqual(itemstack)) {
|
||||
return (IFlower) entry.getValue().copy();
|
||||
}
|
||||
@@ -269,23 +268,24 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerColourMix(final IColourMix colourMix) {
|
||||
FlowerRoot.colourMixes.add(colourMix);
|
||||
public void registerColourMix(IColorMix colorMix) {
|
||||
FlowerRoot.colourMixes.add(colorMix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<IColourMix> getColourMixes(final boolean shuffle) {
|
||||
public Collection<IColorMix> getColorMixes(boolean shuffle) {
|
||||
if (shuffle) {
|
||||
Collections.shuffle(FlowerRoot.colourMixes);
|
||||
}
|
||||
return FlowerRoot.colourMixes;
|
||||
}
|
||||
|
||||
|
||||
public boolean plant(World world, BlockPos pos, IFlower flower, GameProfile owner) {
|
||||
boolean set = world.setBlockState(pos, Botany.flower.getDefaultState());
|
||||
if (!set) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
TileEntity below = world.getTileEntity(pos.down());
|
||||
if (tile != null && tile instanceof TileEntityFlower) {
|
||||
@@ -296,31 +296,35 @@ public class FlowerRoot extends SpeciesRoot implements IFlowerRoot {
|
||||
tileFlower.create(flower, owner);
|
||||
}
|
||||
}
|
||||
|
||||
tryGrowSection(world, pos);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void tryGrowSection(World world, BlockPos pos) {
|
||||
if (world.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
TileEntity tileFlower = world.getTileEntity(pos);
|
||||
if(tileFlower == null || !(tileFlower instanceof TileEntityFlower)){
|
||||
if (tileFlower == null || !(tileFlower instanceof TileEntityFlower)) {
|
||||
return;
|
||||
}
|
||||
|
||||
IFlower flower = ((TileEntityFlower) tileFlower).getFlower();
|
||||
int section = ((TileEntityFlower) tileFlower).getSection();
|
||||
if(flower == null || section >= flower.getGenome().getPrimary().getType().getSections() - 1 || flower.getAge() <= 0){
|
||||
if (flower == null || section >= flower.getGenome().getPrimary().getType().getSections() - 1 || flower.getAge() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
world.setBlockState(pos.up(), Botany.flower.getDefaultState());
|
||||
TileEntity flowerAbove = world.getTileEntity(pos.up());
|
||||
if (flowerAbove != null && flowerAbove instanceof TileEntityFlower) {
|
||||
((TileEntityFlower) flowerAbove).setSection(section + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onGrowFromSeed(World world, BlockPos pos) {
|
||||
tryGrowSection(world, pos);
|
||||
|
||||
@@ -8,8 +8,7 @@ import binnie.botany.api.EnumFlowerChromosome;
|
||||
|
||||
public class FlowerTemplates {
|
||||
public static IAllele[] getDefaultTemplate() {
|
||||
final IAllele[] alleles = new IAllele[EnumFlowerChromosome.values().length];
|
||||
//TODO: Test flower reset
|
||||
IAllele[] alleles = new IAllele[EnumFlowerChromosome.values().length];
|
||||
AlleleHelper.getInstance().set(alleles, EnumFlowerChromosome.SPECIES, FlowerDefinition.Poppy.getSpecies());
|
||||
AlleleHelper.getInstance().set(alleles, EnumFlowerChromosome.PRIMARY, EnumFlowerColor.Red.getFlowerColorAllele());
|
||||
AlleleHelper.getInstance().set(alleles, EnumFlowerChromosome.SECONDARY, EnumFlowerColor.Red.getFlowerColorAllele());
|
||||
|
||||
@@ -18,20 +18,21 @@ import forestry.api.core.IModelManager;
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.CreativeTabBotany;
|
||||
import binnie.botany.core.BotanyGUI;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public class ItemDictionary extends Item implements IItemModelRegister {
|
||||
public ItemDictionary() {
|
||||
this.setCreativeTab(CreativeTabBotany.instance);
|
||||
this.setUnlocalizedName("database");
|
||||
this.setMaxStackSize(1);
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
setUnlocalizedName("database");
|
||||
setMaxStackSize(1);
|
||||
setRegistryName("database");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(final Item itemIn, final CreativeTabs tab, final NonNullList<ItemStack> subItems) {
|
||||
super.getSubItems(itemIn, tab, subItems);
|
||||
subItems.add(new ItemStack(itemIn, 1, 1));
|
||||
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
|
||||
if (this.isInCreativeTab(tab)) {
|
||||
items.add(new ItemStack(this, 1, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,15 +46,15 @@ public class ItemDictionary extends Item implements IItemModelRegister {
|
||||
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
|
||||
ItemStack itemStack = playerIn.getHeldItem(handIn);
|
||||
if (itemStack.getMetadata() == 0) {
|
||||
Botany.proxy.openGui(BotanyGUI.Database, playerIn, playerIn.getPosition());
|
||||
Botany.proxy.openGui(BotanyGUI.DATABASE, playerIn, playerIn.getPosition());
|
||||
} else {
|
||||
Botany.proxy.openGui(BotanyGUI.DatabaseNEI, playerIn, playerIn.getPosition());
|
||||
Botany.proxy.openGui(BotanyGUI.DATABASE_NEI, playerIn, playerIn.getPosition());
|
||||
}
|
||||
return super.onItemRightClick(worldIn, playerIn, handIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack i) {
|
||||
return (i.getItemDamage() == 0) ? "Botanist Database" : "Master Botanist Database";
|
||||
public String getItemStackDisplayName(ItemStack i) {
|
||||
return I18N.localise("item.botany.database." + ((i.getItemDamage() == 0) ? "name" : "master.name"));
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package binnie.botany.genetics;
|
||||
import java.awt.Color;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import binnie.Constants;
|
||||
import binnie.core.util.RecipeUtil;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -13,7 +15,6 @@ import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.api.storage.BackpackManager;
|
||||
import forestry.api.storage.IBackpackInterface;
|
||||
import forestry.core.recipes.RecipeUtil;
|
||||
import forestry.storage.BackpackDefinition;
|
||||
|
||||
import binnie.Binnie;
|
||||
@@ -35,7 +36,7 @@ public class ModuleGenetics implements IInitializable {
|
||||
@Override
|
||||
public void preInit() {
|
||||
/* INIT API*/
|
||||
binnie.botany.api.FlowerManager.flowerFactory = new FlowerFactory();
|
||||
FlowerManager.flowerFactory = new FlowerFactory();
|
||||
AlleleManager.alleleRegistry.registerSpeciesRoot(BotanyCore.getFlowerRoot());
|
||||
AlleleManager.alleleRegistry.registerAllele(ModuleGenetics.alleleEffectNone);
|
||||
EnumFlowerColor.setupMutations();
|
||||
@@ -43,7 +44,7 @@ public class ModuleGenetics implements IInitializable {
|
||||
|
||||
/* BACKPACK*/
|
||||
IBackpackInterface backpackInterface = BackpackManager.backpackInterface;
|
||||
|
||||
|
||||
if (ForestryAPI.enabledPlugins.contains("forestry.storage")) {
|
||||
Predicate<ItemStack> filter = BackpackManager.backpackInterface.createNaturalistBackpackFilter("rootFlowers");
|
||||
BackpackDefinition definition = new BackpackDefinition(new Color(0xf6e83e), Color.WHITE, filter);
|
||||
@@ -56,19 +57,19 @@ public class ModuleGenetics implements IInitializable {
|
||||
}
|
||||
|
||||
/* ITEMS */
|
||||
|
||||
Botany.flower = new BlockFlower();
|
||||
Botany.proxy.registerBlock(Botany.flower);
|
||||
BinnieCore.getBinnieProxy().registerTileEntity(TileEntityFlower.class, "botany.tile.flower", null);
|
||||
|
||||
Botany.flowerItem = new ItemBotany("itemFlower", EnumFlowerStage.FLOWER, "");
|
||||
Botany.pollen = new ItemBotany("pollen", EnumFlowerStage.POLLEN, "pollen");
|
||||
Botany.seed = new ItemBotany("seed", EnumFlowerStage.SEED, "germling");
|
||||
Botany.database = new ItemDictionary();
|
||||
|
||||
Botany.proxy.registerBlock(Botany.flower);
|
||||
Botany.proxy.registerItem(Botany.flowerItem);
|
||||
Botany.proxy.registerItem(Botany.pollen);
|
||||
Botany.proxy.registerItem(Botany.seed);
|
||||
Botany.proxy.registerItem(Botany.database);
|
||||
|
||||
BinnieCore.getBinnieProxy().registerTileEntity(TileEntityFlower.class, "botany.tile.flower", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,26 +80,32 @@ public class ModuleGenetics implements IInitializable {
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
RecipeUtil recipeUtil = new RecipeUtil(Constants.GENETICS_MOD_ID);
|
||||
forestry.api.apiculture.FlowerManager.flowerRegistry.registerAcceptableFlower(Botany.flower, "flowersVanilla");
|
||||
RecipeManagers.carpenterManager.addRecipe(100, Binnie.LIQUID.getFluidStack(ManagerLiquid.WATER, 2000), ItemStack.EMPTY, new ItemStack(Botany.database),
|
||||
"X#X",
|
||||
"YEY",
|
||||
"RDR",
|
||||
'#', Blocks.GLASS_PANE,
|
||||
'X', Items.GOLD_INGOT,
|
||||
'Y', Items.GOLD_NUGGET,
|
||||
'R', Items.REDSTONE,
|
||||
'D', Items.DIAMOND,
|
||||
'E', Items.EMERALD
|
||||
RecipeManagers.carpenterManager.addRecipe(
|
||||
100,
|
||||
Binnie.LIQUID.getFluidStack(ManagerLiquid.WATER, 2000),
|
||||
ItemStack.EMPTY,
|
||||
new ItemStack(Botany.database),
|
||||
"X#X",
|
||||
"YEY",
|
||||
"RDR",
|
||||
'#', Blocks.GLASS_PANE,
|
||||
'X', Items.GOLD_INGOT,
|
||||
'Y', Items.GOLD_NUGGET,
|
||||
'R', Items.REDSTONE,
|
||||
'D', Items.DIAMOND,
|
||||
'E', Items.EMERALD
|
||||
);
|
||||
RecipeUtil.addRecipe(Botany.botanistBackpack,
|
||||
"X#X",
|
||||
"VYZ",
|
||||
"X#X",
|
||||
'#', Blocks.WOOL,
|
||||
'X', Items.STRING,
|
||||
'V', Botany.soilMeter,
|
||||
'Z', "toolTrowel",
|
||||
'Y', "chestWood");
|
||||
recipeUtil.addRecipe("botanist_backpack", Botany.botanistBackpack,
|
||||
"X#X",
|
||||
"VYZ",
|
||||
"X#X",
|
||||
'#', Blocks.WOOL,
|
||||
'X', Items.STRING,
|
||||
'V', Botany.gardening().soilMeter,
|
||||
'Z', "toolTrowel",
|
||||
'Y', "chestWood"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package binnie.botany.gui.database;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import binnie.botany.api.IFlowerColor;
|
||||
import binnie.core.gui.Attribute;
|
||||
import binnie.core.gui.ITooltip;
|
||||
import binnie.core.gui.IWidget;
|
||||
import binnie.core.gui.Tooltip;
|
||||
import binnie.core.gui.controls.core.Control;
|
||||
import binnie.core.gui.controls.core.IControlValue;
|
||||
import binnie.core.gui.renderer.RenderUtil;
|
||||
|
||||
public class ControlColorDisplay extends Control implements IControlValue<IFlowerColor>, ITooltip {
|
||||
private IFlowerColor value;
|
||||
|
||||
public ControlColorDisplay(IWidget parent, int x, int y, IFlowerColor value) {
|
||||
super(parent, x, y, 16, 16);
|
||||
this.value = value;
|
||||
addAttribute(Attribute.MOUSE_OVER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlowerColor getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(IFlowerColor value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onRenderBackground(int guiWidth, int guiHeight) {
|
||||
RenderUtil.drawSolidRect(getArea(), -1);
|
||||
RenderUtil.drawSolidRect(getArea().inset(1), 0xff000000 + getValue().getColor(false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(Tooltip tooltip, ITooltipFlag tooltipFlag) {
|
||||
super.getTooltip(tooltip, tooltipFlag);
|
||||
tooltip.add(value.getColorName());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package binnie.botany.gui.database;
|
||||
|
||||
import binnie.botany.api.IColorMix;
|
||||
import binnie.core.gui.IWidget;
|
||||
import binnie.core.gui.controls.listbox.ControlListBox;
|
||||
|
||||
public class ControlColorMixBox extends ControlListBox<IColorMix> {
|
||||
private int index;
|
||||
private Type type;
|
||||
|
||||
public ControlColorMixBox(IWidget parent, int x, int y, int width, int height, Type type) {
|
||||
super(parent, x, y, width, height, 12);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWidget createOption(IColorMix value, int y) {
|
||||
return new ControlColorMixItem(getContent(), value, y);
|
||||
}
|
||||
|
||||
enum Type {
|
||||
RESULTANT,
|
||||
FURTHER,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package binnie.botany.gui.database;
|
||||
|
||||
import binnie.botany.api.IColorMix;
|
||||
import binnie.core.gui.controls.listbox.ControlList;
|
||||
import binnie.core.gui.controls.listbox.ControlOption;
|
||||
|
||||
public class ControlColorMixItem extends ControlOption<IColorMix> {
|
||||
private final ControlColorDisplay itemWidget1;
|
||||
private final ControlColorDisplay itemWidget2;
|
||||
private final ControlColorDisplay itemWidget3;
|
||||
private final ControlColorMixSymbol addSymbol;
|
||||
private final ControlColorMixSymbol arrowSymbol;
|
||||
|
||||
public ControlColorMixItem(ControlList<IColorMix> controlList, IColorMix option, int y) {
|
||||
super(controlList, option, y);
|
||||
IColorMix value = getValue();
|
||||
itemWidget1 = new ControlColorDisplay(this, 4, 4, value.getColorFirst());
|
||||
itemWidget2 = new ControlColorDisplay(this, 44, 4, value.getColorSecond());
|
||||
itemWidget3 = new ControlColorDisplay(this, 104, 4, value.getResult());
|
||||
addSymbol = new ControlColorMixSymbol(this, 24, 4, 0, value);
|
||||
arrowSymbol = new ControlColorMixSymbol(this, 64, 4, 1, value);
|
||||
}
|
||||
}
|
||||
Loaded 100 of 766 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user