25
25
import gregtech .api .interfaces .IIconContainer ;
26
26
import gregtech .api .interfaces .metatileentity .IMetaTileEntity ;
27
27
import gregtech .api .interfaces .tileentity .IGregTechTileEntity ;
28
+ import gregtech .api .metatileentity .implementations .GT_MetaTileEntity_Hatch_InputBus ;
28
29
import gregtech .api .util .GTPP_Recipe ;
29
30
import gregtech .api .util .GT_Multiblock_Tooltip_Builder ;
30
31
import gregtech .api .util .GT_OverclockCalculator ;
34
35
import gtPlusPlus .core .block .ModBlocks ;
35
36
import gtPlusPlus .core .lib .CORE ;
36
37
import gtPlusPlus .core .util .minecraft .ItemUtils ;
38
+ import gtPlusPlus .xmod .gregtech .api .metatileentity .implementations .GT_MetaTileEntity_ChiselBus ;
37
39
import gtPlusPlus .xmod .gregtech .api .metatileentity .implementations .base .GregtechMeta_MultiBlockBase ;
38
40
import gtPlusPlus .xmod .gregtech .common .blocks .textures .TexturesGtBlock ;
39
41
import team .chisel .carving .Carving ;
@@ -42,6 +44,8 @@ public class GregtechMetaTileEntity_IndustrialChisel
42
44
extends GregtechMeta_MultiBlockBase <GregtechMetaTileEntity_IndustrialChisel > implements ISurvivalConstructable {
43
45
44
46
private int mCasing ;
47
+
48
+ private ItemStack target ;
45
49
private static IStructureDefinition <GregtechMetaTileEntity_IndustrialChisel > STRUCTURE_DEFINITION = null ;
46
50
private ItemStack mInputCache ;
47
51
private ItemStack mOutputCache ;
@@ -69,7 +73,9 @@ public String getMachineType() {
69
73
protected GT_Multiblock_Tooltip_Builder createTooltip () {
70
74
GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder ();
71
75
tt .addMachineType (getMachineType ()).addInfo ("Factory Grade Auto Chisel" )
72
- .addInfo ("Target block goes in GUI slot" ).addInfo ("If no target provided, first chisel result is used" )
76
+ .addInfo ("Target block goes in Controller slot for common Input Buses" )
77
+ .addInfo ("You can also set a target block in each Chisel Input Bus and use them as an Input Bus" )
78
+ .addInfo ("If no target is provided for common buses, the result of the first chisel is used" )
73
79
.addInfo ("Speed: +200% | EU Usage: 75% | Parallel: Tier x 16" )
74
80
.addPollutionAmount (getPollutionPerSecond (null )).addSeparator ().beginStructureBlock (3 , 3 , 3 , true )
75
81
.addController ("Front center" ).addCasingInfo ("Sturdy Printer Casing" , 10 ).addInputBus ("Any casing" , 1 )
@@ -81,12 +87,17 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() {
81
87
@ Override
82
88
public IStructureDefinition <GregtechMetaTileEntity_IndustrialChisel > getStructureDefinition () {
83
89
if (STRUCTURE_DEFINITION == null ) {
84
- STRUCTURE_DEFINITION = StructureDefinition .< GregtechMetaTileEntity_IndustrialChisel > builder ()
85
- .addShape (
90
+ STRUCTURE_DEFINITION = StructureDefinition
91
+ .< GregtechMetaTileEntity_IndustrialChisel > builder (). addShape (
86
92
mName ,
87
93
transpose (
88
- new String [][] { { "CCC" , "CCC" , "CCC" }, { "C~C" , "C-C" , "CCC" },
89
- { "CCC" , "CCC" , "CCC" }, }))
94
+ // spotless:off
95
+ new String [][] {
96
+ { "CCC" , "CCC" , "CCC" },
97
+ { "C~C" , "C-C" , "CCC" },
98
+ { "CCC" , "CCC" , "CCC" },
99
+ }))
100
+ // spotless:on
90
101
.addElement (
91
102
'C' ,
92
103
buildHatchAdder (GregtechMetaTileEntity_IndustrialChisel .class )
@@ -184,7 +195,7 @@ private static List<ItemStack> getItemsForChiseling(ItemStack aStack) {
184
195
}
185
196
186
197
private static ItemStack getChiselOutput (ItemStack aInput , ItemStack aTarget ) {
187
- ItemStack tOutput = null ;
198
+ ItemStack tOutput ;
188
199
if (aTarget != null && canBeMadeFrom (aInput , aTarget )) {
189
200
tOutput = aTarget ;
190
201
} else if (aTarget != null && !canBeMadeFrom (aInput , aTarget )) {
@@ -195,10 +206,10 @@ private static ItemStack getChiselOutput(ItemStack aInput, ItemStack aTarget) {
195
206
return tOutput ;
196
207
}
197
208
198
- private GTPP_Recipe generateChiselRecipe (ItemStack aInput , ItemStack aTarget ) {
199
- boolean tIsCached = hasValidCache (aInput , aTarget , true );
209
+ private GTPP_Recipe generateChiselRecipe (ItemStack aInput ) {
210
+ boolean tIsCached = hasValidCache (aInput , this . target , true );
200
211
if (tIsCached || aInput != null && hasChiselResults (aInput )) {
201
- ItemStack tOutput = tIsCached ? mOutputCache .copy () : getChiselOutput (aInput , aTarget );
212
+ ItemStack tOutput = tIsCached ? mOutputCache .copy () : getChiselOutput (aInput , this . target );
202
213
if (tOutput != null ) {
203
214
if (mCachedRecipe != null && GT_Utility .areStacksEqual (aInput , mInputCache )
204
215
&& GT_Utility .areStacksEqual (tOutput , mOutputCache )) {
@@ -225,74 +236,97 @@ private GTPP_Recipe generateChiselRecipe(ItemStack aInput, ItemStack aTarget) {
225
236
return null ;
226
237
}
227
238
239
+ private GT_Recipe getRecipe () {
240
+ for (GT_MetaTileEntity_Hatch_InputBus bus : this .mInputBusses ) {
241
+ if (bus instanceof GT_MetaTileEntity_ChiselBus ) { // Chisel buses
242
+ if (bus .mInventory [bus .getSizeInventory () - 1 ] == null ) continue ;
243
+ this .target = bus .mInventory [bus .getSizeInventory () - 1 ];
244
+
245
+ for (int i = bus .getSizeInventory () - 2 ; i >= 0 ; i --) {
246
+ ItemStack itemsInSlot = bus .mInventory [i ];
247
+ if (itemsInSlot != null ) {
248
+ GT_Recipe tRecipe = generateChiselRecipe (itemsInSlot );
249
+ if (tRecipe != null ) {
250
+ return tRecipe ;
251
+ }
252
+ }
253
+ }
254
+ } else {
255
+ target = this .getGUIItemStack (); // Common buses
256
+ for (int i = bus .getSizeInventory () - 1 ; i >= 0 ; i --) {
257
+ ItemStack itemsInSlot = bus .mInventory [i ];
258
+ if (itemsInSlot != null ) {
259
+ GT_Recipe tRecipe = generateChiselRecipe (itemsInSlot );
260
+ if (tRecipe != null ) {
261
+ return tRecipe ;
262
+ }
263
+ }
264
+ }
265
+ }
266
+
267
+ }
268
+ return null ;
269
+ }
270
+
228
271
@ Override
229
272
public boolean checkRecipe (final ItemStack aStack ) {
273
+ GT_Recipe tRecipe = getRecipe ();
274
+ if (tRecipe == null ) return false ;
275
+
230
276
ArrayList <ItemStack > aItems = this .getStoredInputs ();
231
- if (!aItems .isEmpty ()) {
232
277
233
- GT_Recipe tRecipe = generateChiselRecipe (aItems .get (0 ), this .getGUIItemStack ());
278
+ // Based on the Processing Array. A bit overkill, but very flexible.
279
+ ItemStack [] aItemInputs = aItems .toArray (new ItemStack [aItems .size ()]);
234
280
235
- if (tRecipe == null ) {
236
- return false ;
237
- }
281
+ // Reset outputs and progress stats
282
+ this .lEUt = 0 ;
283
+ this .mMaxProgresstime = 0 ;
284
+ this .mOutputItems = new ItemStack [] {};
285
+ this .mOutputFluids = new FluidStack [] {};
286
+ long tEnergy = getMaxInputEnergy ();
238
287
239
- // Based on the Processing Array. A bit overkill, but very flexible.
240
- ItemStack [] aItemInputs = aItems .toArray (new ItemStack [aItems .size ()]);
241
- FluidStack [] aFluidInputs = new FluidStack [] {};
242
-
243
- // Reset outputs and progress stats
244
- this .lEUt = 0 ;
245
- this .mMaxProgresstime = 0 ;
246
- this .mOutputItems = new ItemStack [] {};
247
- this .mOutputFluids = new FluidStack [] {};
248
-
249
- long tVoltage = getMaxInputVoltage ();
250
- long tEnergy = getMaxInputEnergy ();
251
- // Remember last recipe - an optimization for findRecipe()
252
- this .mLastRecipe = tRecipe ;
253
-
254
- int aMaxParallelRecipes = getMaxParallelRecipes ();
255
- int aEUPercent = getEuDiscountForParallelism ();
256
- int aSpeedBonusPercent = 200 ;
257
-
258
- GT_ParallelHelper helper = new GT_ParallelHelper ().setRecipe (tRecipe ).setItemInputs (aItemInputs )
259
- .setFluidInputs (aFluidInputs ).setAvailableEUt (tEnergy ).setMaxParallel (aMaxParallelRecipes )
260
- .enableConsumption ().enableOutputCalculation ().setEUtModifier (aEUPercent / 100.0f );
261
- if (!voidExcess ) {
262
- helper .enableVoidProtection (this );
263
- }
288
+ // Remember last recipe - an optimization for findRecipe()
289
+ this .mLastRecipe = tRecipe ;
264
290
265
- if ( batchMode ) {
266
- helper . enableBatchMode ( 128 );
267
- }
291
+ int aMaxParallelRecipes = getMaxParallelRecipes ();
292
+ int aEUPercent = getEuDiscountForParallelism ( );
293
+ int aSpeedBonusPercent = 200 ;
268
294
269
- helper .build ();
295
+ GT_ParallelHelper helper = new GT_ParallelHelper ().setRecipe (tRecipe ).setItemInputs (aItemInputs )
296
+ .setAvailableEUt (tEnergy ).setMaxParallel (aMaxParallelRecipes ).enableConsumption ()
297
+ .enableOutputCalculation ().setEUtModifier (aEUPercent / 100.0f );
298
+ if (!voidExcess ) {
299
+ helper .enableVoidProtection (this );
300
+ }
270
301
271
- if (helper . getCurrentParallel () == 0 ) {
272
- return false ;
273
- }
302
+ if (batchMode ) {
303
+ helper . enableBatchMode ( 128 ) ;
304
+ }
274
305
275
- this .mEfficiency = (10000 - (getIdealStatus () - getRepairStatus ()) * 1000 );
276
- this .mEfficiencyIncrease = 10000 ;
306
+ helper .build ();
277
307
278
- GT_OverclockCalculator calculator = new GT_OverclockCalculator ().setRecipeEUt (tRecipe .mEUt ).setEUt (tEnergy )
279
- .setDuration (tRecipe .mDuration ).setEUtDiscount (aEUPercent / 100.0f )
280
- .setSpeedBoost (100.0f / (100.0f + aSpeedBonusPercent ))
281
- .setParallel ((int ) Math .floor (helper .getCurrentParallel () / helper .getDurationMultiplier ()))
282
- .calculate ();
283
- lEUt = -calculator .getConsumption ();
284
- mMaxProgresstime = (int ) Math .ceil (calculator .getDuration () * helper .getDurationMultiplier ());
308
+ if (helper .getCurrentParallel () == 0 ) {
309
+ return false ;
310
+ }
285
311
286
- mOutputItems = helper .getItemOutputs ();
287
- mOutputFluids = helper .getFluidOutputs ();
288
- updateSlots ();
312
+ this .mEfficiency = (10000 - (getIdealStatus () - getRepairStatus ()) * 1000 );
313
+ this .mEfficiencyIncrease = 10000 ;
289
314
290
- // Play sounds (GT++ addition - GT multiblocks play no sounds)
291
- startProcess ();
292
- return true ;
293
- }
315
+ GT_OverclockCalculator calculator = new GT_OverclockCalculator ().setRecipeEUt (tRecipe .mEUt ).setEUt (tEnergy )
316
+ .setDuration (tRecipe .mDuration ).setEUtDiscount (aEUPercent / 100.0f )
317
+ .setSpeedBoost (100.0f / (100.0f + aSpeedBonusPercent ))
318
+ .setParallel ((int ) Math .floor (helper .getCurrentParallel () / helper .getDurationMultiplier ()))
319
+ .calculate ();
320
+ lEUt = -calculator .getConsumption ();
321
+ mMaxProgresstime = (int ) Math .ceil (calculator .getDuration () * helper .getDurationMultiplier ());
294
322
295
- return false ;
323
+ mOutputItems = helper .getItemOutputs ();
324
+
325
+ updateSlots ();
326
+
327
+ // Play sounds (GT++ addition - GT multiblocks play no sounds)
328
+ startProcess ();
329
+ return true ;
296
330
}
297
331
298
332
@ Override
@@ -307,7 +341,7 @@ public int getEuDiscountForParallelism() {
307
341
308
342
private static String sChiselSound = null ;
309
343
310
- private static final String getChiselSound () {
344
+ private static String getChiselSound () {
311
345
if (sChiselSound == null ) {
312
346
sChiselSound = Carving .chisel .getVariationSound (Blocks .stone , 0 );
313
347
}
0 commit comments