mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-18 19:39:37 +00:00
Add color to serums
This commit is contained in:
1 parent
14deee0df7
commit
e88822fb3d
3 files changed
+24
-13
No files matched your search
@@ -21,6 +21,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GeneArrayItem implements INbtReadable, INbtWritable, IGeneItem {
|
||||
static final String GENES_NBT = "genes";
|
||||
List<IGene> genes;
|
||||
|
||||
public GeneArrayItem(final ItemStack stack) {
|
||||
@@ -83,12 +84,12 @@ public class GeneArrayItem implements INbtReadable, INbtWritable, IGeneItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound nbt) {
|
||||
public void readFromNBT(@Nullable NBTTagCompound nbt) {
|
||||
this.genes.clear();
|
||||
if (nbt != null) {
|
||||
final NBTTagList list = nbt.getTagList("genes", 10);
|
||||
NBTTagList list = nbt.getTagList(GENES_NBT, 10);
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
final Gene gene = Gene.create(list.getCompoundTagAt(i));
|
||||
Gene gene = Gene.create(list.getCompoundTagAt(i));
|
||||
this.genes.add(gene);
|
||||
}
|
||||
}
|
||||
@@ -99,12 +100,11 @@ public class GeneArrayItem implements INbtReadable, INbtWritable, IGeneItem {
|
||||
if (this.genes.size() == 0) {
|
||||
return nbt;
|
||||
}
|
||||
final NBTTagList list = new NBTTagList();
|
||||
for (final IGene gene : this.genes) {
|
||||
final NBTTagCompound geneNBT = gene.getNBTTagCompound();
|
||||
list.appendTag(geneNBT);
|
||||
NBTTagList list = new NBTTagList();
|
||||
for (IGene gene : this.genes) {
|
||||
list.appendTag(gene.getNBTTagCompound());
|
||||
}
|
||||
nbt.setTag("genes", list);
|
||||
nbt.setTag(GENES_NBT, list);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,11 +14,11 @@ public interface IGeneItem {
|
||||
ISpeciesRoot getSpeciesRoot();
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
void getInfo(final List<String> p0);
|
||||
void getInfo(List<String> info);
|
||||
|
||||
int getColour(final int p0);
|
||||
int getColour(int p0);
|
||||
|
||||
void writeToItem(final ItemStack p0);
|
||||
void writeToItem(ItemStack itemStack);
|
||||
|
||||
void addGene(final IGene p0);
|
||||
void addGene(IGene gene);
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import binnie.core.item.ItemCore;
|
||||
import binnie.genetics.CreativeTabGenetics;
|
||||
import binnie.genetics.Genetics;
|
||||
import binnie.genetics.genetics.IGeneItem;
|
||||
import forestry.core.items.IColoredItem;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -15,7 +16,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ItemGene extends ItemCore {
|
||||
public abstract class ItemGene extends ItemCore implements IColoredItem {
|
||||
|
||||
public ItemGene(String unlocName) {
|
||||
super(unlocName);
|
||||
@@ -56,6 +57,16 @@ public abstract class ItemGene extends ItemCore {
|
||||
@Nullable
|
||||
public abstract IGeneItem getGeneItem(ItemStack itemStack);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
|
||||
IGeneItem gene = this.getGeneItem(stack);
|
||||
if (gene != null) {
|
||||
return gene.getColour(tintIndex);
|
||||
}
|
||||
return 16777215;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getShareTag() {
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user