Adding more flower models

This commit is contained in:
Nedelosk committed 2016-10-26 16:24:17 +02:00
1 parent 2a23e60cdb
commit fb732b9398
92 files changed
+750 -219

No files matched your search

@@ -23,7 +23,7 @@ public interface IAlleleFlowerSpecies extends IAlleleSpecies, IAlleleProperty<IA
@Nonnull
@SideOnly(Side.CLIENT)
ModelResourceLocation getFlowerModel(EnumFlowerStage type, boolean flowered, int section);
ModelResourceLocation getFlowerModel(EnumFlowerStage type, boolean flowered);
@SideOnly(Side.CLIENT)
void registerModels(Item item, IModelManager manager, EnumFlowerStage type);
@@ -15,7 +15,7 @@ public interface IFlowerType<I extends IFlowerType> extends Comparable<I> {
@Nonnull
@SideOnly(Side.CLIENT)
ModelResourceLocation getModel(EnumFlowerStage type, boolean flowered, int section);
ModelResourceLocation getModel(EnumFlowerStage type, boolean flowered);
String getName();
@@ -3,10 +3,10 @@ package binnie.botany.core;
import binnie.botany.api.FlowerManager;
import binnie.botany.api.IFlowerRoot;
import binnie.botany.genetics.FlowerRoot;
import forestry.api.genetics.AlleleManager;
public class BotanyCore {
public static final int CHANCE_INTERPOLLINATION = 20;
public static IFlowerRoot speciesRoot;
public static IFlowerRoot getFlowerRoot() {
if(FlowerManager.flowerRoot == null){
@@ -51,6 +51,7 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IItemM
public static final PropertyFlower FLOWER = new PropertyFlower("flower", IFlowerType.class);
public static final PropertyInteger SECTION = PropertyInteger.create("section", 0, EnumFlowerType.highestSection - 1);
public static final PropertyBool FLOWERED = PropertyBool.create("flowered");
public static final PropertyBool SEED = PropertyBool.create("seed");
public BlockFlower() {
super(Material.PLANTS);
@@ -96,10 +97,15 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IItemM
return FLOWER_BLOCK_AABB;
}
@Override
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public boolean isOpaqueCube(IBlockState state){
return false;
}
@Override
public boolean isFullCube(IBlockState state){
return false;
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
@@ -127,15 +133,17 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IItemM
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockState state, IBlockAccess world, BlockPos pos, int tintIndex) {
final TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityFlower) {
TileEntityFlower flower = (TileEntityFlower) tile;
if(tintIndex == 0){
return flower.getStemColour();
}else if(tintIndex == 1){
return flower.getPrimaryColour();
}else{
return flower.getSecondaryColour();
if(pos != null){
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityFlower) {
TileEntityFlower flower = (TileEntityFlower) tile;
if(tintIndex == 0){
return flower.getStemColour();
}else if(tintIndex == 1){
return flower.getPrimaryColour();
}else{
return flower.getSecondaryColour();
}
}
}
return 16777215;
@@ -179,16 +187,18 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IItemM
state = state.withProperty(FLOWER, flower.getType());
state = state.withProperty(FLOWERED, flower.isFlowered());
state = state.withProperty(SECTION, flower.getRenderSection());
state = state.withProperty(SEED, flower.getAge() == 0);
}else{
state = state.withProperty(FLOWER, FlowerDefinition.Dandelion.getSpecies().getType());
state = state.withProperty(FLOWERED, false);
state = state.withProperty(SEED, false);
}
return state;
}
@Override
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, FLOWER, FLOWERED, SECTION);
return new BlockStateContainer(this, FLOWER, FLOWERED, SECTION, SEED);
}
@Override
@@ -151,7 +151,7 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
final IFlower flower = BotanyCore.speciesRoot.getMember(stack);
IFlower flower = BotanyCore.getFlowerRoot().getMember(stack);
if (flower == null || flower.getGenome() == null) {
return 16777215;
}
@@ -174,7 +174,7 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
}
IAlleleFlowerSpecies flowerSpecies = flower.getGenome().getPrimary();
IFlowerType flowerType = flowerSpecies.getType();
return flowerSpecies.getFlowerModel(type, flower.hasFlowered(), flowerType.getSections() - 1);
return flowerSpecies.getFlowerModel(type, flower.hasFlowered());
}
}
@@ -10,75 +10,65 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List;
public class ItemInsulatedTube extends Item {
// IIcon[] icons;
import binnie.botany.CreativeTabBotany;
import binnie.core.item.ItemCore;
import forestry.api.core.IModelManager;
import forestry.core.items.IColoredItem;
public class ItemInsulatedTube extends ItemCore implements IColoredItem {
public ItemInsulatedTube() {
setRegistryName("insulatedTube");
super("insulatedTube");
setUnlocalizedName("insulatedTube");
setCreativeTab(CreativeTabBotany.instance);
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(final Item p_150895_1_, final CreativeTabs p_150895_2_, final List p_150895_3_) {
for (final Material mat : Material.values()) {
for (final Insulate ins : Insulate.values()) {
p_150895_3_.add(new ItemStack(this, 1, mat.ordinal() + ins.ordinal() * 128));
public void getSubItems(Item item, CreativeTabs tab, List subItems) {
for (Material mat : Material.values()) {
for (Insulate ins : Insulate.values()) {
subItems.add(new ItemStack(this, 1, mat.ordinal() + ins.ordinal() * 128));
}
}
}
// @Override
// @SideOnly(Side.CLIENT)
// public void registerIcons(final IIconRegister p_94581_1_) {
// for (int i = 0; i < 3; ++i) {
// this.icons[i] = Botany.proxy.getIcon(p_94581_1_, "insulatedTube." + i);
// }
// }
//
// @Override
// @SideOnly(Side.CLIENT)
// public int getColorFromItemStack(final ItemStack stack, final int pass) {
// return (pass == 0) ? 16777215 : ((pass == 1) ? Material.get(stack.getItemDamage()).getColor() : Insulate.get(stack.getItemDamage()).getColor());
// }
@SideOnly(Side.CLIENT)
@Override
public void registerModel(Item item, IModelManager manager) {
for (Material mat : Material.values()) {
for (Insulate ins : Insulate.values()) {
manager.registerItemModel(item, mat.ordinal() + ins.ordinal() * 128);
}
}
}
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
if(tintIndex == 0){
return 16777215;
}else if(tintIndex == 1){
Material.get(stack.getItemDamage()).getColor();
}
return Insulate.get(stack.getItemDamage()).getColor();
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(final ItemStack p_77624_1_, final EntityPlayer p_77624_2_, final List p_77624_3_, final boolean p_77624_4_) {
super.addInformation(p_77624_1_, p_77624_2_, p_77624_3_, p_77624_4_);
p_77624_3_.add(Insulate.get(p_77624_1_.getItemDamage()).getName());
public void addInformation(ItemStack itemStack, EntityPlayer player, List tooltip, boolean advanced) {
tooltip.add(Insulate.get(itemStack.getItemDamage()).getName());
}
@Override
public String getItemStackDisplayName(final ItemStack p_77653_1_) {
public String getItemStackDisplayName(ItemStack p_77653_1_) {
return Material.get(p_77653_1_.getItemDamage()).getName() + " Insulated Tube";
}
// @Override
// public int getRenderPasses(final int metadata) {
// return 3;
// }
//
// @Override
// public IIcon getIcon(final ItemStack stack, final int pass) {
// return this.icons[pass % 3];
// }
//
// @Override
// public boolean requiresMultipleRenderPasses() {
// return true;
// }
//
// public ItemInsulatedTube() {
// this.icons = new IIcon[3];
// this.setUnlocalizedName("insulatedTube");
// this.setCreativeTab(CreativeTabBotany.instance);
// }
public static String getInsulate(final ItemStack stack) {
public static String getInsulate(ItemStack stack) {
return Insulate.get(stack.getItemDamage()).getName();
}
public static ItemStack getInsulateStack(final ItemStack stack) {
public static ItemStack getInsulateStack(ItemStack stack) {
return Insulate.get(stack.getItemDamage()).getStack();
}
@@ -24,6 +24,13 @@ public class StateMapperFlower extends StateMapperBase {
}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);
properties.remove(BlockFlower.FLOWERED);
}else{
properties.remove(BlockFlower.SEED);
}
return new ModelResourceLocation(Constants.BOTANY_MOD_ID + ":flower", getPropertyString(properties));
}
@@ -26,6 +26,7 @@ import forestry.api.genetics.IPollinatable;
import forestry.api.lepidopterology.IButterfly;
import forestry.api.lepidopterology.IButterflyNursery;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -56,48 +57,62 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
this.renderInfo = null;
this.matureTime = 0;
}
@Override
public void readFromNBT(final NBTTagCompound nbttagcompound) {
this.flower = new Flower(nbttagcompound);
this.section = nbttagcompound.getByte("section");
if (this.flower.getAge() == 0) {
this.flower.setFlowered(false);
}
this.owner = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("owner"));
if (nbttagcompound.hasKey("CATER") && BinnieCore.isLepidopteryActive()) {
this.matureTime = nbttagcompound.getInteger("caterTime");
this.caterpillar = Binnie.Genetics.getButterflyRoot().getMember(nbttagcompound.getCompoundTag("cater"));
}
super.readFromNBT(nbttagcompound);
public NBTTagCompound getUpdateTag() {
updateRender(true);
return super.getUpdateTag();
}
@Override
public NBTTagCompound writeToNBT(final NBTTagCompound nbttagcompound) {
public void readFromNBT(final NBTTagCompound nbtCompound) {
if(nbtCompound.hasKey("Flower")){
this.flower = new Flower(nbtCompound.getCompoundTag("Flower"));
if (flower.getAge() == 0) {
flower.setFlowered(false);
}
}
if(nbtCompound.hasKey("section")){
this.section = nbtCompound.getByte("section");
}
if(nbtCompound.hasKey("owner")){
this.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"));
}
super.readFromNBT(nbtCompound);
}
@Override
public NBTTagCompound writeToNBT(final NBTTagCompound nbtCompound) {
if (this.flower != null) {
this.flower.writeToNBT(nbttagcompound);
nbtCompound.setTag("Flower", flower.writeToNBT(new NBTTagCompound()));
}
if (this.owner != null) {
final NBTTagCompound nbt = new NBTTagCompound();
NBTUtil.writeGameProfile(nbt, this.owner);
nbttagcompound.setTag("owner", nbt);
nbtCompound.setTag("owner", nbt);
}
if (this.caterpillar != null) {
nbttagcompound.setInteger("caterTime", this.matureTime);
nbtCompound.setInteger("caterTime", this.matureTime);
final NBTTagCompound subcompound = new NBTTagCompound();
this.caterpillar.writeToNBT(subcompound);
nbttagcompound.setTag("cater", subcompound);
nbtCompound.setTag("cater", subcompound);
}
nbttagcompound.setByte("section", (byte) this.getSection());
return super.writeToNBT(nbttagcompound);
nbtCompound.setByte("section", (byte) getSection());
return super.writeToNBT(nbtCompound);
}
public void create(final ItemStack stack, final GameProfile owner) {
this.create(BotanyCore.getFlowerRoot().getMember(stack), owner);
}
public void create(final IFlower stack, final GameProfile owner) {
this.flower = stack;
public void create(final IFlower flower, final GameProfile owner) {
this.flower = flower;
if (this.flower.getAge() == 0) {
this.flower.setFlowered(false);
}
@@ -536,8 +551,12 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
public void setRender(final RenderInfo render) {
this.renderInfo = render;
this.section = this.renderInfo.section;
worldObj.markBlockRangeForRenderUpdate(pos, pos);
worldObj.markChunkDirty(pos, this);
if(!worldObj.isRemote){
IBlockState blockState = worldObj.getBlockState(pos);
worldObj.notifyBlockUpdate(pos, blockState, blockState, 0);
}else{
worldObj.markBlockRangeForRenderUpdate(pos, pos);
}
}
public int getAge() {
@@ -84,8 +84,8 @@ public class AlleleFlowerSpecies extends AlleleSpecies implements IAlleleFlowerS
}
@Override
public ModelResourceLocation getFlowerModel(EnumFlowerStage type, boolean flowered, int section) {
return flowerType.getModel(type, flowered, section);
public ModelResourceLocation getFlowerModel(EnumFlowerStage type, boolean flowered) {
return flowerType.getModel(type, flowered);
}
@Override
@@ -6,6 +6,7 @@ import binnie.Constants;
import binnie.botany.api.EnumFlowerStage;
import binnie.botany.api.IFlowerType;
import forestry.api.core.IModelManager;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.Side;
@@ -63,8 +64,7 @@ public enum EnumFlowerType implements IFlowerType<EnumFlowerType> {
public static int highestSection = 2;
int sections;
ModelResourceLocation[] flowered;
ModelResourceLocation[] unflowered;
ModelResourceLocation flower;
ModelResourceLocation seed;
ModelResourceLocation pollen;
@@ -74,36 +74,27 @@ public enum EnumFlowerType implements IFlowerType<EnumFlowerType> {
EnumFlowerType(final int sections) {
this.sections = sections;
this.flowered = new ModelResourceLocation[sections];
this.unflowered = new ModelResourceLocation[sections];
}
@Override
@SideOnly(Side.CLIENT)
public void registerModels(Item item, IModelManager manager, EnumFlowerStage type){
for (int i = 0; i < this.sections; ++i) {
final String suf = (i == 0) ? "" : ("" + (i + 1));
final String pre = (this.sections == 1) ? "" : "double/";
this.flowered[i] = new ModelResourceLocation(Constants.BOTANY_MOD_ID, "flowers/" + pre + this.toString().toLowerCase() + suf + "_flowered");
this.unflowered[i] = new ModelResourceLocation(Constants.BOTANY_MOD_ID, "flowers/" + pre + this.toString().toLowerCase() + suf + "_unflowered");
}
this.seed = new ModelResourceLocation(Constants.BOTANY_MOD_ID, "flowers/seed");
this.pollen = new ModelResourceLocation(Constants.BOTANY_MOD_ID, "flowers/pollen");
String pre = (this.sections == 1) ? "" : "double/";
flower = new ModelResourceLocation(Constants.BOTANY_MOD_ID + "flowers/" + pre + this.toString().toLowerCase(), "inventory");
seed = new ModelResourceLocation(Constants.BOTANY_MOD_ID + ":flowers/seed", "inventory");
pollen = new ModelResourceLocation(Constants.BOTANY_MOD_ID + ":flowers/pollen", "inventory");
ModelBakery.registerItemVariants(item, pollen, seed, flower);
}
@SideOnly(Side.CLIENT)
@Override
public ModelResourceLocation getModel(EnumFlowerStage type, boolean flowered, int section) {
public ModelResourceLocation getModel(EnumFlowerStage type, boolean flowered) {
if(type == EnumFlowerStage.SEED){
return seed;
}else if(type == EnumFlowerStage.POLLEN){
return pollen;
}else{
if(flowered){
return this.flowered[section % this.sections];
}else{
return unflowered[section % this.sections];
}
return flower;
}
}
@@ -927,6 +927,7 @@ public enum FlowerDefinition implements IFlowerDefinition {
String branchName;
List<IAllele[]> variantTemplates;
IClassification branch;
EnumFlowerColor primaryColor, secondaryColor;
private static void setupVariants() {
IFlowerRoot flowerRood = BotanyCore.getFlowerRoot();
@@ -973,6 +974,8 @@ public enum FlowerDefinition implements IFlowerDefinition {
this.binomial = binomial;
this.branchName = branch;
this.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);
@@ -1070,6 +1073,8 @@ public enum FlowerDefinition implements IFlowerDefinition {
template = Arrays.copyOf(FlowerTemplates.getDefaultTemplate(), EnumFlowerChromosome.values().length);
AlleleHelper.instance.set(template, EnumFlowerChromosome.SPECIES, species);
AlleleHelper.instance.set(template, EnumFlowerChromosome.TEMPERATURE_TOLERANCE, EnumAllele.Tolerance.BOTH_1);
AlleleHelper.instance.set(template, EnumFlowerChromosome.PRIMARY, primaryColor);
AlleleHelper.instance.set(template, EnumFlowerChromosome.SECONDARY, secondaryColor);
setAlleles(template);
genome = BotanyCore.getFlowerRoot().templateAsGenome(template);
@@ -8,7 +8,8 @@ import forestry.core.genetics.alleles.EnumAllele;
public class FlowerTemplates {
public static IAllele[] getDefaultTemplate() {
final IAllele[] alleles = new IAllele[EnumFlowerChromosome.values().length];
AlleleHelper.instance.set(alleles, EnumFlowerChromosome.SPECIES, FlowerDefinition.Dandelion.getSpecies());
//TODO: Test flower reset
AlleleHelper.instance.set(alleles, EnumFlowerChromosome.SPECIES, FlowerDefinition.Poppy.getSpecies());
AlleleHelper.instance.set(alleles, EnumFlowerChromosome.PRIMARY, EnumFlowerColor.Red);
AlleleHelper.instance.set(alleles, EnumFlowerChromosome.SECONDARY, EnumFlowerColor.Red);
AlleleHelper.instance.set(alleles, EnumFlowerChromosome.FERTILITY, EnumAllele.Fertility.NORMAL);