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
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();
}
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 @@ -611,6 +611,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;
}
}
4 changes: 4 additions & 0 deletions src/main/java/appeng/helpers/DualityInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,10 @@ private InsertionMode getInsertionMode() {
return (InsertionMode) cm.getSetting(Settings.INSERTION_MODE);
}

public boolean isFakeCraftingMode() {
return this.getInstalledUpgrades(Upgrades.FAKE_CRAFTING) != 0;
}

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
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,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
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ item.appliedenergistics2.ItemMaterial.CardPatternRefiller.name=空白样板重
item.appliedenergistics2.ItemMaterial.CardAdvancedBlocking.name=高级阻挡卡
item.appliedenergistics2.ItemMaterial.CardLockCrafting.name=Locking Card
item.appliedenergistics2.ItemMaterial.CardSticky.name=粘性卡
item.appliedenergistics2.ItemMaterial.CardFakeCrafting.name=伪合成卡

item.appliedenergistics2.ItemMaterial.Cell2SpatialPart.name=2³-空间组件
item.appliedenergistics2.ItemMaterial.Cell16SpatialPart.name=16³-空间组件
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading