Skip to content

Commit

Permalink
feat: add redstone signal to golden bowl
Browse files Browse the repository at this point in the history
Closes #1095
  • Loading branch information
klikli-dev committed Jun 9, 2024
1 parent 2c5243c commit c78400c
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/generated/resources/assets/occultism/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.klikli_dev.occultism.util.StorageUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.core.Direction;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
Expand Down Expand Up @@ -100,6 +101,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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.Recipe;
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;
Expand Down Expand Up @@ -311,6 +312,20 @@ public RitualRecipe 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() {
RitualRecipe recipe = this.getCurrentRitualRecipe();
if (!this.level.isClientSide && recipe != null) {
Expand All @@ -335,6 +350,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(),
Expand Down Expand Up @@ -468,6 +486,8 @@ public void startRitual(@Nullable ServerPlayer player, ItemStack activationItem,

this.setChanged();
this.markNetworkDirty();

this.level.updateNeighborsAt(this.getBlockPos(), this.getBlockState().getBlock());
}
}

Expand Down Expand Up @@ -502,6 +522,8 @@ public void stopRitual(boolean finished) {

this.setChanged();
this.markNetworkDirty();

this.level.updateNeighborsAt(this.getBlockPos(), this.getBlockState().getBlock());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1368,16 +1368,32 @@ Now it is time to place the ingredients you see on the next page in the (regular
""".formatted(COLOR_PURPLE));

this.context().page("automation");
var automationText = BookTextPageModel.create()
var automationText = BookTextPageModel.builder()
.withTitle(this.context().pageTitle())
.withText(this.context().pageText());
.withText(this.context().pageText())
.build();
this.lang.add(this.context().pageTitle(), "Automatic Rituals");
this.lang.add(this.context().pageText(),
"""
Instead of right-clicking the golden sacrificial bowl with the final ingredient, you can also use a Hopper or any type of pipe to insert the item into the bowl. The ritual will start automatically.\\
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.builder()
.withTitle(this.context().pageTitle())
.withText(this.context().pageText())
.build();
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())
Expand All @@ -1392,7 +1408,8 @@ Now it is time to place the ingredients you see on the next page in the (regular
ritualRecipe,
pentacleLinkHint,
startRitualText,
automationText
automationText,
redstoneText
);
}

Expand Down

0 comments on commit c78400c

Please sign in to comment.