Skip to content

Commit

Permalink
Added documentation to updateTexture in GT_MetaTileEntity_Hatch.
Browse files Browse the repository at this point in the history
Added a function to GT_Utility called addTexturePage(byte page).
Added information about who is using which texture page in GT_Block_Casings1.
Updated GT_Block_Casings5 & GT_Block_Casings8 to utilise texture page 1.
Updated Large Chemical Reactor to reflect this change, now also uses Page 1 Index 48.
Moved the Pyrolyse oven casing index from 111 to 22, which is currently unused and within the Gregtech index space.
  • Loading branch information
draknyte1 committed Oct 8, 2017
1 parent 85044d3 commit f70c7d4
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package gregtech.api.metatileentity.implementations;

import gregtech.GT_Mod;
import gregtech.api.enums.GT_Values;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
Expand Down Expand Up @@ -77,6 +76,14 @@ public void loadNBTData(NBTTagCompound aNBT) {
mMachineBlock=actualTexture;
}

/**
*
* @param textureIndex
* Index between 0-127.
* Add 128 per page, if texture index is not on first page.
*
*/

public final void updateTexture(int textureIndex){
onValueUpdate((byte) textureIndex);
onTexturePageUpdate((byte) (textureIndex>>7));
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/gregtech/api/util/GT_Utility.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
import gregtech.api.enums.GT_Values;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.SubTag;
import gregtech.api.enums.Textures;
import gregtech.api.events.BlockScanningEvent;
import gregtech.api.interfaces.IDebugableBlock;
import gregtech.api.interfaces.IProjectileItem;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.*;
import gregtech.api.items.GT_EnergyArmor_Item;
import gregtech.api.items.GT_Generic_Item;
Expand Down Expand Up @@ -1115,6 +1117,17 @@ public static void removeNullStacksFromInventory(IInventory aInventory) {
aInventory.setInventorySlotContents(i, null);
}
}

/**
* Initializes a new texture page.
*/
public static boolean addTexturePage(byte page){
if(Textures.BlockIcons.casingTexturePages[page]==null){
Textures.BlockIcons.casingTexturePages[page]=new ITexture[128];
return true;
}
return false;
}

/**
* Converts a Number to a String
Expand Down
19 changes: 17 additions & 2 deletions src/main/java/gregtech/common/blocks/GT_Block_Casings1.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,27 @@

public class GT_Block_Casings1
extends GT_Block_Casings_Abstract {

/**
* Texture Index Information
* Textures.BlockIcons.casingTexturePages[0][0-63] - Gregtech
* Textures.BlockIcons.casingTexturePages[0][64-127] - GT++
* Textures.BlockIcons.casingTexturePages[1][0-127] - Gregtech
* Textures.BlockIcons.casingTexturePages[2][0-127] - Free
* Textures.BlockIcons.casingTexturePages[3][0-127] - Free
* Textures.BlockIcons.casingTexturePages[4][0-127] - Free
* Textures.BlockIcons.casingTexturePages[5][0-127] - Free
* Textures.BlockIcons.casingTexturePages[6][0-127] - Free
* Textures.BlockIcons.casingTexturePages[7][0-127] - Free
* Textures.BlockIcons.casingTexturePages[8][0-127] - TecTech
*/


public GT_Block_Casings1() {
super(GT_Item_Casings1.class, "gt.blockcasings", GT_Material_Casings.INSTANCE);
for (byte i = 0; i < 16; i = (byte) (i + 1)) {
for (byte i = 0; i < 16; i = (byte) (i + 1)) {
Textures.BlockIcons.CASING_BLOCKS[i] = new GT_CopiedBlockTexture(this, 6, i);
}
Textures.BlockIcons.CASING_BLOCKS[111] = new GT_CopiedBlockTexture(this, 6, 0,Dyes.MACHINE_METAL.mRGBa);
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "ULV Machine Casing");
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "LV Machine Casing");
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "MV Machine Casing");
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/gregtech/common/blocks/GT_Block_Casings2.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package gregtech.common.blocks;

import gregtech.api.enums.Dyes;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Textures;
import gregtech.api.objects.GT_CopiedBlockTexture;
import gregtech.api.util.GT_LanguageManager;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
Expand All @@ -15,8 +17,11 @@ public class GT_Block_Casings2
public GT_Block_Casings2() {
super(GT_Item_Casings2.class, "gt.blockcasings2", GT_Material_Casings.INSTANCE);
for (byte i = 0; i < 16; i = (byte) (i + 1)) {
Textures.BlockIcons.CASING_BLOCKS[(i + 16)] = new GT_CopiedBlockTexture(this, 6, i);
}
if (i != 6){
Textures.BlockIcons.CASING_BLOCKS[(i + 16)] = new GT_CopiedBlockTexture(this, 6, i);
}
}

GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Solid Steel Machine Casing");
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Frost Proof Machine Casing");
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Bronze Gear Box Casing");
Expand Down Expand Up @@ -49,6 +54,9 @@ public GT_Block_Casings2() {
ItemList.Casing_Pipe_Steel.set(new ItemStack(this, 1, 13));
ItemList.Casing_Pipe_Titanium.set(new ItemStack(this, 1, 14));
ItemList.Casing_Pipe_TungstenSteel.set(new ItemStack(this, 1, 15));

//Special handler for Pyrolyse Oven Casing
Textures.BlockIcons.CASING_BLOCKS[22] = new GT_CopiedBlockTexture(Block.getBlockFromItem(ItemList.Casing_ULV.get(1).getItem()), 6, 0,Dyes.MACHINE_METAL.mRGBa);
}

public IIcon getIcon(int aSide, int aMeta) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/gregtech/common/blocks/GT_Block_Casings5.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@
import gregtech.api.enums.Textures;
import gregtech.api.objects.GT_CopiedBlockTexture;
import gregtech.api.util.GT_LanguageManager;
import gregtech.api.util.GT_Utility;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;

public class GT_Block_Casings5
extends GT_Block_Casings_Abstract {
public GT_Block_Casings5() {
super(GT_Item_Casings5.class, "gt.blockcasings5", GT_Material_Casings.INSTANCE);
GT_Utility.addTexturePage((byte) 1);
for (byte i = 0; i < 16; i = (byte) (i + 1)) {
Textures.BlockIcons.CASING_BLOCKS[(i + 64)] = new GT_CopiedBlockTexture(this, 6, i);
Textures.BlockIcons.casingTexturePages[1][i] = new GT_CopiedBlockTexture(this, 6, i);
}
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Cupronickel Coil Block");
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Kanthal Coil Block");
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/gregtech/common/blocks/GT_Block_Casings8.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public class GT_Block_Casings8
extends GT_Block_Casings_Abstract {
public GT_Block_Casings8() {
super(GT_Item_Casings8.class, "gt.blockcasings8", GT_Material_Casings.INSTANCE);
for (int i = 0; i < 16; i = (i + 1)) {
Textures.BlockIcons.CASING_BLOCKS[(i + 112)] = new GT_CopiedBlockTexture(this, 6, i);
for (int i = 0; i < 1; i = (i + 1)) {
Textures.BlockIcons.casingTexturePages[1][i+48] = new GT_CopiedBlockTexture(this, 6, i);
}
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Chemically Inert Machine Casing");
GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "PTFE Pipe Casing");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_MultiBlockBase {

private static final int CASING_INDEX = 112;

private final int CASING_INDEX = 176;
public GT_MetaTileEntity_LargeChemicalReactor(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
}
Expand Down Expand Up @@ -58,11 +58,11 @@ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide
boolean aRedstone) {
if (aSide == aFacing) {
return new ITexture[] {
Textures.BlockIcons.CASING_BLOCKS[CASING_INDEX],
Textures.BlockIcons.casingTexturePages[1][48],
new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE
: Textures.BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR) };
}
return new ITexture[] { Textures.BlockIcons.CASING_BLOCKS[CASING_INDEX] };
return new ITexture[] { Textures.BlockIcons.casingTexturePages[1][48] };
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package gregtech.common.tileentities.machines.multi;

import gregtech.api.GregTech_API;
import gregtech.api.enums.Dyes;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Textures;
import gregtech.api.gui.GT_GUIContainer_MultiMachine;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
import gregtech.api.objects.GT_CopiedBlockTexture;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import net.minecraft.block.Block;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
Expand All @@ -20,6 +24,9 @@
public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_MultiBlockBase {

private int coilMetaID;
public static GT_CopiedBlockTexture mTextureULV = new GT_CopiedBlockTexture(Block.getBlockFromItem(ItemList.Casing_ULV.get(1).getItem()), 6, 0,Dyes.MACHINE_METAL.mRGBa);

//private final int CASING_INDEX = 22;

public GT_MetaTileEntity_PyrolyseOven(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
Expand Down Expand Up @@ -49,10 +56,9 @@ public String[] getDescription() {

public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
if (aSide == aFacing) {
return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[111],
new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN)};
return new ITexture[]{mTextureULV, new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_PYROLYSE_OVEN)};
}
return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[111]};
return new ITexture[]{mTextureULV};
}

public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
Expand Down Expand Up @@ -127,7 +133,7 @@ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack a
}
}
} else if (h == 3) {// innen decke (ulv casings + input + muffler)
if ((!addInputToMachineList(tTileEntity, 111)) && (!addMufflerToMachineList(tTileEntity, 111))) {
if ((!addInputToMachineList(tTileEntity, 22)) && (!addMufflerToMachineList(tTileEntity, 22))) {
if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != GregTech_API.sBlockCasings1) {
return false;
}
Expand All @@ -142,7 +148,7 @@ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack a
}
} else {// Aeusserer 5x5 ohne hoehe
if (h == 0) {// aussen boden (controller, output, energy, maintainance, rest ulv casings)
if ((!addMaintenanceToMachineList(tTileEntity, 111)) && (!addOutputToMachineList(tTileEntity, 111)) && (!addEnergyInputToMachineList(tTileEntity, 111))) {
if ((!addMaintenanceToMachineList(tTileEntity, 22)) && (!addOutputToMachineList(tTileEntity, 22)) && (!addEnergyInputToMachineList(tTileEntity, 22))) {
if ((xDir + i != 0) || (zDir + j != 0)) {//no controller
if (aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j) != GregTech_API.sBlockCasings1) {
return false;
Expand Down

0 comments on commit f70c7d4

Please sign in to comment.