Skip to content

Commit

Permalink
feat: add theurgy integration
Browse files Browse the repository at this point in the history
feat: add theurgy integration class with guards against class loads

chore set higher forge minimum version to exclude < 1.19.2

chore: update theurgy version

feat: add theurgy visualizer to divination rod, and add non-charge usage

chore: disable use of highlight all blocks if theurgy is present

chore: update to latest modonomicon

feat: add modonomicon entry for theurgy rod

chore: update to latest modonomicon to fix mod loaded condition

fix: use theurgy divination rod item for its entry
  • Loading branch information
klikli-dev committed Jan 1, 2023
1 parent 540dc8e commit 73c18c5
Show file tree
Hide file tree
Showing 14 changed files with 306 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ jobs:
game_versions: Forge,Minecraft 1.19:${{ steps.get_mc_version.outputs.result }}
display_name: occultism-${{ steps.get_mc_version.outputs.result }}-${{ steps.get_version.outputs.result }}.jar
release_type: ${{ steps.get_release_type.outputs.result }}
relations: modonomicon:requiredDependency,curios:requiredDependency,geckolib:requiredDependency,smartbrainlib:requiredDependency,jei:optionalDependency
relations: modonomicon:requiredDependency,curios:requiredDependency,geckolib:requiredDependency,smartbrainlib:requiredDependency,theurgy:requiredDependency,jei:optionalDependency
7 changes: 5 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,11 @@ dependencies {
implementation fg.deobf("curse.maven:smartbrainlib-661293:${smartbrainlib_file_id}-sources-${smartbrainlib_src_file_id}")

//modonomicon
compileOnly fg.deobf("com.klikli_dev:modonomicon:${modonomicon_mc_version}-${modonomicon_version}") //we build against full jar because we NEED IT ALL
runtimeOnly fg.deobf("com.klikli_dev:modonomicon:${modonomicon_mc_version}-${modonomicon_version}")
implementation fg.deobf("com.klikli_dev:modonomicon:${modonomicon_mc_version}-${modonomicon_version}") //we build against full jar because we NEED IT ALL

//theurgy
compileOnly fg.deobf("com.klikli_dev:theurgy:${theurgy_mc_version}-${theurgy_version}")
runtimeOnly fg.deobf("com.klikli_dev:theurgy:${theurgy_mc_version}-${theurgy_version}")

//runtime only helper mods for dev env, placed in ./runtime-mods, example: Hwyla-forge-1.10.11-B78_1.16.2.jar
//runtimeOnly fg.deobf("ignoredvalue:Hwyla:forge-1.10.11-B78_1.16.2")
Expand Down
5 changes: 4 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ smartbrainlib_file_id=4277541
smartbrainlib_src_file_id=4277542

modonomicon_mc_version=1.19.3
modonomicon_version=1.21.0
modonomicon_version=1.23.2

theurgy_mc_version=1.19.3
theurgy_version=1.1.0
5 changes: 5 additions & 0 deletions src/generated/resources/assets/occultism/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,11 @@
"book.occultism.dictionary_of_spirits.getting_started.summoning_rituals.more.text": "To find more about Summoning Rituals, see the [Summoning Rituals](category://summoning_rituals) Category.\n",
"book.occultism.dictionary_of_spirits.getting_started.summoning_rituals.more.title": "More Information",
"book.occultism.dictionary_of_spirits.getting_started.summoning_rituals.name": "Summoning Rituals",
"book.occultism.dictionary_of_spirits.getting_started.theurgy_divination_rod.description": "Finding other ores and resources.",
"book.occultism.dictionary_of_spirits.getting_started.theurgy_divination_rod.intro.text": "While the [](item://occultism:divination_rod) is a great tool for finding [#](ad03fc)Otherworld Materials[#](), it would be useful to have a way to find *all other* ores and resources as well.\n\\\n\\\nThis is where the Theurgy Divination Rod comes in.\n",
"book.occultism.dictionary_of_spirits.getting_started.theurgy_divination_rod.more_info.text": "To find out more about the Theurgy Divination Rod, check out *\"The Hermetica\"*, the Guidebook for Theurgy.\n[This Entry](entry://theurgy:the_hermetica/getting_started/divination_rod) has more information about the Theurgy Divination Rod.\n",
"book.occultism.dictionary_of_spirits.getting_started.theurgy_divination_rod.more_info.title": "More Information",
"book.occultism.dictionary_of_spirits.getting_started.theurgy_divination_rod.name": "More Divination Rods",
"book.occultism.dictionary_of_spirits.getting_started.third_eye.about.text": "The ability to see beyond the physical world is referred to as [#](ad03fc)Third Eye[#]().\nHumans do not possess such an ability to see [#](ad03fc)beyond the veil[#](),\nhowever with certain substances and contraptions the knowledgeable summoner can work around this limitation.\n",
"book.occultism.dictionary_of_spirits.getting_started.third_eye.about.title": "Third Eye",
"book.occultism.dictionary_of_spirits.getting_started.third_eye.description": "Do you see now?",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"background_u_index": 0,
"background_v_index": 0,
"category": "occultism:getting_started",
"condition": {
"type": "modonomicon:and",
"children": [
{
"type": "modonomicon:entry_read",
"entry_id": "occultism:getting_started/divination_rod"
},
{
"type": "modonomicon:mod_loaded",
"mod_id": "theurgy"
}
]
},
"description": "book.occultism.dictionary_of_spirits.getting_started.theurgy_divination_rod.description",
"hide_while_locked": true,
"icon": "theurgy:divination_rod_t1",
"name": "book.occultism.dictionary_of_spirits.getting_started.theurgy_divination_rod.name",
"pages": [
{
"type": "modonomicon:spotlight",
"anchor": "",
"item": {
"item": "theurgy:divination_rod_t1"
},
"text": "book.occultism.dictionary_of_spirits.getting_started.theurgy_divination_rod.intro.text",
"title": ""
},
{
"type": "modonomicon:crafting_recipe",
"anchor": "",
"recipe_id_1": "theurgy:crafting/shaped/divination_rod_t1",
"text": "",
"title1": "",
"title2": ""
},
{
"type": "modonomicon:text",
"anchor": "",
"show_title_separator": true,
"text": "book.occultism.dictionary_of_spirits.getting_started.theurgy_divination_rod.more_info.text",
"title": "book.occultism.dictionary_of_spirits.getting_started.theurgy_divination_rod.more_info.title",
"use_markdown_in_title": false
},
{
"type": "modonomicon:crafting_recipe",
"anchor": "",
"recipe_id_1": "theurgy:crafting/shapeless/the_hermetica",
"text": "",
"title1": "",
"title2": ""
}
],
"parents": [
{
"draw_arrow": true,
"entry": "occultism:getting_started/divination_rod",
"line_enabled": true,
"line_reversed": false
}
],
"x": -7,
"y": -4
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.github.klikli_dev.occultism;

public class OccultismConstants {
public static class Nbt {
protected static final String PREFIX = Occultism.MODID + ":";

public static class Divination {
public static final String DISTANCE = PREFIX + "divination.distance";
public static final String POS = PREFIX + "divination.pos";
public static final String LINKED_BLOCK_ID = PREFIX + "divination.linked_block_id";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
package com.github.klikli_dev.occultism.client.divination;

import com.github.klikli_dev.occultism.Occultism;
import com.github.klikli_dev.occultism.integration.theurgy.TheurgyIntegration;
import com.github.klikli_dev.occultism.util.Math3DUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Player;
Expand All @@ -49,7 +50,8 @@ public void beginScan(Player player, Block target) {

this.scanner = new Scanner(target);
this.scanner.initialize(player, player.position(), Occultism.CLIENT_CONFIG.misc.divinationRodScanRange.get(), SCAN_DURATION_TICKS);
this.scanner.setHighlightAllResults(Occultism.CLIENT_CONFIG.misc.divinationRodHighlightAllResults.get());
if(!TheurgyIntegration.isLoaded()) //only use if theurgy not used, because if it is, we use a particle effect that only goes to the closest target
this.scanner.setHighlightAllResults(Occultism.CLIENT_CONFIG.misc.divinationRodHighlightAllResults.get());
}

public void updateScan(Player player, boolean forceFinish) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

package com.github.klikli_dev.occultism.client.itemproperties;

import com.github.klikli_dev.occultism.OccultismConstants;
import com.github.klikli_dev.occultism.common.item.tool.DivinationRodItem;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.item.ItemPropertyFunction;
Expand All @@ -38,8 +39,9 @@ public class DivinationRodItemPropertyGetter implements ItemPropertyFunction {

@Override
public float call(ItemStack itemStack, @Nullable ClientLevel clientLevel, @Nullable LivingEntity livingEntity, int i) {
if (!itemStack.getOrCreateTag().contains("distance") || itemStack.getTag().getFloat("distance") < 0)
if (!itemStack.getOrCreateTag().contains(OccultismConstants.Nbt.Divination.DISTANCE) ||
itemStack.getTag().getFloat(OccultismConstants.Nbt.Divination.DISTANCE) < 0)
return DivinationRodItem.NOT_FOUND;
return itemStack.getTag().getFloat("distance");
return itemStack.getTag().getFloat(OccultismConstants.Nbt.Divination.DISTANCE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
package com.github.klikli_dev.occultism.common.item.tool;

import com.github.klikli_dev.occultism.Occultism;
import com.github.klikli_dev.occultism.OccultismConstants;
import com.github.klikli_dev.occultism.client.divination.ScanManager;
import com.github.klikli_dev.occultism.common.block.otherworld.IOtherworldBlock;
import com.github.klikli_dev.occultism.integration.theurgy.TheurgyIntegration;
import com.github.klikli_dev.occultism.network.MessageSetDivinationResult;
import com.github.klikli_dev.occultism.network.OccultismPackets;
import com.github.klikli_dev.occultism.registry.OccultismBlocks;
Expand Down Expand Up @@ -91,7 +93,7 @@ public InteractionResult useOn(UseOnContext context) {
String translationKey =
block instanceof IOtherworldBlock ? ((IOtherworldBlock) block).getUncoveredBlock()
.getDescriptionId() : block.getDescriptionId();
stack.getOrCreateTag().putString("linkedBlockId", ForgeRegistries.BLOCKS.getKey(block).toString());
stack.getOrCreateTag().putString(OccultismConstants.Nbt.Divination.LINKED_BLOCK_ID, ForgeRegistries.BLOCKS.getKey(block).toString());
player.sendSystemMessage(
Component.translatable(this.getDescriptionId() + ".message.linked_block",
Component.translatable(translationKey)));
Expand All @@ -117,14 +119,14 @@ public InteractionResultHolder<ItemStack> use(Level level, Player player, Intera
ItemStack stack = player.getItemInHand(hand);

if (!player.isShiftKeyDown()) {
if (stack.getOrCreateTag().contains("linkedBlockId")) {
stack.getTag().putFloat("distance", SEARCHING);
if (stack.getOrCreateTag().contains(OccultismConstants.Nbt.Divination.LINKED_BLOCK_ID)) {
stack.getTag().putFloat(OccultismConstants.Nbt.Divination.DISTANCE, SEARCHING);
player.startUsingItem(hand);
level.playSound(player, player.blockPosition(), OccultismSounds.TUNING_FORK.get(), SoundSource.PLAYERS,
1, 1);

if (level.isClientSide) {
ResourceLocation id = new ResourceLocation(stack.getTag().getString("linkedBlockId"));
ResourceLocation id = new ResourceLocation(stack.getTag().getString(OccultismConstants.Nbt.Divination.LINKED_BLOCK_ID));
ScanManager.instance.beginScan(player, ForgeRegistries.BLOCKS.getValue(id));
}
} else if (!level.isClientSide) {
Expand All @@ -137,21 +139,28 @@ public InteractionResultHolder<ItemStack> use(Level level, Player player, Intera

@Override
public ItemStack finishUsingItem(ItemStack stack, Level level, LivingEntity entityLiving) {
if (!(entityLiving instanceof Player))
if (!(entityLiving instanceof Player player))
return stack;

Player player = (Player) entityLiving;
player.getCooldowns().addCooldown(this, 40);
stack.getOrCreateTag().putFloat("distance", NOT_FOUND);
stack.getOrCreateTag().putFloat(OccultismConstants.Nbt.Divination.DISTANCE, NOT_FOUND);
if (level.isClientSide) {
BlockPos result = ScanManager.instance.finishScan(player);
float distance = this.getDistance(player.position(), result);
stack.getTag().putFloat("distance", distance);
OccultismPackets.sendToServer(new MessageSetDivinationResult(distance));
stack.getTag().putFloat(OccultismConstants.Nbt.Divination.DISTANCE, distance);

if (result != null) { // && player.isCreative()
//Show debug visualization
Occultism.SELECTED_BLOCK_RENDERER.selectBlock(result, System.currentTimeMillis() + 10000);
OccultismPackets.sendToServer(new MessageSetDivinationResult(result, distance));

if (result != null) {
stack.getTag().putLong(OccultismConstants.Nbt.Divination.POS, result.asLong());

if (TheurgyIntegration.isLoaded()) {
//show nice particle if possible
TheurgyIntegration.spawnDivinationResultParticle(result, level, entityLiving);
} else {
//otherwise fall back to our old renderer
Occultism.SELECTED_BLOCK_RENDERER.selectBlock(result, System.currentTimeMillis() + 10000);
}
}
}
return stack;
Expand All @@ -165,20 +174,42 @@ public int getUseDuration(ItemStack stack) {

@Override
public void releaseUsing(ItemStack stack, Level level, LivingEntity pLivingEntity, int pTimeCharged) {
//player interrupted, so we can safely set not found on server
stack.getOrCreateTag().putFloat("distance", NOT_FOUND);
if (!stack.getOrCreateTag().contains(OccultismConstants.Nbt.Divination.POS))
//player interrupted, so we can safely set not found on server, if we don't have a previous result
stack.getOrCreateTag().putFloat(OccultismConstants.Nbt.Divination.DISTANCE, NOT_FOUND);
else {
//otherwise, restore distance from result
//nice bonus: will update crystal status on every "display only" use.
BlockPos result = BlockPos.of(stack.getTag().getLong(OccultismConstants.Nbt.Divination.POS));
float distance = this.getDistance(pLivingEntity.position(), result);
stack.getTag().putFloat(OccultismConstants.Nbt.Divination.DISTANCE, distance);
}


if (level.isClientSide) {
ScanManager.instance.cancelScan();

//re-use old result
if (stack.getTag().contains(OccultismConstants.Nbt.Divination.POS)) {
BlockPos result = BlockPos.of(stack.getTag().getLong(OccultismConstants.Nbt.Divination.POS));
if (TheurgyIntegration.isLoaded()) {
//show nice particle if possible
TheurgyIntegration.spawnDivinationResultParticle(result, level, pLivingEntity);
} else {
//otherwise fall back to our old renderer
Occultism.SELECTED_BLOCK_RENDERER.selectBlock(result, System.currentTimeMillis() + 10000);
}
}
}

super.releaseUsing(stack, level, pLivingEntity, pTimeCharged);
}

@Override
public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List<Component> tooltip,
TooltipFlag flagIn) {
if (stack.getOrCreateTag().contains("linkedBlockId")) {
ResourceLocation id = new ResourceLocation(stack.getTag().getString("linkedBlockId"));
if (stack.getOrCreateTag().contains(OccultismConstants.Nbt.Divination.LINKED_BLOCK_ID)) {
ResourceLocation id = new ResourceLocation(stack.getTag().getString(OccultismConstants.Nbt.Divination.LINKED_BLOCK_ID));

Block block = ForgeRegistries.BLOCKS.getValue(id);
String translationKey = block instanceof IOtherworldBlock ? ((IOtherworldBlock) block).getUncoveredBlock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ public MiscSettings(ForgeConfigSpec.Builder builder) {

this.syncJeiSearch = builder.comment("Sync JEI search in storage actuator.")
.define("syncJeiSearch", false);
this.divinationRodHighlightAllResults = builder.comment("If true, divination rod will render all matching blocks with an outline. Disable if it causes lag.")
this.divinationRodHighlightAllResults = builder.comment(
"If true, divination rod will render all matching blocks with an outline. Disable if it causes lag.",
"This setting will be unused, if Theurgy is installed alongside, as Occultism will use Theurgy's divination rod result rendering instead.")
.define("divinationRodHighlightAllResults", false);
this.divinationRodScanRange = builder.comment("The scan range in blocks for the divination rod. Too high might cause lags")
.defineInRange("divinationRodScanRange", 129, 1, Integer.MAX_VALUE);
Expand Down
Loading

0 comments on commit 73c18c5

Please sign in to comment.