Skip to content

Commit a8a47a6

Browse files
beholderfaceSamsTheNerd
authored andcommitted
some attributes
attributes for being allowed to staffcast, media consumption, player ambit radius, and sentinel ambit radius code largely based on justs_js' Hexxy Attributes addon, PR made with his permission
1 parent 84c4889 commit a8a47a6

File tree

7 files changed

+39
-4
lines changed

7 files changed

+39
-4
lines changed

Common/src/main/java/at/petrak/hexcasting/client/gui/GuiSpellcasting.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class GuiSpellcasting constructor(
122122
val player = minecraft.player
123123
if (player != null) {
124124
val heldItem = player.getItemInHand(handOpenedWith)
125-
if (heldItem.isEmpty || !heldItem.`is`(HexTags.Items.STAVES))
125+
if (heldItem.isEmpty || !heldItem.`is`(HexTags.Items.STAVES) || player.getAttributeValue(HexAttributes.FEEBLE_MIND) > 0)
126126
closeForReal()
127127
}
128128
}

Common/src/main/java/at/petrak/hexcasting/client/render/HexAdditionalRenderers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ private static void tryRenderScryingLensOverlay(GuiGraphics graphics, float part
159159
return;
160160
}
161161

162-
if (player.getAttributeValue(HexAttributes.SCRY_SIGHT) <= 0.0)
162+
if (player.getAttributeValue(HexAttributes.SCRY_SIGHT) <= 0.0 || player.getAttributeValue(HexAttributes.FEEBLE_MIND) > 0)
163163
return;
164164

165165
var hitRes = mc.hitResult;

Common/src/main/java/at/petrak/hexcasting/common/items/ItemStaff.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package at.petrak.hexcasting.common.items;
22

33
import at.petrak.hexcasting.api.HexAPI;
4+
import at.petrak.hexcasting.common.lib.HexAttributes;
45
import at.petrak.hexcasting.common.lib.HexSounds;
56
import at.petrak.hexcasting.common.msgs.MsgClearSpiralPatternsS2C;
67
import at.petrak.hexcasting.common.msgs.MsgOpenSpellGuiS2C;
@@ -25,6 +26,9 @@ public ItemStaff(Properties pProperties) {
2526

2627
@Override
2728
public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand) {
29+
if (player.getAttributeValue(HexAttributes.FEEBLE_MIND) > 0){
30+
return InteractionResultHolder.fail(player.getItemInHand(hand));
31+
}
2832
if (player.isShiftKeyDown()) {
2933
if (world.isClientSide()) {
3034
player.playSound(HexSounds.STAFF_RESET, 1f, 1f);

Common/src/main/java/at/petrak/hexcasting/common/lib/HexAttributes.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package at.petrak.hexcasting.common.lib;
22

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

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

28+
private static final String MOD_ID = HexAPI.MOD_ID;
29+
2730
public static final Attribute GRID_ZOOM = make("grid_zoom", new RangedAttribute(
28-
HexAPI.MOD_ID + ".attributes.grid_zoom", 1.0, 0.5, 4.0)).setSyncable(true);
31+
MOD_ID + ".attributes.grid_zoom", 1.0, 0.5, 4.0)).setSyncable(true);
2932

3033
/**
3134
* Whether you have the lens overlay when looking at something. 0 = no, > 0 = yes.
3235
*/
3336
public static final Attribute SCRY_SIGHT = make("scry_sight", new RangedAttribute(
34-
HexAPI.MOD_ID + ".attributes.scry_sight", 0.0, 0.0, 1.0)).setSyncable(true);
37+
MOD_ID + ".attributes.scry_sight", 0.0, 0.0, 1.0)).setSyncable(true);
38+
39+
//whether the player is allowed to use staffcasting and scrying lenses
40+
public static final Attribute FEEBLE_MIND = make("feeble_mind", new RangedAttribute(
41+
MOD_ID + ".attributes.feeble_mind", 0.0, 0.0, 1.0).setSyncable(true));
42+
43+
//a multiplier to adjust media consumption across the board
44+
public static final Attribute MEDIA_CONSUMPTION_MODIFIER = make("media_consumption", new RangedAttribute(
45+
MOD_ID + ".attributes.media_consumption", 1.0, 0.0, Double.MAX_VALUE).setSyncable(true));
46+
47+
public static final Attribute AMBIT_RADIUS = make("ambit_radius", new RangedAttribute(
48+
MOD_ID + ".attributes.ambit_radius", PlayerBasedCastEnv.DEFAULT_AMBIT_RADIUS, 0.0, Double.MAX_VALUE).setSyncable(true));
49+
50+
public static final Attribute SENTINEL_RADIUS = make("sentinel_radius", new RangedAttribute(
51+
MOD_ID + ".attributes.sentinel_radius", PlayerBasedCastEnv.DEFAULT_SENTINEL_RADIUS, 0.0, Double.MAX_VALUE).setSyncable(true));
52+
53+
3554

3655
private static <T extends Attribute> T make(String id, T attr) {
3756
var old = ATTRIBUTES.put(modLoc(id), attr);

Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,8 +615,12 @@
615615

616616
attributes: {
617617
grid_zoom: "Casting Grid Size",
618+
media_consumption: "Media Consumption",
619+
ambit_radius: "Player Ambit Radius",
620+
sentinel_radius: "Sentinel Ambit Radius",
618621
// TODO: the +1 is kind of janky
619622
scry_sight: "Scrying Sight",
623+
feeble_mind: "Feeble Mind"
620624
},
621625

622626
// Action localizations

Fabric/src/main/java/at/petrak/hexcasting/fabric/mixin/FabricPlayerMixin.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,9 @@ protected FabricPlayerMixin(EntityType<? extends LivingEntity> entityType, Level
2222
var out = cir.getReturnValue();
2323
out.add(HexAttributes.GRID_ZOOM);
2424
out.add(HexAttributes.SCRY_SIGHT);
25+
out.add(HexAttributes.FEEBLE_MIND);
26+
out.add(HexAttributes.MEDIA_CONSUMPTION_MODIFIER);
27+
out.add(HexAttributes.AMBIT_RADIUS);
28+
out.add(HexAttributes.SENTINEL_RADIUS);
2529
}
2630
}

Forge/src/main/java/at/petrak/hexcasting/forge/ForgeHexInitializer.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,10 @@ private static void initListeners() {
277277
modBus.addListener((EntityAttributeModificationEvent e) -> {
278278
e.add(EntityType.PLAYER, HexAttributes.GRID_ZOOM);
279279
e.add(EntityType.PLAYER, HexAttributes.SCRY_SIGHT);
280+
e.add(EntityType.PLAYER, HexAttributes.FEEBLE_MIND);
281+
e.add(EntityType.PLAYER, HexAttributes.MEDIA_CONSUMPTION_MODIFIER);
282+
e.add(EntityType.PLAYER, HexAttributes.AMBIT_RADIUS);
283+
e.add(EntityType.PLAYER, HexAttributes.SENTINEL_RADIUS);
280284
});
281285

282286
if (ModList.get().isLoaded(HexInterop.Forge.CURIOS_API_ID)) {

0 commit comments

Comments
 (0)