This commit is contained in:
PrototypeTrousers
2023-01-30 16:50:47 -03:00
parent 13c3067068
commit 9dee7f6c0e
11 changed files with 192 additions and 134 deletions
+50 -55
View File
@@ -32,66 +32,61 @@ import net.minecraft.item.ItemStack;
import appeng.api.definitions.IItemDefinition;
public enum Upgrades
{
/**
* Gold Tier Upgrades.
*/
CAPACITY( 0 ),
REDSTONE( 0 ),
CRAFTING( 0 ),
public enum Upgrades {
/**
* Gold Tier Upgrades.
*/
CAPACITY(0),
REDSTONE(0),
CRAFTING(0),
MAGNET(0),
/**
* Diamond Tier Upgrades.
*/
FUZZY( 1 ),
SPEED( 1 ),
INVERTER( 1 ),
PATTERN_EXPANSION(1);
/**
* Diamond Tier Upgrades.
*/
FUZZY(1),
SPEED(1),
INVERTER(1),
PATTERN_EXPANSION(1),
QUANTUM_LINK(1);
private final int tier;
private final Map<ItemStack, Integer> supportedMax = new HashMap<>();
private final int tier;
private final Map<ItemStack, Integer> supportedMax = new HashMap<>();
Upgrades( final int tier )
{
this.tier = tier;
}
Upgrades(final int tier) {
this.tier = tier;
}
/**
* @return list of Items/Blocks that support this upgrade, and how many it supports.
*/
public Map<ItemStack, Integer> getSupported()
{
return this.supportedMax;
}
/**
* @return list of Items/Blocks that support this upgrade, and how many it supports.
*/
public Map<ItemStack, Integer> getSupported() {
return this.supportedMax;
}
/**
* Registers a specific amount of this upgrade into a specific machine
*
* @param item machine in which this upgrade can be installed
* @param maxSupported amount how many upgrades can be installed
*/
public void registerItem( final IItemDefinition item, final int maxSupported )
{
item.maybeStack( 1 ).ifPresent( is -> this.registerItem( is, maxSupported ) );
}
/**
* Registers a specific amount of this upgrade into a specific machine
*
* @param item machine in which this upgrade can be installed
* @param maxSupported amount how many upgrades can be installed
*/
public void registerItem(final IItemDefinition item, final int maxSupported) {
item.maybeStack(1).ifPresent(is -> this.registerItem(is, maxSupported));
}
/**
* Registers a specific amount of this upgrade into a specific machine
*
* @param stack machine in which this upgrade can be installed
* @param maxSupported amount how many upgrades can be installed
*/
public void registerItem( final ItemStack stack, final int maxSupported )
{
if( stack != null )
{
this.supportedMax.put( stack, maxSupported );
}
}
/**
* Registers a specific amount of this upgrade into a specific machine
*
* @param stack machine in which this upgrade can be installed
* @param maxSupported amount how many upgrades can be installed
*/
public void registerItem(final ItemStack stack, final int maxSupported) {
if (stack != null) {
this.supportedMax.put(stack, maxSupported);
}
}
public int getTier()
{
return this.tier;
}
public int getTier() {
return this.tier;
}
}
@@ -27,121 +27,124 @@ package appeng.api.definitions;
/**
* A list of all materials in AE
*/
public interface IMaterials
{
IItemDefinition cell2SpatialPart();
public interface IMaterials {
IItemDefinition cell2SpatialPart();
IItemDefinition cell16SpatialPart();
IItemDefinition cell16SpatialPart();
IItemDefinition cell128SpatialPart();
IItemDefinition cell128SpatialPart();
IItemDefinition silicon();
IItemDefinition silicon();
IItemDefinition skyDust();
IItemDefinition skyDust();
IItemDefinition calcProcessorPress();
IItemDefinition calcProcessorPress();
IItemDefinition engProcessorPress();
IItemDefinition engProcessorPress();
IItemDefinition logicProcessorPress();
IItemDefinition logicProcessorPress();
IItemDefinition calcProcessorPrint();
IItemDefinition calcProcessorPrint();
IItemDefinition engProcessorPrint();
IItemDefinition engProcessorPrint();
IItemDefinition logicProcessorPrint();
IItemDefinition logicProcessorPrint();
IItemDefinition siliconPress();
IItemDefinition siliconPress();
IItemDefinition siliconPrint();
IItemDefinition siliconPrint();
IItemDefinition namePress();
IItemDefinition namePress();
IItemDefinition logicProcessor();
IItemDefinition logicProcessor();
IItemDefinition calcProcessor();
IItemDefinition calcProcessor();
IItemDefinition engProcessor();
IItemDefinition engProcessor();
IItemDefinition basicCard();
IItemDefinition basicCard();
IItemDefinition advCard();
IItemDefinition advCard();
IItemDefinition purifiedCertusQuartzCrystal();
IItemDefinition purifiedCertusQuartzCrystal();
IItemDefinition purifiedNetherQuartzCrystal();
IItemDefinition purifiedNetherQuartzCrystal();
IItemDefinition purifiedFluixCrystal();
IItemDefinition purifiedFluixCrystal();
IItemDefinition cell1kPart();
IItemDefinition cell1kPart();
IItemDefinition cell4kPart();
IItemDefinition cell4kPart();
IItemDefinition cell16kPart();
IItemDefinition cell16kPart();
IItemDefinition cell64kPart();
IItemDefinition cell64kPart();
IItemDefinition emptyStorageCell();
IItemDefinition emptyStorageCell();
IItemDefinition cardRedstone();
IItemDefinition cardRedstone();
IItemDefinition cardSpeed();
IItemDefinition cardSpeed();
IItemDefinition cardCapacity();
IItemDefinition cardCapacity();
IItemDefinition cardPatternExpansion();
IItemDefinition cardPatternExpansion();
IItemDefinition cardFuzzy();
public IItemDefinition cardQuantumLink();
IItemDefinition cardInverter();
public IItemDefinition cardMagnet();
IItemDefinition cardCrafting();
IItemDefinition cardFuzzy();
IItemDefinition enderDust();
IItemDefinition cardInverter();
IItemDefinition flour();
IItemDefinition cardCrafting();
IItemDefinition goldDust();
IItemDefinition enderDust();
IItemDefinition ironDust();
IItemDefinition flour();
IItemDefinition fluixDust();
IItemDefinition goldDust();
IItemDefinition certusQuartzDust();
IItemDefinition ironDust();
IItemDefinition netherQuartzDust();
IItemDefinition fluixDust();
IItemDefinition matterBall();
IItemDefinition certusQuartzDust();
IItemDefinition certusQuartzCrystal();
IItemDefinition netherQuartzDust();
IItemDefinition certusQuartzCrystalCharged();
IItemDefinition matterBall();
IItemDefinition fluixCrystal();
IItemDefinition certusQuartzCrystal();
IItemDefinition fluixPearl();
IItemDefinition certusQuartzCrystalCharged();
IItemDefinition woodenGear();
IItemDefinition fluixCrystal();
IItemDefinition wirelessReceiver();
IItemDefinition fluixPearl();
IItemDefinition wirelessBooster();
IItemDefinition woodenGear();
IItemDefinition annihilationCore();
IItemDefinition wirelessReceiver();
IItemDefinition formationCore();
IItemDefinition wirelessBooster();
IItemDefinition singularity();
IItemDefinition annihilationCore();
IItemDefinition qESingularity();
IItemDefinition formationCore();
IItemDefinition blankPattern();
IItemDefinition singularity();
IItemDefinition fluidCell1kPart();
IItemDefinition qESingularity();
IItemDefinition fluidCell4kPart();
IItemDefinition blankPattern();
IItemDefinition fluidCell16kPart();
IItemDefinition fluidCell1kPart();
IItemDefinition fluidCell64kPart();
IItemDefinition fluidCell4kPart();
IItemDefinition fluidCell16kPart();
IItemDefinition fluidCell64kPart();
}
@@ -108,9 +108,9 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable implements I
public void setupUpgrades() {
if (wirelessTerminalGUIObject != null) {
final IItemHandler upgrades = wirelessTerminalGUIObject.getInventoryByName("upgrades");
for (int a = 0; a < availableUpgrades(); a++) {
for (int upgradeSlot = 0; upgradeSlot < availableUpgrades(); upgradeSlot++) {
this.addSlotToContainer(
(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, a * 18, this.getInventoryPlayer()))
(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, upgradeSlot, 187, upgradeSlot * 18, this.getInventoryPlayer()))
.setNotDraggable());
}
}
@@ -114,7 +114,7 @@ public class ContainerWirelessPatternTerminal extends ContainerPatternEncoder im
if (this.wirelessTerminalGUIObject == null || currentItem.isEmpty()) {
this.setValidContainer(false);
} else if (this.wirelessTerminalGUIObject != null && !this.wirelessTerminalGUIObject.getItemStack().isEmpty() && currentItem != this.wirelessTerminalGUIObject.getItemStack()) {
} else if (!this.wirelessTerminalGUIObject.getItemStack().isEmpty() && currentItem != this.wirelessTerminalGUIObject.getItemStack()) {
if (ItemStack.areItemsEqual(this.wirelessTerminalGUIObject.getItemStack(), currentItem)) {
this.getPlayerInv().setInventorySlotContents(this.getPlayerInv().currentItem, this.wirelessTerminalGUIObject.getItemStack());
} else {
@@ -239,9 +239,9 @@ public class ContainerWirelessPatternTerminal extends ContainerPatternEncoder im
public void setupUpgrades() {
if (wirelessTerminalGUIObject != null) {
final IItemHandler upgrades = wirelessTerminalGUIObject.getInventoryByName("upgrades");
for (int a = 0; a < availableUpgrades(); a++) {
for (int upgradeSlot = 0; upgradeSlot < availableUpgrades(); upgradeSlot++) {
this.addSlotToContainer(
(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, -2 + a * 18, this.getInventoryPlayer()))
(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, upgradeSlot, 187, upgradeSlot * 18 - 2, this.getInventoryPlayer()))
.setNotDraggable());
}
}
+16 -5
View File
@@ -21,6 +21,7 @@ package appeng.core;
import appeng.api.config.Upgrades;
import appeng.api.definitions.IBlocks;
import appeng.api.definitions.IItemDefinition;
import appeng.api.definitions.IItems;
import appeng.api.definitions.IParts;
import appeng.api.features.IRecipeHandlerRegistry;
@@ -105,7 +106,9 @@ import javax.annotation.Nonnull;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -403,11 +406,19 @@ final class Registration {
Upgrades.SPEED.registerItem(blocks.inscriber(), 3);
// Wireless Terminal Handler
items.wirelessTerminal().maybeItem().ifPresent(terminal -> registries.wireless().registerWirelessHandler((IWirelessTermHandler) terminal));
items.wirelessCraftingTerminal().maybeItem().ifPresent(terminal -> registries.wireless().registerWirelessHandler((IWirelessTermHandler) terminal));
items.wirelessPatternTerminal().maybeItem().ifPresent(terminal -> registries.wireless().registerWirelessHandler((IWirelessTermHandler) terminal));
items.wirelessFluidTerminal().maybeItem().ifPresent(terminal -> registries.wireless().registerWirelessHandler((IWirelessTermHandler) terminal));
ArrayList<IItemDefinition> iids = new ArrayList<>();
iids.add(items.wirelessTerminal());
iids.add(items.wirelessCraftingTerminal());
iids.add(items.wirelessPatternTerminal());
iids.add(items.wirelessFluidTerminal());
for (IItemDefinition id : iids) {
id.maybeItem().ifPresent(terminal -> {
registries.wireless().registerWirelessHandler((IWirelessTermHandler) terminal);
Upgrades.QUANTUM_LINK.registerItem(id, 1);
Upgrades.MAGNET.registerItem(id, 1);
});
}
// Charge Rates
items.chargedStaff().maybeItem().ifPresent(chargedStaff -> registries.charger().addChargeRate(chargedStaff, 320d));
@@ -85,6 +85,8 @@ public final class ApiMaterials implements IMaterials {
private final IItemDefinition cardSpeed;
private final IItemDefinition cardCapacity;
private final IItemDefinition cardPatternExpansion;
private final IItemDefinition cardQuantumLink;
private final IItemDefinition cardMagnet;
private final IItemDefinition cardFuzzy;
private final IItemDefinition cardInverter;
private final IItemDefinition cardCrafting;
@@ -201,6 +203,8 @@ public final class ApiMaterials implements IMaterials {
this.cardSpeed = new DamagedItemDefinition("material.card.acceleration", materials.createMaterial(MaterialType.CARD_SPEED));
this.cardCapacity = new DamagedItemDefinition("material.card.capacity", materials.createMaterial(MaterialType.CARD_CAPACITY));
this.cardPatternExpansion = new DamagedItemDefinition("material.card.pattern.expansion", materials.createMaterial(MaterialType.CARD_PATTERN_EXPANSION));
this.cardQuantumLink = new DamagedItemDefinition("material.card.quantum.link", materials.createMaterial(MaterialType.CARD_QUANTUM_LINK));
this.cardMagnet = new DamagedItemDefinition("material.card.magnet", materials.createMaterial(MaterialType.CARD_MAGNET));
this.cardFuzzy = new DamagedItemDefinition("material.card.fuzzy", materials.createMaterial(MaterialType.CARD_FUZZY));
this.cardInverter = new DamagedItemDefinition("material.card.inverter", materials.createMaterial(MaterialType.CARD_INVERTER));
this.cardCrafting = new DamagedItemDefinition("material.card.crafting", materials.createMaterial(MaterialType.CARD_CRAFTING));
@@ -396,6 +400,16 @@ public final class ApiMaterials implements IMaterials {
return this.cardPatternExpansion;
}
@Override
public IItemDefinition cardQuantumLink() {
return this.cardQuantumLink;
}
@Override
public IItemDefinition cardMagnet() {
return this.cardMagnet;
}
@Override
public IItemDefinition cardFuzzy() {
return this.cardFuzzy;
@@ -39,6 +39,8 @@ import appeng.helpers.WirelessTerminalGuiObject;
import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
import appeng.util.inv.IAEAppEngInventory;
import appeng.util.inv.InvOperation;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
@@ -53,7 +55,7 @@ import javax.annotation.Nonnull;
import java.io.IOException;
import java.nio.BufferOverflowException;
public class ContainerMEPortableFluidCell extends AEBaseContainer implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<IAEFluidStack>, IUpgradeableCellContainer {
public class ContainerMEPortableFluidCell extends AEBaseContainer implements IAEAppEngInventory, IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<IAEFluidStack>, IUpgradeableCellContainer {
private final WirelessTerminalGuiObject wirelessTerminalGUIObject;
@@ -138,7 +140,7 @@ public class ContainerMEPortableFluidCell extends AEBaseContainer implements ICo
if (this.wirelessTerminalGUIObject == null || currentItem.isEmpty()) {
this.setValidContainer(false);
} else if (this.wirelessTerminalGUIObject != null && !this.wirelessTerminalGUIObject.getItemStack().isEmpty() && currentItem != this.wirelessTerminalGUIObject.getItemStack()) {
} else if (!this.wirelessTerminalGUIObject.getItemStack().isEmpty() && currentItem != this.wirelessTerminalGUIObject.getItemStack()) {
if (ItemStack.areItemsEqual(this.wirelessTerminalGUIObject.getItemStack(), currentItem)) {
this.getPlayerInv().setInventorySlotContents(this.getPlayerInv().currentItem, this.wirelessTerminalGUIObject.getItemStack());
} else {
@@ -524,13 +526,24 @@ public class ContainerMEPortableFluidCell extends AEBaseContainer implements ICo
@Override
public void setupUpgrades() {
if (wirelessTerminalGUIObject instanceof WirelessTerminalGuiObject) {
final IItemHandler upgrades = ((WirelessTerminalGuiObject) wirelessTerminalGUIObject).getInventoryByName("upgrades");
for (int a = 0; a < availableUpgrades(); a++) {
if (wirelessTerminalGUIObject != null) {
final IItemHandler upgrades = wirelessTerminalGUIObject.getInventoryByName("upgrades");
for (int upgradeSlot = 0; upgradeSlot < availableUpgrades(); upgradeSlot++) {
this.addSlotToContainer(
(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 139 + a * 18, this.getInventoryPlayer()))
(new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, upgradeSlot, 187, 139 + upgradeSlot * 18, this.getInventoryPlayer()))
.setNotDraggable());
}
}
}
@Override
public void saveChanges() {
}
@Override
public void onChangeInventory(IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) {
}
}
@@ -105,7 +105,7 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
}
}
upgrades = new StackUpgradeInventory(effectiveItem, this, 4);
upgrades = new StackUpgradeInventory(effectiveItem, this, 2);
this.loadFromNBT();
}
@@ -319,6 +319,7 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
data = new NBTTagCompound();
}
viewCell.writeToNBT(data, "viewCell");
upgrades.writeToNBT(data, "upgrades");
}
@Override
@@ -347,6 +348,8 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
public IItemHandler getInventoryByName(String name) {
if (name.equals("upgrades")) {
return upgrades;
} else if (name.equals("viewCell")) {
return viewCell;
}
return null;
}
@@ -144,6 +144,10 @@ public final class ItemMaterial extends AEBaseItem implements IStorageComponent,
return Upgrades.CRAFTING;
case CARD_PATTERN_EXPANSION:
return Upgrades.PATTERN_EXPANSION;
case CARD_MAGNET:
return Upgrades.MAGNET;
case CARD_QUANTUM_LINK:
return Upgrades.QUANTUM_LINK;
default:
return null;
}
@@ -118,7 +118,9 @@ public enum MaterialType {
FLUID_CELL16K_PART(56, "material_fluid_cell16k_part", EnumSet.of(AEFeature.STORAGE_CELLS)),
FLUID_CELL64K_PART(57, "material_fluid_cell64k_part", EnumSet.of(AEFeature.STORAGE_CELLS)),
CARD_PATTERN_EXPANSION(58, "material_card_pattern_expansion", EnumSet.of(AEFeature.ADVANCED_CARDS));
CARD_PATTERN_EXPANSION(58, "material_card_pattern_expansion", EnumSet.of(AEFeature.ADVANCED_CARDS)),
CARD_QUANTUM_LINK(59, "material_card_quantum_link", EnumSet.of(AEFeature.ADVANCED_CARDS)),
CARD_MAGNET(60, "material_card_quantum_link", EnumSet.of(AEFeature.BASIC_CARDS));
private final Set<AEFeature> features;
@@ -46,6 +46,8 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
private int inverterUpgrades = 0;
private int craftingUpgrades = 0;
private int patternExpansionUpgrades = 0;
private int magnetUpgrades = 0;
private int quantumUpgrades = 0;
public UpgradeInventory(final IAEAppEngInventory parent, final int s) {
super(null, s, 1);
@@ -79,6 +81,10 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
return this.craftingUpgrades;
case PATTERN_EXPANSION:
return this.patternExpansionUpgrades;
case MAGNET:
return this.magnetUpgrades;
case QUANTUM_LINK:
return this.quantumUpgrades;
default:
return 0;
}
@@ -88,7 +94,7 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
private void updateUpgradeInfo() {
this.cached = true;
this.patternExpansionUpgrades = this.inverterUpgrades = this.capacityUpgrades = this.redstoneUpgrades = this.speedUpgrades = this.fuzzyUpgrades = this.craftingUpgrades = 0;
this.patternExpansionUpgrades = this.inverterUpgrades = this.capacityUpgrades = this.redstoneUpgrades = this.speedUpgrades = this.fuzzyUpgrades = this.craftingUpgrades = magnetUpgrades = quantumUpgrades = 0;
for (final ItemStack is : this) {
if (is == null || is.getItem() == Items.AIR || !(is.getItem() instanceof IUpgradeModule)) {
@@ -118,6 +124,11 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
case PATTERN_EXPANSION:
this.patternExpansionUpgrades++;
break;
case MAGNET:
this.magnetUpgrades++;
break;
case QUANTUM_LINK:
this.quantumUpgrades++;
default:
break;
}
@@ -130,6 +141,8 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
this.inverterUpgrades = Math.min(this.inverterUpgrades, this.getMaxInstalled(Upgrades.INVERTER));
this.craftingUpgrades = Math.min(this.craftingUpgrades, this.getMaxInstalled(Upgrades.CRAFTING));
this.patternExpansionUpgrades = Math.min(this.patternExpansionUpgrades, this.getMaxInstalled(Upgrades.PATTERN_EXPANSION));
this.magnetUpgrades = Math.min(this.magnetUpgrades, this.getMaxInstalled(Upgrades.MAGNET));
this.quantumUpgrades = Math.min(this.quantumUpgrades, this.getMaxInstalled(Upgrades.QUANTUM_LINK));
}
@Override