mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 03:49:29 +00:00
109 lines
3.6 KiB
Java
109 lines
3.6 KiB
Java
package tconstruct.smeltery.blocks;
|
|
|
|
import java.util.List;
|
|
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
import net.minecraft.item.Item;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.util.IIcon;
|
|
import net.minecraft.world.IBlockAccess;
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
import tconstruct.util.config.PHConstruct;
|
|
|
|
public class GlassPaneConnectedMeta extends GlassPaneConnected {
|
|
|
|
private final String[] textures;
|
|
private final IIcon[][] icons;
|
|
private final IIcon[] topIcons;
|
|
private final IIcon[] bottomIcons;
|
|
public static final boolean ignoreMetaForConnectedGlass = PHConstruct.connectedTexturesMode == 2;
|
|
|
|
public GlassPaneConnectedMeta(String location, boolean hasAlpha, String... textures) {
|
|
super(location, hasAlpha);
|
|
this.textures = textures;
|
|
this.icons = new IIcon[textures.length][16];
|
|
this.topIcons = new IIcon[textures.length];
|
|
this.bottomIcons = new IIcon[textures.length];
|
|
}
|
|
|
|
@Override
|
|
@SideOnly(Side.CLIENT)
|
|
public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) {
|
|
int meta = blockAccess.getBlockMetadata(x, y, z);
|
|
if (meta < icons.length) {
|
|
return getConnectedBlockTexture(blockAccess, x, y, z, side, icons[meta]);
|
|
} else {
|
|
return getConnectedBlockTexture(blockAccess, x, y, z, side, icons[0]);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public boolean shouldConnectToBlock(IBlockAccess blockAccess, int x, int y, int z, Block block, int meta) {
|
|
return block == this && (meta == blockAccess.getBlockMetadata(x, y, z) || ignoreMetaForConnectedGlass);
|
|
}
|
|
|
|
@Override
|
|
public IIcon getPaneConnectedTexture(IBlockAccess blockAccess, int x, int y, int z, boolean openUp,
|
|
boolean openDown, boolean openLeft, boolean openRight) {
|
|
int meta = blockAccess.getBlockMetadata(x, y, z);
|
|
IIcon[] icons = meta < this.icons.length ? this.icons[meta] : this.icons[0];
|
|
if (PHConstruct.connectedTexturesMode == 0) {
|
|
return icons[0];
|
|
}
|
|
return getConnectedTexture(icons, openUp, openDown, openLeft, openRight);
|
|
}
|
|
|
|
@Override
|
|
@SideOnly(Side.CLIENT)
|
|
public IIcon getIcon(int side, int meta) {
|
|
if (meta < icons.length) {
|
|
return icons[meta][0];
|
|
} else {
|
|
return icons[0][0];
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void getSubBlocks(Item b, CreativeTabs creativeTabs, List<ItemStack> list) {
|
|
for (int i = 0; i < textures.length; i++) {
|
|
list.add(new ItemStack(b, 1, i));
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void registerBlockIcons(IIconRegister iconRegister) {
|
|
for (int i = 0; i < textures.length; i++) {
|
|
registerBlockIcons(iconRegister, icons[i], folder + "/" + textures[i]);
|
|
topIcons[i] = iconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_top");
|
|
bottomIcons[i] = iconRegister.registerIcon("tinker:glass/" + folder + "/" + textures[i] + "/glass_bottom");
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public IIcon getTopIcon(int meta) {
|
|
if (meta < topIcons.length) {
|
|
return topIcons[meta];
|
|
} else {
|
|
return topIcons[0];
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public IIcon getBottomIcon(int meta) {
|
|
if (meta < bottomIcons.length) {
|
|
return bottomIcons[meta];
|
|
} else {
|
|
return bottomIcons[0];
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public int damageDropped(int meta) {
|
|
return meta;
|
|
}
|
|
}
|