Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/byebyeEC2' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Dream-Master committed Apr 29, 2023
2 parents 77ec418 + 50c4015 commit 4e1983b
Show file tree
Hide file tree
Showing 28 changed files with 1,457 additions and 18 deletions.
8 changes: 8 additions & 0 deletions src/main/java/com/glodblock/github/FluidCraft.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import com.glodblock.github.common.Config;
import com.glodblock.github.common.storage.FluidCellHandler;
import com.glodblock.github.crossmod.extracells.EC2Replacer;
import com.glodblock.github.crossmod.opencomputers.OCDriverInit;
import com.glodblock.github.crossmod.waila.WailaInit;
import com.glodblock.github.inventory.InventoryHandler;
Expand Down Expand Up @@ -93,6 +94,13 @@ public void onServerStop(FMLServerStoppedEvent event) {
SPacketMEUpdateBuffer.disable();
}

@Mod.EventHandler
public void missingMappings(FMLMissingMappingsEvent event) {
if (!ModAndClassUtil.EC2 && Config.replaceEC2) {
EC2Replacer.replaceExtraCells(event);
}
}

@Mod.EventHandler
public void onLoadComplete(FMLLoadCompleteEvent event) {}

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/glodblock/github/common/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class Config {
public static double portableCellBattery;
public static int packetSize;
public static int packetRate;
public static boolean replaceEC2;

public static void run() {
loadCategory();
Expand Down Expand Up @@ -60,6 +61,11 @@ private static void loadProperty() {
.get("Fluid Craft for AE2", "packetRate", 50, "Period at which packets are dispatched, in ms.")
.getInt();
if (packetRate <= 0) packetRate = 50;
replaceEC2 = Config.getBoolean(
"Fluid Craft for AE2",
"replaceEC2",
true,
"Set true to handle missing item mappings from EC2. Note to work properly, you must have all relevant parts.");
if (Config.hasChanged()) Config.save();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public boolean isStorageCell(ItemStack i) {
}

@Override
public double getIdleDrain() {
public double getIdleDrain(ItemStack is) {
return this.idleDrain;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public boolean isStorageCell(ItemStack i) {
}

@Override
public double getIdleDrain() {
public double getIdleDrain(ItemStack is) {
return 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public boolean isStorageCell(final ItemStack i) {
}

@Override
public double getIdleDrain() {
public double getIdleDrain(ItemStack is) {
return 0.5;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ public int getStatusForCell(final ItemStack is, final IMEInventory handler) {
@Override
public double cellIdleDrain(final ItemStack is, final IMEInventory handler) {
final IFluidCellInventory inv = ((IFluidCellInventoryHandler) handler).getCellInv();
return inv.getIdleDrain();
return inv.getIdleDrain(is);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,25 @@
import appeng.util.item.AEFluidStack;

import com.glodblock.github.common.item.ItemCreativeFluidStorageCell;
import com.glodblock.github.crossmod.extracells.storage.ProxyFluidCellInventory;
import com.glodblock.github.crossmod.extracells.storage.ProxyFluidStorageCell;

public class FluidCellInventory implements IFluidCellInventory {

private static final String FLUID_TYPE_TAG = "ft";
private static final String FLUID_COUNT_TAG = "fc";
private static final String FLUID_SLOT = "#";
private static final String FLUID_SLOT_COUNT = "@";
protected static final String FLUID_TYPE_TAG = "ft";
protected static final String FLUID_COUNT_TAG = "fc";
protected static final String FLUID_SLOT = "#";
protected static final String FLUID_SLOT_COUNT = "@";
protected IStorageFluidCell cellType;
private static String[] fluidSlots;
private static String[] fluidSlotCount;
protected static String[] fluidSlots;
protected static String[] fluidSlotCount;
protected final ItemStack cellItem;
private final ISaveProvider container;
private final int MAX_TYPE = 63;
private long storedFluidCount;
private short storedFluids;
protected long storedFluidCount;
protected short storedFluids;
protected IItemList<IAEFluidStack> cellFluids;
private final NBTTagCompound tagCompound;
protected final NBTTagCompound tagCompound;
public static final int singleByteAmount = 256 * 8;

public FluidCellInventory(final ItemStack o, final ISaveProvider container) throws AppEngException {
Expand Down Expand Up @@ -80,6 +82,8 @@ public static IMEInventoryHandler<IAEFluidStack> getCell(final ItemStack o, fina
try {
if (o.getItem() instanceof ItemCreativeFluidStorageCell) {
return new FluidCellInventoryHandler(new CreativeFluidCellInventory(o, container2));
} else if (o.getItem() instanceof ProxyFluidStorageCell) {
return new FluidCellInventoryHandler(new ProxyFluidCellInventory(o, container2));
} else {
return new FluidCellInventoryHandler(new FluidCellInventory(o, container2));
}
Expand All @@ -105,8 +109,8 @@ public ItemStack getItemStack() {
}

@Override
public double getIdleDrain() {
return this.cellType.getIdleDrain();
public double getIdleDrain(ItemStack is) {
return this.cellType.getIdleDrain(is);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack> implements IFluidCellInventoryHandler {

FluidCellInventoryHandler(final IMEInventory<IAEFluidStack> c) {
protected FluidCellInventoryHandler(final IMEInventory<IAEFluidStack> c) {
super(c, StorageChannel.FLUIDS);

final IFluidCellInventory ci = this.getCellInv();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public interface IFluidCellInventory extends IMEInventory<IAEFluidStack> {
/**
* @return idle cost for this Storage Cell
*/
double getIdleDrain();
double getIdleDrain(ItemStack is);

/**
* @return access configured list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface IStorageFluidCell extends ICellWorkbenchItem {

boolean isStorageCell(ItemStack i);

double getIdleDrain();
double getIdleDrain(ItemStack is);

int getTotalTypes(ItemStack cellItem);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.glodblock.github.crossmod.extracells;

import java.util.List;

import net.minecraft.item.Item;

import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
import cpw.mods.fml.common.registry.GameRegistry;

public class EC2Replacer {

/**
* Should be called if and only if replaceEC2 config is true and EC2 not present. Registers proxy items for the
* entire EC2 mod. After running this once, you should set replaceEC2 back to false.
*/
public static void initReplacer() {
ItemReplacements.init();
}

public static void replaceExtraCells(FMLMissingMappingsEvent event) {
List<FMLMissingMappingsEvent.MissingMapping> mappings = event.getAll();
for (FMLMissingMappingsEvent.MissingMapping m : mappings) {
if (m.type == GameRegistry.Type.ITEM && ItemReplacements.registry.containsKey(m.name)) {
Item toRemap = ItemReplacements.registry.get(m.name);
m.remap(toRemap);
} else {
m.warn();
}
}
}
}
Loading

0 comments on commit 4e1983b

Please sign in to comment.