Skip to content

Commit

Permalink
Merge pull request #9 from S4mpsa/master
Browse files Browse the repository at this point in the history
Add transparent mode to Advanced Information Panels and fix chunk boundary rendering bug
  • Loading branch information
Dream-Master authored Aug 13, 2022
2 parents 35af8dc + e7917da commit 86929c1
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public class GuiAdvancedInfoPanel extends GuiInfoPanel{
private static final int ID_COLORS = 3;
private static final int ID_POWER = 4;
private static final int ID_SETTINGS = 5;
private static final int ID_TRANSPARENCY = 6;
private static final int ID_ROTATELEFT = 7;
private static final int ID_ROTATERIGHT = 8;

private byte activeTab;
private boolean initialized;
Expand Down Expand Up @@ -84,14 +87,20 @@ protected void initControls()
prevCard = card;

//labels
buttonList.add(new IconButton(ID_LABELS, guiLeft + 83 , guiTop + 42, 16, 16, TEXTURE_LOCATION, 192-16, getIconLabelsTopOffset(container.panel.getShowLabels())));
buttonList.add(new IconButton(ID_LABELS, guiLeft + 80 + 18*2 , guiTop + 42 + 18, 16, 16, TEXTURE_LOCATION, 192-16, getIconLabelsTopOffset(container.panel.getShowLabels())));
//slope
buttonList.add(new IconButton(ID_SLOPE, guiLeft + 83 + 17*1, guiTop + 42, 16, 16, TEXTURE_LOCATION, 192, 15));
buttonList.add(new IconButton(ID_SLOPE, guiLeft + 80 + 18*3, guiTop + 42 + 18, 16, 16, TEXTURE_LOCATION, 192, 15));
//colors
buttonList.add(new IconButton(ID_COLORS, guiLeft + 83 + 17*2, guiTop + 42, 16, 16, TEXTURE_LOCATION, 192, 15 + 16));
buttonList.add(new IconButton(ID_COLORS, guiLeft + 80 + 18*2, guiTop + 42, 16, 16, TEXTURE_LOCATION, 192, 15 + 16));
//power
buttonList.add(new IconButton(ID_POWER, guiLeft + 83 + 17*3, guiTop + 42, 16, 16, TEXTURE_LOCATION, 192-16,
buttonList.add(new IconButton(ID_POWER, guiLeft + 80 + 18*3, guiTop + 42, 16, 16, TEXTURE_LOCATION, 192-16,
getIconPowerTopOffset(((TileEntityAdvancedInfoPanel)container.panel).getPowerMode())));
//transparency
buttonList.add(new IconButton(ID_TRANSPARENCY, guiLeft + 80 + 18*4, guiTop + 42 + 18, 16, 16, TEXTURE_LOCATION, 192, 15 + 48));
//rotate left
buttonList.add(new IconButton(ID_ROTATELEFT, guiLeft + 80 + 18*1, guiTop + 42, 16, 16, TEXTURE_LOCATION, 192, 15 + 64));
//rotate right
buttonList.add(new IconButton(ID_ROTATERIGHT, guiLeft + 80 + 18*1, guiTop + 42 + 18, 16, 16, TEXTURE_LOCATION, 192, 15 + 80));

if (card != null && card.getItem() instanceof IPanelDataSource)
{
Expand All @@ -100,7 +109,7 @@ protected void initControls()
if (source instanceof IAdvancedCardSettings)
{
//settings
buttonList.add(new IconButton(ID_SETTINGS, guiLeft + 83 + 17*4, guiTop + 42, 16, 16, TEXTURE_LOCATION, 192, 15 + 16*2));
buttonList.add(new IconButton(ID_SETTINGS, guiLeft + 80 + 18*4, guiTop + 42, 16, 16, TEXTURE_LOCATION, 192, 15 + 16*2));
}
List<PanelSetting> settingsList = null;
if (card.getItem() instanceof IPanelMultiCard)
Expand Down Expand Up @@ -230,6 +239,15 @@ protected void actionPerformed(GuiButton button){
GuiPanelSlope slopeGui = new GuiPanelSlope(this, (TileEntityAdvancedInfoPanel)container.panel);
mc.displayGuiScreen(slopeGui);
break;
case ID_TRANSPARENCY:
((NetworkManager)IC2.network.get()).initiateClientTileEntityEvent(container.panel, ID_TRANSPARENCY);
break;
case ID_ROTATELEFT:
((NetworkManager)IC2.network.get()).initiateClientTileEntityEvent(container.panel, ID_ROTATELEFT);
break;
case ID_ROTATERIGHT:
((NetworkManager)IC2.network.get()).initiateClientTileEntityEvent(container.panel, ID_ROTATERIGHT);
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,9 @@ public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z,
renderer.renderStandardBlock(block, x, y, z);
} else if (tileEntity instanceof TileEntityAdvancedInfoPanelExtender) {
TileEntityAdvancedInfoPanelExtender advancedExtender = (TileEntityAdvancedInfoPanelExtender) tileEntity;
if (advancedExtender.getScreen() == null
|| advancedExtender.getScreen().getCore(
advancedExtender.getWorldObj()) == null)
if (advancedExtender.getNBTLoaded() && !advancedExtender.getPartOfScreen()) {
renderer.renderStandardBlock(block, x, y, z);
}
} else {
renderer.renderStandardBlock(block, x, y, z);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ public void renderTileEntityAt(TileEntity tileEntity, double x, double y,
}
GL11.glRotatef((float) -angleVert, 1, 0, 0);
GL11.glRotatef((float) angleHor, 0, 1, 0);
//Do text rotation here
GL11.glRotatef((float) panel.getTextRotation() * 90.0f, 0, 0, 1);
FontRenderer fontRenderer = this.func_147498_b();

int maxWidth = 1;
Expand All @@ -253,6 +255,11 @@ public void renderTileEntityAt(TileEntity tileEntity, double x, double y,

int lineHeight = fontRenderer.FONT_HEIGHT + 2;
int requiredHeight = lineHeight * joinedData.size();
if (panel.getTextRotation() == 1 || panel.getTextRotation() == 3) {
float tm = displayWidth;
displayWidth = displayHeight;
displayHeight = tm;
}
float scaleX = displayWidth / maxWidth;
float scaleY = displayHeight / requiredHeight;
float scale = Math.min(scaleX, scaleY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,71 +388,75 @@ public void renderScreen(Block block, TileEntityAdvancedInfoPanel panel, double

tess.setBrightness(block.getMixedBrightnessForBlock(panel.getWorldObj(), panel.xCoord, panel.yCoord, panel.zCoord));
tess.setColorOpaque_F(0.5F, 0.5F, 0.5F);
drawFacing(facing, panel.getRotation(), screen, panel, block, tess);

if (panel.getTransparencyMode() == 0) { //Check if face should be transparent
drawFacing(facing, panel.getRotation(), screen, panel, block, tess);
}
//
tess.draw();

//SIDES
Tessellator.instance.startDrawingQuads();
renderer.minecraftRB.renderEngine.bindTexture(TEXTURE_LOCATION);
Tessellator.instance.setBrightness(block.getMixedBrightnessForBlock(panel.getWorldObj(), panel.xCoord, panel.yCoord, panel.zCoord));
Tessellator.instance.setColorOpaque_F(0.5F, 0.5F, 0.5F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

int dx = screen.getDx() + 1;
int dy = screen.getDy() + 1;
int dz = screen.getDz() + 1;

// bottom
if (facing != 0) {
Tessellator.instance.setNormal(0, -1, 0);
addPoint(0, 0, 0);
addPoint(3, dx, 0);
addPoint(2, dx, dz);
addPoint(1, 0, dz);
}
if (panel.getTransparencyMode() == 0) { //Check if block should be transparent
Tessellator.instance.startDrawingQuads();
renderer.minecraftRB.renderEngine.bindTexture(TEXTURE_LOCATION);
Tessellator.instance.setBrightness(block.getMixedBrightnessForBlock(panel.getWorldObj(), panel.xCoord, panel.yCoord, panel.zCoord));
Tessellator.instance.setColorOpaque_F(0.5F, 0.5F, 0.5F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

int dx = screen.getDx() + 1;
int dy = screen.getDy() + 1;
int dz = screen.getDz() + 1;

// bottom
if (facing != 0) {
Tessellator.instance.setNormal(0, -1, 0);
addPoint(0, 0, 0);
addPoint(3, dx, 0);
addPoint(2, dx, dz);
addPoint(1, 0, dz);
}

if (facing != 1) {
Tessellator.instance.setNormal(0, 1, 0);
addPoint(4, 0, 0);
addPoint(5, dz, 0);
addPoint(6, dz, dx);
addPoint(7, 0, dx);
}
if (facing != 1) {
Tessellator.instance.setNormal(0, 1, 0);
addPoint(4, 0, 0);
addPoint(5, dz, 0);
addPoint(6, dz, dx);
addPoint(7, 0, dx);
}

if (facing != 2) {
Tessellator.instance.setNormal(0, 0, -1);
addPoint(0, 0, 0);
addPoint(4, dy, 0);
addPoint(7, dy, dx);
addPoint(3, 0, dx);
}
if (facing != 2) {
Tessellator.instance.setNormal(0, 0, -1);
addPoint(0, 0, 0);
addPoint(4, dy, 0);
addPoint(7, dy, dx);
addPoint(3, 0, dx);
}

if (facing != 3) {
Tessellator.instance.setNormal(0, 0, 1);
addPoint(6, 0, 0);
addPoint(5, dx, 0);
addPoint(1, dx, dy);
addPoint(2, 0, dy);
}
if (facing != 3) {
Tessellator.instance.setNormal(0, 0, 1);
addPoint(6, 0, 0);
addPoint(5, dx, 0);
addPoint(1, dx, dy);
addPoint(2, 0, dy);
}

if (facing != 4) {
Tessellator.instance.setNormal(-1, 0, 0);
addPoint(5, 0, 0);
addPoint(4, dz, 0);
addPoint(0, dz, dy);
addPoint(1, 0, dy);
}
if (facing != 4) {
Tessellator.instance.setNormal(-1, 0, 0);
addPoint(5, 0, 0);
addPoint(4, dz, 0);
addPoint(0, dz, dy);
addPoint(1, 0, dy);
}

if (facing != 5) {
Tessellator.instance.setNormal(1, 0, 0);
addPoint(2, 0, 0);
addPoint(3, dz, 0);
addPoint(7, dz, dy);
addPoint(6, 0, dy);
if (facing != 5) {
Tessellator.instance.setNormal(1, 0, 0);
addPoint(2, 0, 0);
addPoint(3, dz, 0);
addPoint(7, dz, dy);
addPoint(6, 0, dy);
}
Tessellator.instance.draw();
}
Tessellator.instance.draw();

//RETURN TO MC DRAWING
Tessellator.instance.startDrawingQuads();
renderer.minecraftRB.renderEngine.bindTexture(TEXTURE_LOCATION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ public class TileEntityAdvancedInfoPanel extends TileEntityInfoPanel {
private byte prevPowerMode;
public byte powerMode;

private byte prevtransparencyMode;
public byte transparencyMode;

private byte prevThickness;
public byte thickness;

Expand All @@ -27,6 +30,9 @@ public class TileEntityAdvancedInfoPanel extends TileEntityInfoPanel {
private byte prevRotateVert;
public byte rotateVert;

private byte prevTextRotation;
public byte textRotation;

public ItemStack card2;
public ItemStack card3;

Expand All @@ -40,6 +46,9 @@ public class TileEntityAdvancedInfoPanel extends TileEntityInfoPanel {
public static final int POWER_INVERTED = 1;
public static final int POWER_ON = 2;
public static final int POWER_OFF = 3;
public static final int TRANSPARENCY_CHANGED = 6;
public static final int ROTATE_LEFT = 7;
public static final int ROTATE_RIGHT = 8;

public static final int OFFSET_THICKNESS = 100;
public static final int OFFSET_ROTATE_HOR = 200;
Expand Down Expand Up @@ -68,6 +77,32 @@ public void setPowerMode(byte p) {
prevPowerMode = powerMode;
}

public byte getTransparencyMode() {
return transparencyMode;
}

public void setTransparencyMode(byte b) {
if (b == 2) {b = 0;}
transparencyMode = b;
if (prevtransparencyMode != b) {
IC2.network.get().updateTileEntityField(this, "transparencyMode");
}
prevtransparencyMode = transparencyMode;
}
@Override
public byte getTextRotation() {
return textRotation;
}

public void setTextRotation(byte r) {
if (r == -1) {r = 3;} else if (r == 4) {r = 0;}
textRotation = r;
if (prevTextRotation != r) {
IC2.network.get().updateTileEntityField(this, "textRotation");
}
prevTextRotation = textRotation;
}

public void setThickness(byte p) {
thickness = p;
if (prevThickness != p) {
Expand Down Expand Up @@ -110,9 +145,11 @@ public List<String> getNetworkedFields() {
list.add("card2");
list.add("card3");
list.add("powerMode");
list.add("transparencyMode");
list.add("thickness");
list.add("rotateHor");
list.add("rotateVert");
list.add("textRotation");
return list;
}

Expand All @@ -134,6 +171,11 @@ public void onNetworkUpdate(String field) {
} else if (field.equals("thickness") || field.equals("rotateHor")
|| field.equals("rotateVert")) {
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
} else if (field.equals("transparencyMode")) {
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
worldObj.func_147451_t(xCoord, yCoord, zCoord);
} else if (field.equals("textRotation")) {
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}

}
Expand Down Expand Up @@ -194,6 +236,8 @@ protected void saveDisplaySettings(NBTTagCompound nbttagcompound) {
nbttagcompound.setByte("rotateVert", rotateVert);
nbttagcompound.setByte("thickness", thickness);
nbttagcompound.setByte("powerMode", powerMode);
nbttagcompound.setByte("transparencyMode", transparencyMode);
nbttagcompound.setByte("textRotation", transparencyMode);
}

@Override
Expand All @@ -205,6 +249,8 @@ protected void readDisplaySettings(NBTTagCompound nbttagcompound) {
rotateVert = nbttagcompound.getByte("rotateVert");
thickness = nbttagcompound.getByte("thickness");
powerMode = nbttagcompound.getByte("powerMode");
transparencyMode = nbttagcompound.getByte("transparencyMode");
textRotation = nbttagcompound.getByte("textRotation");
}

@Override
Expand Down Expand Up @@ -259,6 +305,16 @@ public void onNetworkEvent(EntityPlayer entityplayer, int i) {
case POWER_REDSTONE:
case POWER_INVERTED:
setPowerMode((byte) i);
break;
case TRANSPARENCY_CHANGED:
setTransparencyMode((byte) (getTransparencyMode() + 1));
break;
case ROTATE_LEFT:
setTextRotation((byte) (textRotation - 1));
break;
case ROTATE_RIGHT:
setTextRotation((byte) (textRotation + 1));
break;
}
} else if (i >= OFFSET_THICKNESS && i < OFFSET_THICKNESS + 100) {
i -= OFFSET_THICKNESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ public boolean getColored() {
return colored;
}

public byte getTextRotation() {
return 0;
}

public void setIsWeb(boolean c) {
isWeb = c;
if (prevIsWeb != c) {
Expand Down
Loading

0 comments on commit 86929c1

Please sign in to comment.