Skip to content
This repository was archived by the owner on May 26, 2024. It is now read-only.

Commit 69791bd

Browse files
author
Quetz4l
authored
added chisel input busses (#638)
* added chisel input busses * fix industrial chisel tooltip * fixes industrial chisel
1 parent 79ba91d commit 69791bd

File tree

6 files changed

+223
-66
lines changed

6 files changed

+223
-66
lines changed

build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//version: 1684139283
1+
//version: 1684218858
22
/*
33
DO NOT CHANGE THIS FILE!
44
Also, you may replace this file at any time if there is an update available.
@@ -730,7 +730,7 @@ dependencies {
730730
java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}")
731731
}
732732
if (modId != 'hodgepodge') {
733-
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.2.8')
733+
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.2.13')
734734
}
735735

736736
java17PatchDependencies('net.minecraft:launchwrapper:1.15') {transitive = false}

src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java

+22
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ private static void run() {
262262
rockBreaker();
263263
thermicFluidHeater();
264264
advHeatExchanger();
265+
chiselBuses();
265266

266267
gt4FarmManager();
267268
gt4Redstone();
@@ -3551,6 +3552,27 @@ private static void superBuses() {
35513552
}
35523553
}
35533554

3555+
private static void chiselBuses() {
3556+
ItemStack[] mSuperBusesInput = new ItemStack[] { ItemList.Hatch_Input_Bus_HV.get(1),
3557+
GregtechItemList.Hatch_SuperBus_Input_LV.get(1), GregtechItemList.Hatch_SuperBus_Input_MV.get(1),
3558+
GregtechItemList.Hatch_SuperBus_Input_HV.get(1), };
3559+
3560+
ItemStack[] mChiselBuses = new ItemStack[] { GregtechItemList.GT_MetaTileEntity_ChiselBus_I.get(1),
3561+
GregtechItemList.GT_MetaTileEntity_ChiselBus_II.get(1),
3562+
GregtechItemList.GT_MetaTileEntity_ChiselBus_III.get(1),
3563+
GregtechItemList.GT_MetaTileEntity_ChiselBus_IV.get(1), };
3564+
3565+
for (int i = 0; i < 4; i++) {
3566+
CORE.RA.addSixSlotAssemblingRecipe(
3567+
new ItemStack[] { CI.getNumberedCircuit(17), mSuperBusesInput[i], CI.getSensor(i, 1),
3568+
CI.getRobotArm(i, 2), CI.getBolt(i, 16), ItemUtils.getSimpleStack(Blocks.chest) },
3569+
CI.getAlternativeTieredFluid(i, 144 * 2),
3570+
mChiselBuses[i],
3571+
20 * 30 * 2,
3572+
(int) GT_Values.VP[i + 1]);
3573+
}
3574+
}
3575+
35543576
private static void roundRobinators() {
35553577

35563578
RecipeUtils.addShapedGregtechRecipe(

src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java

+6
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,12 @@ public enum GregtechItemList implements GregtechItemContainer {
613613
Hatch_SuperBus_Output_UV,
614614
Hatch_SuperBus_Output_MAX,
615615

616+
// Chisel Buses for Industrial Chisel
617+
GT_MetaTileEntity_ChiselBus_I,
618+
GT_MetaTileEntity_ChiselBus_II,
619+
GT_MetaTileEntity_ChiselBus_III,
620+
GT_MetaTileEntity_ChiselBus_IV,
621+
616622
// ----------------------------------------------------------------------------
617623

618624
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations;
2+
3+
import net.minecraft.util.EnumChatFormatting;
4+
5+
import com.gtnewhorizons.modularui.api.screen.ModularWindow;
6+
import com.gtnewhorizons.modularui.api.screen.UIBuildContext;
7+
import com.gtnewhorizons.modularui.common.widget.Scrollable;
8+
import com.gtnewhorizons.modularui.common.widget.SlotWidget;
9+
10+
import gregtech.api.interfaces.ITexture;
11+
import gregtech.api.interfaces.modularui.IAddUIWidgets;
12+
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
13+
import gregtech.api.metatileentity.MetaTileEntity;
14+
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus;
15+
import gregtech.api.util.extensions.ArrayExt;
16+
17+
public class GT_MetaTileEntity_ChiselBus extends GT_MetaTileEntity_Hatch_InputBus implements IAddUIWidgets {
18+
19+
public GT_MetaTileEntity_ChiselBus(int id, String name, String nameRegional, int tier) {
20+
super(id, name, nameRegional, tier);
21+
}
22+
23+
public GT_MetaTileEntity_ChiselBus(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) {
24+
super(aName, aTier, getSlots(aTier), aDescription, aTextures);
25+
}
26+
27+
@Override
28+
public boolean isValidSlot(int aIndex) {
29+
return aIndex < getSlots(this.mTier);
30+
}
31+
32+
public static int getSlots(int aTier) {
33+
return (1 + aTier) * 16 + 1;
34+
}
35+
36+
@Override
37+
public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
38+
return new GT_MetaTileEntity_ChiselBus(this.mName, this.mTier, ArrayExt.of(this.mDescription), this.mTextures);
39+
}
40+
41+
@Override
42+
public boolean allowSelectCircuit() {
43+
return false;
44+
}
45+
46+
@Override
47+
public String[] getDescription() {
48+
return new String[] { "Item Input Bus for Industrial Chisel", getSlots(this.mTier) - 1 + " + 1 " + " Slots",
49+
"Added by: " + EnumChatFormatting.AQUA
50+
+ "Quetz4l"
51+
+ " - "
52+
+ EnumChatFormatting.RED
53+
+ "[GT++]"
54+
+ EnumChatFormatting.RESET };
55+
}
56+
57+
@Override
58+
public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) {
59+
int slotIndex = 0;
60+
final Scrollable scrollable = new Scrollable().setVerticalScroll();
61+
for (int row = 0; row * 4 < inventoryHandler.getSlots() - 1; row++) {
62+
int columnsToMake = Math.min(inventoryHandler.getSlots() - row * 4, 4);
63+
for (int column = 0; column < columnsToMake; column++) {
64+
scrollable.widget(
65+
new SlotWidget(inventoryHandler, slotIndex++).setPos(column * 18, row * 18).setSize(18, 18));
66+
67+
}
68+
}
69+
70+
builder.widget(scrollable.setSize(18 * 4 + 4, 18 * 4).setPos(52, 7)); // main slots
71+
builder.widget(new SlotWidget(inventoryHandler, slotIndex).setPos(18, 18).setSize(18, 18)); // slot for target
72+
}
73+
74+
}

src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java

+98-64
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import gregtech.api.interfaces.IIconContainer;
2626
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
2727
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
28+
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus;
2829
import gregtech.api.util.GTPP_Recipe;
2930
import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
3031
import gregtech.api.util.GT_OverclockCalculator;
@@ -34,6 +35,7 @@
3435
import gtPlusPlus.core.block.ModBlocks;
3536
import gtPlusPlus.core.lib.CORE;
3637
import gtPlusPlus.core.util.minecraft.ItemUtils;
38+
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_ChiselBus;
3739
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase;
3840
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;
3941
import team.chisel.carving.Carving;
@@ -42,6 +44,8 @@ public class GregtechMetaTileEntity_IndustrialChisel
4244
extends GregtechMeta_MultiBlockBase<GregtechMetaTileEntity_IndustrialChisel> implements ISurvivalConstructable {
4345

4446
private int mCasing;
47+
48+
private ItemStack target;
4549
private static IStructureDefinition<GregtechMetaTileEntity_IndustrialChisel> STRUCTURE_DEFINITION = null;
4650
private ItemStack mInputCache;
4751
private ItemStack mOutputCache;
@@ -69,7 +73,9 @@ public String getMachineType() {
6973
protected GT_Multiblock_Tooltip_Builder createTooltip() {
7074
GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
7175
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")
7379
.addInfo("Speed: +200% | EU Usage: 75% | Parallel: Tier x 16")
7480
.addPollutionAmount(getPollutionPerSecond(null)).addSeparator().beginStructureBlock(3, 3, 3, true)
7581
.addController("Front center").addCasingInfo("Sturdy Printer Casing", 10).addInputBus("Any casing", 1)
@@ -81,12 +87,17 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() {
8187
@Override
8288
public IStructureDefinition<GregtechMetaTileEntity_IndustrialChisel> getStructureDefinition() {
8389
if (STRUCTURE_DEFINITION == null) {
84-
STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_IndustrialChisel>builder()
85-
.addShape(
90+
STRUCTURE_DEFINITION = StructureDefinition
91+
.<GregtechMetaTileEntity_IndustrialChisel>builder().addShape(
8692
mName,
8793
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
90101
.addElement(
91102
'C',
92103
buildHatchAdder(GregtechMetaTileEntity_IndustrialChisel.class)
@@ -184,7 +195,7 @@ private static List<ItemStack> getItemsForChiseling(ItemStack aStack) {
184195
}
185196

186197
private static ItemStack getChiselOutput(ItemStack aInput, ItemStack aTarget) {
187-
ItemStack tOutput = null;
198+
ItemStack tOutput;
188199
if (aTarget != null && canBeMadeFrom(aInput, aTarget)) {
189200
tOutput = aTarget;
190201
} else if (aTarget != null && !canBeMadeFrom(aInput, aTarget)) {
@@ -195,10 +206,10 @@ private static ItemStack getChiselOutput(ItemStack aInput, ItemStack aTarget) {
195206
return tOutput;
196207
}
197208

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);
200211
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);
202213
if (tOutput != null) {
203214
if (mCachedRecipe != null && GT_Utility.areStacksEqual(aInput, mInputCache)
204215
&& GT_Utility.areStacksEqual(tOutput, mOutputCache)) {
@@ -225,74 +236,97 @@ private GTPP_Recipe generateChiselRecipe(ItemStack aInput, ItemStack aTarget) {
225236
return null;
226237
}
227238

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+
228271
@Override
229272
public boolean checkRecipe(final ItemStack aStack) {
273+
GT_Recipe tRecipe = getRecipe();
274+
if (tRecipe == null) return false;
275+
230276
ArrayList<ItemStack> aItems = this.getStoredInputs();
231-
if (!aItems.isEmpty()) {
232277

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()]);
234280

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();
238287

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;
264290

265-
if (batchMode) {
266-
helper.enableBatchMode(128);
267-
}
291+
int aMaxParallelRecipes = getMaxParallelRecipes();
292+
int aEUPercent = getEuDiscountForParallelism();
293+
int aSpeedBonusPercent = 200;
268294

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+
}
270301

271-
if (helper.getCurrentParallel() == 0) {
272-
return false;
273-
}
302+
if (batchMode) {
303+
helper.enableBatchMode(128);
304+
}
274305

275-
this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
276-
this.mEfficiencyIncrease = 10000;
306+
helper.build();
277307

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+
}
285311

286-
mOutputItems = helper.getItemOutputs();
287-
mOutputFluids = helper.getFluidOutputs();
288-
updateSlots();
312+
this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
313+
this.mEfficiencyIncrease = 10000;
289314

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());
294322

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;
296330
}
297331

298332
@Override
@@ -307,7 +341,7 @@ public int getEuDiscountForParallelism() {
307341

308342
private static String sChiselSound = null;
309343

310-
private static final String getChiselSound() {
344+
private static String getChiselSound() {
311345
if (sChiselSound == null) {
312346
sChiselSound = Carving.chisel.getVariationSound(Blocks.stone, 0);
313347
}

0 commit comments

Comments
 (0)