Skip to content

Commit

Permalink
fix DT outputs sometimes on wrong layers
Browse files Browse the repository at this point in the history
  • Loading branch information
serenibyss committed Aug 14, 2021
1 parent 859bcb9 commit 90c4e2f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import org.apache.commons.lang3.ArrayUtils;
Expand All @@ -35,6 +36,7 @@
import javax.annotation.Nullable;
import java.util.*;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Predicate;

public abstract class MultiblockControllerBase extends MetaTileEntity implements IMultiblockController {
Expand Down Expand Up @@ -170,14 +172,18 @@ public Pair<TextureAtlasSprite, Integer> getParticleTexture() {
}

/**
* if true allows all hatches to share but energy hatches and rotor holders
* defualt true
*
* @return
* Override to disable MultiblockPart sharing for this Multiblock. (Rotor Holders always disallowed).
*/
public boolean canShare() {
return true;
}

/**
* Used if MultiblockPart Abilities need to be sorted a certain way, like
* Distillation Tower and Assembly Line.
*/
protected Function<BlockPos, Integer> multiblockPartSorter() {
return BlockPos::hashCode;
}

protected void checkStructurePattern() {
Expand All @@ -186,7 +192,7 @@ protected void checkStructurePattern() {
if (context != null && !structureFormed) {
Set<IMultiblockPart> rawPartsSet = context.getOrCreate("MultiblockParts", HashSet::new);
ArrayList<IMultiblockPart> parts = new ArrayList<>(rawPartsSet);
parts.sort(Comparator.comparing(it -> ((MetaTileEntity) it).getPos().hashCode()));
parts.sort(Comparator.comparing(it -> multiblockPartSorter().apply(((MetaTileEntity) it).getPos())));
for (IMultiblockPart part : parts) {
if (part.isAttachedToMultiBlock()) {
if (!canShare() || part instanceof MetaTileEntityRotorHolder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
import gregtech.common.blocks.MetaBlocks;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraftforge.fluids.FluidStack;

import javax.annotation.Nonnull;
import java.util.List;
import java.util.function.Function;
import java.util.function.Predicate;

import static gregtech.api.util.RelativeDirection.*;
Expand All @@ -38,6 +40,11 @@ public MetaTileEntity createMetaTileEntity(MetaTileEntityHolder holder) {
return new MetaTileEntityDistillationTower(metaTileEntityId);
}

@Override
protected Function<BlockPos, Integer> multiblockPartSorter() {
return BlockPos::getY; // todo this needs to be "relative up" with Freedom Wrench
}

@Override
protected void addDisplayText(List<ITextComponent> textList) {
if (isStructureFormed()) {
Expand Down

0 comments on commit 90c4e2f

Please sign in to comment.