mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-20 12:19:47 +00:00
Merge remote-tracking branch 'origin/master-MC1.11.2' into master-MC1.11.2
This commit is contained in:
commit
c9d3001b47
253 files changed
+3604
-3139
No files matched your search
@@ -60,7 +60,11 @@ 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;
|
||||
|
||||
@@ -102,25 +106,25 @@ public class Botany extends AbstractMod {
|
||||
public static Item botanistBackpack;
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(final FMLPreInitializationEvent evt) {
|
||||
this.preInit();
|
||||
public void preInit(FMLPreInitializationEvent evt) {
|
||||
preInit();
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(final FMLInitializationEvent evt) {
|
||||
this.init();
|
||||
public void init(FMLInitializationEvent evt) {
|
||||
init();
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void postInit(final FMLPostInitializationEvent evt) {
|
||||
this.postInit();
|
||||
public void postInit(FMLPostInitializationEvent evt) {
|
||||
postInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerModules() {
|
||||
this.addModule(new ModuleCore());
|
||||
this.addModule(new ModuleGenetics());
|
||||
this.addModule(new ModuleGardening());
|
||||
addModule(new ModuleCore());
|
||||
addModule(new ModuleGenetics());
|
||||
addModule(new ModuleGardening());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -164,7 +168,7 @@ public class Botany extends AbstractMod {
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onShearFlower(final PlayerInteractEvent.RightClickBlock event) {
|
||||
public void onShearFlower(PlayerInteractEvent.RightClickBlock event) {
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
if (player == null) {
|
||||
return;
|
||||
@@ -196,7 +200,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 +216,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 +263,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 +281,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 +290,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 +320,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();
|
||||
}
|
||||
+2
-2
@@ -2,8 +2,8 @@ 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();
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,7 @@ public class BlockCeramic extends Block implements IColoredBlock, IItemModelRegi
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(final Item item, final CreativeTabs tab, final NonNullList<ItemStack> itemList) {
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, NonNullList<ItemStack> itemList) {
|
||||
for (EnumFlowerColor c : EnumFlowerColor.values()) {
|
||||
itemList.add(new ItemStack(item, 1, c.getFlowerColorAllele().getID()));
|
||||
}
|
||||
|
||||
@@ -14,19 +14,19 @@ import binnie.extratrees.carpentry.ModuleCarpentry;
|
||||
public class BlockCeramicPatterned extends BlockDesign {
|
||||
public BlockCeramicPatterned() {
|
||||
super(CeramicDesignSystem.instance, Material.ROCK);
|
||||
this.setHardness(1.0f);
|
||||
this.setResistance(5.0f);
|
||||
this.setCreativeTab(CreativeTabBotany.instance);
|
||||
this.setRegistryName("ceramicPattern");
|
||||
setHardness(1.0f);
|
||||
setResistance(5.0f);
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
setRegistryName("ceramicPattern");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCreativeStack(final IDesign design) {
|
||||
public ItemStack getCreativeStack(IDesign design) {
|
||||
return ModuleCarpentry.getItemStack(this, CeramicColor.get(EnumFlowerColor.White), CeramicColor.get(EnumFlowerColor.Black), design);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlockName(final DesignBlock design) {
|
||||
public String getBlockName(DesignBlock design) {
|
||||
return I18N.localise("botany.ceramic.block.name", design.getDesign().getName());
|
||||
}
|
||||
}
|
||||
@@ -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,13 +137,13 @@ public class BlockStainedGlass extends Block implements IBlockMetadata, IColored
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName(final ItemStack itemStack) {
|
||||
public String getDisplayName(ItemStack itemStack) {
|
||||
EnumFlowerColor color = EnumFlowerColor.get(TileEntityMetadata.getItemDamage(itemStack));
|
||||
return I18N.localise("botany.pigmented.glass.name", color.getDisplayName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(final Item itemIn, final CreativeTabs tab, final NonNullList<ItemStack> itemList) {
|
||||
public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> itemList) {
|
||||
for (EnumFlowerColor color : EnumFlowerColor.values()) {
|
||||
itemList.add(TileEntityMetadata.getItemStack(this, color.ordinal()));
|
||||
}
|
||||
|
||||
@@ -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.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.ceramic))
|
||||
? getMaterial(itemStack.getItemDamage())
|
||||
: null;
|
||||
}
|
||||
}
|
||||
@@ -19,25 +19,25 @@ public class CeramicTileRecipe implements IRecipe {
|
||||
private ItemStack cached = ItemStack.EMPTY;
|
||||
|
||||
@Override
|
||||
public boolean matches(final InventoryCrafting inv, final World world) {
|
||||
this.cached = this.getCraftingResult(inv);
|
||||
return !this.cached.isEmpty();
|
||||
public boolean matches(InventoryCrafting inv, World world) {
|
||||
cached = getCraftingResult(inv);
|
||||
return !cached.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(final InventoryCrafting inv) {
|
||||
final Item ceramicBlock = Item.getItemFromBlock(Botany.ceramic);
|
||||
final Item ceramicTile = Item.getItemFromBlock(Botany.ceramicTile);
|
||||
final Item ceramicBrick = Item.getItemFromBlock(Botany.ceramicBrick);
|
||||
final Item mortar = Botany.misc;
|
||||
final List<ItemStack> stacks = new ArrayList<>();
|
||||
public ItemStack getCraftingResult(InventoryCrafting inv) {
|
||||
Item ceramicBlock = Item.getItemFromBlock(Botany.ceramic);
|
||||
Item ceramicTile = Item.getItemFromBlock(Botany.ceramicTile);
|
||||
Item ceramicBrick = Item.getItemFromBlock(Botany.ceramicBrick);
|
||||
Item mortar = Botany.misc;
|
||||
List<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;
|
||||
@@ -67,7 +67,7 @@ public class CeramicTileRecipe implements IRecipe {
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return this.cached;
|
||||
return cached;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,7 +17,7 @@ public class ItemCeramic extends ItemBlock implements IColoredItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(final int metadata) {
|
||||
public int getMetadata(int metadata) {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ import binnie.botany.api.IFlower;
|
||||
|
||||
public class PigmentRecipe implements IRecipe {
|
||||
@Override
|
||||
public boolean matches(final InventoryCrafting crafting, final World world) {
|
||||
return !this.getCraftingResult(crafting).isEmpty();
|
||||
public boolean matches(InventoryCrafting crafting, World world) {
|
||||
return !getCraftingResult(crafting).isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -24,7 +24,7 @@ public class PigmentRecipe implements IRecipe {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(final InventoryCrafting crafting) {
|
||||
public ItemStack getCraftingResult(InventoryCrafting crafting) {
|
||||
int n = 0;
|
||||
ItemStack stack = ItemStack.EMPTY;
|
||||
for (int i = 0; i < crafting.getSizeInventory(); ++i) {
|
||||
@@ -34,7 +34,7 @@ public class PigmentRecipe implements IRecipe {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
if (Binnie.GENETICS.getFlowerRoot().isMember(stackInSlot)) {
|
||||
final IFlower flower = Binnie.GENETICS.getFlowerRoot().getMember(stackInSlot);
|
||||
IFlower flower = Binnie.GENETICS.getFlowerRoot().getMember(stackInSlot);
|
||||
if (flower != null && flower.getAge() >= 1) {
|
||||
stack = new ItemStack(Botany.pigment, 1, flower.getGenome().getPrimaryColor().getID());
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -105,18 +105,18 @@ public class BlockCeramicBrick extends Block implements IMultipassBlock<CeramicB
|
||||
|
||||
@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(Item item, 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 +125,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 +140,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
|
||||
@@ -193,7 +201,7 @@ public class BlockCeramicBrick extends Block implements IMultipassBlock<CeramicB
|
||||
}
|
||||
}
|
||||
}
|
||||
return 16777215;
|
||||
return 0xffffff;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -14,16 +14,17 @@ import binnie.core.block.TileEntityMetadata;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public class CeramicBrickPair {
|
||||
EnumFlowerColor colorFirst;
|
||||
EnumFlowerColor colorSecond;
|
||||
CeramicBrickType type;
|
||||
int ordinal;
|
||||
public final EnumFlowerColor colorFirst;
|
||||
public final EnumFlowerColor colorSecond;
|
||||
|
||||
CeramicBrickPair(final EnumFlowerColor colorFirst, final EnumFlowerColor colorSecond, CeramicBrickType type) {
|
||||
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) {
|
||||
@@ -31,23 +32,23 @@ public class CeramicBrickPair {
|
||||
}
|
||||
|
||||
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 ItemStack getStack(int i) {
|
||||
return new ItemStack(Botany.ceramicBrick, i, this.ordinal());
|
||||
return new ItemStack(Botany.ceramicBrick, i, ordinal());
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
String name = this.colorFirst.getFlowerColorAllele().getColorName();
|
||||
if (this.type.canDouble() && this.colorSecond != this.colorFirst) {
|
||||
name = name + " & " + this.colorSecond.getFlowerColorAllele().getColorName();
|
||||
String name = colorFirst.getFlowerColorAllele().getColorName();
|
||||
if (type.canDouble() && colorSecond != colorFirst) {
|
||||
name = name + " & " + colorSecond.getFlowerColorAllele().getColorName();
|
||||
}
|
||||
return I18N.localise("botany.ceramic.type." + type.id + ".name", name);
|
||||
}
|
||||
@@ -58,7 +59,7 @@ public class CeramicBrickPair {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getSprite(int pass) {
|
||||
TextureAtlasSprite[] sprites = this.type.sprites;
|
||||
TextureAtlasSprite[] sprites = type.sprites;
|
||||
Preconditions.checkState(sprites != null, "Sprites have not been registered.");
|
||||
return sprites[pass];
|
||||
}
|
||||
@@ -71,6 +72,6 @@ public class CeramicBrickPair {
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof CeramicBrickPair
|
||||
&& ((CeramicBrickPair) obj).ordinal() == ordinal();
|
||||
&& ((CeramicBrickPair) obj).ordinal() == ordinal();
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package binnie.botany.ceramic.brick;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -18,7 +17,7 @@ import binnie.botany.items.BotanyItems;
|
||||
import binnie.core.block.TileEntityMetadata;
|
||||
|
||||
public enum CeramicBrickType implements IStringSerializable {
|
||||
Tile("tile") {
|
||||
TILE("tile") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<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)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
++blocks;
|
||||
final int color = TileEntityMetadata.getItemDamage(stack);
|
||||
int color = TileEntityMetadata.getItemDamage(stack);
|
||||
if (blockColor == -1) {
|
||||
blockColor = color;
|
||||
} else {
|
||||
@@ -48,29 +47,29 @@ public enum CeramicBrickType implements IStringSerializable {
|
||||
if (mortars != 1) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final EnumFlowerColor c = EnumFlowerColor.get(blockColor);
|
||||
return new CeramicBrickPair(c, c, CeramicBrickType.Tile).getStack(3);
|
||||
EnumFlowerColor c = EnumFlowerColor.get(blockColor);
|
||||
return new CeramicBrickPair(c, c, CeramicBrickType.TILE).getStack(3);
|
||||
}
|
||||
},
|
||||
Brick("brick") {
|
||||
BRICK("brick") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
return getBrickRecipe(this, stacks);
|
||||
}
|
||||
},
|
||||
StripeBrick("brickstripe") {
|
||||
STRIPE_BRICK("brickstripe") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
return getBrickRecipe(this, stacks);
|
||||
}
|
||||
},
|
||||
LargeBrick("bricklarge") {
|
||||
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) {
|
||||
for (ItemStack stack4 : stacks) {
|
||||
if (stack4.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final CeramicBrickPair type4 = new CeramicBrickPair(stack4);
|
||||
if (type4.type != CeramicBrickType.Tile) {
|
||||
CeramicBrickPair type4 = new CeramicBrickPair(stack4);
|
||||
if (type4.type != CeramicBrickType.TILE) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final int color5 = type4.colorFirst.ordinal();
|
||||
int color5 = type4.colorFirst.ordinal();
|
||||
if (colors[0] == -1) {
|
||||
colors[0] = color5;
|
||||
++a;
|
||||
a++;
|
||||
} else if (colors[0] == color5) {
|
||||
++a;
|
||||
a++;
|
||||
} else if (colors[1] == -1) {
|
||||
colors[1] = color5;
|
||||
++b;
|
||||
b++;
|
||||
} else {
|
||||
if (colors[1] != color5) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
++b;
|
||||
b++;
|
||||
}
|
||||
}
|
||||
if (colors[1] == -1) {
|
||||
colors[1] = colors[0];
|
||||
}
|
||||
return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), CeramicBrickType.LargeBrick).getStack(3);
|
||||
return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), CeramicBrickType.LARGE_BRICK).getStack(3);
|
||||
}
|
||||
}
|
||||
},
|
||||
Split("split") {
|
||||
SPLIT("split") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<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;
|
||||
for (ItemStack stack2 : stacks) {
|
||||
int alt = (altCounter != 0 && altCounter != 3) ? 1 : 0;
|
||||
if (stack2.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final CeramicBrickPair type = new CeramicBrickPair(stack2);
|
||||
if (type.type != CeramicBrickType.Tile) {
|
||||
CeramicBrickPair type = new CeramicBrickPair(stack2);
|
||||
if (type.type != CeramicBrickType.TILE) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final int color2 = type.colorFirst.ordinal();
|
||||
int color2 = type.colorFirst.ordinal();
|
||||
if (colors[alt] == -1) {
|
||||
colors[alt] = color2;
|
||||
} else if (colors[alt] != color2) {
|
||||
@@ -138,26 +137,26 @@ public enum CeramicBrickType implements IStringSerializable {
|
||||
}
|
||||
++altCounter;
|
||||
}
|
||||
return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), CeramicBrickType.Split).getStack(4);
|
||||
return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), CeramicBrickType.SPLIT).getStack(4);
|
||||
}
|
||||
},
|
||||
Chequered("cheque") {
|
||||
CHEQUERED("cheque") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
if (stacks.size() != 4) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final int[] colors = {-1, -1};
|
||||
for (final ItemStack stack2 : stacks) {
|
||||
int[] colors = {-1, -1};
|
||||
for (ItemStack stack2 : stacks) {
|
||||
if (stack2.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final CeramicBrickPair type2 = new CeramicBrickPair(stack2);
|
||||
if (type2.type != CeramicBrickType.Split) {
|
||||
CeramicBrickPair type2 = new CeramicBrickPair(stack2);
|
||||
if (type2.type != CeramicBrickType.SPLIT) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final int color3 = type2.colorFirst.ordinal();
|
||||
final int color4 = type2.colorSecond.ordinal();
|
||||
int color3 = type2.colorFirst.ordinal();
|
||||
int color4 = type2.colorSecond.ordinal();
|
||||
if (colors[0] == -1) {
|
||||
colors[0] = color3;
|
||||
colors[1] = color4;
|
||||
@@ -167,32 +166,32 @@ public enum CeramicBrickType implements IStringSerializable {
|
||||
}
|
||||
}
|
||||
}
|
||||
return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), CeramicBrickType.Chequered).getStack(4);
|
||||
return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), CeramicBrickType.CHEQUERED).getStack(4);
|
||||
}
|
||||
},
|
||||
Mixed("mixed") {
|
||||
MIXED("mixed") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
if (stacks.size() != 4) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final int[] colors = {-1, -1};
|
||||
for (final ItemStack stack2 : stacks) {
|
||||
int[] colors = {-1, -1};
|
||||
for (ItemStack stack2 : stacks) {
|
||||
if (stack2.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final CeramicBrickPair type2 = new CeramicBrickPair(stack2);
|
||||
CeramicBrickPair type2 = new CeramicBrickPair(stack2);
|
||||
if (type2.isTwoColors()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final int color3 = type2.colorFirst.ordinal();
|
||||
if (type2.type == CeramicBrickType.Split) {
|
||||
int color3 = type2.colorFirst.ordinal();
|
||||
if (type2.type == CeramicBrickType.SPLIT) {
|
||||
if (colors[1] != -1) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
colors[1] = color3;
|
||||
} else {
|
||||
if (type2.type != CeramicBrickType.Chequered) {
|
||||
if (type2.type != CeramicBrickType.CHEQUERED) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
if (colors[0] == -1) {
|
||||
@@ -201,27 +200,27 @@ public enum CeramicBrickType implements IStringSerializable {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
final int color4 = type2.colorSecond.ordinal();
|
||||
int color4 = type2.colorSecond.ordinal();
|
||||
}
|
||||
if (colors[0] == -1 || colors[1] == -1) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), CeramicBrickType.Mixed).getStack(4);
|
||||
return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), CeramicBrickType.MIXED).getStack(4);
|
||||
}
|
||||
},
|
||||
VerticalBrick("verticalbrick") {
|
||||
VERTICAL_BRICK("verticalbrick") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
return getVerticalBrickRecipe(stacks);
|
||||
}
|
||||
},
|
||||
VerticalStripeBrick("verticalbrickstripe") {
|
||||
VERTICAL_STRIPE_BRICK("verticalbrickstripe") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
return getVerticalBrickRecipe(stacks);
|
||||
}
|
||||
},
|
||||
VerticalLargeBrick("verticalbricklarge") {
|
||||
VERTICAL_LARGE_BRICK("verticalbricklarge") {
|
||||
@Override
|
||||
public ItemStack getRecipe(List<ItemStack> stacks) {
|
||||
return getVerticalBrickRecipe(stacks);
|
||||
@@ -230,7 +229,7 @@ public enum CeramicBrickType implements IStringSerializable {
|
||||
|
||||
public static final CeramicBrickType[] VALUES = values();
|
||||
|
||||
String id;
|
||||
public String id;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Nullable
|
||||
@@ -240,12 +239,12 @@ public enum CeramicBrickType implements IStringSerializable {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public static CeramicBrickType get(final int id) {
|
||||
public static CeramicBrickType get(int id) {
|
||||
return VALUES[id % VALUES.length];
|
||||
}
|
||||
|
||||
public boolean canDouble() {
|
||||
return this != CeramicBrickType.Tile;
|
||||
return this != CeramicBrickType.TILE;
|
||||
}
|
||||
|
||||
public abstract ItemStack getRecipe(List<ItemStack> stacks);
|
||||
@@ -254,18 +253,20 @@ public enum CeramicBrickType implements IStringSerializable {
|
||||
if (stacks.size() != 1) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final ItemStack stack5 = stacks.get(0);
|
||||
final CeramicBrickPair type = new CeramicBrickPair(stack5);
|
||||
if (type.type == CeramicBrickType.LargeBrick) {
|
||||
type.type = CeramicBrickType.VerticalLargeBrick;
|
||||
ItemStack stack5 = stacks.get(0);
|
||||
CeramicBrickPair type = new CeramicBrickPair(stack5);
|
||||
if (type.type == CeramicBrickType.LARGE_BRICK) {
|
||||
type.type = CeramicBrickType.VERTICAL_LARGE_BRICK;
|
||||
return type.getStack(1);
|
||||
}
|
||||
if (type.type == CeramicBrickType.Brick) {
|
||||
type.type = CeramicBrickType.VerticalBrick;
|
||||
|
||||
if (type.type == CeramicBrickType.BRICK) {
|
||||
type.type = CeramicBrickType.VERTICAL_BRICK;
|
||||
return type.getStack(1);
|
||||
}
|
||||
if (type.type == CeramicBrickType.StripeBrick) {
|
||||
type.type = CeramicBrickType.VerticalStripeBrick;
|
||||
|
||||
if (type.type == CeramicBrickType.STRIPE_BRICK) {
|
||||
type.type = CeramicBrickType.VERTICAL_STRIPE_BRICK;
|
||||
return type.getStack(1);
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
@@ -273,34 +274,38 @@ public enum CeramicBrickType implements IStringSerializable {
|
||||
|
||||
protected ItemStack getBrickRecipe(CeramicBrickType ceramicType, List<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);
|
||||
ItemStack stack4 = stacks.get(index2);
|
||||
if (stack4.getItem() != Item.getItemFromBlock(Botany.ceramicBrick)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final CeramicBrickPair type4 = new CeramicBrickPair(stack4);
|
||||
if (type4.type != CeramicBrickType.LargeBrick) {
|
||||
|
||||
CeramicBrickPair type4 = new CeramicBrickPair(stack4);
|
||||
if (type4.type != CeramicBrickType.LARGE_BRICK) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
final int color5 = type4.colorFirst.ordinal();
|
||||
final int color6 = type4.colorSecond.ordinal();
|
||||
|
||||
int color5 = type4.colorFirst.ordinal();
|
||||
int color6 = type4.colorSecond.ordinal();
|
||||
int alt2 = (index2 != 0 && index2 != 3) ? 1 : 0;
|
||||
if (ceramicType == CeramicBrickType.StripeBrick) {
|
||||
if (ceramicType == CeramicBrickType.STRIPE_BRICK) {
|
||||
alt2 = 0;
|
||||
}
|
||||
|
||||
if (colors[alt2] == -1) {
|
||||
colors[alt2] = color5;
|
||||
colors[1 - alt2] = color6;
|
||||
@@ -309,17 +314,16 @@ public enum CeramicBrickType implements IStringSerializable {
|
||||
}
|
||||
}
|
||||
return new CeramicBrickPair(EnumFlowerColor.get(colors[0]), EnumFlowerColor.get(colors[1]), ceramicType).getStack(4);
|
||||
} else {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
protected boolean isMortar(final ItemStack stack) {
|
||||
return stack.getItem() == Botany.misc && stack.getItemDamage() == BotanyItems.Mortar.ordinal();
|
||||
protected boolean isMortar(ItemStack stack) {
|
||||
return stack.getItem() == Botany.misc && stack.getItemDamage() == BotanyItems.MORTAR.ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ public class ItemCeramicBrick extends ItemBlock implements IColoredItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(final int metadata) {
|
||||
public int getMetadata(int metadata) {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,17 +18,17 @@ public class TileCeramicBrick extends TileEntity {
|
||||
}
|
||||
|
||||
public boolean hasTwoColors() {
|
||||
return CeramicBrickType.VALUES[getBlockMetadata()].canDouble() && this.colorSecond != this.colorFirst;
|
||||
return CeramicBrickType.VALUES[getBlockMetadata()].canDouble() && colorSecond != colorFirst;
|
||||
}
|
||||
|
||||
public ItemStack getStack(final int i) {
|
||||
final ItemStack s = TileEntityMetadata.getItemStack(Botany.ceramicBrick, this.ordinal());
|
||||
public ItemStack getStack(int i) {
|
||||
ItemStack s = TileEntityMetadata.getItemStack(Botany.ceramicBrick, ordinal());
|
||||
s.setCount(i);
|
||||
return s;
|
||||
}
|
||||
|
||||
public int ordinal() {
|
||||
return this.colorFirst.ordinal() + this.colorSecond.ordinal() * 256 + getBlockMetadata() * 256 * 256;
|
||||
return colorFirst.ordinal() + colorSecond.ordinal() * 256 + getBlockMetadata() * 256 * 256;
|
||||
}
|
||||
|
||||
public CeramicBrickPair pair() {
|
||||
@@ -61,6 +61,7 @@ public class TileCeramicBrick extends TileEntity {
|
||||
if (compound.hasKey("First")) {
|
||||
colorFirst = EnumFlowerColor.VALUES[compound.getInteger("First")];
|
||||
}
|
||||
|
||||
if (compound.hasKey("Second")) {
|
||||
colorSecond = EnumFlowerColor.VALUES[compound.getInteger("Second")];
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -13,21 +13,21 @@ import binnie.core.craftgui.minecraft.Window;
|
||||
import binnie.core.gui.IBinnieGUID;
|
||||
|
||||
public enum BotanyGUI implements IBinnieGUID {
|
||||
Database,
|
||||
DatabaseNEI;
|
||||
DATABASE,
|
||||
DATABASE_NEI;
|
||||
|
||||
@Override
|
||||
public Window getWindow(final EntityPlayer player, final World world, final int x, final int y, final int z, final Side side) {
|
||||
public Window getWindow(EntityPlayer player, World world, int x, int y, int z, Side side) {
|
||||
Window window = null;
|
||||
final TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z));
|
||||
TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z));
|
||||
IInventory object = null;
|
||||
if (tileEntity instanceof IInventory) {
|
||||
object = (IInventory) tileEntity;
|
||||
}
|
||||
switch (this) {
|
||||
case Database:
|
||||
case DatabaseNEI: {
|
||||
window = WindowBotanistDatabase.create(player, side, this != BotanyGUI.Database);
|
||||
case DATABASE:
|
||||
case DATABASE_NEI: {
|
||||
window = WindowBotanistDatabase.create(player, side, this != BotanyGUI.DATABASE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import binnie.core.resource.BinnieResource;
|
||||
import binnie.core.resource.IBinnieTexture;
|
||||
import binnie.core.resource.ResourceType;
|
||||
|
||||
// TODO unused enum?
|
||||
public enum BotanyTexture implements IBinnieTexture {
|
||||
;
|
||||
String texture;
|
||||
@@ -20,16 +21,16 @@ public enum BotanyTexture implements IBinnieTexture {
|
||||
@Nullable
|
||||
private BinnieResource resource;
|
||||
|
||||
BotanyTexture(final ResourceType base, final String texture) {
|
||||
BotanyTexture(ResourceType base, String texture) {
|
||||
this.texture = texture;
|
||||
this.type = base;
|
||||
type = base;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public BinnieResource getTexture() {
|
||||
if (resource == null) {
|
||||
resource = Binnie.RESOURCE.getPNG(Botany.instance, this.type, this.texture);
|
||||
resource = Binnie.RESOURCE.getPNG(Botany.instance, type, texture);
|
||||
}
|
||||
return resource;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package binnie.botany.craftgui;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import binnie.botany.api.IFlowerColour;
|
||||
import binnie.botany.api.IFlowerColor;
|
||||
import binnie.core.craftgui.Attribute;
|
||||
import binnie.core.craftgui.ITooltip;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
@@ -12,35 +12,35 @@ import binnie.core.craftgui.controls.core.Control;
|
||||
import binnie.core.craftgui.controls.core.IControlValue;
|
||||
import binnie.core.craftgui.renderer.RenderUtil;
|
||||
|
||||
public class ControlColorDisplay extends Control implements IControlValue<IFlowerColour>, ITooltip {
|
||||
private IFlowerColour value;
|
||||
public class ControlColorDisplay extends Control implements IControlValue<IFlowerColor>, ITooltip {
|
||||
private IFlowerColor value;
|
||||
|
||||
public ControlColorDisplay(final IWidget parent, final int x, final int y, final IFlowerColour value) {
|
||||
public ControlColorDisplay(IWidget parent, int x, int y, IFlowerColor value) {
|
||||
super(parent, x, y, 16, 16);
|
||||
this.value = value;
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
addAttribute(Attribute.MouseOver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlowerColour getValue() {
|
||||
return this.value;
|
||||
public IFlowerColor getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(final IFlowerColour value) {
|
||||
public void setValue(IFlowerColor value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onRenderBackground(int guiWidth, int guiHeight) {
|
||||
RenderUtil.drawSolidRect(this.getArea(), -1);
|
||||
RenderUtil.drawSolidRect(this.getArea().inset(1), -16777216 + this.getValue().getColor(false));
|
||||
RenderUtil.drawSolidRect(getArea(), -1);
|
||||
RenderUtil.drawSolidRect(getArea().inset(1), 0xff000000 + getValue().getColor(false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
public void getTooltip(Tooltip tooltip) {
|
||||
super.getTooltip(tooltip);
|
||||
tooltip.add(this.value.getColorName());
|
||||
tooltip.add(value.getColorName());
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,25 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import binnie.botany.api.IColourMix;
|
||||
import binnie.botany.api.IColorMix;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.controls.listbox.ControlListBox;
|
||||
|
||||
public class ControlColorMixBox extends ControlListBox<IColourMix> {
|
||||
public class ControlColorMixBox extends ControlListBox<IColorMix> {
|
||||
private int index;
|
||||
private Type type;
|
||||
|
||||
public ControlColorMixBox(final IWidget parent, final int x, final int y, final int width, final int height, final Type type) {
|
||||
public ControlColorMixBox(IWidget parent, int x, int y, int width, int height, Type type) {
|
||||
super(parent, x, y, width, height, 12);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWidget createOption(final IColourMix value, final int y) {
|
||||
return new ControlColorMixItem(this.getContent(), value, y);
|
||||
public IWidget createOption(IColorMix value, int y) {
|
||||
return new ControlColorMixItem(getContent(), value, y);
|
||||
}
|
||||
|
||||
enum Type {
|
||||
Resultant,
|
||||
Further,
|
||||
RESULTANT,
|
||||
FURTHER,
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,23 @@
|
||||
package binnie.botany.craftgui;
|
||||
|
||||
import binnie.botany.api.IColourMix;
|
||||
import binnie.botany.api.IColorMix;
|
||||
import binnie.core.craftgui.controls.listbox.ControlList;
|
||||
import binnie.core.craftgui.controls.listbox.ControlOption;
|
||||
|
||||
public class ControlColorMixItem extends ControlOption<IColourMix> {
|
||||
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(final ControlList<IColourMix> controlList, final IColourMix option, final int y) {
|
||||
public ControlColorMixItem(ControlList<IColorMix> controlList, IColorMix option, int y) {
|
||||
super(controlList, option, y);
|
||||
IColourMix value = this.getValue();
|
||||
this.itemWidget1 = new ControlColorDisplay(this, 4, 4, value.getColourFirst());
|
||||
this.itemWidget2 = new ControlColorDisplay(this, 44, 4, value.getColourSecond());
|
||||
this.itemWidget3 = new ControlColorDisplay(this, 104, 4, value.getResult());
|
||||
this.addSymbol = new ControlColorMixSymbol(this, 24, 4, 0, value);
|
||||
this.arrowSymbol = new ControlColorMixSymbol(this, 64, 4, 1, value);
|
||||
IColorMix value = getValue();
|
||||
itemWidget1 = new ControlColorDisplay(this, 4, 4, value.getColorFirst());
|
||||
itemWidget2 = new ControlColorDisplay(this, 44, 4, value.getColorSecond());
|
||||
itemWidget3 = new ControlColorDisplay(this, 104, 4, value.getResult());
|
||||
addSymbol = new ControlColorMixSymbol(this, 24, 4, 0, value);
|
||||
arrowSymbol = new ControlColorMixSymbol(this, 64, 4, 1, value);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package binnie.botany.craftgui;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import binnie.botany.api.IColourMix;
|
||||
import binnie.botany.api.IColorMix;
|
||||
import binnie.core.craftgui.Attribute;
|
||||
import binnie.core.craftgui.CraftGUI;
|
||||
import binnie.core.craftgui.ITooltip;
|
||||
@@ -19,36 +19,36 @@ import binnie.core.util.I18N;
|
||||
public class ControlColorMixSymbol 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;
|
||||
IColorMix value;
|
||||
int type;
|
||||
|
||||
protected ControlColorMixSymbol(final IWidget parent, final int x, final int y, final int type, final IColourMix value) {
|
||||
protected ControlColorMixSymbol(IWidget parent, int x, int y, int type, IColorMix value) {
|
||||
super(parent, x, y, 16 + type * 16, 16);
|
||||
this.value = value;
|
||||
this.type = type;
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
addAttribute(Attribute.MouseOver);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onRenderBackground(int guiWidth, int guiHeight) {
|
||||
super.onRenderBackground(guiWidth, guiHeight);
|
||||
if (this.type == 0) {
|
||||
if (type == 0) {
|
||||
CraftGUI.render.texture(ControlColorMixSymbol.MutationPlus, Point.ZERO);
|
||||
} else {
|
||||
CraftGUI.render.texture(ControlColorMixSymbol.MutationArrow, Point.ZERO);
|
||||
}
|
||||
}
|
||||
|
||||
public void setValue(final IColourMix value) {
|
||||
public void setValue(IColorMix value) {
|
||||
this.value = value;
|
||||
this.setColour(0xffffff);
|
||||
setColor(0xffffff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
if (this.type == 1) {
|
||||
final float chance = this.value.getChance();
|
||||
public void getTooltip(Tooltip tooltip) {
|
||||
if (type == 1) {
|
||||
float chance = value.getChance();
|
||||
tooltip.add(I18N.localise("botany.gui.controls.color_mix_symbol.chance", chance));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package binnie.botany.craftgui;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import binnie.botany.api.IFlowerColour;
|
||||
import binnie.botany.api.IFlowerColor;
|
||||
import binnie.core.craftgui.Attribute;
|
||||
import binnie.core.craftgui.CraftGUI;
|
||||
import binnie.core.craftgui.controls.listbox.ControlList;
|
||||
@@ -12,21 +12,21 @@ import binnie.core.craftgui.geometry.CraftGUIUtil;
|
||||
import binnie.core.craftgui.geometry.Point;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ControlColorOption extends ControlTextOption<IFlowerColour> {
|
||||
ControlColorDisplay controlBee;
|
||||
Point boxPosition;
|
||||
public class ControlColorOption extends ControlTextOption<IFlowerColor> {
|
||||
private ControlColorDisplay controlBee;
|
||||
private Point boxPosition;
|
||||
|
||||
public ControlColorOption(final ControlList<IFlowerColour> controlList, final IFlowerColour option, final int y) {
|
||||
public ControlColorOption(ControlList<IFlowerColor> controlList, IFlowerColor option, int y) {
|
||||
super(controlList, option, option.getColorName(), y);
|
||||
this.setSize(new Point(this.getSize().x(), 20));
|
||||
this.controlBee = new ControlColorDisplay(this, 2, 2, option);
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
CraftGUIUtil.moveWidget(this.textWidget, new Point(22, 0));
|
||||
this.textWidget.setSize(this.textWidget.getSize().sub(new Point(24, 0)));
|
||||
final int th = CraftGUI.render.textHeight(this.textWidget.getValue(), this.textWidget.getSize().x());
|
||||
final int height = Math.max(20, th + 6);
|
||||
this.setSize(new Point(this.size().x(), height));
|
||||
this.textWidget.setSize(new Point(this.textWidget.getSize().x(), height));
|
||||
this.boxPosition = new Point(2, (height - 18) / 2);
|
||||
setSize(new Point(getSize().x(), 20));
|
||||
controlBee = new ControlColorDisplay(this, 2, 2, option);
|
||||
addAttribute(Attribute.MouseOver);
|
||||
CraftGUIUtil.moveWidget(textWidget, new Point(22, 0));
|
||||
textWidget.setSize(textWidget.getSize().sub(new Point(24, 0)));
|
||||
int th = CraftGUI.render.textHeight(textWidget.getValue(), textWidget.getSize().x());
|
||||
int height = Math.max(20, th + 6);
|
||||
setSize(new Point(size().x(), height));
|
||||
textWidget.setSize(new Point(textWidget.getSize().x(), height));
|
||||
boxPosition = new Point(2, (height - 18) / 2);
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,8 @@ 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.api.IColorMix;
|
||||
import binnie.botany.api.IFlowerColor;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.controls.ControlText;
|
||||
@@ -13,24 +13,24 @@ import binnie.core.craftgui.database.DatabaseTab;
|
||||
import binnie.core.craftgui.database.PageAbstract;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public class PageColorMix extends PageAbstract<IFlowerColour> {
|
||||
public class PageColorMix extends PageAbstract<IFlowerColor> {
|
||||
ControlText pageSpeciesFurther_Title;
|
||||
ControlColorMixBox pageSpeciesFurther_List;
|
||||
|
||||
public PageColorMix(final IWidget parent, final DatabaseTab tab) {
|
||||
public PageColorMix(IWidget parent, DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
this.pageSpeciesFurther_Title = new ControlTextCentered(this, 8, I18N.localise("botany.gui.controls.page.color_further.title"));
|
||||
this.pageSpeciesFurther_List = new ControlColorMixBox(this, 4, 20, 136, 152, ControlColorMixBox.Type.Further);
|
||||
pageSpeciesFurther_Title = new ControlTextCentered(this, 8, I18N.localise("botany.gui.controls.page.color_further.title"));
|
||||
pageSpeciesFurther_List = new ControlColorMixBox(this, 4, 20, 136, 152, ControlColorMixBox.Type.FURTHER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(final IFlowerColour colour) {
|
||||
final List<IColourMix> mixes = new ArrayList<>();
|
||||
for (final IColourMix mix : BotanyCore.getFlowerRoot().getColourMixes(false)) {
|
||||
if (mix.getColourFirst() == colour || mix.getColourSecond() == colour) {
|
||||
public void onValueChanged(IFlowerColor colour) {
|
||||
List<IColorMix> mixes = new ArrayList<>();
|
||||
for (IColorMix mix : BotanyCore.getFlowerRoot().getColorMixes(false)) {
|
||||
if (mix.getColorFirst() == colour || mix.getColorSecond() == colour) {
|
||||
mixes.add(mix);
|
||||
}
|
||||
}
|
||||
this.pageSpeciesFurther_List.setOptions(mixes);
|
||||
pageSpeciesFurther_List.setOptions(mixes);
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,8 @@ 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.api.IColorMix;
|
||||
import binnie.botany.api.IFlowerColor;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.controls.ControlText;
|
||||
@@ -13,24 +13,24 @@ import binnie.core.craftgui.database.DatabaseTab;
|
||||
import binnie.core.craftgui.database.PageAbstract;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public class PageColorMixResultant extends PageAbstract<IFlowerColour> {
|
||||
public class PageColorMixResultant extends PageAbstract<IFlowerColor> {
|
||||
ControlText pageSpeciesFurther_Title;
|
||||
ControlColorMixBox pageSpeciesFurther_List;
|
||||
|
||||
public PageColorMixResultant(final IWidget parent, final DatabaseTab tab) {
|
||||
public PageColorMixResultant(IWidget parent, DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
this.pageSpeciesFurther_Title = new ControlTextCentered(this, 8, I18N.localise("botany.gui.controls.page.species_further.title"));
|
||||
this.pageSpeciesFurther_List = new ControlColorMixBox(this, 4, 20, 136, 152, ControlColorMixBox.Type.Resultant);
|
||||
pageSpeciesFurther_Title = new ControlTextCentered(this, 8, I18N.localise("botany.gui.controls.page.species_further.title"));
|
||||
pageSpeciesFurther_List = new ControlColorMixBox(this, 4, 20, 136, 152, ControlColorMixBox.Type.RESULTANT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(final IFlowerColour colour) {
|
||||
final List<IColourMix> mixes = new ArrayList<>();
|
||||
for (final IColourMix mix : BotanyCore.getFlowerRoot().getColourMixes(false)) {
|
||||
public void onValueChanged(IFlowerColor colour) {
|
||||
List<IColorMix> mixes = new ArrayList<>();
|
||||
for (IColorMix mix : BotanyCore.getFlowerRoot().getColorMixes(false)) {
|
||||
if (mix.getResult() == colour) {
|
||||
mixes.add(mix);
|
||||
}
|
||||
}
|
||||
this.pageSpeciesFurther_List.setOptions(mixes);
|
||||
pageSpeciesFurther_List.setOptions(mixes);
|
||||
}
|
||||
}
|
||||
@@ -26,11 +26,11 @@ import binnie.core.craftgui.minecraft.control.ControlItemDisplay;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public class PageSpeciesFlowerGenome extends PageSpecies {
|
||||
public PageSpeciesFlowerGenome(final IWidget parent, final DatabaseTab tab) {
|
||||
public PageSpeciesFlowerGenome(IWidget parent, DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
}
|
||||
|
||||
public static String tolerated(final boolean t) {
|
||||
public static String tolerated(boolean t) {
|
||||
if (t) {
|
||||
return "Tolerated";
|
||||
}
|
||||
@@ -38,48 +38,52 @@ public class PageSpeciesFlowerGenome extends PageSpecies {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onValueChanged(final IAlleleSpecies species) {
|
||||
this.deleteAllChildren();
|
||||
public void onValueChanged(IAlleleSpecies species) {
|
||||
deleteAllChildren();
|
||||
IAllele[] template = Binnie.GENETICS.getFlowerRoot().getTemplate(species.getUID());
|
||||
if (template == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
IFlower tree = Binnie.GENETICS.getFlowerRoot().templateAsIndividual(template);
|
||||
if (tree == null) {
|
||||
return;
|
||||
}
|
||||
IFlowerGenome genome = tree.getGenome();
|
||||
IAlleleFlowerSpecies treeSpecies = genome.getPrimary();
|
||||
int w = 144;
|
||||
int h = 176;
|
||||
new ControlText(this, new Area(0, 4, w, 16), I18N.localise("botany.gui.database.tab.genome"), TextJustification.MiddleCenter);
|
||||
new ControlText(this, new Area(0, 4, w, 16), I18N.localise("botany.gui.database.tab.genome"), TextJustification.MIDDLE_CENTER);
|
||||
ControlScrollableContent scrollable = new ControlScrollableContent(this, 4, 20, w - 8, h - 8 - 16, 12);
|
||||
Control contents = new Control(scrollable, 0, 0, w - 8 - 12, h - 8 - 16);
|
||||
int tw = w - 8 - 12;
|
||||
int w2 = 55;
|
||||
int w3 = tw - 50;
|
||||
int y = 0;
|
||||
final int th = 14;
|
||||
final int th2 = 18;
|
||||
new ControlText(contents, new Area(0, y, w2, th), I18N.localise("botany.gui.database.tab.genome.temp"), TextJustification.MiddleRight);
|
||||
new ControlText(contents, new Area(w2, y, w3, th), treeSpecies.getTemperature().getName(), TextJustification.MIDDLE_LEFTt);
|
||||
int th = 14;
|
||||
int th2 = 18;
|
||||
new ControlText(contents, new Area(0, y, w2, th), I18N.localise("botany.gui.database.tab.genome.temp"), TextJustification.MIDDLE_RIGHT);
|
||||
new ControlText(contents, new Area(w2, y, w3, th), treeSpecies.getTemperature().getName(), TextJustification.MIDDLE_LEFT);
|
||||
|
||||
y += th;
|
||||
new ControlText(contents, new Area(0, y, w2, th), I18N.localise("botany.gui.database.tab.genome.moist"), TextJustification.MiddleRight);
|
||||
new ControlText(contents, new Area(w2, y, w3, th), treeSpecies.getMoisture().getLocalisedName(false), TextJustification.MIDDLE_LEFTt);
|
||||
new ControlText(contents, new Area(0, y, w2, th), I18N.localise("botany.gui.database.tab.genome.moist"), TextJustification.MIDDLE_RIGHT);
|
||||
new ControlText(contents, new Area(w2, y, w3, th), treeSpecies.getMoisture().getLocalisedName(false), TextJustification.MIDDLE_LEFT);
|
||||
|
||||
y += th;
|
||||
new ControlText(contents, new Area(0, y, w2, th), I18N.localise("botany.gui.database.tab.genome.ph"), TextJustification.MiddleRight);
|
||||
new ControlText(contents, new Area(w2, y, w3, th), treeSpecies.getPH().getLocalisedName(false), TextJustification.MIDDLE_LEFTt);
|
||||
new ControlText(contents, new Area(0, y, w2, th), I18N.localise("botany.gui.database.tab.genome.ph"), TextJustification.MIDDLE_RIGHT);
|
||||
new ControlText(contents, new Area(w2, y, w3, th), treeSpecies.getPH().getLocalisedName(false), TextJustification.MIDDLE_LEFT);
|
||||
|
||||
y += th;
|
||||
new ControlText(contents, new Area(0, y, w2, th), I18N.localise("botany.gui.database.tab.genome.fertility"), TextJustification.MiddleRight);
|
||||
new ControlText(contents, new Area(w2, y, w3, th), genome.getFertility() + "x", TextJustification.MIDDLE_LEFTt);
|
||||
new ControlText(contents, new Area(0, y, w2, th), I18N.localise("botany.gui.database.tab.genome.fertility"), TextJustification.MIDDLE_RIGHT);
|
||||
new ControlText(contents, new Area(w2, y, w3, th), genome.getFertility() + "x", TextJustification.MIDDLE_LEFT);
|
||||
|
||||
y += th;
|
||||
float lifespan = genome.getLifespan() * 68.27f / genome.getAgeChance() / 24000.0f;
|
||||
String lifespanValue = String.format("%.2f", lifespan);
|
||||
new ControlText(contents, new Area(0, y, w2, th), I18N.localise("botany.gui.database.tab.genome.lifespan"), TextJustification.MiddleRight);
|
||||
new ControlText(contents, new Area(w2, y, w3, th), I18N.localise("botany.gui.database.tab.genome.lifespan.value", lifespanValue), TextJustification.MIDDLE_LEFTt);
|
||||
new ControlText(contents, new Area(0, y, w2, th), I18N.localise("botany.gui.database.tab.genome.lifespan"), TextJustification.MIDDLE_RIGHT);
|
||||
new ControlText(contents, new Area(w2, y, w3, th), I18N.localise("botany.gui.database.tab.genome.lifespan.value", lifespanValue), TextJustification.MIDDLE_LEFT);
|
||||
|
||||
y += th;
|
||||
new ControlText(contents, new Area(0, y, w2, th), I18N.localise("botany.gui.database.tab.genome.nectar"), TextJustification.MiddleRight);
|
||||
new ControlText(contents, new Area(w2, y, w3, th), genome.getActiveAllele(EnumFlowerChromosome.SAPPINESS).getName(), TextJustification.MIDDLE_LEFTt);
|
||||
new ControlText(contents, new Area(0, y, w2, th), I18N.localise("botany.gui.database.tab.genome.nectar"), TextJustification.MIDDLE_RIGHT);
|
||||
new ControlText(contents, new Area(w2, y, w3, th), genome.getActiveAllele(EnumFlowerChromosome.SAPPINESS).getName(), TextJustification.MIDDLE_LEFT);
|
||||
|
||||
y += th;
|
||||
int x = w2;
|
||||
int tot = 0;
|
||||
@@ -96,8 +100,9 @@ public class PageSpeciesFlowerGenome extends PageSpecies {
|
||||
x += 18;
|
||||
}
|
||||
}
|
||||
|
||||
int numOfLines = 1 + (tot - 1) / 3;
|
||||
new ControlText(contents, new Area(0, y - (numOfLines - 1) * 18, w2, 4 + 18 * numOfLines), I18N.localise("botany.gui.database.tab.genome.varieties"), TextJustification.MiddleRight);
|
||||
new ControlText(contents, new Area(0, y - (numOfLines - 1) * 18, w2, 4 + 18 * numOfLines), I18N.localise("botany.gui.database.tab.genome.varieties"), TextJustification.MIDDLE_RIGHT);
|
||||
y += th;
|
||||
contents.setSize(new Point(contents.size().x(), y));
|
||||
scrollable.setScrollableContent(contents);
|
||||
|
||||
@@ -11,7 +11,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.api.IFlowerColour;
|
||||
import binnie.botany.api.IFlowerColor;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.core.AbstractMod;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
@@ -31,30 +31,30 @@ import binnie.core.craftgui.minecraft.Window;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public class WindowBotanistDatabase extends WindowAbstractDatabase {
|
||||
ControlListBox<EnumFlowerColor> selectionBoxColors;
|
||||
private ControlListBox<EnumFlowerColor> selectionBoxColors;
|
||||
|
||||
public WindowBotanistDatabase(final EntityPlayer player, final Side side, final boolean nei) {
|
||||
public WindowBotanistDatabase(EntityPlayer player, Side side, boolean nei) {
|
||||
super(player, side, nei, Binnie.GENETICS.flowerBreedingSystem, 130);
|
||||
}
|
||||
|
||||
public static Window create(final EntityPlayer player, final Side side, final boolean nei) {
|
||||
public static Window create(EntityPlayer player, Side side, boolean nei) {
|
||||
return new WindowBotanistDatabase(player, side, nei);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected void addTabs() {
|
||||
new PageSpeciesOverview(this.getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.overview", 0));
|
||||
new PageSpeciesFlowerGenome(this.getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "genome", 0));
|
||||
new PageSpeciesClassification(this.getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.classification", 0));
|
||||
new PageSpeciesResultant(this.getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.resultant", 0));
|
||||
new PageSpeciesMutations(this.getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.further", 0));
|
||||
new PageBranchOverview(this.getInfoPages(Mode.BRANCHES), new DatabaseTab(Botany.instance, "branches.overview", 0));
|
||||
new PageBranchSpecies(this.getInfoPages(Mode.BRANCHES), new DatabaseTab(Botany.instance, "branches.species", 0));
|
||||
this.createMode(FlowerMode.Color, new FlowerColorModeWidgets());
|
||||
new PageColorMixResultant(this.getInfoPages(FlowerMode.Color), new DatabaseTab(Botany.instance, "color.resultant", 0));
|
||||
new PageColorMix(this.getInfoPages(FlowerMode.Color), new DatabaseTab(Botany.instance, "color.further", 0));
|
||||
new PageBreeder(this.getInfoPages(Mode.BREEDER), this.getUsername(), new DatabaseTab(Botany.instance, "breeder", 0));
|
||||
new PageSpeciesOverview(getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.overview", 0));
|
||||
new PageSpeciesFlowerGenome(getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "genome", 0));
|
||||
new PageSpeciesClassification(getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.classification", 0));
|
||||
new PageSpeciesResultant(getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.resultant", 0));
|
||||
new PageSpeciesMutations(getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.further", 0));
|
||||
new PageBranchOverview(getInfoPages(Mode.BRANCHES), new DatabaseTab(Botany.instance, "branches.overview", 0));
|
||||
new PageBranchSpecies(getInfoPages(Mode.BRANCHES), new DatabaseTab(Botany.instance, "branches.species", 0));
|
||||
createMode(FlowerMode.Color, new FlowerColorModeWidgets());
|
||||
new PageColorMixResultant(getInfoPages(FlowerMode.Color), new DatabaseTab(Botany.instance, "color.resultant", 0));
|
||||
new PageColorMix(getInfoPages(FlowerMode.Color), new DatabaseTab(Botany.instance, "color.further", 0));
|
||||
new PageBreeder(getInfoPages(Mode.BREEDER), getUsername(), new DatabaseTab(Botany.instance, "breeder", 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,7 +72,7 @@ public class WindowBotanistDatabase extends WindowAbstractDatabase {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return I18N.localise("botany.gui.database.tab." + this.name().toLowerCase());
|
||||
return I18N.localise("botany.gui.database.tab." + name().toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,15 +83,16 @@ public class WindowBotanistDatabase extends WindowAbstractDatabase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createListBox(final Area area) {
|
||||
this.listBox = new ControlListBox<IFlowerColour>(this.modePage, area.xPos(), area.yPos(), area.width(), area.height(), 12) {
|
||||
public void createListBox(Area area) {
|
||||
listBox = new ControlListBox<IFlowerColor>(modePage, area.xPos(), area.yPos(), area.width(), area.height(), 12) {
|
||||
@Override
|
||||
public IWidget createOption(final IFlowerColour value, final int y) {
|
||||
return new ControlColorOption(this.getContent(), value, y);
|
||||
public IWidget createOption(IFlowerColor value, int y) {
|
||||
return new ControlColorOption(getContent(), value, y);
|
||||
}
|
||||
};
|
||||
final List<IFlowerColour> colors = Arrays.stream(EnumFlowerColor.values()).map( c -> c.getFlowerColorAllele()).collect(Collectors.toList());
|
||||
this.listBox.setOptions(colors);
|
||||
|
||||
List<IFlowerColor> colors = Arrays.stream(EnumFlowerColor.values()).map(c -> c.getFlowerColorAllele()).collect(Collectors.toList());
|
||||
listBox.setOptions(colors);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,15 +23,15 @@ public class CircuitGarden extends BinnieCircuit {
|
||||
|
||||
public CircuitGarden(EnumMoisture moisture, @Nullable EnumAcidity ph, boolean manual, boolean fertilised, ItemStack recipe, ItemStack icon) {
|
||||
super(getName(moisture, ph, manual, fertilised), 4, getLayout(manual), recipe);
|
||||
this.isManual = manual;
|
||||
this.logic = new GardenLogic(moisture, ph, this.isManual, fertilised, icon, I18N.localise(this.getUnlocalizedName()));
|
||||
isManual = manual;
|
||||
logic = new GardenLogic(moisture, ph, isManual, fertilised, icon, I18N.localise(getUnlocalizedName()));
|
||||
String info = I18N.localise("botany.moisture") + ": " + moisture.getLocalisedName(true);
|
||||
if(ph != null){
|
||||
info+= TextFormatting.GRAY + ", " + I18N.localise("botany.ph") + ": " + moisture.getLocalisedName(true);
|
||||
if (ph != null) {
|
||||
info += TextFormatting.GRAY + ", " + I18N.localise("botany.ph") + ": " + moisture.getLocalisedName(true);
|
||||
}
|
||||
String fertilizedKey = fertilised ? "for.binnie.circuit.garden.fertilized" : "for.binnie.circuit.garden.unfertilized";
|
||||
info+= TextFormatting.GRAY + " " + I18N.localise(fertilizedKey);
|
||||
this.addTooltipString(I18N.localise("for.binnie.circuit.garden.info", info));
|
||||
info += TextFormatting.GRAY + " " + I18N.localise(fertilizedKey);
|
||||
addTooltipString(I18N.localise("for.binnie.circuit.garden.info", info));
|
||||
}
|
||||
|
||||
private static ICircuitLayout getLayout(boolean manual) {
|
||||
@@ -102,5 +102,6 @@ public class CircuitGarden extends BinnieCircuit {
|
||||
|
||||
@Override
|
||||
public void onTick(int slot, Object tile) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
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.flowerbed, Botany.loam, Botany.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.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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,19 +6,19 @@ import net.minecraft.item.ItemStack;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
enum EnumTubeInsulate {
|
||||
Clay(0xa1aacc, "clay"),
|
||||
Cobble(0x7b7b7b, "cobblestone"),
|
||||
Sand(0xefeab5, "sandstone"),
|
||||
HardenedClay(0x935c43, "hardened_clay"),
|
||||
Stone(0x6d6d6d, "stone"),
|
||||
Sandstone(0xc1b989, "sandstone");
|
||||
CLAY(0xa1aacc, "clay"),
|
||||
COBBLE(0x7b7b7b, "cobblestone"),
|
||||
SAND(0xefeab5, "sandstone"),
|
||||
HARDENED_CLAY(0x935c43, "hardened_clay"),
|
||||
STONE(0x6d6d6d, "stone"),
|
||||
SANDSTONE(0xc1b989, "sandstone");
|
||||
|
||||
public static final EnumTubeInsulate[] VALUES = values();
|
||||
|
||||
|
||||
int color;
|
||||
String name;
|
||||
|
||||
EnumTubeInsulate(final int color, final String name) {
|
||||
EnumTubeInsulate(int color, String name) {
|
||||
this.color = color;
|
||||
this.name = name;
|
||||
}
|
||||
@@ -28,7 +28,7 @@ enum EnumTubeInsulate {
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return this.color;
|
||||
return color;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
@@ -37,27 +37,24 @@ enum EnumTubeInsulate {
|
||||
|
||||
public ItemStack getStack() {
|
||||
switch (this) {
|
||||
case Clay: {
|
||||
case CLAY:
|
||||
return new ItemStack(Blocks.CLAY);
|
||||
}
|
||||
case Cobble: {
|
||||
|
||||
case COBBLE:
|
||||
return new ItemStack(Blocks.COBBLESTONE);
|
||||
}
|
||||
case HardenedClay: {
|
||||
|
||||
case HARDENED_CLAY:
|
||||
return new ItemStack(Blocks.HARDENED_CLAY);
|
||||
}
|
||||
case Sand: {
|
||||
|
||||
case SAND:
|
||||
return new ItemStack(Blocks.SAND);
|
||||
}
|
||||
case Sandstone: {
|
||||
|
||||
case SANDSTONE:
|
||||
return new ItemStack(Blocks.SANDSTONE);
|
||||
}
|
||||
case Stone: {
|
||||
|
||||
case STONE:
|
||||
return new ItemStack(Blocks.STONE);
|
||||
}
|
||||
default: {
|
||||
throw new IllegalStateException("Unknown insulated tube type: " + this);
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("Unknown insulated tube type: " + this);
|
||||
}
|
||||
}
|
||||
@@ -3,17 +3,17 @@ package binnie.botany.flower;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
enum EnumTubeMaterial {
|
||||
Copper(0xe3b78e, "copper"),
|
||||
Tin(0xe1eef4, "tin"),
|
||||
Bronze(0xddc276, "bronze"),
|
||||
Iron(0xd8d8d8, "iron");
|
||||
COPPER(0xe3b78e, "copper"),
|
||||
TIN(0xe1eef4, "tin"),
|
||||
BRONZE(0xddc276, "bronze"),
|
||||
IRON(0xd8d8d8, "iron");
|
||||
|
||||
public static final EnumTubeMaterial[] VALUES = values();
|
||||
|
||||
|
||||
int color;
|
||||
String name;
|
||||
|
||||
EnumTubeMaterial(final int color, final String name) {
|
||||
EnumTubeMaterial(int color, String name) {
|
||||
this.color = color;
|
||||
this.name = name;
|
||||
}
|
||||
@@ -23,9 +23,9 @@ enum EnumTubeMaterial {
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return this.color;
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
public String getDisplayName() {
|
||||
return I18N.localise("botany.tube.material." + name + ".name");
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,13 +54,13 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
|
||||
private EnumFlowerStage type;
|
||||
private String tag;
|
||||
|
||||
public ItemBotany(final String name, EnumFlowerStage type, String tag) {
|
||||
this.setCreativeTab(CreativeTabBotany.instance);
|
||||
this.setUnlocalizedName(name);
|
||||
setRegistryName(name);
|
||||
this.hasSubtypes = true;
|
||||
public ItemBotany(String name, EnumFlowerStage type, String tag) {
|
||||
this.type = type;
|
||||
this.tag = tag;
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
setUnlocalizedName(name);
|
||||
setRegistryName(name);
|
||||
hasSubtypes = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,22 +79,23 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasEffect(final ItemStack itemstack) {
|
||||
public boolean hasEffect(ItemStack itemstack) {
|
||||
if (!itemstack.hasTagCompound()) {
|
||||
return false;
|
||||
}
|
||||
final IIndividual individual = this.getIndividual(itemstack);
|
||||
IIndividual individual = getIndividual(itemstack);
|
||||
return individual != null && individual.hasEffect();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(final ItemStack itemStack, final EntityPlayer player, final List<String> list, final boolean flag) {
|
||||
IFlower individual = (IFlower) this.getIndividual(itemStack);
|
||||
public void addInformation(ItemStack itemStack, EntityPlayer player, List<String> list, boolean flag) {
|
||||
IFlower individual = (IFlower) getIndividual(itemStack);
|
||||
if (individual == null) {
|
||||
list.add(TextFormatting.DARK_RED + I18N.localise("item.botany.flower.destroy"));
|
||||
return;
|
||||
}
|
||||
|
||||
IFlowerGenome genome = individual.getGenome();
|
||||
//Colors
|
||||
String primaryColor = genome.getPrimaryColor().getColorName();
|
||||
@@ -120,7 +121,7 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected IIndividual getIndividual(final ItemStack itemstack) {
|
||||
protected IIndividual getIndividual(ItemStack itemstack) {
|
||||
NBTTagCompound tagCompound = itemstack.getTagCompound();
|
||||
if (tagCompound == null) {
|
||||
return null;
|
||||
@@ -128,8 +129,8 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
|
||||
return new Flower(tagCompound);
|
||||
}
|
||||
|
||||
private IAlleleFlowerSpecies getPrimarySpecies(final ItemStack itemstack) {
|
||||
final IFlower tree = BotanyCore.getFlowerRoot().getMember(itemstack);
|
||||
private IAlleleFlowerSpecies getPrimarySpecies(ItemStack itemstack) {
|
||||
IFlower tree = BotanyCore.getFlowerRoot().getMember(itemstack);
|
||||
if (tree == null) {
|
||||
return (IAlleleFlowerSpecies) BotanyCore.getFlowerRoot().getDefaultTemplate()[EnumFlowerChromosome.SPECIES.ordinal()];
|
||||
}
|
||||
@@ -137,11 +138,11 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack itemstack) {
|
||||
public String getItemStackDisplayName(ItemStack itemstack) {
|
||||
if (!itemstack.hasTagCompound()) {
|
||||
return I18N.localise("item.botany.flower.corrupted.name");
|
||||
}
|
||||
IIndividual individual = this.getIndividual(itemstack);
|
||||
IIndividual individual = getIndividual(itemstack);
|
||||
if (individual != null) {
|
||||
return individual.getDisplayName() + (!tag.isEmpty() ? " " + I18N.localise("item.botany." + tag + ".name") : "");
|
||||
}
|
||||
@@ -149,12 +150,12 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(final Item item, final CreativeTabs tab, final NonNullList<ItemStack> itemList) {
|
||||
this.addCreativeItems(itemList, true);
|
||||
public void getSubItems(Item item, CreativeTabs tab, NonNullList<ItemStack> itemList) {
|
||||
addCreativeItems(itemList, 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;
|
||||
}
|
||||
@@ -166,9 +167,14 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
|
||||
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
|
||||
IFlower flower = BotanyCore.getFlowerRoot().getMember(stack);
|
||||
if (flower == null) {
|
||||
return 16777215;
|
||||
return 0xffffff;
|
||||
}
|
||||
return (tintIndex == 0) ? flower.getGenome().getStemColor().getColor(flower.isWilted()) : ((tintIndex == 1) ? flower.getGenome().getPrimaryColor().getColor(flower.isWilted()) : flower.getGenome().getSecondaryColor().getColor(flower.isWilted()));
|
||||
if (tintIndex == 0) {
|
||||
return flower.getGenome().getStemColor().getColor(flower.isWilted());
|
||||
}
|
||||
return (tintIndex == 1)
|
||||
? flower.getGenome().getPrimaryColor().getColor(flower.isWilted())
|
||||
: flower.getGenome().getSecondaryColor().getColor(flower.isWilted());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -184,12 +190,12 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (type == EnumFlowerStage.POLLEN) {
|
||||
final IFlower flower = Binnie.GENETICS.getFlowerRoot().getMember(stack);
|
||||
final TileEntity target = world.getTileEntity(pos);
|
||||
IFlower flower = Binnie.GENETICS.getFlowerRoot().getMember(stack);
|
||||
TileEntity target = world.getTileEntity(pos);
|
||||
if (!(target instanceof IPollinatable)) {
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
final IPollinatable pollinatable = (IPollinatable) target;
|
||||
IPollinatable pollinatable = (IPollinatable) target;
|
||||
if (!pollinatable.canMateWith(flower)) {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
@@ -198,29 +204,28 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
|
||||
stack.shrink(1);
|
||||
}
|
||||
return EnumActionResult.SUCCESS;
|
||||
} else {
|
||||
IBlockState iblockstate = world.getBlockState(pos);
|
||||
Block block = iblockstate.getBlock();
|
||||
|
||||
if (!block.isReplaceable(world, pos)) {
|
||||
pos = pos.offset(facing);
|
||||
}
|
||||
|
||||
if (stack.getCount() != 0 && player.canPlayerEdit(pos, facing, stack) && world.mayPlace(Botany.flower, pos, false, facing, null)) {
|
||||
int i = this.getMetadata(stack.getMetadata());
|
||||
IBlockState iblockstate1 = Botany.flower.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, i, player, hand);
|
||||
|
||||
if (placeBlockAt(stack, player, world, pos, facing, hitX, hitY, hitZ, iblockstate1)) {
|
||||
SoundType soundtype = world.getBlockState(pos).getBlock().getSoundType(world.getBlockState(pos), world, pos, player);
|
||||
world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
|
||||
stack.shrink(1);
|
||||
}
|
||||
|
||||
return EnumActionResult.SUCCESS;
|
||||
} else {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
IBlockState iblockstate = world.getBlockState(pos);
|
||||
Block block = iblockstate.getBlock();
|
||||
|
||||
if (!block.isReplaceable(world, pos)) {
|
||||
pos = pos.offset(facing);
|
||||
}
|
||||
|
||||
if (stack.getCount() != 0 && player.canPlayerEdit(pos, facing, stack) && world.mayPlace(Botany.flower, pos, false, facing, null)) {
|
||||
int i = getMetadata(stack.getMetadata());
|
||||
IBlockState iblockstate1 = Botany.flower.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, i, player, hand);
|
||||
|
||||
if (placeBlockAt(stack, player, world, pos, facing, hitX, hitY, hitZ, iblockstate1)) {
|
||||
SoundType soundtype = world.getBlockState(pos).getBlock().getSoundType(world.getBlockState(pos), world, pos, player);
|
||||
world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
|
||||
stack.shrink(1);
|
||||
}
|
||||
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) {
|
||||
|
||||
@@ -112,6 +112,10 @@ public class ItemInsulatedTube extends ItemCore implements IColoredItem {
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack itemStack) {
|
||||
int meta = itemStack.getMetadata();
|
||||
return I18N.localise("item.botany.insulated_tube.name", EnumTubeMaterial.get(meta).getDisplayName(), EnumTubeInsulate.get(meta).getDisplayName());
|
||||
return I18N.localise(
|
||||
"item.botany.insulated_tube.name",
|
||||
EnumTubeMaterial.get(meta).getDisplayName(),
|
||||
EnumTubeInsulate.get(meta).getDisplayName()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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,82 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
}
|
||||
|
||||
public boolean isBreeding() {
|
||||
final Block roots = this.getWorld().getBlockState(getPos().down()).getBlock();
|
||||
Block roots = getWorld().getBlockState(getPos().down()).getBlock();
|
||||
return BotanyCore.getGardening().isSoil(roots);
|
||||
}
|
||||
|
||||
public void randomUpdate(final Random rand) {
|
||||
if (this.world.getBlockState(pos).getBlock() != Botany.flower) {
|
||||
this.invalidate();
|
||||
public void randomUpdate(Random rand) {
|
||||
if (world.getBlockState(pos).getBlock() != Botany.flower) {
|
||||
invalidate();
|
||||
return;
|
||||
}
|
||||
if (this.getSection() > 0) {
|
||||
if (getSection() > 0) {
|
||||
return;
|
||||
}
|
||||
if (this.flower == null) {
|
||||
if (flower == null) {
|
||||
return;
|
||||
}
|
||||
if (this.flower.getGenome() == null) {
|
||||
this.invalidate();
|
||||
|
||||
// TODO always false?
|
||||
if (flower.getGenome() == null) {
|
||||
invalidate();
|
||||
return;
|
||||
}
|
||||
if (!this.isBreeding()) {
|
||||
if (!isBreeding()) {
|
||||
return;
|
||||
}
|
||||
float light = this.world.getLight(pos);
|
||||
|
||||
float light = world.getLight(pos);
|
||||
if (light < 6.0f) {
|
||||
for (int dx = -2; dx <= 2; ++dx) {
|
||||
for (int dy = -2; dy <= 2; ++dy) {
|
||||
light -= (this.world.canBlockSeeSky(pos) ? 0.0f : 0.5f);
|
||||
light -= (world.canBlockSeeSky(pos) ? 0.0f : 0.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IGardeningManager gardening = BotanyCore.getGardening();
|
||||
final boolean canTolerate = gardening.canTolerate(this.getFlower(), this.world, pos);
|
||||
final EnumSoilType soil = gardening.getSoilType(this.world, pos.down());
|
||||
if (rand.nextFloat() < this.getFlower().getGenome().getAgeChance()) {
|
||||
if (this.flower.getAge() < 1) {
|
||||
boolean canTolerate = gardening.canTolerate(getFlower(), world, pos);
|
||||
EnumSoilType soil = gardening.getSoilType(world, pos.down());
|
||||
if (rand.nextFloat() < getFlower().getGenome().getAgeChance()) {
|
||||
if (flower.getAge() < 1) {
|
||||
if (canTolerate && light > 6.0f) {
|
||||
this.doFlowerAge();
|
||||
doFlowerAge();
|
||||
}
|
||||
} else {
|
||||
this.doFlowerAge();
|
||||
doFlowerAge();
|
||||
}
|
||||
}
|
||||
if (canTolerate && this.flower.getAge() > 1 && !this.flower.isWilted() && light > 6.0f) {
|
||||
this.flower.setFlowered(true);
|
||||
|
||||
if (canTolerate && flower.getAge() > 1 && !flower.isWilted() && light > 6.0f) {
|
||||
flower.setFlowered(true);
|
||||
}
|
||||
if (!canTolerate && this.flower.isWilted() && rand.nextInt(2 + Math.max(this.flower.getAge(), 2)) == 0) {
|
||||
this.kill();
|
||||
|
||||
if (!canTolerate && flower.isWilted() && rand.nextInt(2 + Math.max(flower.getAge(), 2)) == 0) {
|
||||
kill();
|
||||
return;
|
||||
}
|
||||
if (light < 2.0f && this.flower.isWilted()) {
|
||||
this.kill();
|
||||
|
||||
if (light < 2.0f && flower.isWilted()) {
|
||||
kill();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!canTolerate || light < 1.0f) {
|
||||
this.flower.setWilted(true);
|
||||
flower.setWilted(true);
|
||||
} else {
|
||||
this.flower.setWilted(false);
|
||||
flower.setWilted(false);
|
||||
}
|
||||
|
||||
float CHANCE_DISPERSAL = 0.8f;
|
||||
CHANCE_DISPERSAL += 0.2f * this.flower.getGenome().getFertility();
|
||||
CHANCE_DISPERSAL += 0.2f * flower.getGenome().getFertility();
|
||||
CHANCE_DISPERSAL *= 1.0f + soil.ordinal() * 0.5f;
|
||||
float CHANCE_POLLINATE = 1.0f;
|
||||
CHANCE_POLLINATE += 0.25f * this.flower.getGenome().getFertility();
|
||||
CHANCE_POLLINATE += 0.25f * flower.getGenome().getFertility();
|
||||
CHANCE_POLLINATE *= 1.0f + soil.ordinal() * 0.5f;
|
||||
final float CHANCE_SELFPOLLINATE = 0.2f * CHANCE_POLLINATE;
|
||||
if (this.world.rand.nextFloat() < CHANCE_DISPERSAL && this.flower.hasFlowered() && !this.flower.isWilted()) {
|
||||
final IFlowerGenome mate = this.flower.getMate();
|
||||
float CHANCE_SELFPOLLINATE = 0.2f * CHANCE_POLLINATE;
|
||||
if (world.rand.nextFloat() < CHANCE_DISPERSAL && flower.hasFlowered() && !flower.isWilted()) {
|
||||
IFlowerGenome mate = flower.getMate();
|
||||
if (mate != null) {
|
||||
boolean dispersed = false;
|
||||
for (int a = 0; a < 5 && !dispersed; ++a) {
|
||||
@@ -240,68 +264,70 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
for (dx2 = 0, dz = 0; dx2 == 0 && dz == 0; dx2 = rand.nextInt(3) - 1, dz = rand.nextInt(3) - 1) {
|
||||
}
|
||||
|
||||
final Block b2 = world.getBlockState(pos.add(dx2, -1, dz)).getBlock();
|
||||
Block b2 = world.getBlockState(pos.add(dx2, -1, dz)).getBlock();
|
||||
if (world.isAirBlock(pos.add(dx2, 0, dz)) && BotanyCore.getGardening().isSoil(b2)) {
|
||||
final IFlower offspring = this.flower.getOffspring(world, pos);
|
||||
IFlower offspring = flower.getOffspring(world, pos);
|
||||
if (offspring != null) {
|
||||
BotanyCore.getFlowerRoot().plant(world, pos.add(dx2, 0, dz), offspring, this.getOwner());
|
||||
this.flower.removeMate();
|
||||
BotanyCore.getFlowerRoot().plant(world, pos.add(dx2, 0, dz), offspring, getOwner());
|
||||
flower.removeMate();
|
||||
dispersed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.world.rand.nextFloat() < CHANCE_POLLINATE && this.flower.hasFlowered() && !this.flower.isWilted()) {
|
||||
|
||||
if (world.rand.nextFloat() < CHANCE_POLLINATE && flower.hasFlowered() && !flower.isWilted()) {
|
||||
for (int a2 = 0; a2 < 4; ++a2) {
|
||||
int dx3;
|
||||
int dz2;
|
||||
for (dx3 = 0, dz2 = 0; dx3 == 0 && dz2 == 0; dx3 = rand.nextInt(5) - 2, dz2 = rand.nextInt(5) - 2) {
|
||||
}
|
||||
final TileEntity tile = world.getTileEntity(pos.add(dx3, 0, dz2));
|
||||
if (tile instanceof IPollinatable && ((IPollinatable) tile).canMateWith(this.getFlower())) {
|
||||
((IPollinatable) tile).mateWith(this.getFlower());
|
||||
TileEntity tile = world.getTileEntity(pos.add(dx3, 0, dz2));
|
||||
if (tile instanceof IPollinatable && ((IPollinatable) tile).canMateWith(getFlower())) {
|
||||
((IPollinatable) tile).mateWith(getFlower());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.world.rand.nextFloat() < CHANCE_SELFPOLLINATE && this.flower.hasFlowered() && this.flower.getMate() == null) {
|
||||
this.mateWith(this.getFlower());
|
||||
|
||||
if (world.rand.nextFloat() < CHANCE_SELFPOLLINATE && flower.hasFlowered() && flower.getMate() == null) {
|
||||
mateWith(getFlower());
|
||||
}
|
||||
this.spawnButterflies();
|
||||
this.matureCaterpillar();
|
||||
this.checkIfDead(false);
|
||||
this.updateRender(true);
|
||||
spawnButterflies();
|
||||
matureCaterpillar();
|
||||
checkIfDead(false);
|
||||
updateRender(true);
|
||||
}
|
||||
|
||||
private void doFlowerAge() {
|
||||
this.getFlower().age();
|
||||
if (this.getFlower().getAge() == 1) {
|
||||
getFlower().age();
|
||||
if (getFlower().getAge() == 1) {
|
||||
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
|
||||
flowerRoot.onGrowFromSeed(this.world, pos);
|
||||
if (this.getOwner() != null && this.getFlower() != null) {
|
||||
flowerRoot.getBreedingTracker(world, this.getOwner()).registerBirth(this.getFlower());
|
||||
flowerRoot.onGrowFromSeed(world, pos);
|
||||
if (getOwner() != null && getFlower() != null) {
|
||||
flowerRoot.getBreedingTracker(world, getOwner()).registerBirth(getFlower());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private NBTTagCompound writeRenderInfo(NBTTagCompound tag){
|
||||
if(renderInfo!=null){
|
||||
private NBTTagCompound writeRenderInfo(NBTTagCompound tag) {
|
||||
if (renderInfo != null) {
|
||||
NBTTagCompound nbtRenderInfo = new NBTTagCompound();
|
||||
nbtRenderInfo.setByte("primary",(byte)this.renderInfo.primary.getID());
|
||||
nbtRenderInfo.setByte("secondary",(byte)this.renderInfo.secondary.getID());
|
||||
nbtRenderInfo.setByte("stem",(byte)this.renderInfo.stem.getID());
|
||||
nbtRenderInfo.setByte("type",(byte)this.renderInfo.type.ordinal());
|
||||
nbtRenderInfo.setByte("age",this.renderInfo.age);
|
||||
nbtRenderInfo.setByte("section",this.renderInfo.section);
|
||||
nbtRenderInfo.setBoolean("wilted",this.renderInfo.wilted);
|
||||
nbtRenderInfo.setBoolean("flowered",this.renderInfo.flowered);
|
||||
nbtRenderInfo.setByte("primary", (byte) renderInfo.primary.getID());
|
||||
nbtRenderInfo.setByte("secondary", (byte) renderInfo.secondary.getID());
|
||||
nbtRenderInfo.setByte("stem", (byte) renderInfo.stem.getID());
|
||||
nbtRenderInfo.setByte("type", (byte) renderInfo.type.ordinal());
|
||||
nbtRenderInfo.setByte("age", renderInfo.age);
|
||||
nbtRenderInfo.setByte("section", renderInfo.section);
|
||||
nbtRenderInfo.setBoolean("wilted", renderInfo.wilted);
|
||||
nbtRenderInfo.setBoolean("flowered", renderInfo.flowered);
|
||||
tag.setTag("renderinfo", nbtRenderInfo);
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
private void readRenderInfo(NBTTagCompound tag){
|
||||
if(tag.hasKey("renderinfo")){
|
||||
private void readRenderInfo(NBTTagCompound tag) {
|
||||
if (tag.hasKey("renderinfo")) {
|
||||
NBTTagCompound infotag = tag.getCompoundTag("renderinfo");
|
||||
RenderInfo info = new RenderInfo();
|
||||
info.primary = EnumFlowerColor.values()[infotag.getByte("primary")].getFlowerColorAllele();
|
||||
@@ -319,6 +345,7 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
|
||||
super.onDataPacket(net, pkt);
|
||||
// TODO client only call?
|
||||
readRenderInfo(pkt.getNbtCompound());
|
||||
}
|
||||
|
||||
@@ -330,38 +357,40 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
|
||||
@Override
|
||||
public SPacketUpdateTileEntity getUpdatePacket() {
|
||||
if (this.renderInfo == null && this.getFlower() != null && this.getFlower().getGenome() != null) {
|
||||
this.renderInfo = new RenderInfo(this.getFlower(), this);
|
||||
// TODO getFlower().getGenome() != null always true?
|
||||
if (renderInfo == null && getFlower() != null && getFlower().getGenome() != null) {
|
||||
renderInfo = new RenderInfo(getFlower(), this);
|
||||
}
|
||||
return (this.renderInfo != null) ? new SPacketUpdateTileEntity(pos, 0, getUpdateTag()) : null;
|
||||
return (renderInfo != null) ? new SPacketUpdateTileEntity(pos, 0, getUpdateTag()) : null;
|
||||
}
|
||||
|
||||
public void updateRender(final boolean update) {
|
||||
if (update && this.getFlower() != null && this.getFlower().getGenome() != null) {
|
||||
final RenderInfo newInfo = new RenderInfo(this.getFlower(), this);
|
||||
if (this.renderInfo == null || !newInfo.equals(this.renderInfo)) {
|
||||
this.setRender(newInfo);
|
||||
public void updateRender(boolean update) {
|
||||
if (update && getFlower() != null && getFlower().getGenome() != null) {
|
||||
RenderInfo newInfo = new RenderInfo(getFlower(), this);
|
||||
if (renderInfo == null || !newInfo.equals(renderInfo)) {
|
||||
setRender(newInfo);
|
||||
}
|
||||
}
|
||||
final TileEntity above = this.world.getTileEntity(pos.up());
|
||||
|
||||
TileEntity above = world.getTileEntity(pos.up());
|
||||
if (above instanceof TileEntityFlower) {
|
||||
((TileEntityFlower) above).updateRender(true);
|
||||
}
|
||||
}
|
||||
|
||||
public int getSection() {
|
||||
return this.section;
|
||||
return section;
|
||||
}
|
||||
|
||||
public void setSection(final int i) {
|
||||
this.section = i;
|
||||
if (BinnieCore.getBinnieProxy().isSimulating(this.world)) {
|
||||
this.updateRender(true);
|
||||
public void setSection(int i) {
|
||||
section = i;
|
||||
if (BinnieCore.getBinnieProxy().isSimulating(world)) {
|
||||
updateRender(true);
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getItemStack() {
|
||||
IFlower flower = this.getFlower();
|
||||
IFlower flower = getFlower();
|
||||
if (flower == null) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
@@ -370,57 +399,61 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
|
||||
@Nullable
|
||||
private TileEntityFlower getRoot() {
|
||||
if (this.getSection() == 0) {
|
||||
if (getSection() == 0) {
|
||||
return null;
|
||||
}
|
||||
final TileEntity tile = this.world.getTileEntity(pos.down(getSection()));
|
||||
TileEntity tile = world.getTileEntity(pos.down(getSection()));
|
||||
return (tile instanceof TileEntityFlower) ? ((TileEntityFlower) tile) : null;
|
||||
}
|
||||
|
||||
public void onShear() {
|
||||
if (this.getRoot() != null) {
|
||||
this.getRoot().onShear();
|
||||
if (getRoot() != null) {
|
||||
getRoot().onShear();
|
||||
}
|
||||
if (this.getFlower() != null && this.getFlower().getAge() > 1) {
|
||||
final Random rand = new Random();
|
||||
final IFlower cutting = (IFlower) this.getFlower().copy();
|
||||
cutting.setAge(0);
|
||||
final ItemStack cuttingStack = BotanyCore.getFlowerRoot().getMemberStack(cutting, EnumFlowerStage.SEED);
|
||||
final float f = 0.7f;
|
||||
final double d = rand.nextFloat() * f + (1.0f - f) * 0.5;
|
||||
final double d2 = rand.nextFloat() * f + (1.0f - f) * 0.5;
|
||||
final double d3 = rand.nextFloat() * f + (1.0f - f) * 0.5;
|
||||
final EntityItem entityitem = new EntityItem(this.world, pos.getX() + d, pos.getY() + d2, pos.getZ() + d3, cuttingStack);
|
||||
entityitem.setPickupDelay(10);
|
||||
this.world.spawnEntity(entityitem);
|
||||
for (int maxAge = this.getFlower().getMaxAge(), i = 0; i < maxAge; ++i) {
|
||||
if (rand.nextBoolean()) {
|
||||
this.getFlower().age();
|
||||
if (this.checkIfDead(true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (getFlower() == null || getFlower().getAge() <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
Random rand = new Random();
|
||||
IFlower cutting = (IFlower) getFlower().copy();
|
||||
cutting.setAge(0);
|
||||
ItemStack cuttingStack = BotanyCore.getFlowerRoot().getMemberStack(cutting, EnumFlowerStage.SEED);
|
||||
float f = 0.7f;
|
||||
double d = rand.nextFloat() * f + (1.0f - f) * 0.5;
|
||||
double d2 = rand.nextFloat() * f + (1.0f - f) * 0.5;
|
||||
double d3 = rand.nextFloat() * f + (1.0f - f) * 0.5;
|
||||
EntityItem entityitem = new EntityItem(world, pos.getX() + d, pos.getY() + d2, pos.getZ() + d3, cuttingStack);
|
||||
entityitem.setPickupDelay(10);
|
||||
world.spawnEntity(entityitem);
|
||||
for (int maxAge = getFlower().getMaxAge(), i = 0; i < maxAge; ++i) {
|
||||
if (rand.nextBoolean()) {
|
||||
getFlower().age();
|
||||
if (checkIfDead(true)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkIfDead(final boolean wasCut) {
|
||||
if (this.getSection() != 0) {
|
||||
return this.getRoot().checkIfDead(wasCut);
|
||||
public boolean checkIfDead(boolean wasCut) {
|
||||
if (getSection() != 0) {
|
||||
return getRoot().checkIfDead(wasCut);
|
||||
}
|
||||
final EnumSoilType soil = BotanyCore.getGardening().getSoilType(this.world, pos);
|
||||
final int maxAge = (int) (this.flower.getMaxAge() * (1.0f + soil.ordinal() * 0.25f));
|
||||
if (this.flower.getAge() > maxAge) {
|
||||
if (!wasCut && this.flower.getMate() != null) {
|
||||
this.world.setBlockToAir(pos);
|
||||
final IFlower offspring = this.flower.getOffspring(this.world, pos.down());
|
||||
final TileEntity above = this.world.getTileEntity(pos.up());
|
||||
|
||||
EnumSoilType soil = BotanyCore.getGardening().getSoilType(world, pos);
|
||||
int maxAge = (int) (flower.getMaxAge() * (1.0f + soil.ordinal() * 0.25f));
|
||||
if (flower.getAge() > maxAge) {
|
||||
if (!wasCut && flower.getMate() != null) {
|
||||
world.setBlockToAir(pos);
|
||||
IFlower offspring = flower.getOffspring(world, pos.down());
|
||||
TileEntity above = world.getTileEntity(pos.up());
|
||||
if (above instanceof TileEntityFlower) {
|
||||
this.world.setBlockToAir(pos.up());
|
||||
world.setBlockToAir(pos.up());
|
||||
}
|
||||
BotanyCore.getFlowerRoot().plant(this.world, pos, offspring, this.getOwner());
|
||||
BotanyCore.getFlowerRoot().plant(world, pos, offspring, getOwner());
|
||||
} else {
|
||||
this.kill();
|
||||
kill();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -428,42 +461,44 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
}
|
||||
|
||||
public void kill() {
|
||||
if (this.flower.getAge() > 0) {
|
||||
this.world.setBlockState(pos, Botany.plant.getStateFromMeta(BlockPlant.Type.DeadFlower.ordinal()), 2);
|
||||
if (flower.getAge() > 0) {
|
||||
world.setBlockState(pos, Botany.plant.getStateFromMeta(PlantType.DEAD_FLOWER.ordinal()), 2);
|
||||
} else {
|
||||
this.world.setBlockToAir(pos);
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
for (int i = 1; this.world.getTileEntity(pos.up(i)) instanceof TileEntityFlower; ++i) {
|
||||
this.world.setBlockToAir(pos.up(i));
|
||||
|
||||
for (int i = 1; world.getTileEntity(pos.up(i)) instanceof TileEntityFlower; ++i) {
|
||||
world.setBlockToAir(pos.up(i));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onBonemeal() {
|
||||
if (this.getFlower() == null) {
|
||||
if (getFlower() == null) {
|
||||
return false;
|
||||
}
|
||||
if (!this.isBreeding()) {
|
||||
if (!isBreeding()) {
|
||||
return false;
|
||||
}
|
||||
if (this.getFlower().isWilted()) {
|
||||
if (getFlower().isWilted()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//this.doFlowerAge();
|
||||
if (this.getFlower().getAge() > 1 && !this.getFlower().hasFlowered()) {
|
||||
this.getFlower().setFlowered(true);
|
||||
if (getFlower().getAge() > 1 && !getFlower().hasFlowered()) {
|
||||
getFlower().setFlowered(true);
|
||||
}
|
||||
this.checkIfDead(false);
|
||||
this.updateRender(true);
|
||||
checkIfDead(false);
|
||||
updateRender(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GameProfile getOwner() {
|
||||
return this.owner;
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(final GameProfile ownerName) {
|
||||
this.owner = ownerName;
|
||||
public void setOwner(GameProfile ownerName) {
|
||||
owner = ownerName;
|
||||
}
|
||||
|
||||
public void spawnButterflies() {
|
||||
@@ -510,57 +545,57 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
}*/
|
||||
}
|
||||
|
||||
private void attemptButterflySpawn(final World world, final IButterfly butterfly, final double x, final double y, final double z) {
|
||||
private void attemptButterflySpawn(World world, IButterfly butterfly, double x, double y, double z) {
|
||||
if (BinnieCore.isLepidopteryActive()) {
|
||||
Binnie.GENETICS.getButterflyRoot().spawnButterflyInWorld(world, butterfly.copy(), x, y + 0.10000000149011612, z);
|
||||
}
|
||||
}
|
||||
|
||||
public GameProfile getOwnerName() {
|
||||
return this.getOwner();
|
||||
return getOwner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumTemperature getTemperature() {
|
||||
return EnumTemperature.getFromValue(this.world.getBiome(getPos()).getTemperature());
|
||||
return EnumTemperature.getFromValue(world.getBiome(getPos()).getTemperature());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumHumidity getHumidity() {
|
||||
return EnumHumidity.getFromValue(this.world.getBiome(getPos()).getRainfall());
|
||||
return EnumHumidity.getFromValue(world.getBiome(getPos()).getRainfall());
|
||||
}
|
||||
|
||||
public void setErrorState(final int state) {
|
||||
public void setErrorState(int state) {
|
||||
}
|
||||
|
||||
public int getErrorOrdinal() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean addProduct(final ItemStack product, final boolean all) {
|
||||
public boolean addProduct(ItemStack product, boolean all) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IButterfly getCaterpillar() {
|
||||
return this.caterpillar;
|
||||
return caterpillar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCaterpillar(@Nullable final IButterfly butterfly) {
|
||||
this.caterpillar = butterfly;
|
||||
this.matureTime = 0;
|
||||
public void setCaterpillar(@Nullable IButterfly butterfly) {
|
||||
caterpillar = butterfly;
|
||||
matureTime = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndividual getNanny() {
|
||||
return this.getFlower();
|
||||
return getFlower();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canNurse(final IButterfly butterfly) {
|
||||
return this.getFlower() != null && !this.getFlower().isWilted() && this.getFlower().getAge() > 1;
|
||||
public boolean canNurse(IButterfly butterfly) {
|
||||
return getFlower() != null && !getFlower().isWilted() && getFlower().getAge() > 1;
|
||||
}
|
||||
|
||||
private void matureCaterpillar() {
|
||||
@@ -589,9 +624,9 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
}*/
|
||||
}
|
||||
|
||||
public void setRender(final RenderInfo render) {
|
||||
this.renderInfo = render;
|
||||
this.section = this.renderInfo.section;
|
||||
public void setRender(RenderInfo render) {
|
||||
renderInfo = render;
|
||||
section = renderInfo.section;
|
||||
if (!world.isRemote) {
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
world.notifyBlockUpdate(pos, blockState, blockState, 0);
|
||||
@@ -601,40 +636,48 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return (this.renderInfo == null) ? 1 : this.renderInfo.age;
|
||||
return (renderInfo == null) ? 1 : renderInfo.age;
|
||||
}
|
||||
|
||||
public int getRenderSection() {
|
||||
return (this.renderInfo == null) ? 1 : this.renderInfo.section;
|
||||
return (renderInfo == null) ? 1 : renderInfo.section;
|
||||
}
|
||||
|
||||
public boolean isWilted() {
|
||||
return this.renderInfo != null && this.renderInfo.wilted;
|
||||
return renderInfo != null && renderInfo.wilted;
|
||||
}
|
||||
|
||||
public boolean isFlowered() {
|
||||
return this.renderInfo == null || this.renderInfo.flowered;
|
||||
return renderInfo == null || renderInfo.flowered;
|
||||
}
|
||||
|
||||
public int getPrimaryColour() {
|
||||
return (this.renderInfo == null) ? EnumFlowerColor.Red.getFlowerColorAllele().getColor(false) : this.renderInfo.primary.getColor(this.isWilted());
|
||||
return (renderInfo == null)
|
||||
? EnumFlowerColor.Red.getFlowerColorAllele().getColor(false)
|
||||
: renderInfo.primary.getColor(isWilted());
|
||||
}
|
||||
|
||||
public int getSecondaryColour() {
|
||||
return (this.renderInfo == null) ? EnumFlowerColor.Red.getFlowerColorAllele().getColor(false) : this.renderInfo.secondary.getColor(this.isWilted());
|
||||
return (renderInfo == null)
|
||||
? EnumFlowerColor.Red.getFlowerColorAllele().getColor(false)
|
||||
: renderInfo.secondary.getColor(isWilted());
|
||||
}
|
||||
|
||||
public int getStemColour() {
|
||||
return (this.renderInfo == null) ? EnumFlowerColor.Green.getFlowerColorAllele().getColor(false) : this.renderInfo.stem.getColor(this.isWilted());
|
||||
return (renderInfo == null)
|
||||
? EnumFlowerColor.Green.getFlowerColorAllele().getColor(false)
|
||||
: renderInfo.stem.getColor(isWilted());
|
||||
}
|
||||
|
||||
public IFlowerType getType() {
|
||||
return (this.renderInfo == null) ? EnumFlowerType.Poppy : this.renderInfo.type;
|
||||
return (renderInfo == null)
|
||||
? EnumFlowerType.Poppy
|
||||
: renderInfo.type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome getBiome() {
|
||||
return this.getWorld().getBiome(getPos());
|
||||
return getWorld().getBiome(getPos());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -642,10 +685,10 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setErrorState(final IErrorState state) {
|
||||
public void setErrorState(IErrorState state) {
|
||||
}
|
||||
|
||||
public boolean setErrorCondition(final boolean condition, final IErrorState errorState) {
|
||||
public boolean setErrorCondition(boolean condition, IErrorState errorState) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -669,9 +712,9 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
}
|
||||
|
||||
public static class RenderInfo {
|
||||
public IFlowerColour primary;
|
||||
public IFlowerColour secondary;
|
||||
public IFlowerColour stem;
|
||||
public IFlowerColor primary;
|
||||
public IFlowerColor secondary;
|
||||
public IFlowerColor stem;
|
||||
public IFlowerType type;
|
||||
public byte age;
|
||||
public boolean wilted;
|
||||
@@ -681,22 +724,22 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
public RenderInfo() {
|
||||
}
|
||||
|
||||
public RenderInfo(final IFlower flower, final TileEntityFlower tile) {
|
||||
this.section = (byte) tile.getSection();
|
||||
this.primary = flower.getGenome().getPrimaryColor();
|
||||
this.secondary = flower.getGenome().getSecondaryColor();
|
||||
this.stem = flower.getGenome().getStemColor();
|
||||
this.age = (byte) flower.getAge();
|
||||
this.wilted = flower.isWilted();
|
||||
this.flowered = flower.hasFlowered();
|
||||
this.type = flower.getGenome().getType();
|
||||
public RenderInfo(IFlower flower, TileEntityFlower tile) {
|
||||
section = (byte) tile.getSection();
|
||||
primary = flower.getGenome().getPrimaryColor();
|
||||
secondary = flower.getGenome().getSecondaryColor();
|
||||
stem = flower.getGenome().getStemColor();
|
||||
age = (byte) flower.getAge();
|
||||
wilted = flower.isWilted();
|
||||
flowered = flower.hasFlowered();
|
||||
type = flower.getGenome().getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof RenderInfo) {
|
||||
final RenderInfo o = (RenderInfo) obj;
|
||||
return o.age == this.age && o.wilted == this.wilted && o.flowered == this.flowered && o.primary == this.primary && o.secondary == this.secondary && o.stem == this.stem && o.type == this.type;
|
||||
RenderInfo o = (RenderInfo) obj;
|
||||
return o.age == age && o.wilted == wilted && o.flowered == flowered && o.primary == primary && o.secondary == secondary && o.stem == stem && o.type == type;
|
||||
}
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -92,49 +91,54 @@ public class BlockPlant extends BlockBush implements IItemModelRegister {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(final Item p_149666_1_, final CreativeTabs p_149666_2_, final NonNullList<ItemStack> subBlocks) {
|
||||
for (final Type type : Type.values()) {
|
||||
public void getSubBlocks(Item p_149666_1_, 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 +151,4 @@ public class BlockPlant extends BlockBush implements IItemModelRegister {
|
||||
public EnumOffsetType getOffsetType() {
|
||||
return EnumOffsetType.XZ;
|
||||
}
|
||||
|
||||
public enum Type implements IStringSerializable {
|
||||
Weeds("weeds", true),
|
||||
WeedsLong("weeds_long", true),
|
||||
WeedsVeryLong("weeds_very_long", true),
|
||||
DeadFlower("dead_flower"),
|
||||
DecayingFlower("decaying_flower");
|
||||
|
||||
String name;
|
||||
boolean isWeed;
|
||||
|
||||
Type(String name) {
|
||||
this(name, false);
|
||||
}
|
||||
|
||||
Type(String name, boolean isWeed) {
|
||||
this.name = name;
|
||||
this.isWeed = isWeed;
|
||||
}
|
||||
|
||||
public static Type get(int id) {
|
||||
return values()[id % values().length];
|
||||
}
|
||||
|
||||
public ItemStack get() {
|
||||
return new ItemStack(Botany.plant, 1, this.ordinal());
|
||||
}
|
||||
|
||||
public boolean isWeed(){
|
||||
return isWeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,18 +47,18 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister {
|
||||
|
||||
public BlockSoil(EnumSoilType type, String blockName, boolean weedKilled) {
|
||||
super(Material.GROUND);
|
||||
this.type = type;
|
||||
this.weedKilled = weedKilled;
|
||||
setUnlocalizedName("botany.soil." + type.getName());
|
||||
this.setCreativeTab(CreativeTabBotany.instance);
|
||||
this.setRegistryName(blockName);
|
||||
this.setTickRandomly(true);
|
||||
this.setLightOpacity(255);
|
||||
this.setHardness(0.5f);
|
||||
this.setSoundType(SoundType.GROUND);
|
||||
this.type = type;
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
setRegistryName(blockName);
|
||||
setTickRandomly(true);
|
||||
setLightOpacity(255);
|
||||
setHardness(0.5f);
|
||||
setSoundType(SoundType.GROUND);
|
||||
}
|
||||
|
||||
public static int getMeta(final EnumAcidity acid, final EnumMoisture moisture) {
|
||||
public static int getMeta(EnumAcidity acid, EnumMoisture moisture) {
|
||||
return acid.ordinal() * 3 + moisture.ordinal();
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister {
|
||||
switch (side) {
|
||||
case UP:
|
||||
return true;
|
||||
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
case WEST:
|
||||
@@ -95,9 +96,8 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister {
|
||||
IBlockState iblockstate = blockAccess.getBlockState(pos.offset(side));
|
||||
Block block = iblockstate.getBlock();
|
||||
return !iblockstate.isOpaqueCube() && block != Blocks.FARMLAND && block != Blocks.GRASS_PATH && block != this;
|
||||
default:
|
||||
return super.shouldSideBeRendered(blockState, blockAccess, pos, side);
|
||||
}
|
||||
return super.shouldSideBeRendered(blockState, blockAccess, pos, side);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,7 +136,7 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(final Item itemIn, final CreativeTabs tab, final NonNullList<ItemStack> list) {
|
||||
public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) {
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
list.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
@@ -151,16 +151,19 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister {
|
||||
if (acidity != EnumAcidity.NEUTRAL) {
|
||||
modelName += acidity.getName();
|
||||
}
|
||||
|
||||
if (moisture != EnumMoisture.NORMAL) {
|
||||
if (!modelName.isEmpty()) {
|
||||
modelName += "_";
|
||||
}
|
||||
modelName += moisture.getName();
|
||||
}
|
||||
|
||||
if (modelName.isEmpty()) {
|
||||
modelName = "normal";
|
||||
}
|
||||
final String identifier;
|
||||
|
||||
String identifier;
|
||||
if (weedKilled) {
|
||||
identifier = type.getName() + "_no_weed/" + modelName;
|
||||
} else {
|
||||
@@ -183,13 +186,13 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister {
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
final EnumMoisture moisture = EnumMoisture.values()[meta % 3];
|
||||
final EnumAcidity acidity = EnumAcidity.values()[meta / 3];
|
||||
EnumMoisture moisture = EnumMoisture.values()[meta % 3];
|
||||
EnumAcidity acidity = EnumAcidity.values()[meta / 3];
|
||||
return getDefaultState().withProperty(MOISTURE, moisture).withProperty(ACIDITY, acidity);
|
||||
}
|
||||
|
||||
public EnumSoilType getType() {
|
||||
return this.type;
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -203,23 +206,24 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister {
|
||||
EnumMoisture desiredMoisture = BotanyCore.getGardening().getNaturalMoisture(world, pos);
|
||||
if (desiredMoisture.ordinal() > moisture.ordinal()) {
|
||||
moisture = ((moisture == EnumMoisture.DRY) ? EnumMoisture.NORMAL : EnumMoisture.DAMP);
|
||||
}
|
||||
if (desiredMoisture.ordinal() < moisture.ordinal()) {
|
||||
} else if (desiredMoisture.ordinal() < moisture.ordinal()) {
|
||||
moisture = ((moisture == EnumMoisture.DAMP) ? EnumMoisture.NORMAL : EnumMoisture.DRY);
|
||||
}
|
||||
|
||||
IBlockState blockState = state.withProperty(MOISTURE, moisture);
|
||||
if (state != blockState) {
|
||||
world.setBlockState(pos, blockState, 2);
|
||||
}
|
||||
if(!weedKilled){
|
||||
if(rand.nextInt(5 - getType(world, pos).ordinal()) != 0){
|
||||
|
||||
if (!weedKilled) {
|
||||
if (rand.nextInt(5 - getType(world, pos).ordinal()) != 0) {
|
||||
return;
|
||||
}
|
||||
pos = pos.up();
|
||||
if(!world.isAirBlock(pos)){
|
||||
if (!world.isAirBlock(pos)) {
|
||||
return;
|
||||
}
|
||||
world.setBlockState(pos, Botany.plant.getStateFromMeta(BlockPlant.Type.Weeds.ordinal()), 2);
|
||||
world.setBlockState(pos, Botany.plant.getStateFromMeta(PlantType.WEEDS.ordinal()), 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,48 +237,48 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAcidity getPH(final World world, final BlockPos pos) {
|
||||
public EnumAcidity getPH(World world, BlockPos pos) {
|
||||
return world.getBlockState(pos).getValue(ACIDITY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumMoisture getMoisture(final World world, final BlockPos pos) {
|
||||
public EnumMoisture getMoisture(World world, BlockPos pos) {
|
||||
return world.getBlockState(pos).getValue(MOISTURE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSoilType getType(final World world, final BlockPos pos) {
|
||||
return this.type;
|
||||
public EnumSoilType getType(World world, BlockPos pos) {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fertilise(final World world, final BlockPos pos, final EnumSoilType maxLevel) {
|
||||
final EnumSoilType type = this.getType(world, pos);
|
||||
public boolean fertilise(World world, BlockPos pos, EnumSoilType maxLevel) {
|
||||
EnumSoilType type = getType(world, pos);
|
||||
if (type.ordinal() >= maxLevel.ordinal()) {
|
||||
return false;
|
||||
}
|
||||
final IBlockState old = world.getBlockState(pos);
|
||||
return world.setBlockState(pos, BotanyCore.getGardening().getSoilBlock(maxLevel, this.weedKilled).getDefaultState().withProperty(ACIDITY, old.getValue(ACIDITY)).withProperty(MOISTURE, old.getValue(MOISTURE)), 2);
|
||||
IBlockState old = world.getBlockState(pos);
|
||||
return world.setBlockState(pos, BotanyCore.getGardening().getSoilBlock(maxLevel, weedKilled).getDefaultState().withProperty(ACIDITY, old.getValue(ACIDITY)).withProperty(MOISTURE, old.getValue(MOISTURE)), 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean degrade(final World world, final BlockPos pos, final EnumSoilType minLevel) {
|
||||
final EnumSoilType type = this.getType(world, pos);
|
||||
public boolean degrade(World world, BlockPos pos, EnumSoilType minLevel) {
|
||||
EnumSoilType type = getType(world, pos);
|
||||
if (type.ordinal() <= minLevel.ordinal()) {
|
||||
return false;
|
||||
}
|
||||
final IBlockState old = world.getBlockState(pos);
|
||||
return world.setBlockState(pos, BotanyCore.getGardening().getSoilBlock(minLevel, this.weedKilled).getDefaultState().withProperty(ACIDITY, old.getValue(ACIDITY)).withProperty(MOISTURE, old.getValue(MOISTURE)), 2);
|
||||
IBlockState old = world.getBlockState(pos);
|
||||
return world.setBlockState(pos, BotanyCore.getGardening().getSoilBlock(minLevel, weedKilled).getDefaultState().withProperty(ACIDITY, old.getValue(ACIDITY)).withProperty(MOISTURE, old.getValue(MOISTURE)), 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setPH(final World world, final BlockPos pos, final EnumAcidity pH) {
|
||||
public boolean setPH(World world, BlockPos pos, EnumAcidity pH) {
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
return world.setBlockState(pos, blockState.withProperty(ACIDITY, pH));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setMoisture(final World world, final BlockPos pos, final EnumMoisture moisture) {
|
||||
public boolean setMoisture(World world, BlockPos pos, EnumMoisture moisture) {
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
return world.setBlockState(pos, blockState.withProperty(MOISTURE, moisture));
|
||||
}
|
||||
@@ -293,15 +297,16 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister {
|
||||
if (plant.getBlock() == Botany.flower) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (plant.getBlock() == Botany.plant) {
|
||||
return !this.weedKilled || !BlockPlant.isWeed(world, pos);
|
||||
return !weedKilled || !BlockPlant.isWeed(world, pos);
|
||||
}
|
||||
return world instanceof World && Blocks.DIRT.canSustainPlant(state, world, pos, direction, plantable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean resistsWeeds(final World world, final BlockPos pos) {
|
||||
return this.weedKilled;
|
||||
public boolean resistsWeeds(World world, BlockPos pos) {
|
||||
return weedKilled;
|
||||
}
|
||||
|
||||
public boolean isWeedKilled() {
|
||||
|
||||
@@ -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.flowerbedNoWeed : Botany.flowerbed;
|
||||
|
||||
case LOAM:
|
||||
return weedKill ? Botany.loamNoWeed : Botany.loam;
|
||||
}
|
||||
return weedKill ? Botany.soilNoWeed : Botany.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);
|
||||
|
||||
@@ -19,35 +19,37 @@ public class ItemSoil extends ItemBlock {
|
||||
|
||||
public ItemSoil(BlockSoil block) {
|
||||
super(block);
|
||||
this.type = block.getType();
|
||||
this.noWeed = block.isWeedKilled();
|
||||
this.hasSubtypes = true;
|
||||
type = block.getType();
|
||||
noWeed = block.isWeedKilled();
|
||||
hasSubtypes = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(final ItemStack stack, final EntityPlayer playerIn, final List<String> tooltip, final boolean advanced) {
|
||||
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
|
||||
String info = "";
|
||||
info += BlockSoil.getMoisture(stack, true, true);
|
||||
if (info.length() > 0) {
|
||||
info += ", ";
|
||||
}
|
||||
|
||||
info += BlockSoil.getPH(stack, true, true);
|
||||
if (info.length() > 0) {
|
||||
tooltip.add(info);
|
||||
}
|
||||
if (this.noWeed) {
|
||||
|
||||
if (noWeed) {
|
||||
tooltip.add(TextFormatting.GREEN + I18N.localise("botany.soil.weedkiller"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
return this.getUnlocalizedNameInefficiently(stack).trim();
|
||||
return getUnlocalizedNameInefficiently(stack).trim();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(final int damage) {
|
||||
public int getMetadata(int damage) {
|
||||
return damage;
|
||||
}
|
||||
}
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
@@ -42,13 +42,13 @@ public class ItemTrowel extends Item implements IItemModelRegister {
|
||||
protected final String modelName;
|
||||
|
||||
public ItemTrowel(ToolMaterial toolMaterial, String materialName) {
|
||||
this.theToolMaterial = toolMaterial;
|
||||
this.setMaxStackSize(1);
|
||||
this.setMaxDamage(toolMaterial.getMaxUses());
|
||||
this.setCreativeTab(CreativeTabBotany.instance);
|
||||
this.modelName = "trowel_" + materialName;
|
||||
this.setUnlocalizedName("botany." + modelName);
|
||||
this.setRegistryName(modelName);
|
||||
theToolMaterial = toolMaterial;
|
||||
setMaxStackSize(1);
|
||||
setMaxDamage(toolMaterial.getMaxUses());
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
modelName = "trowel_" + materialName;
|
||||
setUnlocalizedName("botany." + modelName);
|
||||
setRegistryName(modelName);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -64,14 +64,17 @@ public class ItemTrowel extends Item implements IItemModelRegister {
|
||||
if (!player.canPlayerEdit(pos, facing, stack)) {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
Block block = worldIn.getBlockState(pos).getBlock();
|
||||
if (facing == EnumFacing.DOWN || (!worldIn.isAirBlock(pos.up()) && worldIn.getBlockState(pos.up()).getBlock() != Botany.flower) || (block != Blocks.GRASS && block != Blocks.DIRT && block != Blocks.GRASS_PATH)) {
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
|
||||
worldIn.playSound(player, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
if (worldIn.isRemote) {
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
IGardeningManager gardening = BotanyCore.getGardening();
|
||||
EnumMoisture moisture = gardening.getNaturalMoisture(worldIn, pos);
|
||||
EnumAcidity acidity = gardening.getNaturalPH(worldIn, pos);
|
||||
@@ -99,7 +102,7 @@ public class ItemTrowel extends Item implements IItemModelRegister {
|
||||
}
|
||||
|
||||
public String getToolMaterialName() {
|
||||
return this.theToolMaterial.toString();
|
||||
return theToolMaterial.toString();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -53,54 +53,58 @@ public class ModuleGardening implements IInitializable {
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
// TODO migrate static into BotanyItems
|
||||
Botany.plant = new BlockPlant();
|
||||
Botany.proxy.registerBlock(Botany.plant, new ItemWeed(Botany.plant));
|
||||
Botany.soil = new BlockSoil(EnumSoilType.SOIL, "soil", false);
|
||||
Botany.proxy.registerBlock(Botany.soil, new ItemSoil(Botany.soil));
|
||||
Botany.loam = new BlockSoil(EnumSoilType.LOAM, "loam", false);
|
||||
Botany.proxy.registerBlock(Botany.loam, new ItemSoil(Botany.loam));
|
||||
Botany.flowerbed = new BlockSoil(EnumSoilType.FLOWERBED, "flowerbed", false);
|
||||
Botany.proxy.registerBlock(Botany.flowerbed, new ItemSoil(Botany.flowerbed));
|
||||
Botany.soilNoWeed = new BlockSoil(EnumSoilType.SOIL, "soil_no_weed", true);
|
||||
Botany.proxy.registerBlock(Botany.soilNoWeed, new ItemSoil(Botany.soilNoWeed));
|
||||
Botany.loamNoWeed = new BlockSoil(EnumSoilType.LOAM, "loam_no_weed", true);
|
||||
Botany.proxy.registerBlock(Botany.loamNoWeed, new ItemSoil(Botany.loamNoWeed));
|
||||
Botany.flowerbedNoWeed = new BlockSoil(EnumSoilType.FLOWERBED, "flowerbed_no_weed", true);
|
||||
Botany.proxy.registerBlock(Botany.flowerbedNoWeed, new ItemSoil(Botany.flowerbedNoWeed));
|
||||
Botany.soilMeter = new ItemSoilMeter();
|
||||
Botany.proxy.registerItem(Botany.soilMeter);
|
||||
Botany.insulatedTube = new ItemInsulatedTube();
|
||||
Botany.proxy.registerItem(Botany.insulatedTube);
|
||||
Botany.trowelWood = new ItemTrowel(Item.ToolMaterial.WOOD, "wood");
|
||||
Botany.proxy.registerItem(Botany.trowelWood);
|
||||
Botany.trowelStone = new ItemTrowel(Item.ToolMaterial.STONE, "stone");
|
||||
Botany.proxy.registerItem(Botany.trowelStone);
|
||||
Botany.trowelIron = new ItemTrowel(Item.ToolMaterial.IRON, "iron");
|
||||
Botany.proxy.registerItem(Botany.trowelIron);
|
||||
Botany.trowelDiamond = new ItemTrowel(Item.ToolMaterial.DIAMOND, "diamond");
|
||||
Botany.proxy.registerItem(Botany.trowelDiamond);
|
||||
Botany.trowelGold = new ItemTrowel(Item.ToolMaterial.GOLD, "gold");
|
||||
Botany.proxy.registerItem(Botany.trowelGold);
|
||||
Botany.misc = new ItemMisc(CreativeTabBotany.instance, BotanyItems.values());
|
||||
Botany.proxy.registerItem(Botany.misc);
|
||||
Botany.pigment = new ItemPigment();
|
||||
Botany.proxy.registerItem(Botany.pigment);
|
||||
Botany.clay = new ItemClay();
|
||||
Botany.proxy.registerItem(Botany.clay);
|
||||
Botany.ceramic = new BlockCeramic();
|
||||
Botany.stained = new BlockStainedGlass();
|
||||
Botany.ceramicTile = new BlockCeramicPatterned();
|
||||
Botany.ceramicBrick = new BlockCeramicBrick();
|
||||
|
||||
Botany.proxy.registerBlock(Botany.plant, new ItemWeed(Botany.plant));
|
||||
Botany.proxy.registerBlock(Botany.soil, new ItemSoil(Botany.soil));
|
||||
Botany.proxy.registerBlock(Botany.loam, new ItemSoil(Botany.loam));
|
||||
Botany.proxy.registerBlock(Botany.flowerbed, new ItemSoil(Botany.flowerbed));
|
||||
Botany.proxy.registerBlock(Botany.soilNoWeed, new ItemSoil(Botany.soilNoWeed));
|
||||
Botany.proxy.registerBlock(Botany.loamNoWeed, new ItemSoil(Botany.loamNoWeed));
|
||||
Botany.proxy.registerBlock(Botany.flowerbedNoWeed, new ItemSoil(Botany.flowerbedNoWeed));
|
||||
Botany.proxy.registerItem(Botany.soilMeter);
|
||||
Botany.proxy.registerItem(Botany.insulatedTube);
|
||||
Botany.proxy.registerItem(Botany.trowelWood);
|
||||
Botany.proxy.registerItem(Botany.trowelStone);
|
||||
Botany.proxy.registerItem(Botany.trowelIron);
|
||||
Botany.proxy.registerItem(Botany.trowelDiamond);
|
||||
Botany.proxy.registerItem(Botany.trowelGold);
|
||||
Botany.proxy.registerItem(Botany.misc);
|
||||
Botany.proxy.registerItem(Botany.pigment);
|
||||
Botany.proxy.registerItem(Botany.clay);
|
||||
Botany.proxy.registerBlock(Botany.ceramic, new ItemCeramic(Botany.ceramic));
|
||||
Botany.proxy.registerBlock(Botany.stained, new ItemStainedGlass(Botany.stained));
|
||||
Botany.proxy.registerBlock(Botany.ceramicTile, new ItemDesign(Botany.ceramicTile));
|
||||
Botany.proxy.registerBlock(Botany.ceramicBrick, new ItemCeramicBrick(Botany.ceramicBrick));
|
||||
|
||||
BinnieCore.getBinnieProxy().registerTileEntity(TileCeramic.class, "botany.tile.ceramic");
|
||||
//BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.ceramic), new ItemMetadataRenderer());
|
||||
Botany.stained = new BlockStainedGlass();
|
||||
Botany.proxy.registerBlock(Botany.stained, new ItemStainedGlass(Botany.stained));
|
||||
//BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.stained), new ItemMetadataRenderer());
|
||||
Botany.ceramicTile = new BlockCeramicPatterned();
|
||||
Botany.proxy.registerBlock(Botany.ceramicTile, new ItemDesign(Botany.ceramicTile));
|
||||
Botany.ceramicBrick = new BlockCeramicBrick();
|
||||
Botany.proxy.registerBlock(Botany.ceramicBrick, new ItemCeramicBrick(Botany.ceramicBrick));
|
||||
BinnieCore.getBinnieProxy().registerTileEntity(TileCeramicBrick.class, "botany.tile.ceramicBrick");
|
||||
//BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.ceramicTile), new MultipassItemRenderer());
|
||||
//BinnieCore.proxy.registerCustomItemRenderer(Item.getItemFromBlock(Botany.ceramicBrick), new MultipassItemRenderer());
|
||||
|
||||
OreDictionary.registerOre("pigment", Botany.pigment);
|
||||
OreDictionary.registerOre("toolTrowel", Botany.trowelWood);
|
||||
OreDictionary.registerOre("toolTrowel", Botany.trowelStone);
|
||||
@@ -113,9 +117,9 @@ public class ModuleGardening implements IInitializable {
|
||||
public void init() {
|
||||
RecipeSorter.register("botany:ceramictile", CeramicTileRecipe.class, RecipeSorter.Category.SHAPED, "");
|
||||
RecipeSorter.register("botany:pigment", PigmentRecipe.class, RecipeSorter.Category.SHAPED, "");
|
||||
final ItemStack yellow = new ItemStack(Blocks.YELLOW_FLOWER, 1);
|
||||
final ItemStack red = new ItemStack(Blocks.RED_FLOWER, 1);
|
||||
final ItemStack blue = new ItemStack(Blocks.RED_FLOWER, 1, 7);
|
||||
ItemStack yellow = new ItemStack(Blocks.YELLOW_FLOWER, 1);
|
||||
ItemStack red = new ItemStack(Blocks.RED_FLOWER, 1);
|
||||
ItemStack blue = new ItemStack(Blocks.RED_FLOWER, 1, 7);
|
||||
for (boolean manual : new boolean[]{true, false}) {
|
||||
for (boolean fertilised : new boolean[]{true, false}) {
|
||||
for (EnumMoisture moist : EnumMoisture.values()) {
|
||||
@@ -131,7 +135,7 @@ public class ModuleGardening implements IInitializable {
|
||||
if (fertilised) {
|
||||
insulate += 3;
|
||||
}
|
||||
new CircuitGarden(moist, null, manual, fertilised, new ItemStack(Botany.insulatedTube, 1, 0 + 128 * insulate), icon);
|
||||
new CircuitGarden(moist, null, manual, fertilised, new ItemStack(Botany.insulatedTube, 1, 128 * insulate), icon);
|
||||
new CircuitGarden(moist, EnumAcidity.ACID, manual, fertilised, new ItemStack(Botany.insulatedTube, 1, 1 + 128 * insulate), icon);
|
||||
new CircuitGarden(moist, EnumAcidity.NEUTRAL, manual, fertilised, new ItemStack(Botany.insulatedTube, 1, 2 + 128 * insulate), icon);
|
||||
new CircuitGarden(moist, EnumAcidity.ALKALINE, manual, fertilised, new ItemStack(Botany.insulatedTube, 1, 3 + 128 * insulate), icon);
|
||||
@@ -146,80 +150,167 @@ public class ModuleGardening implements IInitializable {
|
||||
GameRegistry.addRecipe(new CeramicTileRecipe());
|
||||
for (int mat = 0; mat < 4; ++mat) {
|
||||
for (int insulate = 0; insulate < 6; ++insulate) {
|
||||
final ItemStack tubes = new ItemStack(Botany.insulatedTube, 2, mat + 128 * insulate);
|
||||
final ItemStack insulateStack = ItemInsulatedTube.getInsulateStack(tubes);
|
||||
final ItemStack forestryTube = new ItemStack(Mods.Forestry.item("thermionic_tubes"), 1, mat);
|
||||
ItemStack tubes = new ItemStack(Botany.insulatedTube, 2, mat + 128 * insulate);
|
||||
ItemStack insulateStack = ItemInsulatedTube.getInsulateStack(tubes);
|
||||
ItemStack forestryTube = new ItemStack(Mods.Forestry.item("thermionic_tubes"), 1, mat);
|
||||
GameRegistry.addShapelessRecipe(tubes, forestryTube, forestryTube, insulateStack);
|
||||
}
|
||||
}
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(Botany.trowelWood, "d ", " x ", " s", 'd', Blocks.DIRT, 's', "stickWood", 'x', "plankWood"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(Botany.trowelStone, "d ", " x ", " s", 'd', Blocks.DIRT, 's', "stickWood", 'x', "cobblestone"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(Botany.trowelIron, "d ", " x ", " s", 'd', Blocks.DIRT, 's', "stickWood", 'x', "ingotIron"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(Botany.trowelGold, "d ", " x ", " s", 'd', Blocks.DIRT, 's', "stickWood", 'x', "ingotGold"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(Botany.trowelDiamond, "d ", " x ", " s", 'd', Blocks.DIRT, 's', "stickWood", 'x', "gemDiamond"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(Botany.soilMeter, " gg", " rg", "i ", 'g', "ingotGold", 'r', "dustRedstone", 'i', "ingotIron"));
|
||||
GameRegistry.addShapelessRecipe(BotanyItems.Weedkiller.get(4), new ItemStack(Items.SPIDER_EYE), new ItemStack(Items.WHEAT_SEEDS), new ItemStack(Items.WHEAT_SEEDS), new ItemStack(Items.WHEAT_SEEDS));
|
||||
GameRegistry.addShapelessRecipe(BotanyItems.AshPowder.get(4), Mods.Forestry.stack("ash"));
|
||||
GameRegistry.addShapelessRecipe(BotanyItems.MulchPowder.get(4), Mods.Forestry.stack("mulch"));
|
||||
GameRegistry.addShapelessRecipe(BotanyItems.CompostPowder.get(4), Mods.Forestry.stack("fertilizer_bio"));
|
||||
GameRegistry.addShapelessRecipe(BotanyItems.FertiliserPowder.get(4), Mods.Forestry.stack("fertilizer_compound"));
|
||||
GameRegistry.addShapelessRecipe(BotanyItems.PulpPowder.get(4), Mods.Forestry.stack("wood_pulp"));
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(BotanyItems.SulphurPowder.get(4), "dustSulphur"));
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(Botany.pigment, 2, EnumFlowerColor.Black.ordinal()), "pigment", "pigment", "dyeBlack"));
|
||||
gardening.registerAcidFertiliser(BotanyItems.SulphurPowder.get(1), 1);
|
||||
gardening.registerAcidFertiliser(BotanyItems.MulchPowder.get(1), 1);
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(
|
||||
Botany.trowelWood,
|
||||
"d ", " x ", " s",
|
||||
'd', Blocks.DIRT,
|
||||
's', "stickWood",
|
||||
'x', "plankWood")
|
||||
);
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(
|
||||
Botany.trowelStone,
|
||||
"d ", " x ", " s",
|
||||
'd', Blocks.DIRT,
|
||||
's', "stickWood",
|
||||
'x', "cobblestone"
|
||||
));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(
|
||||
Botany.trowelIron,
|
||||
"d ", " x ", " s",
|
||||
'd', Blocks.DIRT,
|
||||
's', "stickWood",
|
||||
'x', "ingotIron"
|
||||
));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(
|
||||
Botany.trowelGold,
|
||||
"d ", " x ", " s",
|
||||
'd', Blocks.DIRT,
|
||||
's', "stickWood",
|
||||
'x', "ingotGold"
|
||||
));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(
|
||||
Botany.trowelDiamond,
|
||||
"d ", " x ", " s",
|
||||
'd', Blocks.DIRT,
|
||||
's', "stickWood",
|
||||
'x', "gemDiamond"
|
||||
));
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(
|
||||
Botany.soilMeter,
|
||||
" gg", " rg", "i ",
|
||||
'g', "ingotGold",
|
||||
'r', "dustRedstone",
|
||||
'i', "ingotIron"
|
||||
));
|
||||
|
||||
GameRegistry.addShapelessRecipe(
|
||||
BotanyItems.WEEDKILLER.get(4),
|
||||
new ItemStack(Items.SPIDER_EYE),
|
||||
new ItemStack(Items.WHEAT_SEEDS),
|
||||
new ItemStack(Items.WHEAT_SEEDS),
|
||||
new ItemStack(Items.WHEAT_SEEDS)
|
||||
);
|
||||
|
||||
GameRegistry.addShapelessRecipe(
|
||||
BotanyItems.POWDER_ASH.get(4),
|
||||
Mods.Forestry.stack("ash")
|
||||
);
|
||||
|
||||
GameRegistry.addShapelessRecipe(
|
||||
BotanyItems.POWDER_MULCH.get(4),
|
||||
Mods.Forestry.stack("mulch")
|
||||
);
|
||||
|
||||
GameRegistry.addShapelessRecipe(
|
||||
BotanyItems.POWDER_COMPOST.get(4),
|
||||
Mods.Forestry.stack("fertilizer_bio")
|
||||
);
|
||||
|
||||
GameRegistry.addShapelessRecipe(
|
||||
BotanyItems.POWDER_FERTILISER.get(4),
|
||||
Mods.Forestry.stack("fertilizer_compound")
|
||||
);
|
||||
|
||||
GameRegistry.addShapelessRecipe(
|
||||
BotanyItems.POWDER_PULP.get(4),
|
||||
Mods.Forestry.stack("wood_pulp")
|
||||
);
|
||||
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(
|
||||
BotanyItems.POWDER_SULPHUR.get(4),
|
||||
"dustSulphur"
|
||||
));
|
||||
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(
|
||||
new ItemStack(Botany.pigment, 2, EnumFlowerColor.Black.ordinal()),
|
||||
"pigment", "pigment", "dyeBlack"
|
||||
));
|
||||
|
||||
gardening.registerAcidFertiliser(BotanyItems.POWDER_SULPHUR.get(1), 1);
|
||||
gardening.registerAcidFertiliser(BotanyItems.POWDER_MULCH.get(1), 1);
|
||||
gardening.registerAcidFertiliser(Mods.Forestry.stack("mulch"), 2);
|
||||
for (final ItemStack stack : OreDictionary.getOres("dustSulfur")) {
|
||||
for (ItemStack stack : OreDictionary.getOres("dustSulfur")) {
|
||||
gardening.registerAcidFertiliser(stack, 2);
|
||||
}
|
||||
gardening.registerAlkalineFertiliser(BotanyItems.AshPowder.get(1), 1);
|
||||
gardening.registerAlkalineFertiliser(BotanyItems.PulpPowder.get(1), 1);
|
||||
|
||||
gardening.registerAlkalineFertiliser(BotanyItems.POWDER_ASH.get(1), 1);
|
||||
gardening.registerAlkalineFertiliser(BotanyItems.POWDER_PULP.get(1), 1);
|
||||
gardening.registerAlkalineFertiliser(Mods.Forestry.stack("ash"), 2);
|
||||
gardening.registerAlkalineFertiliser(Mods.Forestry.stack("wood_pulp"), 2);
|
||||
gardening.registerNutrientFertiliser(BotanyItems.CompostPowder.get(1), 1);
|
||||
gardening.registerNutrientFertiliser(BotanyItems.FertiliserPowder.get(1), 1);
|
||||
gardening.registerNutrientFertiliser(BotanyItems.POWDER_COMPOST.get(1), 1);
|
||||
gardening.registerNutrientFertiliser(BotanyItems.POWDER_FERTILISER.get(1), 1);
|
||||
gardening.registerNutrientFertiliser(Mods.Forestry.stack("fertilizer_bio"), 2);
|
||||
gardening.registerNutrientFertiliser(Mods.Forestry.stack("fertilizer_compound"), 2);
|
||||
for (final Map.Entry<ItemStack, Integer> entry : ModuleGardening.queuedAcidFertilisers.entrySet()) {
|
||||
this.addAcidFertiliserRecipe(entry.getKey(), entry.getValue());
|
||||
|
||||
for (Map.Entry<ItemStack, Integer> entry : ModuleGardening.queuedAcidFertilisers.entrySet()) {
|
||||
addAcidFertiliserRecipe(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(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(entry.getKey(), entry.getValue());
|
||||
}
|
||||
GameRegistry.addRecipe(BotanyItems.Mortar.get(6), " c ", "cgc", " c ", 'c', Items.CLAY_BALL, 'g', Blocks.GRAVEL);
|
||||
for (final EnumFlowerColor c : EnumFlowerColor.values()) {
|
||||
final ItemStack clay = new ItemStack(Botany.clay, 1, c.ordinal());
|
||||
final ItemStack pigment = new ItemStack(Botany.pigment, 1, c.ordinal());
|
||||
|
||||
GameRegistry.addRecipe(BotanyItems.MORTAR.get(6), " c ", "cgc", " c ", 'c', Items.CLAY_BALL, 'g', Blocks.GRAVEL);
|
||||
for (EnumFlowerColor c : EnumFlowerColor.values()) {
|
||||
ItemStack clay = new ItemStack(Botany.clay, 1, c.ordinal());
|
||||
ItemStack pigment = new ItemStack(Botany.pigment, 1, c.ordinal());
|
||||
GameRegistry.addShapelessRecipe(clay, Items.CLAY_BALL, Items.CLAY_BALL, Items.CLAY_BALL, pigment);
|
||||
GameRegistry.addSmelting(clay, TileEntityMetadata.getItemStack(Botany.ceramic, c.ordinal()), 0.0f);
|
||||
final ItemStack glass = TileEntityMetadata.getItemStack(Botany.stained, c.ordinal());
|
||||
ItemStack glass = TileEntityMetadata.getItemStack(Botany.stained, c.ordinal());
|
||||
glass.setCount(4);
|
||||
GameRegistry.addShapedRecipe(glass, " g ", "gpg", " g ", 'g', Blocks.GLASS, 'p', pigment);
|
||||
|
||||
GameRegistry.addShapedRecipe(
|
||||
glass,
|
||||
" g ", "gpg", " g ",
|
||||
'g', Blocks.GLASS,
|
||||
'p', pigment
|
||||
);
|
||||
}
|
||||
GameRegistry.addRecipe(new PigmentRecipe());
|
||||
}
|
||||
|
||||
private ItemStack getStack(final int type, final int pH, final int moisture) {
|
||||
private ItemStack getStack(int type, int pH, int moisture) {
|
||||
if (type >= 0 && type <= 2 && pH >= 0 && pH <= 2 && moisture >= 0 && moisture <= 2) {
|
||||
return new ItemStack(BotanyCore.getGardening().getSoilBlock(EnumSoilType.values()[type]), 1, BlockSoil.getMeta(EnumAcidity.values()[pH], EnumMoisture.values()[moisture]));
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
private void addAcidFertiliserRecipe(final ItemStack stack, final int strengthMax) {
|
||||
private void addAcidFertiliserRecipe(ItemStack stack, int strengthMax) {
|
||||
for (int moisture = 0; moisture < 3; ++moisture) {
|
||||
for (int pH = 0; pH < 3; ++pH) {
|
||||
for (int type = 0; type < 3; ++type) {
|
||||
int numOfBlocks = strengthMax * strengthMax;
|
||||
for (int strength = 1; strength < strengthMax; ++strength) {
|
||||
final ItemStack start = this.getStack(type, pH, moisture);
|
||||
final ItemStack end = this.getStack(type, pH - strength, moisture);
|
||||
ItemStack start = getStack(type, pH, moisture);
|
||||
ItemStack end = getStack(type, pH - strength, moisture);
|
||||
if (!start.isEmpty() && !end.isEmpty()) {
|
||||
end.setCount(numOfBlocks);
|
||||
final Object[] stacks = new Object[numOfBlocks + 1];
|
||||
Object[] stacks = new Object[numOfBlocks + 1];
|
||||
for (int i = 0; i < numOfBlocks; ++i) {
|
||||
stacks[i] = start;
|
||||
}
|
||||
@@ -233,17 +324,17 @@ public class ModuleGardening implements IInitializable {
|
||||
}
|
||||
}
|
||||
|
||||
private void addAlkalineFertiliserRecipe(final ItemStack stack, final int strengthMax) {
|
||||
private void addAlkalineFertiliserRecipe(ItemStack stack, int strengthMax) {
|
||||
for (int moisture = 0; moisture < 3; ++moisture) {
|
||||
for (int pH = 0; pH < 3; ++pH) {
|
||||
for (int type = 0; type < 3; ++type) {
|
||||
int numOfBlocks = strengthMax * strengthMax;
|
||||
for (int strength = 1; strength < strengthMax; ++strength) {
|
||||
final ItemStack start = this.getStack(type, pH, moisture);
|
||||
final ItemStack end = this.getStack(type, pH + strength, moisture);
|
||||
ItemStack start = getStack(type, pH, moisture);
|
||||
ItemStack end = getStack(type, pH + strength, moisture);
|
||||
if (!end.isEmpty()) {
|
||||
end.setCount(numOfBlocks);
|
||||
final Object[] stacks = new Object[numOfBlocks + 1];
|
||||
Object[] stacks = new Object[numOfBlocks + 1];
|
||||
for (int i = 0; i < numOfBlocks; ++i) {
|
||||
stacks[i] = start;
|
||||
}
|
||||
@@ -257,17 +348,17 @@ public class ModuleGardening implements IInitializable {
|
||||
}
|
||||
}
|
||||
|
||||
private void addNutrientFertiliserRecipe(final ItemStack stack, final int strengthMax) {
|
||||
private void addNutrientFertiliserRecipe(ItemStack stack, int strengthMax) {
|
||||
for (int moisture = 0; moisture < 3; ++moisture) {
|
||||
for (int pH = 0; pH < 3; ++pH) {
|
||||
for (int type = 0; type < 3; ++type) {
|
||||
int numOfBlocks = strengthMax * strengthMax;
|
||||
for (int strength = 1; strength < strengthMax; ++strength) {
|
||||
final ItemStack start = this.getStack(type, pH, moisture);
|
||||
final ItemStack end = this.getStack(type + strength, pH, moisture);
|
||||
ItemStack start = getStack(type, pH, moisture);
|
||||
ItemStack end = getStack(type + strength, pH, moisture);
|
||||
if (!end.isEmpty()) {
|
||||
end.setCount(numOfBlocks);
|
||||
final Object[] stacks = new Object[numOfBlocks + 1];
|
||||
Object[] stacks = new Object[numOfBlocks + 1];
|
||||
for (int i = 0; i < numOfBlocks; ++i) {
|
||||
stacks[i] = start;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package binnie.botany.gardening;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
|
||||
public enum PlantType implements IStringSerializable {
|
||||
WEEDS("weeds", true),
|
||||
WEEDS_LONG("weeds_long", true),
|
||||
WEEDS_VERY_LONG("weeds_very_long", true),
|
||||
DEAD_FLOWER("dead_flower"),
|
||||
DECAYING_FLOWER("decaying_flower");
|
||||
|
||||
String name;
|
||||
boolean isWeed;
|
||||
|
||||
PlantType(String name) {
|
||||
this(name, false);
|
||||
}
|
||||
|
||||
PlantType(String name, boolean isWeed) {
|
||||
this.name = name;
|
||||
this.isWeed = isWeed;
|
||||
}
|
||||
|
||||
public static PlantType get(int id) {
|
||||
return values()[id % values().length];
|
||||
}
|
||||
|
||||
public ItemStack get() {
|
||||
return new ItemStack(Botany.plant, 1, ordinal());
|
||||
}
|
||||
|
||||
public boolean isWeed() {
|
||||
return isWeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -93,11 +93,11 @@ public enum EnumFlowerColor implements IStringSerializable {
|
||||
|
||||
private FlowerColorAllele allele;
|
||||
|
||||
EnumFlowerColor(final String ident, final int c) {
|
||||
EnumFlowerColor(String ident, int c) {
|
||||
this(c);
|
||||
}
|
||||
|
||||
EnumFlowerColor(final int color) {
|
||||
EnumFlowerColor(int color) {
|
||||
int r = color >> 16 & 0xFF;
|
||||
int g = color >> 8 & 0xFF;
|
||||
int b = color & 0xFF;
|
||||
@@ -105,12 +105,12 @@ public enum EnumFlowerColor implements IStringSerializable {
|
||||
g = (int) (0.45 * (g + 174));
|
||||
b = (int) (0.45 * (b + 131));
|
||||
int colorDis = (r << 16) + (g << 8) + b;
|
||||
String uid = "botany.color" + this.name();
|
||||
String uid = "botany.color" + name();
|
||||
allele = new FlowerColorAllele(uid, ordinal(), color, colorDis, name().toLowerCase(), uid, true);
|
||||
}
|
||||
|
||||
public static void addMix(final EnumFlowerColor start1, final EnumFlowerColor start2, final EnumFlowerColor result, final int chance) {
|
||||
BotanyCore.getFlowerRoot().registerColourMix(new ColourMix(start1.allele, start2.allele, result.allele, chance));
|
||||
public static void addMix(EnumFlowerColor start1, EnumFlowerColor start2, EnumFlowerColor result, int chance) {
|
||||
BotanyCore.getFlowerRoot().registerColourMix(new ColorMix(start1.allele, start2.allele, result.allele, chance));
|
||||
}
|
||||
|
||||
public static void setupMutations() {
|
||||
@@ -2937,24 +2937,24 @@ public enum EnumFlowerColor implements IStringSerializable {
|
||||
}
|
||||
}
|
||||
|
||||
public static EnumFlowerColor get(final int i) {
|
||||
public static EnumFlowerColor get(int i) {
|
||||
return values()[Math.max(0, i) % values().length];
|
||||
}
|
||||
|
||||
public String getDisplayName(){
|
||||
public String getDisplayName() {
|
||||
return I18N.localise("botany.color." + getName());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase();
|
||||
}
|
||||
|
||||
public String getHTMLName() {
|
||||
return this.name();
|
||||
return name();
|
||||
}
|
||||
|
||||
public FlowerColorAllele getFlowerColorAllele(){
|
||||
public FlowerColorAllele getFlowerColorAllele() {
|
||||
return allele;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -17,98 +17,102 @@ import forestry.core.genetics.Individual;
|
||||
|
||||
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;
|
||||
|
||||
public class Flower extends Individual implements IFlower {
|
||||
public IFlowerGenome genome;
|
||||
|
||||
@Nullable
|
||||
public IFlowerGenome mate;
|
||||
|
||||
private int age;
|
||||
private boolean wilting;
|
||||
private boolean flowered;
|
||||
|
||||
public Flower(final NBTTagCompound nbt) {
|
||||
public Flower(NBTTagCompound nbt) {
|
||||
super(nbt);
|
||||
|
||||
if (nbt.hasKey("Age")) {
|
||||
this.age = nbt.getInteger("Age");
|
||||
age = nbt.getInteger("Age");
|
||||
} else {
|
||||
this.age = 0;
|
||||
age = 0;
|
||||
}
|
||||
|
||||
this.wilting = nbt.hasKey("Wilt") && nbt.getBoolean("Wilt");
|
||||
wilting = nbt.hasKey("Wilt") && nbt.getBoolean("Wilt");
|
||||
|
||||
if (nbt.hasKey("Flowered")) {
|
||||
this.flowered = nbt.getBoolean("Flowered");
|
||||
flowered = nbt.getBoolean("Flowered");
|
||||
} else {
|
||||
this.flowered = age > 0;
|
||||
flowered = age > 0;
|
||||
}
|
||||
|
||||
if (nbt.hasKey("Genome")) {
|
||||
this.genome = new FlowerGenome(nbt.getCompoundTag("Genome"));
|
||||
genome = new FlowerGenome(nbt.getCompoundTag("Genome"));
|
||||
} else {
|
||||
this.genome = BotanyCore.getFlowerRoot().templateAsGenome(BotanyCore.getFlowerRoot().getDefaultTemplate());
|
||||
genome = BotanyCore.getFlowerRoot().templateAsGenome(BotanyCore.getFlowerRoot().getDefaultTemplate());
|
||||
}
|
||||
|
||||
if (nbt.hasKey("Mate")) {
|
||||
this.mate = new FlowerGenome(nbt.getCompoundTag("Mate"));
|
||||
mate = new FlowerGenome(nbt.getCompoundTag("Mate"));
|
||||
}
|
||||
}
|
||||
|
||||
public Flower(final IFlowerGenome genome, final int age) {
|
||||
public Flower(IFlowerGenome genome, int age) {
|
||||
this.age = 0;
|
||||
this.wilting = false;
|
||||
this.genome = genome;
|
||||
this.age = age;
|
||||
this.flowered = age > 0;
|
||||
wilting = false;
|
||||
flowered = age > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
final IAlleleFlowerSpecies species = this.getGenome().getPrimary();
|
||||
IAlleleFlowerSpecies species = getGenome().getPrimary();
|
||||
String name = species.getName();
|
||||
if (this.age == 0) {
|
||||
if (age == 0) {
|
||||
name += "";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTooltip(final List<String> list) {
|
||||
final IAlleleFlowerSpecies primary = this.genome.getPrimary();
|
||||
final IAlleleFlowerSpecies secondary = this.genome.getSecondary();
|
||||
if (!this.isPureBred(EnumFlowerChromosome.SPECIES)) {
|
||||
public void addTooltip(List<String> list) {
|
||||
IAlleleFlowerSpecies primary = genome.getPrimary();
|
||||
IAlleleFlowerSpecies secondary = genome.getSecondary();
|
||||
// TODO localize
|
||||
if (!isPureBred(EnumFlowerChromosome.SPECIES)) {
|
||||
list.add(TextFormatting.BLUE + primary.getAlleleName() + "-" + secondary.getAlleleName() + " Hybrid");
|
||||
}
|
||||
list.add(TextFormatting.GOLD + "Age: " + this.getAge());
|
||||
list.add(TextFormatting.GOLD + "T: " + this.getGenome().getPrimary().getTemperature() + " / " + this.getGenome().getToleranceTemperature());
|
||||
list.add(TextFormatting.GOLD + "M: " + this.getGenome().getPrimary().getMoisture() + " / " + this.getGenome().getToleranceMoisture());
|
||||
list.add(TextFormatting.GOLD + "pH: " + this.getGenome().getPrimary().getHumidity() + " / " + this.getGenome().getTolerancePH());
|
||||
list.add(TextFormatting.GOLD + "Fert: " + this.getGenome().getFertility() + "x");
|
||||
|
||||
list.add(TextFormatting.GOLD + "Age: " + getAge());
|
||||
list.add(TextFormatting.GOLD + "T: " + getGenome().getPrimary().getTemperature() + " / " + getGenome().getToleranceTemperature());
|
||||
list.add(TextFormatting.GOLD + "M: " + getGenome().getPrimary().getMoisture() + " / " + getGenome().getToleranceMoisture());
|
||||
list.add(TextFormatting.GOLD + "pH: " + getGenome().getPrimary().getHumidity() + " / " + getGenome().getTolerancePH());
|
||||
list.add(TextFormatting.GOLD + "Fert: " + getGenome().getFertility() + "x");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdent() {
|
||||
return this.getGenome().getPrimary().getUID();
|
||||
return getGenome().getPrimary().getUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(final NBTTagCompound nbttagcompound2) {
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound2) {
|
||||
NBTTagCompound nbttagcompound = super.writeToNBT(nbttagcompound2);
|
||||
nbttagcompound.setInteger("Age", this.age);
|
||||
nbttagcompound.setBoolean("Wilt", this.wilting);
|
||||
nbttagcompound.setBoolean("Flowered", this.flowered);
|
||||
final NBTTagCompound nbtGenome = new NBTTagCompound();
|
||||
this.genome.writeToNBT(nbtGenome);
|
||||
nbttagcompound.setInteger("Age", age);
|
||||
nbttagcompound.setBoolean("Wilt", wilting);
|
||||
nbttagcompound.setBoolean("Flowered", flowered);
|
||||
NBTTagCompound nbtGenome = new NBTTagCompound();
|
||||
genome.writeToNBT(nbtGenome);
|
||||
nbttagcompound.setTag("Genome", nbtGenome);
|
||||
if (this.mate != null) {
|
||||
final NBTTagCompound nbtMate = new NBTTagCompound();
|
||||
this.mate.writeToNBT(nbtMate);
|
||||
if (mate != null) {
|
||||
NBTTagCompound nbtMate = new NBTTagCompound();
|
||||
mate.writeToNBT(nbtMate);
|
||||
nbttagcompound.setTag("Mate", nbtMate);
|
||||
}
|
||||
return nbttagcompound;
|
||||
@@ -116,7 +120,7 @@ public class Flower extends Individual implements IFlower {
|
||||
|
||||
@Override
|
||||
public IFlowerGenome getGenome() {
|
||||
return this.genome;
|
||||
return genome;
|
||||
}
|
||||
|
||||
private IChromosome inheritChromosome(Random rand, IChromosome parentFirst, IChromosome parentSecond) {
|
||||
@@ -140,91 +144,91 @@ public class Flower extends Individual implements IFlower {
|
||||
|
||||
@Override
|
||||
public void mate(IFlower other) {
|
||||
this.mate = new FlowerGenome(other.getGenome().getChromosomes());
|
||||
mate = new FlowerGenome(other.getGenome().getChromosomes());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IFlowerGenome getMate() {
|
||||
return this.mate;
|
||||
return mate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlower copy() {
|
||||
final NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
this.writeToNBT(nbttagcompound);
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
writeToNBT(nbttagcompound);
|
||||
return new Flower(nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAge() {
|
||||
return this.age;
|
||||
return age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAge(final int i) {
|
||||
this.age = i;
|
||||
public void setAge(int i) {
|
||||
age = i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void age() {
|
||||
if (this.age < 15) {
|
||||
++this.age;
|
||||
if (age < 15) {
|
||||
age++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxAge() {
|
||||
return this.getGenome().getLifespan();
|
||||
return getGenome().getLifespan();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWilted() {
|
||||
return this.wilting;
|
||||
return wilting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWilted(final boolean wilted) {
|
||||
this.wilting = wilted;
|
||||
public void setWilted(boolean wilted) {
|
||||
wilting = wilted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFlowered() {
|
||||
return this.flowered;
|
||||
return flowered;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlowered(final boolean flowered) {
|
||||
public void setFlowered(boolean flowered) {
|
||||
this.flowered = flowered;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMate() {
|
||||
this.mate = null;
|
||||
mate = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlower getOffspring(final World world, final BlockPos pos) {
|
||||
if (this.mate != null) {
|
||||
final IChromosome[] chromosomes = new IChromosome[this.genome.getChromosomes().length];
|
||||
IChromosome[] parentFirst = this.mutateSpecies(world, pos, this.genome, this.mate);
|
||||
IChromosome[] parentSecond = this.mutateSpecies(world, pos, this.mate, this.genome);
|
||||
public IFlower getOffspring(World world, BlockPos pos) {
|
||||
if (mate != null) {
|
||||
IChromosome[] chromosomes = new IChromosome[genome.getChromosomes().length];
|
||||
IChromosome[] parentFirst = mutateSpecies(world, pos, genome, mate);
|
||||
IChromosome[] parentSecond = mutateSpecies(world, pos, mate, genome);
|
||||
for (int i = 0; i < parentFirst.length; ++i) {
|
||||
if (parentFirst[i] != null && parentSecond[i] != null) {
|
||||
chromosomes[i] = Chromosome.inheritChromosome(world.rand, parentFirst[i], parentSecond[i]);
|
||||
}
|
||||
}
|
||||
return new Flower(new FlowerGenome(chromosomes), 0);
|
||||
} else {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
return new Flower(nbt);
|
||||
}
|
||||
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeToNBT(nbt);
|
||||
return new Flower(nbt);
|
||||
}
|
||||
|
||||
private IChromosome[] mutateSpecies(World world, BlockPos pos, IFlowerGenome genomeFirst, IFlowerGenome genomeSecond) {
|
||||
IChromosome[] parentFirst = genomeFirst.getChromosomes();
|
||||
final IChromosome[] parentSecond = genomeSecond.getChromosomes();
|
||||
IChromosome[] parentSecond = genomeSecond.getChromosomes();
|
||||
IAlleleFlowerSpecies alleleFrist;
|
||||
IAlleleFlowerSpecies alleleSecond;
|
||||
IFlowerGenome genome0;
|
||||
@@ -240,40 +244,44 @@ public class Flower extends Individual implements IFlower {
|
||||
genome0 = genomeSecond;
|
||||
genome2 = genomeFirst;
|
||||
}
|
||||
IFlowerColour colourFirst = genome0.getPrimaryColor();
|
||||
IFlowerColour colourSecond = genome2.getPrimaryColor();
|
||||
if (colourFirst != colourSecond) {
|
||||
for (final 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;
|
||||
}
|
||||
|
||||
@@ -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){
|
||||
public void drawLine(GuiScreen gui, int xOffset, String msg, int color) {
|
||||
gui.mc.fontRendererObj.drawString(msg, guiLeft + xOffset, guiTop + lastTopOffset + margin, color);
|
||||
}
|
||||
|
||||
public void drawChromosom(GuiScreen gui, EnumFlowerChromosome chromosome, IFlower flower){
|
||||
public void drawChromosom(GuiScreen gui, EnumFlowerChromosome chromosome, IFlower flower) {
|
||||
drawLine(gui, COLUMN_0, StringUtils.capitalize(chromosome.getName()), 0xEEEEEE);
|
||||
drawLine(gui, COLUMN_1, I18N.localise(flower.getGenome().getActiveAllele(chromosome).getUnlocalizedName()), 0xEEEEEE);
|
||||
drawLine(gui, COLUMN_2, I18N.localise(flower.getGenome().getInactiveAllele(chromosome).getUnlocalizedName()), 0xEEEEEE);
|
||||
lastTopOffset += rowSize;
|
||||
}
|
||||
|
||||
public void newLine(){
|
||||
public void newLine() {
|
||||
lastTopOffset += rowSize;
|
||||
}
|
||||
|
||||
@@ -100,13 +98,13 @@ public class FlowerAlyzerPlugin implements IAlyzerPlugin {
|
||||
gui.mc.fontRendererObj.drawString("Active", guiLeft + 10 + COLUMN_1, guiTop + 10, 0xffffff);
|
||||
gui.mc.fontRendererObj.drawString("Inactive", guiLeft + 10 + COLUMN_2, guiTop + 10, 0xffffff);
|
||||
|
||||
if (renderP != null && renderS!=null){
|
||||
if (renderP != null && renderS != null) {
|
||||
RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
|
||||
itemRender.renderItemAndEffectIntoGUI(renderP, guiLeft + 10 + COLUMN_1, guiTop + 10 +12);
|
||||
itemRender.renderItemAndEffectIntoGUI(renderP, guiLeft + 10 + COLUMN_1, guiTop + 10 + 12);
|
||||
itemRender.renderItemOverlayIntoGUI(gui.mc.fontRendererObj, renderP, guiLeft + 10 + COLUMN_1, guiTop + 10 + 12, null);
|
||||
|
||||
itemRender.renderItemAndEffectIntoGUI(renderS, guiLeft + 10 + COLUMN_2, guiTop +10 +12);
|
||||
itemRender.renderItemOverlayIntoGUI(gui.mc.fontRendererObj, renderS, guiLeft + 10 + COLUMN_1, guiTop +10 + 12, null);
|
||||
itemRender.renderItemAndEffectIntoGUI(renderS, guiLeft + 10 + COLUMN_2, guiTop + 10 + 12);
|
||||
itemRender.renderItemOverlayIntoGUI(gui.mc.fontRendererObj, renderS, guiLeft + 10 + COLUMN_1, guiTop + 10 + 12, null);
|
||||
}
|
||||
|
||||
guiTop += rowSize * 3;
|
||||
@@ -128,8 +126,8 @@ public class FlowerAlyzerPlugin implements IAlyzerPlugin {
|
||||
|
||||
for (EnumFlowerChromosome chromosome : secondPageColorChromosome) {
|
||||
drawChromosom(gui, chromosome, f);
|
||||
RenderUtil.drawSolidRect(new Area(guiLeft + COLUMN_1, guiTop + lastTopOffset + margin, 50, 10), ((IAlleleInteger)f.getGenome().getActiveAllele(chromosome)).getValue());
|
||||
RenderUtil.drawSolidRect(new Area(guiLeft + COLUMN_2, guiTop + lastTopOffset + margin, 50, 10), ((IAlleleInteger)f.getGenome().getInactiveAllele(chromosome)).getValue());
|
||||
RenderUtil.drawSolidRect(new Area(guiLeft + COLUMN_1, guiTop + lastTopOffset + margin, 50, 10), ((IAlleleInteger) f.getGenome().getActiveAllele(chromosome)).getValue());
|
||||
RenderUtil.drawSolidRect(new Area(guiLeft + COLUMN_2, guiTop + lastTopOffset + margin, 50, 10), ((IAlleleInteger) f.getGenome().getInactiveAllele(chromosome)).getValue());
|
||||
newLine();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,12 +26,12 @@ import binnie.core.util.I18N;
|
||||
|
||||
public class FlowerBreedingSystem extends BreedingSystem {
|
||||
public FlowerBreedingSystem() {
|
||||
this.iconUndiscovered = Binnie.RESOURCE.getUndiscoveredBeeSprite();
|
||||
this.iconDiscovered = Binnie.RESOURCE.getDiscoveredBeeSprite();
|
||||
iconUndiscovered = Binnie.RESOURCE.getUndiscoveredBeeSprite();
|
||||
iconDiscovered = Binnie.RESOURCE.getDiscoveredBeeSprite();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getChance(final IMutation mutation, final EntityPlayer player, final IAlleleSpecies species1, final IAlleleSpecies species2) {
|
||||
public float getChance(IMutation mutation, EntityPlayer player, IAlleleSpecies species1, IAlleleSpecies species2) {
|
||||
return mutation.getBaseChance();
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class FlowerBreedingSystem extends BreedingSystem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAlleleName(final IChromosomeType chromosome, final IAllele allele) {
|
||||
public String getAlleleName(IChromosomeType chromosome, IAllele allele) {
|
||||
if (chromosome == EnumFlowerChromosome.FERTILITY) {
|
||||
if (allele.getUID().contains("Low")) {
|
||||
return I18N.localise("binniecore.allele.fertility.low");
|
||||
@@ -70,8 +70,8 @@ public class FlowerBreedingSystem extends BreedingSystem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDNAManipulable(final ItemStack member) {
|
||||
ISpeciesType type = this.getSpeciesRoot().getType(member);
|
||||
public boolean isDNAManipulable(ItemStack member) {
|
||||
ISpeciesType type = getSpeciesRoot().getType(member);
|
||||
return type != null && isDNAManipulable(type);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class FlowerBreedingSystem extends BreedingSystem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIndividual getConversion(final ItemStack stack) {
|
||||
public IIndividual getConversion(ItemStack stack) {
|
||||
return BotanyCore.getFlowerRoot().getConversion(stack);
|
||||
}
|
||||
|
||||
@@ -91,51 +91,47 @@ public class FlowerBreedingSystem extends BreedingSystem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addExtraAlleles(final IChromosomeType chromosome, final TreeSet<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,10 +2,10 @@ package binnie.botany.genetics;
|
||||
|
||||
import forestry.api.genetics.IAlleleInteger;
|
||||
|
||||
import binnie.botany.api.IFlowerColour;
|
||||
import binnie.botany.api.IFlowerColor;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public class FlowerColorAllele implements IFlowerColour, IAlleleInteger {
|
||||
public class FlowerColorAllele implements IFlowerColor, IAlleleInteger {
|
||||
private int color;
|
||||
private String uid;
|
||||
private boolean isDominant;
|
||||
@@ -50,8 +50,8 @@ public class FlowerColorAllele implements IFlowerColour, IAlleleInteger {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor(final boolean dis) {
|
||||
return dis ? this.colorDis : this.color;
|
||||
public int getColor(boolean dis) {
|
||||
return dis ? colorDis : color;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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,7 +8,7 @@ import binnie.botany.api.EnumFlowerChromosome;
|
||||
|
||||
public class FlowerTemplates {
|
||||
public static IAllele[] getDefaultTemplate() {
|
||||
final IAllele[] alleles = new IAllele[EnumFlowerChromosome.values().length];
|
||||
IAllele[] alleles = new IAllele[EnumFlowerChromosome.values().length];
|
||||
//TODO: Test flower reset
|
||||
AlleleHelper.getInstance().set(alleles, EnumFlowerChromosome.SPECIES, FlowerDefinition.Poppy.getSpecies());
|
||||
AlleleHelper.getInstance().set(alleles, EnumFlowerChromosome.PRIMARY, EnumFlowerColor.Red.getFlowerColorAllele());
|
||||
|
||||
@@ -22,15 +22,15 @@ import binnie.core.util.I18N;
|
||||
|
||||
public class ItemDictionary extends Item implements IItemModelRegister {
|
||||
public ItemDictionary() {
|
||||
this.setCreativeTab(CreativeTabBotany.instance);
|
||||
this.setUnlocalizedName("database");
|
||||
this.setMaxStackSize(1);
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
setUnlocalizedName("database");
|
||||
setMaxStackSize(1);
|
||||
setRegistryName("database");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(final Item itemIn, final CreativeTabs tab, final NonNullList<ItemStack> subItems) {
|
||||
public void getSubItems(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> subItems) {
|
||||
super.getSubItems(itemIn, tab, subItems);
|
||||
subItems.add(new ItemStack(itemIn, 1, 1));
|
||||
}
|
||||
@@ -46,15 +46,15 @@ public class ItemDictionary extends Item implements IItemModelRegister {
|
||||
public ActionResult<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) {
|
||||
public String getItemStackDisplayName(ItemStack i) {
|
||||
return I18N.localise("item.botany.database." + ((i.getItemDamage() == 0) ? "name" : "master.name"));
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public class ModuleGenetics implements IInitializable {
|
||||
@Override
|
||||
public void preInit() {
|
||||
/* INIT API*/
|
||||
binnie.botany.api.FlowerManager.flowerFactory = new FlowerFactory();
|
||||
FlowerManager.flowerFactory = new FlowerFactory();
|
||||
AlleleManager.alleleRegistry.registerSpeciesRoot(BotanyCore.getFlowerRoot());
|
||||
AlleleManager.alleleRegistry.registerAllele(ModuleGenetics.alleleEffectNone);
|
||||
EnumFlowerColor.setupMutations();
|
||||
@@ -43,7 +43,7 @@ public class ModuleGenetics implements IInitializable {
|
||||
|
||||
/* BACKPACK*/
|
||||
IBackpackInterface backpackInterface = BackpackManager.backpackInterface;
|
||||
|
||||
|
||||
if (ForestryAPI.enabledPlugins.contains("forestry.storage")) {
|
||||
Predicate<ItemStack> filter = BackpackManager.backpackInterface.createNaturalistBackpackFilter("rootFlowers");
|
||||
BackpackDefinition definition = new BackpackDefinition(new Color(0xf6e83e), Color.WHITE, filter);
|
||||
@@ -56,19 +56,19 @@ public class ModuleGenetics implements IInitializable {
|
||||
}
|
||||
|
||||
/* ITEMS */
|
||||
|
||||
Botany.flower = new BlockFlower();
|
||||
Botany.proxy.registerBlock(Botany.flower);
|
||||
BinnieCore.getBinnieProxy().registerTileEntity(TileEntityFlower.class, "botany.tile.flower", null);
|
||||
|
||||
Botany.flowerItem = new ItemBotany("itemFlower", EnumFlowerStage.FLOWER, "");
|
||||
Botany.pollen = new ItemBotany("pollen", EnumFlowerStage.POLLEN, "pollen");
|
||||
Botany.seed = new ItemBotany("seed", EnumFlowerStage.SEED, "germling");
|
||||
Botany.database = new ItemDictionary();
|
||||
|
||||
Botany.proxy.registerBlock(Botany.flower);
|
||||
Botany.proxy.registerItem(Botany.flowerItem);
|
||||
Botany.proxy.registerItem(Botany.pollen);
|
||||
Botany.proxy.registerItem(Botany.seed);
|
||||
Botany.proxy.registerItem(Botany.database);
|
||||
|
||||
BinnieCore.getBinnieProxy().registerTileEntity(TileEntityFlower.class, "botany.tile.flower", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,25 +80,31 @@ public class ModuleGenetics implements IInitializable {
|
||||
@Override
|
||||
public void postInit() {
|
||||
forestry.api.apiculture.FlowerManager.flowerRegistry.registerAcceptableFlower(Botany.flower, "flowersVanilla");
|
||||
RecipeManagers.carpenterManager.addRecipe(100, Binnie.LIQUID.getFluidStack(ManagerLiquid.WATER, 2000), ItemStack.EMPTY, new ItemStack(Botany.database),
|
||||
"X#X",
|
||||
"YEY",
|
||||
"RDR",
|
||||
'#', Blocks.GLASS_PANE,
|
||||
'X', Items.GOLD_INGOT,
|
||||
'Y', Items.GOLD_NUGGET,
|
||||
'R', Items.REDSTONE,
|
||||
'D', Items.DIAMOND,
|
||||
'E', Items.EMERALD
|
||||
RecipeManagers.carpenterManager.addRecipe(
|
||||
100,
|
||||
Binnie.LIQUID.getFluidStack(ManagerLiquid.WATER, 2000),
|
||||
ItemStack.EMPTY,
|
||||
new ItemStack(Botany.database),
|
||||
"X#X",
|
||||
"YEY",
|
||||
"RDR",
|
||||
'#', Blocks.GLASS_PANE,
|
||||
'X', Items.GOLD_INGOT,
|
||||
'Y', Items.GOLD_NUGGET,
|
||||
'R', Items.REDSTONE,
|
||||
'D', Items.DIAMOND,
|
||||
'E', Items.EMERALD
|
||||
);
|
||||
RecipeUtil.addRecipe(Botany.botanistBackpack,
|
||||
"X#X",
|
||||
"VYZ",
|
||||
"X#X",
|
||||
'#', Blocks.WOOL,
|
||||
'X', Items.STRING,
|
||||
'V', Botany.soilMeter,
|
||||
'Z', "toolTrowel",
|
||||
'Y', "chestWood");
|
||||
RecipeUtil.addRecipe
|
||||
(Botany.botanistBackpack,
|
||||
"X#X",
|
||||
"VYZ",
|
||||
"X#X",
|
||||
'#', Blocks.WOOL,
|
||||
'X', Items.STRING,
|
||||
'V', Botany.soilMeter,
|
||||
'Z', "toolTrowel",
|
||||
'Y', "chestWood"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package binnie.botany.items;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -9,23 +10,24 @@ import binnie.core.item.IItemMiscProvider;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public enum BotanyItems implements IItemMiscProvider {
|
||||
AshPowder("powder_ash"),
|
||||
PulpPowder("powder_pulp"),
|
||||
MulchPowder("powder_mulch"),
|
||||
SulphurPowder("powder_sulphur"),
|
||||
FertiliserPowder("powder_fertiliser"),
|
||||
CompostPowder("powder_compost"),
|
||||
Mortar("mortar"),
|
||||
Weedkiller("weedkiller");
|
||||
POWDER_ASH,
|
||||
POWDER_PULP,
|
||||
POWDER_MULCH,
|
||||
POWDER_SULPHUR,
|
||||
POWDER_FERTILISER,
|
||||
POWDER_COMPOST,
|
||||
MORTAR,
|
||||
WEEDKILLER;
|
||||
|
||||
String name;
|
||||
|
||||
BotanyItems(String name) {
|
||||
this.name = name;
|
||||
BotanyItems() {
|
||||
name = name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(List<String> tooltip) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -40,7 +42,7 @@ public enum BotanyItems implements IItemMiscProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack get(int size) {
|
||||
return new ItemStack(Botany.misc, size, this.ordinal());
|
||||
return new ItemStack(Botany.misc, size, ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,10 +18,10 @@ import binnie.core.util.I18N;
|
||||
|
||||
public class ItemClay extends Item implements IColoredItem, IItemModelRegister {
|
||||
public ItemClay() {
|
||||
this.setUnlocalizedName("botany.clay");
|
||||
this.setHasSubtypes(true);
|
||||
this.setCreativeTab(CreativeTabBotany.instance);
|
||||
this.setRegistryName("clay");
|
||||
setUnlocalizedName("botany.clay");
|
||||
setHasSubtypes(true);
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
setRegistryName("clay");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -40,14 +40,14 @@ public class ItemClay extends Item implements IColoredItem, IItemModelRegister {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack stack) {
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
EnumFlowerColor color = EnumFlowerColor.get(stack.getItemDamage());
|
||||
return I18N.localise("item.botany.clay.name", color.getFlowerColorAllele().getColorName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(final Item itemIn, final CreativeTabs tab, final NonNullList<ItemStack> list) {
|
||||
public void getSubItems(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) {
|
||||
for (EnumFlowerColor color : EnumFlowerColor.values()) {
|
||||
list.add(new ItemStack(this, 1, color.ordinal()));
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ import binnie.core.util.I18N;
|
||||
|
||||
public class ItemPigment extends Item implements IItemModelRegister, IColoredItem {
|
||||
public ItemPigment() {
|
||||
this.setUnlocalizedName("botany.pigment");
|
||||
this.setHasSubtypes(true);
|
||||
this.setCreativeTab(CreativeTabBotany.instance);
|
||||
this.setRegistryName("pigment");
|
||||
setUnlocalizedName("botany.pigment");
|
||||
setHasSubtypes(true);
|
||||
setCreativeTab(CreativeTabBotany.instance);
|
||||
setRegistryName("pigment");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -40,14 +40,14 @@ public class ItemPigment extends Item implements IItemModelRegister, IColoredIte
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack stack) {
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
EnumFlowerColor color = EnumFlowerColor.get(stack.getItemDamage());
|
||||
return I18N.localise("item.botany.pigment.name", color.getFlowerColorAllele().getColorName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(final Item itemIn, final CreativeTabs tab, final NonNullList<ItemStack> list) {
|
||||
public void getSubItems(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) {
|
||||
for (EnumFlowerColor color : EnumFlowerColor.values()) {
|
||||
list.add(new ItemStack(this, 1, color.ordinal()));
|
||||
}
|
||||
|
||||
@@ -11,10 +11,11 @@ import binnie.botany.flower.TileEntityFlower;
|
||||
import binnie.botany.genetics.EnumFlowerColor;
|
||||
import binnie.botany.genetics.EnumFlowerType;
|
||||
|
||||
// TODO unused class?
|
||||
public class PacketFlowerUpdate extends SPacketUpdateTileEntity {
|
||||
public TileEntityFlower.RenderInfo render;
|
||||
|
||||
public PacketFlowerUpdate(BlockPos blockPos, int metadata, NBTTagCompound compound, final TileEntityFlower.RenderInfo render) {
|
||||
public PacketFlowerUpdate(BlockPos blockPos, int metadata, NBTTagCompound compound, TileEntityFlower.RenderInfo render) {
|
||||
super(blockPos, metadata, compound);
|
||||
this.render = render;
|
||||
}
|
||||
@@ -22,27 +23,27 @@ public class PacketFlowerUpdate extends SPacketUpdateTileEntity {
|
||||
@Override
|
||||
public void readPacketData(PacketBuffer buf) throws IOException {
|
||||
super.readPacketData(buf);
|
||||
this.render = new TileEntityFlower.RenderInfo();
|
||||
this.render.primary = EnumFlowerColor.values()[buf.readByte()].getFlowerColorAllele();
|
||||
this.render.secondary = EnumFlowerColor.values()[buf.readByte()].getFlowerColorAllele();
|
||||
this.render.stem = EnumFlowerColor.values()[buf.readByte()].getFlowerColorAllele();
|
||||
this.render.type = EnumFlowerType.values()[buf.readByte()];
|
||||
this.render.age = buf.readByte();
|
||||
this.render.section = buf.readByte();
|
||||
this.render.wilted = buf.readBoolean();
|
||||
this.render.flowered = buf.readBoolean();
|
||||
render = new TileEntityFlower.RenderInfo();
|
||||
render.primary = EnumFlowerColor.values()[buf.readByte()].getFlowerColorAllele();
|
||||
render.secondary = EnumFlowerColor.values()[buf.readByte()].getFlowerColorAllele();
|
||||
render.stem = EnumFlowerColor.values()[buf.readByte()].getFlowerColorAllele();
|
||||
render.type = EnumFlowerType.values()[buf.readByte()];
|
||||
render.age = buf.readByte();
|
||||
render.section = buf.readByte();
|
||||
render.wilted = buf.readBoolean();
|
||||
render.flowered = buf.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacketData(PacketBuffer buf) throws IOException {
|
||||
super.writePacketData(buf);
|
||||
buf.writeByte(this.render.primary.getID());
|
||||
buf.writeByte(this.render.secondary.getID());
|
||||
buf.writeByte(this.render.stem.getID());
|
||||
buf.writeByte(this.render.type.ordinal());
|
||||
buf.writeByte(this.render.age);
|
||||
buf.writeByte(this.render.section);
|
||||
buf.writeBoolean(this.render.wilted);
|
||||
buf.writeBoolean(this.render.flowered);
|
||||
buf.writeByte(render.primary.getID());
|
||||
buf.writeByte(render.secondary.getID());
|
||||
buf.writeByte(render.stem.getID());
|
||||
buf.writeByte(render.type.ordinal());
|
||||
buf.writeByte(render.age);
|
||||
buf.writeByte(render.section);
|
||||
buf.writeBoolean(render.wilted);
|
||||
buf.writeBoolean(render.flowered);
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public enum PacketID implements IPacketID {
|
||||
public void onUseFieldKit(NBTTagCompound data) {
|
||||
EntityPlayer player = BinnieCore.getBinnieProxy().getPlayer();
|
||||
String info = "";
|
||||
if (data == null || data.hasNoTags()) {
|
||||
if (data.hasNoTags()) {
|
||||
info += I18N.localise("botany.flowers.species.not.discover");
|
||||
} else {
|
||||
IAlleleFlowerSpecies primary = (IAlleleFlowerSpecies) AlleleManager.alleleRegistry.getAllele(data.getString("Species"));
|
||||
@@ -42,6 +42,7 @@ public enum PacketID implements IPacketID {
|
||||
if (primary == null || secondary == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
info += I18N.localise("botany.flowers.fielkit.a");
|
||||
if (age == 0.0f) {
|
||||
info += "";
|
||||
@@ -52,16 +53,19 @@ public enum PacketID implements IPacketID {
|
||||
} else {
|
||||
info += " " + I18N.localise("botany.flowers.fielkit.old");
|
||||
}
|
||||
|
||||
if (color1 == color2) {
|
||||
info = info + " " + color1.getName();
|
||||
} else {
|
||||
info = info + " " + color1.getName() + " & " + color2.getName();
|
||||
}
|
||||
|
||||
if (primary == secondary) {
|
||||
info = info + " " + primary.getName();
|
||||
} else {
|
||||
info = info + " " + primary.getName() + "-" + secondary.getName() + " " + I18N.localise("botany.flowers.species.hybrid");
|
||||
}
|
||||
|
||||
if (age == 0.0f) {
|
||||
info += " " + I18N.localise("botany.flowers.species.germling");
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ import binnie.core.triggers.ModuleTrigger;
|
||||
@Mod(
|
||||
modid = Constants.CORE_MOD_ID,
|
||||
name = "Binnie Core",
|
||||
useMetadata = true,
|
||||
version = "@VERSION@",
|
||||
dependencies = "required-after:forge@[13.20.0.2279,);" +
|
||||
"required-after:forestry@[5.3.4.102,);" +
|
||||
"after:jei@[4.3.1,);"
|
||||
|
||||
@@ -5,5 +5,5 @@ public enum Attribute implements IWidgetAttribute {
|
||||
CanFocus,
|
||||
NeedsDeletion,
|
||||
AlwaysOnTop,
|
||||
BlockTooltip;
|
||||
BlockTooltip
|
||||
}
|
||||
@@ -53,9 +53,9 @@ public interface IWidget {
|
||||
|
||||
Point getRelativeMousePosition();
|
||||
|
||||
int getColour();
|
||||
int getColor();
|
||||
|
||||
void setColour(final int p0);
|
||||
void setColor(final int p0);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
void render(int guiWidth, int guiHeight);
|
||||
|
||||
@@ -3,5 +3,5 @@ package binnie.core.craftgui;
|
||||
public enum RenderStage {
|
||||
PreChildren,
|
||||
PostChildren,
|
||||
PostSiblings;
|
||||
PostSiblings
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public class Tooltip {
|
||||
Help,
|
||||
Information,
|
||||
User,
|
||||
Power;
|
||||
Power
|
||||
}
|
||||
|
||||
public interface ITooltipType {
|
||||
|
||||
@@ -209,12 +209,12 @@ public class Widget implements IWidget {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getColour() {
|
||||
public final int getColor() {
|
||||
return this.colour;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setColour(final int colour) {
|
||||
public final void setColor(final int colour) {
|
||||
if (this.colour != colour) {
|
||||
this.colour = colour;
|
||||
this.callEvent(new EventWidget.ChangeColour(this));
|
||||
|
||||
@@ -120,8 +120,8 @@ public class WindowFieldKit extends Window {
|
||||
this.GlassControl = new ControlImage(this, handGlass.x(), handGlass.y(), new StandardTexture(0, 160, 96, 96, ExtraBeeTexture.GUIPunnett));
|
||||
new ControlSlot.Builder(this, handGlass.x() + 54, handGlass.y() + 26).assign(InventoryType.Window, 0);
|
||||
new ControlSlot.Builder(this, 208, 8).assign(InventoryType.Window, 1);
|
||||
(this.text = new ControlText(this, new Point(232, 13), "Paper")).setColour(2236962);
|
||||
(this.text = new ControlText(this, new Area(0, 120, this.width(), 24), "", TextJustification.MiddleCenter)).setColour(2236962);
|
||||
(this.text = new ControlText(this, new Point(232, 13), "Paper")).setColor(2236962);
|
||||
(this.text = new ControlText(this, new Area(0, 120, this.width(), 24), "", TextJustification.MIDDLE_CENTER)).setColor(2236962);
|
||||
this.chromo = new ControlChromosome(this, 150, 24);
|
||||
this.addEventHandler(new EventValueChanged.Handler() {
|
||||
@Override
|
||||
|
||||
@@ -29,7 +29,7 @@ public class ControlCheckbox extends Control implements IControlValue<Boolean> {
|
||||
this.text = text;
|
||||
this.value = bool;
|
||||
if (w > 16) {
|
||||
new ControlText(this, new Area(16, 1, w - 16, 16), text, TextJustification.MiddleCenter).setColour(4473924);
|
||||
new ControlText(this, new Area(16, 1, w - 16, 16), text, TextJustification.MIDDLE_CENTER).setColor(4473924);
|
||||
}
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
this.addEventHandler(new EventMouse.Down.Handler() {
|
||||
|
||||
Loaded 100 of 253 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user