From 01ead5b4077874edaba08fa37a052ae72a7312e7 Mon Sep 17 00:00:00 2001 From: Kli Kli Date: Sun, 9 Jun 2024 08:43:43 +0200 Subject: [PATCH] feat: add redstone signal to golden bowl Closes #1095 --- .../assets/occultism/lang/en_us.json | 2 ++ .../entries/getting_started/first_ritual.json | 11 ++++++++++ .../block/GoldenSacrificialBowlBlock.java | 11 ++++++++++ .../GoldenSacrificialBowlBlockEntity.java | 22 +++++++++++++++++++ .../datagen/OccultismBookProvider.java | 17 +++++++++++++- 5 files changed, 62 insertions(+), 1 deletion(-) diff --git a/src/generated/resources/assets/occultism/lang/en_us.json b/src/generated/resources/assets/occultism/lang/en_us.json index ef0fe528e..121383278 100644 --- a/src/generated/resources/assets/occultism/lang/en_us.json +++ b/src/generated/resources/assets/occultism/lang/en_us.json @@ -350,6 +350,8 @@ "book.occultism.dictionary_of_spirits.getting_started.first_ritual.name": "First Ritual", "book.occultism.dictionary_of_spirits.getting_started.first_ritual.pentacle_link_hint.text": "Ritual recipe pages, such as the previous pageshow not only the ingredients, but also the pentacle that you need to draw with chalk in order to use the ritual.\n\\\n\\\n**To show the pentacle, click the blue link** at the center top of the ritual page. You can then even preview it in-world.\n", "book.occultism.dictionary_of_spirits.getting_started.first_ritual.pentacle_link_hint.title": "A Note about Ritual Recipes", + "book.occultism.dictionary_of_spirits.getting_started.first_ritual.redstone.text": "Depending on the ritual state the golden bowl will emit a different redstone level:\n- **0** if no ritual is active\n- **1** if the ritual is active, but waiting for a sacrifice\n- **2** if the ritual is active, but waiting for an item to be used\n- **4** if the ritual is active and running\n", + "book.occultism.dictionary_of_spirits.getting_started.first_ritual.redstone.title": "Redstone", "book.occultism.dictionary_of_spirits.getting_started.first_ritual.ritual_text.text": "Now it is time to place the ingredients you see on the next page in the (regular, not golden) sacrificial bowls. The ingredients will be consumed from the bowls as the ritual progresses.\n", "book.occultism.dictionary_of_spirits.getting_started.first_ritual.ritual_text.title": "Placing Ingredients", "book.occultism.dictionary_of_spirits.getting_started.first_ritual.start_ritual.text": "Finally, [#](ad03fc)right-click[#]() the [](item://occultism:golden_sacrificial_bowl) with the **bound** book of binding you created before and wait until the crusher spawns.\n\\\n\\\nNow all that remains is to drop appropriate ores near the crusher and wait for it to turn it into dust.\n", diff --git a/src/generated/resources/data/occultism/modonomicon/books/dictionary_of_spirits/entries/getting_started/first_ritual.json b/src/generated/resources/data/occultism/modonomicon/books/dictionary_of_spirits/entries/getting_started/first_ritual.json index 802733acf..258748837 100644 --- a/src/generated/resources/data/occultism/modonomicon/books/dictionary_of_spirits/entries/getting_started/first_ritual.json +++ b/src/generated/resources/data/occultism/modonomicon/books/dictionary_of_spirits/entries/getting_started/first_ritual.json @@ -109,6 +109,17 @@ "text": "book.occultism.dictionary_of_spirits.getting_started.first_ritual.automation.text", "title": "book.occultism.dictionary_of_spirits.getting_started.first_ritual.automation.title", "use_markdown_in_title": false + }, + { + "type": "modonomicon:text", + "anchor": "", + "condition": { + "type": "modonomicon:none" + }, + "show_title_separator": true, + "text": "book.occultism.dictionary_of_spirits.getting_started.first_ritual.redstone.text", + "title": "book.occultism.dictionary_of_spirits.getting_started.first_ritual.redstone.title", + "use_markdown_in_title": false } ], "parents": [ diff --git a/src/main/java/com/klikli_dev/occultism/common/block/GoldenSacrificialBowlBlock.java b/src/main/java/com/klikli_dev/occultism/common/block/GoldenSacrificialBowlBlock.java index 79e596284..1f20374af 100644 --- a/src/main/java/com/klikli_dev/occultism/common/block/GoldenSacrificialBowlBlock.java +++ b/src/main/java/com/klikli_dev/occultism/common/block/GoldenSacrificialBowlBlock.java @@ -26,6 +26,7 @@ import com.klikli_dev.occultism.registry.OccultismBlockEntities; import com.klikli_dev.occultism.util.StorageUtil; import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; @@ -99,6 +100,16 @@ public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, return SHAPE; } + @SuppressWarnings("deprecation") + @Override + public int getSignal(BlockState pBlockState, BlockGetter pBlockAccess, BlockPos pPos, Direction pSide) { + BlockEntity blockEntity = pBlockAccess.getBlockEntity(pPos); + if (blockEntity instanceof GoldenSacrificialBowlBlockEntity bowl) { + return bowl.getSignal(pBlockState, pBlockAccess, pPos, pSide); + } + return 0; + } + @Nullable @Override public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) { diff --git a/src/main/java/com/klikli_dev/occultism/common/blockentity/GoldenSacrificialBowlBlockEntity.java b/src/main/java/com/klikli_dev/occultism/common/blockentity/GoldenSacrificialBowlBlockEntity.java index 4b6bd61e4..6f41be2b3 100644 --- a/src/main/java/com/klikli_dev/occultism/common/blockentity/GoldenSacrificialBowlBlockEntity.java +++ b/src/main/java/com/klikli_dev/occultism/common/blockentity/GoldenSacrificialBowlBlockEntity.java @@ -54,6 +54,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.RecipeHolder; +import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Rotation; @@ -306,6 +307,20 @@ public RecipeHolder getCurrentRitualRecipe() { return this.currentRitualRecipe; } + public int getSignal(BlockState pBlockState, BlockGetter pBlockAccess, BlockPos pPos, Direction pSide) { + if(this.getCurrentRitualRecipe() == null) + return 0; + + if(!this.sacrificeFulfilled()) + return 1; + + if(!this.itemUseFulfilled()) + return 2; + + + return 8; + } + public void tick() { RecipeHolder recipe = this.getCurrentRitualRecipe(); if (!this.level.isClientSide && recipe != null) { @@ -330,6 +345,9 @@ public void tick() { //if we do not have a sacrifice yet, we cannot advance time if (!this.sacrificeFulfilled() || !this.itemUseFulfilled()) { + if(this.level.getGameTime() % 20 == 0) + this.level.updateNeighborsAt(this.getBlockPos(), this.getBlockState().getBlock()); + if (this.level.random.nextInt(16) == 0) { ((ServerLevel) this.level) .sendParticles(OccultismParticles.RITUAL_WAITING.get(), @@ -463,6 +481,8 @@ public void startRitual(@Nullable ServerPlayer player, ItemStack activationItem, this.setChanged(); this.markNetworkDirty(); + + this.level.updateNeighborsAt(this.getBlockPos(), this.getBlockState().getBlock()); } } @@ -497,6 +517,8 @@ public void stopRitual(boolean finished) { this.setChanged(); this.markNetworkDirty(); + + this.level.updateNeighborsAt(this.getBlockPos(), this.getBlockState().getBlock()); } } diff --git a/src/main/java/com/klikli_dev/occultism/datagen/OccultismBookProvider.java b/src/main/java/com/klikli_dev/occultism/datagen/OccultismBookProvider.java index 72dca61f7..5a678a50a 100644 --- a/src/main/java/com/klikli_dev/occultism/datagen/OccultismBookProvider.java +++ b/src/main/java/com/klikli_dev/occultism/datagen/OccultismBookProvider.java @@ -1298,6 +1298,20 @@ Now it is time to place the ingredients you see on the next page in the (regular Note that any rituals that summon tamed animals or familiars will summon them untamed instead. """.formatted(COLOR_PURPLE)); + this.context().page("redstone"); + var redstoneText = BookTextPageModel.create() + .withTitle(this.context().pageTitle()) + .withText(this.context().pageText()); + this.lang.add(this.context().pageTitle(), "Redstone"); + this.lang.add(this.context().pageText(), + """ + Depending on the ritual state the golden bowl will emit a different redstone level: + - **0** if no ritual is active + - **1** if the ritual is active, but waiting for a sacrifice + - **2** if the ritual is active, but waiting for an item to be used + - **4** if the ritual is active and running + """.formatted(COLOR_PURPLE)); + return BookEntryModel.create(this.modLoc(this.context().categoryId() + "/" + this.context().entryId()), this.context().entryName()) .withDescription(this.context().entryDescription()) @@ -1312,7 +1326,8 @@ Now it is time to place the ingredients you see on the next page in the (regular ritualRecipe, pentacleLinkHint, startRitualText, - automationText + automationText, + redstoneText ); }