Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fake crafting card for AE #622

Merged
merged 13 commits into from
Dec 23, 2024
13 changes: 13 additions & 0 deletions src/main/java/appeng/api/config/FakeCraftingMode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package appeng.api.config;

/*
* Author : MCTBL Time : 2024-11-07 20:41:21
*/

public enum FakeCraftingMode {

NONE,

FAKE;

}
4 changes: 3 additions & 1 deletion src/main/java/appeng/api/config/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ public enum Settings {

TERMINAL_FONT_SIZE(EnumSet.allOf(TerminalFontSize.class)),

INTERFACE_TERMINAL_SECTION_ORDER(EnumSet.allOf(StringOrder.class));
INTERFACE_TERMINAL_SECTION_ORDER(EnumSet.allOf(StringOrder.class)),

FAKE_CRAFTING_MODE(EnumSet.allOf(FakeCraftingMode.class));

private final EnumSet<? extends Enum<?>> values;

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/appeng/api/config/Upgrades.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public enum Upgrades {
PATTERN_CAPACITY(1),
ORE_FILTER(1),
ADVANCED_BLOCKING(1),
LOCK_CRAFTING(1);
LOCK_CRAFTING(1),
FAKE_CRAFTING(1);

/**
* @deprecated use {@link Upgrades#getTier()}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/appeng/api/definitions/IMaterials.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,6 @@ public interface IMaterials {
IItemDefinition cardAdvancedBlocking();

IItemDefinition cardLockCrafting();

IItemDefinition cardFakeCrafting();
}
23 changes: 23 additions & 0 deletions src/main/java/appeng/client/gui/implementations/GuiInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.lwjgl.input.Mouse;

import appeng.api.config.AdvancedBlockingMode;
import appeng.api.config.FakeCraftingMode;
import appeng.api.config.InsertionMode;
import appeng.api.config.LockCraftingMode;
import appeng.api.config.Settings;
Expand Down Expand Up @@ -50,6 +51,7 @@ public class GuiInterface extends GuiUpgradeable {

private GuiImgButton advancedBlockingMode;
private GuiImgButton lockCraftingMode;
private GuiImgButton fakeCraftingMode;

public GuiInterface(final InventoryPlayer inventoryPlayer, final IInterfaceHost te) {
super(new ContainerInterface(inventoryPlayer, te));
Expand Down Expand Up @@ -129,6 +131,16 @@ protected void addButtons() {
LockCraftingMode.NONE);
this.lockCraftingMode.visible = this.bc.getInstalledUpgrades(Upgrades.LOCK_CRAFTING) > 0;
this.buttonList.add(lockCraftingMode);

offset += 18;

this.fakeCraftingMode = new GuiImgButton(
serenibyss marked this conversation as resolved.
Show resolved Hide resolved
this.guiLeft - 18,
this.guiTop + offset,
Settings.FAKE_CRAFTING_MODE,
FakeCraftingMode.FAKE);
this.fakeCraftingMode.visible = this.bc.getInstalledUpgrades(Upgrades.FAKE_CRAFTING) > 0;
this.buttonList.add(fakeCraftingMode);
}

@Override
Expand Down Expand Up @@ -168,6 +180,10 @@ public void drawFG(final int offsetX, final int offsetY, final int mouseX, final
this.lockCraftingMode.set(((ContainerInterface) this.cvb).getLockCraftingMode());
}

if (this.fakeCraftingMode != null) {
this.fakeCraftingMode.set(((ContainerInterface) this.cvb).getFakeCraftingMode());
}

this.fontRendererObj.drawString(
this.getGuiDisplayName(GuiText.Interface.getLocal()),
8,
Expand Down Expand Up @@ -234,6 +250,10 @@ protected void actionPerformed(final GuiButton btn) {
if (btn == this.lockCraftingMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.lockCraftingMode.getSetting(), backwards));
}

if (btn == this.fakeCraftingMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.fakeCraftingMode.getSetting(), backwards));
}
}

@Override
Expand All @@ -245,5 +265,8 @@ protected void handleButtonVisibility() {
if (this.lockCraftingMode != null) {
this.lockCraftingMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.LOCK_CRAFTING) > 0);
}
if (this.fakeCraftingMode != null) {
this.fakeCraftingMode.setVisibility(this.bc.getInstalledUpgrades(Upgrades.FAKE_CRAFTING) > 0);
}
}
}
13 changes: 13 additions & 0 deletions src/main/java/appeng/client/gui/widgets/GuiImgButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import appeng.api.config.CraftingMode;
import appeng.api.config.CraftingSortOrder;
import appeng.api.config.CraftingStatus;
import appeng.api.config.FakeCraftingMode;
import appeng.api.config.FullnessMode;
import appeng.api.config.FuzzyMode;
import appeng.api.config.InsertionMode;
Expand Down Expand Up @@ -718,6 +719,18 @@ public GuiImgButton(final int x, final int y, final Enum idx, final Enum val) {
LockCraftingMode.LOCK_UNTIL_RESULT,
ButtonToolTips.LockCraftingMode,
ButtonToolTips.LockCraftingUntilResultReturned);
this.registerApp(
16 * 13 + 4,
Settings.FAKE_CRAFTING_MODE,
FakeCraftingMode.FAKE,
ButtonToolTips.FakeCraftingMode,
ButtonToolTips.FakeCraftingOn);
this.registerApp(
16 * 13 + 5,
Settings.FAKE_CRAFTING_MODE,
FakeCraftingMode.NONE,
ButtonToolTips.FakeCraftingMode,
ButtonToolTips.FakeCraftingOff);
this.registerApp(
16 + 2,
Settings.CRAFTING_MODE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import net.minecraft.tileentity.TileEntity;

import appeng.api.config.AdvancedBlockingMode;
import appeng.api.config.FakeCraftingMode;
import appeng.api.config.InsertionMode;
import appeng.api.config.LockCraftingMode;
import appeng.api.config.SecurityPermissions;
Expand Down Expand Up @@ -64,6 +65,9 @@ public class ContainerInterface extends ContainerUpgradeable implements IOptiona
@GuiSync(12)
public LockCraftingMode lockCraftingMode = LockCraftingMode.NONE;

@GuiSync(16)
public FakeCraftingMode fakeCraftingMode = FakeCraftingMode.FAKE;

@GuiSync(8)
public InsertionMode insertionMode = InsertionMode.DEFAULT;

Expand Down Expand Up @@ -167,6 +171,7 @@ protected void loadSettingsFromHost(final IConfigManager cm) {
this.setPatternOptimization((YesNo) cm.getSetting(Settings.PATTERN_OPTIMIZATION));
this.setAdvancedBlockingMode((AdvancedBlockingMode) cm.getSetting(Settings.ADVANCED_BLOCKING_MODE));
this.setLockCraftingMode((LockCraftingMode) cm.getSetting(Settings.LOCK_CRAFTING_MODE));
this.setFakeCraftingMode((FakeCraftingMode) cm.getSetting(Settings.FAKE_CRAFTING_MODE));
}

public void doublePatterns(int val) {
Expand Down Expand Up @@ -254,6 +259,14 @@ private void setLockCraftingMode(LockCraftingMode mode) {
this.lockCraftingMode = mode;
}

public FakeCraftingMode getFakeCraftingMode() {
return this.fakeCraftingMode;
}

public void setFakeCraftingMode(FakeCraftingMode mode) {
this.fakeCraftingMode = mode;
}

public int getPatternCapacityCardsInstalled() {
if (Platform.isClient() && isEmpty) return -1;
if (myDuality == null) return 0;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/appeng/core/Registration.java
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,8 @@ void postInit(final FMLPostInitializationEvent event) {
Upgrades.PATTERN_CAPACITY.registerItem(parts.p2PTunnelMEInterface(), 3);
Upgrades.ADVANCED_BLOCKING.registerItem(parts.iface(), 1);
Upgrades.ADVANCED_BLOCKING.registerItem(blocks.iface(), 1);
Upgrades.FAKE_CRAFTING.registerItem(parts.iface(), 1);
Upgrades.FAKE_CRAFTING.registerItem(blocks.iface(), 1);
Upgrades.LOCK_CRAFTING.registerItem(parts.iface(), 1);
Upgrades.LOCK_CRAFTING.registerItem(blocks.iface(), 1);
Upgrades.LOCK_CRAFTING.registerItem(parts.p2PTunnelMEInterface(), 1);
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/appeng/core/api/definitions/ApiMaterials.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public final class ApiMaterials implements IMaterials {
private final IItemDefinition cardPatternRefiller;
private final IItemDefinition cardAdvancedBlocking;
private final IItemDefinition cardLockCrafting;
private final IItemDefinition cardFakeCrafting;
private final IItemDefinition enderDust;
private final IItemDefinition flour;
private final IItemDefinition goldDust;
Expand Down Expand Up @@ -181,6 +182,8 @@ public ApiMaterials(final DefinitionConstructor constructor) {
itemMultiMaterial.createMaterial(MaterialType.CardAdvancedBlocking));
this.cardLockCrafting = new DamagedItemDefinition(
itemMultiMaterial.createMaterial(MaterialType.CardLockCrafting));
this.cardFakeCrafting = new DamagedItemDefinition(
itemMultiMaterial.createMaterial(MaterialType.CardFakeCrafting));

this.enderDust = new DamagedItemDefinition(itemMultiMaterial.createMaterial(MaterialType.EnderDust));
this.flour = new DamagedItemDefinition(itemMultiMaterial.createMaterial(MaterialType.Flour));
Expand Down Expand Up @@ -546,4 +549,9 @@ public IItemDefinition cardAdvancedBlocking() {
public IItemDefinition cardLockCrafting() {
return this.cardLockCrafting;
}

@Override
public IItemDefinition cardFakeCrafting() {
return this.cardFakeCrafting;
}
}
3 changes: 3 additions & 0 deletions src/main/java/appeng/core/localization/ButtonToolTips.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ public enum ButtonToolTips {
CraftingModeIgnoreMissing,
CraftingModeIgnoreMissingDesc,
ExtraOptions,
FakeCraftingMode,
FakeCraftingOn,
FakeCraftingOff,

SwitchBytesInfo,
SwitchBytesInfo_Item,
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/appeng/helpers/DualityInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.AdvancedBlockingMode;
import appeng.api.config.FakeCraftingMode;
import appeng.api.config.InsertionMode;
import appeng.api.config.LockCraftingMode;
import appeng.api.config.Settings;
Expand Down Expand Up @@ -150,6 +151,7 @@ public DualityInterface(final AENetworkProxy networkProxy, final IInterfaceHost
this.cm.registerSetting(Settings.ADVANCED_BLOCKING_MODE, AdvancedBlockingMode.DEFAULT);
this.cm.registerSetting(Settings.LOCK_CRAFTING_MODE, LockCraftingMode.NONE);
this.cm.registerSetting(Settings.PATTERN_OPTIMIZATION, YesNo.YES);
this.cm.registerSetting(Settings.FAKE_CRAFTING_MODE, FakeCraftingMode.FAKE);

this.iHost = ih;
this.craftingTracker = new MultiCraftingTracker(this.iHost, 9);
Expand Down Expand Up @@ -205,6 +207,8 @@ public void onChangeInventory(final IInventory inv, final int slot, final InvOpe
if (this.getInstalledUpgrades(Upgrades.LOCK_CRAFTING) == 0) {
cm.putSetting(Settings.LOCK_CRAFTING_MODE, LockCraftingMode.NONE);
resetCraftingLock();
} else if (this.getInstalledUpgrades(Upgrades.FAKE_CRAFTING) == 0) {
cm.putSetting(Settings.FAKE_CRAFTING_MODE, FakeCraftingMode.NONE);
}
}
}
Expand Down Expand Up @@ -1038,6 +1042,11 @@ private InsertionMode getInsertionMode() {
return (InsertionMode) cm.getSetting(Settings.INSERTION_MODE);
}

public boolean isFakeCraftingMode() {
return this.getInstalledUpgrades(Upgrades.FAKE_CRAFTING) != 0
&& cm.getSetting(Settings.FAKE_CRAFTING_MODE) == FakeCraftingMode.FAKE;
}

private static boolean acceptsItems(final InventoryAdaptor ad, final InventoryCrafting table,
final InsertionMode insertionMode) {
for (int x = 0; x < table.getSizeInventory(); x++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public Upgrades getType(final ItemStack itemstack) {
case CardAdvancedBlocking -> Upgrades.ADVANCED_BLOCKING;
case CardLockCrafting -> Upgrades.LOCK_CRAFTING;
case CardSticky -> Upgrades.STICKY;
case CardFakeCrafting -> Upgrades.FAKE_CRAFTING;
default -> null;
};
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/appeng/items/materials/MaterialType.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ public enum MaterialType {
CardPatternRefiller(62),
CardAdvancedBlocking(63),
CardSticky(64),
CardLockCrafting(65);
CardLockCrafting(65),
CardFakeCrafting(66);

private final EnumSet<AEFeature> features;
// IIcon for the material.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public final class CraftingCPUCluster implements IAECluster, ICraftingCPU {
private boolean isComplete = true;
private int remainingOperations;
private boolean somethingChanged;
private boolean isFakeCrafting;

private long lastTime;
private long elapsedTime;
Expand Down Expand Up @@ -497,6 +498,7 @@ private void completeJob() {
}

craftCompleteListeners.forEach(f -> f.apply(this.finalOutput.getItemStack(), this.numsOfOutput, elapsedTime));
this.isFakeCrafting = false;
this.usedStorage = 0;
this.remainingItemCount = 0;
this.startItemCount = 0;
Expand Down Expand Up @@ -688,6 +690,21 @@ public void updateCraftingLogic(final IGrid grid, final IEnergyGrid eg, final Cr
if (this.remainingOperations > 0 && !this.somethingChanged) {
this.waiting = true;
}

if (this.isFakeCrafting) {
final IAEItemStack is = this.waitingFor.findPrecise(this.finalOutput);
if (is != null) {
long stackSize = is.getStackSize();
is.decStackSize(stackSize);
this.markDirty();
this.postCraftingStatusChange(is);
this.finalOutput.decStackSize(stackSize);
if (this.finalOutput.getStackSize() <= 0) {
this.completeJob();
}
this.updateCPU();
}
}
}

private void executeCrafting(final IEnergyGrid eg, final CraftingGridCache cc) {
Expand Down Expand Up @@ -787,6 +804,7 @@ private void executeCrafting(final IEnergyGrid eg, final CraftingGridCache cc) {
this.somethingChanged = true;
this.remainingOperations--;
pushedPattern = true;
this.isFakeCrafting = (m instanceof DualityInterface di && di.isFakeCraftingMode());

for (final IAEItemStack out : details.getCondensedOutputs()) {
this.postChange(out, this.machineSrc);
Expand Down Expand Up @@ -816,7 +834,6 @@ private void executeCrafting(final IEnergyGrid eg, final CraftingGridCache cc) {
Platform.getPlayer((WorldServer) this.getWorld()),
details.getOutput(ic, this.getWorld()),
ic);

for (int x = 0; x < ic.getSizeInventory(); x++) {
final ItemStack output = Platform.getContainerItem(ic.getStackInSlot(x));
if (output != null) {
Expand Down Expand Up @@ -934,6 +951,7 @@ public ICraftingLink submitJob(final IGrid g, final ICraftingJob job, final Base
// when it comes to a new craft,
if (job.getOutput() != null) {
this.finalOutput = job.getOutput();
this.isFakeCrafting = false;
this.waiting = false;
this.isComplete = false;
this.usedStorage = job.getByteTotal();
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/appeng/parts/automation/UpgradeInventory.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
private int patternCapacityUpgrades = 0;
private int advancedBlockingUpgrades = 0;
private int lockCraftingUpgrades = 0;
private int fakeCraftingUpgrades = 0;
private int stickyUpgrades = 0;

public UpgradeInventory(final IAEAppEngInventory parent, final int s) {
Expand Down Expand Up @@ -89,6 +90,7 @@ public int getInstalledUpgrades(final Upgrades u) {
case ADVANCED_BLOCKING -> this.advancedBlockingUpgrades;
case LOCK_CRAFTING -> this.lockCraftingUpgrades;
case STICKY -> this.stickyUpgrades;
case FAKE_CRAFTING -> this.fakeCraftingUpgrades;
default -> 0;
};
}
Expand All @@ -97,7 +99,7 @@ public int getInstalledUpgrades(final Upgrades u) {

private void updateUpgradeInfo() {
this.cached = true;
this.patternCapacityUpgrades = this.stickyUpgrades = this.inverterUpgrades = this.capacityUpgrades = this.redstoneUpgrades = this.speedUpgrades = this.superSpeedUpgrades = this.fuzzyUpgrades = this.craftingUpgrades = this.oreFilterUpgrades = this.advancedBlockingUpgrades = this.lockCraftingUpgrades = 0;
this.patternCapacityUpgrades = this.stickyUpgrades = this.inverterUpgrades = this.capacityUpgrades = this.redstoneUpgrades = this.speedUpgrades = this.superSpeedUpgrades = this.fuzzyUpgrades = this.craftingUpgrades = this.oreFilterUpgrades = this.advancedBlockingUpgrades = this.lockCraftingUpgrades = this.fakeCraftingUpgrades = 0;

for (final ItemStack is : this) {
if (is == null || is.getItem() == null || !(is.getItem() instanceof IUpgradeModule)) {
Expand All @@ -118,6 +120,7 @@ private void updateUpgradeInfo() {
case ADVANCED_BLOCKING -> this.advancedBlockingUpgrades++;
case LOCK_CRAFTING -> this.lockCraftingUpgrades++;
case STICKY -> this.stickyUpgrades++;
case FAKE_CRAFTING -> this.fakeCraftingUpgrades++;
default -> {}
}
}
Expand All @@ -135,6 +138,7 @@ private void updateUpgradeInfo() {
this.advancedBlockingUpgrades = Math
.min(this.advancedBlockingUpgrades, this.getMaxInstalled(Upgrades.ADVANCED_BLOCKING));
this.lockCraftingUpgrades = Math.min(this.lockCraftingUpgrades, this.getMaxInstalled(Upgrades.LOCK_CRAFTING));
this.fakeCraftingUpgrades = Math.min(this.fakeCraftingUpgrades, this.getMaxInstalled(Upgrades.FAKE_CRAFTING));
this.stickyUpgrades = Math.min(this.stickyUpgrades, this.getMaxInstalled(Upgrades.STICKY));
}

Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/assets/appliedenergistics2/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,10 @@ gui.tooltips.appliedenergistics2.CraftingModeStandardDesc=Only starts craft if a
gui.tooltips.appliedenergistics2.CraftingModeIgnoreMissing=Ignore Missing Crafting Mode
gui.tooltips.appliedenergistics2.CraftingModeIgnoreMissingDesc=Starts craft even if ingredients are missing from the ME System.

gui.tooltips.appliedenergistics2.FakeCraftingMode=Fake Crafting
gui.tooltips.appliedenergistics2.FakeCraftingOn=Fake Crafting Mode
gui.tooltips.appliedenergistics2.FakeCraftingOff=Standard Crafting Mode

gui.tooltips.appliedenergistics2.ExtraOptions=Extra Options

gui.tooltips.appliedenergistics2.SwitchBytesInfo=Cell Info
Expand Down Expand Up @@ -625,6 +629,7 @@ item.appliedenergistics2.ItemMaterial.CardPatternRefiller.name=Pattern Refiller
item.appliedenergistics2.ItemMaterial.CardAdvancedBlocking.name=Advanced Blocking Card
item.appliedenergistics2.ItemMaterial.CardLockCrafting.name=Locking Card
item.appliedenergistics2.ItemMaterial.CardSticky.name=Sticky Card
item.appliedenergistics2.ItemMaterial.CardFakeCrafting.name=Fake Crafting Card

item.appliedenergistics2.ItemMaterial.Cell2SpatialPart.name=2³ Spatial Component
item.appliedenergistics2.ItemMaterial.Cell16SpatialPart.name=16³ Spatial Component
Expand Down
Loading
Loading