Fix OreDrill; fix getting block in ItemList; some changes in addInformation - need check this

This commit is contained in:
Techlone 2017-06-01 20:23:13 +05:00
parent 19f7074897
commit 75a33be210
9 changed files with 50 additions and 51 deletions

View file

@ -684,7 +684,7 @@ public enum ItemList implements IItemContainer {
public Block getBlock() { public Block getBlock() {
if (mHasNotBeenSet) if (mHasNotBeenSet)
throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!");
return GT_Utility.getBlockFromStack(getItem()); return GT_Utility.getBlockFromItem(getItem());
} }
@Override @Override

View file

@ -101,7 +101,7 @@ public class Textures {
BASALT_BRICKS_CRACKED, BASALT_BRICKS_MOSSY, BASALT_BRICKS_CHISELED, BASALT_SMOOTH, OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE, OVERLAY_FRONT_HEAT_EXCHANGER, OVERLAY_FRONT_PROCESSING_ARRAY_ACTIVE, BASALT_BRICKS_CRACKED, BASALT_BRICKS_MOSSY, BASALT_BRICKS_CHISELED, BASALT_SMOOTH, OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE, OVERLAY_FRONT_HEAT_EXCHANGER, OVERLAY_FRONT_PROCESSING_ARRAY_ACTIVE,
OVERLAY_FRONT_PROCESSING_ARRAY, OVERLAY_FRONT_OIL_DRILL_ACTIVE, OVERLAY_FRONT_OIL_DRILL, OVERLAY_FRONT_DIESEL_ENGINE_ACTIVE, OVERLAY_FRONT_DIESEL_ENGINE, OVERLAY_FRONT_PYROLYSE_OVEN_ACTIVE, OVERLAY_FRONT_PROCESSING_ARRAY, OVERLAY_FRONT_OIL_DRILL_ACTIVE, OVERLAY_FRONT_OIL_DRILL, OVERLAY_FRONT_DIESEL_ENGINE_ACTIVE, OVERLAY_FRONT_DIESEL_ENGINE, OVERLAY_FRONT_PYROLYSE_OVEN_ACTIVE,
OVERLAY_FRONT_PYROLYSE_OVEN, OVERLAY_FRONT_OIL_CRACKER_ACTIVE, OVERLAY_FRONT_OIL_CRACKER, OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE, OVERLAY_FRONT_DISTILLATION_TOWER, OVERLAY_FRONT_PYROLYSE_OVEN, OVERLAY_FRONT_OIL_CRACKER_ACTIVE, OVERLAY_FRONT_OIL_CRACKER, OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE, OVERLAY_FRONT_DISTILLATION_TOWER,
OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE, OVERLAY_FRONT_ASSEMBLY_LINE, OVERLAY_FRONT_ADVMINER2_ACTIVE, OVERLAY_FRONT_ADVMINER2, OVERLAY_TOP_CLEANROOM_ACTIVE, OVERLAY_TOP_CLEANROOM; OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE, OVERLAY_FRONT_ASSEMBLY_LINE, OVERLAY_FRONT_ORE_DRILL_ACTIVE, OVERLAY_FRONT_ORE_DRILL, OVERLAY_TOP_CLEANROOM_ACTIVE, OVERLAY_TOP_CLEANROOM;
/** /**
* Icon for Fresh CFoam * Icon for Fresh CFoam

View file

@ -86,10 +86,10 @@ public abstract class MetaTileEntity implements IMetaTileEntity {
GT_LanguageManager.addStringLocalization("gt.blockmachines." + mName + ".name", aRegionalName); GT_LanguageManager.addStringLocalization("gt.blockmachines." + mName + ".name", aRegionalName);
mInventory = new ItemStack[aInvSlotCount]; mInventory = new ItemStack[aInvSlotCount];
if (GT.isClientSide()) { // if (GT.isClientSide()) {
ItemStack tStack = new ItemStack(GregTech_API.sBlockMachines, 1, aID); // ItemStack tStack = new ItemStack(GregTech_API.sBlockMachines, 1, aID);
tStack.getItem().addInformation(tStack, null, new ArrayList<String>(), true); // tStack.getItem().addInformation(tStack, null, new ArrayList<String>(), true);
} // }
} }
/** /**

View file

@ -1018,9 +1018,13 @@ public class GT_Utility {
return (Block) aBlock; return (Block) aBlock;
} }
public static Block getBlockFromStack(Object aStack) { public static Block getBlockFromStack(ItemStack itemStack) {
if (isStackInvalid(aStack)) return Blocks.air; if (isStackInvalid(itemStack)) return Blocks.air;
return Block.getBlockFromItem(((ItemStack) aStack).getItem()); return getBlockFromItem(itemStack.getItem());
}
public static Block getBlockFromItem(Item item) {
return Block.getBlockFromItem(item);
} }
public static boolean isBlockValid(Object aBlock) { public static boolean isBlockValid(Object aBlock) {

View file

@ -33,14 +33,9 @@ public class GT_Item_Machines
if ((tDamage <= 0) || (tDamage >= GregTech_API.METATILEENTITIES.length)) { if ((tDamage <= 0) || (tDamage >= GregTech_API.METATILEENTITIES.length)) {
return; return;
} }
TileEntity temp = GregTech_API.sBlockMachines.createTileEntity(aPlayer == null ? GT_Values.DW : aPlayer.worldObj, GregTech_API.METATILEENTITIES[tDamage] == null ? 0 : GregTech_API.METATILEENTITIES[tDamage].getTileEntityBaseType());
temp.setWorldObj(aPlayer == null ? GT_Values.DW : aPlayer.worldObj); if (GregTech_API.METATILEENTITIES[tDamage] != null) {
temp.xCoord = 0; IGregTechTileEntity tTileEntity = GregTech_API.METATILEENTITIES[tDamage].getBaseMetaTileEntity();
temp.yCoord = 0;
temp.zCoord = 0;
if ((temp instanceof IGregTechTileEntity)) {
IGregTechTileEntity tTileEntity = (IGregTechTileEntity) temp;
tTileEntity.setInitialValuesAsNBT(new NBTTagCompound(), (short) tDamage);
if (tTileEntity.getDescription() != null) { if (tTileEntity.getDescription() != null) {
int i = 0; int i = 0;
for (String tDescription : tTileEntity.getDescription()) { for (String tDescription : tTileEntity.getDescription()) {

View file

@ -36,7 +36,7 @@ public class GT_MetaTileEntity_OreDrillingPlant4 extends GT_MetaTileEntity_OreDr
@Override @Override
protected int getCasingTextureIndex() { protected int getCasingTextureIndex() {
return 50; return 62;
} }
@Override @Override

View file

@ -45,7 +45,7 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
public GT_MetaTileEntity_OreDrillingPlantBase(int aID, String aName, String aNameRegional) { public GT_MetaTileEntity_OreDrillingPlantBase(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional); super(aID, aName, aNameRegional);
//initFields(); initFields();
} }
public GT_MetaTileEntity_OreDrillingPlantBase(String aName) { public GT_MetaTileEntity_OreDrillingPlantBase(String aName) {
@ -54,24 +54,18 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
} }
private void initFields() { private void initFields() {
xDrill = getBaseMetaTileEntity().getXCoord();
yDrill = getBaseMetaTileEntity().getYCoord();
zDrill = getBaseMetaTileEntity().getZCoord();
back = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing());
xCenter = xDrill + back.offsetX;
zCenter = zDrill + back.offsetZ;
isPickingPipes = false;
casingBlock = getCasingBlockItem().getBlock(); casingBlock = getCasingBlockItem().getBlock();
casingMeta = getCasingBlockItem().get(0).getItemDamage(); casingMeta = getCasingBlockItem().get(0).getItemDamage();
frameMeta = 4096 + getFrameMaterial().mMetaItemSubID; int frameId = 4096 + getFrameMaterial().mMetaItemSubID;
frameMeta = GregTech_API.METATILEENTITIES[frameId] != null ? GregTech_API.METATILEENTITIES[frameId].getTileEntityBaseType() : W;
casingTextureIndex = getCasingTextureIndex(); casingTextureIndex = getCasingTextureIndex();
isPickingPipes = false;
} }
public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
if (aSide == aFacing) { if (aSide == aFacing)
return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[16], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_ADVMINER2_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_ADVMINER2)}; return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[casingTextureIndex],new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_ORE_DRILL_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_ORE_DRILL)};
} return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[casingTextureIndex]};
return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[16]};
} }
public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
@ -194,9 +188,7 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
return new ArrayList<ItemStack>() {{ return new ArrayList<ItemStack>() {{
add(new ItemStack(oreBlock, 1, blockMeta)); add(new ItemStack(oreBlock, 1, blockMeta));
}}; }};
} else { } else return oreBlock.getDrops(getBaseMetaTileEntity().getWorld(), posX, posY, posZ, blockMeta, 1);
return oreBlock.getDrops(getBaseMetaTileEntity().getWorld(), posX, posY, posZ, blockMeta, 1);
}
} }
private boolean tryConsumeDrillingFluid() { private boolean tryConsumeDrillingFluid() {
@ -234,12 +226,10 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
if (yHead == yDrill) return; //skip controller block layer if (yHead == yDrill) return; //skip controller block layer
int radius = getRadiusInChunks() << 4; int radius = getRadiusInChunks() << 4;
for (int xOff = -radius; xOff <= radius; xOff++) { for (int xOff = -radius; xOff <= radius; xOff++)
for (int zOff = -radius; zOff <= radius; zOff++) { for (int zOff = -radius; zOff <= radius; zOff++)
tryAddOreBlockToMineList(xDrill + xOff, yHead, zDrill + zOff); tryAddOreBlockToMineList(xDrill + xOff, yHead, zDrill + zOff);
} }
}
}
private void tryAddOreBlockToMineList(int x, int y, int z) { private void tryAddOreBlockToMineList(int x, int y, int z) {
Block block = getBaseMetaTileEntity().getBlock(x, y, z); Block block = getBaseMetaTileEntity().getBlock(x, y, z);
@ -247,16 +237,14 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
ChunkPosition blockPos = new ChunkPosition(x, y, z); ChunkPosition blockPos = new ChunkPosition(x, y, z);
if (block instanceof GT_Block_Ores_Abstract) { if (block instanceof GT_Block_Ores_Abstract) {
TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntity(x, y, z); TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntity(x, y, z);
if (tTileEntity != null && tTileEntity instanceof GT_TileEntity_Ores && ((GT_TileEntity_Ores) tTileEntity).mNatural && !oreBlockPositions.contains(blockPos)) { if (tTileEntity != null && tTileEntity instanceof GT_TileEntity_Ores && ((GT_TileEntity_Ores) tTileEntity).mNatural && !oreBlockPositions.contains(blockPos))
oreBlockPositions.add(blockPos); oreBlockPositions.add(blockPos);
}
} else { } else {
ItemData association = GT_OreDictUnificator.getAssociation(new ItemStack(block, 1, blockMeta)); ItemData association = GT_OreDictUnificator.getAssociation(new ItemStack(block, 1, blockMeta));
if (association != null && association.mPrefix.toString().startsWith("ore") && !oreBlockPositions.contains(blockPos)) { if (association != null && association.mPrefix.toString().startsWith("ore") && !oreBlockPositions.contains(blockPos))
oreBlockPositions.add(blockPos); oreBlockPositions.add(blockPos);
} }
} }
}
private boolean moveOneDown() { private boolean moveOneDown() {
if (!isHasMiningPipes()) return false; if (!isHasMiningPipes()) return false;
@ -282,21 +270,23 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
@Override @Override
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
updateCoordinates();
//check base layer //check base layer
for (int xOff = -1 + back.offsetX; xOff <= 1 + back.offsetX; xOff++) { for (int xOff = -1 + back.offsetX; xOff <= 1 + back.offsetX; xOff++) {
for (int zOff = -1 + back.offsetZ; zOff <= 1 + back.offsetZ; zOff++) { for (int zOff = -1 + back.offsetZ; zOff <= 1 + back.offsetZ; zOff++) {
if (xOff == 0 && zOff == 0) continue; if (xOff == 0 && zOff == 0) continue;
IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xOff, 0, zOff); IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xOff, 0, zOff);
if (addMaintenanceToMachineList(tTileEntity, casingTextureIndex) if (!checkCasingBlock(xOff, 0, zOff)
|| addInputToMachineList(tTileEntity, casingTextureIndex) && !addMaintenanceToMachineList(tTileEntity, casingTextureIndex)
|| addOutputToMachineList(tTileEntity, casingTextureIndex) && !addInputToMachineList(tTileEntity, casingTextureIndex)
|| addEnergyInputToMachineList(tTileEntity, casingTextureIndex)) && !addOutputToMachineList(tTileEntity, casingTextureIndex)
continue; && !addEnergyInputToMachineList(tTileEntity, casingTextureIndex))
return false;
if (!checkCasingBlock(xOff, 0, zOff)) return false;
} }
} }
if (mMaintenanceHatches.isEmpty() || mInputHatches.isEmpty() || mOutputBusses.isEmpty() || mEnergyHatches.isEmpty()) return false;
if (GT_Utility.getTier(getMaxInputVoltage()) < getMinTier()) return false;
//check tower //check tower
for (int yOff = 1; yOff < 4; yOff++) { for (int yOff = 1; yOff < 4; yOff++) {
if (!checkCasingBlock(back.offsetX, yOff, back.offsetZ) if (!checkCasingBlock(back.offsetX, yOff, back.offsetZ)
@ -310,6 +300,15 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
return checkPipesAndSetYHead(); return checkPipesAndSetYHead();
} }
private void updateCoordinates() {
xDrill = getBaseMetaTileEntity().getXCoord();
yDrill = getBaseMetaTileEntity().getYCoord();
zDrill = getBaseMetaTileEntity().getZCoord();
back = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing());
xCenter = xDrill + back.offsetX;
zCenter = zDrill + back.offsetZ;
}
private boolean checkPipesAndSetYHead() { private boolean checkPipesAndSetYHead() {
yHead = yDrill - 1; yHead = yDrill - 1;
while (checkBlockAndMeta(xCenter, yHead, zCenter, miningPipeBlock, W)) yHead--; while (checkBlockAndMeta(xCenter, yHead, zCenter, miningPipeBlock, W)) yHead--;
@ -321,7 +320,7 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
private boolean checkCasingBlock(int xOff, int yOff, int zOff) { private boolean checkCasingBlock(int xOff, int yOff, int zOff) {
return checkBlockAndMetaOffset(xOff, yOff, zOff, casingBlock, casingMeta); return checkBlockAndMetaOffset(xOff, yOff, zOff, casingBlock, casingMeta);
} }
//meta of frame is getTileEntityBaseType; frame should be checked using its drops (possible a high weight operation)
private boolean checkFrameBlock(int xOff, int yOff, int zOff) { private boolean checkFrameBlock(int xOff, int yOff, int zOff) {
return checkBlockAndMetaOffset(xOff, yOff, zOff, GregTech_API.sBlockMachines, frameMeta); return checkBlockAndMetaOffset(xOff, yOff, zOff, GregTech_API.sBlockMachines, frameMeta);
} }
@ -378,7 +377,8 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
"3x1x3 Base of " + casings, "3x1x3 Base of " + casings,
"1x3x1 " + casings + " pillar (Center of base)", "1x3x1 " + casings + " pillar (Center of base)",
"1x3x1 " + getFrameMaterial().mName + " Frame Boxes (Each pillar side and on top)", "1x3x1 " + getFrameMaterial().mName + " Frame Boxes (Each pillar side and on top)",
"1x Input Hatch (Any bottom layer casing)", "1x Input Hatch for drilling fluid (Any bottom layer casing)",
"1x Input Bus for mining pipes (Any bottom layer casing; not necessary)",
"1x Output Bus (Any bottom layer casing)", "1x Output Bus (Any bottom layer casing)",
"1x Maintenance Hatch (Any bottom layer casing)", "1x Maintenance Hatch (Any bottom layer casing)",
"1x " + VN[getMinTier()] + "+ Energy Hatch (Any bottom layer casing)"}; "1x " + VN[getMinTier()] + "+ Energy Hatch (Any bottom layer casing)"};