diff --git a/src/main/generated/assets/ragium/lang/en_us.json b/src/main/generated/assets/ragium/lang/en_us.json index 3fb2c275..548cfb88 100644 --- a/src/main/generated/assets/ragium/lang/en_us.json +++ b/src/main/generated/assets/ragium/lang/en_us.json @@ -111,9 +111,11 @@ "item.ragium.engineering_plastic_plate": "Engineering Plastic Plate", "item.ragium.filled_fluid_cube": "Fluid Cube (%s)", "item.ragium.flour": "Flour", + "item.ragium.fluid_filter": "Fluid Filter", "item.ragium.forge_hammer": "Forge Hammer", "item.ragium.gigant_hammer": "Gigant Hammer", "item.ragium.heart_of_the_nether": "Heart of the Nether", + "item.ragium.item_filter": "Item Filter", "item.ragium.laser_emitter": "Laser Emitter", "item.ragium.minced_meat": "Minced Meat", "item.ragium.plastic_plate": "Plastic Plate", @@ -125,6 +127,7 @@ "item.ragium.ragi_alloy_compound": "Ragi-Alloy Compound", "item.ragium.ragi_crystal_processor": "Ragi-Crystal Processor", "item.ragium.ragi_ticket": "Ragi-Ticket", + "item.ragium.ragi_wrench": "Ragi-Wrench", "item.ragium.refined_silicon": "Refined Silicon", "item.ragium.residual_coke": "Residual Coke", "item.ragium.silicon": "Silicon", diff --git a/src/main/generated/assets/ragium/lang/ja_jp.json b/src/main/generated/assets/ragium/lang/ja_jp.json index 6d9c2aba..3dc79891 100644 --- a/src/main/generated/assets/ragium/lang/ja_jp.json +++ b/src/main/generated/assets/ragium/lang/ja_jp.json @@ -111,9 +111,11 @@ "item.ragium.engineering_plastic_plate": "エンジニアリングプラスチック板", "item.ragium.filled_fluid_cube": "液体キューブ(%s)", "item.ragium.flour": "小麦粉", + "item.ragium.fluid_filter": "液体フィルタ", "item.ragium.forge_hammer": "鍛造ハンマー", "item.ragium.gigant_hammer": "ギガントハンマー", "item.ragium.heart_of_the_nether": "地獄の心臓", + "item.ragium.item_filter": "アイテムフィルタ", "item.ragium.laser_emitter": "レーザーエミッタ", "item.ragium.minced_meat": "ひき肉", "item.ragium.plastic_plate": "プラスチック板", @@ -125,6 +127,7 @@ "item.ragium.ragi_alloy_compound": "ラギ合金混合物", "item.ragium.ragi_crystal_processor": "ラギクリスタリルプロセッサ", "item.ragium.ragi_ticket": "らぎチケット", + "item.ragium.ragi_wrench": "らぎレンチ", "item.ragium.refined_silicon": "精製シリコン", "item.ragium.residual_coke": "残渣油コークス", "item.ragium.silicon": "シリコン", diff --git a/src/main/generated/assets/ragium/models/item/ragi_wrench.json b/src/main/generated/assets/ragium/models/item/ragi_wrench.json new file mode 100644 index 00000000..c23bc141 --- /dev/null +++ b/src/main/generated/assets/ragium/models/item/ragi_wrench.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "ragium:item/ragi_wrench" + } +} \ No newline at end of file diff --git a/src/main/generated/data/ragium/advancement/recipes/misc/shaped/ragi_wrench.json b/src/main/generated/data/ragium/advancement/recipes/misc/shaped/ragi_wrench.json new file mode 100644 index 00000000..d4152bb4 --- /dev/null +++ b/src/main/generated/data/ragium/advancement/recipes/misc/shaped/ragi_wrench.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_the_item": { + "conditions": { + "items": [ + { + "items": "#c:ingots/ragi_alloy" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "ragium:shaped/ragi_wrench" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_the_item" + ] + ], + "rewards": { + "recipes": [ + "ragium:shaped/ragi_wrench" + ] + } +} \ No newline at end of file diff --git a/src/main/generated/data/ragium/recipe/shaped/ragi_wrench.json b/src/main/generated/data/ragium/recipe/shaped/ragi_wrench.json new file mode 100644 index 00000000..4c70feda --- /dev/null +++ b/src/main/generated/data/ragium/recipe/shaped/ragi_wrench.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "key": { + "A": { + "tag": "c:ingots/ragi_alloy" + } + }, + "pattern": [ + "A A", + "AAA", + " A " + ], + "result": { + "count": 1, + "id": "ragium:ragi_wrench" + } +} \ No newline at end of file diff --git a/src/main/kotlin/hiiragi283/ragium/api/extension/RagiumItemExtensions.kt b/src/main/kotlin/hiiragi283/ragium/api/extension/RagiumItemExtensions.kt index 48c18774..ffee7962 100644 --- a/src/main/kotlin/hiiragi283/ragium/api/extension/RagiumItemExtensions.kt +++ b/src/main/kotlin/hiiragi283/ragium/api/extension/RagiumItemExtensions.kt @@ -41,8 +41,7 @@ fun buildItemStack(item: ItemConvertible?, count: Int = 1, builderAction: Compon fun ItemStack.hasEnchantment(world: WorldView, key: RegistryKey): Boolean = world .getEnchantment(key) ?.let(EnchantmentHelper.getEnchantments(this)::getLevel) - ?.let { it > 0 } - ?: false + ?.let { it > 0 } == true fun ItemStack.isOf(item: ItemConvertible): Boolean = isOf(item.asItem()) diff --git a/src/main/kotlin/hiiragi283/ragium/api/extension/RagiumUtils.kt b/src/main/kotlin/hiiragi283/ragium/api/extension/RagiumUtils.kt index ea9d32f5..6d0ef059 100644 --- a/src/main/kotlin/hiiragi283/ragium/api/extension/RagiumUtils.kt +++ b/src/main/kotlin/hiiragi283/ragium/api/extension/RagiumUtils.kt @@ -31,6 +31,7 @@ import net.minecraft.screen.ScreenHandlerContext import net.minecraft.server.network.ServerPlayerEntity import net.minecraft.server.world.ServerWorld import net.minecraft.text.MutableText +import net.minecraft.text.Style import net.minecraft.text.Text import net.minecraft.text.Texts import net.minecraft.text.TranslatableTextContent @@ -246,5 +247,6 @@ fun boolText(value: Boolean): MutableText = Text.literal(value.toString()) fun Text.hasValidTranslation(): Boolean = (this.content as? TranslatableTextContent) ?.let(TranslatableTextContent::getKey) - ?.let(Language.getInstance()::hasTranslation) - ?: false + ?.let(Language.getInstance()::hasTranslation) == true + +inline fun buildStyle(builderAction: Style.() -> Unit): Style = Style.EMPTY.apply(builderAction) diff --git a/src/main/kotlin/hiiragi283/ragium/api/machine/HTMachineTier.kt b/src/main/kotlin/hiiragi283/ragium/api/machine/HTMachineTier.kt index 9a8f4427..3e007c21 100644 --- a/src/main/kotlin/hiiragi283/ragium/api/machine/HTMachineTier.kt +++ b/src/main/kotlin/hiiragi283/ragium/api/machine/HTMachineTier.kt @@ -157,7 +157,7 @@ enum class HTMachineTier( fun canProcess(world: World): Boolean = canProcess(world.energyNetwork) fun canProcess(network: HTEnergyNetwork?, multiplier: Long = 1): Boolean = - network?.amount?.let { it >= recipeCost * multiplier } ?: false + network?.amount?.let { it >= recipeCost * multiplier } == true fun consumerEnergy(world: World, parent: TransactionContext? = null, multiplier: Long = 1): Boolean { useTransaction(parent) { transaction: Transaction -> diff --git a/src/main/kotlin/hiiragi283/ragium/api/storage/HTStorageBuilder.kt b/src/main/kotlin/hiiragi283/ragium/api/storage/HTStorageBuilder.kt index ccdd71bb..4db0d514 100644 --- a/src/main/kotlin/hiiragi283/ragium/api/storage/HTStorageBuilder.kt +++ b/src/main/kotlin/hiiragi283/ragium/api/storage/HTStorageBuilder.kt @@ -83,7 +83,7 @@ class HTStorageBuilder(val size: Int) { override fun getAvailableSlots(side: Direction): IntArray = slotsMapper(side) override fun canInsert(slot: Int, stack: ItemStack, dir: Direction?): Boolean = - dir?.let { ioMapper(slot).canInsert && slot in slotsMapper(it) } ?: false + dir?.let { ioMapper(slot).canInsert && slot in slotsMapper(it) } == true override fun canExtract(slot: Int, stack: ItemStack, dir: Direction): Boolean = ioMapper(slot).canExtract && slot in slotsMapper(dir) diff --git a/src/main/kotlin/hiiragi283/ragium/common/block/HTExporterBlock.kt b/src/main/kotlin/hiiragi283/ragium/common/block/HTExporterBlock.kt index 02b9ac14..14788cab 100644 --- a/src/main/kotlin/hiiragi283/ragium/common/block/HTExporterBlock.kt +++ b/src/main/kotlin/hiiragi283/ragium/common/block/HTExporterBlock.kt @@ -18,7 +18,8 @@ import net.minecraft.util.BlockRotation import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction -class HTExporterBlock(private val tier: HTMachineTier) : HTBlockWithEntity(blockSettings().solid().nonOpaque()) { +class HTExporterBlock(private val tier: HTMachineTier) : + HTBlockWithEntity(blockSettings().solid().nonOpaque().strength(2f, 6f)) { init { defaultState = stateManager.defaultState.with(Properties.FACING, Direction.NORTH) } diff --git a/src/main/kotlin/hiiragi283/ragium/common/block/HTPipeBlock.kt b/src/main/kotlin/hiiragi283/ragium/common/block/HTPipeBlock.kt index ed34fa59..5474d7af 100644 --- a/src/main/kotlin/hiiragi283/ragium/common/block/HTPipeBlock.kt +++ b/src/main/kotlin/hiiragi283/ragium/common/block/HTPipeBlock.kt @@ -15,13 +15,16 @@ import net.minecraft.item.tooltip.TooltipType import net.minecraft.state.StateManager import net.minecraft.state.property.Properties import net.minecraft.text.Text +import net.minecraft.util.BlockMirror +import net.minecraft.util.BlockRotation import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction import net.minecraft.util.shape.VoxelShape import net.minecraft.world.BlockView import net.minecraft.world.WorldAccess -class HTPipeBlock(private val tier: HTMachineTier, private val type: HTPipeType) : HTBlockWithEntity(blockSettings().solid().nonOpaque()) { +class HTPipeBlock(private val tier: HTMachineTier, private val type: HTPipeType) : + HTBlockWithEntity(blockSettings().solid().nonOpaque().strength(2f, 6f)) { companion object { @JvmField val SHAPE: VoxelShape = createCuboidShape(4.0, 4.0, 4.0, 12.0, 12.0, 12.0) @@ -75,6 +78,11 @@ class HTPipeBlock(private val tier: HTMachineTier, private val type: HTPipeType) .with(Properties.WEST, HTPipeType.canConnect(ctx.world, ctx.blockPos, Direction.WEST, type)) .with(Properties.EAST, HTPipeType.canConnect(ctx.world, ctx.blockPos, Direction.EAST, type)) + override fun rotate(state: BlockState, rotation: BlockRotation): BlockState = + state.with(Properties.FACING, rotation.rotate(state.get(Properties.FACING))) + + override fun mirror(state: BlockState, mirror: BlockMirror): BlockState = state.rotate(mirror.getRotation(state.get(Properties.FACING))) + override fun getStateForNeighborUpdate( state: BlockState, direction: Direction, @@ -84,7 +92,7 @@ class HTPipeBlock(private val tier: HTMachineTier, private val type: HTPipeType) neighborPos: BlockPos, ): BlockState = state.with( ConnectingBlock.FACING_PROPERTIES[direction], - (world.getBlockEntity(pos) as? HTPipeBlockEntity)?.canConnect(direction) ?: false, + (world.getBlockEntity(pos) as? HTPipeBlockEntity)?.canConnect(direction) == true, ) override fun createBlockEntity(pos: BlockPos, state: BlockState): BlockEntity = HTPipeBlockEntity(pos, state, tier, type) diff --git a/src/main/kotlin/hiiragi283/ragium/common/block/entity/HTPipeBlockEntity.kt b/src/main/kotlin/hiiragi283/ragium/common/block/entity/HTPipeBlockEntity.kt index 04107d7e..e99c3b7b 100644 --- a/src/main/kotlin/hiiragi283/ragium/common/block/entity/HTPipeBlockEntity.kt +++ b/src/main/kotlin/hiiragi283/ragium/common/block/entity/HTPipeBlockEntity.kt @@ -42,7 +42,7 @@ class HTPipeBlockEntity(pos: BlockPos, state: BlockState) : fun canConnect(dir: Direction): Boolean = ifPresentWorld { world: World -> HTPipeType.canConnect(world, pos, dir, type) - } ?: false + } == true override fun onStateReplaced( state: BlockState, diff --git a/src/main/kotlin/hiiragi283/ragium/common/init/RagiumEventHandlers.kt b/src/main/kotlin/hiiragi283/ragium/common/init/RagiumEventHandlers.kt index 3e476650..22f1c42e 100644 --- a/src/main/kotlin/hiiragi283/ragium/common/init/RagiumEventHandlers.kt +++ b/src/main/kotlin/hiiragi283/ragium/common/init/RagiumEventHandlers.kt @@ -14,6 +14,7 @@ import hiiragi283.ragium.api.screen.HTMachineScreenHandlerBase import hiiragi283.ragium.common.RagiumContents import net.fabricmc.fabric.api.event.lifecycle.v1.ServerEntityEvents import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents +import net.fabricmc.fabric.api.event.player.UseBlockCallback import net.fabricmc.fabric.api.item.v1.DefaultItemComponentEvents import net.minecraft.advancement.AdvancementEntry import net.minecraft.block.BlockState @@ -22,6 +23,7 @@ import net.minecraft.entity.Entity import net.minecraft.entity.EquipmentSlot import net.minecraft.entity.LivingEntity import net.minecraft.entity.effect.StatusEffects +import net.minecraft.entity.player.PlayerEntity import net.minecraft.item.ItemConvertible import net.minecraft.item.ItemStack import net.minecraft.recipe.Recipe @@ -32,10 +34,11 @@ import net.minecraft.recipe.input.SingleStackRecipeInput import net.minecraft.server.MinecraftServer import net.minecraft.server.network.ServerPlayerEntity import net.minecraft.server.world.ServerWorld +import net.minecraft.state.property.Properties import net.minecraft.text.MutableText import net.minecraft.text.Text -import net.minecraft.util.Formatting -import net.minecraft.util.Rarity +import net.minecraft.util.* +import net.minecraft.util.hit.BlockHitResult import net.minecraft.util.math.BlockPos import net.minecraft.world.World @@ -230,19 +233,30 @@ object RagiumEventHandlers { } } - /*UseBlockCallback.EVENT.register { player: PlayerEntity, world: World, hand: Hand, result: BlockHitResult -> + // rotate block by ragi-wrench + UseBlockCallback.EVENT.register { player: PlayerEntity, world: World, hand: Hand, result: BlockHitResult -> val stack: ItemStack = player.getStackInHand(hand) - if (stack.hasEnchantments() && world.getBlockState(result.blockPos).isOf(Blocks.CRYING_OBSIDIAN)) { - stack.enchantments - .toLevelMap() - .map(EnchantedBookItem::forEnchantment) - .onEach { dropStackAt(player, it) } - stack.remove(DataComponentTypes.ENCHANTMENTS) - ActionResult.success(world.isClient) - } else { - ActionResult.PASS + if (stack.isOf(RagiumItems.RAGI_WRENCH)) { + val pos: BlockPos = result.blockPos + val state: BlockState = world.getBlockState(pos) + val rotated: BlockState = when (player.isSneaking) { + true -> { + if (Properties.FACING in state) { + state.with(Properties.FACING, result.side) + } else state + } + + false -> state.rotate(BlockRotation.COUNTERCLOCKWISE_90) + } + if (rotated != state) { + if (!world.isClient) { + world.setBlockState(pos, rotated) + } + return@register ActionResult.success(world.isClient) + } } - }*/ + ActionResult.PASS + } } @JvmStatic diff --git a/src/main/kotlin/hiiragi283/ragium/common/init/RagiumItems.kt b/src/main/kotlin/hiiragi283/ragium/common/init/RagiumItems.kt index bf3d5e3d..6e883be7 100644 --- a/src/main/kotlin/hiiragi283/ragium/common/init/RagiumItems.kt +++ b/src/main/kotlin/hiiragi283/ragium/common/init/RagiumItems.kt @@ -207,6 +207,9 @@ object RagiumItems { @JvmField val ITEM_FILTER: Item = Item(itemSettings()) + @JvmField + val RAGI_WRENCH: Item = Item(itemSettings()) + @JvmField val STEEL_AXE: Item = HTToolType.AXE.createToolItem(RagiumToolMaterials.STEEL) @@ -245,6 +248,7 @@ object RagiumItems { FILLED_FLUID_CUBE, FLUID_FILTER, ITEM_FILTER, + RAGI_WRENCH, TRADER_CATALOG, ) diff --git a/src/main/kotlin/hiiragi283/ragium/common/internal/RagiumContentRegister.kt b/src/main/kotlin/hiiragi283/ragium/common/internal/RagiumContentRegister.kt index ee314763..34820bcc 100644 --- a/src/main/kotlin/hiiragi283/ragium/common/internal/RagiumContentRegister.kt +++ b/src/main/kotlin/hiiragi283/ragium/common/internal/RagiumContentRegister.kt @@ -260,6 +260,7 @@ internal object RagiumContentRegister { registerItem("ragi_alloy_compound", RagiumItems.RAGI_ALLOY_COMPOUND) registerItem("ragi_crystal_processor", RagiumItems.RAGI_CRYSTAL_PROCESSOR) registerItem("ragi_ticket", RagiumItems.RAGI_TICKET) + registerItem("ragi_wrench", RagiumItems.RAGI_WRENCH) registerItem("refined_silicon", RagiumItems.REFINED_SILICON) registerItem("residual_coke", RagiumItems.RESIDUAL_COKE) registerItem("silicon", RagiumItems.SILICON) diff --git a/src/main/kotlin/hiiragi283/ragium/data/RagiumLangProviders.kt b/src/main/kotlin/hiiragi283/ragium/data/RagiumLangProviders.kt index 82bdb412..cd5d204c 100644 --- a/src/main/kotlin/hiiragi283/ragium/data/RagiumLangProviders.kt +++ b/src/main/kotlin/hiiragi283/ragium/data/RagiumLangProviders.kt @@ -258,9 +258,11 @@ object RagiumLangProviders { builder.add(RagiumItems.ENGINE, "V8 Engine") builder.add(RagiumItems.ENGINEERING_PLASTIC_PLATE, "Engineering Plastic Plate") builder.add(RagiumItems.FILLED_FLUID_CUBE, "Fluid Cube (%s)") + builder.add(RagiumItems.FLUID_FILTER, "Fluid Filter") builder.add(RagiumItems.FORGE_HAMMER, "Forge Hammer") builder.add(RagiumItems.GIGANT_HAMMER, "Gigant Hammer") builder.add(RagiumItems.HEART_OF_THE_NETHER, "Heart of the Nether") + builder.add(RagiumItems.ITEM_FILTER, "Item Filter") builder.add(RagiumItems.LASER_EMITTER, "Laser Emitter") builder.add(RagiumItems.PLASTIC_PLATE, "Plastic Plate") builder.add(RagiumItems.POLYMER_RESIN, "Polymer Resin") @@ -268,6 +270,7 @@ object RagiumLangProviders { builder.add(RagiumItems.RAGI_ALLOY_COMPOUND, "Ragi-Alloy Compound") builder.add(RagiumItems.RAGI_CRYSTAL_PROCESSOR, "Ragi-Crystal Processor") builder.add(RagiumItems.RAGI_TICKET, "Ragi-Ticket") + builder.add(RagiumItems.RAGI_WRENCH, "Ragi-Wrench") builder.add(RagiumItems.REFINED_SILICON, "Refined Silicon") builder.add(RagiumItems.RESIDUAL_COKE, "Residual Coke") builder.add(RagiumItems.SILICON, "Silicon") @@ -527,9 +530,11 @@ object RagiumLangProviders { builder.add(RagiumItems.ENGINE, "V8エンジン") builder.add(RagiumItems.ENGINEERING_PLASTIC_PLATE, "エンジニアリングプラスチック板") builder.add(RagiumItems.FILLED_FLUID_CUBE, "液体キューブ(%s)") + builder.add(RagiumItems.FLUID_FILTER, "液体フィルタ") builder.add(RagiumItems.FORGE_HAMMER, "鍛造ハンマー") builder.add(RagiumItems.GIGANT_HAMMER, "ギガントハンマー") builder.add(RagiumItems.HEART_OF_THE_NETHER, "地獄の心臓") + builder.add(RagiumItems.ITEM_FILTER, "アイテムフィルタ") builder.add(RagiumItems.LASER_EMITTER, "レーザーエミッタ") builder.add(RagiumItems.PLASTIC_PLATE, "プラスチック板") builder.add(RagiumItems.POLYMER_RESIN, "高分子樹脂") @@ -537,6 +542,7 @@ object RagiumLangProviders { builder.add(RagiumItems.RAGI_ALLOY_COMPOUND, "ラギ合金混合物") builder.add(RagiumItems.RAGI_CRYSTAL_PROCESSOR, "ラギクリスタリルプロセッサ") builder.add(RagiumItems.RAGI_TICKET, "らぎチケット") + builder.add(RagiumItems.RAGI_WRENCH, "らぎレンチ") builder.add(RagiumItems.REFINED_SILICON, "精製シリコン") builder.add(RagiumItems.RESIDUAL_COKE, "残渣油コークス") builder.add(RagiumItems.SILICON, "シリコン") diff --git a/src/main/kotlin/hiiragi283/ragium/data/recipe/RagiumVanillaRecipeProvider.kt b/src/main/kotlin/hiiragi283/ragium/data/recipe/RagiumVanillaRecipeProvider.kt index cc04d50c..47b18c27 100644 --- a/src/main/kotlin/hiiragi283/ragium/data/recipe/RagiumVanillaRecipeProvider.kt +++ b/src/main/kotlin/hiiragi283/ragium/data/recipe/RagiumVanillaRecipeProvider.kt @@ -191,6 +191,16 @@ class RagiumVanillaRecipeProvider(output: FabricDataOutput, registriesFuture: Co .input('B', ConventionalItemTags.WOODEN_RODS) .unlockedBy(RagiumContents.Gems.RAGIUM) .offerTo(exporter) + + HTShapedRecipeJsonBuilder + .create(RagiumItems.RAGI_WRENCH) + .patterns( + "A A", + "AAA", + " A ", + ).input('A', RagiumContents.Ingots.RAGI_ALLOY) + .unlockedBy(RagiumContents.Ingots.RAGI_ALLOY) + .offerTo(exporter) // filter HTShapelessRecipeJsonBuilder .create(RagiumItems.FLUID_FILTER) diff --git a/src/main/resources/assets/ragium/textures/item/ragi_wrench.png b/src/main/resources/assets/ragium/textures/item/ragi_wrench.png new file mode 100644 index 00000000..df813ba5 Binary files /dev/null and b/src/main/resources/assets/ragium/textures/item/ragi_wrench.png differ