Skip to content

Commit 94d236f

Browse files
committed
Port bridge changes from 1.21.1 back
1 parent 7f32526 commit 94d236f

File tree

20 files changed

+471
-567
lines changed

20 files changed

+471
-567
lines changed

src/main/java/de/srendi/advancedperipherals/client/smartglasses/objects/twodim/RectangleRenderer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ public void renderBatch(List<RenderableObject> objects, ForgeGui gui, PoseStack
3030
float green = RenderUtil.getGreen(obj.color);
3131
float blue = RenderUtil.getBlue(obj.color);
3232

33-
bufferbuilder.vertex(matrix, obj.x, obj.maxY, 0f).color(red, green, blue, alpha).endVertex();
34-
bufferbuilder.vertex(matrix, obj.maxX, obj.maxY, 0f).color(red, green, blue, alpha).endVertex();
35-
bufferbuilder.vertex(matrix, obj.maxX, obj.y, 0f).color(red, green, blue, alpha).endVertex();
36-
bufferbuilder.vertex(matrix, obj.x, obj.y, 0f).color(red, green, blue, alpha).endVertex();
33+
bufferbuilder.vertex(matrix, obj.x, obj.maxY, obj.z).color(red, green, blue, 0.0001f).endVertex();
34+
bufferbuilder.vertex(matrix, obj.maxX, obj.maxY, obj.z).color(red, green, blue, 0.00f).endVertex();
35+
bufferbuilder.vertex(matrix, obj.maxX, obj.y, obj.z).color(red, green, blue, 0.0f).endVertex();
36+
bufferbuilder.vertex(matrix, obj.x, obj.y, obj.z).color(red, green, blue, 0f).endVertex();
3737
}
3838

3939
BufferUploader.drawWithShader(bufferbuilder.end());

src/main/java/de/srendi/advancedperipherals/client/smartglasses/objects/twodim/TextRenderer.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,24 @@ public class TextRenderer implements ITwoDObjectRenderer {
1212

1313
@Override
1414
public void renderBatch(List<RenderableObject> objects, ForgeGui gui, PoseStack poseStack, float partialTick, int screenWidth, int screenHeight) {
15-
1615
Minecraft minecraft = Minecraft.getInstance();
1716
for (RenderableObject obj : objects) {
1817
TextObject text = (TextObject) obj;
18+
poseStack.pushPose();
1919
poseStack.scale(text.fontSize, text.fontSize, 1);
20+
21+
float x = text.x;
22+
23+
if (text.center) {
24+
x -= (minecraft.font.width(text.content) * text.fontSize) / 2f;
25+
}
26+
2027
if (text.shadow) {
21-
minecraft.font.drawShadow(poseStack, text.content, text.x / text.fontSize, text.y / text.fontSize, text.color);
28+
minecraft.font.drawShadow(poseStack, text.content, x / text.fontSize, text.y / text.fontSize, text.color);
2229
} else {
23-
minecraft.font.draw(poseStack, text.content, text.x / text.fontSize, text.y / text.fontSize, text.color);
30+
minecraft.font.draw(poseStack, text.content, x / text.fontSize, text.y / text.fontSize, text.color);
2431
}
32+
poseStack.popPose();
2533
}
2634

2735
}

src/main/java/de/srendi/advancedperipherals/common/addons/APAddons.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package de.srendi.advancedperipherals.common.addons;
22

33
import de.srendi.advancedperipherals.AdvancedPeripherals;
4-
import de.srendi.advancedperipherals.common.addons.refinedstorage.RefinedStorage;
4+
import de.srendi.advancedperipherals.common.addons.refinedstorage.RSApi;
55
import de.srendi.advancedperipherals.common.addons.valkyrienskies.ValkyrienSkies;
66
import net.minecraft.core.BlockPos;
77
import net.minecraft.resources.ResourceLocation;
@@ -65,7 +65,7 @@ public class APAddons {
6565
vs2Loaded = modList.isLoaded(VALKYRIEN_SKIES_MODID);
6666

6767
if (refinedStorageLoaded) {
68-
RefinedStorage.instance = new RefinedStorage();
68+
RSApi.instance = new RSApi();
6969
}
7070
}
7171

src/main/java/de/srendi/advancedperipherals/common/addons/ae2/AppEngApi.java renamed to src/main/java/de/srendi/advancedperipherals/common/addons/ae2/AEApi.java

Lines changed: 8 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
import java.util.Set;
6363
import java.util.stream.Collectors;
6464

65-
public class AppEngApi {
65+
public class AEApi {
6666

6767
public static Pair<Long, AEItemKey> findAEStackFromStack(MEStorage monitor, @Nullable ICraftingService crafting, ItemStack item) {
6868
return findAEStackFromFilter(monitor, crafting, ItemFilter.fromStack(item));
@@ -238,7 +238,7 @@ public static List<IPatternDetails> getPatterns(IGrid grid, Level level) {
238238
}
239239

240240
public static List<Object> listPatterns(IGrid grid, Level level) {
241-
return getPatterns(grid, level).stream().map(AppEngApi::parsePattern).collect(Collectors.toList());
241+
return getPatterns(grid, level).stream().map(AEApi::parsePattern).collect(Collectors.toList());
242242
}
243243

244244
public static List<Object> listDrives(IGrid grid) {
@@ -367,8 +367,8 @@ private static Map<String, Object> parseChemStack(Pair<Long, MekanismKey> stack)
367367
public static Map<String, Object> parsePattern(IPatternDetails pattern) {
368368
Map<String, Object> map = new HashMap<>();
369369

370-
map.put("inputs", Arrays.stream(pattern.getInputs()).map(AppEngApi::parsePatternInput).collect(Collectors.toList()));
371-
map.put("outputs", Arrays.stream(pattern.getOutputs()).map(AppEngApi::parseGenericStack).collect(Collectors.toList()));
370+
map.put("inputs", Arrays.stream(pattern.getInputs()).map(AEApi::parsePatternInput).collect(Collectors.toList()));
371+
map.put("outputs", Arrays.stream(pattern.getOutputs()).map(AEApi::parseGenericStack).collect(Collectors.toList()));
372372
map.put("primaryOutput", parseGenericStack(pattern.getPrimaryOutput()));
373373
return map;
374374
}
@@ -378,7 +378,7 @@ public static Map<String, Object> parsePatternInput(IPatternDetails.IInput patte
378378
map.put("primaryInput", parseGenericStack(patternInput.getPossibleInputs()[0]));
379379
map.put("possibleInputs",
380380
Arrays.stream(Arrays.copyOfRange(patternInput.getPossibleInputs(), 1, patternInput.getPossibleInputs().length))
381-
.map(AppEngApi::parseGenericStack));
381+
.map(AEApi::parseGenericStack));
382382
map.put("multiplier", patternInput.getMultiplier());
383383
map.put("remaining", patternInput.getRemainingKey(patternInput.getPossibleInputs()[0].what()));
384384
return map;
@@ -417,14 +417,8 @@ public static MEStorage getMonitor(IGridNode node) {
417417
return node.getGrid().getService(IStorageService.class).getInventory();
418418
}
419419

420-
public static boolean isItemCrafting(MEStorage monitor, ICraftingService grid, ItemFilter filter,
420+
public static boolean isCrafting(ICraftingService grid, GenericFilter<?> filter,
421421
@Nullable ICraftingCPU craftingCPU) {
422-
Pair<Long, AEItemKey> stack = AppEngApi.findAEStackFromFilter(monitor, grid, filter);
423-
424-
// If the item stack does not exist, it cannot be crafted.
425-
if (stack == null)
426-
return false;
427-
428422
// If the passed cpu is null, check all cpus
429423
if (craftingCPU == null) {
430424
// Loop through all crafting cpus and check if the item is being crafted.
@@ -436,45 +430,7 @@ public static boolean isItemCrafting(MEStorage monitor, ICraftingService grid, I
436430
if (jobStatus == null)
437431
continue;
438432

439-
if (jobStatus.crafting().what().equals(stack.getRight()))
440-
return true;
441-
}
442-
}
443-
} else {
444-
if (craftingCPU.isBusy()) {
445-
CraftingJobStatus jobStatus = craftingCPU.getJobStatus();
446-
447-
// avoid null pointer exception
448-
if (jobStatus == null)
449-
return false;
450-
451-
return jobStatus.crafting().what().equals(stack.getRight());
452-
}
453-
}
454-
455-
return false;
456-
}
457-
458-
public static boolean isFluidCrafting(MEStorage monitor, ICraftingService grid, FluidFilter filter,
459-
@Nullable ICraftingCPU craftingCPU) {
460-
Pair<Long, AEFluidKey> stack = AppEngApi.findAEFluidFromFilter(monitor, grid, filter);
461-
462-
// If the fluid stack does not exist, it cannot be crafted.
463-
if (stack == null)
464-
return false;
465-
466-
// If the passed cpu is null, check all cpus
467-
if (craftingCPU == null) {
468-
// Loop through all crafting cpus and check if the fluid is being crafted.
469-
for (ICraftingCPU cpu : grid.getCpus()) {
470-
if (cpu.isBusy()) {
471-
CraftingJobStatus jobStatus = cpu.getJobStatus();
472-
473-
// avoid null pointer exception
474-
if (jobStatus == null)
475-
continue;
476-
477-
if (jobStatus.crafting().what().equals(stack.getRight()))
433+
if (filter.testAE(jobStatus.crafting()))
478434
return true;
479435
}
480436
}
@@ -486,7 +442,7 @@ public static boolean isFluidCrafting(MEStorage monitor, ICraftingService grid,
486442
if (jobStatus == null)
487443
return false;
488444

489-
return jobStatus.crafting().what().equals(stack.getRight());
445+
return filter.testAE(jobStatus.crafting());
490446
}
491447
}
492448

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import appeng.api.networking.IGridNodeListener;
55
import de.srendi.advancedperipherals.common.blocks.blockentities.MeBridgeEntity;
66

7-
public class MeBridgeEntityListener implements IGridNodeListener<MeBridgeEntity> {
7+
public class MEBridgeEntityListener implements IGridNodeListener<MeBridgeEntity> {
88

9-
public static final MeBridgeEntityListener INSTANCE = new MeBridgeEntityListener();
9+
public static final MEBridgeEntityListener INSTANCE = new MEBridgeEntityListener();
1010

1111
@Override
1212
public void onSecurityBreak(MeBridgeEntity nodeOwner, IGridNode node) {

src/main/java/de/srendi/advancedperipherals/common/addons/ae2/MeFluidHandler.java renamed to src/main/java/de/srendi/advancedperipherals/common/addons/ae2/MEFluidHandler.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import appeng.api.networking.security.IActionSource;
55
import appeng.api.stacks.AEFluidKey;
66
import appeng.api.storage.MEStorage;
7+
import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.MEBridgePeripheral;
78
import de.srendi.advancedperipherals.common.util.Pair;
89
import de.srendi.advancedperipherals.common.util.inventory.FluidFilter;
910
import de.srendi.advancedperipherals.common.util.inventory.IStorageSystemFluidHandler;
@@ -13,16 +14,16 @@
1314
/**
1415
* Used to transfer item between an inventory and the ME system.
1516
*
16-
* @see de.srendi.advancedperipherals.common.addons.computercraft.peripheral.MeBridgePeripheral
17+
* @see MEBridgePeripheral
1718
*/
18-
public class MeFluidHandler implements IStorageSystemFluidHandler {
19+
public class MEFluidHandler implements IStorageSystemFluidHandler {
1920

2021
@NotNull
2122
private final MEStorage storageMonitor;
2223
@NotNull
2324
private final IActionSource actionSource;
2425

25-
public MeFluidHandler(@NotNull MEStorage storageMonitor, @NotNull IActionSource actionSource) {
26+
public MEFluidHandler(@NotNull MEStorage storageMonitor, @NotNull IActionSource actionSource) {
2627
this.storageMonitor = storageMonitor;
2728
this.actionSource = actionSource;
2829
}
@@ -40,7 +41,7 @@ public int fill(FluidStack resource, FluidAction action) {
4041
@NotNull
4142
@Override
4243
public FluidStack drain(FluidFilter filter, FluidAction simulate) {
43-
Pair<Long, AEFluidKey> itemKey = AppEngApi.findAEFluidFromFilter(storageMonitor, null, filter);
44+
Pair<Long, AEFluidKey> itemKey = AEApi.findAEFluidFromFilter(storageMonitor, null, filter);
4445
if (itemKey == null)
4546
return FluidStack.EMPTY;
4647
long extracted = storageMonitor.extract(itemKey.getRight(), filter.getCount(), simulate == FluidAction.SIMULATE ? Actionable.SIMULATE : Actionable.MODULATE, actionSource);

src/main/java/de/srendi/advancedperipherals/common/addons/ae2/MeItemHandler.java renamed to src/main/java/de/srendi/advancedperipherals/common/addons/ae2/MEItemHandler.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import appeng.api.networking.security.IActionSource;
55
import appeng.api.stacks.AEItemKey;
66
import appeng.api.storage.MEStorage;
7+
import de.srendi.advancedperipherals.common.addons.computercraft.peripheral.MEBridgePeripheral;
78
import de.srendi.advancedperipherals.common.util.Pair;
89
import de.srendi.advancedperipherals.common.util.inventory.IStorageSystemItemHandler;
910
import de.srendi.advancedperipherals.common.util.inventory.ItemFilter;
@@ -13,16 +14,16 @@
1314
/**
1415
* Used to transfer item between an inventory and the ME system.
1516
*
16-
* @see de.srendi.advancedperipherals.common.addons.computercraft.peripheral.MeBridgePeripheral
17+
* @see MEBridgePeripheral
1718
*/
18-
public class MeItemHandler implements IStorageSystemItemHandler {
19+
public class MEItemHandler implements IStorageSystemItemHandler {
1920

2021
@NotNull
2122
private final MEStorage storageMonitor;
2223
@NotNull
2324
private final IActionSource actionSource;
2425

25-
public MeItemHandler(@NotNull MEStorage storageMonitor, @NotNull IActionSource actionSource) {
26+
public MEItemHandler(@NotNull MEStorage storageMonitor, @NotNull IActionSource actionSource) {
2627
this.storageMonitor = storageMonitor;
2728
this.actionSource = actionSource;
2829
}
@@ -40,7 +41,7 @@ public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate
4041

4142
@Override
4243
public ItemStack extractItem(ItemFilter filter, int count, boolean simulate) {
43-
Pair<Long, AEItemKey> itemKey = AppEngApi.findAEStackFromFilter(storageMonitor, null, filter);
44+
Pair<Long, AEItemKey> itemKey = AEApi.findAEStackFromFilter(storageMonitor, null, filter);
4445
if (itemKey.getRight() == null)
4546
return ItemStack.EMPTY;
4647
long extracted = storageMonitor.extract(itemKey.getRight(), count, simulate ? Actionable.SIMULATE : Actionable.MODULATE, actionSource);

0 commit comments

Comments
 (0)