- 103
- 2
- 2
Хочу чтобы в GUI можно было переключать кнопкой режимы (работать по сигналу редстоуна/работать всегда). Я почти это сделал (мне так кажется), но я не знаю как сделать кнопку и как в TE переключать переменную redstonecontrol. Ниже я приведу методы которые я пытался использовать. Текстура меняется если менять переменную в TE через класс.
blockbreaker tileentity:
public int redstoneControl = 1;
protected final IIntArray blockbreakerData = new IIntArray() {
public int get(int index) {
switch(index) {
case 0:
return redstoneControl;
default:
return 0;
}
}
public void set(int index, int value) {
switch(index) {
case 0:
redstoneControl = value;
break;
}
}
public int size() {
return 1;
}
@Override
public void read(CompoundNBT tag) {
super.read(tag);
this.redstoneControl = tag.getInt("redstonecontrol");
}
@Override
public CompoundNBT write(CompoundNBT tag) {
super.write(tag);
tag.putInt("redstonecontrol", this.redstoneControl);
return tag;
}
};
blockbreaker container:
this.redstoneSignal = tileEntity.blockbreakerData.get(0);
blockbreaker gui:
@Override
protected void drawGuiContainerForegroundLayer(final int mouseX, final int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
String s = this.title.getFormattedText();
int textWidth = font.getStringWidth(s);
int centerX = (this.xSize / 2) - (textWidth / 2);
this.font.drawString(s, centerX, 6.0F, 0x404040);
this.font.drawString(this.playerInventory.getDisplayName().getFormattedText(), 8.0F, (float) (this.ySize - 93), 0x404040);
getMinecraft().getTextureManager().bindTexture(BACKGROUND_TEXTURE);
if (this.container.redstoneSignal == 1) {
this.blit(133, 35, 176, 0, 18, 18);//x,y,texturex,texturey,width,height
}else{
this.blit(133, 35, 194, 0, 18, 18);//x,y,texturex,texturey,width,height
}
}
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton)
{
super.mouseClicked(mouseX, mouseY, mouseButton);
double mx = mouseX;
double my = mouseY;
if (mx >= 139 && my >= 35 && mx < 157 && my < 53)
{
this.minecraft.playerController.sendEnchantPacket((this.container).windowId, 0);
}
return super.mouseClicked(mouseX, mouseY, mouseButton);
}