Skip to content

Commit

Permalink
the great unboxing
Browse files Browse the repository at this point in the history
  • Loading branch information
vrejhead committed Dec 27, 2024
1 parent a58923f commit 98979da
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.function.ToIntFunction;

import static gregtech.api.capability.GregtechDataCodes.*;

Expand All @@ -95,7 +96,7 @@ public abstract class MultiblockControllerBase extends MetaTileEntity implements

protected final Comparator<IMultiblockPart> partComparator = Comparator.comparingLong(part -> {
MetaTileEntity mte = (MetaTileEntity) part;
return ((long) multiblockPartSorter().apply(mte.getPos()) << 32) | mte.getPos().hashCode();
return ((long) multiblockPartSorter().applyAsInt(mte.getPos()) << 32) | mte.getPos().hashCode();
});

private final Map<MultiblockAbility<Object>, List<Object>> multiblockAbilities = new HashMap<>();
Expand Down Expand Up @@ -435,7 +436,7 @@ public boolean shouldShowInJei() {
* Used if MultiblockPart Abilities need to be sorted a certain way, like
* Distillation Tower and Assembly Line.
*/
protected Function<BlockPos, Integer> multiblockPartSorter() {
protected ToIntFunction<BlockPos> multiblockPartSorter() {
return BlockPos::hashCode;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/gregtech/api/util/RelativeDirection.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import net.minecraft.util.math.BlockPos;

import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.ToIntFunction;

/**
* Relative direction when facing horizontally
Expand Down Expand Up @@ -58,7 +58,7 @@ public EnumFacing getRelativeFacing(EnumFacing frontFacing, EnumFacing upwardsFa
getRelativeFacing(frontFacing, upwardsFacing);
}

public Function<BlockPos, Integer> getSorter(EnumFacing frontFacing, EnumFacing upwardsFacing, boolean isFlipped) {
public ToIntFunction<BlockPos> getSorter(EnumFacing frontFacing, EnumFacing upwardsFacing, boolean isFlipped) {
// get the direction to go in for the part sorter
EnumFacing sorterDirection = getRelativeFacing(frontFacing, upwardsFacing, isFlipped);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.function.Function;
import java.util.function.ToIntFunction;

import static gregtech.api.util.RelativeDirection.*;

Expand Down Expand Up @@ -141,7 +141,7 @@ protected static TraceabilityPredicate dataHatchPredicate() {
}

@Override
protected Function<BlockPos, Integer> multiblockPartSorter() {
protected ToIntFunction<BlockPos> multiblockPartSorter() {
// player's right when looking at the controller, but the controller's left
return RelativeDirection.LEFT.getSorter(getFrontFacing(), getUpwardsFacing(), isFlipped());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import org.jetbrains.annotations.NotNull;

import java.util.List;
import java.util.function.Function;
import java.util.function.ToIntFunction;

import static gregtech.api.util.RelativeDirection.*;

Expand Down Expand Up @@ -70,7 +70,7 @@ public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) {
* a properly overriden {@link DistillationTowerLogicHandler#determineOrderedFluidOutputs()}
*/
@Override
protected Function<BlockPos, Integer> multiblockPartSorter() {
protected ToIntFunction<BlockPos> multiblockPartSorter() {
return RelativeDirection.UP.getSorter(getFrontFacing(), getUpwardsFacing(), isFlipped());
}

Expand Down

0 comments on commit 98979da

Please sign in to comment.