Skip to content

Commit 355e5a5

Browse files
committed
* stash
Former-commit-id: 6b9e412
1 parent 8245794 commit 355e5a5

1 file changed

Lines changed: 143 additions & 107 deletions

File tree

src/main/java/com/detrav/tileentities/Detrav_MetaTileEntity_AdvMiner2.java

Lines changed: 143 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ public Detrav_MetaTileEntity_AdvMiner2(String aName) {
4848
public String[] getDescription() {
4949
return new String[]{
5050
"Controller Block for the Detrav Advanced Miner II",
51-
"Size is controlled by the odd circuits configuration",
51+
"Default size is one chunk, use circuit configuration",
52+
"to increase the size, {config}*2 + 1 chunks"
5253
"Size(WxHxD): 3x7x3, Controller (Front middle bottom)",
5354
"3x1x3 Base of Solid Steel Casings",
5455
"1x3x1 Solid Steel Casing pillar (Center of base)",
5556
"1x3x1 Steel Frame Boxes (Each Steel pillar side and on top)",
5657
"1x Input Hatch (Any bottom layer casing)",
57-
"1x Input Bus for Mining Pipe (Any bottom layer casing)",
5858
"1x Output Bus (Any bottom layer casing)",
5959
"1x Maintenance Hatch (Any bottom layer casing)",
6060
"1x MV+ Energy Hatch (Any bottom layer casing)"};
@@ -73,28 +73,10 @@ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechT
7373

7474
@Override
7575
public boolean checkRecipe(ItemStack aStack) {
76-
int circuit_config;
77-
if (mInventory[1] == null && !mInventory[1].getUnlocalizedName().startsWith("gt.integrated_circuit")) return false;
78-
79-
circuit_config = mInventory[1].getItemDamage();
80-
if (circuit_config < 1 && circuit_config % 2 != 1) {
76+
77+
if(!moveFirst())
8178
return false;
82-
}
83-
84-
circuit_config --;
85-
circuit_config /= 2;
86-
87-
if(mInputBusses == null) return false;
88-
boolean flagreturn = true;
89-
ArrayList<ItemStack> tItems = getStoredInputs();
90-
for (ItemStack tStack : tItems) {
91-
if (tStack.isItemEqual(GT_ModHandler.getIC2Item("miningPipe", 1L))) {
92-
flagreturn = false;
93-
break;
94-
}
95-
}
96-
if(flagreturn) return false;
97-
79+
9880
if (mInputHatches == null || mInputHatches.get(0).mFluid == null || mInputHatches.get(0).mFluid.getFluid().getID() != ItemList.sDrillingFluid.getID()) {
9981
return false;
10082
}
@@ -111,35 +93,33 @@ public boolean checkRecipe(ItemStack aStack) {
11193

11294
if (getBaseMetaTileEntity().getRandomNumber(10) <= 4) {
11395
if (mMineList.isEmpty()) {
114-
for(int i = - circuit_config; i<=circuit_config; i++)
115-
for(int j = - circuit_config; j<=circuit_config; j++) {
116-
Chunk c = getBaseMetaTileEntity().getWorld().getChunkFromBlockCoords(getBaseMetaTileEntity().getXCoord() + i * 16, getBaseMetaTileEntity().getZCoord() + j * 16);
117-
for (int x = 0; x < 16; x++)
118-
for (int z = 0; z < 16; z++) {
119-
int yLevel = getYOfPumpHead();
120-
Block tBlock = c.getBlock(x,yLevel,z);
121-
int tMetaID = c.getBlockMetadata(x,yLevel,z);
122-
if (tBlock instanceof GT_Block_Ores_Abstract) {
123-
TileEntity tTileEntity = c.getTileEntityUnsafe(x,yLevel,z);
124-
if ((tTileEntity!=null)
125-
&& (tTileEntity instanceof GT_TileEntity_Ores)
126-
&& ((GT_TileEntity_Ores) tTileEntity).mNatural == true
127-
&& !mMineList.contains(new ChunkPosition(tTileEntity.xCoord, tTileEntity.yCoord, tTileEntity.zCoord))) {
128-
mMineList.add(new ChunkPosition(tTileEntity.xCoord, tTileEntity.yCoord, tTileEntity.zCoord));
129-
}
130-
}
131-
else {
132-
ItemData tAssotiation = GT_OreDictUnificator.getAssociation(new ItemStack(tBlock, 1, tMetaID));
133-
if ((tAssotiation != null) && (tAssotiation.mPrefix.toString().startsWith("ore"))) {
134-
ChunkPosition cp = new ChunkPosition(c.xPosition * 16 + x, yLevel, c.zPosition * 16 + z);
135-
if (!mMineList.contains(cp)) {
136-
mMineList.add(cp);
137-
}
138-
}
139-
}
96+
int x = getXCurrent();
97+
int z = getZCurrent();
98+
for(int yLevel = getBaseMetaTileEntity().getYCoord() - 1; yLevel>1; yLevel --)
99+
{
100+
Block tBlock = c.getBlock(x,yLevel,z);
101+
int tMetaID = c.getBlockMetadata(x,yLevel,z);
102+
if (tBlock instanceof GT_Block_Ores_Abstract) {
103+
TileEntity tTileEntity = c.getTileEntityUnsafe(x,yLevel,z);
104+
if ((tTileEntity!=null)
105+
&& (tTileEntity instanceof GT_TileEntity_Ores)
106+
&& ((GT_TileEntity_Ores) tTileEntity).mNatural == true
107+
&& !mMineList.contains(new ChunkPosition(tTileEntity.xCoord, tTileEntity.yCoord, tTileEntity.zCoord))) {
108+
mMineList.add(new ChunkPosition(tTileEntity.xCoord, tTileEntity.yCoord, tTileEntity.zCoord));
140109
}
141-
}
110+
}
111+
else {
112+
ItemData tAssotiation = GT_OreDictUnificator.getAssociation(new ItemStack(tBlock, 1, tMetaID));
113+
if ((tAssotiation != null) && (tAssotiation.mPrefix.toString().startsWith("ore"))) {
114+
ChunkPosition cp = new ChunkPosition(c.xPosition * 16 + x, yLevel, c.zPosition * 16 + z);
115+
if (!mMineList.contains(cp)) {
116+
mMineList.add(cp);
117+
}
118+
}
119+
}
120+
}
142121
}
122+
143123

144124
ArrayList<ItemStack> tDrops = new ArrayList();
145125
Block tMineBlock = null;
@@ -196,12 +176,8 @@ public boolean checkRecipe(ItemStack aStack) {
196176
}
197177
else
198178
{
199-
if(getBaseMetaTileEntity().getBlockOffset(ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetX, getYOfPumpHead() - 1 - getBaseMetaTileEntity().getYCoord(), ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetZ) != Blocks.bedrock){
200-
if (mEnergyHatches.size() > 0 && mEnergyHatches.get(0).getEUVar() > (512 + getMaxInputVoltage() * 4)) {
201-
moveOneDown();
202-
}
203-
}else{
204-
return false;
179+
if (mEnergyHatches.size() > 0 && mEnergyHatches.get(0).getEUVar() > (512 + getMaxInputVoltage() * 4)) {
180+
moveNext();
205181
}
206182
}
207183
}
@@ -229,70 +205,130 @@ public boolean checkRecipe(ItemStack aStack) {
229205
return true;
230206
}
231207

232-
private boolean moveOneDown() {
208+
private boolean moveFirst() {
209+
int circuit_config = 1;
210+
if (mInventory[1] == null && !mInventory[1].getUnlocalizedName().startsWith("gt.integrated_circuit")) return false;
233211

234-
boolean flagreturn = true;
235-
ArrayList<ItemStack> tItems = getStoredInputs();
236-
for (ItemStack tStack : tItems) {
237-
if (tStack.isItemEqual(GT_ModHandler.getIC2Item("miningPipe", 1L))) {
238-
flagreturn = false;
239-
break;
240-
}
212+
circuit_config = mInventory[1].getItemDamage();
213+
214+
circuit_config *= 2;
215+
circuit_config++;
216+
//in here if circuit is empty set data to chunk
217+
boolean configurated = false;
218+
219+
NBTTagCompound aNBT = aCircuit.getTagCompound();
220+
if(aNBT == null) {
221+
aCircuit = new NBTTagCompound();
222+
NBTTagCompound detravPosition = new NBTTagCompound();
223+
aNBT.setTag("DetravPosition", detravPosition);
224+
aStack.setTagCompound(aNBT);
225+
}
226+
227+
NBTTagCompound detravPosition = aNBT.getCompoundTag("DetravPosition");
228+
if (detravPosition == null ) {
229+
detravPosition = new NBTTagCompound();
230+
aNBT.setTag("DetravPosition", detravPosition);
231+
}
232+
configurated = detravPosition.hasKey("Configurated") && detravPosition.get("Configurated");
233+
234+
if(!configurated)
235+
{
236+
configurated = true;
237+
int x_from = getBaseMetaTileEntity().getXCoord() -circuit_config * 16;
238+
int x_to = getBaseMetaTileEntity().getXCoord() +circuit_config * 16;
239+
int x_current = x_from;
240+
int z_from = getBaseMetaTileEntity().getZCoord() - circuit_config * 16;
241+
int z_to = getBaseMetaTileEntity().getZCoord() + circuit_config * 16;
242+
int z_current = z_from;
243+
244+
detravPosition.set("XFrom",x_from);
245+
detravPosition.set("XTo",x_to);
246+
detravPosition.set("XCurrent",x_current);
247+
detravPosition.set("ZFrom",z_from);
248+
detravPosition.set("ZTo",z_to);
249+
detravPosition.set("ZCurrent",z_current);
241250
}
242-
if(flagreturn) return false;
251+
if(detravPosition.hasKey("Finished"))
252+
configurated = !detravPosition.get("Finished");
253+
return configurated;
254+
}
243255

256+
private int getXCurrent()
257+
{
258+
int fakeResult = getBaseMetaTileEntity().getXCoord();
259+
if(mInventory[1] == null) return fakeResult;
260+
ItemStack aCircuit = mInventory[1];
261+
NBTTagCompound aNBT = aCircuit.getTagCompound();
262+
if(aNBT == null) return fakeResultfalse;
263+
NBTTagCompound detravPosition = aNBT.getCompoundTag("DetravPosition");
264+
if (detravPosition == null ) return fakeResult;
265+
266+
if(detravPosition.hasKey("Finished"))
267+
if(detravPosition.get("Finished"))
268+
return fakeResult;
269+
270+
return detravPosition.get("XCurrent");
271+
}
244272

273+
private int getZCurrent()
274+
{
275+
int fakeResult = getBaseMetaTileEntity().getZCoord();
276+
if(mInventory[1] == null) return fakeResult;
277+
ItemStack aCircuit = mInventory[1];
278+
NBTTagCompound aNBT = aCircuit.getTagCompound();
279+
if(aNBT == null) return fakeResultfalse;
280+
NBTTagCompound detravPosition = aNBT.getCompoundTag("DetravPosition");
281+
if (detravPosition == null ) return fakeResult;
282+
283+
if(detravPosition.hasKey("Finished"))
284+
if(detravPosition.get("Finished"))
285+
return fakeResult;
286+
287+
return detravPosition.get("ZCurrent");
288+
}
245289

246290

247-
int xDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetX;
248-
int zDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetZ;
249-
int yHead = getYOfPumpHead();
250-
if (yHead <= 0) {
251-
return false;
252-
}
253-
if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord() + xDir, yHead - 1, getBaseMetaTileEntity().getZCoord() + zDir) == Blocks.bedrock) {
254-
return false;
255-
}
256-
if (!(getBaseMetaTileEntity().getWorld().setBlock(getBaseMetaTileEntity().getXCoord() + xDir, yHead - 1, getBaseMetaTileEntity().getZCoord() + zDir, GT_Utility.getBlockFromStack(GT_ModHandler.getIC2Item("miningPipeTip", 1L))))) {
257-
return false;
258-
}
259-
if (yHead != getBaseMetaTileEntity().getYCoord()) {
260-
getBaseMetaTileEntity().getWorld().setBlock(getBaseMetaTileEntity().getXCoord() + xDir, yHead, getBaseMetaTileEntity().getZCoord() + zDir, GT_Utility.getBlockFromStack(GT_ModHandler.getIC2Item("miningPipe", 1L)));
261-
}
291+
private boolean moveNext() {
292+
if(mInventory[1] == null) return false;
293+
ItemStack aCircuit = mInventory[1];
294+
NBTTagCompound aNBT = aCircuit.getTagCompound();
295+
if(aNBT == null) return false;
296+
NBTTagCompound detravPosition = aNBT.getCompoundTag("DetravPosition");
297+
if (detravPosition == null ) return false;
262298

263-
for (ItemStack tStack : tItems) {
264-
if (tStack.isItemEqual(GT_ModHandler.getIC2Item("miningPipe", 1L))) {
265-
tStack.stackSize--;
266-
if (tStack.stackSize < 1) {
267-
tStack = null;
268-
}
269-
return true;
299+
if(detravPosition.hasKey("Finished"))
300+
if(detravPosition.get("Finished"))
301+
return false;
302+
303+
int x_from = detravPosition.get("XFrom");
304+
int z_from = detravPosition.get("ZFrom");
305+
int x_to = detravPosition.get("XTo");
306+
int z_to = detravPosition.get("ZTo");
307+
int x_current = detravPosition.get("XCurrent");
308+
int z_current = detravPosition.get("ZCurrent");
309+
310+
if(z_current < z_to)
311+
z_current++;
312+
else
313+
{
314+
if(x_current < x_to)
315+
{
316+
z_current = z_from;
317+
x_current++;
318+
}
319+
else
320+
{
321+
detravPosition.set("Finished",true);
322+
return false;
270323
}
271324
}
272325

326+
detravPosition.set("XCurrent",x_current);
327+
detravPosition.get("ZCurrent",z_current);
328+
273329
return true;
274330
}
275331

276-
private int getYOfPumpHead() {
277-
int xDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetX;
278-
int zDir = ForgeDirection.getOrientation(getBaseMetaTileEntity().getBackFacing()).offsetZ;
279-
int y = getBaseMetaTileEntity().getYCoord() - 1;
280-
while (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord() + xDir, y, getBaseMetaTileEntity().getZCoord() + zDir) == GT_Utility.getBlockFromStack(GT_ModHandler.getIC2Item("miningPipe", 1L))) {
281-
y--;
282-
}
283-
if (y == getBaseMetaTileEntity().getYCoord() - 1) {
284-
if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord() + xDir, y, getBaseMetaTileEntity().getZCoord() + zDir) != GT_Utility.getBlockFromStack(GT_ModHandler.getIC2Item("miningPipeTip", 1L))) {
285-
return y + 1;
286-
}
287-
} else if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord() + xDir, y, getBaseMetaTileEntity().getZCoord() + zDir) != GT_Utility
288-
.getBlockFromStack(GT_ModHandler.getIC2Item("miningPipeTip", 1L)) && this.mInventory[1] != null && this.mInventory[1].stackSize > 0 && GT_Utility.areStacksEqual(this.mInventory[1], GT_ModHandler.getIC2Item("miningPipe", 1L))) {
289-
getBaseMetaTileEntity().getWorld().setBlock(getBaseMetaTileEntity().getXCoord() + xDir, y, getBaseMetaTileEntity().getZCoord() + zDir,
290-
GT_Utility.getBlockFromStack(GT_ModHandler.getIC2Item("miningPipeTip", 1L)));
291-
getBaseMetaTileEntity().decrStackSize(0, 1);
292-
}
293-
return y;
294-
}
295-
296332
@Override
297333
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
298334
int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX;

0 commit comments

Comments
 (0)