Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.20.1' into feature/PortableSca…
Browse files Browse the repository at this point in the history
…nnerPort
  • Loading branch information
minecraft7771 committed Apr 2, 2024
2 parents f5f2106 + d140b9f commit 95b964e
Show file tree
Hide file tree
Showing 36 changed files with 376 additions and 223 deletions.
37 changes: 4 additions & 33 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,12 @@
# ChangeLog

Version: 1.1.4
Version: 1.1.4.b

### ADDITIONS:
- add Curios slot for magnets
- add compass pages for coke oven, EBF, large boiler
- add collapsible entry for ore blocks in REI

### FIXES:
- fix proxy recipes not being found
- add dimension requirements for fluid veins
- fix world accelerator block entity duplication and/or voiding
- fix multi-amp transformer capacity
- fix machines not connecting to already placed cables
- fix battery buffers allowing stacked batteries
- fix bucket emptying behavior
- fix item collector behavior
- fix issues with EMI integration
- fix ConcurrentModificationException in recipe conditions
- fix large boiler fuel consumption and steam output display
- fix descriptions for impure ore cauldron actions
- fix item tooltip performance issues
- fix KJS not being able to remove GT tags
- improve performance in the JEI integration by caching recipe UI size
- improve ingredient lookup performance
- fix bucket model
- fix chainsaw durability consumption
- fix large miner crashes
- fix fluid drilling rig EU/t usage and add extra tooltips
- fix distinct bus mode not working with ghost circuits
- fix item filter mode resetting every time the UI is opened
- fix pumps inserting the same fluid into more than one slot
- fix pump/conveyor covers and other machines being able to extract from a creative tank's internal slot
- fix startup crash when creating custom coils using KJS
- fixed client error when opening multiblock UI for the first time
- fixed Large assembler & circuit assembler being able to have >1 energy hatch
- fix server crash in LDlib

### CHANGES:
- updated Russian and Chinese translations
- buff the large miner's fortune level
- removed async recipe searching, as it's no longer necessary
- make UI titlebars only scroll/roll when hovering over them
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.jvmargs = -Xmx6G
# Mod Info
mod_id = gtceu
mod_name = GregTech
mod_version = 1.1.4
mod_version = 1.1.4.b
mod_description = GregTech CE Unofficial, ported from 1.12.2
mod_license = LGPL-3.0 license
mod_url = https://github.com/GregTechCEu/GregTech-Modern/
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dependencyResolutionManagement {
def vineFlowerVersion = "1.+"
def macheteVersion = "1.+"
def configurationVersion = "2.2.0"
def ldLibVersion = "1.0.24.a"
def ldLibVersion = "1.0.24.c"
def mixinextrasVersion = "0.2.0"
def shimmerVersion = "0.2.2"

Expand Down
3 changes: 3 additions & 0 deletions src/generated/resources/assets/gtceu/lang/en_ud.json
Original file line number Diff line number Diff line change
Expand Up @@ -3044,6 +3044,9 @@
"gtceu.multiblock.multiple_recipemaps.tooltip": "˙ǝsn oʇ ǝpoɯ ǝuıɥɔɐɯ ɥɔıɥʍ ǝbuɐɥɔ oʇ ɹǝןןoɹʇuoɔ ǝɥʇ ɹǝʌıɹpʍǝɹɔS",
"gtceu.multiblock.multiple_recipemaps_recipes.tooltip": "ɹ§%sǝ§ :sǝpoW ǝuıɥɔɐW",
"gtceu.multiblock.not_enough_energy": "˙ʎbɹǝuǝ ǝɹoɯ spǝǝu ǝuıɥɔɐW :⅁NINᴚⱯM",
"gtceu.multiblock.page_switcher.io.both": "sʇndʇnO + sʇnduI pǝuıqɯoƆϛ§",
"gtceu.multiblock.page_switcher.io.export": "sʇndʇnOㄣ§",
"gtceu.multiblock.page_switcher.io.import": "sʇnduIᄅ§",
"gtceu.multiblock.parallel": "ןǝןןɐɹɐԀ uı sǝdıɔǝᴚ %d oʇ dn buıɯɹoɟɹǝԀ",
"gtceu.multiblock.parallelizable.tooltip": "˙sǝɥɔʇɐH ןoɹʇuoƆ ןǝןןɐɹɐԀ ɥʇıʍ ǝzıןǝןןɐɹɐd uɐƆ",
"gtceu.multiblock.pattern.clear_amount_1": "ɹ§ʇuoɹɟ uı ǝɔɐds ƖxƖxƖ ɹɐǝןɔ ɐ ǝʌɐɥ ʇsnW9§",
Expand Down
3 changes: 3 additions & 0 deletions src/generated/resources/assets/gtceu/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -3044,6 +3044,9 @@
"gtceu.multiblock.multiple_recipemaps.tooltip": "Screwdriver the controller to change which machine mode to use.",
"gtceu.multiblock.multiple_recipemaps_recipes.tooltip": "Machine Modes: §e%s§r",
"gtceu.multiblock.not_enough_energy": "WARNING: Machine needs more energy.",
"gtceu.multiblock.page_switcher.io.both": "§5Combined Inputs + Outputs",
"gtceu.multiblock.page_switcher.io.export": "§4Outputs",
"gtceu.multiblock.page_switcher.io.import": "§2Inputs",
"gtceu.multiblock.parallel": "Performing up to %d Recipes in Parallel",
"gtceu.multiblock.parallelizable.tooltip": "Can parallelize with Parallel Control Hatches.",
"gtceu.multiblock.pattern.clear_amount_1": "§6Must have a clear 1x1x1 space in front§r",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,12 @@ default List<Component> getTabTooltips() {
default TooltipComponent getTabTooltipComponent() {
return null;
}

@Nullable
default PageGroupingData getPageGroupingData() {
return null;
}

record PageGroupingData(@Nullable String groupKey, int groupPositionWeight) {
}
}
51 changes: 35 additions & 16 deletions src/main/java/com/gregtechceu/gtceu/api/gui/fancy/PageSwitcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
import net.minecraft.ChatFormatting;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.network.chat.Component;
import org.apache.commons.lang3.mutable.MutableInt;

import javax.annotation.ParametersAreNonnullByDefault;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.stream.Collectors;

@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
Expand Down Expand Up @@ -39,22 +43,37 @@ public Widget createMainPage(FancyMachineUIWidget widget) {
scrollableGroup.setYBarStyle(GuiTextures.SLIDER_BACKGROUND_VERTICAL, GuiTextures.BUTTON);
container.addWidget(scrollableGroup);

int currentY = 0;
for (IFancyUIProvider page : pages) {
var pageWidget = new WidgetGroup(0, currentY, 146, 24);

pageWidget.addWidget(new ButtonWidget(0, 0, 146, 24, GuiTextures.BACKGROUND, clickData -> onPageSwitched.accept(page)));
pageWidget.addWidget(new ImageWidget(2, 2, 20, 20, page.getTabIcon()));
pageWidget.addWidget(new ImageWidget(24, 2, 118, 20,
new TextTexture(ChatFormatting.BLACK.toString() + page.getTitle().getString())
.setDropShadow(false)
.setWidth(118)
.setType(TextTexture.TextType.LEFT_ROLL)
));

scrollableGroup.addWidget(pageWidget);
currentY += 28;
}
var groupedPages = pages.stream().collect(Collectors.groupingBy(page ->
Objects.requireNonNullElse(page.getPageGroupingData(), new PageGroupingData(null, -1))
));

final MutableInt currentY = new MutableInt(0);
groupedPages.keySet().stream()
.sorted(Comparator.comparingInt(PageGroupingData::groupPositionWeight))
.forEachOrdered(group -> {
if (group.groupKey() != null) {
scrollableGroup.addWidget(new LabelWidget(0, currentY.getAndAdd(12), group.groupKey()).setDropShadow(false));
}

final var currentPage = new MutableInt(0);
currentY.subtract(30); // To account for adding it back on the first page inside this group

groupedPages.get(group).forEach(page -> {
var index = currentPage.getAndIncrement();
var y = currentY.addAndGet(index % 5 == 0 ? 30 : 0); // Jump to the next row every 5 parts

var pageWidget = new WidgetGroup((index % 5) * 30, y, 25, 25);
pageWidget.addWidget(new ButtonWidget(0, 0, 25, 25, GuiTextures.BACKGROUND, clickData -> onPageSwitched.accept(page)));
pageWidget.addWidget(new ImageWidget(4, 4, 17, 17, page.getTabIcon()));
// For some reason, this doesn't work in any other way:
pageWidget.widgets.get(0).setHoverTooltips(page.getTitle().getString());
scrollableGroup.addWidget(pageWidget);
});

if (!groupedPages.get(group).isEmpty()) {
currentY.add(30);
}
});

return container;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ default int getBarWidth(ItemStack stack) {
return Math.round(getDurabilityForDisplay(stack) * 13);
}

default int getDurabilityForDisplay(ItemStack stack) {
return (stack.getMaxDamage() - stack.getDamageValue()) / stack.getMaxDamage();
default float getDurabilityForDisplay(ItemStack stack) {
return (float) (stack.getMaxDamage() - stack.getDamageValue()) / stack.getMaxDamage();
}

default int getMaxDurability(ItemStack stack) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ static ItemColor getItemStackColor() {
}

@Override
default int getDurabilityForDisplay(ItemStack itemStack) {
default float getDurabilityForDisplay(ItemStack itemStack) {
var maxDurability = getPartMaxDurability(itemStack);
return (maxDurability - getPartDamage(itemStack)) / maxDurability;
return (float) (maxDurability - getPartDamage(itemStack)) / maxDurability;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ default ModularUI createUI(Player entityPlayer) {
var screen = new DraggableScrollableWidgetGroup(7, 4, 162, 121).setBackground(getScreenTexture());
screen.addWidget(new LabelWidget(4, 5, self().getBlockState().getBlock().getDescriptionId()));
screen.addWidget(new ComponentPanelWidget(4, 17, this::addDisplayText)
.textSupplier(this.self().getLevel().isClientSide ? null : this::addDisplayText)
.setMaxWidthLimit(150)
.clickHandler(this::handleDisplayClick));
return new ModularUI(176, 216, this, entityPlayer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
import com.gregtechceu.gtceu.utils.GTUtil;
import com.lowdragmc.lowdraglib.gui.modular.ModularUI;
import com.lowdragmc.lowdraglib.gui.widget.*;
import net.minecraft.ChatFormatting;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
import net.minecraft.world.entity.player.Player;

import javax.annotation.ParametersAreNonnullByDefault;
Expand All @@ -40,7 +38,7 @@
@MethodsReturnNonnullByDefault
public class WorkableElectricMultiblockMachine extends WorkableMultiblockMachine implements IFancyUIMachine, IDisplayUIMachine, ITieredMachine, IOverclockMachine {
// runtime
protected IEnergyContainer energyContainer;
protected EnergyContainerList energyContainer;

public WorkableElectricMultiblockMachine(IMachineBlockEntity holder, Object... args) {
super(holder, args);
Expand Down Expand Up @@ -97,6 +95,7 @@ public Widget createUIWidget() {
group.addWidget(new DraggableScrollableWidgetGroup(4, 4, 182, 117).setBackground(getScreenTexture())
.addWidget(new LabelWidget(4, 5, self().getBlockState().getBlock().getDescriptionId()))
.addWidget(new ComponentPanelWidget(4, 17, this::addDisplayText)
.textSupplier(this.getLevel().isClientSide ? null : this::addDisplayText)
.setMaxWidthLimit(150)
.clickHandler(this::handleDisplayClick)));
group.setBackground(GuiTextures.BACKGROUND_INVERSE);
Expand Down Expand Up @@ -146,31 +145,29 @@ public void setOverclockTier(int tier) {

@Override
public long getOverclockVoltage() {
IEnergyContainer energyContainer = this.energyContainer;
if (energyContainer instanceof EnergyContainerList) {
long voltage;
long amperage;
if (energyContainer.getInputVoltage() > energyContainer.getOutputVoltage()) {
voltage = energyContainer.getInputVoltage();
amperage = energyContainer.getInputAmperage();
} else {
voltage = energyContainer.getOutputVoltage();
amperage = energyContainer.getOutputAmperage();
}

if (amperage == 1) {
// amperage is 1 when the energy is not exactly on a tier
if (this.energyContainer == null) {
this.energyContainer = getEnergyContainer();
}
long voltage;
long amperage;
if (energyContainer.getInputVoltage() > energyContainer.getOutputVoltage()) {
voltage = energyContainer.getInputVoltage();
amperage = energyContainer.getInputAmperage();
} else {
voltage = energyContainer.getOutputVoltage();
amperage = energyContainer.getOutputAmperage();
}

// the voltage for recipe search is always on tier, so take the closest lower tier
return GTValues.V[GTUtil.getFloorTierByVoltage(voltage)];
} else {
// amperage != 1 means the voltage is exactly on a tier
// ignore amperage, since only the voltage is relevant for recipe search
// amps are never > 3 in an EnergyContainerList
return voltage;
}
if (amperage == 1) {
// amperage is 1 when the energy is not exactly on a tier
// the voltage for recipe search is always on tier, so take the closest lower tier
return GTValues.V[GTUtil.getFloorTierByVoltage(voltage)];
} else {
// amperage != 1 means the voltage is exactly on a tier
// ignore amperage, since only the voltage is relevant for recipe search
// amps are never > 3 in an EnergyContainerList
return voltage;
}
return Math.max(energyContainer.getInputVoltage(), energyContainer.getOutputVoltage());
}

//////////////////////////////////////
Expand All @@ -185,7 +182,7 @@ public int getTier() {
return GTUtil.getFloorTierByVoltage(getMaxVoltage());
}

public IEnergyContainer getEnergyContainer() {
public EnergyContainerList getEnergyContainer() {
List<IEnergyContainer> containers = new ArrayList<>();
var capabilities = capabilitiesProxy.get(IO.IN, EURecipeCapability.CAP);
if (capabilities != null) {
Expand All @@ -204,39 +201,35 @@ public IEnergyContainer getEnergyContainer() {
}
}
}
return containers.size() == 1 ? containers.get(0) : new EnergyContainerList(containers);
return new EnergyContainerList(containers);
}

public long getMaxVoltage() {
IEnergyContainer energyContainer = this.energyContainer;
if (this.energyContainer == null) {
this.energyContainer = getEnergyContainer();
}
if (this.isGenerator()) {
// Generators
long voltage = energyContainer.getOutputVoltage();
long amperage = energyContainer.getOutputAmperage();
if (energyContainer instanceof EnergyContainerList && amperage == 1) {
if (amperage == 1) {
// Amperage is 1 when the energy is not exactly on a tier.
// The voltage for recipe search is always on tier, so take the closest lower tier.
// List check is done because single hatches will always be a "clean voltage," no need
// for any additional checks.
return GTValues.V[GTUtil.getFloorTierByVoltage(voltage)];
} else {
return voltage;
}
return voltage;
} else {
// Machines
if (energyContainer instanceof EnergyContainerList energyList) {
long highestVoltage = energyList.getHighestInputVoltage();
if (energyList.getNumHighestInputContainers() > 1) {
// allow tier + 1 if there are multiple hatches present at the highest tier
int tier = GTUtil.getTierByVoltage(highestVoltage);
return GTValues.V[Math.min(tier + 1, GTValues.MAX)];
} else {
return highestVoltage;
}
long highestVoltage = energyContainer.getHighestInputVoltage();
if (energyContainer.getNumHighestInputContainers() > 1) {
// allow tier + 1 if there are multiple hatches present at the highest tier
int tier = GTUtil.getTierByVoltage(highestVoltage);
return GTValues.V[Math.min(tier + 1, GTValues.MAX)];
} else {
return energyContainer.getInputVoltage();
return highestVoltage;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import lombok.Getter;
import lombok.Setter;
import net.minecraft.MethodsReturnNonnullByDefault;
import org.jetbrains.annotations.Nullable;

import javax.annotation.ParametersAreNonnullByDefault;

Expand Down Expand Up @@ -47,4 +48,14 @@ public ManagedFieldHolder getFieldHolder() {
return MANAGED_FIELD_HOLDER;
}

@Nullable
@Override
public PageGroupingData getPageGroupingData() {
return switch (this.io) {
case IN -> new PageGroupingData("gtceu.multiblock.page_switcher.io.import", 1);
case OUT -> new PageGroupingData("gtceu.multiblock.page_switcher.io.export", 2);
case BOTH -> new PageGroupingData("gtceu.multiblock.page_switcher.io.both", 3);
case NONE -> null;
};
}
}
14 changes: 10 additions & 4 deletions src/main/java/com/gregtechceu/gtceu/api/pattern/Predicates.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
import com.gregtechceu.gtceu.api.machine.multiblock.IBatteryData;
import com.gregtechceu.gtceu.api.machine.multiblock.PartAbility;
import com.gregtechceu.gtceu.api.pattern.error.PatternStringError;
import com.gregtechceu.gtceu.api.pattern.predicates.PredicateBlocks;
import com.gregtechceu.gtceu.api.pattern.predicates.PredicateFluids;
import com.gregtechceu.gtceu.api.pattern.predicates.PredicateStates;
import com.gregtechceu.gtceu.api.pattern.predicates.SimplePredicate;
import com.gregtechceu.gtceu.api.pattern.predicates.*;
import com.gregtechceu.gtceu.api.pipenet.IPipeNode;
import com.gregtechceu.gtceu.api.recipe.GTRecipeType;
import com.gregtechceu.gtceu.common.block.BatteryBlock;
Expand All @@ -25,6 +22,7 @@
import com.lowdragmc.lowdraglib.utils.BlockInfo;
import com.tterrag.registrate.util.entry.RegistryEntry;
import net.minecraft.network.chat.Component;
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
Expand Down Expand Up @@ -62,10 +60,18 @@ public static TraceabilityPredicate blocks(IMachineBlock... blocks) {
return new TraceabilityPredicate(new PredicateBlocks(Arrays.stream(blocks).map(IMachineBlock::self).toArray(Block[]::new)));
}

public static TraceabilityPredicate blockTag(TagKey<Block> tag) {
return new TraceabilityPredicate(new PredicateBlockTag(tag));
}

public static TraceabilityPredicate fluids(Fluid... fluids) {
return new TraceabilityPredicate(new PredicateFluids(fluids));
}

public static TraceabilityPredicate fluidTag(TagKey<Fluid> tag) {
return new TraceabilityPredicate(new PredicateFluidTag(tag));
}

public static TraceabilityPredicate custom(Predicate<MultiblockState> predicate, Supplier<BlockInfo[]> candidates) {
return new TraceabilityPredicate(predicate, candidates);
}
Expand Down
Loading

0 comments on commit 95b964e

Please sign in to comment.