diff --git a/README.md b/README.md
index 1228ff3ec..bf7c2e432 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ Join our Discord: https://discord.gg/4tMAnBAacW
Visit our website: https://pylonmc.github.io/
## Warning
-PYLON IS CURRENTLY EXPERIMENTAL. ONLY RUN IT ON A TEST SERVER THAT YOU ARE WILLING TO DELETE. THE NEXT PYLON VERSION WILL PROBABLY NOT BE COMPATIBLE WITH THE PREVIOUS ONE. IF YOU INSTALL PYLON SOMEWHERE YOU SHOULDN'T AND END UP LOSING DATA, WE WILL POINT AND LAUGH AT YOU.
+PYLON IS CURRENTLY EXPERIMENTAL. ONLY RUN IT ON A TEST SERVER THAT YOU ARE WILLING TO DELETE. THE NEXT PYLON VERSION WILL PROBABLY NOT BE COMPATIBLE WITH THE PREVIOUS ONE. IF YOU INSTALL PYLON SOMEWHERE YOU SHOULDN'T AND END UP LOSING DATA, WE WILL POINT AND LAUGH AT YOU
## Pylon in pictures
diff --git a/src/main/java/io/github/pylonmc/pylon/base/content/machines/cargo/CargoBuffer.java b/src/main/java/io/github/pylonmc/pylon/base/content/machines/cargo/CargoBuffer.java
index d4d7b29e1..81a61075f 100644
--- a/src/main/java/io/github/pylonmc/pylon/base/content/machines/cargo/CargoBuffer.java
+++ b/src/main/java/io/github/pylonmc/pylon/base/content/machines/cargo/CargoBuffer.java
@@ -170,7 +170,7 @@ public void write(@NotNull PersistentDataContainer pdc) {
}
@Override
- public void setupLogisticGroups() {
+ public void postInitialise() {
createLogisticGroup("input", LogisticSlotType.INPUT, new VirtualInventoryLogisticSlot(inventory, 0));
createLogisticGroup("output", LogisticSlotType.OUTPUT, new VirtualInventoryLogisticSlot(inventory, 0));
}
diff --git a/src/main/java/io/github/pylonmc/pylon/base/content/machines/cargo/CargoExtractor.java b/src/main/java/io/github/pylonmc/pylon/base/content/machines/cargo/CargoExtractor.java
index b4995c945..a3b3873cc 100644
--- a/src/main/java/io/github/pylonmc/pylon/base/content/machines/cargo/CargoExtractor.java
+++ b/src/main/java/io/github/pylonmc/pylon/base/content/machines/cargo/CargoExtractor.java
@@ -155,9 +155,6 @@ public boolean isPartOfMultiblock(@NotNull Block otherBlock) {
return facing;
}
- @Override
- public void setupLogisticGroups() {}
-
@Override
public @NotNull Map getLogisticGroups() {
PylonLogisticBlock logisticBlock = getTargetLogisticBlock();
diff --git a/src/main/java/io/github/pylonmc/pylon/base/content/machines/cargo/CargoInserter.java b/src/main/java/io/github/pylonmc/pylon/base/content/machines/cargo/CargoInserter.java
index 918037229..f3c23d062 100644
--- a/src/main/java/io/github/pylonmc/pylon/base/content/machines/cargo/CargoInserter.java
+++ b/src/main/java/io/github/pylonmc/pylon/base/content/machines/cargo/CargoInserter.java
@@ -152,9 +152,6 @@ public boolean isPartOfMultiblock(@NotNull Block otherBlock) {
return facing;
}
- @Override
- public void setupLogisticGroups() {}
-
@Override
public void onDuctConnected(@NotNull PylonCargoConnectEvent event) {
// Remove all faces that aren't to the connected block - this will make sure only
diff --git a/src/main/java/io/github/pylonmc/pylon/base/content/machines/diesel/DieselPipeBender.java b/src/main/java/io/github/pylonmc/pylon/base/content/machines/diesel/DieselPipeBender.java
index 0de352fe0..f40d2cd78 100644
--- a/src/main/java/io/github/pylonmc/pylon/base/content/machines/diesel/DieselPipeBender.java
+++ b/src/main/java/io/github/pylonmc/pylon/base/content/machines/diesel/DieselPipeBender.java
@@ -8,7 +8,7 @@
import io.github.pylonmc.pylon.core.block.base.PylonFluidBufferBlock;
import io.github.pylonmc.pylon.core.block.base.PylonGuiBlock;
import io.github.pylonmc.pylon.core.block.base.PylonLogisticBlock;
-import io.github.pylonmc.pylon.core.block.base.PylonTickingBlock;
+import io.github.pylonmc.pylon.core.block.base.PylonRecipeProcessor;
import io.github.pylonmc.pylon.core.block.context.BlockBreakContext;
import io.github.pylonmc.pylon.core.block.context.BlockCreateContext;
import io.github.pylonmc.pylon.core.config.adapter.ConfigAdapter;
@@ -44,7 +44,7 @@
public class DieselPipeBender extends PylonBlock
- implements PylonGuiBlock, PylonFluidBufferBlock, PylonTickingBlock, PylonLogisticBlock {
+ implements PylonGuiBlock, PylonFluidBufferBlock, PylonLogisticBlock, PylonRecipeProcessor {
public final double dieselBuffer = getSettings().getOrThrow("diesel-buffer", ConfigAdapter.DOUBLE);
public final double dieselPerSecond = getSettings().getOrThrow("diesel-per-second", ConfigAdapter.DOUBLE);
@@ -69,8 +69,6 @@ public Item(@NotNull ItemStack stack) {
}
}
- private int recipeTicksRemaining;
- private @Nullable PipeBendingRecipe recipe;
private final VirtualInventory inputInventory = new VirtualInventory(1);
private final VirtualInventory outputInventory = new VirtualInventory(1);
private final ProgressItem progressItem = new ProgressItem(ItemStackBuilder.of(GuiItems.background()));
@@ -117,51 +115,50 @@ public DieselPipeBender(@NotNull Block block, @NotNull BlockCreateContext contex
.build(block.getLocation().toCenterLocation().add(0, 0.5, 0))
);
createFluidBuffer(BaseFluids.BIODIESEL, dieselBuffer, true, false);
- recipe = null;
- attachInventoryHandlers();
+ setRecipeType(PipeBendingRecipe.RECIPE_TYPE);
}
@SuppressWarnings("unused")
public DieselPipeBender(@NotNull Block block, @NotNull PersistentDataContainer pdc) {
super(block, pdc);
- recipe = null;
- attachInventoryHandlers();
}
@Override
- public void onBreak(@NotNull List<@NotNull ItemStack> drops, @NotNull BlockBreakContext context) {
- PylonGuiBlock.super.onBreak(drops, context);
- PylonFluidBufferBlock.super.onBreak(drops, context);
+ public void postInitialise() {
+ createLogisticGroup("input", LogisticSlotType.INPUT, inputInventory);
+ createLogisticGroup("output", LogisticSlotType.OUTPUT, outputInventory);
+ setProgressItem(progressItem);
+ inputInventory.setPostUpdateHandler(event -> {
+ // Null check here because I've seen exceptions when the block is loading in but the entity hasn't been
+ // loaded yet (no idea why this handler would fire at that point but oh well)
+ ItemDisplay display = getHeldEntity(ItemDisplay.class, "item");
+ if (display != null) {
+ display.setItemStack(event.getNewItem());
+ }
+ });
+ outputInventory.setPreUpdateHandler(event -> {
+ if (!event.isRemove() && event.getUpdateReason() instanceof PlayerUpdateReason) {
+ event.setCancelled(true);
+ }
+ });
}
@Override
- public void setupLogisticGroups() {
- createLogisticGroup("input", LogisticSlotType.INPUT, inputInventory);
- createLogisticGroup("output", LogisticSlotType.OUTPUT, outputInventory);
+ public void onBreak(@NotNull List<@NotNull ItemStack> drops, @NotNull BlockBreakContext context) {
+ PylonGuiBlock.super.onBreak(drops, context);
+ PylonFluidBufferBlock.super.onBreak(drops, context);
}
@Override
public void tick(double deltaSeconds) {
- ItemStack stack = inputInventory.getItem(0);
+ PylonRecipeProcessor.super.tick(deltaSeconds);
- if (recipe != null) {
+ if (getCurrentRecipe() != null) {
spawnParticles();
- progressItem.setRemainingTimeTicks(recipeTicksRemaining);
-
- // tick recipe
- if (recipeTicksRemaining > 0) {
- recipeTicksRemaining -= tickInterval;
- return;
- }
-
- // finish recipe
- outputInventory.addItem(null, recipe.result().clone());
- progressItem.setItemStackBuilder(ItemStackBuilder.of(GuiItems.background()));
- progressItem.setTotalTime(null);
- recipe = null;
return;
}
+ ItemStack stack = inputInventory.getItem(0);
if (stack == null) {
return;
}
@@ -185,16 +182,10 @@ public void tick(double deltaSeconds) {
}
// start recipe
- this.recipe = recipe;
- recipeTicksRemaining = (int) Math.round(recipe.timeTicks() * speed);
+ startRecipe(recipe, (int) Math.round(recipe.timeTicks() * speed / tickInterval));
stack.subtract(recipe.input().getAmount());
inputInventory.setItem(null, 0, stack);
-
- progressItem.setItemStackBuilder(
- ItemStackBuilder.of(recipe.result().clone()).clearLore()
- );
- progressItem.setTotalTimeTicks(recipeTicksRemaining);
- progressItem.setRemainingTimeTicks(recipeTicksRemaining);
+ progressItem.setItemStackBuilder(ItemStackBuilder.of(recipe.result().clone()).clearLore());
spawnParticles();
removeFluid(BaseFluids.BIODIESEL, dieselAmount);
@@ -232,20 +223,10 @@ public void tick(double deltaSeconds) {
));
}
- private void attachInventoryHandlers() {
- inputInventory.setPostUpdateHandler(event -> {
- // Null check here because I've seen exceptions when the block is loading in but the entity hasn't been
- // loaded yet (no idea why this handler would fire at that point but oh well)
- ItemDisplay display = getHeldEntity(ItemDisplay.class, "item");
- if (display != null) {
- display.setItemStack(event.getNewItem());
- }
- });
- outputInventory.setPreUpdateHandler(event -> {
- if (!event.isRemove() && event.getUpdateReason() instanceof PlayerUpdateReason) {
- event.setCancelled(true);
- }
- });
+ @Override
+ public void onRecipeFinished(@NotNull PipeBendingRecipe recipe) {
+ outputInventory.addItem(null, recipe.result().clone());
+ progressItem.setItemStackBuilder(ItemStackBuilder.of(GuiItems.background()));
}
public void spawnParticles() {