Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into inlinepatterns
Browse files Browse the repository at this point in the history
merge main back into inlinepatterns
  • Loading branch information
SamsTheNerd committed Aug 2, 2024
2 parents fa3d126 + 1421976 commit cbe821b
Show file tree
Hide file tree
Showing 18 changed files with 870 additions and 811 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"exhaustion": 0,
"exhaustion": 0.0,
"message_id": "hexcasting.overcast",
"scaling": "when_caused_by_living_non_player"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"exhaustion": 0,
"exhaustion": 0.0,
"message_id": "hexcasting.shame",
"scaling": "when_caused_by_living_non_player"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"values": [
"hexcasting:overcast",
"hexcasting:shame"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"values": [
"hexcasting:overcast",
"hexcasting:shame"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"hexcasting:shame"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"values": [
"hexcasting:overcast",
"hexcasting:shame"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ data class OperationAction(val pattern: HexPattern) : Action {
return try {
HexArithmetics.getEngine().run(pattern, env, image, continuation)
} catch (e: NoOperatorCandidatesException) {
throw MishapInvalidOperatorArgs(e.args, e.pattern)
throw MishapInvalidOperatorArgs(e.args)
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package at.petrak.hexcasting.api.casting.mishaps

import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.iota.GarbageIota
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.pigment.FrozenPigment
import at.petrak.hexcasting.api.utils.asTextComponent
import net.minecraft.network.chat.Component
import net.minecraft.network.chat.ComponentUtils
import net.minecraft.world.item.DyeColor

/**
* The value failed some kind of predicate.
*/
class MishapInvalidOperatorArgs(val perpetrators: List<Iota>) : Mishap() {
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
dyeColor(DyeColor.GRAY)

override fun execute(env: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
for (i in perpetrators.indices) {
stack[stack.size - 1 - i] = GarbageIota()
}
}

override fun errorMessage(ctx: CastingEnvironment, errorCtx: Context): Component {
return if (perpetrators.size == 1) {
error(
"invalid_operator_args.one",
0,
perpetrators[0].display()
)
} else {
error(
"invalid_operator_args.many",
perpetrators.size,
0,
perpetrators.lastIndex,
ComponentUtils.formatList(perpetrators.map { it.display() }, ", ".asTextComponent)
)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
package at.petrak.hexcasting.common.lib;

import net.minecraft.core.registries.Registries;
import net.minecraft.data.worldgen.BootstapContext;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.damagesource.DamageScaling;
import net.minecraft.world.damagesource.DamageType;

import static at.petrak.hexcasting.api.HexAPI.modLoc;

public class HexDamageTypes {
public static final ResourceKey<DamageType> OVERCAST = ResourceKey.create(Registries.DAMAGE_TYPE, modLoc("overcast"));
public static final ResourceKey<DamageType> SHAME_ON_YOU = ResourceKey.create(Registries.DAMAGE_TYPE, modLoc("overcast"));
public static final ResourceKey<DamageType> SHAME_ON_YOU = ResourceKey.create(Registries.DAMAGE_TYPE, modLoc("shame"));

public static void bootstrap(BootstapContext<DamageType> ctx) {
ctx.register(OVERCAST, new DamageType(
"hexcasting.overcast",
DamageScaling.WHEN_CAUSED_BY_LIVING_NON_PLAYER,
0f
));

ctx.register(SHAME_ON_YOU, new DamageType(
"hexcasting.shame",
DamageScaling.WHEN_CAUSED_BY_LIVING_NON_PLAYER,
0f
));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package at.petrak.hexcasting.datagen.tag;

import at.petrak.hexcasting.common.lib.HexDamageTypes;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.minecraft.data.tags.DamageTypeTagsProvider;
import net.minecraft.resources.ResourceKey;
import net.minecraft.tags.DamageTypeTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.damagesource.DamageType;
import org.jetbrains.annotations.NotNull;

import java.util.concurrent.CompletableFuture;

public class HexDamageTypeTagProvider extends DamageTypeTagsProvider {
public HexDamageTypeTagProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> provider) {
super(output, provider);
}

@Override
protected void addTags(@NotNull HolderLookup.Provider provider) {
add(HexDamageTypes.OVERCAST,
DamageTypeTags.BYPASSES_ARMOR,
DamageTypeTags.BYPASSES_EFFECTS,
DamageTypeTags.BYPASSES_SHIELD
);

add(HexDamageTypes.SHAME_ON_YOU,
DamageTypeTags.BYPASSES_ARMOR,
DamageTypeTags.BYPASSES_EFFECTS,
DamageTypeTags.BYPASSES_INVULNERABILITY,
DamageTypeTags.BYPASSES_SHIELD
);
}

@SafeVarargs
private void add(ResourceKey<DamageType> damageType, TagKey<DamageType>... tags) {
for (var tag : tags) {
this.tag(tag).add(damageType);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,11 @@
cos: "the cosine of %s",
},

invalid_operator_args: {
one: "got an unexpected iota at index %d of the stack: %s",
many: "got %d unexpected iotas at indices %d-%d of the stack: %s",
},

no_akashic_record: "No Akashic Record at %s",
disallowed: "has been disallowed by the server admins",
disallowed_circle: "has been disallowed in spell circles by the server admins",
Expand Down
Loading

0 comments on commit cbe821b

Please sign in to comment.