mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-20 04:10:07 +00:00
76 lines
2.1 KiB
Java
76 lines
2.1 KiB
Java
package binnie.botany.ceramic.brick;
|
|
|
|
import com.google.common.base.Preconditions;
|
|
|
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
|
|
import binnie.botany.Botany;
|
|
import binnie.botany.genetics.EnumFlowerColor;
|
|
import binnie.core.block.TileEntityMetadata;
|
|
|
|
public class CeramicBrickPair {
|
|
EnumFlowerColor colorFirst;
|
|
EnumFlowerColor colorSecond;
|
|
CeramicBrickType type;
|
|
int ordinal;
|
|
|
|
CeramicBrickPair(final EnumFlowerColor colorFirst, final EnumFlowerColor colorSecond, CeramicBrickType type) {
|
|
this.colorFirst = colorFirst;
|
|
this.colorSecond = colorSecond;
|
|
this.type = type;
|
|
this.ordinal = colorFirst.ordinal() + colorSecond.ordinal() * 256 + type.ordinal() * 256 * 256;
|
|
}
|
|
|
|
public CeramicBrickPair(ItemStack stack) {
|
|
this(TileEntityMetadata.getItemDamage(stack));
|
|
}
|
|
|
|
public CeramicBrickPair(int id) {
|
|
this.colorFirst = EnumFlowerColor.get(id & 0xFF);
|
|
this.colorSecond = EnumFlowerColor.get(id >> 8 & 0xFF);
|
|
this.type = CeramicBrickType.get(id >> 16 & 0xFF);
|
|
}
|
|
|
|
public boolean isTwoColors() {
|
|
return this.type.canDouble() && this.colorSecond != this.colorFirst;
|
|
}
|
|
|
|
public ItemStack getStack(int i) {
|
|
return new ItemStack(Botany.ceramicBrick, i, this.ordinal());
|
|
}
|
|
|
|
public String getName() {
|
|
String name = this.colorFirst.getFlowerColorAllele().getColorName();
|
|
if (this.type.canDouble() && this.colorSecond != this.colorFirst) {
|
|
name = name + " & " + this.colorSecond.getFlowerColorAllele().getColorName();
|
|
}
|
|
return name + " " + this.type.name;
|
|
}
|
|
|
|
public int ordinal() {
|
|
return ordinal;
|
|
}
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
public TextureAtlasSprite getSprite(int pass) {
|
|
TextureAtlasSprite[] sprites = this.type.sprites;
|
|
Preconditions.checkState(sprites != null, "Sprites have not been registered.");
|
|
return sprites[pass];
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
return Integer.hashCode(ordinal());
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object obj) {
|
|
return obj instanceof CeramicBrickPair
|
|
&& ((CeramicBrickPair) obj).ordinal() == ordinal();
|
|
}
|
|
}
|