Skip to content
Open
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
1 change: 1 addition & 0 deletions src/main/java/io/github/pylonmc/pylon/PylonBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public static void initialize() {
RebarBlock.register(PylonKeys.GRINDSTONE_HANDLE, Material.OAK_FENCE, GrindstoneHandle.class);
RebarBlock.register(PylonKeys.ENRICHED_SOUL_SOIL, Material.SOUL_SOIL, RebarBlock.class);
RebarBlock.register(PylonKeys.MIXING_POT, Material.CAULDRON, MixingPot.class);
RebarBlock.register(PylonKeys.PIPED_CAULDRON, Material.CAULDRON, PipedCauldron.class);
RebarBlock.register(PylonKeys.CRUCIBLE, Material.CAULDRON, Crucible.class);
RebarBlock.register(PylonKeys.IGNEOUS_COMPOSITE, Material.OBSIDIAN, WitherProofBlock.class);
RebarBlock.register(PylonKeys.PORTABLE_FLUID_TANK_WOOD, Material.BROWN_STAINED_GLASS, PortableFluidTank.class);
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/io/github/pylonmc/pylon/PylonItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -1983,6 +1983,13 @@ private PylonItems() {
PylonPages.SIMPLE_MACHINES.addItem(GRINDSTONE_HANDLE);
}

public static final ItemStack PIPED_CAULDRON = ItemStackBuilder.rebar(Material.CAULDRON, PylonKeys.PIPED_CAULDRON)
.build();
static {
RebarItem.register(RebarItem.class, PIPED_CAULDRON, PylonKeys.PIPED_CAULDRON);
PylonPages.SIMPLE_MACHINES.addItem(PIPED_CAULDRON);
}

public static final ItemStack CRUDE_ALLOY_FURNACE = ItemStackBuilder.rebar(Material.BLAST_FURNACE, PylonKeys.CRUDE_ALLOY_FURNACE)
.build();
static {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/io/github/pylonmc/pylon/PylonKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ public class PylonKeys {
public static final NamespacedKey KILN = pylonKey("kiln");

public static final NamespacedKey MIXING_POT = pylonKey("mixing_pot");
public static final NamespacedKey PIPED_CAULDRON = pylonKey("piped_cauldron");
public static final NamespacedKey CRUCIBLE = pylonKey("crucible");

public static final NamespacedKey PRESS = pylonKey("press");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package io.github.pylonmc.pylon.content.machines.simple;

import io.github.pylonmc.pylon.PylonFluids;
import io.github.pylonmc.rebar.block.RebarBlock;
import io.github.pylonmc.rebar.block.context.BlockCreateContext;
import io.github.pylonmc.rebar.block.interfaces.CauldronRebarBlockHandler;
import io.github.pylonmc.rebar.block.interfaces.FluidTankRebarBlock;
import io.github.pylonmc.rebar.fluid.FluidPointType;
import io.github.pylonmc.rebar.fluid.RebarFluid;
import io.github.pylonmc.rebar.i18n.RebarArgument;
import io.github.pylonmc.rebar.util.ProgressBar;
import io.github.pylonmc.rebar.waila.WailaDisplay;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.Levelled;
import org.bukkit.entity.Player;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.CauldronLevelChangeEvent;
import org.bukkit.persistence.PersistentDataContainer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NonNull;


public class PipedCauldron extends RebarBlock implements CauldronRebarBlockHandler, FluidTankRebarBlock {

public PipedCauldron(@NotNull Block block, @NotNull BlockCreateContext context) {
super(block, context);
setCapacity(1000.0);
createFluidPoint(FluidPointType.INPUT, context.getFacing());
createFluidPoint(FluidPointType.OUTPUT, context.getFacing().getOppositeFace());
}

public PipedCauldron(@NotNull Block block, @NotNull PersistentDataContainer pdc) {
super(block, pdc);
}

@Override
public boolean isAllowedFluid(@NotNull RebarFluid fluid) {
return fluid.equals(PylonFluids.WATER) || fluid.equals(PylonFluids.LAVA);
}

@Override
public void onFluidAdded(@NotNull RebarFluid fluid, double amount) {
FluidTankRebarBlock.super.onFluidAdded(fluid, amount);
updateCauldronLevel();
}

@Override
public void onFluidRemoved(@NotNull RebarFluid fluid, double amount) {
FluidTankRebarBlock.super.onFluidRemoved(fluid, amount);
updateCauldronLevel();
}

@Override
public void onCauldronLevelChange(@NotNull CauldronLevelChangeEvent event, @NotNull EventPriority priority) {
Material oldMaterial = event.getBlock().getType();
Material newMaterial = event.getNewState().getBlockData().getMaterial();

if (oldMaterial == Material.LAVA_CAULDRON) {
// lava -> empty
setFluid(0);
return;
}

if (oldMaterial == Material.WATER_CAULDRON && newMaterial == Material.CAULDRON) {
// 1/3 water -> empty
setFluid(0);
return;
}

if (oldMaterial == Material.WATER_CAULDRON && newMaterial == Material.WATER_CAULDRON) {
// ?/3 water -> ?/3 water
int oldLevel = ((Levelled) getBlock().getBlockData()).getLevel();
int newLevel = ((Levelled) event.getNewState().getBlockData()).getLevel();
int levelChange = newLevel - oldLevel;
setFluid(getFluidAmount() + levelChange * 333.3333333333333333333333333333333333333333333333333333);
return;
}

if (oldMaterial == Material.CAULDRON && newMaterial == Material.WATER_CAULDRON) {
// empty -> ?/3 water
int newLevel = ((Levelled) event.getNewState().getBlockData()).getLevel();
setFluidType(PylonFluids.WATER);
setFluid(newLevel * 333.3333333333333333333333333333333333333333333333333333);
return;
}

if (oldMaterial == Material.CAULDRON && newMaterial == Material.LAVA_CAULDRON) {
// empty -> lava
setFluidType(PylonFluids.LAVA);
setFluid(1000.0);
}
}

private void updateCauldronLevel() {
if (getFluidType() == null) {
getBlock().setType(Material.CAULDRON);
return;
}

if (PylonFluids.WATER.equals(getFluidType())) {
int targetLevel = (int) Math.floor(getFluidAmount() / 333.3333333333333333333333333333333333333333333333333333); // lol
if (targetLevel == 0) {
getBlock().setType(Material.CAULDRON);
} else {
getBlock().setType(Material.WATER_CAULDRON);
Levelled levelled = (Levelled) Material.WATER_CAULDRON.createBlockData();
levelled.setLevel(targetLevel);
getBlock().setBlockData(levelled);
}
return;
}

if (PylonFluids.LAVA.equals(getFluidType())) {
if (getFluidAmount() < 999.999) {
getBlock().setType(Material.CAULDRON);
} else {
getBlock().setType(Material.LAVA_CAULDRON);
}
}
}

@Override
public @Nullable WailaDisplay getWaila(@NotNull Player player) {
return new WailaDisplay(getDefaultWailaTranslationKey().arguments(
RebarArgument.of("fluid", ProgressBar.fluidContentsWithName(getFluidType(), getFluidCapacity(), getFluidAmount()))
));
}
}
6 changes: 6 additions & 0 deletions src/main/resources/lang/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2546,6 +2546,12 @@ item:
<diamond> 3x <yellow>Polished Deepslate Wall</yellow>
waila: "Diesel Experience Bottler | %progress%"

piped_cauldron:
name: "Piped Cauldron"
lore: |-
<arrow> A cauldron which can have pipes attached to it
waila: "Piped Cauldron | %fluid%"

fluid:
tag:
melting-point: "Melting point: %temperature%"
Expand Down
11 changes: 10 additions & 1 deletion src/main/resources/recipes/minecraft/crafting_shaped.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2952,4 +2952,13 @@ pylon:experience_drain:
D: pylon:shimmer_dust_1
P: minecraft:ender_pearl
result: pylon:experience_drain
category: building
category: building

pylon:piped_cauldron:
pattern:
- "PCP"
key:
P: pylon:fluid_pipe_copper
C: minecraft:cauldron
result: pylon:piped_cauldron
category: building
Loading