Skip to content

Commit

Permalink
Fluid Efficiency
Browse files Browse the repository at this point in the history
  • Loading branch information
DonovanDMC committed Oct 1, 2022
1 parent da6373e commit 0634c19
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 31 deletions.
2 changes: 1 addition & 1 deletion scripts/publish
Submodule publish updated 1 files
+6 −6 package-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
"block.projectexpansion.white_collector": "White Collector [MK 14]",
"block.projectexpansion.fading_collector": "Fading Collector [MK 15]",
"block.projectexpansion.final_collector": "Final Collector [MK 16]",
"block.projectexpansion.emc_link.tooltip": "Can be used to import emc & items, and export items.",
"block.projectexpansion.emc_link.tooltip": "Can be used to import emc & items, and export items & fluids.",
"block.projectexpansion.emc_link.limit_items": "Item Import/Export Limit: %s/s",
"block.projectexpansion.emc_link.limit_fluids": "Fluid Export Limit: %s mB/s",
"block.projectexpansion.emc_link.fluid_export_efficiency": "Fluid Export Efficiency: %s",
"block.projectexpansion.emc_link.limit_emc": "EMC Limit: %s/s",
"block.projectexpansion.emc_link.not_set": "An export item has not been set.",
"block.projectexpansion.emc_link.already_set": "An export item has already been set, clear the current export first.",
Expand Down Expand Up @@ -153,6 +154,8 @@
"gui.projectexpansion.config.transmutation_interface_item_count.desc": "The amount of items that the transmutation interface will report to have. You likely want this to be at least 64.",
"gui.projectexpansion.config.use_old_values": "Use Old Values",
"gui.projectexpansion.config.use_old_values.desc": "Use the previous emc generation values (much more unbalanced)",
"gui.projectexpansion.config.enable_fluid_efficiency": "Enable Fluid Efficiency",
"gui.projectexpansion.config.enable_fluid_efficiency.desc": "If fluid efficiency should be enabled.",
"gui.projectexpansion.config.collector_multiplier": "Collector Multiplier",
"gui.projectexpansion.config.collector_multiplier.desc": "Multiplies the output of Collectors.",
"gui.projectexpansion.config.emc_link_item_limit_multiplier": "EMC Link Item Limit Multiplier",
Expand Down
2 changes: 1 addition & 1 deletion src/main/generation
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
import cool.furry.mc.forge.projectexpansion.tile.TileEMCLink;
import cool.furry.mc.forge.projectexpansion.tile.TileNBTFilterable;
import cool.furry.mc.forge.projectexpansion.util.ColorStyle;
import cool.furry.mc.forge.projectexpansion.util.EMCFormat;
import cool.furry.mc.forge.projectexpansion.util.IHasMatter;
import cool.furry.mc.forge.projectexpansion.util.Matter;
import net.minecraft.block.*;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.material.Material;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.LivingEntity;
Expand Down Expand Up @@ -57,10 +59,11 @@ public TileEntity createTileEntity(BlockState state, IBlockReader world) {
@Override
public void addInformation(ItemStack stack, @Nullable IBlockReader level, List<ITextComponent> list, ITooltipFlag flag) {
super.addInformation(stack, level, list, flag);
list.add((new TranslationTextComponent("block.projectexpansion.emc_link.tooltip")).setStyle(ColorStyle.GRAY));
list.add((new TranslationTextComponent("block.projectexpansion.emc_link.limit_items", matter.getEMCLinkItemLimitComponent().setStyle(ColorStyle.GREEN))).setStyle(ColorStyle.GRAY));
list.add((new TranslationTextComponent("block.projectexpansion.emc_link.limit_fluids", matter.getEMCLinkFluidLimitComponent().setStyle(ColorStyle.GREEN))).setStyle(ColorStyle.GRAY));
list.add((new TranslationTextComponent("block.projectexpansion.emc_link.limit_emc", matter.getLevel() == 16 ? new StringTextComponent("INFINITY") : EMCFormat.getComponent(matter.getEMCLinkEMCLimit()).setStyle(ColorStyle.GREEN))).setStyle(ColorStyle.GRAY));
list.add(new TranslationTextComponent("block.projectexpansion.emc_link.tooltip").setStyle(ColorStyle.GRAY));
list.add(new TranslationTextComponent("block.projectexpansion.emc_link.limit_items", matter.getEMCLinkItemLimitComponent()).setStyle(ColorStyle.GRAY));
list.add(new TranslationTextComponent("block.projectexpansion.emc_link.limit_fluids", matter.getEMCLinkFluidLimitComponent()).setStyle(ColorStyle.GRAY));
list.add(new TranslationTextComponent("block.projectexpansion.emc_link.fluid_export_efficiency", new StringTextComponent(matter.getFluidEfficiencyPercentage() + "%").setStyle(ColorStyle.GREEN)).setStyle(ColorStyle.GRAY));
list.add(new TranslationTextComponent("block.projectexpansion.emc_link.limit_emc", matter.getEMCLinkEMCLimitComponent()).setStyle(ColorStyle.GRAY));
list.add(new TranslationTextComponent("text.projectexpansion.see_wiki").setStyle(ColorStyle.AQUA));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public final class Config {
public static final ForgeConfigSpec.ConfigValue<Boolean> notifyKnowledgeBookGains = Builder.translation("gui.projectexpansion.config.notify_knowledge_book_gains.desc").define("notifyKnowledgeBookGains", true);
public static final ForgeConfigSpec.ConfigValue<Boolean> limitEmcLinkVendor = Builder.translation("gui.projectexpansion.config.limit_emc_link_vendor.desc").define("limitEmcLinkVendor", true);
public static final ForgeConfigSpec.ConfigValue<Boolean> useOldValues = Builder.translation("gui.projectexpansion.config.use_old_values.desc").define("useOldValues", false);
public static final ForgeConfigSpec.ConfigValue<Boolean> enableFluidEfficiency = Builder.translation("gui.projectexpansion.config.enable_fluid_efficiency.desc").define("enableFluidEfficiency", true);
public static final ForgeConfigSpec.ConfigValue<Integer> transmutationInterfaceItemCount = Builder.translation("gui.projectexpansion.config.transmutation_interface_item_count.desc").defineInRange("transmutationInterfaceItemCount", Integer.MAX_VALUE, 1, Integer.MAX_VALUE);
public static final ForgeConfigSpec.ConfigValue<Double> collectorMultiplier = Builder.translation("gui.projectexpansion.config.collector_multiplier.desc").defineInRange("collectorMultiplier", 1.0D, 0.1D, 50D);
public static final ForgeConfigSpec.ConfigValue<Double> emcLinkItemLimitMultiplier = Builder.translation("gui.projectexpansion.config.emc_link_item_limit_multiplier.desc").defineInRange("emcLinkItemLimitMultiplier", 1.0D, 0.1D, 50D);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ protected void init() {
(__, newValue) -> Config.useOldValues.set(newValue)
));

optionsRowList.addOption(new BooleanOption(
"gui.projectexpansion.config.enable_fluid_efficiency",
__ -> Config.enableFluidEfficiency.get(),
(__, newValue) -> Config.enableFluidEfficiency.set(newValue)
));

optionsRowList.addOption(new SliderPercentageOption(
"gui.projectexpansion.config.collector_multiplier",
0.1F, 20.0F, 0.1F,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public boolean isItemValid(int slot, @Nonnull ItemStack stack) {

private double getFluidCostPer() {
try {
return ProjectEAPI.getEMCProxy().getValue(itemStack) / 1000D;
return (ProjectEAPI.getEMCProxy().getValue(itemStack) - ((ProjectEAPI.getEMCProxy().getValue(net.minecraft.item.Items.BUCKET) * matter.getFluidEfficiencyPercentage()) / 100F)) / 1000D;
} catch(ArithmeticException ignore) {
return Long.MAX_VALUE;
}
Expand Down
69 changes: 48 additions & 21 deletions src/main/java/cool/furry/mc/forge/projectexpansion/util/Matter.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.Rarity;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.fml.RegistryObject;

Expand All @@ -21,26 +22,27 @@
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Supplier;

@SuppressWarnings("unused")
public enum Matter {
BASIC( 4L, 1L, 64L, null),
DARK( 12L, 3L, 192L, PEItems.DARK_MATTER),
RED( 40L, 10L, 640L, PEItems.RED_MATTER),
MAGENTA(160L, 40L, 2560L, null),
PINK( 640L, 150L, 10240L, null),
PURPLE( 2560L, 750L, 40960L, null),
VIOLET( 10240L, 3750L, 163840L, null),
BLUE( 40960L, 15000L, 655360L, null),
CYAN( 163840L, 60000L, 2621440L, null),
GREEN( 655360L, 240000L, 10485760L, null),
LIME( 2621440L, 960000L, 41943040L, null),
YELLOW( 10485760L, 3840000L, 167772160L, null),
ORANGE( 41943040L, 15360000L, 671088640L, null),
WHITE( 167772160L, 61440000L, 2684354560L, null),
FADING( 671088640L, 245760000L, 10737418240L, null),
FINAL( 1000000000000L, 1000000000000L, Long.MAX_VALUE, Items.FINAL_STAR_SHARD);
BASIC( 4L, 1L, 64L, 0, null),
DARK( 12L, 3L, 192L, 2, PEItems.DARK_MATTER),
RED( 40L, 10L, 640L, 4, PEItems.RED_MATTER),
MAGENTA(160L, 40L, 2560L, 4, null),
PINK( 640L, 150L, 10240L, 5, null),
PURPLE( 2560L, 750L, 40960L, 5, null),
VIOLET( 10240L, 3750L, 163840L, 6, null),
BLUE( 40960L, 15000L, 655360L, 6, null),
CYAN( 163840L, 60000L, 2621440L, 7, null),
GREEN( 655360L, 240000L, 10485760L, 7, null),
LIME( 2621440L, 960000L, 41943040L, 8, null),
YELLOW( 10485760L, 3840000L, 167772160L, 8, null),
ORANGE( 41943040L, 15360000L, 671088640L, 9, null),
WHITE( 167772160L, 61440000L, 2684354560L, 9, null),
FADING( 671088640L, 245760000L, 10737418240L, 10, null),
FINAL( 1000000000000L, 1000000000000L, Long.MAX_VALUE, 10, Items.FINAL_STAR_SHARD);

public static final Matter[] VALUES = values();

Expand All @@ -58,6 +60,7 @@ public Matter next() {
public final BigDecimal collectorOutputBase;
public final BigDecimal relayBonusBase;
public final BigDecimal relayTransferBase;
public final int fluidEfficiency;
@Nullable
public final Supplier<Item> existingItem;
public final Rarity rarity;
Expand Down Expand Up @@ -85,7 +88,7 @@ public Matter next() {
public static final int UNCOMMON_THRESHOLD = 4;
public static final int RARE_THRESHOLD = 15;
public static final int EPIC_THRESHOLD = 16;
Matter(long collectorOutput, long relayBonus, long relayTransfer, @Nullable Supplier<Item> existingItem) {
Matter(long collectorOutput, long relayBonus, long relayTransfer, int fluidEfficiency, @Nullable Supplier<Item> existingItem) {
this.name = name().toLowerCase();
this.hasItem = existingItem == null && ordinal() != 0;
this.level = ordinal() + 1;
Expand All @@ -95,6 +98,7 @@ public Matter next() {
this.relayBonusBase = Config.useOldValues.get() ? calcOldValue(BigDecimal.valueOf(1), level) : BigDecimal.valueOf(relayBonus);
// Gₙ(aₙ)(z)=64(2z²+z-1)/4z-1
this.relayTransferBase = Config.useOldValues.get() ? calcOldValue(BigDecimal.valueOf(64), level) : BigDecimal.valueOf(relayTransfer);
this.fluidEfficiency = Config.enableFluidEfficiency.get() ? fluidEfficiency : 100;
this.existingItem = existingItem;
this.rarity =
level >= EPIC_THRESHOLD ? Rarity.EPIC :
Expand All @@ -113,6 +117,13 @@ public int getLevel() {
return level;
}

public int getFluidEfficiencyPercentage() {
if(!Config.enableFluidEfficiency.get()) return 100;
AtomicInteger efficiency = new AtomicInteger(fluidEfficiency);
Arrays.stream(VALUES).filter((m) -> m.level < level).forEach((m) -> efficiency.addAndGet(m.fluidEfficiency));
return efficiency.get();
}

/* Limits */

public BigInteger getPowerFlowerOutput() {
Expand Down Expand Up @@ -181,12 +192,28 @@ public int getEMCLinkFluidLimit() {
}
}

public StringTextComponent getEMCLinkItemLimitComponent() {
return new StringTextComponent(this == FINAL ? "INFINITY" : String.valueOf(getEMCLinkItemLimit()));
public ITextComponent getFormattedComponent(int value) {
return getFormattedComponent(BigInteger.valueOf(value));
}

public ITextComponent getFormattedComponent(long value) {
return getFormattedComponent(BigInteger.valueOf(value));
}

public ITextComponent getFormattedComponent(BigInteger value) {
return (this == FINAL ? new StringTextComponent("INFINITY") : EMCFormat.getComponent(value)).setStyle(ColorStyle.GREEN);
}

public ITextComponent getEMCLinkItemLimitComponent() {
return getFormattedComponent(getEMCLinkItemLimit());
}

public ITextComponent getEMCLinkFluidLimitComponent() {
return getFormattedComponent(getEMCLinkFluidLimit());
}

public StringTextComponent getEMCLinkFluidLimitComponent() {
return new StringTextComponent(this == FINAL ? "INFINITY" : String.valueOf(getEMCLinkFluidLimit()));
public ITextComponent getEMCLinkEMCLimitComponent() {
return getFormattedComponent(getEMCLinkEMCLimit());
}

/* Registry Objects */
Expand Down

0 comments on commit 0634c19

Please sign in to comment.