Skip to content
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<img width="250" alt="using-smeltery" src="https://github.com/user-attachments/assets/b8a7ba3c-9103-46a5-ab43-f31de08dd492" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,6 @@ public boolean isPartOfMultiblock(@NotNull Block otherBlock) {
return facing;
}

@Override
public void setupLogisticGroups() {}

@Override
public @NotNull Map<String, LogisticGroup> getLogisticGroups() {
PylonLogisticBlock logisticBlock = getTargetLogisticBlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -44,7 +44,7 @@


public class DieselPipeBender extends PylonBlock
implements PylonGuiBlock, PylonFluidBufferBlock, PylonTickingBlock, PylonLogisticBlock {
implements PylonGuiBlock, PylonFluidBufferBlock, PylonLogisticBlock, PylonRecipeProcessor<PipeBendingRecipe> {

public final double dieselBuffer = getSettings().getOrThrow("diesel-buffer", ConfigAdapter.DOUBLE);
public final double dieselPerSecond = getSettings().getOrThrow("diesel-per-second", ConfigAdapter.DOUBLE);
Expand All @@ -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()));
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down Expand Up @@ -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() {
Expand Down