Add the insolator #17

Merged
BlakeRain merged 19 commits from BlakeRain/utamacraft:main into main 2023-12-01 18:20:57 +00:00
4 changed files with 13 additions and 9 deletions
Showing only changes of commit 2781e80d1e - Show all commits

Binary file not shown.

View File

@ -134,13 +134,10 @@ public class InsolatorBlockEntity extends BlockEntity implements MenuProvider {
} }
if (entity.canCraft()) { if (entity.canCraft()) {
LOGGER.info("Ticking progress {} -> {}", entity.progress, 1 + entity.progress);
++entity.progress; ++entity.progress;
LOGGER.info("Recording state changed");
setChanged(level, pos, state); setChanged(level, pos, state);
if (entity.progress >= entity.maxProgress) { if (entity.progress >= entity.maxProgress) {
LOGGER.info("Crafting item");
entity.craftItem(); entity.craftItem();
} }
} else { } else {
@ -154,13 +151,9 @@ public class InsolatorBlockEntity extends BlockEntity implements MenuProvider {
} }
private void craftItem() { private void craftItem() {
LOGGER.info("Crafting new item");
ItemStack stack = itemHandler.extractItem(1, 1, false); ItemStack stack = itemHandler.extractItem(1, 1, false);
LOGGER.info("Extracted {}", stack.getItem().getName(stack));
stack.grow(1); stack.grow(1);
LOGGER.info("Grew to {}", stack.getCount());
itemHandler.insertItem(2, stack, false); itemHandler.insertItem(2, stack, false);
LOGGER.info("Inserted into thingy output");
resetProgress(); resetProgress();
} }
@ -168,17 +161,28 @@ public class InsolatorBlockEntity extends BlockEntity implements MenuProvider {
ItemStack input = itemHandler.getStackInSlot(1); ItemStack input = itemHandler.getStackInSlot(1);
ItemStack output = itemHandler.getStackInSlot(2); ItemStack output = itemHandler.getStackInSlot(2);
if (input.isEmpty()) {
return false;
}
// Make sure that the item in the input is a flower. // Make sure that the item in the input is a flower.
if (input.getItem() != Items.CORNFLOWER) { if (input.getItem() != Items.CORNFLOWER) {
LOGGER.info("Cannot run insolator, as item is not recognized");
return false; return false;
} }
// If the output isn't empty, and the item in the output is different to the input, we cannot process. // If the output isn't empty, and the item in the output is different to the input, we cannot process.
if (!output.isEmpty() && output.getItem() != input.getItem()) { if (!output.isEmpty() && output.getItem() != input.getItem()) {
LOGGER.info("Cannot run insolator, as output item is not the same as the input item");
return false; return false;
} }
// Make sure that the output is not saturated. // Make sure that the output is not saturated.
return output.getCount() < output.getMaxStackSize(); if (output.getCount() >= output.getMaxStackSize()) {
LOGGER.info("Cannot run insolator, as output of {} items exceeds maximum of {}", output.getCount(), output.getMaxStackSize());
return false;
}
return true;
} }
} }

View File

@ -31,7 +31,7 @@ public class InsolatorScreen extends AbstractContainerScreen<InsolatorMenu> {
private void renderProgressArrow(PoseStack stack, int x, int y) { private void renderProgressArrow(PoseStack stack, int x, int y) {
if (menu.isCrafting()) { if (menu.isCrafting()) {
blit(stack, x + 105, y + 33, 176, 0, 8, menu.getScaledProgress(26)); blit(stack, x + 90, y + 33, 176, 0, 8, menu.getScaledProgress(25));
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB