Some ODP fixes, energy checking, add radius in tooltip, add "missing pipes" message for II-IV tiers

change build.gradle for debugging in IDEA
This commit is contained in:
Techlone 2017-06-02 22:18:29 +05:00
parent 067f4491a8
commit c5402ee389
5 changed files with 61 additions and 39 deletions

1
.gitignore vendored
View file

@ -70,6 +70,7 @@ local.properties
.idea/ .idea/
.idea_modules/ .idea_modules/
classes/
/out/ /out/
gradle/wrapper/gradle-wrapper.properties gradle/wrapper/gradle-wrapper.properties

View file

@ -37,6 +37,8 @@ minecraft {
runDir = "eclipse" runDir = "eclipse"
} }
idea { module { inheritOutputDirs = true } }
configurations { configurations {
provided provided
embedded embedded

View file

@ -53,18 +53,18 @@ public class GT_GUIContainer_MultiMachine extends GT_GUIContainerMetaTile_Machin
} else { } else {
fontRendererObj.drawString("Running perfectly.", 10, 16, 16448255); fontRendererObj.drawString("Running perfectly.", 10, 16, 16448255);
} }
int id = mContainer.mTileEntity.getMetaTileID(); int id = mContainer.mTileEntity.getMetaTileID();
if(id == 1157 || id == 1158){ if (id == 1157 || id == 1158 || id == 1177 || id == 1178 || id == 1179) {
ItemStack tItem = mContainer.mTileEntity.getMetaTileEntity().getStackInSlot(1); ItemStack tItem = mContainer.mTileEntity.getMetaTileEntity().getStackInSlot(1);
if(tItem==null || !GT_Utility.areStacksEqual(tItem, GT_ModHandler.getIC2Item("miningPipe", 1L))){ if (tItem == null || !GT_Utility.areStacksEqual(tItem, GT_ModHandler.getIC2Item("miningPipe", 1L))) {
fontRendererObj.drawString("Missing Mining Pipe", 10,((GT_Container_MultiMachine) mContainer).mActive == 0 ? 40 : 24, 16448255); fontRendererObj.drawString("Missing Mining Pipe", 10, ((GT_Container_MultiMachine) mContainer).mActive == 0 ? 40 : 24, 16448255);
}
}else if(id == 1131 || id == 1151 || id == 1152 || id == 1153){
ItemStack tItem = mContainer.mTileEntity.getMetaTileEntity().getStackInSlot(1);
if(tItem==null || !(tItem.getItem()==GT_MetaGenerated_Tool_01.INSTANCE&&tItem.getItemDamage()>=170&&tItem.getItemDamage()<=177)){
fontRendererObj.drawString("Missing Turbine Rotor", 10, ((GT_Container_MultiMachine) mContainer).mActive == 0 ? 40 : 24, 16448255);
}
} }
} else if (id == 1131 || id == 1151 || id == 1152 || id == 1153) {
ItemStack tItem = mContainer.mTileEntity.getMetaTileEntity().getStackInSlot(1);
if (tItem == null || !(tItem.getItem() == GT_MetaGenerated_Tool_01.INSTANCE && tItem.getItemDamage() >= 170 && tItem.getItemDamage() <= 177)) {
fontRendererObj.drawString("Missing Turbine Rotor", 10, ((GT_Container_MultiMachine) mContainer).mActive == 0 ? 40 : 24, 16448255);
}
}
} }
} }
} }

View file

@ -1971,11 +1971,6 @@ public class GT_Utility {
return result; return result;
} }
@SuppressWarnings("unchecked")
public static <T> T[] listToArray(List<T> list) {
return (T[]) list.toArray();
}
public static class ItemNBT { public static class ItemNBT {
public static void setNBT(ItemStack aStack, NBTTagCompound aNBT) { public static void setNBT(ItemStack aStack, NBTTagCompound aNBT) {
if (aNBT == null) { if (aNBT == null) {

View file

@ -1,14 +1,21 @@
package gregtech.common.tileentities.machines.multi; package gregtech.common.tileentities.machines.multi;
import gregtech.api.GregTech_API; import gregtech.api.GregTech_API;
import gregtech.api.enums.*; import gregtech.api.enums.ItemList;
import gregtech.api.enums.Materials;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.enums.Textures;
import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.gui.GT_GUIContainer_MultiMachine;
import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.objects.ItemData; import gregtech.api.objects.ItemData;
import gregtech.api.util.*; import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import gregtech.common.blocks.GT_Block_Ores_Abstract; import gregtech.common.blocks.GT_Block_Ores_Abstract;
import gregtech.common.blocks.GT_TileEntity_Ores; import gregtech.common.blocks.GT_TileEntity_Ores;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -23,9 +30,7 @@ import net.minecraftforge.fluids.FluidStack;
import java.util.ArrayList; import java.util.ArrayList;
import static gregtech.api.enums.GT_Values.V; import static gregtech.api.enums.GT_Values.*;
import static gregtech.api.enums.GT_Values.VN;
import static gregtech.api.enums.GT_Values.W;
public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTileEntity_MultiBlockBase { public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTileEntity_MultiBlockBase {
private static final ItemStack miningPipe = GT_ModHandler.getIC2Item("miningPipe", 0); private static final ItemStack miningPipe = GT_ModHandler.getIC2Item("miningPipe", 0);
@ -88,27 +93,33 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
@Override @Override
public boolean checkRecipe(ItemStack aStack) { public boolean checkRecipe(ItemStack aStack) {
setElectricityStats();
if (!checkPipesAndSetYHead() || !isEnergyEnough()) {
stopMachine();
return false;
}
if (isPickingPipes) { if (isPickingPipes) {
if (tryPickPipe()) { if (tryPickPipe()) {
mOutputItems = new ItemStack[] {GT_Utility.copyAmount(1, miningPipe)}; mOutputItems = new ItemStack[] {GT_Utility.copyAmount(1, miningPipe)};
setElectricityStats();
return true; return true;
} else { } else {
isPickingPipes = false;
stopMachine(); stopMachine();
return false; return false;
} }
} }
putMiningPipesFromInputsInController(); putMiningPipesFromInputsInController();
if (!tryConsumeDrillingFluid()) return false; if (!tryConsumeDrillingFluid()) return false;
fillMineListIfEmpty(); fillMineListIfEmpty();
if (oreBlockPositions.isEmpty()) { if (oreBlockPositions.isEmpty()) {
boolean isMoved = moveOneDown(); if (!tryLowerPipe()) {
if (!isMoved) {
isPickingPipes = true; isPickingPipes = true;
setElectricityStats();
return true; return true;
} }
//new layer - fill again
fillMineListIfEmpty();
} }
ChunkPosition oreBlockPos = null; ChunkPosition oreBlockPos = null;
@ -125,10 +136,18 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
mOutputItems = getOutputByDrops(oreBlockDrops); mOutputItems = getOutputByDrops(oreBlockDrops);
} }
setElectricityStats();
return true; return true;
} }
private boolean isEnergyEnough() {
long requiredEnergy = 512 + getMaxInputVoltage() * 4;
for (GT_MetaTileEntity_Hatch_Energy energyHatch : mEnergyHatches) {
requiredEnergy -= energyHatch.getEUVar();
if (requiredEnergy <= 0) return true;
}
return false;
}
private boolean tryPickPipe() { private boolean tryPickPipe() {
if (yHead == yDrill) return false; if (yHead == yDrill) return false;
if (checkBlockAndMeta(xCenter, yHead + 1, zCenter, miningPipeBlock, W)) if (checkBlockAndMeta(xCenter, yHead + 1, zCenter, miningPipeBlock, W))
@ -143,7 +162,7 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
//T1 = 12; T2 = 48; T3 = 192; T4 = 768 //T1 = 12; T2 = 48; T3 = 192; T4 = 768
this.mEUt = 3 * (1 << (getMinTier() << 1)); this.mEUt = 3 * (1 << (getMinTier() << 1));
//T1 = 960; T2 = 480; T3 = 240; T4 = 120 //T1 = 960; T2 = 480; T3 = 240; T4 = 120
this.mMaxProgresstime = 1920 / (1 << getMinTier()); this.mMaxProgresstime = (isPickingPipes ? 80 : 1920) / (1 << getMinTier());
long voltage = getMaxInputVoltage(); long voltage = getMaxInputVoltage();
long overclockEu = V[Math.max(1, GT_Utility.getTier(voltage)) - 1]; long overclockEu = V[Math.max(1, GT_Utility.getTier(voltage)) - 1];
@ -180,7 +199,7 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
outputItems.add(recipeOutput); outputItems.add(recipeOutput);
} }
} }
return GT_Utility.listToArray(outputItems); return outputItems.toArray(new ItemStack[0]);
} }
private boolean doUseMaceratorRecipe(ItemStack currentItem) { private boolean doUseMaceratorRecipe(ItemStack currentItem) {
@ -249,22 +268,23 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
Block block = getBaseMetaTileEntity().getBlock(x, y, z); Block block = getBaseMetaTileEntity().getBlock(x, y, z);
int blockMeta = getBaseMetaTileEntity().getMetaID(x, y, z); int blockMeta = getBaseMetaTileEntity().getMetaID(x, y, z);
ChunkPosition blockPos = new ChunkPosition(x, y, z); ChunkPosition blockPos = new ChunkPosition(x, y, z);
if (oreBlockPositions.contains(blockPos)) return;
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.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.add(blockPos); oreBlockPositions.add(blockPos);
} }
} }
private boolean moveOneDown() { private boolean tryLowerPipe() {
if (!isHasMiningPipes()) return false; if (!isHasMiningPipes()) return false;
if (yHead <= 0) return false; if (yHead <= 0) return false;
if (checkBlockAndMeta(xCenter, yHead - 1, zCenter, Blocks.bedrock, 0)) return false; if (checkBlockAndMeta(xCenter, yHead - 1, zCenter, Blocks.bedrock, W)) return false;
if (!getBaseMetaTileEntity().getWorld().setBlock(xCenter, yHead - 1, zCenter, miningPipeTipBlock)) return false; if (!getBaseMetaTileEntity().getWorld().setBlock(xCenter, yHead - 1, zCenter, miningPipeTipBlock)) return false;
if (yHead != yDrill) getBaseMetaTileEntity().getWorld().setBlock(xCenter, yHead, zCenter, miningPipeBlock); if (yHead != yDrill) getBaseMetaTileEntity().getWorld().setBlock(xCenter, yHead, zCenter, miningPipeBlock);
@ -311,7 +331,7 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
|| !checkFrameBlock(back.offsetX, yOff + 3, back.offsetZ)) || !checkFrameBlock(back.offsetX, yOff + 3, back.offsetZ))
return false; return false;
} }
return checkPipesAndSetYHead(); return true;
} }
private void updateCoordinates() { private void updateCoordinates() {
@ -325,10 +345,13 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
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--; //skip pipes
if (checkBlockAndMeta(xCenter, yHead, zCenter, miningPipeTipBlock, W)) return true; //is pipe tip OR is controller layer
yHead++; if (checkBlockAndMeta(xCenter, yHead, zCenter, miningPipeTipBlock, W) || ++yHead == yDrill) return true;
return yHead == yDrill || getBaseMetaTileEntity().getWorld().setBlock(xCenter, yHead, zCenter, miningPipeTipBlock); //pipe column is broken - try fix
getBaseMetaTileEntity().getWorld().setBlock(xCenter, yHead, zCenter, miningPipeTipBlock);
oreBlockPositions.clear();
return true;
} }
private boolean checkCasingBlock(int xOff, int yOff, int zOff) { private boolean checkCasingBlock(int xOff, int yOff, int zOff) {
@ -395,6 +418,7 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile
"1x Input Bus for mining pipes (Any bottom layer casing; not necessary)", "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)",
"Radius is " + (getRadiusInChunks() << 4) + " blocks"};
} }
} }