Skip to content

Commit e65c700

Browse files
committed
Merge branch 'minecraft/1.21' of https://github.com/TeamGalacticraft/MachineLib into tooltips
2 parents 6f67cff + 7dac4a3 commit e65c700

File tree

10 files changed

+115
-67
lines changed

10 files changed

+115
-67
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ dependencies {
200200
"testmodImplementation"(sourceSets.main.get().output)
201201
"modTestmodImplementation"("net.fabricmc.fabric-api:fabric-api:$fabric")
202202

203-
// modRuntimeOnly("me.shedaniel:RoughlyEnoughItems-fabric:$rei")
203+
modRuntimeOnly("me.shedaniel:RoughlyEnoughItems-fabric:$rei")
204204
modRuntimeOnly("mcp.mobius.waila:wthit:fabric-$wthit")
205205
}
206206

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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 74 additions & 54 deletions
Large diffs are not rendered by default.

src/main/java/dev/galacticraft/machinelib/client/impl/compat/MachineLibREIClientPlugin.java

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import dev.architectury.event.CompoundEventResult;
2626
import dev.galacticraft.machinelib.client.api.screen.MachineScreen;
2727
import dev.galacticraft.machinelib.impl.Constant;
28+
import dev.galacticraft.machinelib.impl.Constant.TextureCoordinate;
2829
import me.shedaniel.math.Rectangle;
2930
import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
3031
import me.shedaniel.rei.api.client.registry.screen.ExclusionZones;
@@ -49,13 +50,30 @@ public void registerScreens(ScreenRegistry registry) {
4950

5051
@Override
5152
public void registerExclusionZones(ExclusionZones zones) {
52-
zones.register(MachineScreen.class, screen -> {
53+
zones.register(MachineScreen.class, provider -> {
5354
List<Rectangle> areas = new ArrayList<>();
54-
if (MachineScreen.Tab.STATS.isOpen() || MachineScreen.Tab.SECURITY.isOpen()) {
55-
areas.add(new Rectangle(screen.getX() + screen.getImageWidth(), screen.getY() + (MachineScreen.Tab.STATS.isOpen() ? 0 : Constant.TextureCoordinate.TAB_HEIGHT), Constant.TextureCoordinate.PANEL_WIDTH, Constant.TextureCoordinate.PANEL_HEIGHT));
56-
areas.add(new Rectangle(screen.getX() + screen.getImageWidth(), screen.getY() + Constant.TextureCoordinate.TAB_HEIGHT, Constant.TextureCoordinate.TAB_WIDTH, Constant.TextureCoordinate.PANEL_HEIGHT));
55+
int leftX = provider.getX();
56+
int rightX = provider.getX() + provider.getImageWidth();
57+
int leftY = provider.getY() + MachineScreen.SPACING;
58+
int rightY = provider.getY() + MachineScreen.SPACING;
59+
int width;
60+
int height;
61+
for (MachineScreen.Tab tab : MachineScreen.Tab.values()) {
62+
if (tab.isOpen()) {
63+
width = TextureCoordinate.PANEL_WIDTH;
64+
height = TextureCoordinate.PANEL_HEIGHT;
65+
} else {
66+
width = TextureCoordinate.TAB_WIDTH;
67+
height = TextureCoordinate.TAB_HEIGHT;
68+
}
69+
if (tab.isLeft()) {
70+
areas.add(new Rectangle(leftX - width, leftY, width, height));
71+
leftY += height + MachineScreen.SPACING;
72+
} else {
73+
areas.add(new Rectangle(rightX, rightY, width, height));
74+
rightY += height + MachineScreen.SPACING;
75+
}
5776
}
58-
areas.add(new Rectangle(screen.getX() + screen.getImageWidth(), screen.getY(), Constant.TextureCoordinate.TAB_WIDTH, Constant.TextureCoordinate.TAB_HEIGHT * 2));
5977
return areas;
6078
});
6179
}

src/main/java/dev/galacticraft/machinelib/impl/Constant.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ interface TextureCoordinate {
102102
/**
103103
* The height of a configuration panel.
104104
*/
105-
int PANEL_HEIGHT = 93;
105+
int PANEL_HEIGHT = 92;
106106
/**
107107
* The width of a configuration tab.
108108
*/

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

Lines changed: 10 additions & 1 deletion
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
4.04 KB
Loading

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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)