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 711c29f commit 0da6b07
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 27 deletions.
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 @@ -145,12 +146,16 @@
"gui.projectexpansion.config.emc_display.desc": "Displays your current emc and gained emc per second in the top left corner.",
"gui.projectexpansion.config.notify_command_changes": "Notify Command Changes",
"gui.projectexpansion.config.notify_command_changes.desc": "Notify users something is changed about them via /emc.",
"gui.projectexpansion.config.notify_knowledge_book_gains": "Notify Knowledge Book Gains",
"gui.projectexpansion.config.notify_knowledge_book_gains.desc": "Tell users the list of items they gained when using a knowledge book.",
"gui.projectexpansion.config.limit_emc_link_vendor": "Limit EMC Link Vendor Output",
"gui.projectexpansion.config.limit_emc_link_vendor.desc": "If EMC Link Right-Click functionality should be Limited by Tier or Not.",
"gui.projectexpansion.config.transmutation_interface_item_count": "Transmutation Interface Item Count",
"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
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.awt.*;
import java.util.List;

@SuppressWarnings("deprecation")
Expand All @@ -54,10 +55,11 @@ public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
@Override
public void appendHoverText(ItemStack stack, @Nullable BlockGetter level, List<Component> list, TooltipFlag flag) {
super.appendHoverText(stack, level, list, flag);
list.add((Component.translatable("block.projectexpansion.emc_link.tooltip")).setStyle(ColorStyle.GRAY));
list.add((Component.translatable("block.projectexpansion.emc_link.limit_items", matter.getEMCLinkItemLimitComponent()).setStyle(ColorStyle.GREEN)).setStyle(ColorStyle.GRAY));
list.add((Component.translatable("block.projectexpansion.emc_link.limit_fluids", matter.getEMCLinkFluidLimitComponent()).setStyle(ColorStyle.GREEN)).setStyle(ColorStyle.GRAY));
list.add((Component.translatable("block.projectexpansion.emc_link.limit_emc", Component.literal(matter.getLevel() == 16 ? "INFINITY" : EMCFormat.format(matter.getEMCLinkEMCLimit())).setStyle(ColorStyle.GREEN))).setStyle(ColorStyle.GRAY));
list.add(Component.translatable("block.projectexpansion.emc_link.tooltip").setStyle(ColorStyle.GRAY));
list.add(Component.translatable("block.projectexpansion.emc_link.limit_items", matter.getEMCLinkItemLimitComponent()).setStyle(ColorStyle.GRAY));
list.add(Component.translatable("block.projectexpansion.emc_link.limit_fluids", matter.getEMCLinkFluidLimitComponent()).setStyle(ColorStyle.GRAY));
list.add(Component.translatable("block.projectexpansion.emc_link.fluid_export_efficiency", Component.literal(matter.getFluidEfficiencyPercentage() + "%").setStyle(ColorStyle.GREEN)).setStyle(ColorStyle.GRAY));
list.add(Component.translatable("block.projectexpansion.emc_link.limit_emc", matter.getEMCLinkEMCLimitComponent()).setStyle(ColorStyle.GRAY));
list.add(Component.translatable("text.projectexpansion.see_wiki").setStyle(ColorStyle.AQUA));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,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.world.item.Items.BUCKET) * matter.getFluidEfficiencyPercentage()) / 100F)) / 1000D;
} catch(ArithmeticException ignore) {
return Long.MAX_VALUE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public final class Config {
public static final ForgeConfigSpec.ConfigValue<Boolean> notifyCommandChanges = Builder.translation("gui.projectexpansion.config.notify_command_changes.desc").define("notifyCommandChanges", true);
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> 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
71 changes: 50 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 @@ -11,36 +11,39 @@
import cool.furry.mc.forge.projectexpansion.registries.Items;
import moze_intel.projecte.gameObjs.registries.PEItems;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Rarity;
import net.minecraftforge.registries.RegistryObject;

import javax.annotation.Nullable;
import java.awt.*;
import java.math.BigDecimal;
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 +61,8 @@ public Matter next() {
public final BigDecimal collectorOutputBase;
public final BigDecimal relayBonusBase;
public final BigDecimal relayTransferBase;
/** @deprecated Note: Due to how 1.19.2 config values work, this will not be set to 100 when fluid efficiency is disabled. */
public final int fluidEfficiency;
@Nullable
public final Supplier<Item> existingItem;
public final Rarity rarity;
Expand Down Expand Up @@ -85,7 +90,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 +100,7 @@ public Matter next() {
this.relayBonusBase = BigDecimal.valueOf(relayBonus);
// Gₙ(aₙ)(z)=64(2z²+z-1)/4z-1
this.relayTransferBase = BigDecimal.valueOf(relayTransfer);
this.fluidEfficiency = fluidEfficiency;
this.existingItem = existingItem;
this.rarity =
level >= EPIC_THRESHOLD ? Rarity.EPIC :
Expand All @@ -107,6 +113,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() {
return collectorOutputBase.multiply(BigDecimal.valueOf(18)).add(relayBonusBase.multiply(BigDecimal.valueOf(30))).multiply(BigDecimal.valueOf(Config.powerflowerMultiplier.get())).toBigInteger();
Expand Down Expand Up @@ -172,12 +185,28 @@ public int getEMCLinkFluidLimit() {
}
}

public Component getEMCLinkItemLimitComponent() {
return Component.literal(this == FINAL ? "INFINITY" : String.valueOf(getEMCLinkItemLimit()));
public MutableComponent getFormattedComponent(int value) {
return getFormattedComponent(BigInteger.valueOf(value));
}

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

public MutableComponent getFormattedComponent(BigInteger value) {
return (this == FINAL ? Component.literal("INFINITY") : EMCFormat.getComponent(value)).setStyle(ColorStyle.GREEN);
}

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

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

public Component getEMCLinkFluidLimitComponent() {
return Component.literal(this == FINAL ? "INFINITY" : String.valueOf(getEMCLinkFluidLimit()));
public MutableComponent getEMCLinkEMCLimitComponent() {
return getFormattedComponent(getEMCLinkEMCLimit());
}

/* Registry Objects */
Expand Down

0 comments on commit 0da6b07

Please sign in to comment.