Skip to content

Commit

Permalink
Added new item Ragi-Wrench
Browse files Browse the repository at this point in the history
Added strength for pipes and exporters
  • Loading branch information
Hiiragi283 committed Nov 18, 2024
1 parent d515ebb commit 3619a7b
Show file tree
Hide file tree
Showing 18 changed files with 130 additions and 23 deletions.
3 changes: 3 additions & 0 deletions src/main/generated/assets/ragium/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions src/main/generated/assets/ragium/lang/ja_jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "プラスチック板",
Expand All @@ -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": "シリコン",
Expand Down
6 changes: 6 additions & 0 deletions src/main/generated/assets/ragium/models/item/ragi_wrench.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "ragium:item/ragi_wrench"
}
}
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
18 changes: 18 additions & 0 deletions src/main/generated/data/ragium/recipe/shaped/ragi_wrench.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ fun buildItemStack(item: ItemConvertible?, count: Int = 1, builderAction: Compon
fun ItemStack.hasEnchantment(world: WorldView, key: RegistryKey<Enchantment>): 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())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
12 changes: 10 additions & 2 deletions src/main/kotlin/hiiragi283/ragium/common/block/HTPipeBlock.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/main/kotlin/hiiragi283/ragium/common/init/RagiumItems.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -245,6 +248,7 @@ object RagiumItems {
FILLED_FLUID_CUBE,
FLUID_FILTER,
ITEM_FILTER,
RAGI_WRENCH,
TRADER_CATALOG,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions src/main/kotlin/hiiragi283/ragium/data/RagiumLangProviders.kt
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,19 @@ 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")
builder.add(RagiumItems.PROCESSOR_SOCKET, "Processor Socket")
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")
Expand Down Expand Up @@ -527,16 +530,19 @@ 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, "高分子樹脂")
builder.add(RagiumItems.PROCESSOR_SOCKET, "プロセッサソケット")
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, "シリコン")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3619a7b

Please sign in to comment.