mirror of
https://github.com/naalit/slotlink.git
synced 2025-12-31 04:13:02 +00:00
1.18.2
This commit is contained in:
parent
586ab6f871
commit
82641cb633
16 changed files with 56 additions and 62 deletions
|
|
@ -10,7 +10,7 @@ plugins {
|
|||
kotlin("jvm").version("1.6.0")
|
||||
kotlin("plugin.serialization").version("1.6.0")
|
||||
|
||||
id("fabric-loom").version("0.10.+")
|
||||
id("fabric-loom").version("0.11.+")
|
||||
id("com.matthewprenger.cursegradle").version("1.4.0")
|
||||
id("com.modrinth.minotaur").version("1.1.0")
|
||||
id("maven-publish")
|
||||
|
|
|
|||
|
|
@ -4,28 +4,28 @@ org.gradle.jvmargs = -Xmx1G
|
|||
run_args = -Dmixin.debug.export=true
|
||||
|
||||
# Fabric properties
|
||||
minecraft = 1.18.1
|
||||
yarn = 1.18.1+build.5
|
||||
fabricLoader = 0.12.8
|
||||
minecraft = 1.18.2
|
||||
yarn = 1.18.2+build.2
|
||||
fabricLoader = 0.13.3
|
||||
|
||||
# Mod properties
|
||||
maven_group = com.github.badasintended
|
||||
archives_base_name = slotlink
|
||||
|
||||
# Dependencies
|
||||
fabricApi = 0.44.0+1.18
|
||||
fabricApi = 0.47.10+1.18.2
|
||||
fabricKotlin = 1.7.0+kotlin.1.6.0
|
||||
rei = 7.0.352
|
||||
wthit = 4.4.1
|
||||
rei = 8.0.442
|
||||
wthit = 4.7.3
|
||||
|
||||
# CurseForge
|
||||
cf.projectId = 391014
|
||||
cf.releaseType = release
|
||||
cf.gameVersion = 1.18.1
|
||||
cf.gameVersion = 1.18.2
|
||||
cf.require = fabric-api, fabric-language-kotlin
|
||||
cf.optional = roughly-enough-items, wthit
|
||||
|
||||
# Modrinth
|
||||
mr.projectId = FTMcNdhv
|
||||
mr.releaseType = release
|
||||
mr.gameVersion = 1.18.1
|
||||
mr.gameVersion = 1.18.2
|
||||
|
|
|
|||
|
|
@ -5,37 +5,36 @@ import badasintended.slotlink.init.Items
|
|||
import badasintended.slotlink.util.modId
|
||||
import java.util.function.Consumer
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator
|
||||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipesProvider
|
||||
import net.fabricmc.fabric.api.tag.TagFactory
|
||||
import net.minecraft.data.server.recipe.CraftingRecipeJsonFactory
|
||||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider
|
||||
import net.minecraft.data.server.recipe.CraftingRecipeJsonBuilder
|
||||
import net.minecraft.data.server.recipe.RecipeJsonProvider
|
||||
import net.minecraft.item.Item
|
||||
import net.minecraft.item.ItemConvertible
|
||||
import net.minecraft.tag.Tag
|
||||
import net.minecraft.tag.TagKey
|
||||
import net.minecraft.util.Identifier
|
||||
import net.fabricmc.fabric.api.tag.TagFactory.ITEM as tag
|
||||
import net.minecraft.util.registry.Registry
|
||||
import net.minecraft.block.Blocks as McBlocks
|
||||
import net.minecraft.data.server.recipe.ShapedRecipeJsonFactory.create as shaped
|
||||
import net.minecraft.data.server.recipe.ShapelessRecipeJsonFactory.create as shapeless
|
||||
import net.minecraft.data.server.recipe.ShapedRecipeJsonBuilder.create as shaped
|
||||
import net.minecraft.data.server.recipe.ShapelessRecipeJsonBuilder.create as shapeless
|
||||
import net.minecraft.item.Items as McItems
|
||||
|
||||
class RecipeProvider(dataGenerator: FabricDataGenerator) : FabricRecipesProvider(dataGenerator) {
|
||||
class RecipeProvider(dataGenerator: FabricDataGenerator) : FabricRecipeProvider(dataGenerator) {
|
||||
|
||||
override fun generateRecipes(exporter: Consumer<RecipeJsonProvider>) {
|
||||
shaped(Blocks.CABLE, 8)
|
||||
.pattern("SSS")
|
||||
.pattern("I I")
|
||||
.pattern("SSS")
|
||||
.input('I', tag.c("iron_ingots"))
|
||||
.input('I', tag("c:iron_ingots"))
|
||||
.input('S', McBlocks.STONE_SLAB)
|
||||
.criterion(McItems.IRON_INGOT, tag.c("iron_ingots"))
|
||||
.criterion(McItems.IRON_INGOT, tag("c:iron_ingots"))
|
||||
.offerTo(exporter)
|
||||
|
||||
shaped(Blocks.IMPORT_CABLE, 4)
|
||||
.pattern(" C ")
|
||||
.pattern("CHC")
|
||||
.pattern(" C ")
|
||||
.input('H', tag.c("hoppers"))
|
||||
.input('H', tag("c:hoppers"))
|
||||
.input('C', Blocks.CABLE)
|
||||
.criterion(Blocks.CABLE)
|
||||
.offerTo(exporter)
|
||||
|
|
@ -56,7 +55,7 @@ class RecipeProvider(dataGenerator: FabricDataGenerator) : FabricRecipesProvider
|
|||
.pattern(" C ")
|
||||
.pattern("CHC")
|
||||
.pattern(" C ")
|
||||
.input('H', tag.c("wooden_chests"))
|
||||
.input('H', tag("c:wooden_chests"))
|
||||
.input('C', Blocks.CABLE)
|
||||
.criterion(Blocks.CABLE)
|
||||
.offerTo(exporter)
|
||||
|
|
@ -65,8 +64,8 @@ class RecipeProvider(dataGenerator: FabricDataGenerator) : FabricRecipesProvider
|
|||
.pattern("QCQ")
|
||||
.pattern("CDC")
|
||||
.pattern("QCQ")
|
||||
.input('D', tag.c("diamonds"))
|
||||
.input('Q', tag.c("quartz_blocks"))
|
||||
.input('D', tag("c:diamonds"))
|
||||
.input('Q', tag("c:quartz_blocks"))
|
||||
.input('C', Blocks.CABLE)
|
||||
.criterion(Blocks.CABLE)
|
||||
.offerTo(exporter)
|
||||
|
|
@ -75,7 +74,7 @@ class RecipeProvider(dataGenerator: FabricDataGenerator) : FabricRecipesProvider
|
|||
.pattern("TCT")
|
||||
.pattern("CGC")
|
||||
.pattern("TCT")
|
||||
.input('G', tag.c("gold_ingots"))
|
||||
.input('G', tag("c:gold_ingots"))
|
||||
.input('T', McBlocks.CRAFTING_TABLE)
|
||||
.input('C', Blocks.LINK_CABLE)
|
||||
.criterion(Blocks.LINK_CABLE)
|
||||
|
|
@ -85,7 +84,7 @@ class RecipeProvider(dataGenerator: FabricDataGenerator) : FabricRecipesProvider
|
|||
.pattern("SIS")
|
||||
.pattern("IRE")
|
||||
.pattern("SES")
|
||||
.input('R', tag.c("iron_ingots"))
|
||||
.input('R', tag("c:iron_ingots"))
|
||||
.input('S', McBlocks.SMOOTH_STONE)
|
||||
.input('I', Blocks.IMPORT_CABLE)
|
||||
.input('E', Blocks.EXPORT_CABLE)
|
||||
|
|
@ -97,9 +96,9 @@ class RecipeProvider(dataGenerator: FabricDataGenerator) : FabricRecipesProvider
|
|||
.pattern("SDS")
|
||||
.pattern("GRG")
|
||||
.pattern("SDS")
|
||||
.input('S', tag.c("redstone_dusts"))
|
||||
.input('D', tag.c("diamonds"))
|
||||
.input('G', tag.c("gold_ingots"))
|
||||
.input('S', tag("c:redstone_dusts"))
|
||||
.input('D', tag("c:diamonds"))
|
||||
.input('G', tag("c:gold_ingots"))
|
||||
.input('R', Blocks.REQUEST)
|
||||
.criterion(Blocks.REQUEST)
|
||||
.offerTo(exporter)
|
||||
|
|
@ -125,16 +124,16 @@ class RecipeProvider(dataGenerator: FabricDataGenerator) : FabricRecipesProvider
|
|||
.offerTo(exporter)
|
||||
}
|
||||
|
||||
private fun <T> TagFactory<T>.c(path: String): Tag.Identified<T> {
|
||||
return create(Identifier("c", path))
|
||||
private fun tag(id: String): TagKey<Item> {
|
||||
return TagKey.of(Registry.ITEM_KEY, Identifier(id))
|
||||
}
|
||||
|
||||
private fun <T : CraftingRecipeJsonFactory> T.criterion(item: ItemConvertible): T {
|
||||
private fun <T : CraftingRecipeJsonBuilder> T.criterion(item: ItemConvertible): T {
|
||||
criterion(hasItem(item), conditionsFromItem(item))
|
||||
return this
|
||||
}
|
||||
|
||||
private fun <T : CraftingRecipeJsonFactory> T.criterion(item: ItemConvertible, tag: Tag.Identified<Item>): T {
|
||||
private fun <T : CraftingRecipeJsonBuilder> T.criterion(item: ItemConvertible, tag: TagKey<Item>): T {
|
||||
criterion(hasItem(item), conditionsFromTag(tag))
|
||||
return this
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ object StorageFillerItem : Item(ModItem.SETTINGS) {
|
|||
val storage = ItemStorage.SIDED.find(world, pos, Direction.UP)
|
||||
if (storage != null) Transaction.openOuter().use { transaction ->
|
||||
while (true) {
|
||||
val item = Registry.ITEM.getRandom(world.random)
|
||||
val item = Registry.ITEM.getRandom(world.random).get().value()
|
||||
if (storage.insert(ItemVariant.of(item), item.maxCount.toLong(), transaction) == 0L) break
|
||||
}
|
||||
transaction.commit()
|
||||
|
|
|
|||
|
|
@ -7,14 +7,15 @@ import java.util.concurrent.Executor;
|
|||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.WorldGenerationProgressListener;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.registry.RegistryEntry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.PersistentStateManager;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.gen.Spawner;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.ServerWorldProperties;
|
||||
import net.minecraft.world.level.storage.LevelStorage;
|
||||
import net.minecraft.world.spawner.Spawner;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
|
@ -33,7 +34,7 @@ public abstract class ServerWorldMixin implements NetworkStateHolder {
|
|||
private NetworkState networkState;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void slotlink$initNetworkState(MinecraftServer server, Executor workerExecutor, LevelStorage.Session session, ServerWorldProperties properties, RegistryKey<World> worldKey, DimensionType dimensionType, WorldGenerationProgressListener worldGenerationProgressListener, ChunkGenerator chunkGenerator, boolean debugWorld, long seed, List<Spawner> spawners, boolean shouldTickTime, CallbackInfo ci) {
|
||||
private void slotlink$initNetworkState(MinecraftServer server, Executor workerExecutor, LevelStorage.Session session, ServerWorldProperties properties, RegistryKey<World> worldKey, RegistryEntry<DimensionType> registryEntry, WorldGenerationProgressListener worldGenerationProgressListener, ChunkGenerator chunkGenerator, boolean debugWorld, long seed, List<Spawner> spawners, boolean shouldTickTime, CallbackInfo ci) {
|
||||
ServerWorld self = (ServerWorld) (Object) this;
|
||||
networkState = getPersistentStateManager().getOrCreate(nbt -> NetworkState.create(self, nbt), NetworkState::new, "slotlink");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ open class CableBlock(id: String = "cable", be: BlockEntityBuilder = ::CableBloc
|
|||
|
||||
val SETTINGS: Settings = FabricBlockSettings
|
||||
.of(Material.GLASS)
|
||||
.breakByHand(true)
|
||||
.hardness(3f)
|
||||
|
||||
val PROPERTIES = mapOf(
|
||||
|
|
|
|||
|
|
@ -65,10 +65,9 @@ abstract class ConnectorCableBlock(id: String, builder: BlockEntityBuilder) : Ca
|
|||
|
||||
var result = state
|
||||
val connected = state.getNull(CONNECTED)
|
||||
val block = neighborState.block
|
||||
if (connected == direction && neighborState.isAir) {
|
||||
result = result.with(CONNECTED, null)
|
||||
} else if (connected == null && !isIgnored(block)) {
|
||||
} else if (connected == null && !isIgnored(neighborState)) {
|
||||
for (d in DIRECTIONS) {
|
||||
val storage = ItemStorage.SIDED.find(world, neighborPos, d)
|
||||
if (storage != null) {
|
||||
|
|
@ -82,7 +81,7 @@ abstract class ConnectorCableBlock(id: String, builder: BlockEntityBuilder) : Ca
|
|||
return result
|
||||
}
|
||||
|
||||
abstract fun isIgnored(block: Block): Boolean
|
||||
abstract fun isIgnored(blockState: BlockState): Boolean
|
||||
|
||||
override fun appendProperties(builder: StateManager.Builder<Block, BlockState>) {
|
||||
super.appendProperties(builder)
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@ package badasintended.slotlink.block
|
|||
|
||||
import badasintended.slotlink.block.entity.LinkCableBlockEntity
|
||||
import badasintended.slotlink.util.ignoredTag
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.block.BlockState
|
||||
|
||||
class LinkCableBlock : ConnectorCableBlock("link_cable", ::LinkCableBlockEntity) {
|
||||
|
||||
override fun isIgnored(block: Block): Boolean {
|
||||
return ignoredTag.contains(block)
|
||||
override fun isIgnored(blockState: BlockState): Boolean {
|
||||
return blockState.isIn(ignoredTag)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ abstract class ModBlock(id: String, settings: Settings = SETTINGS) : BlockWithEn
|
|||
|
||||
val SETTINGS: Settings = FabricBlockSettings
|
||||
.of(Material.STONE)
|
||||
.breakByHand(true)
|
||||
.hardness(5f)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package badasintended.slotlink.block
|
||||
|
||||
import badasintended.slotlink.util.BlockEntityBuilder
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.block.BlockState
|
||||
import net.minecraft.block.LeverBlock
|
||||
import net.minecraft.util.math.BlockPos
|
||||
|
|
@ -10,7 +9,7 @@ import net.minecraft.world.WorldAccess
|
|||
|
||||
abstract class TransferCableBlock(id: String, builder: BlockEntityBuilder) : ConnectorCableBlock(id, builder) {
|
||||
|
||||
override fun isIgnored(block: Block) = false
|
||||
override fun isIgnored(blockState: BlockState) = false
|
||||
|
||||
override fun connect(
|
||||
state: BlockState,
|
||||
|
|
|
|||
|
|
@ -70,9 +70,8 @@ abstract class ConnectorCableBlockEntity(
|
|||
}
|
||||
|
||||
val linkedState = world.getBlockState(linkedPos)
|
||||
val linkedBlock = linkedState.block
|
||||
|
||||
if (!block.isIgnored(linkedBlock)) {
|
||||
if (!block.isIgnored(linkedState)) {
|
||||
if (apiCache == null) apiCache = BlockApiCache.create(ItemStorage.SIDED, world, linkedPos)
|
||||
val storage = apiCache!!.find(side) ?: return FilteredItemStorage.EMPTY
|
||||
return FilteredItemStorage(filter, blacklist, flag, storage, linkedPos!!)
|
||||
|
|
|
|||
|
|
@ -336,7 +336,7 @@ class RequestScreen<H : RequestScreenHandler>(handler: H, inv: PlayerInventory,
|
|||
} else {
|
||||
searchBar.keyPressed(keyCode, scanCode, modifiers)
|
||||
}
|
||||
} else if (client!!.options.keyChat.matchesKey(keyCode, scanCode)) {
|
||||
} else if (client!!.options.chatKey.matchesKey(keyCode, scanCode)) {
|
||||
skipChar = true
|
||||
searchBar.grab = true
|
||||
true
|
||||
|
|
@ -366,9 +366,9 @@ class RequestScreen<H : RequestScreenHandler>(handler: H, inv: PlayerInventory,
|
|||
return super.mouseScrolled(mouseX, mouseY, amount)
|
||||
}
|
||||
|
||||
override fun onClose() {
|
||||
override fun close() {
|
||||
config.save()
|
||||
super.onClose()
|
||||
super.close()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class MultiSlotWidget(
|
|||
|
||||
override fun onKey(keyCode: Int, scanCode: Int, modifiers: Int): Boolean {
|
||||
if (hovered) {
|
||||
if (client.options.keyDrop.matchesKey(keyCode, scanCode)) {
|
||||
if (client.options.dropKey.matchesKey(keyCode, scanCode)) {
|
||||
c2s(MULTI_SLOT_ACTION) {
|
||||
int(handler.syncId)
|
||||
int(index)
|
||||
|
|
@ -81,7 +81,7 @@ class MultiSlotWidget(
|
|||
}
|
||||
return true
|
||||
}
|
||||
val hotbar = client.options.keysHotbar.indexOfFirst { it.matchesKey(keyCode, scanCode) }
|
||||
val hotbar = client.options.hotbarKeys.indexOfFirst { it.matchesKey(keyCode, scanCode) }
|
||||
if (hotbar >= 0) {
|
||||
c2s(MULTI_SLOT_ACTION) {
|
||||
int(handler.syncId)
|
||||
|
|
|
|||
|
|
@ -687,10 +687,9 @@ open class RequestScreenHandler(
|
|||
|
||||
fun match(view: StorageView<ItemVariant>): Boolean = term.isBlank() || when (first) {
|
||||
'@' -> Registry.ITEM.getId(view.resource.item).toString().contains(term, true)
|
||||
'#' -> player.world.tagManager
|
||||
.getOrCreateTagGroup(Registry.ITEM_KEY)
|
||||
.tags.filterValues { it.contains(view.resource.item) }.keys
|
||||
.any { it.toString().contains(term, true) }
|
||||
'#' -> Registry.ITEM
|
||||
.streamTags()
|
||||
.anyMatch { it.id.toString().contains(term, true) && view.resource.item.registryEntry.isIn(it) }
|
||||
else -> view.resource.toStack().name.string.contains(term, true)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import kotlin.math.ln
|
|||
import kotlin.math.min
|
||||
import kotlin.math.pow
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking
|
||||
import net.fabricmc.fabric.api.tag.TagFactory
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.block.BlockState
|
||||
import net.minecraft.block.entity.BlockEntity
|
||||
|
|
@ -16,11 +15,12 @@ import net.minecraft.item.ItemStack
|
|||
import net.minecraft.network.Packet
|
||||
import net.minecraft.network.PacketByteBuf
|
||||
import net.minecraft.server.network.ServerPlayerEntity
|
||||
import net.minecraft.tag.Tag
|
||||
import net.minecraft.tag.TagKey
|
||||
import net.minecraft.text.TranslatableText
|
||||
import net.minecraft.util.Identifier
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.util.math.Direction
|
||||
import net.minecraft.util.registry.Registry
|
||||
import net.minecraft.util.shape.VoxelShape
|
||||
import net.minecraft.util.shape.VoxelShapes
|
||||
import org.apache.logging.log4j.LogManager
|
||||
|
|
@ -99,7 +99,7 @@ fun s2c(player: PlayerEntity, packet: Packet<*>) {
|
|||
ServerPlayNetworking.getSender(player).sendPacket(packet)
|
||||
}
|
||||
|
||||
val ignoredTag: Tag<Block> = TagFactory.BLOCK.create(modId("ignored"))
|
||||
val ignoredTag: TagKey<Block> = TagKey.of(Registry.BLOCK_KEY, modId("ignored"));
|
||||
|
||||
fun ItemStack.isItemAndTagEqual(other: ItemStack): Boolean {
|
||||
return ItemStack.areItemsEqual(this, other) && ItemStack.areNbtEqual(this, other)
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@
|
|||
},
|
||||
"mixins" : ["slotlink.mixins.json"],
|
||||
"depends" : {
|
||||
"fabricloader" : ">=0.12",
|
||||
"minecraft" : "1.18.x",
|
||||
"fabric" : ">=0.43",
|
||||
"fabricloader" : ">=0.13",
|
||||
"minecraft" : ">=1.18.2",
|
||||
"fabric" : ">=0.47",
|
||||
"fabric-language-kotlin": ">=1.7"
|
||||
},
|
||||
"custom" : {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue