Skip to content

Commit 77c811c

Browse files
beholderfaceSamsTheNerd
authored andcommitted
put back formerly-conflicting code
1 parent a8a47a6 commit 77c811c

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

Common/src/main/java/at/petrak/hexcasting/api/casting/eval/CastingEnvironment.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import at.petrak.hexcasting.api.mod.HexConfig;
1111
import at.petrak.hexcasting.api.pigment.FrozenPigment;
1212
import at.petrak.hexcasting.api.utils.HexUtils;
13+
import at.petrak.hexcasting.common.lib.HexAttributes;
1314
import net.minecraft.core.BlockPos;
1415
import net.minecraft.nbt.CompoundTag;
1516
import net.minecraft.network.chat.Component;
@@ -247,6 +248,9 @@ public boolean isEnlightened() {
247248
* positive.
248249
*/
249250
public long extractMedia(long cost, boolean simulate) {
251+
if (this.getCastingEntity() != null){
252+
cost = (long) (cost * this.getCastingEntity().getAttributeValue(HexAttributes.MEDIA_CONSUMPTION_MODIFIER));
253+
}
250254
for (var extractMediaComponent : preMediaExtract)
251255
cost = extractMediaComponent.onExtractMedia(cost, simulate);
252256
cost = extractMediaEnvironment(cost, simulate);

Common/src/main/java/at/petrak/hexcasting/api/casting/eval/env/CircleCastEnv.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import at.petrak.hexcasting.api.casting.mishaps.MishapDisallowedSpell;
1414
import at.petrak.hexcasting.api.mod.HexConfig;
1515
import at.petrak.hexcasting.api.pigment.FrozenPigment;
16+
import at.petrak.hexcasting.common.lib.HexAttributes;
1617
import net.minecraft.core.BlockPos;
1718
import net.minecraft.network.chat.Component;
1819
import net.minecraft.resources.ResourceLocation;
@@ -29,8 +30,6 @@
2930
import java.util.List;
3031
import java.util.function.Predicate;
3132

32-
import static at.petrak.hexcasting.api.casting.eval.env.PlayerBasedCastEnv.SENTINEL_RADIUS;
33-
3433
public class CircleCastEnv extends CastingEnvironment {
3534
protected final CircleExecutionState execState;
3635

@@ -133,6 +132,7 @@ public long extractMediaEnvironment(long cost, boolean simulate) {
133132
public boolean isVecInRangeEnvironment(Vec3 vec) {
134133
var caster = this.execState.getCaster(this.world);
135134
if (caster != null) {
135+
double sentinelRadius = caster.getAttributeValue(HexAttributes.SENTINEL_RADIUS);
136136
if (vec.distanceToSqr(caster.position()) <= caster.getBbHeight() * caster.getBbHeight()) {
137137
return true;
138138
}
@@ -141,7 +141,7 @@ public boolean isVecInRangeEnvironment(Vec3 vec) {
141141
if (sentinel != null
142142
&& sentinel.extendsRange()
143143
&& caster.level().dimension() == sentinel.dimension()
144-
&& vec.distanceToSqr(sentinel.position()) <= SENTINEL_RADIUS * SENTINEL_RADIUS + 0.00000000001
144+
&& vec.distanceToSqr(sentinel.position()) <= sentinelRadius * sentinelRadius + 0.00000000001
145145
) {
146146
return true;
147147
}

Common/src/main/java/at/petrak/hexcasting/api/casting/eval/env/PlayerBasedCastEnv.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import at.petrak.hexcasting.api.pigment.FrozenPigment;
1515
import at.petrak.hexcasting.api.utils.HexUtils;
1616
import at.petrak.hexcasting.api.utils.MediaHelper;
17+
import at.petrak.hexcasting.common.lib.HexAttributes;
1718
import at.petrak.hexcasting.common.lib.HexDamageTypes;
1819
import at.petrak.hexcasting.xplat.IXplatAbstractions;
1920
import net.minecraft.core.BlockPos;
@@ -35,8 +36,10 @@
3536
import static at.petrak.hexcasting.api.HexAPI.modLoc;
3637

3738
public abstract class PlayerBasedCastEnv extends CastingEnvironment {
38-
public static final double AMBIT_RADIUS = 32.0;
39-
public static final double SENTINEL_RADIUS = 16.0;
39+
public static final double DEFAULT_AMBIT_RADIUS = 32.0;
40+
private double ambitRadius;
41+
public static final double DEFAULT_SENTINEL_RADIUS = 16.0;
42+
private double sentinelRadius;
4043

4144
protected final ServerPlayer caster;
4245
protected final InteractionHand castingHand;
@@ -45,6 +48,8 @@ protected PlayerBasedCastEnv(ServerPlayer caster, InteractionHand castingHand) {
4548
super(caster.serverLevel());
4649
this.caster = caster;
4750
this.castingHand = castingHand;
51+
this.ambitRadius = caster.getAttributeValue(HexAttributes.AMBIT_RADIUS);
52+
this.sentinelRadius = caster.getAttributeValue(HexAttributes.SENTINEL_RADIUS);
4853
}
4954

5055
@Override
@@ -78,6 +83,14 @@ protected List<HeldItemInfo> getPrimaryStacks() {
7883
return getPrimaryStacksForPlayer(this.castingHand, this.caster);
7984
}
8085

86+
public double getAmbitRadius() {
87+
return this.ambitRadius;
88+
}
89+
90+
public double getSentinelRadius(){
91+
return this.sentinelRadius;
92+
}
93+
8194
@Override
8295
public boolean replaceItem(Predicate<ItemStack> stackOk, ItemStack replaceWith, @Nullable InteractionHand hand) {
8396
return replaceItemForPlayer(stackOk, replaceWith, hand, this.caster);
@@ -90,12 +103,12 @@ public boolean isVecInRangeEnvironment(Vec3 vec) {
90103
&& sentinel.extendsRange()
91104
&& this.caster.level().dimension() == sentinel.dimension()
92105
// adding 0.00000000001 to avoid machine precision errors at specific angles
93-
&& vec.distanceToSqr(sentinel.position()) <= SENTINEL_RADIUS * SENTINEL_RADIUS + 0.00000000001
106+
&& vec.distanceToSqr(sentinel.position()) <= sentinelRadius * sentinelRadius + 0.00000000001
94107
) {
95108
return true;
96109
}
97110

98-
return vec.distanceToSqr(this.caster.position()) <= AMBIT_RADIUS * AMBIT_RADIUS + 0.00000000001;
111+
return vec.distanceToSqr(this.caster.position()) <= ambitRadius * ambitRadius + 0.00000000001;
99112
}
100113

101114
@Override

0 commit comments

Comments
 (0)