Skip to content

Commit 7dac4a3

Browse files
authoredFeb 4, 2025··
feat: allow hoppers, droppers and crafters to interact with Galacticraft machines (#17)
1 parent 013c289 commit 7dac4a3

File tree

6 files changed

+17
-7
lines changed

6 files changed

+17
-7
lines changed
 

‎src/main/java/dev/galacticraft/machinelib/api/transfer/TransferType.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public enum TransferType {
2828
INPUT(0x009001, true, false, true), // external: insertion only, players: insertion and extraction allowed
2929
OUTPUT(0xa7071e, false, true, false), // external: extraction only, players: extraction only
3030
STORAGE(0x008d90, true, true, true), // external: insertion and extraction allowed, players: insertion and extraction allowed
31-
TRANSFER(0x908400, false, false, true); // external: immutable, players: insertion and extraction allowed - e.g. battery slots
31+
TRANSFER(0x908400, false, false, true), // external: immutable, players: insertion and extraction allowed - e.g. battery slots
32+
PROCESSING(0x908400, true, true, true); // external: insertion and extraction allowed, players: insertion and extraction allowed - e.g. bucket slots
3233

3334
private final int color;
3435
private final boolean externalInsert;

‎src/main/java/dev/galacticraft/machinelib/client/api/screen/MachineScreen.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ protected void drawConfigurationPanels(@NotNull GuiGraphics graphics, int mouseX
389389
* @see #titleLabelY
390390
*/
391391
protected void drawTitle(@NotNull GuiGraphics graphics) {
392-
graphics.drawString(this.font, this.title, this.titleLabelX, this.titleLabelY, 0xFFFFFFFF, false);
392+
graphics.drawString(this.font, this.title, this.titleLabelX, this.titleLabelY, 0xFF404040, false);
393393
}
394394

395395
/**

‎src/main/java/dev/galacticraft/machinelib/impl/compat/transfer/ExposedSlotImpl.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import dev.galacticraft.machinelib.api.compat.transfer.ExposedSlot;
2727
import dev.galacticraft.machinelib.api.storage.slot.ResourceSlot;
2828
import dev.galacticraft.machinelib.api.transfer.ResourceFlow;
29+
import dev.galacticraft.machinelib.api.transfer.TransferType;
2930
import net.fabricmc.fabric.api.transfer.v1.storage.StorageView;
3031
import net.fabricmc.fabric.api.transfer.v1.storage.TransferVariant;
3132
import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext;
@@ -57,7 +58,15 @@ public long insert(Variant variant, long maxAmount, TransactionContext transacti
5758

5859
@Override
5960
public long extract(Variant variant, long maxAmount, TransactionContext transaction) {
60-
return this.supportsExtraction() ? this.slot.extract(variant.getObject(), variant.getComponents(), maxAmount, transaction) : 0;
61+
if (this.supportsExtraction()) {
62+
if (this.slot.transferMode() == TransferType.PROCESSING) {
63+
if (this.slot.getFilter().test(variant.getObject(), variant.getComponents())) {
64+
return 0;
65+
}
66+
}
67+
return this.slot.extract(variant.getObject(), variant.getComponents(), maxAmount, transaction);
68+
}
69+
return 0;
6170
}
6271

6372
@Override

‎src/testmod/java/dev/galacticraft/machinelib/testmod/block/entity/GeneratorBlockEntity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class GeneratorBlockEntity extends MachineBlockEntity {
5454

5555
public static final StorageSpec STORAGE_SPEC = StorageSpec.of(
5656
MachineItemStorage.spec(
57-
ItemResourceSlot.builder(TransferType.TRANSFER)
57+
ItemResourceSlot.builder(TransferType.PROCESSING)
5858
.pos(8, 62)
5959
.filter(ResourceFilters.CAN_INSERT_ENERGY)
6060
.capacity(32),

‎src/testmod/java/dev/galacticraft/machinelib/testmod/block/entity/MelterBlockEntity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class MelterBlockEntity extends MachineBlockEntity {
6868
ItemResourceSlot.builder(TransferType.INPUT)
6969
.pos(59, 42)
7070
.filter(ResourceFilters.ofResource(Items.COBBLESTONE)),
71-
ItemResourceSlot.builder(TransferType.TRANSFER)
71+
ItemResourceSlot.builder(TransferType.PROCESSING)
7272
.pos(152, 62)
7373
.filter(ResourceFilters.canInsertFluid(Fluids.LAVA))
7474
),

‎src/testmod/java/dev/galacticraft/machinelib/testmod/block/entity/MixerBlockEntity.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ public class MixerBlockEntity extends MachineBlockEntity {
6666
.pos(8, 8)
6767
.filter(ResourceFilters.CAN_EXTRACT_ENERGY)
6868
.capacity(32),
69-
ItemResourceSlot.builder(TransferType.TRANSFER)
69+
ItemResourceSlot.builder(TransferType.PROCESSING)
7070
.pos(48, 8)
7171
.filter(ResourceFilters.canExtractFluid(Fluids.WATER)),
72-
ItemResourceSlot.builder(TransferType.TRANSFER)
72+
ItemResourceSlot.builder(TransferType.PROCESSING)
7373
.pos(70, 8)
7474
.filter(ResourceFilters.canExtractFluid(Fluids.LAVA)),
7575
ItemResourceSlot.builder(TransferType.OUTPUT)

0 commit comments

Comments
 (0)
Please sign in to comment.