Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
object-Object authored Feb 3, 2025
2 parents a334b53 + 3a3badd commit c38b8e1
Show file tree
Hide file tree
Showing 14 changed files with 92 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ permissions:

jobs:
hexdoc:
uses: hexdoc-dev/hexdoc/.github/workflows/hexdoc.yml@main
uses: hexdoc-dev/actions/.github/workflows/hexdoc.yml@v1
permissions:
contents: write
pages: read
Expand All @@ -51,7 +51,7 @@ jobs:
id-token: write
steps:
- name: Download package artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: hexdoc-build
path: dist
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
hexdoc:
# don't bother running the docs build when pushing to main - nothing necessary to cache here
if: github.event_name != 'push'
uses: hexdoc-dev/hexdoc/.github/workflows/hexdoc.yml@main
uses: hexdoc-dev/actions/.github/workflows/hexdoc.yml@v1
permissions:
contents: write
pages: read
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import at.petrak.hexcasting.api.mod.HexConfig;
import at.petrak.hexcasting.api.pigment.FrozenPigment;
import at.petrak.hexcasting.api.utils.HexUtils;
import at.petrak.hexcasting.common.lib.HexAttributes;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -247,6 +248,9 @@ public boolean isEnlightened() {
* positive.
*/
public long extractMedia(long cost, boolean simulate) {
if (this.getCastingEntity() != null){
cost = (long) (cost * this.getCastingEntity().getAttributeValue(HexAttributes.MEDIA_CONSUMPTION_MODIFIER));
}
for (var extractMediaComponent : preMediaExtract)
cost = extractMediaComponent.onExtractMedia(cost, simulate);
cost = extractMediaEnvironment(cost, simulate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import at.petrak.hexcasting.api.casting.mishaps.MishapDisallowedSpell;
import at.petrak.hexcasting.api.mod.HexConfig;
import at.petrak.hexcasting.api.pigment.FrozenPigment;
import at.petrak.hexcasting.common.lib.HexAttributes;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -29,8 +30,6 @@
import java.util.List;
import java.util.function.Predicate;

import static at.petrak.hexcasting.api.casting.eval.env.PlayerBasedCastEnv.SENTINEL_RADIUS;

public class CircleCastEnv extends CastingEnvironment {
protected final CircleExecutionState execState;

Expand Down Expand Up @@ -133,6 +132,7 @@ public long extractMediaEnvironment(long cost, boolean simulate) {
public boolean isVecInRangeEnvironment(Vec3 vec) {
var caster = this.execState.getCaster(this.world);
if (caster != null) {
double sentinelRadius = caster.getAttributeValue(HexAttributes.SENTINEL_RADIUS);
if (vec.distanceToSqr(caster.position()) <= caster.getBbHeight() * caster.getBbHeight()) {
return true;
}
Expand All @@ -141,7 +141,7 @@ public boolean isVecInRangeEnvironment(Vec3 vec) {
if (sentinel != null
&& sentinel.extendsRange()
&& caster.level().dimension() == sentinel.dimension()
&& vec.distanceToSqr(sentinel.position()) <= SENTINEL_RADIUS * SENTINEL_RADIUS + 0.00000000001
&& vec.distanceToSqr(sentinel.position()) <= sentinelRadius * sentinelRadius + 0.00000000001
) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import at.petrak.hexcasting.api.pigment.FrozenPigment;
import at.petrak.hexcasting.api.utils.HexUtils;
import at.petrak.hexcasting.api.utils.MediaHelper;
import at.petrak.hexcasting.common.lib.HexAttributes;
import at.petrak.hexcasting.common.lib.HexDamageTypes;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
import net.minecraft.core.BlockPos;
Expand All @@ -35,8 +36,10 @@
import static at.petrak.hexcasting.api.HexAPI.modLoc;

public abstract class PlayerBasedCastEnv extends CastingEnvironment {
public static final double AMBIT_RADIUS = 32.0;
public static final double SENTINEL_RADIUS = 16.0;
public static final double DEFAULT_AMBIT_RADIUS = 32.0;
private double ambitRadius;
public static final double DEFAULT_SENTINEL_RADIUS = 16.0;
private double sentinelRadius;

protected final ServerPlayer caster;
protected final InteractionHand castingHand;
Expand All @@ -45,6 +48,8 @@ protected PlayerBasedCastEnv(ServerPlayer caster, InteractionHand castingHand) {
super(caster.serverLevel());
this.caster = caster;
this.castingHand = castingHand;
this.ambitRadius = caster.getAttributeValue(HexAttributes.AMBIT_RADIUS);
this.sentinelRadius = caster.getAttributeValue(HexAttributes.SENTINEL_RADIUS);
}

@Override
Expand All @@ -66,6 +71,16 @@ public void postExecution(CastResult result) {
this.sendMishapMsgToPlayer(doMishap);
}
}
if (this.caster != null){
double ambitAttribute = this.caster.getAttributeValue(HexAttributes.AMBIT_RADIUS);
if (this.ambitRadius != ambitAttribute){
this.ambitRadius = ambitAttribute;
}
double sentinelAttribute = this.caster.getAttributeValue(HexAttributes.SENTINEL_RADIUS);
if (this.sentinelRadius != sentinelAttribute){
this.sentinelRadius = sentinelAttribute;
}
}
}

@Override
Expand All @@ -78,6 +93,14 @@ protected List<HeldItemInfo> getPrimaryStacks() {
return getPrimaryStacksForPlayer(this.castingHand, this.caster);
}

public double getAmbitRadius() {
return this.ambitRadius;
}

public double getSentinelRadius(){
return this.sentinelRadius;
}

@Override
public boolean replaceItem(Predicate<ItemStack> stackOk, ItemStack replaceWith, @Nullable InteractionHand hand) {
return replaceItemForPlayer(stackOk, replaceWith, hand, this.caster);
Expand All @@ -90,12 +113,12 @@ public boolean isVecInRangeEnvironment(Vec3 vec) {
&& sentinel.extendsRange()
&& this.caster.level().dimension() == sentinel.dimension()
// adding 0.00000000001 to avoid machine precision errors at specific angles
&& vec.distanceToSqr(sentinel.position()) <= SENTINEL_RADIUS * SENTINEL_RADIUS + 0.00000000001
&& vec.distanceToSqr(sentinel.position()) <= sentinelRadius * sentinelRadius + 0.00000000001
) {
return true;
}

return vec.distanceToSqr(this.caster.position()) <= AMBIT_RADIUS * AMBIT_RADIUS + 0.00000000001;
return vec.distanceToSqr(this.caster.position()) <= ambitRadius * ambitRadius + 0.00000000001;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class GuiSpellcasting constructor(
val player = minecraft.player
if (player != null) {
val heldItem = player.getItemInHand(handOpenedWith)
if (heldItem.isEmpty || !heldItem.`is`(HexTags.Items.STAVES))
if (heldItem.isEmpty || !heldItem.`is`(HexTags.Items.STAVES) || player.getAttributeValue(HexAttributes.FEEBLE_MIND) > 0)
closeForReal()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private static void tryRenderScryingLensOverlay(GuiGraphics graphics, float part
return;
}

if (player.getAttributeValue(HexAttributes.SCRY_SIGHT) <= 0.0)
if (player.getAttributeValue(HexAttributes.SCRY_SIGHT) <= 0.0 || player.getAttributeValue(HexAttributes.FEEBLE_MIND) > 0)
return;

var hitRes = mc.hitResult;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package at.petrak.hexcasting.common.items;

import at.petrak.hexcasting.api.HexAPI;
import at.petrak.hexcasting.common.lib.HexAttributes;
import at.petrak.hexcasting.common.lib.HexSounds;
import at.petrak.hexcasting.common.msgs.MsgClearSpiralPatternsS2C;
import at.petrak.hexcasting.common.msgs.MsgOpenSpellGuiS2C;
Expand All @@ -25,6 +26,9 @@ public ItemStaff(Properties pProperties) {

@Override
public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand) {
if (player.getAttributeValue(HexAttributes.FEEBLE_MIND) > 0){
return InteractionResultHolder.fail(player.getItemInHand(hand));
}
if (player.isShiftKeyDown()) {
if (world.isClientSide()) {
player.playSound(HexSounds.STAFF_RESET, 1f, 1f);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package at.petrak.hexcasting.common.lib;

import at.petrak.hexcasting.api.HexAPI;
import at.petrak.hexcasting.api.casting.eval.env.PlayerBasedCastEnv;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.ai.attributes.RangedAttribute;
Expand All @@ -24,14 +25,32 @@ public static void register(BiConsumer<Attribute, ResourceLocation> r) {

private static final Map<ResourceLocation, Attribute> ATTRIBUTES = new LinkedHashMap<>();

private static final String MOD_ID = HexAPI.MOD_ID;

public static final Attribute GRID_ZOOM = make("grid_zoom", new RangedAttribute(
HexAPI.MOD_ID + ".attributes.grid_zoom", 1.0, 0.5, 4.0)).setSyncable(true);
MOD_ID + ".attributes.grid_zoom", 1.0, 0.5, 4.0)).setSyncable(true);

/**
* Whether you have the lens overlay when looking at something. 0 = no, > 0 = yes.
*/
public static final Attribute SCRY_SIGHT = make("scry_sight", new RangedAttribute(
HexAPI.MOD_ID + ".attributes.scry_sight", 0.0, 0.0, 1.0)).setSyncable(true);
MOD_ID + ".attributes.scry_sight", 0.0, 0.0, 1.0)).setSyncable(true);

//whether the player is allowed to use staffcasting and scrying lenses
public static final Attribute FEEBLE_MIND = make("feeble_mind", new RangedAttribute(
MOD_ID + ".attributes.feeble_mind", 0.0, 0.0, 1.0).setSyncable(true));

//a multiplier to adjust media consumption across the board
public static final Attribute MEDIA_CONSUMPTION_MODIFIER = make("media_consumption", new RangedAttribute(
MOD_ID + ".attributes.media_consumption", 1.0, 0.0, Double.MAX_VALUE).setSyncable(true));

public static final Attribute AMBIT_RADIUS = make("ambit_radius", new RangedAttribute(
MOD_ID + ".attributes.ambit_radius", PlayerBasedCastEnv.DEFAULT_AMBIT_RADIUS, 0.0, Double.MAX_VALUE).setSyncable(true));

public static final Attribute SENTINEL_RADIUS = make("sentinel_radius", new RangedAttribute(
MOD_ID + ".attributes.sentinel_radius", PlayerBasedCastEnv.DEFAULT_SENTINEL_RADIUS, 0.0, Double.MAX_VALUE).setSyncable(true));



private static <T extends Attribute> T make(String id, T attr) {
var old = ATTRIBUTES.put(modLoc(id), attr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,12 @@

attributes: {
grid_zoom: "Casting Grid Size",
media_consumption: "Media Consumption",
ambit_radius: "Player Ambit Radius",
sentinel_radius: "Sentinel Ambit Radius",
// TODO: the +1 is kind of janky
scry_sight: "Scrying Sight",
feeble_mind: "Feeble Mind"
},

// Action localizations
Expand Down
18 changes: 10 additions & 8 deletions Fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ plugins {
pkSubproj {
platform "fabric"
curseforgeJar remapJar.archiveFile
curseforgeDependencies[
"paucal", "patchouli", "fabric-language-kotlin", "inline", "cloth-config",
"cardinal-components-api", "fabric-api"
]
curseforgeDependencies([
"paucal:0.6.0", "patchouli:1.20.1-80", "fabric-language-kotlin:1.9.4+kotlin.1.8.21",
"inline:1.20.1-1.0.1", "cloth-config:11.1.0",
"cardinal-components-api:5.2.1", "fabric-api:0.84"
])
modrinthJar remapJar.archiveFile
modrinthDependencies[
"paucal", "patchouli", "fabric-language-kotlin", "inline", "cloth-config",
"cardinal-components-api", "fabric-api"
]
modrinthDependencies([
"paucal:0.6.0", "patchouli:1.20.1-80", "fabric-language-kotlin:1.9.4+kotlin.1.8.21",
"inline:1.20.1-1.0.1", "cloth-config:11.1.0",
"cardinal-components-api:5.2.1", "fabric-api:0.84"
])
}

loom {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,9 @@ protected FabricPlayerMixin(EntityType<? extends LivingEntity> entityType, Level
var out = cir.getReturnValue();
out.add(HexAttributes.GRID_ZOOM);
out.add(HexAttributes.SCRY_SIGHT);
out.add(HexAttributes.FEEBLE_MIND);
out.add(HexAttributes.MEDIA_CONSUMPTION_MODIFIER);
out.add(HexAttributes.AMBIT_RADIUS);
out.add(HexAttributes.SENTINEL_RADIUS);
}
}
12 changes: 6 additions & 6 deletions Forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ apply plugin: 'org.spongepowered.mixin'
pkSubproj {
platform "forge"
curseforgeJar jar.archiveFile
curseforgeDependencies[
"paucal", "patchouli", "caelus", "inline"
]
curseforgeDependencies([
"paucal:0.6.0", "patchouli:1.20.1-80", "caelus:3.1.0+1.20", "inline:1.20.1-1.0.1"
])
modrinthJar jar.archiveFile
modrinthDependencies[
"paucal", "patchouli", "caelus", "inline"
]
modrinthDependencies([
"paucal:0.6.0", "patchouli:1.20.1-80", "caelus:3.1.0+1.20", "inline:1.20.1-1.0.1"
])
}

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ private static void initListeners() {
modBus.addListener((EntityAttributeModificationEvent e) -> {
e.add(EntityType.PLAYER, HexAttributes.GRID_ZOOM);
e.add(EntityType.PLAYER, HexAttributes.SCRY_SIGHT);
e.add(EntityType.PLAYER, HexAttributes.FEEBLE_MIND);
e.add(EntityType.PLAYER, HexAttributes.MEDIA_CONSUMPTION_MODIFIER);
e.add(EntityType.PLAYER, HexAttributes.AMBIT_RADIUS);
e.add(EntityType.PLAYER, HexAttributes.SENTINEL_RADIUS);
});

if (ModList.get().isLoaded(HexInterop.Forge.CURIOS_API_ID)) {
Expand Down

0 comments on commit c38b8e1

Please sign in to comment.