Skip to content

Commit

Permalink
Added new block Auto Illuminator
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiiragi283 committed Nov 12, 2024
1 parent e207457 commit a923572
Show file tree
Hide file tree
Showing 32 changed files with 262 additions and 75 deletions.
4 changes: 3 additions & 1 deletion src/client/kotlin/hiiragi283/ragium/client/RagiumClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ object RagiumClient : ClientModInitializer {
RagiumAPI.id("block/solar_generator"),
)
}
ItemTooltipCallback.EVENT.register(RagiumAPI.id("description")) { stack: ItemStack, _: Item.TooltipContext, _: TooltipType, tooltips: MutableList<Text> ->
ItemTooltipCallback.EVENT.register(
RagiumAPI.id("description"),
) { stack: ItemStack, _: Item.TooltipContext, _: TooltipType, tooltips: MutableList<Text> ->
stack.get(RagiumComponentTypes.DESCRIPTION)?.let(tooltips::add)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "ragium:block/auto_illuminator"
}
}
}
2 changes: 2 additions & 0 deletions src/main/generated/assets/ragium/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"block.ragium.advanced_grate": "Advanced Grate",
"block.ragium.advanced_hull": "Advanced Hull",
"block.ragium.asphalt": "Asphalt",
"block.ragium.auto_illuminator": "Auto Illuminator",
"block.ragium.basic_casing": "Basic Casing",
"block.ragium.basic_coil": "Basic Coil",
"block.ragium.basic_drum": "Basic Drum",
Expand All @@ -34,6 +35,7 @@
"block.ragium.sponge_cake": "Sponge Cake",
"block.ragium.steel_pipe": "Steel Pipe",
"block.ragium.sweet_berries_cake": "Sweet Berries Cake",
"block.ragium.teleport_anchor": "Teleport Anchor",
"block.ragium.trash_box": "Trash Box",
"block.ragium.universal_pipe": "Universal Pipe",
"block.ragium.wooden_pipe": "Wooden Pipe",
Expand Down
2 changes: 2 additions & 0 deletions src/main/generated/assets/ragium/lang/ja_jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"block.ragium.advanced_grate": "発展格子",
"block.ragium.advanced_hull": "発展筐体",
"block.ragium.asphalt": "アスファルト",
"block.ragium.auto_illuminator": "光源置き太郎",
"block.ragium.basic_casing": "基本外装",
"block.ragium.basic_coil": "基本コイル",
"block.ragium.basic_drum": "基本ドラム",
Expand All @@ -34,6 +35,7 @@
"block.ragium.sponge_cake": "スポンジケーキ",
"block.ragium.steel_pipe": "鋼鉄パイプ",
"block.ragium.sweet_berries_cake": "スイートベリーケーキ",
"block.ragium.teleport_anchor": "テレポートアンカー",
"block.ragium.trash_box": "ゴミ箱",
"block.ragium.universal_pipe": "万能パイプ",
"block.ragium.wooden_pipe": "木製パイプ",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "ragium:block/auto_illuminator"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "ragium:block/auto_illuminator"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"values": [
"ragium:porous_netherrack",
"ragium:asphalt",
"ragium:auto_illuminator",
"ragium:large_processor",
"ragium:manual_forge",
"ragium:manual_grinder",
Expand Down
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": "ragium:crimson_crystal"
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "ragium:shaped/auto_illuminator"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_the_recipe",
"has_the_item"
]
],
"rewards": {
"recipes": [
"ragium:shaped/auto_illuminator"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"type": "minecraft:item",
"name": "ragium:auto_illuminator"
}
],
"rolls": 1.0
}
]
}
24 changes: 24 additions & 0 deletions src/main/generated/data/ragium/recipe/shaped/auto_illuminator.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"type": "minecraft:crafting_shaped",
"category": "misc",
"key": {
"A": {
"tag": "c:plates/deep_steel"
},
"B": {
"tag": "c:plates/gold"
},
"C": {
"item": "ragium:crimson_crystal"
}
},
"pattern": [
"ABA",
"BCB",
"ABA"
],
"result": {
"count": 1,
"id": "ragium:auto_illuminator"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"tag": "c:plates/deep_steel"
},
"B": {
"tag": "c:plates/steel"
"tag": "c:plates/aluminum"
},
"C": {
"item": "ragium:warped_crystal"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ object HTStonecuttingRecipeJsonBuilder {
count: Int = 1,
id: Identifier = CraftingRecipeJsonBuilder.getItemId(output),
category: RecipeCategory = RecipeCategory.MISC,
suffix: String = ""
suffix: String = "",
) {
StonecuttingRecipeJsonBuilder.createStonecutting(
Ingredient.ofItems(input),
category,
output,
count
).criterion("has_input", RecipeProvider.conditionsFromItem(input))
StonecuttingRecipeJsonBuilder
.createStonecutting(
Ingredient.ofItems(input),
category,
output,
count,
).criterion("has_input", RecipeProvider.conditionsFromItem(input))
.offerTo(exporter, id.withPrefixedPath("stonecutting/").withSuffixedPath(suffix))
}

Expand All @@ -39,14 +40,15 @@ object HTStonecuttingRecipeJsonBuilder {
count: Int = 1,
id: Identifier = CraftingRecipeJsonBuilder.getItemId(output),
category: RecipeCategory = RecipeCategory.MISC,
suffix: String = ""
suffix: String = "",
) {
StonecuttingRecipeJsonBuilder.createStonecutting(
Ingredient.fromTag(input),
category,
output,
count
).criterion("has_input", RecipeProvider.conditionsFromTag(input))
StonecuttingRecipeJsonBuilder
.createStonecutting(
Ingredient.fromTag(input),
category,
output,
count,
).criterion("has_input", RecipeProvider.conditionsFromTag(input))
.offerTo(exporter, id.withPrefixedPath("stonecutting/").withSuffixedPath(suffix))
}

Expand Down
10 changes: 10 additions & 0 deletions src/main/kotlin/hiiragi283/ragium/api/extension/RagiumUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ fun BlockPos.getAroundPos(filter: (BlockPos) -> Boolean): List<BlockPos> = Direc

// ChunkPos //

fun ChunkPos.iterator(yRange: IntRange): Iterator<BlockPos> = iterator {
(startX..endX).forEach { x: Int ->
(startZ..endZ).forEach { z: Int ->
yRange.forEach { y: Int ->
yield(BlockPos(x, y, z))
}
}
}
}

fun ChunkPos.forEach(yRange: IntRange, action: (BlockPos) -> Unit) {
(startX..endX).forEach { x: Int ->
(startZ..endZ).forEach { z: Int ->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package hiiragi283.ragium.common.block.entity

import hiiragi283.ragium.common.init.RagiumBlockEntityTypes
import net.minecraft.block.BlockState
import net.minecraft.block.Blocks
import net.minecraft.sound.SoundCategory
import net.minecraft.sound.SoundEvents
import net.minecraft.util.math.BlockPos
import net.minecraft.world.World

class HTAutoIlluminatorBlockEntity(pos: BlockPos, state: BlockState) :
HTBlockEntityBase(RagiumBlockEntityTypes.AUTO_ILLUMINATOR, pos, state) {
private val yRange: IntRange
get() = (world?.bottomY ?: 0)..<pos.y

override val tickRate: Int = 1

override fun tickSecond(world: World, pos: BlockPos, state: BlockState) {
for (x: Int in (pos.x - 64..pos.x + 64)) {
for (z: Int in (pos.z - 64..pos.z + 64)) {
for (y: Int in yRange) {
val posIn = BlockPos(x, y, z)
val stateIn: BlockState = world.getBlockState(posIn)
if (stateIn.isAir) {
if (!world.isSkyVisible(posIn) && world.getLightLevel(posIn) <= 7) {
world.setBlockState(posIn, Blocks.LIGHT.defaultState)
return
}
}
}
}
}
world.playSound(null, pos, SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.MASTER, 10.0f, 0.5f)
world.breakBlock(pos, true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ abstract class HTBlockEntityBase(type: BlockEntityType<*>, pos: BlockPos, state:
) {
asInventory()?.let { ItemScatterer.spawn(world, pos, it) }
}

open fun getComparatorOutput(state: BlockState, world: World, pos: BlockPos): Int = 0

open val shouldTick: Boolean = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import net.minecraft.inventory.SidedInventory
import net.minecraft.item.ItemStack
import net.minecraft.sound.SoundCategory
import net.minecraft.util.ActionResult
import net.minecraft.util.Hand
import net.minecraft.util.hit.BlockHitResult
import net.minecraft.util.math.BlockPos
import net.minecraft.world.World
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ class HTPipeBlockEntity(pos: BlockPos, state: BlockState) :
HTPipeType.canConnect(world, pos, dir, type)
} ?: false

override fun onStateReplaced(state: BlockState, world: World, pos: BlockPos, newState: BlockState, moved: Boolean) {
override fun onStateReplaced(
state: BlockState,
world: World,
pos: BlockPos,
newState: BlockState,
moved: Boolean,
) {
ItemStorage.SIDED.find(world, pos, null)?.forEach { view: StorageView<ItemVariant> ->
ItemScatterer.spawn(
world,
Expand All @@ -57,7 +63,7 @@ class HTPipeBlockEntity(pos: BlockPos, state: BlockState) :
}
super.onStateReplaced(state, world, pos, newState, moved)
}

override fun tickSecond(world: World, pos: BlockPos, state: BlockState) {
if (world.isClient) return
// export containment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,22 @@ data class HTDynamiteComponent(val power: Float, val canDestroy: Boolean) : Tool

override fun appendTooltip(context: Item.TooltipContext, tooltip: Consumer<Text>, type: TooltipType) {
tooltip.accept(
Text.translatable(
RagiumTranslationKeys.DYNAMITE_POWER,
floatText(power).formatted(Formatting.WHITE)
).formatted(Formatting.GRAY)
Text
.translatable(
RagiumTranslationKeys.DYNAMITE_POWER,
floatText(power).formatted(Formatting.WHITE),
).formatted(Formatting.GRAY),
)
val destroyText: MutableText = when (canDestroy) {
true -> Text.literal("true").formatted(Formatting.RED)
false -> Text.literal("false").formatted(Formatting.AQUA)
}
tooltip.accept(
Text.translatable(
RagiumTranslationKeys.DYNAMITE_DESTROY,
destroyText
).formatted(Formatting.GRAY)
Text
.translatable(
RagiumTranslationKeys.DYNAMITE_DESTROY,
destroyText,
).formatted(Formatting.GRAY),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ object RagiumBlockEntityTypes {
val CANNING_MACHINE: BlockEntityType<HTCanningMachineBlockEntity> =
register("exporter", ::HTCanningMachineBlockEntity)

@JvmField
val AUTO_ILLUMINATOR: BlockEntityType<HTAutoIlluminatorBlockEntity> =
register("auto_illuminator", ::HTAutoIlluminatorBlockEntity)

@JvmField
val CHEMICAL_PROCESSOR: BlockEntityType<HTProcessorBlockEntityBase.Chemical> =
register("chemical_processor", HTProcessorBlockEntityBase::Chemical)
Expand Down
3 changes: 3 additions & 0 deletions src/main/kotlin/hiiragi283/ragium/common/init/RagiumBlocks.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ object RagiumBlocks : HTContentRegister {
@JvmField
val BACKPACK_INTERFACE: Block = registerBlock("backpack_interface", HTBackpackInterfaceBlock)

@JvmField
val AUTO_ILLUMINATOR: Block = registerWithBE("auto_illuminator", RagiumBlockEntityTypes.AUTO_ILLUMINATOR)

@JvmField
val CREATIVE_SOURCE: Block =
registerWithBE("creative_source", RagiumBlockEntityTypes.CREATIVE_SOURCE, Blocks.COMMAND_BLOCK)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ object RagiumContentRegister : HTContentRegister {
)

registerBlockItem(RagiumBlocks.BACKPACK_INTERFACE)
registerBlockItem(RagiumBlocks.AUTO_ILLUMINATOR)
registerBlockItem(RagiumBlocks.CREATIVE_SOURCE)
registerBlockItem(RagiumBlocks.ITEM_DISPLAY)
registerBlockItem(RagiumBlocks.MANUAL_FORGE)
Expand Down
Loading

0 comments on commit a923572

Please sign in to comment.