Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change pipes to force connections to covers #2666

Merged
merged 2 commits into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,12 @@ public void setConnection(Direction side, boolean connected, boolean fromNeighbo
pipeTile.getPipeType().getClass() != this.getPipeType().getClass()) {
return;
}

if (!connected) {
var cover = getCoverContainer().getCoverAtSide(side);
if (cover != null && cover.canPipePassThrough()) return;
}

connections = withSideConnection(connections, side, connected);

updateNetworkConnection(side, connected);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ public CoverBehavior getCoverAtSide(Direction side) {
}

public void setCoverAtSide(@Nullable CoverBehavior coverBehavior, Direction side) {
var previousCover = getCoverAtSide(side);
switch (side) {
case UP -> up = coverBehavior;
case SOUTH -> south = coverBehavior;
Expand All @@ -196,6 +197,11 @@ public void setCoverAtSide(@Nullable CoverBehavior coverBehavior, Direction side
}
if (coverBehavior != null) {
coverBehavior.getSyncStorage().markAllDirty();
if (coverBehavior.canPipePassThrough()) {
pipeTile.setConnection(side, true, false);
}
} else if (previousCover != null && previousCover.canPipePassThrough()) {
pipeTile.setConnection(side, false, false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,10 @@ public ComputerMonitorCover(CoverDefinition definition, ICoverable coverHolder,
super(definition, coverHolder, attachedSide);
}

@Override
public boolean canPipePassThrough() {
return false;
}

// No implementation here, this cover is just for decorative purposes
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.Direction;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;

import lombok.Getter;
import lombok.Setter;
Expand Down Expand Up @@ -61,7 +60,7 @@ public void setFilterMode(FilterMode filterMode) {

@Override
public boolean canAttach() {
return FluidUtil.getFluidHandler(coverHolder.getLevel(), coverHolder.getPos(), attachedSide).isPresent();
return coverHolder.getFluidHandlerCap(attachedSide, false) != null;
}

public FluidFilter getFluidFilter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.gregtechceu.gtceu.api.gui.GuiTextures;
import com.gregtechceu.gtceu.api.gui.fancy.IFancyConfigurator;
import com.gregtechceu.gtceu.api.gui.widget.SlotWidget;
import com.gregtechceu.gtceu.api.machine.MachineCoverContainer;
import com.gregtechceu.gtceu.api.transfer.item.CustomItemStackHandler;

import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture;
Expand Down Expand Up @@ -50,11 +51,13 @@ public int getSlotLimit(int slot) {
}

@Override
@NotNull
public ManagedFieldHolder getFieldHolder() {
return MANAGED_FIELD_HOLDER;
}

@Override
@NotNull
public List<ItemStack> getAdditionalDrops() {
var list = super.getAdditionalDrops();
for (int slot = 0; slot < SIZE; slot++) {
Expand All @@ -65,6 +68,7 @@ public List<ItemStack> getAdditionalDrops() {

@Override
public boolean canAttach() {
if (!(coverHolder instanceof MachineCoverContainer)) return false;
for (var dir : Direction.values()) {
if (coverHolder.hasCover(dir) && coverHolder.getCoverAtSide(dir) instanceof StorageCover)
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,9 @@ public InteractionResult onScrewdriverClick(Player playerIn, InteractionHand han
public boolean canConnectRedstone() {
return true;
}

@Override
public boolean canPipePassThrough() {
return false;
}
}
Loading