This commit is contained in:
gamma-delta 2022-11-10 10:18:59 -06:00
commit 0193da311d
154 changed files with 1004 additions and 1035 deletions

View file

@ -1,11 +1,11 @@
// 1.19.2 2022-11-05T14:56:40.628663 Item Models: hexcasting
// 1.19.2 2022-11-09T19:44:43.409223 Item Models: hexcasting
f2156b3a7041cf99891b528393db64c6b9ca1a4f assets/hexcasting/models/item/abacus.json
783d8454d6b74f926be0d3e02d87c6505e9d76d0 assets/hexcasting/models/item/acacia_staff.json
19730853397b109cfedd0c3bbda83d5de6cd15b9 assets/hexcasting/models/item/akashic_record.json
8c735feff09d46d00ed681311f46f61a50cfdc9b assets/hexcasting/models/item/amethyst_dust.json
d1b0892de9d751e7bebc763e6407d5285363c851 assets/hexcasting/models/item/artifact.json
7eb3eb776e70eb616c12ada500b9d1d6a3249a6a assets/hexcasting/models/item/artifact_filled.json
f261669448bb990f55545c8e6288a1e75329c2ef assets/hexcasting/models/item/battery.json
82e3be7bbdad92d2b4c728be54d9d2f2809a0ac2 assets/hexcasting/models/item/battery.json
3dcc41ab5cbf7004f9c959d89be961aff0ce6032 assets/hexcasting/models/item/birch_staff.json
f05937151873b1de302a011851edc62d0554e4db assets/hexcasting/models/item/bosnia_staff.json
ec7c3a51882a432185fdbb6a449e66165b6a4c4c assets/hexcasting/models/item/charged_amethyst.json

View file

@ -1,6 +1,6 @@
// 1.19.2 2022-11-04T11:49:15.7703822 Advancements
17c1f596c096c05f510c3c03cef9281c9c6b8d47 data/hexcasting/advancements/aaa_wasteful_cast.json
4da7c22a5a04dfe9652f4f4b5d59a537edf285f8 data/hexcasting/advancements/aab_big_cast.json
// 1.19.2 2022-11-09T19:44:43.405259 Advancements
b21f0b7f0cda29a7e84693df8139f2fecfeea960 data/hexcasting/advancements/aaa_wasteful_cast.json
9d8b41dd8ddfccdf2cd19433d8d7d3cf934e64db data/hexcasting/advancements/aab_big_cast.json
ef61c93d776c6f212820af20909a4c1d92822baf data/hexcasting/advancements/enlightenment.json
8f97205fa79270eab688aa3019d6fe7dd8c8b0d3 data/hexcasting/advancements/lore.json
2f5ad49936d58c7097ac7f8fbbf3f66f9f90fd2c data/hexcasting/advancements/lore/experiment1.json
@ -12,5 +12,5 @@ ef06ae5bd79e2c52291fbfb3c69bc2f74a604477 data/hexcasting/advancements/lore/terab
861374b7c144ccdbbd031a3f5042af6718ba42bf data/hexcasting/advancements/lore/terabithia4.json
e26db8dfa825b7ac572d59a548b610db7c7bf736 data/hexcasting/advancements/lore/terabithia5.json
2acbfb4efe2a72a1986c8dbe62ad8d93e9613e99 data/hexcasting/advancements/opened_eyes.json
f85abe882fbcf05bb3dfbaf36c4ad5bcd8a888a4 data/hexcasting/advancements/root.json
d19039a73324eb7532d035d08442f3b68bb13bcb data/hexcasting/advancements/root.json
b1b82068d65d6872c258d905d4f78499e8227ccf data/hexcasting/advancements/y_u_no_cast_angy.json

View file

@ -3,106 +3,106 @@
{
"model": "hexcasting:item/phial_small_0",
"predicate": {
"hexcasting:mana": 0.0,
"hexcasting:max_mana": 0.0
"hexcasting:max_media": 0.0,
"hexcasting:media": 0.0
}
},
{
"model": "hexcasting:item/phial_small_1",
"predicate": {
"hexcasting:mana": 0.25,
"hexcasting:max_mana": 0.0
"hexcasting:max_media": 0.0,
"hexcasting:media": 0.25
}
},
{
"model": "hexcasting:item/phial_small_2",
"predicate": {
"hexcasting:mana": 0.5,
"hexcasting:max_mana": 0.0
"hexcasting:max_media": 0.0,
"hexcasting:media": 0.5
}
},
{
"model": "hexcasting:item/phial_small_3",
"predicate": {
"hexcasting:mana": 0.75,
"hexcasting:max_mana": 0.0
"hexcasting:max_media": 0.0,
"hexcasting:media": 0.75
}
},
{
"model": "hexcasting:item/phial_small_4",
"predicate": {
"hexcasting:mana": 1.0,
"hexcasting:max_mana": 0.0
"hexcasting:max_media": 0.0,
"hexcasting:media": 1.0
}
},
{
"model": "hexcasting:item/phial_medium_0",
"predicate": {
"hexcasting:mana": 0.0,
"hexcasting:max_mana": 1.0
"hexcasting:max_media": 1.0,
"hexcasting:media": 0.0
}
},
{
"model": "hexcasting:item/phial_medium_1",
"predicate": {
"hexcasting:mana": 0.25,
"hexcasting:max_mana": 1.0
"hexcasting:max_media": 1.0,
"hexcasting:media": 0.25
}
},
{
"model": "hexcasting:item/phial_medium_2",
"predicate": {
"hexcasting:mana": 0.5,
"hexcasting:max_mana": 1.0
"hexcasting:max_media": 1.0,
"hexcasting:media": 0.5
}
},
{
"model": "hexcasting:item/phial_medium_3",
"predicate": {
"hexcasting:mana": 0.75,
"hexcasting:max_mana": 1.0
"hexcasting:max_media": 1.0,
"hexcasting:media": 0.75
}
},
{
"model": "hexcasting:item/phial_medium_4",
"predicate": {
"hexcasting:mana": 1.0,
"hexcasting:max_mana": 1.0
"hexcasting:max_media": 1.0,
"hexcasting:media": 1.0
}
},
{
"model": "hexcasting:item/phial_large_0",
"predicate": {
"hexcasting:mana": 0.0,
"hexcasting:max_mana": 2.0
"hexcasting:max_media": 2.0,
"hexcasting:media": 0.0
}
},
{
"model": "hexcasting:item/phial_large_1",
"predicate": {
"hexcasting:mana": 0.25,
"hexcasting:max_mana": 2.0
"hexcasting:max_media": 2.0,
"hexcasting:media": 0.25
}
},
{
"model": "hexcasting:item/phial_large_2",
"predicate": {
"hexcasting:mana": 0.5,
"hexcasting:max_mana": 2.0
"hexcasting:max_media": 2.0,
"hexcasting:media": 0.5
}
},
{
"model": "hexcasting:item/phial_large_3",
"predicate": {
"hexcasting:mana": 0.75,
"hexcasting:max_mana": 2.0
"hexcasting:max_media": 2.0,
"hexcasting:media": 0.75
}
},
{
"model": "hexcasting:item/phial_large_4",
"predicate": {
"hexcasting:mana": 1.0,
"hexcasting:max_mana": 2.0
"hexcasting:max_media": 2.0,
"hexcasting:media": 1.0
}
}
]

View file

@ -3,11 +3,11 @@
"criteria": {
"waste_amt": {
"conditions": {
"mana_wasted": {
"media_wasted": {
"min": 89000
}
},
"trigger": "hexcasting:spend_mana"
"trigger": "hexcasting:spend_media"
}
},
"display": {

View file

@ -3,11 +3,11 @@
"criteria": {
"cast_amt": {
"conditions": {
"mana_spent": {
"media_spent": {
"min": 6400000
}
},
"trigger": "hexcasting:spend_mana"
"trigger": "hexcasting:spend_media"
}
},
"display": {

View file

@ -8,14 +8,14 @@ import java.util.List;
public interface ADHexHolder {
boolean canDrawManaFromInventory();
boolean canDrawMediaFromInventory();
boolean hasHex();
@Nullable
List<Iota> getHex(ServerLevel level);
void writeHex(List<Iota> patterns, int mana);
void writeHex(List<Iota> patterns, int media);
void clearHex();
}

View file

@ -4,12 +4,12 @@ import at.petrak.hexcasting.mixin.accessor.CriteriaTriggersAccessor;
public class HexAdvancementTriggers {
public static final OvercastTrigger OVERCAST_TRIGGER = new OvercastTrigger();
public static final SpendManaTrigger SPEND_MANA_TRIGGER = new SpendManaTrigger();
public static final SpendMediaTrigger SPEND_MEDIA_TRIGGER = new SpendMediaTrigger();
public static final FailToCastGreatSpellTrigger FAIL_GREAT_SPELL_TRIGGER = new FailToCastGreatSpellTrigger();
public static void registerTriggers() {
CriteriaTriggersAccessor.hex$register(OVERCAST_TRIGGER);
CriteriaTriggersAccessor.hex$register(SPEND_MANA_TRIGGER);
CriteriaTriggersAccessor.hex$register(SPEND_MEDIA_TRIGGER);
CriteriaTriggersAccessor.hex$register(FAIL_GREAT_SPELL_TRIGGER);
}
}

View file

@ -12,7 +12,7 @@ import net.minecraft.server.level.ServerPlayer;
public class OvercastTrigger extends SimpleCriterionTrigger<OvercastTrigger.Instance> {
private static final ResourceLocation ID = new ResourceLocation("hexcasting", "overcast");
private static final String TAG_MANA_GENERATED = "mana_generated";
private static final String TAG_MEDIA_GENERATED = "media_generated";
private static final String TAG_HEALTH_USED = "health_used";
// HEY KIDS DID YOYU KNOW THERE'S NOT A CRITERIA FOR HOW MUCH ***HEALTH*** AN ENTITY HAS
private static final String TAG_HEALTH_LEFT = "mojang_i_am_begging_and_crying_please_add_an_entity_health_criterion";
@ -26,29 +26,29 @@ public class OvercastTrigger extends SimpleCriterionTrigger<OvercastTrigger.Inst
protected Instance createInstance(JsonObject json, EntityPredicate.Composite predicate,
DeserializationContext pContext) {
return new Instance(predicate,
MinMaxBounds.Ints.fromJson(json.get(TAG_MANA_GENERATED)),
MinMaxBounds.Ints.fromJson(json.get(TAG_MEDIA_GENERATED)),
MinMaxBounds.Doubles.fromJson(json.get(TAG_HEALTH_USED)),
MinMaxBounds.Doubles.fromJson(json.get(TAG_HEALTH_LEFT)));
}
public void trigger(ServerPlayer player, int manaGenerated) {
public void trigger(ServerPlayer player, int mediaGenerated) {
super.trigger(player, inst -> {
var manaToHealth = HexConfig.common().mediaToHealthRate();
var healthUsed = manaGenerated / manaToHealth;
return inst.test(manaGenerated, healthUsed / player.getMaxHealth(), player.getHealth());
var mediaToHealth = HexConfig.common().mediaToHealthRate();
var healthUsed = mediaGenerated / mediaToHealth;
return inst.test(mediaGenerated, healthUsed / player.getMaxHealth(), player.getHealth());
});
}
public static class Instance extends AbstractCriterionTriggerInstance {
protected final MinMaxBounds.Ints manaGenerated;
protected final MinMaxBounds.Ints mediaGenerated;
protected final MinMaxBounds.Doubles healthUsed;
// DID YOU KNOW THERES ONE TO CHECK THE WORLD TIME, BUT NOT THE HEALTH!?
protected final MinMaxBounds.Doubles healthLeft;
public Instance(EntityPredicate.Composite predicate, MinMaxBounds.Ints manaGenerated,
public Instance(EntityPredicate.Composite predicate, MinMaxBounds.Ints mediaGenerated,
MinMaxBounds.Doubles healthUsed, MinMaxBounds.Doubles healthLeft) {
super(OvercastTrigger.ID, predicate);
this.manaGenerated = manaGenerated;
this.mediaGenerated = mediaGenerated;
this.healthUsed = healthUsed;
// DID YOU KNOW THERE'S ONE TO CHECK THE FUCKING C A T T Y P E BUT NOT THE HEALTH
this.healthLeft = healthLeft;
@ -62,8 +62,8 @@ public class OvercastTrigger extends SimpleCriterionTrigger<OvercastTrigger.Inst
@Override
public JsonObject serializeToJson(SerializationContext ctx) {
JsonObject json = super.serializeToJson(ctx);
if (!this.manaGenerated.isAny()) {
json.add(TAG_MANA_GENERATED, this.manaGenerated.serializeToJson());
if (!this.mediaGenerated.isAny()) {
json.add(TAG_MEDIA_GENERATED, this.mediaGenerated.serializeToJson());
}
if (!this.healthUsed.isAny()) {
json.add(TAG_HEALTH_USED, this.healthUsed.serializeToJson());
@ -74,8 +74,8 @@ public class OvercastTrigger extends SimpleCriterionTrigger<OvercastTrigger.Inst
return json;
}
private boolean test(int manaGeneratedIn, double healthUsedIn, float healthLeftIn) {
return this.manaGenerated.matches(manaGeneratedIn)
private boolean test(int mediaGeneratedIn, double healthUsedIn, float healthLeftIn) {
return this.mediaGenerated.matches(mediaGeneratedIn)
&& this.healthUsed.matches(healthUsedIn)
// DID YOU KNOW ALL THE ENEITYT PREDICATES ARE HARD-CODED AND YOU CANT MAKE NEW ONES
&& this.healthLeft.matches(healthLeftIn);

View file

@ -1,63 +0,0 @@
package at.petrak.hexcasting.api.advancements;
import com.google.gson.JsonObject;
import net.minecraft.advancements.critereon.*;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
public class SpendManaTrigger extends SimpleCriterionTrigger<SpendManaTrigger.Instance> {
private static final ResourceLocation ID = new ResourceLocation("hexcasting", "spend_mana");
private static final String TAG_MANA_SPENT = "mana_spent";
private static final String TAG_MANA_WASTED = "mana_wasted";
@Override
public ResourceLocation getId() {
return ID;
}
@Override
protected Instance createInstance(JsonObject json, EntityPredicate.Composite predicate,
DeserializationContext pContext) {
return new Instance(predicate,
MinMaxBounds.Ints.fromJson(json.get(TAG_MANA_SPENT)),
MinMaxBounds.Ints.fromJson(json.get(TAG_MANA_WASTED)));
}
public void trigger(ServerPlayer player, int manaSpent, int manaWasted) {
super.trigger(player, inst -> inst.test(manaSpent, manaWasted));
}
public static class Instance extends AbstractCriterionTriggerInstance {
protected final MinMaxBounds.Ints manaSpent;
protected final MinMaxBounds.Ints manaWasted;
public Instance(EntityPredicate.Composite predicate, MinMaxBounds.Ints manaSpent,
MinMaxBounds.Ints manaWasted) {
super(SpendManaTrigger.ID, predicate);
this.manaSpent = manaSpent;
this.manaWasted = manaWasted;
}
@Override
public ResourceLocation getCriterion() {
return ID;
}
@Override
public JsonObject serializeToJson(SerializationContext ctx) {
JsonObject json = super.serializeToJson(ctx);
if (!this.manaSpent.isAny()) {
json.add(TAG_MANA_SPENT, this.manaSpent.serializeToJson());
}
if (!this.manaWasted.isAny()) {
json.add(TAG_MANA_WASTED, this.manaWasted.serializeToJson());
}
return json;
}
private boolean test(int manaSpentIn, int manaWastedIn) {
return this.manaSpent.matches(manaSpentIn) && this.manaWasted.matches(manaWastedIn);
}
}
}

View file

@ -0,0 +1,63 @@
package at.petrak.hexcasting.api.advancements;
import com.google.gson.JsonObject;
import net.minecraft.advancements.critereon.*;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
public class SpendMediaTrigger extends SimpleCriterionTrigger<SpendMediaTrigger.Instance> {
private static final ResourceLocation ID = new ResourceLocation("hexcasting", "spend_media");
private static final String TAG_MEDIA_SPENT = "media_spent";
private static final String TAG_MEDIA_WASTED = "media_wasted";
@Override
public ResourceLocation getId() {
return ID;
}
@Override
protected Instance createInstance(JsonObject json, EntityPredicate.Composite predicate,
DeserializationContext pContext) {
return new Instance(predicate,
MinMaxBounds.Ints.fromJson(json.get(TAG_MEDIA_SPENT)),
MinMaxBounds.Ints.fromJson(json.get(TAG_MEDIA_WASTED)));
}
public void trigger(ServerPlayer player, int mediaSpent, int mediaWasted) {
super.trigger(player, inst -> inst.test(mediaSpent, mediaWasted));
}
public static class Instance extends AbstractCriterionTriggerInstance {
protected final MinMaxBounds.Ints mediaSpent;
protected final MinMaxBounds.Ints mediaWasted;
public Instance(EntityPredicate.Composite predicate, MinMaxBounds.Ints mediaSpent,
MinMaxBounds.Ints mediaWasted) {
super(SpendMediaTrigger.ID, predicate);
this.mediaSpent = mediaSpent;
this.mediaWasted = mediaWasted;
}
@Override
public ResourceLocation getCriterion() {
return ID;
}
@Override
public JsonObject serializeToJson(SerializationContext ctx) {
JsonObject json = super.serializeToJson(ctx);
if (!this.mediaSpent.isAny()) {
json.add(TAG_MEDIA_SPENT, this.mediaSpent.serializeToJson());
}
if (!this.mediaWasted.isAny()) {
json.add(TAG_MEDIA_WASTED, this.mediaWasted.serializeToJson());
}
return json;
}
private boolean test(int mediaSpentIn, int mediaWastedIn) {
return this.mediaSpent.matches(mediaSpentIn) && this.mediaWasted.matches(mediaWastedIn);
}
}
}

View file

@ -52,7 +52,7 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
TAG_NEXT_BLOCK = "next_block",
TAG_TRACKED_BLOCKS = "tracked_blocks",
TAG_FOUND_ALL = "found_all",
TAG_MANA = "mana",
TAG_MEDIA = "media",
TAG_LAST_MISHAP = "last_mishap";
private static final DecimalFormat DUST_AMOUNT = new DecimalFormat("###,###.##");
@ -72,7 +72,7 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
private static final int MAX_CAPACITY = 2_000_000_000;
private int mana = 0;
private int media = 0;
public BlockEntityAbstractImpetus(BlockEntityType<?> pType, BlockPos pWorldPosition, BlockState pBlockState) {
super(pType, pWorldPosition, pBlockState);
@ -80,12 +80,12 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
abstract public boolean activatorAlwaysInRange();
public int getMana() {
return this.mana;
public int getMedia() {
return this.media;
}
public void setMana(int mana) {
this.mana = mana;
public void setMedia(int media) {
this.media = media;
}
@Nullable
@ -119,12 +119,12 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
Player observer, Level world,
Direction hitFace) {
if (world.getBlockEntity(pos) instanceof BlockEntityAbstractImpetus beai) {
if (beai.getMana() < 0) {
if (beai.getMedia() < 0) {
lines.add(new Pair<>(new ItemStack(HexItems.AMETHYST_DUST), ItemCreativeUnlocker.infiniteMedia(world)));
} else {
var dustCount = (float) beai.getMana() / (float) MediaConstants.DUST_UNIT;
var dustCmp = Component.translatable("hexcasting.tooltip.lens.impetus.mana",
String.format("%.2f", dustCount));
var dustCount = (float) beai.getMedia() / (float) MediaConstants.DUST_UNIT;
var dustCmp = Component.translatable("hexcasting.tooltip.media",
DUST_AMOUNT.format(dustCount));
lines.add(new Pair<>(new ItemStack(HexItems.AMETHYST_DUST), dustCmp));
}
@ -150,7 +150,7 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
tag.put(TAG_TRACKED_BLOCKS, trackeds);
}
tag.putInt(TAG_MANA, this.mana);
tag.putInt(TAG_MEDIA, this.media);
if (this.lastMishap != null) {
tag.putString(TAG_LAST_MISHAP, Component.Serializer.toJson(this.lastMishap));
}
@ -183,7 +183,7 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
this.knownBlocks = new HashSet<>();
}
this.mana = tag.getInt(TAG_MANA);
this.media = tag.getInt(TAG_MEDIA);
if (tag.contains(TAG_LAST_MISHAP, Tag.TAG_STRING)) {
this.lastMishap = Component.Serializer.fromJson(tag.getString(TAG_LAST_MISHAP));
} else {
@ -526,7 +526,7 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
@Override
public void setItem(int index, ItemStack stack) {
insertMana(stack);
insertMedia(stack);
}
@Override
@ -541,43 +541,43 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
@Override
public boolean canPlaceItem(int index, ItemStack stack) {
if (remainingManaCapacity() == 0)
if (remainingMediaCapacity() == 0)
return false;
if (stack.is(HexItems.CREATIVE_UNLOCKER))
return true;
var manamount = extractManaFromItem(stack, true);
return manamount > 0;
var mediamount = extractMediaFromItem(stack, true);
return mediamount > 0;
}
public int extractManaFromItem(ItemStack stack, boolean simulate) {
if (this.mana < 0)
public int extractMediaFromItem(ItemStack stack, boolean simulate) {
if (this.media < 0)
return 0;
return MediaHelper.extractMedia(stack, remainingManaCapacity(), true, simulate);
return MediaHelper.extractMedia(stack, remainingMediaCapacity(), true, simulate);
}
public void insertMana(ItemStack stack) {
if (getMana() >= 0 && !stack.isEmpty() && stack.getItem() == HexItems.CREATIVE_UNLOCKER) {
setInfiniteMana();
public void insertMedia(ItemStack stack) {
if (getMedia() >= 0 && !stack.isEmpty() && stack.getItem() == HexItems.CREATIVE_UNLOCKER) {
setInfiniteMedia();
stack.shrink(1);
} else {
var manamount = extractManaFromItem(stack, false);
if (manamount > 0) {
this.mana = Math.min(manamount + mana, MAX_CAPACITY);
var mediamount = extractMediaFromItem(stack, false);
if (mediamount > 0) {
this.media = Math.min(mediamount + media, MAX_CAPACITY);
this.sync();
}
}
}
public void setInfiniteMana() {
this.mana = -1;
public void setInfiniteMedia() {
this.media = -1;
this.sync();
}
public int remainingManaCapacity() {
if (this.mana < 0)
public int remainingMediaCapacity() {
if (this.media < 0)
return 0;
return Math.max(0, MAX_CAPACITY - this.mana);
return Math.max(0, MAX_CAPACITY - this.media);
}
}

View file

@ -17,14 +17,14 @@ import java.util.List;
@ApiStatus.OverrideOnly
public interface HexHolderItem extends MediaHolderItem {
boolean canDrawManaFromInventory(ItemStack stack);
boolean canDrawMediaFromInventory(ItemStack stack);
boolean hasHex(ItemStack stack);
@Nullable
List<Iota> getHex(ItemStack stack, ServerLevel level);
void writeHex(ItemStack stack, List<Iota> program, int mana);
void writeHex(ItemStack stack, List<Iota> program, int media);
void clearHex(ItemStack stack);
}

View file

@ -1,59 +0,0 @@
package at.petrak.hexcasting.api.item;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.ApiStatus;
/**
* This interface should not be accessed direc
*/
@ApiStatus.OverrideOnly
public interface ManaHolderItem {
int getMana(ItemStack stack);
int getMaxMana(ItemStack stack);
void setMana(ItemStack stack, int mana);
boolean manaProvider(ItemStack stack);
boolean canRecharge(ItemStack stack);
default float getManaFullness(ItemStack stack) {
int max = getMaxMana(stack);
if (max == 0) {
return 0;
}
return (float) getMana(stack) / (float) max;
}
default int withdrawMana(ItemStack stack, int cost, boolean simulate) {
var manaHere = getMana(stack);
if (cost < 0) {
cost = manaHere;
}
if (!simulate) {
var manaLeft = manaHere - cost;
setMana(stack, manaLeft);
}
return Math.min(cost, manaHere);
}
default int insertMana(ItemStack stack, int amount, boolean simulate) {
var manaHere = getMana(stack);
int emptySpace = getMaxMana(stack) - manaHere;
if (emptySpace <= 0) {
return 0;
}
if (amount < 0) {
amount = emptySpace;
}
int inserting = Math.min(amount, emptySpace);
if (!simulate) {
var newMana = manaHere + inserting;
setMana(stack, newMana);
}
return inserting;
}
}

View file

@ -30,20 +30,20 @@ public interface MediaHolderItem {
}
default int withdrawMedia(ItemStack stack, int cost, boolean simulate) {
var manaHere = getMedia(stack);
var mediaHere = getMedia(stack);
if (cost < 0) {
cost = manaHere;
cost = mediaHere;
}
if (!simulate) {
var manaLeft = manaHere - cost;
setMedia(stack, manaLeft);
var mediaLeft = mediaHere - cost;
setMedia(stack, mediaLeft);
}
return Math.min(cost, manaHere);
return Math.min(cost, mediaHere);
}
default int insertMedia(ItemStack stack, int amount, boolean simulate) {
var manaHere = getMedia(stack);
int emptySpace = getMaxMedia(stack) - manaHere;
var mediaHere = getMedia(stack);
int emptySpace = getMaxMedia(stack) - mediaHere;
if (emptySpace <= 0) {
return 0;
}
@ -54,8 +54,8 @@ public interface MediaHolderItem {
int inserting = Math.min(amount, emptySpace);
if (!simulate) {
var newMana = manaHere + inserting;
setMedia(stack, newMana);
var newMedia = mediaHere + inserting;
setMedia(stack, newMedia);
}
return inserting;
}

View file

@ -23,7 +23,7 @@ public class HexConfig {
int DEFAULT_DUST_MEDIA_AMOUNT = MediaConstants.DUST_UNIT;
int DEFAULT_SHARD_MEDIA_AMOUNT = MediaConstants.SHARD_UNIT;
int DEFAULT_CHARGED_MEDIA_AMOUNT = MediaConstants.CRYSTAL_UNIT;
double DEFAULT_MANA_TO_HEALTH_RATE = 2 * MediaConstants.CRYSTAL_UNIT / 20.0;
double DEFAULT_MEDIA_TO_HEALTH_RATE = 2 * MediaConstants.CRYSTAL_UNIT / 20.0;
}

View file

@ -9,10 +9,10 @@ import net.minecraft.stats.Stats;
import static at.petrak.hexcasting.api.HexAPI.modLoc;
public class HexStatistics {
public static final ResourceLocation MANA_USED = makeCustomStat("mana_used",
manamount -> StatFormatter.DEFAULT.format(manamount / MediaConstants.DUST_UNIT));
public static final ResourceLocation MANA_OVERCASTED = makeCustomStat("mana_overcasted",
manamount -> StatFormatter.DEFAULT.format(manamount / MediaConstants.DUST_UNIT));
public static final ResourceLocation MEDIA_USED = makeCustomStat("media_used",
mediamount -> StatFormatter.DEFAULT.format(mediamount / MediaConstants.DUST_UNIT));
public static final ResourceLocation MEDIA_OVERCAST = makeCustomStat("media_overcast",
mediamount -> StatFormatter.DEFAULT.format(mediamount / MediaConstants.DUST_UNIT));
public static final ResourceLocation PATTERNS_DRAWN = makeCustomStat("patterns_drawn", StatFormatter.DEFAULT);
public static final ResourceLocation SPELLS_CAST = makeCustomStat("spells_cast", StatFormatter.DEFAULT);

View file

@ -14,7 +14,7 @@ import java.text.DecimalFormat
/**
* Manipulates the stack in some way, usually by popping some number of values off the stack
* and pushing one new value.
* For a more "traditional" pop arguments, push return experience, see [ConstManaAction].
* For a more "traditional" pop arguments, push return experience, see [ConstMediaAction].
*
* Implementors MUST NOT mutate the context.
*/
@ -67,7 +67,7 @@ interface Action {
origin.add(look.normalize().scale(MAX_DISTANCE))
@JvmStatic
fun makeConstantOp(x: Iota): Action = object : ConstManaAction {
fun makeConstantOp(x: Iota): Action = object : ConstMediaAction {
override val argc: Int
get() = 0
@ -78,7 +78,7 @@ interface Action {
private val DOUBLE_FORMATTER = DecimalFormat("####.####")
@JvmStatic
fun makeConstantOp(x: Double, key: ResourceLocation): Action = object : ConstManaAction {
fun makeConstantOp(x: Double, key: ResourceLocation): Action = object : ConstMediaAction {
override val argc: Int
get() = 0

View file

@ -7,11 +7,11 @@ import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.mishaps.MishapNotEnoughArgs
/**
* A SimpleOperator that always costs the same amount of mana.
* A SimpleOperator that always costs the same amount of media.
*/
interface ConstManaAction : Action {
interface ConstMediaAction : Action {
val argc: Int
val manaCost: Int
val mediaCost: Int
get() = 0
fun execute(args: List<Iota>, ctx: CastingContext): List<Iota>
@ -29,7 +29,7 @@ interface ConstManaAction : Action {
val newData = this.execute(args, ctx)
stack.addAll(newData)
val sideEffects = mutableListOf<OperatorSideEffect>(OperatorSideEffect.ConsumeMana(this.manaCost))
val sideEffects = mutableListOf<OperatorSideEffect>(OperatorSideEffect.ConsumeMedia(this.mediaCost))
return OperationResult(continuation, stack, ravenmind, sideEffects)
}

View file

@ -29,12 +29,12 @@ interface SpellAction : Action {
val args = stack.takeLast(this.argc)
for (_i in 0 until this.argc) stack.removeLast()
val executeResult = this.execute(args, ctx) ?: return OperationResult(continuation, stack, ravenmind, listOf())
val (spell, mana, particles) = executeResult
val (spell, media, particles) = executeResult
val sideEffects = mutableListOf<OperatorSideEffect>()
if (mana > 0)
sideEffects.add(OperatorSideEffect.ConsumeMana(mana))
if (media > 0)
sideEffects.add(OperatorSideEffect.ConsumeMedia(media))
// Don't have an effect if the caster isn't enlightened, even if processing other side effects
if (!isGreat || ctx.isCasterEnlightened)

View file

@ -446,14 +446,14 @@ class CastingHarness private constructor(
/**
* Might cast from hitpoints.
* Returns the mana cost still remaining after we deplete everything. It will be <= 0 if we could pay for it.
* Returns the media cost still remaining after we deplete everything. It will be <= 0 if we could pay for it.
*
* Also awards stats and achievements and such
*/
fun withdrawMana(manaCost: Int, allowOvercast: Boolean): Int {
// prevent poor impls from gaining you mana
if (manaCost <= 0) return 0
var costLeft = manaCost
fun withdrawMedia(mediaCost: Int, allowOvercast: Boolean): Int {
// prevent poor impls from gaining you media
if (mediaCost <= 0) return 0
var costLeft = mediaCost
val fake = this.ctx.caster.isCreative
@ -463,34 +463,34 @@ class CastingHarness private constructor(
val tile = this.ctx.world.getBlockEntity(this.ctx.spellCircle.impetusPos)
if (tile is BlockEntityAbstractImpetus) {
val manaAvailable = tile.mana
if (manaAvailable < 0)
val mediaAvailable = tile.media
if (mediaAvailable < 0)
return 0
val manaToTake = min(costLeft, manaAvailable)
costLeft -= manaToTake
tile.mana = manaAvailable - manaToTake
val mediaToTake = min(costLeft, mediaAvailable)
costLeft -= mediaToTake
tile.media = mediaAvailable - mediaToTake
}
} else {
val casterStack = this.ctx.caster.getItemInHand(this.ctx.castingHand)
val casterManaHolder = IXplatAbstractions.INSTANCE.findManaHolder(casterStack)
val casterMediaHolder = IXplatAbstractions.INSTANCE.findMediaHolder(casterStack)
val casterHexHolder = IXplatAbstractions.INSTANCE.findHexHolder(casterStack)
val hexHolderDrawsFromInventory = if (casterHexHolder != null) {
if (casterManaHolder != null) {
val manaAvailable = casterManaHolder.withdrawMedia(-1, true)
val manaToTake = min(costLeft, manaAvailable)
if (!fake) casterManaHolder.withdrawMedia(manaToTake, false)
costLeft -= manaToTake
if (casterMediaHolder != null) {
val mediaAvailable = casterMediaHolder.withdrawMedia(-1, true)
val mediaToTake = min(costLeft, mediaAvailable)
if (!fake) casterMediaHolder.withdrawMedia(mediaToTake, false)
costLeft -= mediaToTake
}
casterHexHolder.canDrawManaFromInventory()
casterHexHolder.canDrawMediaFromInventory()
} else {
false
}
if (casterStack.`is`(HexItemTags.STAVES) || hexHolderDrawsFromInventory) {
val manaSources = DiscoveryHandlers.collectMediaHolders(this)
val mediaSources = DiscoveryHandlers.collectMediaHolders(this)
.sortedWith(Comparator(::compareMediaItem).reversed())
for (source in manaSources) {
for (source in mediaSources) {
costLeft -= extractMedia(source, costLeft, simulate = fake)
if (costLeft <= 0)
break
@ -498,32 +498,32 @@ class CastingHarness private constructor(
if (allowOvercast && costLeft > 0) {
// Cast from HP!
val manaToHealth = HexConfig.common().mediaToHealthRate()
val healthtoRemove = costLeft.toDouble() / manaToHealth
val manaAbleToCastFromHP = this.ctx.caster.health * manaToHealth
val mediaToHealth = HexConfig.common().mediaToHealthRate()
val healthtoRemove = costLeft.toDouble() / mediaToHealth
val mediaAbleToCastFromHP = this.ctx.caster.health * mediaToHealth
val manaToActuallyPayFor = min(manaAbleToCastFromHP.toInt(), costLeft)
val mediaToActuallyPayFor = min(mediaAbleToCastFromHP.toInt(), costLeft)
costLeft -= if (!fake) {
Mishap.trulyHurt(this.ctx.caster, HexDamageSources.OVERCAST, healthtoRemove.toFloat())
val actuallyTaken = (manaAbleToCastFromHP - (this.ctx.caster.health * manaToHealth)).toInt()
val actuallyTaken = (mediaAbleToCastFromHP - (this.ctx.caster.health * mediaToHealth)).toInt()
HexAdvancementTriggers.OVERCAST_TRIGGER.trigger(this.ctx.caster, actuallyTaken)
this.ctx.caster.awardStat(HexStatistics.MANA_OVERCASTED, manaCost - costLeft)
this.ctx.caster.awardStat(HexStatistics.MEDIA_OVERCAST, mediaCost - costLeft)
actuallyTaken
} else {
manaToActuallyPayFor
mediaToActuallyPayFor
}
}
}
}
if (!fake) {
// this might be more than the mana cost! for example if we waste a lot of mana from an item
this.ctx.caster.awardStat(HexStatistics.MANA_USED, manaCost - costLeft)
HexAdvancementTriggers.SPEND_MANA_TRIGGER.trigger(
// this might be more than the media cost! for example if we waste a lot of media from an item
this.ctx.caster.awardStat(HexStatistics.MEDIA_USED, mediaCost - costLeft)
HexAdvancementTriggers.SPEND_MEDIA_TRIGGER.trigger(
this.ctx.caster,
manaCost - costLeft,
mediaCost - costLeft,
if (costLeft < 0) -costLeft else 0
)
}
@ -566,17 +566,17 @@ class CastingHarness private constructor(
DiscoveryHandlers.addMediaHolderDiscoverer {
it.ctx.caster.inventory.items
.filter(::isMediaItem)
.mapNotNull(IXplatAbstractions.INSTANCE::findManaHolder)
.mapNotNull(IXplatAbstractions.INSTANCE::findMediaHolder)
}
DiscoveryHandlers.addMediaHolderDiscoverer {
it.ctx.caster.inventory.armor
.filter(::isMediaItem)
.mapNotNull(IXplatAbstractions.INSTANCE::findManaHolder)
.mapNotNull(IXplatAbstractions.INSTANCE::findMediaHolder)
}
DiscoveryHandlers.addMediaHolderDiscoverer {
it.ctx.caster.inventory.offhand
.filter(::isMediaItem)
.mapNotNull(IXplatAbstractions.INSTANCE::findManaHolder)
.mapNotNull(IXplatAbstractions.INSTANCE::findMediaHolder)
}
}

View file

@ -48,14 +48,14 @@ sealed class OperatorSideEffect {
}
}
data class ConsumeMana(val amount: Int) : OperatorSideEffect() {
data class ConsumeMedia(val amount: Int) : OperatorSideEffect() {
override fun performEffect(harness: CastingHarness): Boolean {
val overcastOk = harness.ctx.canOvercast
val leftoverMana = harness.withdrawMana(this.amount, overcastOk)
if (leftoverMana > 0 && !overcastOk) {
val leftoverMedia = harness.withdrawMedia(this.amount, overcastOk)
if (leftoverMedia > 0 && !overcastOk) {
harness.ctx.caster.sendSystemMessage("hexcasting.message.cant_overcast".asTranslatedComponent)
}
return leftoverMana > 0
return leftoverMedia > 0
}
}

View file

@ -9,19 +9,19 @@ import net.minecraft.world.item.ItemStack
import kotlin.math.roundToInt
fun isMediaItem(stack: ItemStack): Boolean {
val manaHolder = IXplatAbstractions.INSTANCE.findManaHolder(stack) ?: return false
if (!manaHolder.canProvide())
val mediaHolder = IXplatAbstractions.INSTANCE.findMediaHolder(stack) ?: return false
if (!mediaHolder.canProvide())
return false
return manaHolder.withdrawMedia(-1, true) > 0
return mediaHolder.withdrawMedia(-1, true) > 0
}
/**
* Extract [cost] mana from [stack]. If [cost] is less than zero, extract all mana instead.
* Extract [cost] media from [stack]. If [cost] is less than zero, extract all media instead.
* This may mutate [stack] (and may consume it) unless [simulate] is set.
*
* If [drainForBatteries] is false, this will only consider forms of mana that can be used to make new batteries.
* If [drainForBatteries] is false, this will only consider forms of media that can be used to make new batteries.
*
* Return the amount of mana extracted. This may be over [cost] if mana is wasted.
* Return the amount of media extracted. This may be over [cost] if media is wasted.
*/
@JvmOverloads
fun extractMedia(
@ -30,18 +30,18 @@ fun extractMedia(
drainForBatteries: Boolean = false,
simulate: Boolean = false
): Int {
val manaHolder = IXplatAbstractions.INSTANCE.findManaHolder(stack) ?: return 0
val mediaHolder = IXplatAbstractions.INSTANCE.findMediaHolder(stack) ?: return 0
return extractMedia(manaHolder, cost, drainForBatteries, simulate)
return extractMedia(mediaHolder, cost, drainForBatteries, simulate)
}
/**
* Extract [cost] mana from [holder]. If [cost] is less than zero, extract all mana instead.
* Extract [cost] media from [holder]. If [cost] is less than zero, extract all media instead.
* This may mutate the stack underlying [holder] (and may consume it) unless [simulate] is set.
*
* If [drainForBatteries] is false, this will only consider forms of mana that can be used to make new batteries.
* If [drainForBatteries] is false, this will only consider forms of media that can be used to make new batteries.
*
* Return the amount of mana extracted. This may be over [cost] if mana is wasted.
* Return the amount of media extracted. This may be over [cost] if media is wasted.
*/
fun extractMedia(
holder: ADMediaHolder,
@ -58,19 +58,19 @@ fun extractMedia(
/**
* Sorted from least important to most important
*/
fun compareMediaItem(aMana: ADMediaHolder, bMana: ADMediaHolder): Int {
val priority = aMana.consumptionPriority - bMana.consumptionPriority
fun compareMediaItem(aMedia: ADMediaHolder, bMedia: ADMediaHolder): Int {
val priority = aMedia.consumptionPriority - bMedia.consumptionPriority
if (priority != 0)
return priority
return aMana.withdrawMedia(-1, true) - bMana.withdrawMedia(-1, true)
return aMedia.withdrawMedia(-1, true) - bMedia.withdrawMedia(-1, true)
}
fun mediaBarColor(mana: Int, maxMana: Int): Int {
val amt = if (maxMana == 0) {
fun mediaBarColor(media: Int, maxMedia: Int): Int {
val amt = if (maxMedia == 0) {
0f
} else {
mana.toFloat() / maxMana.toFloat()
media.toFloat() / maxMedia.toFloat()
}
val r = Mth.lerp(amt, 84f, 254f)
@ -79,11 +79,11 @@ fun mediaBarColor(mana: Int, maxMana: Int): Int {
return Mth.color(r / 255f, g / 255f, b / 255f)
}
fun mediaBarWidth(mana: Int, maxMana: Int): Int {
val amt = if (maxMana == 0) {
fun mediaBarWidth(media: Int, maxMedia: Int): Int {
val amt = if (maxMedia == 0) {
0f
} else {
mana.toFloat() / maxMana.toFloat()
media.toFloat() / maxMedia.toFloat()
}
return (13f * amt).roundToInt()
}

View file

@ -65,12 +65,12 @@ public class RegisterClientStuff {
registerPackagedSpellOverrides(HexItems.ARTIFACT);
var x = IClientXplatAbstractions.INSTANCE;
x.registerItemProperty(HexItems.BATTERY, ItemMediaBattery.MANA_PREDICATE,
x.registerItemProperty(HexItems.BATTERY, ItemMediaBattery.MEDIA_PREDICATE,
(stack, level, holder, holderID) -> {
var item = (MediaHolderItem) stack.getItem();
return item.getMediaFullness(stack);
});
x.registerItemProperty(HexItems.BATTERY, ItemMediaBattery.MAX_MANA_PREDICATE,
x.registerItemProperty(HexItems.BATTERY, ItemMediaBattery.MAX_MEDIA_PREDICATE,
(stack, level, holder, holderID) -> {
var item = (ItemMediaBattery) stack.getItem();
var max = item.getMaxMedia(stack);

View file

@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators
import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.api.spell.Action
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getVec3
@ -12,9 +12,9 @@ import net.minecraft.world.level.ClipContext
import net.minecraft.world.phys.HitResult
import net.minecraft.world.phys.Vec3
object OpBlockAxisRaycast : ConstManaAction {
object OpBlockAxisRaycast : ConstMediaAction {
override val argc = 2
override val manaCost = MediaConstants.DUST_UNIT / 100
override val mediaCost = MediaConstants.DUST_UNIT / 100
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val origin = args.getVec3(0, argc)
val look = args.getVec3(1, argc)

View file

@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators
import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.api.spell.Action
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getVec3
@ -12,9 +12,9 @@ import net.minecraft.world.level.ClipContext
import net.minecraft.world.phys.HitResult
import net.minecraft.world.phys.Vec3
object OpBlockRaycast : ConstManaAction {
object OpBlockRaycast : ConstMediaAction {
override val argc = 2
override val manaCost = MediaConstants.DUST_UNIT / 100
override val mediaCost = MediaConstants.DUST_UNIT / 100
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val origin = args.getVec3(0, argc)
val look = args.getVec3(1, argc)

View file

@ -1,12 +1,12 @@
package at.petrak.hexcasting.common.casting.operators
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getEntity
import at.petrak.hexcasting.api.spell.iota.Iota
object OpEntityHeight : ConstManaAction {
object OpEntityHeight : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {

View file

@ -1,12 +1,12 @@
package at.petrak.hexcasting.common.casting.operators
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getEntity
import at.petrak.hexcasting.api.spell.iota.Iota
object OpEntityLook : ConstManaAction {
object OpEntityLook : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {

View file

@ -1,12 +1,12 @@
package at.petrak.hexcasting.common.casting.operators
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getEntity
import at.petrak.hexcasting.api.spell.iota.Iota
class OpEntityPos(val feet: Boolean) : ConstManaAction {
class OpEntityPos(val feet: Boolean) : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {

View file

@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.casting.operators
import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.api.spell.Action
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getVec3
@ -11,9 +11,9 @@ import at.petrak.hexcasting.api.spell.iota.NullIota
import net.minecraft.world.entity.projectile.ProjectileUtil
import net.minecraft.world.phys.AABB
object OpEntityRaycast : ConstManaAction {
object OpEntityRaycast : ConstMediaAction {
override val argc = 2
override val manaCost = MediaConstants.DUST_UNIT / 100
override val mediaCost = MediaConstants.DUST_UNIT / 100
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val origin = args.getVec3(0, argc)
val look = args.getVec3(1, argc)

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.common.casting.operators
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getEntity
@ -8,7 +8,7 @@ import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.common.misc.PlayerPositionRecorder
import net.minecraft.server.level.ServerPlayer
object OpEntityVelocity : ConstManaAction {
object OpEntityVelocity : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {

View file

@ -1,12 +1,12 @@
package at.petrak.hexcasting.common.casting.operators
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.mishaps.MishapBadOffhandItem
import at.petrak.hexcasting.xplat.IXplatAbstractions
object OpRead : ConstManaAction {
object OpRead : ConstMediaAction {
override val argc = 0
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {

View file

@ -1,12 +1,12 @@
package at.petrak.hexcasting.common.casting.operators
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.xplat.IXplatAbstractions
object OpReadable : ConstManaAction {
object OpReadable : ConstMediaAction {
override val argc = 0
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {

View file

@ -1,13 +1,13 @@
package at.petrak.hexcasting.common.casting.operators
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getEntity
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.mishaps.MishapBadEntity
import at.petrak.hexcasting.xplat.IXplatAbstractions
object OpTheCoolerRead : ConstManaAction {
object OpTheCoolerRead : ConstMediaAction {
override val argc = 1
override fun execute(

View file

@ -1,13 +1,13 @@
package at.petrak.hexcasting.common.casting.operators
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getEntity
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.xplat.IXplatAbstractions
object OpTheCoolerReadable : ConstManaAction {
object OpTheCoolerReadable : ConstMediaAction {
override val argc = 1
override fun execute(

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.common.casting.operators
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getEntity
@ -8,7 +8,7 @@ import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.iota.NullIota
import at.petrak.hexcasting.xplat.IXplatAbstractions
object OpTheCoolerWritable : ConstManaAction {
object OpTheCoolerWritable : ConstMediaAction {
override val argc = 1
override fun execute(

View file

@ -1,13 +1,13 @@
package at.petrak.hexcasting.common.casting.operators
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.mishaps.MishapOthersName
import at.petrak.hexcasting.xplat.IXplatAbstractions
object OpWritable : ConstManaAction {
object OpWritable : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.akashic
import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getBlockPos
import at.petrak.hexcasting.api.spell.getPattern
@ -10,9 +10,9 @@ import at.petrak.hexcasting.api.spell.iota.NullIota
import at.petrak.hexcasting.api.spell.mishaps.MishapNoAkashicRecord
import at.petrak.hexcasting.common.blocks.akashic.BlockAkashicRecord
object OpAkashicRead : ConstManaAction {
object OpAkashicRead : ConstMediaAction {
override val argc = 2
override val manaCost = MediaConstants.DUST_UNIT
override val mediaCost = MediaConstants.DUST_UNIT
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val pos = args.getBlockPos(0, argc)

View file

@ -1,13 +1,13 @@
package at.petrak.hexcasting.common.casting.operators.circles
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.mishaps.MishapNoSpellCircle
import net.minecraft.world.phys.Vec3
class OpCircleBounds(val max: Boolean) : ConstManaAction {
class OpCircleBounds(val max: Boolean) : ConstMediaAction {
override val argc = 0
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {

View file

@ -1,13 +1,13 @@
package at.petrak.hexcasting.common.casting.operators.circles
import at.petrak.hexcasting.api.block.circle.BlockAbstractImpetus
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.mishaps.MishapNoSpellCircle
object OpImpetusDir : ConstManaAction {
object OpImpetusDir : ConstMediaAction {
override val argc = 0
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {

View file

@ -1,12 +1,12 @@
package at.petrak.hexcasting.common.casting.operators.circles
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.mishaps.MishapNoSpellCircle
object OpImpetusPos : ConstManaAction {
object OpImpetusPos : ConstMediaAction {
override val argc = 0
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {

View file

@ -1,12 +1,12 @@
package at.petrak.hexcasting.common.casting.operators.lists
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getList
import at.petrak.hexcasting.api.spell.iota.Iota
object OpAppend : ConstManaAction {
object OpAppend : ConstMediaAction {
override val argc = 2
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val list = args.getList(0, argc).toMutableList()

View file

@ -1,12 +1,12 @@
package at.petrak.hexcasting.common.casting.operators.lists
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getList
import at.petrak.hexcasting.api.spell.iota.Iota
object OpConcat : ConstManaAction {
object OpConcat : ConstMediaAction {
override val argc = 2
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val lhs = args.getList(0, argc).toMutableList()

View file

@ -1,13 +1,13 @@
package at.petrak.hexcasting.common.casting.operators.lists
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.SpellList
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getList
import at.petrak.hexcasting.api.spell.iota.Iota
object OpCons : ConstManaAction {
object OpCons : ConstMediaAction {
override val argc = 2
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val bottom = args.getList(0, argc)

View file

@ -1,11 +1,11 @@
package at.petrak.hexcasting.common.casting.operators.lists
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
object OpEmptyList : ConstManaAction {
object OpEmptyList : ConstMediaAction {
override val argc = 0
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
return emptyList<Iota>().asActionResult // sorry for taking all the easy impls, hudeler

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.common.casting.operators.lists
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getDouble
import at.petrak.hexcasting.api.spell.getList
@ -8,7 +8,7 @@ import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.iota.NullIota
import kotlin.math.roundToInt
object OpIndex : ConstManaAction {
object OpIndex : ConstMediaAction {
override val argc = 2
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val list = args.getList(0, argc).toMutableList()

View file

@ -1,12 +1,12 @@
package at.petrak.hexcasting.common.casting.operators.lists
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getList
import at.petrak.hexcasting.api.spell.iota.Iota
object OpIndexOf : ConstManaAction {
object OpIndexOf : ConstMediaAction {
override val argc: Int
get() = 2

View file

@ -1,13 +1,13 @@
package at.petrak.hexcasting.common.casting.operators.lists
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getList
import at.petrak.hexcasting.api.spell.iota.Iota
// it's still called beancounter's distillation in my heart
object OpListSize : ConstManaAction {
object OpListSize : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
return args.getList(0, argc).toList().size.asActionResult // mmm one-liner

View file

@ -4,11 +4,11 @@ import at.petrak.hexcasting.api.spell.*
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.iota.Iota
object OpModifyInPlace : ConstManaAction {
object OpModifyInPlace : ConstMediaAction {
override val argc = 3
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val list = args.getList(0, argc)
val index = args.getPositiveIntUnderInclusive(1, list.size(), argc)
val index = args.getPositiveIntUnder(1, list.size(), argc)
val iota = args[2]
return list.modifyAt(index) { SpellList.LPair(iota, it.cdr) }.asActionResult
}

View file

@ -1,13 +1,13 @@
package at.petrak.hexcasting.common.casting.operators.lists
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getInt
import at.petrak.hexcasting.api.spell.getList
import at.petrak.hexcasting.api.spell.iota.Iota
object OpRemove : ConstManaAction {
object OpRemove : ConstMediaAction {
override val argc: Int
get() = 2

View file

@ -1,12 +1,12 @@
package at.petrak.hexcasting.common.casting.operators.lists
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getList
import at.petrak.hexcasting.api.spell.iota.Iota
object OpReverski : ConstManaAction {
object OpReverski : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
return args.getList(0, argc).toList().asReversed().asActionResult // okay kotlin kinda pogged for this

View file

@ -1,11 +1,11 @@
package at.petrak.hexcasting.common.casting.operators.lists
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.iota.Iota
object OpSingleton : ConstManaAction {
object OpSingleton : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
return listOf(args[0]).asActionResult // god i love one-liners

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.common.casting.operators.lists
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getList
@ -9,7 +9,7 @@ import at.petrak.hexcasting.api.spell.iota.Iota
import kotlin.math.max
import kotlin.math.min
object OpSlice : ConstManaAction {
object OpSlice : ConstMediaAction {
override val argc = 3
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val list = args.getList(0, argc).toList()

View file

@ -1,11 +1,11 @@
package at.petrak.hexcasting.common.casting.operators.lists
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getList
import at.petrak.hexcasting.api.spell.iota.Iota
object OpSplat : ConstManaAction {
object OpSplat : ConstMediaAction {
override val argc: Int
get() = 1

View file

@ -1,13 +1,13 @@
package at.petrak.hexcasting.common.casting.operators.lists
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getList
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.iota.ListIota
import at.petrak.hexcasting.api.spell.iota.NullIota
object OpUnCons : ConstManaAction {
object OpUnCons : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val list = args.getList(0, argc)

View file

@ -1,13 +1,13 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getNumOrVec
import at.petrak.hexcasting.api.spell.iota.Iota
import kotlin.math.absoluteValue
object OpAbsLen : ConstManaAction {
object OpAbsLen : ConstMediaAction {
override val argc: Int
get() = 1

View file

@ -1,12 +1,12 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getNumOrVec
import at.petrak.hexcasting.api.spell.iota.Iota
object OpAdd : ConstManaAction {
object OpAdd : ConstMediaAction {
override val argc: Int
get() = 2

View file

@ -1,13 +1,13 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.aplKinnie
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getNumOrVec
import at.petrak.hexcasting.api.spell.iota.Iota
import kotlin.math.ceil
object OpCeil : ConstManaAction {
object OpCeil : ConstMediaAction {
override val argc: Int
get() = 1

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getVec3
@ -8,7 +8,7 @@ import at.petrak.hexcasting.api.spell.iota.Iota
import net.minecraft.core.Direction
import net.minecraft.world.phys.Vec3
object OpCoerceToAxial : ConstManaAction {
object OpCoerceToAxial : ConstMediaAction {
override val argc: Int
get() = 1

View file

@ -1,13 +1,13 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getDouble
import at.petrak.hexcasting.api.spell.iota.Iota
import net.minecraft.world.phys.Vec3
object OpConstructVec : ConstManaAction {
object OpConstructVec : ConstMediaAction {
override val argc = 3
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val x = args.getDouble(0, argc)

View file

@ -1,12 +1,12 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getVec3
import at.petrak.hexcasting.api.spell.iota.DoubleIota
import at.petrak.hexcasting.api.spell.iota.Iota
object OpDeconstructVec : ConstManaAction {
object OpDeconstructVec : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val v = args.getVec3(0, argc)

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getNumOrVec
@ -8,7 +8,7 @@ import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.mishaps.MishapDivideByZero
import net.minecraft.world.phys.Vec3
object OpDivCross : ConstManaAction {
object OpDivCross : ConstMediaAction {
override val argc: Int
get() = 2

View file

@ -1,13 +1,13 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.aplKinnie
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getNumOrVec
import at.petrak.hexcasting.api.spell.iota.Iota
import kotlin.math.floor
object OpFloor : ConstManaAction {
object OpFloor : ConstMediaAction {
override val argc: Int
get() = 1

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getDouble
@ -8,7 +8,7 @@ import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.mishaps.MishapDivideByZero
import kotlin.math.log
object OpLog : ConstManaAction {
object OpLog : ConstMediaAction {
override val argc: Int
get() = 2

View file

@ -1,13 +1,13 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getDouble
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.mishaps.MishapDivideByZero
object OpModulo : ConstManaAction {
object OpModulo : ConstMediaAction {
override val argc: Int
get() = 2

View file

@ -1,12 +1,12 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getNumOrVec
import at.petrak.hexcasting.api.spell.iota.Iota
object OpMulDot : ConstManaAction {
object OpMulDot : ConstMediaAction {
override val argc: Int
get() = 2

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getNumOrVec
@ -9,7 +9,7 @@ import at.petrak.hexcasting.api.spell.mishaps.MishapDivideByZero
import net.minecraft.world.phys.Vec3
import kotlin.math.pow
object OpPowProj : ConstManaAction {
object OpPowProj : ConstMediaAction {
override val argc: Int
get() = 2

View file

@ -1,11 +1,11 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.iota.Iota
object OpRandom : ConstManaAction {
object OpRandom : ConstMediaAction {
override val argc: Int
get() = 0

View file

@ -1,13 +1,13 @@
package at.petrak.hexcasting.common.casting.operators.math
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getNumOrVec
import at.petrak.hexcasting.api.spell.iota.Iota
import net.minecraft.world.phys.Vec3
object OpSub : ConstManaAction {
object OpSub : ConstMediaAction {
override val argc: Int
get() = 2

View file

@ -4,7 +4,7 @@ import at.petrak.hexcasting.api.spell.*
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.iota.Iota
object OpAnd : ConstManaAction {
object OpAnd : ConstMediaAction {
override val argc = 2
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {

View file

@ -1,12 +1,12 @@
package at.petrak.hexcasting.common.casting.operators.math.bit
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getLong
import at.petrak.hexcasting.api.spell.iota.Iota
object OpNot : ConstManaAction {
object OpNot : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {

View file

@ -4,7 +4,7 @@ import at.petrak.hexcasting.api.spell.*
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.iota.Iota
object OpOr : ConstManaAction {
object OpOr : ConstMediaAction {
override val argc = 2
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {

View file

@ -1,12 +1,12 @@
package at.petrak.hexcasting.common.casting.operators.math.bit
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getList
import at.petrak.hexcasting.api.spell.iota.Iota
object OpToSet : ConstManaAction {
object OpToSet : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {

View file

@ -4,7 +4,7 @@ import at.petrak.hexcasting.api.spell.*
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.iota.Iota
object OpXor : ConstManaAction {
object OpXor : ConstMediaAction {
override val argc = 2
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {

View file

@ -1,12 +1,12 @@
package at.petrak.hexcasting.common.casting.operators.math.logic
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getBool
import at.petrak.hexcasting.api.spell.iota.Iota
object OpBoolAnd : ConstManaAction {
object OpBoolAnd : ConstMediaAction {
override val argc = 2
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {

View file

@ -1,11 +1,11 @@
package at.petrak.hexcasting.common.casting.operators.math.logic
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getBool
import at.petrak.hexcasting.api.spell.iota.Iota
object OpBoolIf : ConstManaAction {
object OpBoolIf : ConstMediaAction {
override val argc = 3
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {

View file

@ -1,12 +1,12 @@
package at.petrak.hexcasting.common.casting.operators.math.logic
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getBool
import at.petrak.hexcasting.api.spell.iota.Iota
object OpBoolNot : ConstManaAction {
object OpBoolNot : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {

View file

@ -1,12 +1,12 @@
package at.petrak.hexcasting.common.casting.operators.math.logic
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getBool
import at.petrak.hexcasting.api.spell.iota.Iota
object OpBoolOr : ConstManaAction {
object OpBoolOr : ConstMediaAction {
override val argc = 2
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {

View file

@ -1,12 +1,12 @@
package at.petrak.hexcasting.common.casting.operators.math.logic
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getBool
import at.petrak.hexcasting.api.spell.iota.Iota
object OpBoolXor : ConstManaAction {
object OpBoolXor : ConstMediaAction {
override val argc = 2
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {

View file

@ -1,11 +1,11 @@
package at.petrak.hexcasting.common.casting.operators.math.logic
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.iota.Iota
object OpCoerceToBool : ConstManaAction {
object OpCoerceToBool : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.common.casting.operators.math.logic
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getDouble
@ -8,7 +8,7 @@ import at.petrak.hexcasting.api.spell.iota.DoubleIota
import at.petrak.hexcasting.api.spell.iota.Iota
import java.util.function.BiPredicate
class OpCompare(val acceptsEqual: Boolean, val cmp: BiPredicate<Double, Double>) : ConstManaAction {
class OpCompare(val acceptsEqual: Boolean, val cmp: BiPredicate<Double, Double>) : ConstMediaAction {
override val argc = 2
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {

View file

@ -1,11 +1,11 @@
package at.petrak.hexcasting.common.casting.operators.math.logic
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.iota.Iota
class OpEquality(val invert: Boolean) : ConstManaAction {
class OpEquality(val invert: Boolean) : ConstMediaAction {
override val argc = 2
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {

View file

@ -1,13 +1,13 @@
package at.petrak.hexcasting.common.casting.operators.math.trig
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getDoubleBetween
import at.petrak.hexcasting.api.spell.iota.Iota
import kotlin.math.acos
object OpArcCos : ConstManaAction {
object OpArcCos : ConstMediaAction {
override val argc: Int
get() = 1

View file

@ -1,13 +1,13 @@
package at.petrak.hexcasting.common.casting.operators.math.trig
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getDoubleBetween
import at.petrak.hexcasting.api.spell.iota.Iota
import kotlin.math.asin
object OpArcSin : ConstManaAction {
object OpArcSin : ConstMediaAction {
override val argc: Int
get() = 1

View file

@ -1,13 +1,13 @@
package at.petrak.hexcasting.common.casting.operators.math.trig
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getDouble
import at.petrak.hexcasting.api.spell.iota.Iota
import kotlin.math.atan
object OpArcTan : ConstManaAction {
object OpArcTan : ConstMediaAction {
override val argc: Int
get() = 1

View file

@ -1,13 +1,13 @@
package at.petrak.hexcasting.common.casting.operators.math.trig
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getDouble
import at.petrak.hexcasting.api.spell.iota.Iota
import kotlin.math.atan2
object OpArcTan2 : ConstManaAction {
object OpArcTan2 : ConstMediaAction {
override val argc: Int
get() = 2

View file

@ -1,13 +1,13 @@
package at.petrak.hexcasting.common.casting.operators.math.trig
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getDouble
import at.petrak.hexcasting.api.spell.iota.Iota
import kotlin.math.cos
object OpCos : ConstManaAction {
object OpCos : ConstMediaAction {
override val argc: Int
get() = 1

View file

@ -1,13 +1,13 @@
package at.petrak.hexcasting.common.casting.operators.math.trig
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getDouble
import at.petrak.hexcasting.api.spell.iota.Iota
import kotlin.math.sin
object OpSin : ConstManaAction {
object OpSin : ConstMediaAction {
override val argc: Int
get() = 1

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.common.casting.operators.math.trig
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getDouble
@ -10,7 +10,7 @@ import at.petrak.hexcasting.api.spell.mishaps.MishapDivideByZero
import kotlin.math.cos
import kotlin.math.tan
object OpTan : ConstManaAction {
object OpTan : ConstMediaAction {
override val argc: Int
get() = 1

View file

@ -1,11 +1,11 @@
package at.petrak.hexcasting.common.casting.operators.selectors
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.iota.Iota
object OpGetCaster : ConstManaAction {
object OpGetCaster : ConstMediaAction {
override val argc = 0
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.common.casting.operators.selectors
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getPositiveDouble
@ -18,7 +18,7 @@ import net.minecraft.world.phys.AABB
import net.minecraft.world.phys.Vec3
import java.util.function.Predicate
class OpGetEntitiesBy(val checker: Predicate<Entity>, val negate: Boolean) : ConstManaAction {
class OpGetEntitiesBy(val checker: Predicate<Entity>, val negate: Boolean) : ConstMediaAction {
override val argc = 2
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val pos = args.getVec3(0, argc)

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.common.casting.operators.selectors
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getVec3
@ -10,7 +10,7 @@ import net.minecraft.world.phys.AABB
import net.minecraft.world.phys.Vec3
import java.util.function.Predicate
class OpGetEntityAt(val checker: Predicate<Entity>) : ConstManaAction {
class OpGetEntityAt(val checker: Predicate<Entity>) : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val pos = args.getVec3(0, argc)

View file

@ -17,7 +17,7 @@ object OpBeep : SpellAction {
ctx: CastingContext
): Triple<RenderedSpell, Int, List<ParticleSpray>> {
val target = args.getVec3(0, argc)
val instrument = args.getPositiveIntUnderInclusive(1, NoteBlockInstrument.values().size, argc)
val instrument = args.getPositiveIntUnder(1, NoteBlockInstrument.values().size, argc)
val note = args.getPositiveIntUnderInclusive(2, 24, argc) // mojang don't have magic numbers challenge
ctx.assertVecInRange(target)

View file

@ -56,7 +56,7 @@ object OpMakeBattery : SpellAction {
) {
throw MishapBadItem.of(
entity,
"mana_for_battery"
"media_for_battery"
)
}
@ -68,11 +68,11 @@ object OpMakeBattery : SpellAction {
override fun cast(ctx: CastingContext) {
if (itemEntity.isAlive) {
val entityStack = itemEntity.item.copy()
val manaAmt = extractMedia(entityStack, drainForBatteries = true)
if (manaAmt > 0) {
val mediamount = extractMedia(entityStack, drainForBatteries = true)
if (mediamount > 0) {
ctx.caster.setItemInHand(
hand,
ItemMediaHolder.withMedia(ItemStack(HexItems.BATTERY), manaAmt, manaAmt)
ItemMediaHolder.withMedia(ItemStack(HexItems.BATTERY), mediamount, mediamount)
)
}

View file

@ -42,7 +42,7 @@ class OpMakePackagedSpell<T : ItemPackagedHex>(val itemType: T, val cost: Int) :
) {
throw MishapBadItem.of(
entity,
"mana_for_battery"
"media_for_battery"
)
}
@ -61,9 +61,9 @@ class OpMakePackagedSpell<T : ItemPackagedHex>(val itemType: T, val cost: Int) :
&& itemEntity.isAlive
) {
val entityStack = itemEntity.item.copy()
val manaAmt = extractMedia(entityStack, drainForBatteries = true)
if (manaAmt > 0) {
hexHolder.writeHex(patterns, manaAmt)
val mediamount = extractMedia(entityStack, drainForBatteries = true)
if (mediamount > 0) {
hexHolder.writeHex(patterns, mediamount)
}
itemEntity.item = entityStack

View file

@ -24,13 +24,13 @@ object OpRecharge : SpellAction {
val entity = args.getItemEntity(0, argc)
val (handStack, hand) = ctx.getHeldItemToOperateOn {
val mana = IXplatAbstractions.INSTANCE.findManaHolder(it)
mana != null && mana.canRecharge() && mana.insertMedia(-1, true) != 0
val media = IXplatAbstractions.INSTANCE.findMediaHolder(it)
media != null && media.canRecharge() && media.insertMedia(-1, true) != 0
}
val mana = IXplatAbstractions.INSTANCE.findManaHolder(handStack)
val media = IXplatAbstractions.INSTANCE.findMediaHolder(handStack)
if (mana == null || !mana.canRecharge())
if (media == null || !media.canRecharge())
throw MishapBadOffhandItem.of(
handStack,
hand,
@ -42,11 +42,11 @@ object OpRecharge : SpellAction {
if (!isMediaItem(entity.item)) {
throw MishapBadItem.of(
entity,
"mana"
"media"
)
}
if (mana.insertMedia(-1, true) == 0)
if (media.insertMedia(-1, true) == 0)
return null
return Triple(
@ -58,16 +58,16 @@ object OpRecharge : SpellAction {
private data class Spell(val itemEntity: ItemEntity, val stack: ItemStack) : RenderedSpell {
override fun cast(ctx: CastingContext) {
val mana = IXplatAbstractions.INSTANCE.findManaHolder(stack)
val media = IXplatAbstractions.INSTANCE.findMediaHolder(stack)
if (mana != null && itemEntity.isAlive) {
if (media != null && itemEntity.isAlive) {
val entityStack = itemEntity.item.copy()
val emptySpace = mana.insertMedia(-1, true)
val emptySpace = media.insertMedia(-1, true)
val manaAmt = extractMedia(entityStack, emptySpace)
val mediaAmt = extractMedia(entityStack, emptySpace)
mana.insertMedia(manaAmt, false)
media.insertMedia(mediaAmt, false)
itemEntity.item = entityStack
if (entityStack.isEmpty)

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.spells.sentinel
import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.iota.Iota
@ -9,9 +9,9 @@ import at.petrak.hexcasting.api.spell.iota.NullIota
import at.petrak.hexcasting.api.spell.mishaps.MishapLocationInWrongDimension
import at.petrak.hexcasting.xplat.IXplatAbstractions
object OpGetSentinelPos : ConstManaAction {
object OpGetSentinelPos : ConstMediaAction {
override val argc = 0
override val manaCost = MediaConstants.DUST_UNIT / 10
override val mediaCost = MediaConstants.DUST_UNIT / 10
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val sentinel = IXplatAbstractions.INSTANCE.getSentinel(ctx.caster)
if (sentinel.dimension != ctx.world.dimension())

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.casting.operators.spells.sentinel
import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.asActionResult
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getVec3
@ -12,9 +12,9 @@ import at.petrak.hexcasting.xplat.IXplatAbstractions
// TODO I don't think anyone has ever used this operation in the history of the world.
// TODO standardize "a negligible amount" of media to be 1/8 a dust
object OpGetSentinelWayfind : ConstManaAction {
object OpGetSentinelWayfind : ConstMediaAction {
override val argc = 1
override val manaCost = MediaConstants.DUST_UNIT / 10
override val mediaCost = MediaConstants.DUST_UNIT / 10
override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
val from = args.getVec3(0, argc)

View file

@ -8,8 +8,6 @@ import at.petrak.hexcasting.api.spell.getPositiveInt
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.mishaps.MishapNotEnoughArgs
import it.unimi.dsi.fastutil.ints.IntArrayList
import kotlin.math.abs
import kotlin.math.roundToInt
// "lehmer code"
object OpAlwinfyHasAscendedToABeingOfPureMath : Action {
@ -23,6 +21,7 @@ object OpAlwinfyHasAscendedToABeingOfPureMath : Action {
throw MishapNotEnoughArgs(1, 0)
val code = stack.getPositiveInt(stack.lastIndex)
stack.removeLast()
val strides = IntArrayList()
for (f in FactorialIter()) {

View file

@ -1,10 +1,10 @@
package at.petrak.hexcasting.common.casting.operators.stack
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.iota.Iota
object OpDuplicate : ConstManaAction {
object OpDuplicate : ConstMediaAction {
override val argc: Int
get() = 1

View file

@ -1,11 +1,11 @@
package at.petrak.hexcasting.common.casting.operators.stack
import at.petrak.hexcasting.api.spell.ConstManaAction
import at.petrak.hexcasting.api.spell.ConstMediaAction
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.getPositiveInt
import at.petrak.hexcasting.api.spell.iota.Iota
object OpDuplicateN : ConstManaAction {
object OpDuplicateN : ConstMediaAction {
override val argc: Int
get() = 2

Some files were not shown because too many files have changed in this diff Show more