如何分配自定义红石纹理?

时间:2014-06-24 22:54:59

标签: java minecraft

@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister p_149651_1_)
{
    this.field_150182_M = p_149651_1_.registerIcon(this.getTextureName() + "_" + "cross");
    this.field_150183_N = p_149651_1_.registerIcon(this.getTextureName() + "_" + "line");
    this.field_150184_O = p_149651_1_.registerIcon(this.getTextureName() + "_" + "cross_overlay");
    this.field_150180_P = p_149651_1_.registerIcon(this.getTextureName() + "_" + "line_overlay");
    this.blockIcon = this.field_150182_M;
}

@SideOnly(Side.CLIENT)
public static IIcon getRedstoneWireIcon(String p_150173_0_)
{
    return p_150173_0_.equals("cross") ? ModMain.bluestoneWire.field_150182_M :  (p_150173_0_.equals("line") ? ModMain.bluestoneWire.field_150183_N : (p_150173_0_.equals("cross_overlay") ? ModMain.bluestoneWire.field_150184_O : (p_150173_0_.equals("line_overlay") ? ModMain.bluestoneWire.field_150180_P : null)));
} 

我正在尝试制作自定义的红石类型,但我不知道如何分配纹理。我复制了原始redstone文件中的代码,但我很难理解它。我在所有getRedstoneWireIcon()条款的field_方法中收到错误。这是说它无法解决或不是一个领域。

2 个答案:

答案 0 :(得分:0)

您发布的代码没有任何问题,您需要确保所有变量都匹配,如下所示:

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;

class ModMain
{
    public static BluestoneWire bluestoneWire = new BluestoneWire();
}

public class BluestoneWire
{
    @SideOnly(Side.CLIENT)
    private IIcon field_150182_M;
    @SideOnly(Side.CLIENT)
    private IIcon field_150183_N;
    @SideOnly(Side.CLIENT)
    private IIcon field_150184_O;
    @SideOnly(Side.CLIENT)
    private IIcon field_150180_P;
    @SideOnly(Side.CLIENT)
    private IIcon blockIcon;

    public String getTextureName()
    {
        return "bluestoneWire";
    }

    @SideOnly(Side.CLIENT)
    public void registerBlockIcons(IIconRegister p_149651_1_)
    {
        this.field_150182_M = p_149651_1_.registerIcon(this.getTextureName() + "_" + "cross");
        this.field_150183_N = p_149651_1_.registerIcon(this.getTextureName() + "_" + "line");
        this.field_150184_O = p_149651_1_.registerIcon(this.getTextureName() + "_" + "cross_overlay");
        this.field_150180_P = p_149651_1_.registerIcon(this.getTextureName() + "_" + "line_overlay");
        this.blockIcon = this.field_150182_M;
    }

    @SideOnly(Side.CLIENT)
    public static IIcon getRedstoneWireIcon(String p_150173_0_)
    {
        return p_150173_0_.equals("cross") ? ModMain.bluestoneWire.field_150182_M : (p_150173_0_.equals("line") ? ModMain.bluestoneWire.field_150183_N : (p_150173_0_.equals("cross_overlay") ? ModMain.bluestoneWire.field_150184_O : (p_150173_0_.equals("line_overlay") ? ModMain.bluestoneWire.field_150180_P : null)));
    }
}

答案 1 :(得分:0)

getRedstoneWireIcon替换为:

@SideOnly(Side.CLIENT)
public static IIcon getRedstoneWireIcon(String p_150173_0_)
{
    return p_150173_0_.equals("cross") ? field_150182_M :  (p_150173_0_.equals("line") ? field_150183_N : (p_150173_0_.equals("cross_overlay") ? field_150184_O : (p_150173_0_.equals("line_overlay") ? field_150180_P : null)));
} 

您无法使用ModMain.bluestoneWire.field_,因为每个field_都是私有的。