Skip to content
Draft
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 src/main/java/io/github/pylonmc/pylon/PylonBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static void initialize() {
RebarBlock.register(PylonKeys.SHIMMER_ALTAR, Material.SMOOTH_STONE_SLAB, ShimmerAltar.class);
RebarBlock.register(PylonKeys.GRINDSTONE, Material.SMOOTH_STONE_SLAB, Grindstone.class);
RebarBlock.register(PylonKeys.GRINDSTONE_HANDLE, Material.OAK_FENCE, GrindstoneHandle.class);
RebarBlock.register(PylonKeys.ENRICHED_SOUL_SOIL, Material.SOUL_SOIL, EnrichedSoulSoil.class);
RebarBlock.register(PylonKeys.ENRICHED_SOUL_SOIL, Material.SOUL_SOIL, RebarBlock.class);
RebarBlock.register(PylonKeys.MIXING_POT, Material.CAULDRON, MixingPot.class);
RebarBlock.register(PylonKeys.CRUCIBLE, Material.CAULDRON, Crucible.class);
RebarBlock.register(PylonKeys.IGNEOUS_COMPOSITE, Material.OBSIDIAN, WitherProofBlock.class);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -184,21 +184,31 @@ public void tryStartRecipe() {
}

ItemStack stack = inputInventory.getItem(0);
if (stack == null) {
if (stack == null || stack.isEmpty()) {
return;
}

if (getLastRecipe() != null && tryStartRecipe(getLastRecipe(), stack)) {
return;
}

for (MoldingRecipe recipe : MoldingRecipe.RECIPE_TYPE) {
if (!recipe.input().isSimilar(stack) || !outputInventory.canHold(recipe.result())) {
continue;
if (tryStartRecipe(recipe, stack)) {
break;
}
}
}

startRecipe(recipe, recipe.moldingCycles() * tickInterval * ticksPerMoldingCycle);
getRecipeProgressItem().setItem(ItemStackBuilder.of(stack.asOne()).clearLore());
getHeldEntityOrThrow(ItemDisplay.class, "item").setItemStack(stack);
inputInventory.setItem(new MachineUpdateReason(), 0, stack.subtract(recipe.input().getAmount()));
break;
private boolean tryStartRecipe(MoldingRecipe recipe, ItemStack stack) {
if (!recipe.input().isSimilar(stack) || !outputInventory.canHold(recipe.result())) {
return false;
}

startRecipe(recipe, recipe.moldingCycles() * tickInterval * ticksPerMoldingCycle);
getRecipeProgressItem().setItem(ItemStackBuilder.of(stack.asOne()).clearLore());
getHeldEntityOrThrow(ItemDisplay.class, "item").setItemStack(stack);
inputInventory.setItem(new MachineUpdateReason(), 0, stack.subtract(recipe.input().getAmount()));
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,20 +177,30 @@ public void tryStartRecipe() {
}

ItemStack stack = inputInventory.getItem(0);
if (stack == null) {
if (stack == null || stack.isEmpty()) {
return;
}

if (getLastRecipe() != null && tryStartRecipe(getLastRecipe(), stack)) {
return;
}

for (FurnaceRecipeWrapper recipe : FurnaceRecipeType.INSTANCE) {
if (!recipe.isInput(stack) || !outputInventory.canHold(recipe.getRecipe().getResult())) {
continue;
if (tryStartRecipe(recipe, stack)) {
break;
}
}
}

startRecipe(recipe, recipeTime);
getRecipeProgressItem().setItem(ItemStackBuilder.of(stack.asOne()).clearLore());
inputInventory.setItem(new MachineUpdateReason(), 0, stack.subtract());
break;
private boolean tryStartRecipe(FurnaceRecipeWrapper recipe, ItemStack stack) {
if (!recipe.isInput(stack) || !outputInventory.canHold(recipe.getRecipe().getResult())) {
return false;
}

startRecipe(recipe, recipeTime);
getRecipeProgressItem().setItem(ItemStackBuilder.of(stack.asOne()).clearLore());
inputInventory.setItem(new MachineUpdateReason(), 0, stack.subtract());
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,23 +196,30 @@ public void tryStartRecipe() {
return;
}

recipeLoop:
if (getLastRecipe() != null && tryStartRecipe(getLastRecipe(), stack)) {
return;
}

for (GrindstoneRecipe recipe : GrindstoneRecipe.RECIPE_TYPE) {
if (!recipe.input().matches(stack)) {
continue;
if (tryStartRecipe(recipe, stack)) {
return;
}
}
}

for (ItemStack output : recipe.results().getElements()) {
if (!outputInventory.canHold(output)) {
break recipeLoop;
}
}
private boolean tryStartRecipe(GrindstoneRecipe recipe, ItemStack stack) {
if (!recipe.input().matches(stack)) {
return false;
}

startRecipe(recipe, recipe.cycles() * Grindstone.CYCLE_DURATION_TICKS);
getRecipeProgressItem().setItem(ItemStackBuilder.of(stack.asOne()).clearLore());
inputInventory.setItem(new MachineUpdateReason(), 0, stack.subtract(recipe.input().getAmount()));
break;
if (!outputInventory.canHold(List.copyOf(recipe.results().getElements()))) {
return true;
}

startRecipe(recipe, recipe.cycles() * Grindstone.CYCLE_DURATION_TICKS);
getRecipeProgressItem().setItem(ItemStackBuilder.of(stack.asOne()).clearLore());
inputInventory.setItem(new MachineUpdateReason(), 0, stack.subtract(recipe.input().getAmount()));
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public void tick() {
return;
}

if (!hammer.tryDoRecipe(baseBlock, null, null, BlockFace.UP)) {
if (!hammer.tryDoRecipe(baseBlock, null, null)) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,21 +195,31 @@ public void tryStartRecipe() {
}

ItemStack stack = inputInventory.getItem(0);
if (stack == null) {
if (stack == null || stack.isEmpty()) {
return;
}

if (getLastRecipe() != null && tryStartRecipe(getLastRecipe(), stack)) {
return;
}

for (PipeBendingRecipe recipe : PipeBendingRecipe.RECIPE_TYPE) {
if (!recipe.input().matches(stack) || !outputInventory.canHold(recipe.result())) {
continue;
if (tryStartRecipe(recipe, stack)) {
break;
}
}
}

startRecipe(recipe, (int) Math.round(recipe.timeTicks() / speed));
getRecipeProgressItem().setItem(ItemStackBuilder.of(stack.asOne()).clearLore());
getHeldEntityOrThrow(ItemDisplay.class, "item").setItemStack(stack);
inputInventory.setItem(new MachineUpdateReason(), 0, stack.subtract(recipe.input().getAmount()));
break;
private boolean tryStartRecipe(PipeBendingRecipe recipe, ItemStack stack) {
if (!recipe.input().matches(stack) || !outputInventory.canHold(recipe.result())) {
return false;
}

startRecipe(recipe, (int) Math.round(recipe.timeTicks() / speed));
getRecipeProgressItem().setItem(ItemStackBuilder.of(stack.asOne()).clearLore());
getHeldEntityOrThrow(ItemDisplay.class, "item").setItemStack(stack);
inputInventory.setItem(new MachineUpdateReason(), 0, stack.subtract(recipe.input().getAmount()));
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,21 +192,31 @@ public void tryStartRecipe() {
}

ItemStack stack = inputInventory.getItem(0);
if (stack == null) {
if (stack == null || stack.isEmpty()) {
return;
}

if (getLastRecipe() != null && tryStartRecipe(getLastRecipe(), stack)) {
return;
}

for (PressRecipe recipe : PressRecipe.RECIPE_TYPE) {
double plantOilAmount = recipe.oilAmount();
if (!recipe.input().matches(stack) || fluidSpaceRemaining(PylonFluids.PLANT_OIL) < plantOilAmount) {
continue;
if (tryStartRecipe(recipe, stack)) {
break;
}
}
}

startRecipe(recipe, (int) (timePerItem * 20));
getRecipeProgressItem().setItem(ItemStackBuilder.of(stack.asOne()).clearLore());
inputInventory.setItem(new MachineUpdateReason(), 0, stack.subtract(recipe.input().getAmount()));
break;
private boolean tryStartRecipe(PressRecipe recipe, ItemStack stack) {
double plantOilAmount = recipe.oilAmount();
if (fluidSpaceRemaining(PylonFluids.PLANT_OIL) < plantOilAmount || !recipe.input().matches(stack)) {
return false;
}

startRecipe(recipe, (int) (timePerItem * 20));
getRecipeProgressItem().setItem(ItemStackBuilder.of(stack.asOne()).clearLore());
inputInventory.setItem(new MachineUpdateReason(), 0, stack.subtract(recipe.input().getAmount()));
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,25 +187,35 @@ public void tryStartRecipe() {
}

ItemStack stack = inputInventory.getItem(0);
if (stack == null) {
if (stack == null || stack.isEmpty()) {
return;
}

if (getLastRecipe() != null && tryStartRecipe(getLastRecipe(), stack)) {
return;
}

for (TableSawRecipe recipe : TableSawRecipe.RECIPE_TYPE) {
double dieselAmount = dieselPerSecond * recipe.timeTicks() / 20.0;
if (fluidAmount(PylonFluids.BIODIESEL) < dieselAmount
|| !recipe.input().isSimilar(stack)
|| !outputInventory.canHold(recipe.result())
) {
continue;
if (tryStartRecipe(recipe, stack)) {
break;
}
}
}

startRecipe(recipe, recipe.timeTicks());
getRecipeProgressItem().setItem(ItemStackBuilder.of(stack.asOne()).clearLore());
getHeldEntityOrThrow(ItemDisplay.class, "item").setItemStack(stack);
inputInventory.setItem(new MachineUpdateReason(), 0, stack.subtract(recipe.input().getAmount()));
break;
private boolean tryStartRecipe(TableSawRecipe recipe, ItemStack stack) {
double dieselAmount = dieselPerSecond * recipe.timeTicks() / 20.0;
if (fluidAmount(PylonFluids.BIODIESEL) < dieselAmount
|| !recipe.input().isSimilar(stack)
|| !outputInventory.canHold(recipe.result())
) {
return false;
}

startRecipe(recipe, recipe.timeTicks());
getRecipeProgressItem().setItem(ItemStackBuilder.of(stack.asOne()).clearLore());
getHeldEntityOrThrow(ItemDisplay.class, "item").setItemStack(stack);
inputInventory.setItem(new MachineUpdateReason(), 0, stack.subtract(recipe.input().getAmount()));
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public class FluidMeter extends RebarBlock implements
private final List<Double> measurements;
private int numberOfMeasurements;

private int lastAverage;

public static class Item extends RebarItem {

public final double buffer = getSettings().getOrThrow("buffer", ConfigAdapter.DOUBLE);
Expand Down Expand Up @@ -206,10 +208,16 @@ public void tick() {
measurements.removeFirst();
}
}

double total = measurements.stream()
.mapToDouble(x -> x)
.sum();
double average = (total / measurements.size()) * 20.0 / getTickInterval();
int average = (int) ((total / measurements.size()) * 20.0 / getTickInterval());
if (average == lastAverage) {
return;
}
lastAverage = average;

Component component = UnitFormat.MILLIBUCKETS_PER_SECOND.format(average).decimalPlaces(0).asComponent();
getHeldEntityOrThrow(TextDisplay.class, "flow_rate").text(component);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public void tick() {
return;
}

if (!hammer.tryDoRecipe(baseBlock, null, null, BlockFace.UP)) {
if (!hammer.tryDoRecipe(baseBlock, null, null)) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,28 @@ public void tick() {
}

ItemStack stack = getItemDisplay().getItemStack();
if (stack.isEmpty()) {
return;
}

if (getLastRecipe() != null && tryStartRecipe(getLastRecipe(), stack)) {
return;
}

for (PipeBendingRecipe recipe : PipeBendingRecipe.RECIPE_TYPE) {
if (!recipe.input().matches(stack)) {
continue;
if (tryStartRecipe(recipe, stack)) {
break;
}
}
}

startRecipe(recipe, recipe.timeTicks());
break;
private boolean tryStartRecipe(PipeBendingRecipe recipe, ItemStack stack) {
if (!recipe.input().matches(stack)) {
return false;
}

startRecipe(recipe, recipe.timeTicks());
return true;
}

public ItemDisplay getItemDisplay() {
Expand Down
Loading
Loading