repo for my hex addons :3
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

mediaweave tying

+104 -18
+2
project/hexic/src/client/scala/org/eu/net/pool/hexic/client.scala
··· 295 295 for action -> name <- Vector( 296 296 "attachworld" -> "Bind Demiplane", 297 297 "blind" -> "Hidden Sun's Nadir", 298 + "collar" -> "Tie Mediaweave", 299 + "decollar" -> "Untie Mediaweave", 298 300 "deleteworld" -> "Shatter Demiplane", 299 301 "drop" -> "Rejection Distillation", 300 302 "dye_offhand" -> "Apply Pigment",
+15 -17
project/hexic/src/main/scala/org/eu/net/pool/hexic/chat.scala
··· 137 137 @targetName("hexic$setPos") @Accessor("pos") private[hexic] def pos_=(pos: Float): Unit 138 138 139 139 extension (p: PlayerEntity) 140 - def validMediaweave: Option[(NbtCompound, DyeColor, ItemStack)] = 140 + def equippedMediaweave: Seq[(Mediaweave, ItemStack)] = 141 141 TrinketsApi.getTrinketComponent(p) 142 - .pipe(o => Option.when[TrinketComponent](o.isPresent)(o.get())) 142 + .pipe(o => Option.when[TrinketComponent](o.isPresent)(o.get()).toSeq) 143 143 .flatMap: (c: TrinketComponent) => 144 - c.getEquipped(_.getItem.isInstanceOf[Mediaweave]).asScala.collectFirst: 145 - Function.unlift: p => 146 - p.getRight.getItem match 147 - case m@Mediaweave(color) => Option(m.readIotaTag(p.getRight)).map((_, color, p.getRight)) 144 + c.getEquipped(_.getItem.isInstanceOf[Mediaweave]).asScala.collect: 145 + Function.unlift: e => 146 + e.getRight.getItem match 147 + case m: Mediaweave => Some(m, e.getRight) 148 148 case _ => None 149 + def validMediaweave: Option[(Mediaweave, ItemStack, ServerWorld ?=> Iota)] = 150 + p.equippedMediaweave.collectFirst: 151 + Function.unlift: 152 + case (item, stack) => Option(item.readIotaTag(stack)).map(tag => (item, stack, IotaType.deserialize(tag, summon[ServerWorld]))) 149 153 def catCollarColor: Option[DyeColor] = 150 - TrinketsApi.getTrinketComponent(p) 151 - .pipe(o => Option.when[TrinketComponent](o.isPresent)(o.get())) 152 - .flatMap: (c: TrinketComponent) => 153 - c.getEquipped(_.getItem.isInstanceOf[Mediaweave]).asScala.collectFirst: 154 - Function.unlift: p => 155 - p.getRight.getItem match 156 - case m@Mediaweave(color) if p.getRight.hasCustomName && p.getRight.getName.getString.toLowerCase == "instant cat" => Some(m.color) 157 - case _ => None 154 + p.equippedMediaweave.collectFirst: 155 + case (item, stack) if stack.hasCustomName && stack.getName.getString.toLowerCase == "instant cat" => item.color 158 156 extension (p: ServerPlayerEntity) 159 157 def executeMediaweave(text: String, ctx: Seq[Iota]): Boolean = 160 158 p.validMediaweave match 161 - case Some(hex, color, stack) => 159 + case Some(item, stack, hex) => 162 160 given world: ServerWorld = p.getWorld.asInstanceOf[ServerWorld] 163 161 lazy val env = new PlayerBasedCastEnv(p, Hand.OFF_HAND): 164 162 override def extractMediaEnvironment(cost: Long, simulate: Boolean): Long = 165 163 if p.isCreative then 0L else extractMediaFromInventory(cost, canOvercast, simulate) 166 164 override def getCastingHand: Hand = castingHand 167 - override def getPigment = FrozenPigment(ItemStack(HexItems.DYE_PIGMENTS.get(color)), Util.NIL_UUID) 165 + override def getPigment = FrozenPigment(ItemStack(HexItems.DYE_PIGMENTS.get(item.color)), Util.NIL_UUID) 168 166 val image = CastingImage(ctx :+ StringIota.make(text), 0, Seq(), false, 0, NbtCompound(), null) 169 - val instrs = IotaType.deserialize(hex, world) match 167 + val instrs = hex match 170 168 case list: ListIota => list.getList.asScala.toSeq 171 169 case iota => Seq(iota) 172 170 val vm = CastingVM(image, env)
+87 -1
project/hexic/src/main/scala/org/eu/net/pool/hexic/main.scala
··· 168 168 169 169 import scala.util.matching.Regex 170 170 import at.petrak.hexcasting.api.casting.eval.vm.CastingImage.ParenthesizedIota 171 - import dev.emi.trinkets.api.{TrinketComponent, TrinketsApi} 171 + import at.petrak.hexcasting.interop.inline.InlinePatternData 172 + import dev.emi.trinkets.api 173 + import dev.emi.trinkets.api.{Trinket, TrinketComponent, TrinketEnums, TrinketsApi} 172 174 import net.beholderface.oneironaut.casting.iotatypes.DimIota 175 + import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback 173 176 import net.fabricmc.fabric.api.dimension.v1.FabricDimensions 174 177 import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents 175 178 import net.minecraft.block.dispenser.ItemDispenserBehavior ··· 541 544 return stack 542 545 super.dispenseSilently(pointer, stack) 543 546 ) 547 + TrinketsApi.registerTrinket(this, Mediaweave.trinket) 544 548 object Mediaweave: 545 549 val colors: DyeColor :> Mediaweave = DyeColor.values().map(c => c -> Mediaweave(c)).toMap 546 550 val tag: TagKey[Item] = TagKey.of(Registries.ITEM, "mediaweaves") 551 + object trinket extends Trinket: 552 + override def canUnequip(stack: ItemStack, slot: api.SlotReference, entity: LivingEntity): Boolean = Option(stack).flatMap(s => Option(s.getNbt)).forall(_.get("lock") == null) 553 + override def getDropRule(stack: ItemStack, slot: api.SlotReference, entity: LivingEntity): TrinketEnums.DropRule = 554 + if Option(stack).flatMap(s => Option(s.getNbt)).exists(_.get("lock") == null) then 555 + TrinketEnums.DropRule.KEEP 556 + else 557 + super.getDropRule(stack, slot, entity) 547 558 548 559 extension (x: Iterable[Boolean]) 549 560 def any: Boolean = x.exists(identity) ··· 977 988 trait MutableFunction[T, R] extends (T => R): 978 989 def update(key: T, value: R): Unit 979 990 991 + extension (img: CastingImage) 992 + def apply(stack: Seq[Iota] = img.getStack.toSeq, 993 + parenCount: Int = img.getParenCount, 994 + parenthesized: Seq[ParenthesizedIota] = img.getParenthesized.toSeq, 995 + escapeNext: Boolean = img.getEscapeNext, 996 + opsConsumed: Long = img.getOpsConsumed, 997 + userData: NbtCompound = img.getUserData) = 998 + CastingImage(stack = stack, 999 + parenCount = parenCount, 1000 + parenthesized = parenthesized, 1001 + escapeNext = escapeNext, 1002 + opsConsumed = opsConsumed, 1003 + userData = userData, 1004 + null : DefaultConstructorMarker) 1005 + 980 1006 def init(): Unit = 981 1007 given_Logger.info: 982 1008 val possible = Seq( ··· 1205 1231 FoxEntity.Type.fromBiome(p.getWorld.getBiome(p.getBlockPos)) 1206 1232 Patterns.register("unfox", se"wqwqwqwaeeaw"): 1207 1233 fox { case Some(_) => None } 1234 + // /data get entity @s cardinal_components."trinkets:trinkets".chest.hexic_mediaweave.Items[0].tag.lock 1235 + Patterns.register("collar", sw"aqeqqqwqqqqqaqwqa"): 1236 + Patterns.mkAction: (img, cont) => 1237 + // (→) patterns do not need to modify the image 1238 + summon[CastingEnvironment] match 1239 + case env: PlayerBasedCastEnv => 1240 + val consume = OperatorSideEffect.ConsumeMedia(15000) 1241 + if isDev then println(s"starting with ${env.getCaster.equippedMediaweave}") 1242 + ( 1243 + img, cont, 1244 + HexEvalSounds.SPELL, 1245 + for 1246 + (_, stack) <- env.getCaster.equippedMediaweave 1247 + if isDev && { println(s"ok ${stack} how ya ${stack.getNbt} okie ${Option(stack.getNbt).forall(_.get("lock") == null)}"); true } 1248 + if Option(stack.getNbt).forall(_.get("lock") == null) 1249 + e <- Seq( 1250 + consume, 1251 + OperatorSideEffect.AttemptSpell( 1252 + new RenderedSpell: 1253 + override def cast(env: CastingEnvironment): Unit = 1254 + stack.getOrCreateNbt().put("lock", NbtCompound()) 1255 + override def cast(env: CastingEnvironment, img: CastingImage): CastingImage = { cast(env); img } 1256 + , true, true 1257 + ) 1258 + ) 1259 + yield e 1260 + ) 1261 + case _ => throw MishapBadCaster() 1262 + Patterns.register("decollar", ne"wwqaqqqqqwqqqew"): 1263 + Patterns.mkAction: (img, cont) => 1264 + // (→) patterns do not need to modify the image 1265 + summon[CastingEnvironment] match 1266 + case env: PlayerBasedCastEnv => 1267 + val consume = OperatorSideEffect.ConsumeMedia(15000) 1268 + ( 1269 + img, cont, 1270 + HexEvalSounds.SPELL, 1271 + for 1272 + (_, stack) <- env.getCaster.equippedMediaweave 1273 + if Option(stack.getNbt).exists(_.get("lock") != null) 1274 + e <- Seq( 1275 + consume, 1276 + OperatorSideEffect.AttemptSpell( 1277 + new RenderedSpell: 1278 + override def cast(env: CastingEnvironment): Unit = 1279 + Option(stack.getNbt).foreach(_.remove("lock")) 1280 + override def cast(env: CastingEnvironment, img: CastingImage): CastingImage = { cast(env); img } 1281 + , true, true 1282 + ) 1283 + ) 1284 + yield e 1285 + ) 1286 + case _ => throw MishapBadCaster() 1208 1287 hexXplat.getArithmeticRegistry("null_abs") = arith("null_abs", Arithmetic.ABS -> ((_: NullIota) => DoubleIota(0))) 1209 1288 val planeCaches = ju.WeakHashMap[MinecraftServer, mutable.Map[UUID, RuntimeWorldHandle]]() 1210 1289 def planeCache(using server: MinecraftServer): mutable.Map[UUID, RuntimeWorldHandle] = planeCaches.computeIfAbsent(server, _ => mutable.Map()) ··· 1783 1862 val x = pos.getComponentAlongAxis(axis) 1784 1863 if x < 0 || x >= 11 then boundary.break(false) 1785 1864 true 1865 + ItemTooltipCallback.EVENT.register: (stack, ctx, lines) => 1866 + stack.getItem match 1867 + case _: Mediaweave if Option(stack.getNbt).exists(_.get("lock") != null) => 1868 + lines.append(Text.literal("Tied").styled(_.withColor(0x782fe0))) 1869 + lines.append(Text.literal("Cannot be unequipped and won't be dropped on death.").styled(_.withColor(0x4b1d8c))) 1870 + lines.append(Text.literal("Use ").append(Text.empty().append(InlinePatternData(sw"aqeqqqwqqqqqaqwqa").asText(withExtra=false)).styled(_.withColor(0x782fe0))).append(" to untie.").styled(_.withColor(0x4b1d8c))) 1871 + case _ => 1786 1872 // dump patterns 1787 1873 val out = Files.newOutputStream(Path.of("patterns.csv")) 1788 1874 try