Skip to content

Commit da095be

Browse files
committed
feat: add redstone signal to golden bowl
Closes #1095
1 parent 90e69d6 commit da095be

File tree

5 files changed

+62
-1
lines changed

5 files changed

+62
-1
lines changed

src/generated/resources/assets/occultism/lang/en_us.json

+2
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@
350350
"book.occultism.dictionary_of_spirits.getting_started.first_ritual.name": "First Ritual",
351351
"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",
352352
"book.occultism.dictionary_of_spirits.getting_started.first_ritual.pentacle_link_hint.title": "A Note about Ritual Recipes",
353+
"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",
354+
"book.occultism.dictionary_of_spirits.getting_started.first_ritual.redstone.title": "Redstone",
353355
"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",
354356
"book.occultism.dictionary_of_spirits.getting_started.first_ritual.ritual_text.title": "Placing Ingredients",
355357
"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",

src/generated/resources/data/occultism/modonomicon/books/dictionary_of_spirits/entries/getting_started/first_ritual.json

+11
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,17 @@
109109
"text": "book.occultism.dictionary_of_spirits.getting_started.first_ritual.automation.text",
110110
"title": "book.occultism.dictionary_of_spirits.getting_started.first_ritual.automation.title",
111111
"use_markdown_in_title": false
112+
},
113+
{
114+
"type": "modonomicon:text",
115+
"anchor": "",
116+
"condition": {
117+
"type": "modonomicon:none"
118+
},
119+
"show_title_separator": true,
120+
"text": "book.occultism.dictionary_of_spirits.getting_started.first_ritual.redstone.text",
121+
"title": "book.occultism.dictionary_of_spirits.getting_started.first_ritual.redstone.title",
122+
"use_markdown_in_title": false
112123
}
113124
],
114125
"parents": [

src/main/java/com/klikli_dev/occultism/common/block/GoldenSacrificialBowlBlock.java

+11
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.klikli_dev.occultism.registry.OccultismBlockEntities;
2727
import com.klikli_dev.occultism.util.StorageUtil;
2828
import net.minecraft.core.BlockPos;
29+
import net.minecraft.core.Direction;
2930
import net.minecraft.world.InteractionHand;
3031
import net.minecraft.world.InteractionResult;
3132
import net.minecraft.world.ItemInteractionResult;
@@ -93,6 +94,16 @@ public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos,
9394
return SHAPE;
9495
}
9596

97+
@SuppressWarnings("deprecation")
98+
@Override
99+
public int getSignal(BlockState pBlockState, BlockGetter pBlockAccess, BlockPos pPos, Direction pSide) {
100+
BlockEntity blockEntity = pBlockAccess.getBlockEntity(pPos);
101+
if (blockEntity instanceof GoldenSacrificialBowlBlockEntity bowl) {
102+
return bowl.getSignal(pBlockState, pBlockAccess, pPos, pSide);
103+
}
104+
return 0;
105+
}
106+
96107
@Nullable
97108
@Override
98109
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {

src/main/java/com/klikli_dev/occultism/common/blockentity/GoldenSacrificialBowlBlockEntity.java

+22
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import net.minecraft.world.item.ItemStack;
5656
import net.minecraft.world.item.crafting.Ingredient;
5757
import net.minecraft.world.item.crafting.RecipeHolder;
58+
import net.minecraft.world.level.BlockGetter;
5859
import net.minecraft.world.level.Level;
5960
import net.minecraft.world.level.block.Block;
6061
import net.minecraft.world.level.block.Rotation;
@@ -307,6 +308,20 @@ public RecipeHolder<RitualRecipe> getCurrentRitualRecipe() {
307308
return this.currentRitualRecipe;
308309
}
309310

311+
public int getSignal(BlockState pBlockState, BlockGetter pBlockAccess, BlockPos pPos, Direction pSide) {
312+
if(this.getCurrentRitualRecipe() == null)
313+
return 0;
314+
315+
if(!this.sacrificeFulfilled())
316+
return 1;
317+
318+
if(!this.itemUseFulfilled())
319+
return 2;
320+
321+
322+
return 8;
323+
}
324+
310325
public void tick() {
311326
RecipeHolder<RitualRecipe> recipe = this.getCurrentRitualRecipe();
312327
if (!this.level.isClientSide && recipe != null) {
@@ -331,6 +346,9 @@ public void tick() {
331346

332347
//if we do not have a sacrifice yet, we cannot advance time
333348
if (!this.sacrificeFulfilled() || !this.itemUseFulfilled()) {
349+
if(this.level.getGameTime() % 20 == 0)
350+
this.level.updateNeighborsAt(this.getBlockPos(), this.getBlockState().getBlock());
351+
334352
if (this.level.random.nextInt(16) == 0) {
335353
((ServerLevel) this.level)
336354
.sendParticles(OccultismParticles.RITUAL_WAITING.get(),
@@ -464,6 +482,8 @@ public void startRitual(@Nullable ServerPlayer player, ItemStack activationItem,
464482

465483
this.setChanged();
466484
this.markNetworkDirty();
485+
486+
this.level.updateNeighborsAt(this.getBlockPos(), this.getBlockState().getBlock());
467487
}
468488
}
469489

@@ -498,6 +518,8 @@ public void stopRitual(boolean finished) {
498518

499519
this.setChanged();
500520
this.markNetworkDirty();
521+
522+
this.level.updateNeighborsAt(this.getBlockPos(), this.getBlockState().getBlock());
501523
}
502524
}
503525

src/main/java/com/klikli_dev/occultism/datagen/OccultismBookProvider.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -1301,6 +1301,20 @@ Now it is time to place the ingredients you see on the next page in the (regular
13011301
Note that any rituals that summon tamed animals or familiars will summon them untamed instead.
13021302
""".formatted(COLOR_PURPLE));
13031303

1304+
this.context().page("redstone");
1305+
var redstoneText = BookTextPageModel.create()
1306+
.withTitle(this.context().pageTitle())
1307+
.withText(this.context().pageText());
1308+
this.lang.add(this.context().pageTitle(), "Redstone");
1309+
this.lang.add(this.context().pageText(),
1310+
"""
1311+
Depending on the ritual state the golden bowl will emit a different redstone level:
1312+
- **0** if no ritual is active
1313+
- **1** if the ritual is active, but waiting for a sacrifice
1314+
- **2** if the ritual is active, but waiting for an item to be used
1315+
- **4** if the ritual is active and running
1316+
""".formatted(COLOR_PURPLE));
1317+
13041318

13051319
return BookEntryModel.create(this.modLoc(this.context().categoryId() + "/" + this.context().entryId()), this.context().entryName())
13061320
.withDescription(this.context().entryDescription())
@@ -1315,7 +1329,8 @@ Now it is time to place the ingredients you see on the next page in the (regular
13151329
ritualRecipe,
13161330
pentacleLinkHint,
13171331
startRitualText,
1318-
automationText
1332+
automationText,
1333+
redstoneText
13191334
);
13201335
}
13211336

0 commit comments

Comments
 (0)