Skip to content

Commit

Permalink
large item cells (AppliedEnergistics#234)
Browse files Browse the repository at this point in the history
* fluid energy and io multiplier

* oversight

* requst changes

* large item cells
  • Loading branch information
GlodBlock authored Jan 24, 2023
1 parent f22c43b commit 4b7d593
Show file tree
Hide file tree
Showing 23 changed files with 300 additions and 50 deletions.
8 changes: 8 additions & 0 deletions src/main/java/appeng/api/definitions/IItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ public interface IItems {

IItemDefinition cell64k();

IItemDefinition cell256k();

IItemDefinition cell1024k();

IItemDefinition cell4096k();

IItemDefinition cell16384k();

IItemDefinition spatialCell2();

IItemDefinition spatialCell16();
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/appeng/api/definitions/IMaterials.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ public interface IMaterials {

IItemDefinition emptyStorageCell();

IItemDefinition cell256kPart();

IItemDefinition cell1024kPart();

IItemDefinition cell4096kPart();

IItemDefinition cell16384kPart();

IItemDefinition emptyAdvancedStorageCell();

IItemDefinition cardRedstone();

IItemDefinition cardSpeed();
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/appeng/core/Registration.java
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,22 @@ void postInit(final FMLPostInitializationEvent event) {
Upgrades.INVERTER.registerItem(items.cell64k(), 1);
Upgrades.ORE_FILTER.registerItem(items.cell64k(), 1);

Upgrades.FUZZY.registerItem(items.cell256k(), 1);
Upgrades.INVERTER.registerItem(items.cell256k(), 1);
Upgrades.ORE_FILTER.registerItem(items.cell256k(), 1);

Upgrades.FUZZY.registerItem(items.cell1024k(), 1);
Upgrades.INVERTER.registerItem(items.cell1024k(), 1);
Upgrades.ORE_FILTER.registerItem(items.cell1024k(), 1);

Upgrades.FUZZY.registerItem(items.cell4096k(), 1);
Upgrades.INVERTER.registerItem(items.cell4096k(), 1);
Upgrades.ORE_FILTER.registerItem(items.cell4096k(), 1);

Upgrades.FUZZY.registerItem(items.cell16384k(), 1);
Upgrades.INVERTER.registerItem(items.cell16384k(), 1);
Upgrades.ORE_FILTER.registerItem(items.cell16384k(), 1);

Upgrades.FUZZY.registerItem(items.portableCell(), 1);
Upgrades.INVERTER.registerItem(items.portableCell(), 1);
Upgrades.ORE_FILTER.registerItem(items.portableCell(), 1);
Expand Down
36 changes: 32 additions & 4 deletions src/main/java/appeng/core/api/definitions/ApiItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@
import appeng.items.misc.ItemEncodedPattern;
import appeng.items.misc.ItemPaintBall;
import appeng.items.parts.ItemFacade;
import appeng.items.storage.ItemBasicStorageCell;
import appeng.items.storage.ItemCreativeStorageCell;
import appeng.items.storage.ItemSpatialStorageCell;
import appeng.items.storage.ItemViewCell;
import appeng.items.storage.*;
import appeng.items.tools.ToolBiometricCard;
import appeng.items.tools.ToolMemoryCard;
import appeng.items.tools.ToolNetworkTool;
Expand Down Expand Up @@ -77,6 +74,10 @@ public final class ApiItems implements IItems {
private final IItemDefinition cell4k;
private final IItemDefinition cell16k;
private final IItemDefinition cell64k;
private final IItemDefinition cell256k;
private final IItemDefinition cell1024k;
private final IItemDefinition cell4096k;
private final IItemDefinition cell16384k;

private final IItemDefinition spatialCell2;
private final IItemDefinition spatialCell16;
Expand Down Expand Up @@ -134,6 +135,13 @@ public ApiItems(final DefinitionConstructor constructor) {
this.cell4k = constructor.registerItemDefinition(new ItemBasicStorageCell(MaterialType.Cell4kPart, 4));
this.cell16k = constructor.registerItemDefinition(new ItemBasicStorageCell(MaterialType.Cell16kPart, 16));
this.cell64k = constructor.registerItemDefinition(new ItemBasicStorageCell(MaterialType.Cell64kPart, 64));
this.cell256k = constructor.registerItemDefinition(new ItemAdvancedStorageCell(MaterialType.Cell256kPart, 256));
this.cell1024k =
constructor.registerItemDefinition(new ItemAdvancedStorageCell(MaterialType.Cell1024kPart, 1024));
this.cell4096k =
constructor.registerItemDefinition(new ItemAdvancedStorageCell(MaterialType.Cell4096kPart, 4096));
this.cell16384k =
constructor.registerItemDefinition(new ItemAdvancedStorageCell(MaterialType.Cell16384kPart, 16384));

this.spatialCell2 = constructor.registerItemDefinition(new ItemSpatialStorageCell(2));
this.spatialCell16 = constructor.registerItemDefinition(new ItemSpatialStorageCell(16));
Expand Down Expand Up @@ -296,6 +304,26 @@ public IItemDefinition cell64k() {
return this.cell64k;
}

@Override
public IItemDefinition cell256k() {
return this.cell256k;
}

@Override
public IItemDefinition cell1024k() {
return this.cell1024k;
}

@Override
public IItemDefinition cell4096k() {
return this.cell4096k;
}

@Override
public IItemDefinition cell16384k() {
return this.cell16384k;
}

@Override
public IItemDefinition spatialCell2() {
return this.spatialCell2;
Expand Down
36 changes: 36 additions & 0 deletions src/main/java/appeng/core/api/definitions/ApiMaterials.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ public final class ApiMaterials implements IMaterials {
private final IItemDefinition cell16kPart;
private final IItemDefinition cell64kPart;
private final IItemDefinition emptyStorageCell;
private final IItemDefinition cell256kPart;
private final IItemDefinition cell1024kPart;
private final IItemDefinition cell4096kPart;
private final IItemDefinition cell16384kPart;
private final IItemDefinition emptyAdvancedStorageCell;

private final IItemDefinition cardRedstone;
private final IItemDefinition cardSpeed;
Expand Down Expand Up @@ -155,6 +160,12 @@ public ApiMaterials(final DefinitionConstructor constructor) {
this.cell64kPart = new DamagedItemDefinition(itemMultiMaterial.createMaterial(MaterialType.Cell64kPart));
this.emptyStorageCell =
new DamagedItemDefinition(itemMultiMaterial.createMaterial(MaterialType.EmptyStorageCell));
this.cell256kPart = new DamagedItemDefinition(itemMultiMaterial.createMaterial(MaterialType.Cell256kPart));
this.cell1024kPart = new DamagedItemDefinition(itemMultiMaterial.createMaterial(MaterialType.Cell1024kPart));
this.cell4096kPart = new DamagedItemDefinition(itemMultiMaterial.createMaterial(MaterialType.Cell4096kPart));
this.cell16384kPart = new DamagedItemDefinition(itemMultiMaterial.createMaterial(MaterialType.Cell16384kPart));
this.emptyAdvancedStorageCell =
new DamagedItemDefinition(itemMultiMaterial.createMaterial(MaterialType.EmptyAdvancedStorageCell));

this.cardRedstone = new DamagedItemDefinition(itemMultiMaterial.createMaterial(MaterialType.CardRedstone));
this.cardSpeed = new DamagedItemDefinition(itemMultiMaterial.createMaterial(MaterialType.CardSpeed));
Expand Down Expand Up @@ -337,6 +348,31 @@ public IItemDefinition emptyStorageCell() {
return this.emptyStorageCell;
}

@Override
public IItemDefinition cell256kPart() {
return this.cell256kPart;
}

@Override
public IItemDefinition cell1024kPart() {
return this.cell1024kPart;
}

@Override
public IItemDefinition cell4096kPart() {
return this.cell4096kPart;
}

@Override
public IItemDefinition cell16384kPart() {
return this.cell16384kPart;
}

@Override
public IItemDefinition emptyAdvancedStorageCell() {
return this.emptyAdvancedStorageCell;
}

@Override
public IItemDefinition cardRedstone() {
return this.cardRedstone;
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/appeng/items/materials/MaterialType.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,13 @@ public enum MaterialType {
CardCrafting(53),
CardPatternCapacity(54),
CardOreFilter(55),
CardSuperSpeed(56);
CardSuperSpeed(56),
Cell256kPart(57, AEFeature.StorageCells),
Cell1024kPart(58, AEFeature.StorageCells),
Cell4096kPart(59, AEFeature.StorageCells),
Cell16384kPart(60, AEFeature.StorageCells),
EmptyAdvancedStorageCell(61, AEFeature.StorageCells);

private final EnumSet<AEFeature> features;
// IIcon for the material.
@SideOnly(Side.CLIENT)
Expand Down
63 changes: 63 additions & 0 deletions src/main/java/appeng/items/storage/ItemAdvancedStorageCell.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package appeng.items.storage;

import appeng.api.AEApi;
import appeng.api.definitions.IItemDefinition;
import appeng.api.exceptions.MissingDefinition;
import appeng.core.features.AEFeature;
import appeng.items.materials.MaterialType;
import com.google.common.base.Optional;
import java.util.EnumSet;
import net.minecraft.item.ItemStack;

public class ItemAdvancedStorageCell extends ItemBasicStorageCell {

@SuppressWarnings("Guava")
public ItemAdvancedStorageCell(final MaterialType whichCell, final int kilobytes) {
super(Optional.of(kilobytes + "k"));

this.setFeature(EnumSet.of(AEFeature.StorageCells));
this.setMaxStackSize(1);
this.totalBytes = kilobytes * 1024;
this.component = whichCell;

switch (this.component) {
case Cell256kPart:
this.idleDrain = 2.5;
this.perType = 2048;
break;
case Cell1024kPart:
this.idleDrain = 3.0;
this.perType = 8192;
break;
case Cell4096kPart:
this.idleDrain = 3.5;
this.perType = 32768;
break;
case Cell16384kPart:
this.idleDrain = 4.0;
this.perType = 131072;
break;
default:
this.idleDrain = 0.0;
this.perType = 8;
}
}

@Override
protected IItemDefinition getStorageCellCase() {
return AEApi.instance().definitions().materials().emptyAdvancedStorageCell();
}

@Override
public ItemStack getContainerItem(final ItemStack itemStack) {
for (final ItemStack stack : AEApi.instance()
.definitions()
.materials()
.emptyAdvancedStorageCell()
.maybeStack(1)
.asSet()) {
return stack;
}
throw new MissingDefinition("Tried to use empty storage cells while basic storage cells are defined.");
}
}
30 changes: 19 additions & 11 deletions src/main/java/appeng/items/storage/ItemBasicStorageCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode;
import appeng.api.config.IncludeExclude;
import appeng.api.definitions.IItemDefinition;
import appeng.api.exceptions.MissingDefinition;
import appeng.api.implementations.items.IItemGroup;
import appeng.api.implementations.items.IStorageCell;
Expand Down Expand Up @@ -56,12 +57,13 @@
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.ForgeEventFactory;

public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, IItemGroup {
private final MaterialType component;
private final int totalBytes;
private final int perType;
private final double idleDrain;
public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, IItemGroup {
protected MaterialType component;
protected int totalBytes;
protected int perType;
protected double idleDrain;

@SuppressWarnings("Guava")
public ItemBasicStorageCell(final MaterialType whichCell, final int kilobytes) {
super(Optional.of(kilobytes + "k"));

Expand Down Expand Up @@ -93,6 +95,11 @@ public ItemBasicStorageCell(final MaterialType whichCell, final int kilobytes) {
}
}

@SuppressWarnings("Guava")
public ItemBasicStorageCell(final Optional<String> subName) {
super(subName);
}

@SideOnly(Side.CLIENT)
@Override
public void addCheckedInformation(
Expand Down Expand Up @@ -236,6 +243,7 @@ public ItemStack onItemRightClick(final ItemStack stack, final World world, fina
return stack;
}

@SuppressWarnings({"rawtypes", "unchecked"})
private boolean disassembleDrive(final ItemStack stack, final World world, final EntityPlayer player) {
if (player.isSneaking()) {
if (Platform.isClient()) {
Expand Down Expand Up @@ -267,12 +275,8 @@ private boolean disassembleDrive(final ItemStack stack, final World world, final
}

// drop empty storage cell case
for (final ItemStack storageCellStack : AEApi.instance()
.definitions()
.materials()
.emptyStorageCell()
.maybeStack(1)
.asSet()) {
for (final ItemStack storageCellStack :
getStorageCellCase().maybeStack(1).asSet()) {
final ItemStack extraA = ia.addItems(storageCellStack);
if (extraA != null) {
player.dropPlayerItemWithRandomChoice(extraA, false);
Expand All @@ -290,6 +294,10 @@ private boolean disassembleDrive(final ItemStack stack, final World world, final
return false;
}

protected IItemDefinition getStorageCellCase() {
return AEApi.instance().definitions().materials().emptyStorageCell();
}

@Override
public boolean onItemUseFirst(
final ItemStack stack,
Expand Down
Loading

0 comments on commit 4b7d593

Please sign in to comment.