repo for my hex addons :3
0
fork

Configure Feed

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

thinking hat thinking shirt

+54 -10
+1
project/hexic/src/client/scala/org/eu/net/pool/hexic/client.scala
··· 350 350 "staffcast_factory" -> "Lani's Greater Gambit", 351 351 "staffcast_factory/lazy" -> "Lani's Lesser Gambit", 352 352 "take" -> "Retention Distillation", 353 + "thinkaboutit" -> "Inquiry Purification", 353 354 "unfox" -> "Vulpine Expulsion", 354 355 "where" -> "Deductive Purification", 355 356 ) do gen.add(s"hexcasting.action.hexic:$action", name)
+53 -10
project/hexic/src/main/scala/org/eu/net/pool/hexic/views.scala
··· 11 11 import com.samsthenerd.inline.impl.InlineStyle 12 12 import net.fabricmc.fabric.api.dimension.v1.FabricDimensions 13 13 import net.fabricmc.fabric.api.event.{Event, EventFactory} 14 + import net.fabricmc.fabric.api.resource.ResourceReloadListenerKeys 14 15 import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant 15 16 import net.fabricmc.fabric.api.transfer.v1.item.{ItemStorage, ItemVariant} 16 17 import net.fabricmc.fabric.api.transfer.v1.storage.{Storage, TransferVariant} 17 18 import net.fabricmc.fabric.api.transfer.v1.transaction.base.SnapshotParticipant 18 19 import net.fabricmc.fabric.api.transfer.v1.transaction.{Transaction, TransactionContext} 19 - import net.minecraft.block.BlockState 20 + import net.minecraft.block.{AbstractFurnaceBlock, BlockState} 20 21 import net.minecraft.block.entity.AbstractFurnaceBlockEntity 21 - import net.minecraft.entity.Entity 22 - import net.minecraft.fluid.Fluid 23 - import net.minecraft.item.Item 22 + import net.minecraft.entity.decoration.ItemFrameEntity 23 + import net.minecraft.entity.{Entity, ItemEntity} 24 + import net.minecraft.fluid.{Fluid, Fluids} 25 + import net.minecraft.item.{Item, Items} 24 26 import net.minecraft.nbt.{NbtCompound, NbtElement, NbtList, NbtLong} 25 27 import net.minecraft.registry.{RegistryKey, RegistryKeys} 26 28 import net.minecraft.server.MinecraftServer ··· 28 30 import net.minecraft.text.{HoverEvent, MutableText, Text} 29 31 import net.minecraft.util.Identifier 30 32 import net.minecraft.util.math.{BlockPos, Box} 31 - import net.minecraft.world.{TeleportTarget, World} 33 + import net.minecraft.world.{BlockView, TeleportTarget, World} 32 34 import org.eu.net.pool.phlib.{*, given} 33 35 import org.slf4j.{Logger, LoggerFactory} 36 + import ram.talia.moreiotas.api.casting.iota.{ItemStackIota, ItemTypeIota} 34 37 35 38 import java.util.UUID 36 39 import scala.collection.immutable.ArraySeq.unsafeWrapArray ··· 46 49 def deserialize(data: NbtCompound)(using ServerWorld): Option[T] 47 50 trait Handler: 48 51 def apply(idx: Int)(using CastingEnvironment): Option[SlotReference] = None 52 + def contents(using TransactionContext, CastingEnvironment): Set[VariantIota[?]] = Set() 49 53 def tryExtract(variant: TransferVariant[?], amount: Long)(using TransactionContext, CastingEnvironment): Long = 0 50 54 def tryInsert(variant: TransferVariant[?], amount: Long)(using TransactionContext, CastingEnvironment): Long = 0 51 55 def capacity(variant: TransferVariant[?])(using TransactionContext, CastingEnvironment): Long = ··· 70 74 abstract class OfMerged(viewType: InventoryView.Type[?], views: => Seq[Handler]) extends InventoryView(viewType): 71 75 def getViews = views 72 76 override def apply(idx: Int)(using CastingEnvironment): Option[SlotReference] = views.collectFirst(Function.unlift(_(idx))) 77 + override def contents(using TransactionContext, CastingEnvironment) = views.flatMap(_.contents).toSet 73 78 override def tryExtract(variant: TransferVariant[?], amount: Long)(using TransactionContext, CastingEnvironment): Long = LazyList.from(views).scanLeft(0L)((n, view) => view.tryExtract(variant, amount - n) + n).findFirstOrLast(_ >= amount).getOrElse(0) 74 79 override def tryInsert(variant: TransferVariant[?], amount: Long)(using TransactionContext, CastingEnvironment): Long = LazyList.from(views).scanLeft(0L)((n, view) => view.tryInsert(variant, amount - n) + n).findFirstOrLast(_ >= amount).getOrElse(0) 75 80 override def capacity(variant: TransferVariant[?])(using TransactionContext, CastingEnvironment) = views.map(_.capacity(variant)).sum ··· 146 151 if storage == null then Seq() 147 152 else Seq( 148 153 new Handler: 154 + override def contents(using TransactionContext, CastingEnvironment): Set[VariantIota[?]] = storage.nonEmptyIterator.map(v => VariantIota(v.getResource, RegistryKey.of(VariantIota.key, Identifier("item")))).toSet 149 155 override def tryInsert(variant: TransferVariant[?], amount: Long)(using TransactionContext, CastingEnvironment): Long = 150 156 variant match 151 157 case i: ItemVariant => storage.insert(i, amount, summon) ··· 165 171 true 166 172 ) 167 173 else Seq() 168 - trait SingleVariantHandler(variant: TransferVariant[?]) extends Handler: 174 + trait SingleVariantHandler[O: ClassTag](variant: TransferVariant[O], key: RegistryKey[VariantIota.Reader]) extends Handler: 175 + def asIota = VariantIota(variant, key) 176 + def isPresent(using TransactionContext, CastingEnvironment): Boolean = true 177 + override def contents(using TransactionContext, CastingEnvironment): Set[VariantIota[?]] = if isPresent then Set(asIota) else Set() 169 178 override def tryExtract(variant: TransferVariant[?], amount: Long)(using TransactionContext, CastingEnvironment): Long = if variant == this.variant then trySubtract(amount) else 0L 170 179 override def tryInsert(variant: TransferVariant[?], amount: Long)(using TransactionContext, CastingEnvironment): Long = if variant == this.variant then tryAdd(amount) else 0L 171 180 override def capacity(variant: TransferVariant[?])(using TransactionContext, CastingEnvironment): Long = if variant == this.variant then cap else 0L ··· 175 184 176 185 Events.forBlock.register: (pos, state) => 177 186 summon[ServerWorld].getBlockEntity(pos) match 178 - case e: BlockEntityAbstractImpetus => Seq(new SingleVariantHandler(SingletonVariant.media) { 187 + case e: BlockEntityAbstractImpetus => Seq(new SingleVariantHandler(SingletonVariant.media, RegistryKey.of(VariantIota.key, "media")) { 179 188 private def mediaCapacity = 9000000000000000000L - e.getMedia 180 189 override def trySubtract(amount: Long)(using TransactionContext, CastingEnvironment): Long = 181 190 val toExtract = amount min e.getMedia ··· 191 200 Events.forBlock.register: (pos, state) => 192 201 summon[ServerWorld].getBlockEntity(pos) match 193 202 case e: AbstractFurnaceBlockEntity => Seq( 194 - new SingleVariantHandler(SingletonVariant.heat): 203 + new SingleVariantHandler(SingletonVariant.heat, RegistryKey.of(VariantIota.key, "heat")): 195 204 override def trySubtract(amount: Long)(using TransactionContext, CastingEnvironment): Long = 196 205 val action = (amount min e.burnTime).toInt 197 206 doSnapshot(e.burnTime, e.burnTime = _)(e.burnTime - action) 207 + doSnapshot(summon[ServerWorld].getBlockState(pos), summon[ServerWorld].setBlockState(pos, _, 3))(summon[ServerWorld].getBlockState(pos).`with`(AbstractFurnaceBlock.LIT, true)) 198 208 action 199 209 override def tryAdd(amount: Long)(using TransactionContext, CastingEnvironment): Long = 200 210 val action = (amount min cap).toInt ··· 228 238 229 239 object BoxedView extends IotaType[BoxedView.Instance]: 230 240 InventoryView 231 - class Instance(val view: InventoryView) extends Iota(BoxedView, view): 241 + case class Instance(view: InventoryView) extends Iota(BoxedView, view): 232 242 export view.{isTruthy, serialize} 233 243 override def toleratesOther(that: Iota): Boolean = that match 234 244 case that: BoxedView.Instance => view == that.view ··· 306 316 val count = from.view.entities.count(into.view.teleportEntity) 307 317 if count > 0 then tx.commit() 308 318 Seq(DoubleIota(count)) 309 - 319 + Patterns.register("thinkaboutit", e"awqawewaqw"): 320 + Patterns.mkConstAction(1): 321 + case Seq(iota) => 322 + def dieOfBadType() = throw MishapInvalidIota.of(iota, 0, "hexic:not_eldritch_horror") 323 + iota match 324 + case BoxedView.Instance(view) => 325 + Using.resource(Transaction.openOuter()): 326 + case given TransactionContext => 327 + Seq(ListIota(view.contents.toSeq)) 328 + case i: ItemStackIota => Seq(if i.getItemStack.getItem == Items.AIR then NullIota() else VariantIota(ItemVariant.of(i.getItemStack), RegistryKey.of(VariantIota.key, Identifier("item")))) 329 + case i: ItemTypeIota => Seq(if i.getItem == Items.AIR then NullIota() else VariantIota(ItemVariant.of(i.getItem), RegistryKey.of(VariantIota.key, Identifier("item")))) 330 + case v: Vec3Iota => 331 + val pos = BlockPos.ofFloored(v.getVec3) 332 + summon[CastingEnvironment].assertPosInRange(pos) 333 + val state = summon[BlockView].getBlockState(pos) 334 + if state.isAir then 335 + Seq(NullIota()) 336 + else 337 + state.getFluidState.getFluid match 338 + case Fluids.EMPTY => 339 + state.getBlock.asItem match 340 + case null | Items.AIR => 341 + state.getBlock.getPickStack(summon, pos, state) match 342 + case null | Items.AIR => 343 + Seq(NullIota()) 344 + case item => Seq(VariantIota(ItemVariant.of(item), RegistryKey.of(VariantIota.key, Identifier("item")))) 345 + case item => Seq(VariantIota(ItemVariant.of(item), RegistryKey.of(VariantIota.key, Identifier("item")))) 346 + case fluid => Seq(VariantIota(FluidVariant.of(fluid), RegistryKey.of(VariantIota.key, Identifier("fluid")))) 347 + case e: EntityIota if !e.getEntity.isRemoved => 348 + e.getEntity match 349 + case s: ItemEntity => Seq(if s.getStack.getItem == Items.AIR then NullIota() else VariantIota(ItemVariant.of(s.getStack), RegistryKey.of(VariantIota.key, Identifier("item")))) 350 + case s: ItemFrameEntity => Seq(if s.getHeldItemStack.getItem == Items.AIR then NullIota() else VariantIota(ItemVariant.of(s.getHeldItemStack), RegistryKey.of(VariantIota.key, Identifier("item")))) 351 + case _ => dieOfBadType() 352 + case _ => dieOfBadType() 310 353 //noinspection UnstableApiUsage 311 354 case class VariantIota[T: ClassTag](data: TransferVariant[T], key: RegistryKey[VariantIota.Reader]) extends Iota(VariantIota, data): 312 355 override def isTruthy: Boolean = true