init Project#2

This commit is contained in:
叁玖领域 2025-02-23 01:24:16 +08:00
parent 1ec72a4873
commit b1efbe3a32
1982 changed files with 72407 additions and 3 deletions

View File

@ -139,9 +139,9 @@ dependencies {
// If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"],
// then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
compileOnly files("lib/modernlife.jar")
implementation 'org.spongepowered:mixin:0.8.5'
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
compileOnly files("libs/modernlife-1.20.1-1.74.jar")
// Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}-common-api:${jei_version}")

Binary file not shown.

View File

@ -0,0 +1,5 @@
// 1.20.1 2025-02-22T12:37:42.6884778 Item Models: modernlifepatch
1eabd9e17c204afaa5e461373e76704b469b1551 assets/modernlifepatch/models/item/large_mirror.json
ddf31e8377fca2bb97fef098a294a7473b56bd96 assets/modernlifepatch/models/item/massive_mirror.json
bd757d611e2b5cac8731ae51b0b8ce0d77da80ae assets/modernlifepatch/models/item/mirror.json
9d0fdb4d53d6cf9e86d1f98aeb9f23f9310a9ec7 assets/modernlifepatch/models/item/tall_mirror.json

View File

@ -0,0 +1,2 @@
// 1.20.1 2025-02-22T12:37:42.6884778 Languages: zh_cn
b86030154fc971c84b41c6267f947721dfc55fb7 assets/modernlifepatch/lang/zh_cn.json

View File

@ -0,0 +1,5 @@
// 1.20.1 2025-02-22T12:37:42.6884778 Loot Tables
1ee070aa7f3d869c7610d021206ae1a3d680d050 data/modernlifepatch/loot_tables/blocks/large_mirror.json
1b5b1090f47e29526af1cd0df979d4f216abeb07 data/modernlifepatch/loot_tables/blocks/massive_mirror.json
384f868a4d71fa14dafb4bdca2fd0fd877507025 data/modernlifepatch/loot_tables/blocks/mirror.json
c76a70b5a42ede00cb92bdc4f5c292bb6c961071 data/modernlifepatch/loot_tables/blocks/tall_mirror.json

View File

@ -0,0 +1,9 @@
// 1.20.1 2025-02-23T01:22:49.9804054 Recipes
829d226e46b965c74cdc812972e5e4a6feee89d3 data/modernlifepatch/advancements/recipes/decorations/large_mirror.json
9d1914bb2bddd1bbadd0b58f3f7e5eb992f984c8 data/modernlifepatch/advancements/recipes/decorations/massive_mirror.json
e31f330892c0abe33cce7f858b1e2cb23125e29c data/modernlifepatch/advancements/recipes/decorations/mirror.json
1a1423565c4e8c9d2b2a4157c61ab00ea154e474 data/modernlifepatch/advancements/recipes/decorations/tall_mirror.json
c7af367b61d30ea781a72a6a72e86677bc5b0136 data/modernlifepatch/recipes/large_mirror.json
89bab02b61801049313724df763ab216dbf1f09c data/modernlifepatch/recipes/massive_mirror.json
28133e9320816c3ffc37e11191f19dffd41da17c data/modernlifepatch/recipes/mirror.json
fc2a0f648922c5e671df5e33e7634c1a54c78739 data/modernlifepatch/recipes/tall_mirror.json

View File

@ -0,0 +1 @@
// 1.20.1 2025-02-22T12:37:42.7086672 Tags for minecraft:item mod id modernlifepatch

View File

@ -0,0 +1 @@
// 1.20.1 2025-02-22T12:37:42.7086672 Tags for minecraft:block mod id modernlifepatch

View File

@ -0,0 +1 @@
// 1.20.1 2025-02-22T12:37:42.6884778 Block States: modernlifepatch

View File

@ -0,0 +1,2 @@
// 1.20.1 2025-02-22T12:37:42.7041161 Languages: en_us
72c73ed767b25aa4259ae5b89aae7150a81411fb assets/modernlifepatch/lang/en_us.json

View File

@ -0,0 +1,98 @@
{
"block.modernlifepatch.large_mirror": "Large Mirror",
"block.modernlifepatch.massive_mirror": "Massive Mirror",
"block.modernlifepatch.mirror": "Mirror",
"block.modernlifepatch.tall_mirror": "Tall Mirror",
"gui.tag_filter.modernlifepatch.bathroom": "BathRoom",
"gui.tag_filter.modernlifepatch.bedchamber": "Bedchamber",
"gui.tag_filter.modernlifepatch.door": "Door",
"gui.tag_filter.modernlifepatch.general": "General",
"gui.tag_filter.modernlifepatch.kitchen": "Kitchen",
"gui.tag_filter.modernlifepatch.lounge": "Lounge",
"gui.tag_filter.modernlifepatch.m_tool": "Tool",
"gui.tag_filter.modernlifepatch.outside": "Outside",
"gui.tag_filter.modernlifepatch.seat": "Seat",
"gui.tag_filter.modernlifepatch.shelf": "Shelf",
"gui.tag_filter.modernlifepatch.table": "Table",
"itemGroup.modernlifepatch": "Modern Life Patch",
"modernlifepatch.lang.battery.hover_text.0": "Right click to recharge flashlight (battery will be consumed)",
"modernlifepatch.lang.bicycle.hover_text.0": "Right click to deploy",
"modernlifepatch.lang.bookshelf.hover_text.1": "Right click tp place a book on the shelf",
"modernlifepatch.lang.bookshelf.hover_text.2": "Shift-right-click with an empty hand to remove a book",
"modernlifepatch.lang.camera.hover_text.1": "%d/%d photos stored in memory card",
"modernlifepatch.lang.camera.hover_text.2": "* Does not break when durability hits 0",
"modernlifepatch.lang.camera.hover_text.3": "* Take to a printer to print your photos",
"modernlifepatch.lang.canvas.hover_text.block_size": "%f x %f ",
"modernlifepatch.lang.canvas.hover_text.custom_size": "Custom print",
"modernlifepatch.lang.canvas.hover_text.desc_completed": "A work of art",
"modernlifepatch.lang.canvas.hover_text.desc_empty": "For use with an easel",
"modernlifepatch.lang.canvas.hover_text.extra_large_size": "Extra Large print",
"modernlifepatch.lang.canvas.hover_text.extra_large_square_size": "Extra Large square",
"modernlifepatch.lang.canvas.hover_text.large_size": "Large print",
"modernlifepatch.lang.canvas.hover_text.large_square_size": "Large square print",
"modernlifepatch.lang.canvas.hover_text.massive_size": "Massive print",
"modernlifepatch.lang.canvas.hover_text.massive_square_size": "Massive square print",
"modernlifepatch.lang.canvas.hover_text.normal_size": "Normal print",
"modernlifepatch.lang.canvas.hover_text.offset": "(%f,%f)",
"modernlifepatch.lang.canvas.hover_text.pixels_size": "%d x %d pixels",
"modernlifepatch.lang.canvas.hover_text.unique_id": "ID = %d",
"modernlifepatch.lang.chainsaw.hover_text.1": "Right click to use",
"modernlifepatch.lang.chainsaw.hover_text.2": "* Highly effective on trees an leaves",
"modernlifepatch.lang.chess.modernlifepatch.bishop": "Bishop",
"modernlifepatch.lang.chess.modernlifepatch.king": "King",
"modernlifepatch.lang.chess.modernlifepatch.knight": "Knight",
"modernlifepatch.lang.chess.modernlifepatch.pawn": "Pawn",
"modernlifepatch.lang.chess.modernlifepatch.queen": "Queen",
"modernlifepatch.lang.chess.modernlifepatch.rook": "Rook",
"modernlifepatch.lang.chess_board.hover_text.0": "PLace it down and begin a new game!",
"modernlifepatch.lang.easel.hover_text.0": "Place a canvas on it to begin painting",
"modernlifepatch.lang.extractor.hover_text.0": "Extracts items from attached chests or from the space in front of it",
"modernlifepatch.lang.flashlight.hover_text.1": "Right click to use",
"modernlifepatch.lang.flashlight.hover_text.2": "* Using it will deplete the battery but it will not break",
"modernlifepatch.lang.flashlight.hover_text.3": "* %s minutes remaining before drained",
"modernlifepatch.lang.flashlight.hover_text.4": "* Lasts %s minutes at full charge",
"modernlifepatch.lang.flashlight.hover_text.5": "* Repair durability by using a battery",
"modernlifepatch.lang.gui.button.modernlifepatch.disable_filters": "Disable Filters",
"modernlifepatch.lang.gui.button.modernlifepatch.enable_filters": "Enable Filters",
"modernlifepatch.lang.gui.button.modernlifepatch.scroll_filter_down": "Scroll down",
"modernlifepatch.lang.gui.button.modernlifepatch.scroll_filter_up": "Scroll up",
"modernlifepatch.lang.guitar.hover_text.1": "Right click to use",
"modernlifepatch.lang.guitar.hover_text.2": "* Standard Tuning (EADGBE)",
"modernlifepatch.lang.guitar_amplifier.hover_text.0": "Play a guitar nearby to add a distortion effect",
"modernlifepatch.lang.handgun.hover_text.1": "Left click to fire",
"modernlifepatch.lang.handgun.hover_text.2": "Right click to aim down sights",
"modernlifepatch.lang.handgun.hover_text.3": "* Requires at least one Magazine in order to shoot",
"modernlifepatch.lang.menu.kitchen_cabinet": "Kitchen Cabinet",
"modernlifepatch.lang.menu.kitchen_drawer_cabinet": "Kitchen Drawer Cabinet",
"modernlifepatch.lang.menu.night_stand": "Night Stand",
"modernlifepatch.lang.menu.photo_copier": "Photocopier",
"modernlifepatch.lang.menu.print_size": "Print Size",
"modernlifepatch.lang.menu.printer": "Printer",
"modernlifepatch.lang.menu.radiator": "Radiator",
"modernlifepatch.lang.menu.refrigerator": "refrigerator",
"modernlifepatch.lang.menu.seed_spreader": "Seed Spreader",
"modernlifepatch.lang.menu.trash_can": "Trash Can",
"modernlifepatch.lang.metal_grate.hover_text.0": "Allows water and items to flow through freely",
"modernlifepatch.lang.motorboat.hover_text.1": "Right click to deploy",
"modernlifepatch.lang.motorboat.hover_text.2": "Remaining fuel: %f%%",
"modernlifepatch.lang.motorboat.hover_text.3": "Refuel by using a gas can on the deployed boat",
"modernlifepatch.lang.need_rs_power.hover_text.0": "Requires redstone power to operate",
"modernlifepatch.lang.paved_road.hover_text.0": "Slightly increases movement speed of vehicles",
"modernlifepatch.lang.photocopier.hover_text.1": "Interact with a canvas or photograph to make copies",
"modernlifepatch.lang.photocopier.hover_text.2": " * Requires paper",
"modernlifepatch.lang.power_receiver.hover_text.1": "Receives power on the selected channel from all transmitters",
"modernlifepatch.lang.power_receiver.hover_text.2": "Right click block to change current channel",
"modernlifepatch.lang.power_transmitter.hover_text.1": "Transmits power on the selected channel to all receivers",
"modernlifepatch.lang.resource_pack.modernlifepatch.description": "All of textures and models are created by BF_Meow_Do not use for other purposes without permission.",
"modernlifepatch.lang.road_marker.hover_text.1": "* Right click paved road to apply currently selected road marker",
"modernlifepatch.lang.road_marker.hover_text.2": "* Right click elsewhere to toggle between available road markers",
"modernlifepatch.lang.seed_spreader.hover_text.0": "Automatically disperses seeds that are put inside of it",
"modernlifepatch.lang.steam_radiator.hover_text.0": "Right click placed radiator to activate",
"modernlifepatch.lang.store_18.hover_text.0": "Stores up to 18 items",
"modernlifepatch.lang.trash_can.hover_text.0": "Items inserted into the trash slot will be deleted when the trash can is full",
"modernlifepatch.lang.turn_table.hover_text.0": "Rotates clockwise when powered by redstone",
"modernlifepatch.lang.wall_shelf.hover_text.1": "Right click tp place an item on the shelf",
"modernlifepatch.lang.wall_shelf.hover_text.2": "Shift-right-click with an empty hand to remove an item",
"modernlifepatch.unknown": "Unknown",
"resource.modernlifepatch.modern_life_patch": "§b§lModern Life §fExclusive Materials"
}

View File

@ -0,0 +1,98 @@
{
"block.modernlifepatch.large_mirror": "大型镜子",
"block.modernlifepatch.massive_mirror": "超大型镜子",
"block.modernlifepatch.mirror": "镜子",
"block.modernlifepatch.tall_mirror": "高镜子",
"gui.tag_filter.modernlifepatch.bathroom": "卫生间",
"gui.tag_filter.modernlifepatch.bedchamber": "寝室",
"gui.tag_filter.modernlifepatch.door": "门",
"gui.tag_filter.modernlifepatch.general": "普通",
"gui.tag_filter.modernlifepatch.kitchen": "厨房",
"gui.tag_filter.modernlifepatch.lounge": "客厅",
"gui.tag_filter.modernlifepatch.m_tool": "工具",
"gui.tag_filter.modernlifepatch.outside": "户外",
"gui.tag_filter.modernlifepatch.seat": "坐具",
"gui.tag_filter.modernlifepatch.shelf": "架子",
"gui.tag_filter.modernlifepatch.table": "桌子",
"itemGroup.modernlifepatch": "摩登生活补丁",
"modernlifepatch.lang.battery.hover_text.0": "右键消耗为手电筒更换电池",
"modernlifepatch.lang.bicycle.hover_text.0": "右键放置",
"modernlifepatch.lang.bookshelf.hover_text.1": "右键以放置书在书架上",
"modernlifepatch.lang.bookshelf.hover_text.2": "空手按住Shift键+右键即可取下书",
"modernlifepatch.lang.camera.hover_text.1": "内存卡里照片数: %d/%d",
"modernlifepatch.lang.camera.hover_text.2": "* 当耐久掉到0时也不会损坏",
"modernlifepatch.lang.camera.hover_text.3": "* 提供打印机把所拍照冲洗出来",
"modernlifepatch.lang.canvas.hover_text.block_size": "%f x %f",
"modernlifepatch.lang.canvas.hover_text.custom_size": "自定义尺寸画作",
"modernlifepatch.lang.canvas.hover_text.desc_completed": "艺术品",
"modernlifepatch.lang.canvas.hover_text.desc_empty": "可用画架来创作",
"modernlifepatch.lang.canvas.hover_text.extra_large_size": "超大型尺寸画作",
"modernlifepatch.lang.canvas.hover_text.extra_large_square_size": "超大型方寸画作",
"modernlifepatch.lang.canvas.hover_text.large_size": "大型尺寸画作",
"modernlifepatch.lang.canvas.hover_text.large_square_size": "大型方寸画作",
"modernlifepatch.lang.canvas.hover_text.massive_size": "巨大尺寸的画作",
"modernlifepatch.lang.canvas.hover_text.massive_square_size": "巨大方寸画作",
"modernlifepatch.lang.canvas.hover_text.normal_size": "常规尺寸画作",
"modernlifepatch.lang.canvas.hover_text.offset": "(%f,%f)",
"modernlifepatch.lang.canvas.hover_text.pixels_size": "%d x %d 像素",
"modernlifepatch.lang.canvas.hover_text.unique_id": "ID = %d",
"modernlifepatch.lang.chainsaw.hover_text.1": "右键使用",
"modernlifepatch.lang.chainsaw.hover_text.2": "* 一种极其高效砍树方案",
"modernlifepatch.lang.chess.modernlifepatch.bishop": "象",
"modernlifepatch.lang.chess.modernlifepatch.king": "国王",
"modernlifepatch.lang.chess.modernlifepatch.knight": "骑士",
"modernlifepatch.lang.chess.modernlifepatch.pawn": "士兵",
"modernlifepatch.lang.chess.modernlifepatch.queen": "皇后",
"modernlifepatch.lang.chess.modernlifepatch.rook": "车",
"modernlifepatch.lang.chess_board.hover_text.0": "放置后使用即可开始一场新游戏!",
"modernlifepatch.lang.easel.hover_text.0": "放置(帆布)画布在其上,即可开始绘画",
"modernlifepatch.lang.extractor.hover_text.0": "从其吸取端处的箱子或空间中取出物品",
"modernlifepatch.lang.flashlight.hover_text.1": "右键使用",
"modernlifepatch.lang.flashlight.hover_text.2": "* 使用它会耗尽电池,但不会损坏",
"modernlifepatch.lang.flashlight.hover_text.3": "* 电量耗尽前剩余%s分钟",
"modernlifepatch.lang.flashlight.hover_text.4": "* 一节满电电池可以为其提供至少%s分钟的照亮时间",
"modernlifepatch.lang.flashlight.hover_text.5": "* 通过电池来修复耐久",
"modernlifepatch.lang.gui.button.modernlifepatch.disable_filters": "禁用过滤器",
"modernlifepatch.lang.gui.button.modernlifepatch.enable_filters": "启用过滤器",
"modernlifepatch.lang.gui.button.modernlifepatch.scroll_filter_down": "向下",
"modernlifepatch.lang.gui.button.modernlifepatch.scroll_filter_up": "向上",
"modernlifepatch.lang.guitar.hover_text.1": "右键使用",
"modernlifepatch.lang.guitar.hover_text.2": "* 标准调谐EADGBE",
"modernlifepatch.lang.guitar_amplifier.hover_text.0": "在附近弹奏吉他以增加失真效果",
"modernlifepatch.lang.handgun.hover_text.1": "左键开火",
"modernlifepatch.lang.handgun.hover_text.2": "右键聚焦对准",
"modernlifepatch.lang.handgun.hover_text.3": "* 需要至少一个弹匣来发射",
"modernlifepatch.lang.menu.kitchen_cabinet": "厨房柜子",
"modernlifepatch.lang.menu.kitchen_drawer_cabinet": "厨房抽屉柜",
"modernlifepatch.lang.menu.night_stand": "床头柜",
"modernlifepatch.lang.menu.photo_copier": "复印机",
"modernlifepatch.lang.menu.print_size": "打印尺寸",
"modernlifepatch.lang.menu.printer": "打印机",
"modernlifepatch.lang.menu.radiator": "蒸汽散热器",
"modernlifepatch.lang.menu.refrigerator": "冰箱",
"modernlifepatch.lang.menu.seed_spreader": "播种器",
"modernlifepatch.lang.menu.trash_can": "垃圾桶",
"modernlifepatch.lang.metal_grate.hover_text.0": "允许水与物品自由地穿过",
"modernlifepatch.lang.motorboat.hover_text.1": "右键放置",
"modernlifepatch.lang.motorboat.hover_text.2": "燃料剩余量: %f%%",
"modernlifepatch.lang.motorboat.hover_text.3": "对船使用汽油罐来加油",
"modernlifepatch.lang.need_rs_power.hover_text.0": "需要红石充能",
"modernlifepatch.lang.paved_road.hover_text.0": "载具在该路上行驶,移速会有所提升",
"modernlifepatch.lang.photocopier.hover_text.1": "可以用于照片或画作的复制",
"modernlifepatch.lang.photocopier.hover_text.2": " * 需要纸",
"modernlifepatch.lang.power_receiver.hover_text.1": "从所有能量发射器中去接收所选工作频道的能量",
"modernlifepatch.lang.power_receiver.hover_text.2": "右键方块打开界面,来切换工作频道",
"modernlifepatch.lang.power_transmitter.hover_text.1": "将红石信号传输给对应频道的所有能量接收器",
"modernlifepatch.lang.resource_pack.modernlifepatch.description": "所有材质和模型均由 白帆小喵BF_Meow_ 绘制。未经允许,请勿用作他用。",
"modernlifepatch.lang.road_marker.hover_text.1": "* 右键单击已铺设的道路以应用当前选定的道路标记",
"modernlifepatch.lang.road_marker.hover_text.2": "* 右键单击其他位置以在可用道路标记之间切换",
"modernlifepatch.lang.seed_spreader.hover_text.0": "自动播种机器里的种子",
"modernlifepatch.lang.steam_radiator.hover_text.0": "右键已放置的散热器,即可激活",
"modernlifepatch.lang.store_18.hover_text.0": "可存储18组物品",
"modernlifepatch.lang.trash_can.hover_text.0": "当垃圾桶已满时,进入垃圾桶的物品将被删除",
"modernlifepatch.lang.turn_table.hover_text.0": "当有红石充能时顺时针旋转",
"modernlifepatch.lang.wall_shelf.hover_text.1": "右键以放置物品在墙架上",
"modernlifepatch.lang.wall_shelf.hover_text.2": "空手按住Shift键+右键即可取下物品",
"modernlifepatch.unknown": "未知",
"resource.modernlifepatch.modern_life_patch": "§b§l摩登生活 §f专属材质"
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "modernlifepatch:item/large_mirror_item"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "modernlifepatch:item/massive_mirror_item"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "modernlifepatch:item/mirror_item"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "modernlifepatch:item/tall_mirror_item"
}
}

View File

@ -0,0 +1,35 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_item_mirror": {
"conditions": {
"items": [
{
"items": [
"modernlifepatch:mirror"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "modernlifepatch:large_mirror"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_item_mirror",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"modernlifepatch:large_mirror"
]
},
"sends_telemetry_event": false
}

View File

@ -0,0 +1,35 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_item_mirror": {
"conditions": {
"items": [
{
"items": [
"modernlifepatch:mirror"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "modernlifepatch:massive_mirror"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_item_mirror",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"modernlifepatch:massive_mirror"
]
},
"sends_telemetry_event": false
}

View File

@ -0,0 +1,33 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_item_glass_pane": {
"conditions": {
"items": [
{
"tag": "forge:glass_panes"
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "modernlifepatch:mirror"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_item_glass_pane",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"modernlifepatch:mirror"
]
},
"sends_telemetry_event": false
}

View File

@ -0,0 +1,35 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_item_mirror": {
"conditions": {
"items": [
{
"items": [
"modernlifepatch:mirror"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "modernlifepatch:tall_mirror"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_item_mirror",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"modernlifepatch:tall_mirror"
]
},
"sends_telemetry_event": false
}

View File

@ -0,0 +1,21 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"type": "minecraft:item",
"name": "modernlifepatch:large_mirror"
}
],
"rolls": 1.0
}
],
"random_sequence": "modernlifepatch:blocks/large_mirror"
}

View File

@ -0,0 +1,21 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"type": "minecraft:item",
"name": "modernlifepatch:massive_mirror"
}
],
"rolls": 1.0
}
],
"random_sequence": "modernlifepatch:blocks/massive_mirror"
}

View File

@ -0,0 +1,21 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"type": "minecraft:item",
"name": "modernlifepatch:mirror"
}
],
"rolls": 1.0
}
],
"random_sequence": "modernlifepatch:blocks/mirror"
}

View File

@ -0,0 +1,21 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"type": "minecraft:item",
"name": "modernlifepatch:tall_mirror"
}
],
"rolls": 1.0
}
],
"random_sequence": "modernlifepatch:blocks/tall_mirror"
}

View File

@ -0,0 +1,17 @@
{
"type": "minecraft:crafting_shaped",
"category": "misc",
"key": {
"@": {
"item": "modernlifepatch:mirror"
}
},
"pattern": [
"@@",
"@@"
],
"result": {
"item": "modernlifepatch:large_mirror"
},
"show_notification": true
}

View File

@ -0,0 +1,17 @@
{
"type": "minecraft:crafting_shaped",
"category": "misc",
"key": {
"@": {
"item": "modernlifepatch:mirror"
}
},
"pattern": [
"@@@",
"@@@"
],
"result": {
"item": "modernlifepatch:massive_mirror"
},
"show_notification": true
}

View File

@ -0,0 +1,18 @@
{
"type": "minecraft:crafting_shapeless",
"category": "misc",
"ingredients": [
{
"tag": "forge:glass_panes"
},
{
"item": "minecraft:iron_ingot"
},
{
"tag": "minecraft:wooden_slabs"
}
],
"result": {
"item": "modernlifepatch:mirror"
}
}

View File

@ -0,0 +1,17 @@
{
"type": "minecraft:crafting_shaped",
"category": "misc",
"key": {
"@": {
"item": "modernlifepatch:mirror"
}
},
"pattern": [
"@",
"@"
],
"result": {
"item": "modernlifepatch:tall_mirror"
},
"show_notification": true
}

View File

@ -0,0 +1,31 @@
package com.r3944realms.modernlifepatch;
import com.r3944realms.modernlifepatch.client.blockentity.MirrorBlockEntityRenderer;
import com.r3944realms.modernlifepatch.content.blocks.entities.ModBlockEntityType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.EntityRenderersEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
public abstract class ClientEventHandler {
// @net.minecraftforge.fml.common.Mod.EventBusSubscriber(value = Dist.CLIENT, bus = net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.FORGE, modid = ModernLifePatch.MOD_ID)
public static class Game extends ClientEventHandler {
}
@net.minecraftforge.fml.common.Mod.EventBusSubscriber(value = Dist.CLIENT, bus = net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.MOD, modid = ModernLifePatch.MOD_ID)
public static class Mod extends ClientEventHandler {
@SubscribeEvent
@OnlyIn(Dist.CLIENT)
public static void onClientSetup(FMLClientSetupEvent event) {
event.enqueueWork(() -> {
});
}
@SubscribeEvent
public static void onRegisterRenderer (EntityRenderersEvent.RegisterRenderers event) {
event.registerBlockEntityRenderer(ModBlockEntityType.MIRROR.get(), MirrorBlockEntityRenderer::new);
}
}
}

View File

@ -0,0 +1,52 @@
package com.r3944realms.modernlifepatch;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.PackResources;
import net.minecraft.server.packs.PackType;
import net.minecraft.server.packs.repository.Pack;
import net.minecraft.server.packs.repository.PackSource;
import net.minecraftforge.event.AddPackFindersEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.forgespi.locating.IModFile;
import net.minecraftforge.resource.PathPackResources;
import java.nio.file.Path;
import static com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue.MOD_RESOURCE_DESC;
import static com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue.MOD_RESOURCE_NAME;
public abstract class CommonEventHandler {
// @net.minecraftforge.fml.common.Mod.EventBusSubscriber(bus = net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.FORGE, modid = ModernLifePatch.MOD_ID)
public static class Game extends CommonEventHandler {
}
@net.minecraftforge.fml.common.Mod.EventBusSubscriber(bus = net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.MOD, modid = ModernLifePatch.MOD_ID)
public static class Mod extends CommonEventHandler {
@SubscribeEvent
public static void onCommonSetup(FMLCommonSetupEvent event) {
event.enqueueWork(() -> {
});
}
@SubscribeEvent
public static void onRegisterResourcePack(AddPackFindersEvent event) {
IModFile modFile = ModList.get().getModFileById(ModernLifePatch.MOD_ID).getFile();
Path modFilePath = modFile.findResource("resourcepacks/modernlifepatch");
event.addRepositorySource(consumer -> {
Pack pack = Pack.readMetaAndCreate(
new ResourceLocation(ModernLifePatch.MOD_ID, "modernlifepatch").toString(),
Component.translatable(MOD_RESOURCE_NAME.getKey()),
true,
name -> new PathPackResources(name, true, modFilePath),
PackType.CLIENT_RESOURCES,
Pack.Position.TOP,
PackSource.BUILT_IN
);
if(pack != null) consumer.accept(pack);
});
}
}
}

View File

@ -1,10 +1,28 @@
package com.r3944realms.modernlifepatch;
import com.r3944realms.modernlifepatch.content.blocks.ModBlocks;
import com.r3944realms.modernlifepatch.content.blocks.entities.ModBlockEntityType;
import com.r3944realms.modernlifepatch.content.item.ModItems;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static com.r3944realms.modernlifepatch.ModernLifePatch.MOD_ID;
@Mod(value = MOD_ID)
public class ModernLifePatch {
public static final String MOD_ID = "modernlifepatch";
public static final Logger logger = LoggerFactory.getLogger(ModernLifePatch.class);
public final static boolean isModernLifeLoaded = ModList.get().isLoaded("modernlife");
public ModernLifePatch() {
MinecraftForge.EVENT_BUS.register(this);
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
ModItems.ITEMS.register(modEventBus);
ModBlocks.BLOCKS.register(modEventBus);
ModBlockEntityType.BLOCK_ENTITY_TYPE.register(modEventBus);
}
}

View File

@ -0,0 +1,22 @@
package com.r3944realms.modernlifepatch.client.blockentity;
import com.mojang.blaze3d.vertex.PoseStack;
import com.r3944realms.modernlifepatch.content.blocks.entities.type.mirror.MirrorBlockEntity;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.jetbrains.annotations.NotNull;
@OnlyIn(Dist.CLIENT)
public class MirrorBlockEntityRenderer implements BlockEntityRenderer<MirrorBlockEntity> {
public MirrorBlockEntityRenderer(BlockEntityRendererProvider.Context context) {
}
@Override
public void render(@NotNull MirrorBlockEntity pBlockEntity, float pPartialTick, @NotNull PoseStack pPoseStack, @NotNull MultiBufferSource pBufferSource, int pPackedLight, int pPackedOverlay) {
}
}

View File

@ -0,0 +1,35 @@
package com.r3944realms.modernlifepatch.content.blocks;
import com.r3944realms.modernlifepatch.ModernLifePatch;
import com.r3944realms.modernlifepatch.content.blocks.type.mirror.MirrorBlock;
import com.r3944realms.modernlifepatch.content.blocks.type.mirror.MirrorPart;
import com.r3944realms.modernlifepatch.content.item.ModItems;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
public class ModBlocks {
public static final DeferredRegister<Block> BLOCKS
= DeferredRegister.create(ForgeRegistries.BLOCKS, ModernLifePatch.MOD_ID);
public static final RegistryObject<MirrorBlock> MIRROR = BLOCKS.register("mirror",
() -> new MirrorBlock(BlockBehaviour.Properties.copy(Blocks.GLASS), MirrorPart.MirrorType.COMMON_MIRROR));
public static final RegistryObject<MirrorBlock> TALL_MIRROR = BLOCKS.register("tall_mirror",
() -> new MirrorBlock(BlockBehaviour.Properties.copy(Blocks.GLASS), MirrorPart.MirrorType.TELL_MIRROR));
public static final RegistryObject<MirrorBlock> LARGE_MIRROR= BLOCKS.register("large_mirror",
() -> new MirrorBlock(BlockBehaviour.Properties.copy(Blocks.GLASS), MirrorPart.MirrorType.LARGE_MIRROR));
public static final RegistryObject<MirrorBlock> MASSIVE_MIRROR = BLOCKS.register("massive_mirror" ,
() -> new MirrorBlock(BlockBehaviour.Properties.copy(Blocks.GLASS), MirrorPart.MirrorType.MASSIVE_MIRROR));
@SuppressWarnings("UnusedReturnValue")
public static <T extends Block> RegistryObject<BlockItem> registerBlockItem(String name , RegistryObject<T> block){
return ModItems.ITEMS.register(name,() -> new BlockItem(block.get(),new Item.Properties()));
}
public static void register(IEventBus bus) {
BLOCKS.register(bus);
}
}

View File

@ -0,0 +1,8 @@
package com.r3944realms.modernlifepatch.content.blocks.blockstate;
import com.r3944realms.modernlifepatch.content.blocks.type.mirror.MirrorPart;
import net.minecraft.world.level.block.state.properties.EnumProperty;
public class ModBlockStateProperties {
public final static EnumProperty<MirrorPart> MIRROR_PART = EnumProperty.create("mirror_part", MirrorPart.class);
}

View File

@ -0,0 +1,23 @@
package com.r3944realms.modernlifepatch.content.blocks.entities;
import com.r3944realms.modernlifepatch.ModernLifePatch;
import com.r3944realms.modernlifepatch.content.blocks.ModBlocks;
import com.r3944realms.modernlifepatch.content.blocks.entities.type.mirror.MirrorBlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import java.util.Set;
public class ModBlockEntityType {
public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITY_TYPE
= DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, ModernLifePatch.MOD_ID);
@SuppressWarnings("DataFlowIssue")
public static final RegistryObject<BlockEntityType<MirrorBlockEntity>> MIRROR
= BLOCK_ENTITY_TYPE.register("mirror", () -> new BlockEntityType<>(MirrorBlockEntity::new, Set.of(ModBlocks.MIRROR.get()), null));
public static void register(IEventBus bus) {
BLOCK_ENTITY_TYPE.register(bus);
}
}

View File

@ -0,0 +1,12 @@
package com.r3944realms.modernlifepatch.content.blocks.entities.type.mirror;
import com.r3944realms.modernlifepatch.content.blocks.entities.ModBlockEntityType;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
public class MirrorBlockEntity extends BlockEntity {
public MirrorBlockEntity(BlockPos pPos, BlockState pBlockState) {
super(ModBlockEntityType.MIRROR.get(), pPos, pBlockState);
}
}

View File

@ -0,0 +1,341 @@
package com.r3944realms.modernlifepatch.content.blocks.type.mirror;
import com.r3944realms.modernlifepatch.content.blocks.blockstate.ModBlockStateProperties;
import com.r3944realms.modernlifepatch.content.blocks.entities.type.mirror.MirrorBlockEntity;
import com.r3944realms.modernlifepatch.content.blocks.type.mirror.shape.IMirrorShape;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class MirrorBlock extends HorizontalDirectionalBlock implements EntityBlock, SimpleWaterloggedBlock {
public static final EnumProperty<MirrorPart> PART = ModBlockStateProperties.MIRROR_PART;
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public final MirrorPart.MirrorType mirrorType;
public MirrorBlock(Properties pProperties, MirrorPart.@NotNull MirrorType mirrorType) {
super(pProperties);
MirrorPart mirrorPart = null;
this.mirrorType = mirrorType;
switch (mirrorType) {
case COMMON_MIRROR -> mirrorPart = MirrorPart.SINGLE;
case TELL_MIRROR -> mirrorPart = MirrorPart.FOOT;
case LARGE_MIRROR -> mirrorPart = MirrorPart.FOOT_LEFT;
case MASSIVE_MIRROR -> mirrorPart = MirrorPart.F11;
}
this.registerDefaultState(this.stateDefinition.any().setValue(PART, mirrorPart).setValue(WATERLOGGED, false));
}
@Override
public @NotNull FluidState getFluidState(@NotNull BlockState pState) {
return pState.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState();
}
// 控制是否能够在该放置放置方块 如果不能满足放置要求则返回null借鉴于原版的梯子方块
@Nullable
@Override
public BlockState getStateForPlacement(@NotNull BlockPlaceContext pContext) {
final BlockPos clickedPos = pContext.getClickedPos();
final Level level = pContext.getLevel();
final Direction horizontalDirection = pContext.getHorizontalDirection();
FluidState fluidState$Root = pContext.getLevel().getFluidState(clickedPos);
return switch (mirrorType) {
case COMMON_MIRROR -> {
// 检查后部分是否有合法的支撑方块
BlockPos behind = clickedPos.relative(horizontalDirection);
boolean flag = !level.getBlockState(behind).isAir() && level.getBlockState(behind).isSolidRender(level, behind);
yield flag ? this.defaultBlockState().setValue(FACING, horizontalDirection).setValue(WATERLOGGED, fluidState$Root.getType() == Fluids.WATER) : null;
}
case TELL_MIRROR -> {
// 检查上部分是不是有阻挡
BlockPos above = clickedPos.above();
boolean flag1 = level.getBlockState(above).canBeReplaced(pContext);
// 检查上部分是否有合法的支撑方块
BlockPos relative = above.relative(horizontalDirection);
boolean flag2 = !level.getBlockState(relative).isAir() && level.getBlockState(relative).isSolidRender(level, relative);
yield flag1 && flag2 ? this.defaultBlockState().setValue(FACING, horizontalDirection).setValue(WATERLOGGED, fluidState$Root.getType() == Fluids.WATER) : null;
}
case LARGE_MIRROR -> {
// 检查空间是否足够2x2
BlockPos headLeft = clickedPos.above(),
footRight = clickedPos.relative(pContext.getHorizontalDirection().getCounterClockWise().getOpposite()),
headRight = footRight.above();
boolean flag1 = level.getBlockState(headLeft).canBeReplaced(pContext) &&
level.getBlockState(footRight).canBeReplaced(pContext) &&
level.getBlockState(headRight).canBeReplaced(pContext);
// 检查其它部分是否有合法的支撑方块
BlockPos headLeftSupport = headLeft.relative(horizontalDirection),
headRightSupport = headRight.relative(horizontalDirection),
footRightSupport = footRight.relative(horizontalDirection);
boolean flag2 = (!level.getBlockState(headLeftSupport).isAir() && level.getBlockState(headLeftSupport).isSolidRender(level, headLeftSupport)) &&
(!level.getBlockState(footRightSupport).isAir() && level.getBlockState(footRightSupport).isSolidRender(level, footRightSupport)) &&
(!level.getBlockState(headRightSupport).isAir() && level.getBlockState(headRightSupport).isSolidRender(level, headRightSupport));
yield flag1 && flag2 ? this.defaultBlockState().setValue(FACING, horizontalDirection).setValue(WATERLOGGED, fluidState$Root.getType() == Fluids.WATER) : null;
}
case MASSIVE_MIRROR -> {
// 检查空间是否足够2x3
BlockPos footLeft = clickedPos.relative(pContext.getHorizontalDirection().getCounterClockWise()),
headLeft = footLeft.above(),
footRight = clickedPos.relative(pContext.getHorizontalDirection().getCounterClockWise().getOpposite()),
headMiddle = clickedPos.above(),
headRight = footRight.above();
boolean flag1 = level.getBlockState(headLeft).canBeReplaced(pContext) &&
level.getBlockState(footRight).canBeReplaced(pContext) &&
level.getBlockState(footLeft).canBeReplaced(pContext) &&
level.getBlockState(headMiddle).canBeReplaced(pContext) &&
level.getBlockState(headRight).canBeReplaced(pContext);
// 检查其它部分是否有合法的支撑方块
BlockPos headLeftSupport = headLeft.relative(horizontalDirection),
headMiddleSupport = headMiddle.relative(horizontalDirection),
headRightSupport = headRight.relative(horizontalDirection),
footLeftSupport = footLeft.relative(horizontalDirection),
footRightSupport = footRight.relative(horizontalDirection);
boolean flag2 = (!level.getBlockState(headLeftSupport).isAir() && level.getBlockState(headLeftSupport).isSolidRender(level, headLeftSupport)) &&
(!level.getBlockState(footRightSupport).isAir() && level.getBlockState(footRightSupport).isSolidRender(level, footRightSupport)) &&
(!level.getBlockState(headRightSupport).isAir() && level.getBlockState(headRightSupport).isSolidRender(level, headRightSupport)) &&
(!level.getBlockState(headMiddleSupport).isAir() && level.getBlockState(headMiddleSupport).isSolidRender(level, headMiddleSupport)) &&
(!level.getBlockState(footLeftSupport).isAir() && level.getBlockState(footLeftSupport).isSolidRender(level, footLeftSupport));
yield flag1 && flag2 ? this.defaultBlockState().setValue(FACING, horizontalDirection).setValue(WATERLOGGED, fluidState$Root.getType() == Fluids.WATER) : null;
}
};
}
// 控制当方块结构不完整时破坏另一结构的方块借鉴于于原版的床破坏逻辑
@Override
public @NotNull BlockState updateShape(@NotNull BlockState pState, @NotNull Direction pDirection, @NotNull BlockState pNeighborState, @NotNull LevelAccessor pLevel, @NotNull BlockPos pCurrentPos, @NotNull BlockPos pNeighborPos) {
if (pState.getValue(WATERLOGGED)) {
pLevel.scheduleTick(pCurrentPos, Fluids.WATER, Fluids.WATER.getTickDelay(pLevel));
}
final boolean canSelfNotSurvive = !pState.canSurvive(pLevel, pCurrentPos);
final Direction facing = pState.getValue(FACING);
final MirrorPart part = pState.getValue(PART);
return switch (mirrorType) {
case COMMON_MIRROR -> (pDirection == facing && canSelfNotSurvive) ?
Blocks.AIR.defaultBlockState() : pState;
case TELL_MIRROR -> {
boolean isFoot = part == MirrorPart.FOOT;
BlockPos otherPartPos = isFoot ? pCurrentPos.above() : pCurrentPos.below();
BlockState otherPartState = pLevel.getBlockState(otherPartPos);
// 当自身无法存活时检查另一部分是否存在并一起破坏
boolean flag = otherPartState.is(this) && otherPartState.getValue(PART) == (isFoot ? MirrorPart.HEAD : MirrorPart.FOOT);
if (canSelfNotSurvive) {
// 破坏自身
pLevel.destroyBlock(pCurrentPos, true);
// 若另一部分存在则破坏另一部分
pLevel.destroyBlock(otherPartPos, false);
yield Blocks.AIR.defaultBlockState();
}
if(!flag) {
pLevel.destroyBlock(otherPartPos, true);
pLevel.destroyBlock(pCurrentPos, false);
}
yield flag ? pState : Blocks.AIR.defaultBlockState();
}
case LARGE_MIRROR -> {
boolean isMainPart = part == MirrorPart.FOOT_LEFT;
BlockPos[] dependentPositions = (isMainPart ? getAllLargeMirrorPosByMainPos(pCurrentPos, facing) : findLargeMirrorMainPartPositions(pCurrentPos, pState));
// 统一处理所有关联部件
boolean flag = canSelfNotSurvive || isAnyCriticalPartMissing(pLevel, dependentPositions);
if (canSelfNotSurvive) {
pLevel.destroyBlock(pCurrentPos, true);
destroyEntireStructure(pLevel, pCurrentPos, dependentPositions);
} else if(isAnyCriticalPartMissing(pLevel, dependentPositions)) {
pLevel.destroyBlock(pCurrentPos, false);
destroyEntireStructure(pLevel, pCurrentPos, dependentPositions);
}
yield flag ?
Blocks.AIR.defaultBlockState() : pState;
}
case MASSIVE_MIRROR -> {
boolean isMainPart = part == MirrorPart.F11;
BlockPos[] dependentPositions = isMainPart ? getAllMassiveMirrorPartsPosByMainPos(pCurrentPos, facing) : findMassiveMirrorMainPartPositions(pCurrentPos, pState);
// 统一处理所有关联部件
boolean flag = canSelfNotSurvive || isAnyCriticalPartMissing(pLevel, dependentPositions);
if (canSelfNotSurvive) {
pLevel.destroyBlock(pCurrentPos, true);
destroyEntireStructure(pLevel, pCurrentPos, dependentPositions);
} else if(isAnyCriticalPartMissing(pLevel, dependentPositions)) {
pLevel.destroyBlock(pCurrentPos, false);
destroyEntireStructure(pLevel, pCurrentPos, dependentPositions);
}
yield flag ?
Blocks.AIR.defaultBlockState() : pState;
}
};
}
// 控制实体放置一部分方块后自动放置另一部分借鉴于于原版的床放置逻辑
@Override
public void setPlacedBy(@NotNull Level pLevel, @NotNull BlockPos pPos, @NotNull BlockState pState, @Nullable LivingEntity pPlacer, @NotNull ItemStack pStack) {
super.setPlacedBy(pLevel, pPos, pState, pPlacer, pStack);
if(!pLevel.isClientSide) {
final Direction facing = pState.getValue(FACING);
switch (mirrorType) {
case COMMON_MIRROR -> {
//NOOP
}
case TELL_MIRROR -> {
BlockPos blockpos = pPos.above();
pLevel.setBlock(blockpos, pState.setValue(PART, MirrorPart.HEAD).setValue(WATERLOGGED, pLevel.getFluidState(blockpos).getType() == Fluids.WATER), Block.UPDATE_ALL);
pLevel.blockUpdated(pPos, Blocks.AIR);
pState.updateNeighbourShapes(pLevel, pPos, Block.UPDATE_ALL);
}
case LARGE_MIRROR -> {
BlockPos headLeft = pPos.above(), footRight = pPos.relative(facing.getCounterClockWise().getOpposite()), headRight = footRight.above();
pLevel.setBlock(headLeft, pState.setValue(PART, MirrorPart.HEAD_LEFT).setValue(WATERLOGGED, pLevel.getFluidState(headLeft).getType() == Fluids.WATER), Block.UPDATE_ALL);
pLevel.setBlock(footRight, pState.setValue(PART, MirrorPart.FOOT_RIGHT).setValue(WATERLOGGED, pLevel.getFluidState(footRight).getType() == Fluids.WATER), Block.UPDATE_ALL);
pLevel.setBlock(headRight, pState.setValue(PART, MirrorPart.HEAD_RIGHT).setValue(WATERLOGGED, pLevel.getFluidState(headRight).getType() == Fluids.WATER), Block.UPDATE_ALL);
pLevel.blockUpdated(pPos, Blocks.AIR);
pState.updateNeighbourShapes(pLevel, pPos, Block.UPDATE_ALL);
}
case MASSIVE_MIRROR -> {
BlockPos h01 = pPos.above(),
f10 = pPos.relative(facing.getCounterClockWise()),
f12 = pPos.relative(facing.getCounterClockWise().getOpposite()),
h00 = f10.above(),
h02 = f12.above();
pLevel.setBlock(h00, pState.setValue(PART, MirrorPart.H00).setValue(WATERLOGGED, pLevel.getFluidState(h00).getType() == Fluids.WATER), Block.UPDATE_ALL);
pLevel.setBlock(f10, pState.setValue(PART, MirrorPart.F10).setValue(WATERLOGGED, pLevel.getFluidState(f10).getType() == Fluids.WATER), Block.UPDATE_ALL);
pLevel.setBlock(h01, pState.setValue(PART, MirrorPart.H01).setValue(WATERLOGGED, pLevel.getFluidState(h01).getType() == Fluids.WATER), Block.UPDATE_ALL);
pLevel.setBlock(f12, pState.setValue(PART, MirrorPart.F12).setValue(WATERLOGGED, pLevel.getFluidState(f12).getType() == Fluids.WATER), Block.UPDATE_ALL);
pLevel.setBlock(h02, pState.setValue(PART, MirrorPart.H02).setValue(WATERLOGGED, pLevel.getFluidState(h02).getType() == Fluids.WATER), Block.UPDATE_ALL);
pLevel.blockUpdated(pPos, Blocks.AIR);
pState.updateNeighbourShapes(pLevel, pPos, Block.UPDATE_ALL);
}
}
}
}
private BlockPos @NotNull [] findMassiveMirrorMainPartPositions(BlockPos currentPos, @NotNull BlockState state) {
Direction facing = state.getValue(FACING);
MirrorPart part = state.getValue(PART);
// 根据部件类型反向计算主部件位置
return switch (part) {
case H00 -> getAllMassiveMirrorPartsPosByMainPos(currentPos.relative(facing.getClockWise()).below(), facing);
case H01 -> getAllMassiveMirrorPartsPosByMainPos(currentPos.below(), facing);
case H02 -> getAllMassiveMirrorPartsPosByMainPos(currentPos.relative(facing.getClockWise().getOpposite()).below(),facing);
case F10 -> getAllMassiveMirrorPartsPosByMainPos(currentPos.relative(facing.getClockWise()), facing);
case F12 -> getAllMassiveMirrorPartsPosByMainPos(currentPos.relative(facing.getClockWise().getOpposite()), facing);
default -> throw new IllegalStateException("Unexpected value: " + part);
};
}
// 辅助方法获取MASSIVE_MIRROR所有部件坐标
private BlockPos @NotNull [] getAllMassiveMirrorPartsPosByMainPos(@NotNull BlockPos origin, @NotNull Direction facing) {
BlockPos f10 = origin.relative(facing.getCounterClockWise());
BlockPos f12 = origin.relative(facing.getCounterClockWise().getOpposite());
return new BlockPos[]{
f10, // F10
f10.above(), // H00
origin, // F11
origin.above(), // H01
f12, // F12
f12.above() // H02
};
}
// 辅助方法破坏整个结构
private void destroyEntireStructure(LevelAccessor level, BlockPos currentPos, BlockPos @NotNull [] parts) {
for (BlockPos pos : parts) {
if (pos.equals(currentPos)) continue; // 跳过当前已处理的方块
if (level.getBlockState(pos).getBlock() == this) {
level.destroyBlock(pos, false);
}
}
}
// 辅助方法检查关键部件是否缺失
private boolean isAnyCriticalPartMissing(LevelAccessor level, BlockPos @NotNull [] parts) {
for (BlockPos pos : parts) {
if (!level.getBlockState(pos).is(this)) {
return true;
}
}
return false;
}
/**
*
* @return [0]->FL [1]->HL [2]->FR [3]->HR
*/
private static BlockPos @NotNull [] getAllLargeMirrorPosByMainPos(@NotNull BlockPos pCurrentPos, @NotNull Direction facing) {
BlockPos footRight = pCurrentPos.relative(facing.getCounterClockWise().getOpposite());
return new BlockPos[]{pCurrentPos, pCurrentPos.above(), footRight, footRight.above()};
}
// 用于LARGE_MIRROR反向查找主部件并以此组装有序的数组
private BlockPos @NotNull [] findLargeMirrorMainPartPositions(BlockPos currentPos, @NotNull BlockState state) {
Direction facing = state.getValue(FACING);
MirrorPart part = state.getValue(PART);
// 根据部件类型反向计算主部件位置
return switch (part) {
case HEAD_LEFT -> getAllLargeMirrorPosByMainPos(currentPos.below(), facing);
case FOOT_RIGHT -> getAllLargeMirrorPosByMainPos(currentPos.relative(facing.getClockWise().getOpposite()), facing);
case HEAD_RIGHT -> getAllLargeMirrorPosByMainPos(currentPos.below().relative(facing.getClockWise().getOpposite()),facing);
default -> throw new IllegalStateException("Unexpected value: " + part);
};
}
@Override
public @NotNull VoxelShape getShape(@NotNull BlockState pState, @NotNull BlockGetter pLevel, @NotNull BlockPos pPos, @NotNull CollisionContext pContext) {
MirrorPart part = pState.getValue(PART);
Direction direction = pState.getValue(FACING);
return IMirrorShape.getShapeInstanceByPart(part).getShapeByPart(direction, part);
}
@Override
public @NotNull InteractionResult use(@NotNull BlockState pState, @NotNull Level pLevel, @NotNull BlockPos pPos, @NotNull Player pPlayer, @NotNull InteractionHand pHand, @NotNull BlockHitResult pHit) {
if (pLevel.isClientSide) {
return InteractionResult.CONSUME;
} else {
return InteractionResult.PASS;
}
}
@Nullable
@Override
public BlockEntity newBlockEntity(@NotNull BlockPos pPos, @NotNull BlockState pState) {
return new MirrorBlockEntity(pPos, pState);
}
private boolean canAttachTo(@NotNull BlockGetter pBlockReader, BlockPos pPos, Direction direction) {
BlockState blockState = pBlockReader.getBlockState(pPos);
return blockState.isFaceSturdy(pBlockReader, pPos, direction);
}
@Override
public boolean canSurvive(@NotNull BlockState pState, @NotNull LevelReader pLevel, @NotNull BlockPos pPos) {
Direction direction = pState.getValue(FACING);
return this.canAttachTo(pLevel, pPos.relative(direction), direction);
}
protected void createBlockStateDefinition(StateDefinition.@NotNull Builder<Block, BlockState> pBuilder) {
pBuilder.add(FACING, PART, WATERLOGGED);
}
}

View File

@ -0,0 +1,47 @@
package com.r3944realms.modernlifepatch.content.blocks.type.mirror;
import net.minecraft.util.StringRepresentable;
import org.jetbrains.annotations.NotNull;
public enum MirrorPart implements StringRepresentable {
SINGLE("mirror", MirrorType.COMMON_MIRROR),
HEAD("mirror_head", MirrorType.TELL_MIRROR),
FOOT("mirror_foot", MirrorType.TELL_MIRROR),
HEAD_LEFT("mirror_head_left", MirrorType.LARGE_MIRROR),
HEAD_RIGHT("mirror_head_right", MirrorType.LARGE_MIRROR),
FOOT_LEFT("mirror_foot_left", MirrorType.LARGE_MIRROR),
FOOT_RIGHT("mirror_foot_right", MirrorType.LARGE_MIRROR),
H00("mirror_h00", MirrorType.MASSIVE_MIRROR),
H01("mirror_h01", MirrorType.MASSIVE_MIRROR),
H02("mirror_h02", MirrorType.MASSIVE_MIRROR),
F10("mirror_f10", MirrorType.MASSIVE_MIRROR),
F11("mirror_f11", MirrorType.MASSIVE_MIRROR),
F12("mirror_f12", MirrorType.MASSIVE_MIRROR)
;
final String name;
final MirrorType type;
MirrorPart(String name, MirrorType type) {
this.name = name;
this.type = type;
}
public String getName() {
return name;
}
public MirrorType getType() {
return type;
}
@Override
public @NotNull String getSerializedName() {
return this.name;
}
public enum MirrorType {
COMMON_MIRROR,
TELL_MIRROR,
LARGE_MIRROR,
MASSIVE_MIRROR
}
}

View File

@ -0,0 +1,29 @@
package com.r3944realms.modernlifepatch.content.blocks.type.mirror.shape;
import com.r3944realms.modernlifepatch.content.blocks.type.mirror.MirrorPart;
import net.minecraft.core.Direction;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
public interface IMirrorShape {
MirrorShape mirrorShape = new MirrorShape();
TallMirrorShape tallMirrorShape = new TallMirrorShape();
LargeMirrorShape largeMirrorShape = new LargeMirrorShape();
MassiveMirrorShape massiveMirrorShape = new MassiveMirrorShape();
VoxelShape getDefaultShape(Direction direction);
VoxelShape getShapeByPart(Direction direction, MirrorPart part);
MirrorPart.MirrorType getMirrorType();
default boolean testIsRightPart(@NotNull MirrorPart part) {
return part.getType() == getMirrorType();
}
@Contract(pure = true)
static IMirrorShape getShapeInstanceByPart(@NotNull MirrorPart part) {
return switch (part) {
case SINGLE -> mirrorShape;
case HEAD, FOOT -> tallMirrorShape;
case HEAD_LEFT, HEAD_RIGHT, FOOT_LEFT, FOOT_RIGHT -> largeMirrorShape;
case H00, H01, H02, F10, F11, F12 -> massiveMirrorShape;
};
}
}

View File

@ -0,0 +1,80 @@
package com.r3944realms.modernlifepatch.content.blocks.type.mirror.shape;
import com.r3944realms.modernlifepatch.content.blocks.type.mirror.MirrorPart;
import com.r3944realms.modernlifepatch.utils.ShapeUtil;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.phys.shapes.VoxelShape;
import java.util.stream.Stream;
public class LargeMirrorShape implements IMirrorShape {
public static final VoxelShape FOOT_LEFT_SHAPE_NORTH = Block.box(0, 0, 0, 16, 16, 1.1),
FOOT_LEFT_SHAPE_SOUTH, FOOT_LEFT_SHAPE_WEST, FOOT_LEFT_SHAPE_EAST,
FOOT_RIGHT_SHAPE_NORTH = Block.box(0, 0, 0, 16, 16, 1.1),
FOOT_RIGHT_SHAPE_SOUTH, FOOT_RIGHT_SHAPE_WEST, FOOT_RIGHT_SHAPE_EAST,
HEAD_LEFT_SHAPE_NORTH = Block.box(0, 0, 0, 16, 16, 1.1),
HEAD_LEFT_SHAPE_SOUTH, HEAD_LEFT_SHAPE_WEST, HEAD_LEFT_SHAPE_EAST,
HEAD_RIGHT_SHAPE_NORTH = Block.box(0, 0, 0, 16, 16, 1.1),
HEAD_RIGHT_SHAPE_SOUTH, HEAD_RIGHT_SHAPE_WEST, HEAD_RIGHT_SHAPE_EAST
;
static {
FOOT_LEFT_SHAPE_EAST = ShapeUtil.RotateVoxelShapeClockwise(FOOT_LEFT_SHAPE_NORTH);
FOOT_LEFT_SHAPE_SOUTH = ShapeUtil.RotateVoxelShapeClockwise(FOOT_LEFT_SHAPE_EAST);
FOOT_LEFT_SHAPE_WEST = ShapeUtil.RotateVoxelShapeClockwise(FOOT_LEFT_SHAPE_SOUTH);
FOOT_RIGHT_SHAPE_EAST = ShapeUtil.RotateVoxelShapeClockwise(FOOT_RIGHT_SHAPE_NORTH);
FOOT_RIGHT_SHAPE_SOUTH = ShapeUtil.RotateVoxelShapeClockwise(FOOT_RIGHT_SHAPE_EAST);
FOOT_RIGHT_SHAPE_WEST = ShapeUtil.RotateVoxelShapeClockwise(FOOT_RIGHT_SHAPE_SOUTH);
HEAD_LEFT_SHAPE_EAST = ShapeUtil.RotateVoxelShapeClockwise(HEAD_LEFT_SHAPE_NORTH);
HEAD_LEFT_SHAPE_SOUTH = ShapeUtil.RotateVoxelShapeClockwise(HEAD_LEFT_SHAPE_EAST);
HEAD_LEFT_SHAPE_WEST = ShapeUtil.RotateVoxelShapeClockwise(HEAD_LEFT_SHAPE_SOUTH);
HEAD_RIGHT_SHAPE_EAST = ShapeUtil.RotateVoxelShapeClockwise(HEAD_RIGHT_SHAPE_NORTH);
HEAD_RIGHT_SHAPE_SOUTH = ShapeUtil.RotateVoxelShapeClockwise(HEAD_RIGHT_SHAPE_EAST);
HEAD_RIGHT_SHAPE_WEST = ShapeUtil.RotateVoxelShapeClockwise(HEAD_RIGHT_SHAPE_SOUTH);
}
@Override
public VoxelShape getDefaultShape(Direction direction) {
return (VoxelShape) switch (direction) {
case DOWN, UP -> Stream.empty();
case NORTH -> FOOT_LEFT_SHAPE_NORTH;
case SOUTH -> FOOT_LEFT_SHAPE_SOUTH;
case WEST -> FOOT_LEFT_SHAPE_WEST;
case EAST -> FOOT_LEFT_SHAPE_EAST;
};
}
@Override
public VoxelShape getShapeByPart(Direction direction, MirrorPart part) {
if (!testIsRightPart(part)) throw new IllegalArgumentException("Not a right part in mirror shape");
if (part == MirrorPart.FOOT_LEFT) return getDefaultShape(direction);
else if (part == MirrorPart.FOOT_RIGHT) return (VoxelShape) switch (direction) {
case DOWN, UP -> Stream.empty();
case NORTH -> FOOT_RIGHT_SHAPE_NORTH;
case SOUTH -> FOOT_RIGHT_SHAPE_SOUTH;
case WEST -> FOOT_RIGHT_SHAPE_WEST;
case EAST -> FOOT_RIGHT_SHAPE_EAST;
};
else if (part == MirrorPart.HEAD_LEFT) return (VoxelShape) switch (direction) {
case DOWN, UP -> Stream.empty();
case NORTH -> HEAD_LEFT_SHAPE_NORTH;
case SOUTH -> HEAD_LEFT_SHAPE_SOUTH;
case WEST -> HEAD_LEFT_SHAPE_WEST;
case EAST -> HEAD_LEFT_SHAPE_EAST;
};
else return (VoxelShape) switch (direction) {
case DOWN, UP -> Stream.empty();
case NORTH -> HEAD_RIGHT_SHAPE_NORTH;
case SOUTH -> HEAD_RIGHT_SHAPE_SOUTH;
case WEST -> HEAD_RIGHT_SHAPE_WEST;
case EAST -> HEAD_RIGHT_SHAPE_EAST;
};
}
@Override
public MirrorPart.MirrorType getMirrorType() {
return MirrorPart.MirrorType.LARGE_MIRROR;
}
}

View File

@ -0,0 +1,91 @@
package com.r3944realms.modernlifepatch.content.blocks.type.mirror.shape;
import com.r3944realms.modernlifepatch.content.blocks.type.mirror.MirrorPart;
import com.r3944realms.modernlifepatch.utils.ShapeUtil;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import java.util.stream.Stream;
public class MassiveMirrorShape implements IMirrorShape {
public static final VoxelShape F11_SHAPE_NORTH = Block.box(0, 0, 0, 16, 16, 1.1),
F11_SHAPE_SOUTH, F11_SHAPE_EAST, F11_SHAPE_WEST,
F10_SHAPE_NORTH =Block.box(0, 0, 0, 16, 16, 1.1),
F10_SHAPE_SOUTH, F10_SHAPE_WEST, F10_SHAPE_EAST,
F12_SHAPE_NORTH = Block.box(0, 0, 0, 16, 16, 1.1),
F12_SHAPE_SOUTH, F12_SHAPE_WEST, F12_SHAPE_EAST,
H01_SHAPE_NORTH = Block.box(0, 0, 0, 16, 16, 1.1),
H01_SHAPE_SOUTH, H01_SHAPE_WEST, H01_SHAPE_EAST,
H00_SHAPE_NORTH = Block.box(0, 0, 0, 16, 16, 1.1),
H00_SHAPE_SOUTH, H00_SHAPE_WEST, H00_SHAPE_EAST,
H02_SHAPE_NORTH = Block.box(0, 0, 0, 16, 16, 1.1),
H02_SHAPE_SOUTH, H02_SHAPE_WEST, H02_SHAPE_EAST;
static {
F11_SHAPE_EAST = ShapeUtil.RotateVoxelShapeClockwise(F11_SHAPE_NORTH);
F11_SHAPE_SOUTH = ShapeUtil.RotateVoxelShapeClockwise(F11_SHAPE_EAST);
F11_SHAPE_WEST = ShapeUtil.RotateVoxelShapeClockwise(F11_SHAPE_SOUTH);
F10_SHAPE_EAST = ShapeUtil.RotateVoxelShapeClockwise(F10_SHAPE_NORTH);
F10_SHAPE_SOUTH = ShapeUtil.RotateVoxelShapeClockwise(F10_SHAPE_EAST);
F10_SHAPE_WEST = ShapeUtil.RotateVoxelShapeClockwise(F10_SHAPE_SOUTH);
F12_SHAPE_EAST = ShapeUtil.RotateVoxelShapeClockwise(F12_SHAPE_NORTH);
F12_SHAPE_SOUTH = ShapeUtil.RotateVoxelShapeClockwise(F12_SHAPE_EAST);
F12_SHAPE_WEST = ShapeUtil.RotateVoxelShapeClockwise(F12_SHAPE_SOUTH);
H01_SHAPE_EAST = ShapeUtil.RotateVoxelShapeClockwise(H01_SHAPE_NORTH);
H01_SHAPE_SOUTH = ShapeUtil.RotateVoxelShapeClockwise(H01_SHAPE_EAST);
H01_SHAPE_WEST = ShapeUtil.RotateVoxelShapeClockwise(H01_SHAPE_SOUTH);
H00_SHAPE_EAST = ShapeUtil.RotateVoxelShapeClockwise(H00_SHAPE_NORTH);
H00_SHAPE_SOUTH = ShapeUtil.RotateVoxelShapeClockwise(H00_SHAPE_EAST);
H00_SHAPE_WEST = ShapeUtil.RotateVoxelShapeClockwise(H00_SHAPE_SOUTH);
H02_SHAPE_EAST = ShapeUtil.RotateVoxelShapeClockwise(H02_SHAPE_NORTH);
H02_SHAPE_SOUTH = ShapeUtil.RotateVoxelShapeClockwise(H02_SHAPE_EAST);
H02_SHAPE_WEST = ShapeUtil.RotateVoxelShapeClockwise(H02_SHAPE_SOUTH);
}
@Override
public VoxelShape getDefaultShape(@NotNull Direction direction) {
return (VoxelShape) switch (direction) {
case DOWN, UP -> Stream.empty();
case NORTH -> F11_SHAPE_NORTH;
case SOUTH -> F11_SHAPE_SOUTH;
case WEST -> F11_SHAPE_WEST;
case EAST -> F11_SHAPE_EAST;
};
}
@Override
public VoxelShape getShapeByPart(Direction direction, MirrorPart part) {
if (!testIsRightPart(part)) throw new IllegalArgumentException("Not a right part in mirror shape");
return switch (part) {
case H00 -> N_S_W_E(direction, H00_SHAPE_NORTH, H00_SHAPE_SOUTH, H00_SHAPE_WEST, H00_SHAPE_EAST);
case H01 -> N_S_W_E(direction, H01_SHAPE_NORTH, H01_SHAPE_SOUTH, H01_SHAPE_WEST, H01_SHAPE_EAST);
case H02 -> N_S_W_E(direction, H02_SHAPE_NORTH, H02_SHAPE_SOUTH, H02_SHAPE_WEST, H02_SHAPE_EAST);
case F10 -> N_S_W_E(direction, F10_SHAPE_NORTH, F10_SHAPE_SOUTH, F10_SHAPE_WEST, F10_SHAPE_EAST);
case F11 -> N_S_W_E(direction, F11_SHAPE_NORTH, F11_SHAPE_SOUTH, F11_SHAPE_WEST, F11_SHAPE_EAST);
case F12 -> N_S_W_E(direction, F12_SHAPE_NORTH, F12_SHAPE_SOUTH, F12_SHAPE_WEST, F12_SHAPE_EAST);
default -> throw new IllegalStateException("Unexpected value: " + part);
};
}
@Contract(pure = true)
private VoxelShape N_S_W_E(@NotNull Direction direction, VoxelShape N, VoxelShape S, VoxelShape E, VoxelShape W) {
return (VoxelShape) switch (direction) {
case DOWN, UP -> Stream.empty();
case NORTH -> N;
case SOUTH -> S;
case WEST -> E;
case EAST -> W;
};
}
@Override
public MirrorPart.MirrorType getMirrorType() {
return MirrorPart.MirrorType.MASSIVE_MIRROR;
}
}

View File

@ -0,0 +1,41 @@
package com.r3944realms.modernlifepatch.content.blocks.type.mirror.shape;
import com.r3944realms.modernlifepatch.content.blocks.type.mirror.MirrorPart;
import com.r3944realms.modernlifepatch.utils.ShapeUtil;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.phys.shapes.VoxelShape;
import java.util.stream.Stream;
public class MirrorShape implements IMirrorShape{
public static final VoxelShape SHAPE_NORTH = Block.box(0, 0, 0.099, 16, 16, 1.099), SHAPE_SOUTH, SHAPE_EAST, SHAPE_WEST;
static {
SHAPE_EAST = ShapeUtil.RotateVoxelShapeClockwise(SHAPE_NORTH);
SHAPE_SOUTH = ShapeUtil.RotateVoxelShapeClockwise(SHAPE_EAST);
SHAPE_WEST = ShapeUtil.RotateVoxelShapeClockwise(SHAPE_SOUTH);
}
@Override
public VoxelShape getDefaultShape(Direction direction) {
return (VoxelShape) switch (direction) {
case DOWN, UP -> Stream.empty();
case NORTH -> SHAPE_NORTH;
case SOUTH -> SHAPE_SOUTH;
case WEST -> SHAPE_WEST;
case EAST -> SHAPE_EAST;
};
}
@Override
public VoxelShape getShapeByPart(Direction direction, MirrorPart part) {
if (!testIsRightPart(part)) throw new IllegalArgumentException("Not a right part in mirror shape");
return getDefaultShape(direction);
}
@Override
public MirrorPart.MirrorType getMirrorType() {
return MirrorPart.MirrorType.COMMON_MIRROR;
}
}

View File

@ -0,0 +1,53 @@
package com.r3944realms.modernlifepatch.content.blocks.type.mirror.shape;
import com.r3944realms.modernlifepatch.content.blocks.type.mirror.MirrorPart;
import com.r3944realms.modernlifepatch.utils.ShapeUtil;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.phys.shapes.VoxelShape;
import java.util.stream.Stream;
public class TallMirrorShape implements IMirrorShape {
public static final VoxelShape FOOT_SHAPE_NORTH = Block.box(0, 0, 0, 16, 16, 1.1),
FOOT_SHAPE_SOUTH , FOOT_SHAPE_EAST, FOOT_SHAPE_WEST,
HEAD_SHAPE_NORTH= Block.box(0, 0, 0, 16, 16, 1.1),
HEAD_SHAPE_SOUTH, HEAD_SHAPE_EAST, HEAD_SHAPE_WEST;
static {
FOOT_SHAPE_EAST = ShapeUtil.RotateVoxelShapeClockwise(FOOT_SHAPE_NORTH);
FOOT_SHAPE_SOUTH = ShapeUtil.RotateVoxelShapeClockwise(FOOT_SHAPE_EAST);
FOOT_SHAPE_WEST = ShapeUtil.RotateVoxelShapeClockwise(FOOT_SHAPE_SOUTH);
HEAD_SHAPE_EAST = ShapeUtil.RotateVoxelShapeClockwise(HEAD_SHAPE_NORTH);
HEAD_SHAPE_SOUTH = ShapeUtil.RotateVoxelShapeClockwise(HEAD_SHAPE_EAST);
HEAD_SHAPE_WEST = ShapeUtil.RotateVoxelShapeClockwise(HEAD_SHAPE_SOUTH);
}
@Override
public VoxelShape getDefaultShape(Direction direction) {
return (VoxelShape) switch (direction) {
case DOWN, UP -> Stream.empty();
case NORTH -> FOOT_SHAPE_NORTH;
case SOUTH -> FOOT_SHAPE_SOUTH;
case WEST -> FOOT_SHAPE_WEST;
case EAST -> FOOT_SHAPE_EAST;
};
}
@Override
public VoxelShape getShapeByPart(Direction direction, MirrorPart part) {
if (!testIsRightPart(part)) throw new IllegalArgumentException("Not a right part in mirror shape");
if (part == MirrorPart.FOOT) return getDefaultShape(direction);
else return (VoxelShape) switch (direction) {
case DOWN, UP -> Stream.empty();
case NORTH -> HEAD_SHAPE_NORTH;
case SOUTH -> HEAD_SHAPE_SOUTH;
case WEST -> HEAD_SHAPE_WEST;
case EAST -> HEAD_SHAPE_EAST;
};
}
@Override
public MirrorPart.MirrorType getMirrorType() {
return MirrorPart.MirrorType.TELL_MIRROR;
}
}

View File

@ -0,0 +1,22 @@
package com.r3944realms.modernlifepatch.content.item;
import com.r3944realms.modernlifepatch.ModernLifePatch;
import com.r3944realms.modernlifepatch.content.blocks.ModBlocks;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
public class ModItems {
public static final DeferredRegister<Item> ITEMS
= DeferredRegister.create(ForgeRegistries.ITEMS, ModernLifePatch.MOD_ID);
public static final RegistryObject<BlockItem> MIRROR_ITEM = ModBlocks.registerBlockItem("mirror", ModBlocks.MIRROR);
public static final RegistryObject<BlockItem> TALL_MIRROR_ITEM = ModBlocks.registerBlockItem("tall_mirror", ModBlocks.TALL_MIRROR);
public static final RegistryObject<BlockItem> LARGE_MIRROR_ITEM = ModBlocks.registerBlockItem("large_mirror", ModBlocks.LARGE_MIRROR);
public static final RegistryObject<BlockItem> MASSIVE_MIRROR_ITEM = ModBlocks.registerBlockItem("massive_mirror", ModBlocks.MASSIVE_MIRROR);
public static void register(IEventBus bus) {
ITEMS.register(bus);
}
}

View File

@ -0,0 +1,34 @@
package com.r3944realms.modernlifepatch.content.tag;
import com.r3944realms.modernlifepatch.ModernLifePatch;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
public class ModTags {
public static class Items {
public static final TagKey<Item>
BEDCHAMBER = tag("bedchamber"),
BATHROOM = tag("bathroom"),
LOUNGE = tag("lounge"),
KITCHEN = tag("kitchen"),
WEAPON = tag("weapon"),
TOOL = tag("m_tool"),
GENERAL = tag("general"),
SHELF = tag("shelf"),
TABLE = tag("table"),
SEAT = tag("seat"),
RAMP = tag("ramp"),
BARRIER = tag("barrier"),
CONTAINER = tag("container"),
OUTSIDE = tag("outside"),
DOOR = tag("door")
;
private static TagKey<Item> tag(String name)
{
return TagKey.create(Registries.ITEM, new ResourceLocation(ModernLifePatch.MOD_ID, name));
}
}
}

View File

@ -0,0 +1,35 @@
package com.r3944realms.modernlifepatch.datagen;
import com.r3944realms.modernlifepatch.datagen.provider.*;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.PackOutput;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.data.event.GatherDataEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import com.r3944realms.modernlifepatch.utils.Enum.LanguageEnum;
import java.util.concurrent.CompletableFuture;
import static com.r3944realms.modernlifepatch.ModernLifePatch.MOD_ID;
@Mod.EventBusSubscriber(modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class DataGeneratorHandler {
@SubscribeEvent
public static void generatorDataEvent(GatherDataEvent event) {
DataGenerator generator = event.getGenerator();
PackOutput output = generator.getPackOutput();
CompletableFuture<HolderLookup.Provider> lookupProvider = event.getLookupProvider();
ExistingFileHelper existingFileHelper = event.getExistingFileHelper();
ModBlockTagProvider modBlockTagProvider = new ModBlockTagProvider(output, lookupProvider, existingFileHelper);
generator.addProvider(event.includeClient(), new ModLanguageProvider(output, LanguageEnum.English));
generator.addProvider(event.includeClient(), new ModLanguageProvider(output, LanguageEnum.SimpleChinese));
generator.addProvider(event.includeClient(), new ModItemModelProvider(output, existingFileHelper));
generator.addProvider(event.includeClient(), new ModBlockModelProvider(output, existingFileHelper));
generator.addProvider(event.includeServer(), new ModLootTableProvider(output));
generator.addProvider(event.includeServer(), new ModRecipeProvider(output));
generator.addProvider(event.includeServer(), modBlockTagProvider);
generator.addProvider(event.includeServer(), new ModItemTagProvider(output, lookupProvider, modBlockTagProvider.contentsGetter(), existingFileHelper));
}
}

View File

@ -0,0 +1,210 @@
package com.r3944realms.modernlifepatch.datagen.lang;
import com.r3944realms.modernlifepatch.ModernLifePatch;
import com.r3944realms.modernlifepatch.content.blocks.ModBlocks;
import com.r3944realms.modernlifepatch.content.item.ModItems;
import com.r3944realms.modernlifepatch.content.tag.ModTags;
import com.r3944realms.modernlifepatch.utils.Enum.LanguageEnum;
import com.r3944realms.modernlifepatch.utils.String.StringValidator;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import java.util.function.Supplier;
public enum ModLangKeyValue {
MIRROR_ITEM(getItemKey(ModItems.MIRROR_ITEM), "Mirror", "镜子"),
TALL_MIRROR_ITEM(getItemKey(ModItems.TALL_MIRROR_ITEM), "Tall Mirror", "高镜子"),
LARGE_MIRROR_ITEM(getItemKey(ModItems.LARGE_MIRROR_ITEM), "Large Mirror","大型镜子"),
MASSIVE_MIRROR_ITEM(getItemKey(ModItems.MASSIVE_MIRROR_ITEM), "Massive Mirror", "超大型镜子"),
MIRROR(getBlockKey(ModBlocks.MIRROR), copyEnglish(MIRROR_ITEM), copySimpleChinese(MIRROR_ITEM)),
TALL_MIRROR(getBlockKey(ModBlocks.TALL_MIRROR), copyEnglish(TALL_MIRROR_ITEM), copySimpleChinese(TALL_MIRROR_ITEM)),
LARGE_MIRROR(getBlockKey(ModBlocks.LARGE_MIRROR), copyEnglish(LARGE_MIRROR_ITEM), copySimpleChinese(LARGE_MIRROR_ITEM)),
MASSIVE_MIRROR(getBlockKey(ModBlocks.MASSIVE_MIRROR), copyEnglish(MASSIVE_MIRROR_ITEM), copySimpleChinese(MASSIVE_MIRROR_ITEM)),
CREATIVE_TAB_NAME(getCreativeTabNameKey(ModernLifePatch.MOD_ID), "Modern Life Patch", "摩登生活补丁"),
CT_F_TAG_GENERAL(getTagKey(ModTags.Items.GENERAL), "General", "普通"),
CT_F_TAG_KITCHEN(getTagKey(ModTags.Items.KITCHEN), "Kitchen", "厨房"),
CT_F_TAG_BEDCHAMBER(getTagKey(ModTags.Items.BEDCHAMBER), "Bedchamber", "寝室"),
CT_F_TAG_BATHROOM(getTagKey(ModTags.Items.BATHROOM), "BathRoom", "卫生间"),
CT_F_TAB_LOUNGE(getTagKey(ModTags.Items.LOUNGE), "Lounge", "客厅"),
CT_F_TAG_OUTSIDE(getTagKey(ModTags.Items.OUTSIDE), "Outside", "户外"),
CT_F_TAG_TOOL(getTagKey(ModTags.Items.TOOL), "Tool", "工具"),
CT_F_TAG_SEAT(getTagKey(ModTags.Items.SEAT), "Seat", "坐具"),
CT_F_TAG_TABLE(getTagKey(ModTags.Items.TABLE), "Table", "桌子"),
CT_F_TAG_SHELF(getTagKey(ModTags.Items.SHELF), "Shelf", "架子"),
CT_F_TAB_DOOR(getTagKey(ModTags.Items.DOOR), "Door", ""),
UNKNOWN("modernlifepatch.unknown", "Unknown", "未知"),
QUEEN(getCustomTextKey("chess", ModernLifePatch.MOD_ID, "queen"), "Queen", "皇后"),
KING(getCustomTextKey("chess", ModernLifePatch.MOD_ID, "king"), "King", "国王"),
KNIGHT(getCustomTextKey("chess", ModernLifePatch.MOD_ID, "knight"), "Knight", "骑士"),
PAWN(getCustomTextKey("chess", ModernLifePatch.MOD_ID, "pawn"), "Pawn", "士兵"),
BISHOP(getCustomTextKey("chess", ModernLifePatch.MOD_ID, "bishop"), "Bishop", ""),
ROOK(getCustomTextKey("chess", ModernLifePatch.MOD_ID, "rook"), "Rook", ""),
MOD_RESOURCE_NAME(getResourceTextKey(ModernLifePatch.MOD_ID, "modern_life_patch"), "§b§lModern Life §fExclusive Materials", "§b§l摩登生活 §f专属材质"),
MOD_RESOURCE_DESC(getCustomTextKey("resource_pack", ModernLifePatch.MOD_ID ,"description"), "All of textures and models are created by BF_Meow_Do not use for other purposes without permission.", "所有材质和模型均由 白帆小喵BF_Meow_ 绘制。未经允许,请勿用作他用。"),
CREATIVE_TAB_SCROLL_UP_BUTTON(getCustomTextKey("gui.button", ModernLifePatch.MOD_ID, "scroll_filter_up"), "Scroll up", "向上"),
CREATIVE_TAB_SCROLL_DOWN_BUTTON(getCustomTextKey("gui.button", ModernLifePatch.MOD_ID, "scroll_filter_down"), "Scroll down", "向下"),
CREATIVE_TAB_ENABLE_FILTERS_BUTTON(getCustomTextKey("gui.button", ModernLifePatch.MOD_ID, "enable_filters"), "Enable Filters", "启用过滤器"),
CREATIVE_TAB_DISABLE_FILTERS_BUTTON(getCustomTextKey("gui.button", ModernLifePatch.MOD_ID, "disable_filters"), "Disable Filters", "禁用过滤器"),
POWER_RECEIVER_HOVER_FIRST(getHoverTextKey("power_receiver", "1"), "Receives power on the selected channel from all transmitters", "从所有能量发射器中去接收所选工作频道的能量"),
POWER_RECEIVER_AND_TRANSMITTER_HOVER_SECOND(getHoverTextKey("power_receiver", "2"), "Right click block to change current channel", "右键方块打开界面,来切换工作频道"),
TURNTABLE_HOVER(getHoverTextKey("turn_table"), "Rotates clockwise when powered by redstone", "当有红石充能时顺时针旋转"),
POWER_TRANSMITTER_FIRST(getHoverTextKey("power_transmitter", "1"), "Transmits power on the selected channel to all receivers", "将红石信号传输给对应频道的所有能量接收器"),
TRASH_CAN_HOVER(getHoverTextKey("trash_can"), "Items inserted into the trash slot will be deleted when the trash can is full", "当垃圾桶已满时,进入垃圾桶的物品将被删除"),
PHOTOCOPIER_HOVER_FIRST(getHoverTextKey("photocopier", "1"), "Interact with a canvas or photograph to make copies", "可以用于照片或画作的复制"),
PHOTOCOPIER_HOVER_SECOND(getHoverTextKey("photocopier", "2"), " * Requires paper", " * 需要纸"),
PAVED_ROAD_HOVER(getHoverTextKey("paved_road"), "Slightly increases movement speed of vehicles", "载具在该路上行驶,移速会有所提升"),
EXTRACTOR_HOVER(getHoverTextKey("extractor"), "Extracts items from attached chests or from the space in front of it", "从其吸取端处的箱子或空间中取出物品"),
CHESS_BOARD_HOVER(getHoverTextKey("chess_board"), "PLace it down and begin a new game!", "放置后使用即可开始一场新游戏!"),
WALL_SHELF_HOVER_FIRST(getHoverTextKey("wall_shelf", "1"), "Right click tp place an item on the shelf", "右键以放置物品在墙架上"),
WALL_SHELF_HOVER_SECOND(getHoverTextKey("wall_shelf", "2"), "Shift-right-click with an empty hand to remove an item", "空手按住Shift键+右键即可取下物品"),
STEAM_RADIATOR_HOVER(getHoverTextKey("steam_radiator"), "Right click placed radiator to activate", "右键已放置的散热器,即可激活"),
BOOKSHELF_HOVER_FIRST(getHoverTextKey("bookshelf", "1"), "Right click tp place a book on the shelf", "右键以放置书在书架上"),
BOOKSHELF_HOVER_SECOND(getHoverTextKey("bookshelf", "2"), "Shift-right-click with an empty hand to remove a book", "空手按住Shift键+右键即可取下书"),
//C_TOOL
GUITAR_AMPLIFIER_HOVER(getHoverTextKey("guitar_amplifier"), "Play a guitar nearby to add a distortion effect" ,"在附近弹奏吉他以增加失真效果"),
SEED_SPREADER_HOVER(getHoverTextKey("seed_spreader"), "Automatically disperses seeds that are put inside of it", "自动播种机器里的种子"),
BATTERY_HOVER(getHoverTextKey("battery"), "Right click to recharge flashlight (battery will be consumed)", "右键消耗为手电筒更换电池"),
CHAINSAW_HOVER_FIRST(getHoverTextKey("chainsaw", "1"), "Right click to use", "右键使用"),
CHAINSAW_HOVER_SECOND(getHoverTextKey("chainsaw", "2"), "* Highly effective on trees an leaves", "* 一种极其高效砍树方案"),
HAND_GUN_HOVER_FIRST(getHoverTextKey("handgun", "1"), "Left click to fire", "左键开火"),
HAND_GUN_HOVER_SECOND(getHoverTextKey("handgun", "2"), "Right click to aim down sights", "右键聚焦对准"),
HAND_GUN_HOVER_THIRD(getHoverTextKey("handgun", "3"), "* Requires at least one Magazine in order to shoot", "* 需要至少一个弹匣来发射"),
GUITAR_HOVER_FIRST(getHoverTextKey("guitar", "1"), "Right click to use", "右键使用"),
GUITAR_HOVER_SECOND(getHoverTextKey("guitar", "2"), "* Standard Tuning (EADGBE)", "* 标准调谐EADGBE"),
FLASH_LIGHT_HOVER_FIRST(getHoverTextKey("flashlight", "1"), "Right click to use", "右键使用"),
FLASH_LIGHT_HOVER_SECOND(getHoverTextKey("flashlight", "2"), "* Using it will deplete the battery but it will not break", "* 使用它会耗尽电池,但不会损坏"),
FLASH_LIGHT_HOVER_THIRD(getHoverTextKey("flashlight", "3"), "* %s minutes remaining before drained", "* 电量耗尽前剩余%s分钟"),
FLASH_LIGHT_HOVER_FOURTH(getHoverTextKey("flashlight", "4"), "* Lasts %s minutes at full charge", "* 一节满电电池可以为其提供至少%s分钟的照亮时间"),
FLASH_LIGHT_HOVER_FIFTH(getHoverTextKey("flashlight", "5"), "* Repair durability by using a battery", "* 通过电池来修复耐久"),
CAMERA_HOVER_FIRST(getHoverTextKey("camera", "1"), "%d/%d photos stored in memory card", "内存卡里照片数: %d/%d"),
CAMERA_HOVER_SECOND(getHoverTextKey("camera", "2"), "* Does not break when durability hits 0", "* 当耐久掉到0时也不会损坏"),
CAMERA_HOVER_THIRD(getHoverTextKey("camera", "3"), "* Take to a printer to print your photos", "* 提供打印机把所拍照冲洗出来"),
//TRAN
BICYCLE_HOVER(getHoverTextKey("bicycle"), "Right click to deploy", "右键放置"),
MOTORBOAT_HOVER_FIRST(getHoverTextKey("motorboat", "1"), "Right click to deploy", "右键放置"),
MOTORBOAT_HOVER_SECOND(getHoverTextKey("motorboat", "2"), "Remaining fuel: %f%%","燃料剩余量: %f%%"),
MOTORBOAT_HOVER_THIRD(getHoverTextKey("motorboat", "3"), "Refuel by using a gas can on the deployed boat", "对船使用汽油罐来加油"),
ROAD_MARKER_FIRST(getHoverTextKey("road_marker", "1"), "* Right click paved road to apply currently selected road marker", "* 右键单击已铺设的道路以应用当前选定的道路标记"),
ROAD_MARKER_SECOND(getHoverTextKey("road_marker", "2"), "* Right click elsewhere to toggle between available road markers", "* 右键单击其他位置以在可用道路标记之间切换"),
//P
NEED_RED_STONE_POWER_HOVER(getHoverTextKey("need_rs_power"), "Requires redstone power to operate", "需要红石充能"),
STORE_18_HOVER(getHoverTextKey("store_18"), "Stores up to 18 items", "可存储18组物品"),
//~P
METAL_GRATE_HOVER(getHoverTextKey("metal_grate"), "Allows water and items to flow through freely", "允许水与物品自由地穿过"),
EASEL_HOVER(getHoverTextKey("easel"), "Place a canvas on it to begin painting", "放置(帆布)画布在其上,即可开始绘画"),
//CONTAINER & MENU
KITCHEN_CABINET_MENU_LABEL(getMenuLabelKey("kitchen_cabinet"), "Kitchen Cabinet", "厨房柜子"),
KITCHEN_DRAWER_CABINET_MENU_LABEL(getMenuLabelKey("kitchen_drawer_cabinet"), "Kitchen Drawer Cabinet", "厨房抽屉柜"),
TRASH_CAN_MENU_LABEL(getMenuLabelKey("trash_can"), "Trash Can", "垃圾桶"),
PHOTOCOPIER_MENU_LABEL(getMenuLabelKey("photo_copier"), "Photocopier", "复印机"),
PRINTER_MENU_LABEL(getMenuLabelKey("printer"), "Printer", "打印机"),
PRINTER_SIZE_MENU_LABEL(getMenuLabelKey("print_size"), "Print Size", "打印尺寸"),
NIGHT_STAND_MENU_LABEL(getMenuLabelKey("night_stand"), "Night Stand", "床头柜"),
STEAM_RADIATOR_MENU_LABEL(getMenuLabelKey("radiator"), "Radiator" ,"蒸汽散热器"),
SEED_SPREADER_MENU_LABEL(getMenuLabelKey("seed_spreader"), "Seed Spreader", "播种器"),
REFRIGERATOR_MENU_LABEL(getMenuLabelKey("refrigerator"), "refrigerator", "冰箱"),
//CANVAS
CANVAS_HOVER_DESC_COMPLETED(getHoverTextKey("canvas", "desc_completed"), "A work of art" ,"艺术品"),
CANVAS_HOVER_UNIQUE_ID(getHoverTextKey("canvas", "unique_id"), "ID = %d", "ID = %d"),
CANVAS_HOVER_PIXELS_SIZE(getHoverTextKey("canvas", "pixels_size"), "%d x %d pixels", "%d x %d 像素"),
CANVAS_HOVER_BLOCK_SIZE(getHoverTextKey("canvas", "block_size"), "%f x %f ", "%f x %f"),
CANVAS_HOVER_OFFSET(getHoverTextKey("canvas", "offset"), "(%f,%f)", "(%f,%f)"),
CANVAS_HOVER_DESC_EMPTY(getHoverTextKey("canvas", "desc_empty"), "For use with an easel", "可用画架来创作"),
CANVAS_HOVER_DESC_SIZE_NORMAL(getHoverTextKey("canvas", "normal_size"), "Normal print", "常规尺寸画作"),
CANVAS_HOVER_DESC_SIZE_LARGE(getHoverTextKey("canvas", "large_size"), "Large print", "大型尺寸画作"),
CANVAS_HOVER_DESC_SIZE_EXTRA_LARGE(getHoverTextKey("canvas", "extra_large_size"), "Extra Large print", "超大型尺寸画作"),
CANVAS_HOVER_DESC_SIZE_MASSIVE(getHoverTextKey("canvas", "massive_size"), "Massive print", "巨大尺寸的画作"),
CANVAS_HOVER_DESC_SIZE_LARGE_SQUARE(getHoverTextKey("canvas", "large_square_size"),"Large square print", "大型方寸画作"),
CANVAS_HOVER_DESC_SIZE_EXTRA_LARGE_SQUARE(getHoverTextKey("canvas", "extra_large_square_size"), "Extra Large square", "超大型方寸画作"),
CANVAS_HOVER_DESC_SIZE_MASSIVE_SQUARE(getHoverTextKey("canvas", "massive_square_size"),"Massive square print","巨大方寸画作"),
CANVAS_HOVER_DESC_SIZE_CUSTOM(getHoverTextKey("canvas", "custom_size"), "Custom print", "自定义尺寸画作"),
;
private final String key;
private final String US_EN;
private final String SIM_CN;
ModLangKeyValue(String key, String US_EN, String SIM_CN) {
this.key = key;
this.US_EN = US_EN;
this.SIM_CN = SIM_CN;
}
public String getKey() {
return key;
}
public static String getLan(LanguageEnum lan, ModLangKeyValue key) {
if (lan == LanguageEnum.SimpleChinese) {
return getSimpleChinese(key);
}
return getEnglish(key);
}
private static String getEnglish(ModLangKeyValue key) {
return key.US_EN;
}
private static String getSimpleChinese(ModLangKeyValue key) {
return key.SIM_CN;
}
private static final String HEAD_ = "modernlifepatch.lang.";
public static String getHoverTextKey(String key) {
return getHoverTextKey(key, "0");
}
public static String getResourceTextKey(String mod_id, String name) {
if(StringValidator.isNotValidMinecraftKey(mod_id) || StringValidator.isNotValidMinecraftKey(name)) {
throw new IllegalArgumentException("Not valid MinecraftKey which only including [a-z], '.' and '_'.");
}
return "resource." + mod_id + "." + name;
}
public static String getCustomTextKey(String prefix, String mod_id, String custom) {
if(StringValidator.isNotValidMinecraftKey(prefix) || StringValidator.isNotValidMinecraftKey(mod_id) || StringValidator.isNotValidMinecraftKey(custom)) {
throw new IllegalArgumentException("Not valid MinecraftKey which only including [a-z], '.' and '_'.");
}
return HEAD_ + prefix + "." + mod_id + "." + custom;
}
public static String getHoverTextKey(String itemName, String diffMark) {
if(StringValidator.isNotValidMinecraftKey(itemName) || StringValidator.isNotValidMinecraftKey(diffMark)) {
throw new IllegalArgumentException("Not valid MinecraftKey which only including [a-z], '.' and [0-9] and '_'.");
}
return HEAD_ + itemName + ".hover_text." + diffMark;
}
public static String getMenuLabelKey(String menuLabel) {
if(StringValidator.isNotValidMinecraftKey(menuLabel)) {
throw new IllegalArgumentException("Not valid MinecraftKey which only including [a-z], '.' and '_'.");
}
return HEAD_ + "menu." + menuLabel;
}
public static String getTagKey(TagKey<Item> tag) {
return String.format("gui.tag_filter.%s.%s", tag.location().getNamespace(), tag.location().getPath().replace("/", "."));
}
public static String getCreativeTabNameKey(String tabName) {
return "itemGroup." + tabName;
}
public static String getBlockKey(Supplier<? extends Block> block) {
return getBlockKey(block.get());
}
public static String getBlockKey(Block block) {
return block.getDescriptionId();
}
public static String getItemKey(Supplier<? extends Item> item) {
return getItemKey(item.get());
}
public static String getItemKey(Item item) {
return item.getDescriptionId();
}
public static String copyEnglish(ModLangKeyValue modLangKeyValue) {
return modLangKeyValue.US_EN;
}
public static String copySimpleChinese(ModLangKeyValue modLangKeyValue) {
return modLangKeyValue.SIM_CN;
}
}

View File

@ -0,0 +1,43 @@
package com.r3944realms.modernlifepatch.datagen.provider;
import com.r3944realms.modernlifepatch.ModernLifePatch;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.client.model.generators.BlockModelBuilder;
import net.minecraftforge.client.model.generators.BlockStateProvider;
import net.minecraftforge.client.model.generators.ModelProvider;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.registries.ForgeRegistries;
public class ModBlockModelProvider extends BlockStateProvider {
public ModBlockModelProvider(PackOutput packOutput, ExistingFileHelper existingFileHelper) {
super(packOutput, ModernLifePatch.MOD_ID, existingFileHelper);
}
public void registerStatesAndModels(Block block) {
this.simpleBlock(block, this.cubeAll(block));
}
public ResourceLocation blockTextureSuffix(Block block,String suffix) {
ResourceLocation name = key(block);
return new ResourceLocation(name.getNamespace(), ModelProvider.BLOCK_FOLDER + "/" + name.getPath() + suffix);
}
private ResourceLocation key(Block block) {
return ForgeRegistries.BLOCKS.getKey(block);
}
@Override
protected void registerStatesAndModels() {
}
public void generateJasmineBlockState(Block block) {
BlockModelBuilder model = models().cubeAll(name(block), blockTexture(block));
simpleBlock(block,model);
}
public String name(Block block) {
return key(block).getPath();
}
}

View File

@ -0,0 +1,25 @@
package com.r3944realms.modernlifepatch.datagen.provider;
import com.r3944realms.modernlifepatch.ModernLifePatch;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.minecraftforge.common.data.BlockTagsProvider;
import net.minecraftforge.common.data.ExistingFileHelper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.concurrent.CompletableFuture;
public class ModBlockTagProvider extends BlockTagsProvider {
public ModBlockTagProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, @Nullable ExistingFileHelper existingFileHelper) {
super(output, lookupProvider, ModernLifePatch.MOD_ID, existingFileHelper);
}
@Override
protected void addTags(HolderLookup.@NotNull Provider pProvider) {
}
}

View File

@ -0,0 +1,40 @@
package com.r3944realms.modernlifepatch.datagen.provider;
import com.r3944realms.modernlifepatch.ModernLifePatch;
import com.r3944realms.modernlifepatch.content.item.ModItems;
import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraftforge.client.model.generators.ItemModelProvider;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.registries.ForgeRegistries;
import java.util.Objects;
public class ModItemModelProvider extends ItemModelProvider {
public static final String GENERATED = "item/generated";
public ModItemModelProvider(PackOutput packOutput, ExistingFileHelper existingFileHelper) {
super(packOutput, ModernLifePatch.MOD_ID, existingFileHelper);
}
@Override
protected void registerModels() {
itemGeneratedModel(ModItems.MIRROR_ITEM.get(), new ResourceLocation(ModernLifePatch.MOD_ID, "item/mirror_item"));
itemGeneratedModel(ModItems.TALL_MIRROR_ITEM.get(), new ResourceLocation(ModernLifePatch.MOD_ID, "item/tall_mirror_item"));
itemGeneratedModel(ModItems.LARGE_MIRROR_ITEM.get(), new ResourceLocation(ModernLifePatch.MOD_ID, "item/large_mirror_item"));
itemGeneratedModel(ModItems.MASSIVE_MIRROR_ITEM.get(), new ResourceLocation(ModernLifePatch.MOD_ID, "item/massive_mirror_item"));
}
public void itemGeneratedModel(Item item, ResourceLocation texture) {
withExistingParent(itemName(item), GENERATED).texture("layer0", texture);
}
private String itemName(Item item) {
return Objects.requireNonNull(ForgeRegistries.ITEMS.getKey(item)).getPath();
}
public ResourceLocation resourceItem(String path) {
return new ResourceLocation(ModernLifePatch.MOD_ID, "item/" + path);
}
}

View File

@ -0,0 +1,26 @@
package com.r3944realms.modernlifepatch.datagen.provider;
import com.r3944realms.modernlifepatch.ModernLifePatch;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.minecraft.data.tags.ItemTagsProvider;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.common.data.ExistingFileHelper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.concurrent.CompletableFuture;
public class ModItemTagProvider extends ItemTagsProvider {
public ModItemTagProvider(PackOutput pOutput, CompletableFuture<HolderLookup.Provider> pLookupProvider, CompletableFuture<TagLookup<Block>> pBlockTags, @Nullable ExistingFileHelper existingFileHelper) {
super(pOutput, pLookupProvider, pBlockTags, ModernLifePatch.MOD_ID, existingFileHelper);
}
@Override
protected void addTags(HolderLookup.@NotNull Provider pProvider) {
}
}

View File

@ -0,0 +1,38 @@
package com.r3944realms.modernlifepatch.datagen.provider;
import com.r3944realms.modernlifepatch.ModernLifePatch;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.data.PackOutput;
import net.minecraftforge.common.data.LanguageProvider;
import com.r3944realms.modernlifepatch.utils.Enum.LanguageEnum;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ModLanguageProvider extends LanguageProvider {
private final LanguageEnum Language;
private final Map<String, String> LanKeyMap;
private static final List<String> objects = new ArrayList<>();
public ModLanguageProvider(PackOutput output, LanguageEnum Lan) {
super(output, ModernLifePatch.MOD_ID, Lan.local);
this.Language = Lan;
LanKeyMap = new HashMap<>();
init();
}
private void init() {
for (ModLangKeyValue key : ModLangKeyValue.values()) {
addLang(key.getKey(), ModLangKeyValue.getLan(Language, key));
}
}
private void addLang(String Key, String value) {
if(!objects.contains(Key)) objects.add(Key);
LanKeyMap.put(Key, value);
}
@Override
protected void addTranslations() {
objects.forEach(key -> add(key,LanKeyMap.get(key)));
}
}

View File

@ -0,0 +1,28 @@
package com.r3944realms.modernlifepatch.datagen.provider;
import com.r3944realms.modernlifepatch.datagen.provider.loot.ModBlockLootTables;
import net.minecraft.data.PackOutput;
import net.minecraft.data.loot.LootTableProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.ValidationContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class ModLootTableProvider extends LootTableProvider {
public ModLootTableProvider(PackOutput output) {
super(output, Set.of(), List.of(new LootTableProvider.SubProviderEntry(
ModBlockLootTables::new,
LootContextParamSets.BLOCK
)));
}
@Override
protected void validate(@NotNull Map<ResourceLocation, LootTable> map, @NotNull ValidationContext validationcontext) {
map.forEach((id, table) -> table.validate(validationcontext));
}
}

View File

@ -0,0 +1,45 @@
package com.r3944realms.modernlifepatch.datagen.provider;
import com.r3944realms.modernlifepatch.content.item.ModItems;
import net.minecraft.data.PackOutput;
import net.minecraft.data.recipes.*;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.item.Items;
import net.minecraftforge.common.Tags;
import org.jetbrains.annotations.NotNull;
import java.util.function.Consumer;
public class ModRecipeProvider extends RecipeProvider {
public ModRecipeProvider(PackOutput pOutput) {
super(pOutput);
}
@Override
protected void buildRecipes(@NotNull Consumer<FinishedRecipe> pWriter) {
ShapelessRecipeBuilder.shapeless(RecipeCategory.DECORATIONS, ModItems.MIRROR_ITEM.get(), 1)
.requires(Tags.Items.GLASS_PANES)
.requires(Items.IRON_INGOT)
.requires(ItemTags.WOODEN_SLABS)
.unlockedBy("has_item_glass_pane", has(Tags.Items.GLASS_PANES))
.save(pWriter);
ShapedRecipeBuilder.shaped(RecipeCategory.DECORATIONS, ModItems.TALL_MIRROR_ITEM.get(), 1)
.define('@', ModItems.MIRROR_ITEM.get())
.pattern("@")
.pattern("@")
.unlockedBy("has_item_mirror", has(ModItems.MIRROR_ITEM.get()))
.save(pWriter);
ShapedRecipeBuilder.shaped(RecipeCategory.DECORATIONS, ModItems.LARGE_MIRROR_ITEM.get(), 1)
.define('@', ModItems.MIRROR_ITEM.get())
.pattern("@@")
.pattern("@@")
.unlockedBy("has_item_mirror", has(ModItems.MIRROR_ITEM.get()))
.save(pWriter);
ShapedRecipeBuilder.shaped(RecipeCategory.DECORATIONS, ModItems.MASSIVE_MIRROR_ITEM.get(), 1)
.define('@', ModItems.MIRROR_ITEM.get())
.pattern("@@@")
.pattern("@@@")
.unlockedBy("has_item_mirror", has(ModItems.MIRROR_ITEM.get()))
.save(pWriter);
}
}

View File

@ -0,0 +1,34 @@
package com.r3944realms.modernlifepatch.datagen.provider.loot;
import com.r3944realms.modernlifepatch.content.blocks.ModBlocks;
import net.minecraft.data.loot.BlockLootSubProvider;
import net.minecraft.world.flag.FeatureFlagSet;
import net.minecraft.world.flag.FeatureFlags;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.registries.RegistryObject;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
import java.util.stream.Stream;
public class ModBlockLootTables extends BlockLootSubProvider {
public ModBlockLootTables() {
super(Set.of(), FeatureFlags.REGISTRY.allFlags());
}
@Override
protected void generate() {
this.dropSelf(ModBlocks.MIRROR.get());
this.dropSelf(ModBlocks.TALL_MIRROR.get());
this.dropSelf(ModBlocks.LARGE_MIRROR.get());
this.dropSelf(ModBlocks.MASSIVE_MIRROR.get());
}
@Override
protected @NotNull Iterable<Block> getKnownBlocks() {
return ModBlocks.BLOCKS.getEntries().stream().map(RegistryObject::get)::iterator;
}
}

View File

@ -0,0 +1,45 @@
package com.r3944realms.modernlifepatch.mixin;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
import java.util.List;
import java.util.Set;
public class MLPMixinPlugin implements IMixinConfigPlugin {
@Override
public void onLoad(String s) {
}
@Override
public String getRefMapperConfig() {
return "";
}
@Override
public boolean shouldApplyMixin(String s, String s1) {
return true;
}
@Override
public void acceptTargets(Set<String> set, Set<String> set1) {
}
@Override
public List<String> getMixins() {
return List.of();
}
@Override
public void preApply(String s, ClassNode classNode, String s1, IMixinInfo iMixinInfo) {
}
@Override
public void postApply(String s, ClassNode classNode, String s1, IMixinInfo iMixinInfo) {
}
}

View File

@ -0,0 +1,42 @@
package com.r3944realms.modernlifepatch.mixin.block.bathroom;
import com.dairymoose.modernlife.blocks.AbstractWallBlock;
import com.dairymoose.modernlife.blocks.ShowerHeadBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ShowerHeadBlock.class)
public abstract class MixinShowerHead extends AbstractWallBlock implements EntityBlock {
@Unique
private static final VoxelShape SHAPE_N = Block.box(6, 8.5, 10, 10, 12.5, 16), SHAPE_E, SHAPE_S, SHAPE_W;
static {
SHAPE_E = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N);
SHAPE_S = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_E);
SHAPE_W = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S);
}
public MixinShowerHead(Properties properties) {
super(properties);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
switch (bs.getValue(FACING)) {
case SOUTH -> cir.setReturnValue(SHAPE_S);
case EAST -> cir.setReturnValue(SHAPE_E);
case WEST -> cir.setReturnValue(SHAPE_W);
default -> cir.setReturnValue(SHAPE_N);
}
}
}

View File

@ -0,0 +1,55 @@
package com.r3944realms.modernlifepatch.mixin.block.bathroom;
import com.dairymoose.modernlife.blocks.StandardHorizontalBlock;
import com.dairymoose.modernlife.blocks.ToiletBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.stream.Stream;
@Mixin(ToiletBlock.class)
public abstract class MixinToilet extends StandardHorizontalBlock implements SimpleWaterloggedBlock, EntityBlock {
@Unique
private static final VoxelShape SHAPE_S, SHAPE_W, SHAPE_N, SHAPE_E;
static {
SHAPE_S = Stream.of(
Block.box(3, 4, 0, 13, 16, 5),
Block.box(3, 3.99, 5, 5, 7.99, 15),
Block.box(11, 3.99, 5, 13, 7.99, 15),
Block.box(5, 3.99, 5, 11, 7.99, 7),
Block.box(5, 3.99, 13, 11, 7.99, 15),
Block.box(4, -0.01, 2, 12, 3.99, 13)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get();
SHAPE_W = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S);
SHAPE_N = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_W);
SHAPE_E = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N);
}
public MixinToilet(Properties properties) {
super(properties);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
switch (bs.getValue(FACING)) {
case SOUTH -> cir.setReturnValue(SHAPE_S);
case EAST -> cir.setReturnValue(SHAPE_E);
case WEST -> cir.setReturnValue(SHAPE_W);
default -> cir.setReturnValue(SHAPE_N);
}
}
}

View File

@ -0,0 +1,103 @@
package com.r3944realms.modernlifepatch.mixin.block.bedchamber;
import com.dairymoose.modernlife.blocks.NightStandBlock;
import com.dairymoose.modernlife.tileentities.NightStandBlockEntity;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import com.r3944realms.modernlifepatch.modInterface.IContainMenu;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.ChestMenu;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.List;
import java.util.stream.Stream;
import static com.dairymoose.modernlife.blocks.NightStandBlock.FACING;
@SuppressWarnings("AddedMixinMembersNamePattern")
@Mixin(NightStandBlock.class)
public abstract class MixinNightStand extends Block implements EntityBlock ,IContainMenu{
public MixinNightStand(Properties properties) {
super(properties);
}
@Unique
private static final VoxelShape SHAPE_S = Shapes.join(Stream.of(
Block.box(0, 0, 12, 2, 1, 14),
Block.box(14, 0, 12, 16, 1, 14),
Block.box(0, 0, 0, 2, 1, 2),
Block.box(14, 0, 0, 16, 1, 2)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(), Block.box(0, 1, 0, 16, 16, 14), BooleanOp.OR), SHAPE_E, SHAPE_N, SHAPE_W;
static {
SHAPE_W = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S);
SHAPE_N = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_W);
SHAPE_E = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
switch (bs.getValue(FACING)) {
case SOUTH -> cir.setReturnValue(SHAPE_S);
case EAST -> cir.setReturnValue(SHAPE_E);
case WEST -> cir.setReturnValue(SHAPE_W);
default -> cir.setReturnValue(SHAPE_N);
}
}
@Inject(method = {"getMenuProvider"}, at = @At("HEAD"), cancellable = true)
public void getMenuProvider(BlockState blockState, Level level, BlockPos blockPos, CallbackInfoReturnable<MenuProvider> cir) {
if (!MixinNightStand.this.ContainMenuLabel().isEmpty()) {
cir.setReturnValue(new MenuProvider() {
@Override
public AbstractContainerMenu createMenu(int paramInt, @NotNull Inventory paramInventory, @NotNull Player paramPlayer) {
BlockEntity tileEntity = level.getBlockEntity(blockPos);
if (tileEntity instanceof NightStandBlockEntity nightStandBlockEntity) {
return new ChestMenu(MenuType.GENERIC_9x2, paramInt, paramInventory, nightStandBlockEntity, 2);
} else {
return null;
}
}
@Override
public @NotNull Component getDisplayName() {
return Component.translatable(String.valueOf(MixinNightStand.this.ContainMenuLabel()));
}
});
}
}
@Unique
@Override
public String ContainMenuLabel() {
return ModLangKeyValue.NIGHT_STAND_MENU_LABEL.getKey();
}
@Inject(method = {"appendHoverText"}, at= @At("HEAD"), cancellable = true)
private void appendHoverTextHead(ItemStack itemStack, BlockGetter blockReader, List<Component> list, TooltipFlag tooltipFlag, CallbackInfo ci) {
list.add(Component.translatable(ModLangKeyValue.STORE_18_HOVER.getKey()));
ci.cancel();
}
}

View File

@ -0,0 +1,46 @@
package com.r3944realms.modernlifepatch.mixin.block.common;
import com.dairymoose.modernlife.blocks.ArrowSlitBlock;
import com.dairymoose.modernlife.blocks.WallSocketBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.stream.Stream;
@Mixin(ArrowSlitBlock.class)
public class MixinArrowSlit {
@Unique
private static final VoxelShape SHAPE_S = Stream.of(
Block.box(0, 0, 12, 16, 6, 16),
Block.box(10, 6, 12, 16, 14, 16),
Block.box(0, 14, 12, 16, 16, 16),
Block.box(0, 6, 12, 6, 14, 16)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(), SHAPE_E, SHAPE_N, SHAPE_W;
static {
SHAPE_W = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S);
SHAPE_N = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_W);
SHAPE_E = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
switch (bs.getValue(WallSocketBlock.FACING)) {
case SOUTH -> cir.setReturnValue(SHAPE_S);
case EAST -> cir.setReturnValue(SHAPE_E);
case WEST -> cir.setReturnValue(SHAPE_W);
default -> cir.setReturnValue(SHAPE_N);
}
}
}

View File

@ -0,0 +1,25 @@
package com.r3944realms.modernlifepatch.mixin.block.common;
import com.dairymoose.modernlife.blocks.ModernBookshelfBlock;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.List;
@Mixin(ModernBookshelfBlock.class)
public class MixinBookShelf {
@Inject(method = {"appendHoverText"}, at= @At("HEAD"), cancellable = true)
public void appendHoverText(ItemStack itemStack, BlockGetter blockReader, List<Component> list, TooltipFlag tooltipFlag, CallbackInfo ci) {
list.add(Component.translatable(ModLangKeyValue.BOOKSHELF_HOVER_FIRST.getKey()));
list.add(Component.translatable(ModLangKeyValue.BOOKSHELF_HOVER_SECOND.getKey()));
ci.cancel();
}
}

View File

@ -0,0 +1,56 @@
package com.r3944realms.modernlifepatch.mixin.block.common;
import com.dairymoose.modernlife.blocks.CCTVCameraBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.stream.Stream;
import static com.dairymoose.modernlife.blocks.CCTVCameraBlock.FACING;
@Mixin(CCTVCameraBlock.class)
public class MixinCCTVCamera {
@Unique
private static final VoxelShape SHAPE_S = Stream.of(
Stream.of(
Block.box(7, 7, 1.00138, 9, 8, 4.00138),
Block.box(7, 4, 1.00138, 7, 7, 5.00138),
Block.box(9, 4, 1.00138, 9, 7, 5.00138)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(),
Block.box(6, 4, 0.00138, 10, 9, 1.00138),
Stream.of(
Block.box(6, 7, 3.00138, 10, 11, 9.00138),
Block.box(6, 9, 9.00138, 6, 11, 11.00138),
Block.box(10, 9, 9.00138, 10, 11, 11.00138),
Block.box(6, 11, 9.00138, 10, 11, 11.00138)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get()
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(), SHAPE_E, SHAPE_N, SHAPE_W;
static {
SHAPE_W = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S);
SHAPE_N = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_W);
SHAPE_E = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
switch (bs.getValue(FACING)) {
case SOUTH -> cir.setReturnValue(SHAPE_S);
case EAST -> cir.setReturnValue(SHAPE_E);
case WEST -> cir.setReturnValue(SHAPE_W);
default -> cir.setReturnValue(SHAPE_N);
}
}
}

View File

@ -0,0 +1,88 @@
package com.r3944realms.modernlifepatch.mixin.block.common;
import com.dairymoose.modernlife.blocks.CanvasBlock;
import com.dairymoose.modernlife.core.ModernLifeClient;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.text.DecimalFormat;
import java.util.List;
@Mixin(CanvasBlock.class)
public class MixinCanvas {
@OnlyIn(Dist.CLIENT)
@Inject(method = {"appendHoverText"}, at= @At("HEAD"), cancellable = true)
public void appendHoverText(ItemStack itemStack, BlockGetter blockReader, List<Component> list, TooltipFlag tooltipFlag, CallbackInfo ci) {
Long canvasUniqueId = null;
if (itemStack.getTag() != null && itemStack.getTag().contains("UniqueId")) {
list.add(Component.translatable(ModLangKeyValue.CANVAS_HOVER_DESC_COMPLETED.getKey()));
long uniqueId = itemStack.getTag().getLong("UniqueId");
list.add(Component.translatable(ModLangKeyValue.CANVAS_HOVER_UNIQUE_ID.getKey(), uniqueId));
canvasUniqueId = uniqueId;
} else {
list.add(Component.translatable(ModLangKeyValue.CANVAS_HOVER_DESC_EMPTY.getKey()));
}
int size;
if (canvasUniqueId != null) {
size = ModernLifeClient.getCanvasWidth(canvasUniqueId);
int height = ModernLifeClient.getCanvasHeight(canvasUniqueId);
list.add(Component.translatable(ModLangKeyValue.CANVAS_HOVER_PIXELS_SIZE.getKey() , size, height));
}
if (itemStack.getTag() != null && itemStack.getTag().contains("Size")) {
size = itemStack.getTag().getInt("Size");
list.add(Component.literal(""));
if (size == 1) {
list.add(Component.translatable(ModLangKeyValue.CANVAS_HOVER_DESC_SIZE_NORMAL.getKey()));
} else if (size == 2) {
list.add(Component.translatable(ModLangKeyValue.CANVAS_HOVER_DESC_SIZE_LARGE.getKey()));
} else if (size == 3) {
list.add(Component.translatable(ModLangKeyValue.CANVAS_HOVER_DESC_SIZE_EXTRA_LARGE.getKey()));
} else if (size == 4) {
list.add(Component.translatable(ModLangKeyValue.CANVAS_HOVER_DESC_SIZE_MASSIVE.getKey()));
} else if (size == 5) {
list.add(Component.translatable(ModLangKeyValue.CANVAS_HOVER_DESC_SIZE_LARGE_SQUARE.getKey()));
} else if (size == 6) {
list.add(Component.translatable(ModLangKeyValue.CANVAS_HOVER_DESC_SIZE_EXTRA_LARGE_SQUARE.getKey()));
} else if (size == 7) {
list.add(Component.translatable(ModLangKeyValue.CANVAS_HOVER_DESC_SIZE_MASSIVE_SQUARE.getKey()));
} else if (size == 0) {
list.add(Component.translatable(ModLangKeyValue.CANVAS_HOVER_DESC_SIZE_CUSTOM.getKey()));
CompoundTag nbt = itemStack.getTag();
DecimalFormat df = new DecimalFormat("#.##");
String var10003;
float xOffset;
float yOffset;
if (nbt.contains("BlockWidth") && nbt.contains("BlockHeight")) {
xOffset = nbt.getFloat("BlockWidth");
yOffset = nbt.getFloat("BlockHeight");
var10003 = df.format(xOffset);
list.add(Component.translatable(ModLangKeyValue.CANVAS_HOVER_BLOCK_SIZE.getKey(), var10003, df.format(yOffset)));
}
if (nbt.contains("xOffset") && nbt.contains("yOffset")) {
xOffset = nbt.getFloat("xOffset");
yOffset = nbt.getFloat("yOffset");
if (xOffset != 0.0F || yOffset != 0.0F) {
var10003 = df.format(xOffset);
list.add(Component.translatable(ModLangKeyValue.CANVAS_HOVER_OFFSET.getKey(), var10003, df.format(yOffset)));
}
}
}
}
ci.cancel();
}
}

View File

@ -0,0 +1,24 @@
package com.r3944realms.modernlifepatch.mixin.block.common;
import com.dairymoose.modernlife.blocks.CeilingFanBlock;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.List;
@Mixin(CeilingFanBlock.class)
public class MixinCeilingFan {
@Inject(method = {"appendHoverText"}, at= @At("HEAD"), cancellable = true)
public void appendHoverText(ItemStack itemStack, BlockGetter blockReader, List<Component> list, TooltipFlag tooltipFlag, CallbackInfo ci) {
list.add(Component.translatable(ModLangKeyValue.NEED_RED_STONE_POWER_HOVER.getKey()));
ci.cancel();
}
}

View File

@ -0,0 +1,58 @@
package com.r3944realms.modernlifepatch.mixin.block.common;
import com.dairymoose.modernlife.blocks.ChairBlock;
import com.dairymoose.modernlife.blocks.StandardHorizontalBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.stream.Stream;
@Mixin(ChairBlock.class)
public class MixinChair extends StandardHorizontalBlock {
public MixinChair(Properties properties) {
super(properties);
}
@Unique
private static final VoxelShape SHAPE_S = Stream.of(
Block.box(2, 7, 2, 14, 10, 14),
Block.box(4, 10, 13, 12, 25, 13),
Block.box(2, 10, 12, 4, 24, 14),
Block.box(12, 10, 12, 14, 24, 14),
Block.box(4, 2, 3, 12, 4, 3),
Block.box(4, 2, 13, 12, 4, 13),
Block.box(13, 2, 4, 13, 4, 12),
Block.box(3, 2, 4, 3, 4, 12),
Block.box(12, 0, 2, 14, 7, 4),
Block.box(2, 0, 2, 4, 7, 4),
Block.box(2, 0, 12, 4, 7, 14),
Block.box(12, 0, 12, 14, 7, 14)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(), SHAPE_E, SHAPE_N, SHAPE_W;
static {
SHAPE_W = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S);
SHAPE_N = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_W);
SHAPE_E = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
switch (bs.getValue(FACING)) {
case SOUTH -> cir.setReturnValue(SHAPE_S);
case EAST -> cir.setReturnValue(SHAPE_E);
case WEST -> cir.setReturnValue(SHAPE_W);
default -> cir.setReturnValue(SHAPE_N);
}
}
}

View File

@ -0,0 +1,25 @@
package com.r3944realms.modernlifepatch.mixin.block.common;
import com.dairymoose.modernlife.blocks.ChessBoardBlock;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.List;
@Mixin(ChessBoardBlock.class)
public class MixinChessBoard {
@Inject(method = {"appendHoverText"}, at= @At("HEAD"), cancellable = true)
public void appendHoverText(ItemStack itemStack, BlockGetter blockReader, List<Component> list, TooltipFlag tooltipFlag, CallbackInfo ci) {
list.add(Component.translatable(ModLangKeyValue.CHESS_BOARD_HOVER.getKey()));
ci.cancel();
}
}

View File

@ -0,0 +1,50 @@
package com.r3944realms.modernlifepatch.mixin.block.common;
import com.dairymoose.modernlife.blocks.CoffeeMugBlock;
import com.dairymoose.modernlife.blocks.StandardHorizontalBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.stream.Stream;
@Mixin(CoffeeMugBlock.class)
public class MixinCoffeeMug extends StandardHorizontalBlock {
public MixinCoffeeMug(Properties properties) {
super(properties);
}
@Unique
private static final VoxelShape SHAPE_N = Stream.of(
Block.box(7, 0, 9, 9, 5, 10),
Block.box(7, 0, 6, 9, 5, 7),
Block.box(7, 0, 7, 9, 1, 9),
Block.box(6, 0, 6, 7, 5, 10),
Block.box(9, 0, 6, 10, 5, 10)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(), SHAPE_E, SHAPE_S, SHAPE_W;
static {
SHAPE_E = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N);
SHAPE_S = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_E);
SHAPE_W = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
switch (bs.getValue(FACING)) {
case SOUTH -> cir.setReturnValue(SHAPE_S);
case EAST -> cir.setReturnValue(SHAPE_E);
case WEST -> cir.setReturnValue(SHAPE_W);
default -> cir.setReturnValue(SHAPE_N);
}
}
}

View File

@ -0,0 +1,36 @@
package com.r3944realms.modernlifepatch.mixin.block.common;
import com.dairymoose.modernlife.blocks.DeckBlock;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.stream.Stream;
@Mixin(DeckBlock.class)
public class MixinDeck {
@Unique
private static final VoxelShape SHAPE_S = Stream.of(
Block.box(0, 14, 4, 16, 16, 7),
Block.box(3, 13, 0, 6, 15, 16),
Block.box(10, 13, 0, 13, 15, 16),
Block.box(0, 14, 0, 16, 16, 3),
Block.box(0, 14, 12, 16, 16, 15),
Block.box(0, 14, 8, 16, 16, 11)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(),
_WITH_SUPPORT = Stream.of(SHAPE_S, Block.box(6.0, 0.0, 6.0, 10.0, 14.0, 10.0)).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get();
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
cir.setReturnValue(!bs.getValue(DeckBlock.SUPPORT) ? SHAPE_S : _WITH_SUPPORT);
}
}

View File

@ -0,0 +1,51 @@
package com.r3944realms.modernlifepatch.mixin.block.common;
import com.dairymoose.modernlife.blocks.EaselBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.List;
import static com.dairymoose.modernlife.blocks.EaselBlock.FACING;
@Mixin(EaselBlock.class)
public class MixinEasel {
@Unique
private static final VoxelShape SHAPE_N = Block.box(2, 0, 4, 14, 22, 15), SHAPE_E, SHAPE_S, SHAPE_W;
static {
SHAPE_E = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N);
SHAPE_S = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_E);
SHAPE_W = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
switch (bs.getValue(FACING)) {
case SOUTH -> cir.setReturnValue(SHAPE_S);
case EAST -> cir.setReturnValue(SHAPE_E);
case WEST -> cir.setReturnValue(SHAPE_W);
default -> cir.setReturnValue(SHAPE_N);
}
}
@Inject(method = {"appendHoverText"}, at= @At("HEAD"), cancellable = true)
public void appendHoverText(ItemStack itemStack, BlockGetter blockReader, List<Component> list, TooltipFlag tooltipFlag, CallbackInfo ci) {
list.add(Component.translatable(ModLangKeyValue.EASEL_HOVER.getKey()));
ci.cancel();
}
}

View File

@ -0,0 +1,40 @@
package com.r3944realms.modernlifepatch.mixin.block.common;
import com.dairymoose.modernlife.blocks.FlatScreenTvBlock;
import com.dairymoose.modernlife.blocks.StandardHorizontalBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(FlatScreenTvBlock.class)
public class MixinFlatScreenTV extends StandardHorizontalBlock {
public MixinFlatScreenTV(Properties properties) {
super(properties);
}
@Unique
private static final VoxelShape SHAPE_N = Block.box(-11, 0, 6, 27, 23, 9), SHAPE_E, SHAPE_S, SHAPE_W;
static {
SHAPE_E = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N);
SHAPE_S = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_E);
SHAPE_W = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
switch (bs.getValue(FACING)) {
case SOUTH -> cir.setReturnValue(SHAPE_S);
case EAST -> cir.setReturnValue(SHAPE_E);
case WEST -> cir.setReturnValue(SHAPE_W);
default -> cir.setReturnValue(SHAPE_N);
}
}
}

View File

@ -0,0 +1,50 @@
package com.r3944realms.modernlifepatch.mixin.block.common;
import com.dairymoose.modernlife.blocks.GuitarAmplifierBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.List;
@Mixin(GuitarAmplifierBlock.class)
public class MixinGuitarAmplifier {
@Unique
private static final VoxelShape SHAPE_S = Block.box(2, 0, 5, 14, 12, 11), SHAPE_E, SHAPE_N, SHAPE_W;
static {
SHAPE_W = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S);
SHAPE_N = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_W);
SHAPE_E = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
switch (bs.getValue(GuitarAmplifierBlock.FACING)) {
case SOUTH -> cir.setReturnValue(SHAPE_S);
case EAST -> cir.setReturnValue(SHAPE_E);
case WEST -> cir.setReturnValue(SHAPE_W);
default -> cir.setReturnValue(SHAPE_N);
}
}
@Inject(method = {"appendHoverText"}, at= @At("HEAD"), cancellable = true)
public void appendHoverText(ItemStack itemStack, BlockGetter blockReader, List<Component> list, TooltipFlag tooltipFlag, CallbackInfo ci) {
list.add(Component.translatable(ModLangKeyValue.GUITAR_AMPLIFIER_HOVER.getKey()));
ci.cancel();
}
}

View File

@ -0,0 +1,69 @@
package com.r3944realms.modernlifepatch.mixin.block.common;
import com.dairymoose.modernlife.blocks.LightBulbBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.List;
@Mixin(LightBulbBlock.class)
public class MixinLightBulb extends FaceAttachedHorizontalDirectionalBlock {
public MixinLightBulb(Properties properties) {
super(properties);
}
@Unique
private static final VoxelShape _SHAPE_CEILING = Shapes.join(Block.box(5, 8, 5, 11, 14, 11), Block.box(7, 13, 7, 9, 16, 9), BooleanOp.OR)
, _SHAPE_WALL_NORTH, _SHAPE_WALL_EAST, _SHAPE_WALL_SOUTH, _SHAPE_WALL_WEST, _SHAPE_FLOOR;
static {
_SHAPE_WALL_NORTH = ModernLifeUtil.RotateVoxelShapeXAxis(_SHAPE_CEILING);
_SHAPE_WALL_EAST = ModernLifeUtil.RotateVoxelShapeClockwise(_SHAPE_WALL_NORTH);
_SHAPE_WALL_SOUTH = ModernLifeUtil.RotateVoxelShapeClockwise(_SHAPE_WALL_EAST);
_SHAPE_WALL_WEST = ModernLifeUtil.RotateVoxelShapeClockwise(_SHAPE_WALL_SOUTH);
_SHAPE_FLOOR = ModernLifeUtil.RotateVoxelShapeXAxis(_SHAPE_WALL_NORTH);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
switch (bs.getValue(FACE)) {
case WALL:
switch (bs.getValue(FACING)) {
case NORTH -> cir.setReturnValue(_SHAPE_WALL_NORTH);
case EAST -> cir.setReturnValue(_SHAPE_WALL_EAST);
case WEST -> cir.setReturnValue(_SHAPE_WALL_WEST);
case SOUTH -> cir.setReturnValue(_SHAPE_WALL_SOUTH);
}
break;
case FLOOR:
cir.setReturnValue(_SHAPE_FLOOR);
break;
default:
cir.setReturnValue(_SHAPE_CEILING);
}
}
@Inject(method = {"appendHoverText"}, at= @At("HEAD"), cancellable = true)
public void appendHoverText(ItemStack itemStack, BlockGetter blockReader, List<Component> list, TooltipFlag tooltipFlag, CallbackInfo ci) {
list.add(Component.translatable(ModLangKeyValue.NEED_RED_STONE_POWER_HOVER.getKey()));
ci.cancel();
}
}

View File

@ -0,0 +1,38 @@
package com.r3944realms.modernlifepatch.mixin.block.common;
import com.dairymoose.modernlife.blocks.MetalDuctBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import static com.dairymoose.modernlife.blocks.MetalDuctBlock.AXIS;
@Mixin(MetalDuctBlock.class)
public class MixinMetalDuct {
@Unique
private static final VoxelShape SHAPE_Y = Block.box(3, 0, 3, 13, 16, 13), SHAPE_X, SHAPE_Z;
static {
SHAPE_Z = ModernLifeUtil.RotateVoxelShapeXAxis(SHAPE_Y);
SHAPE_X = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_Z);
}
@Inject(method = {"getShape"}, at = @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
if (bs.getValue(AXIS) == Direction.Axis.X) {
cir.setReturnValue(SHAPE_X);
} else {
cir.setReturnValue(bs.getValue(AXIS) == Direction.Axis.Z ? SHAPE_Z : SHAPE_Y);
}
}
}

View File

@ -0,0 +1,24 @@
package com.r3944realms.modernlifepatch.mixin.block.common;
import com.dairymoose.modernlife.blocks.GrateBlock;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.List;
@Mixin(GrateBlock.class)
public class MixinMetalGrate {
@Inject(method = {"appendHoverText"}, at= @At("HEAD"), cancellable = true)
private void appendHoverTextHead(ItemStack itemStack, BlockGetter blockReader, List<Component> list, TooltipFlag tooltipFlag, CallbackInfo ci) {
list.add(Component.translatable(ModLangKeyValue.METAL_GRATE_HOVER.getKey()));
ci.cancel();
}
}

View File

@ -0,0 +1,25 @@
package com.r3944realms.modernlifepatch.mixin.block.common;
import com.dairymoose.modernlife.blocks.PavedRoadBlock;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.List;
@Mixin(PavedRoadBlock.class)
public class MixinPavedRoad {
@Inject(method = {"appendHoverText"}, at= @At("HEAD"), cancellable = true)
public void appendHoverText(ItemStack itemStack, BlockGetter blockReader, List<Component> list, TooltipFlag tooltipFlag, CallbackInfo ci) {
list.add(Component.translatable(ModLangKeyValue.PAVED_ROAD_HOVER.getKey()));
ci.cancel();
}
}

View File

@ -0,0 +1,95 @@
package com.r3944realms.modernlifepatch.mixin.block.common;
import com.dairymoose.modernlife.blocks.PhotocopierBlock;
import com.dairymoose.modernlife.blocks.StandardHorizontalBlock;
import com.dairymoose.modernlife.blocks.WallSocketBlock;
import com.dairymoose.modernlife.tileentities.PhotocopierBlockEntity;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.ChestMenu;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.List;
import java.util.stream.Stream;
@Mixin(PhotocopierBlock.class)
public abstract class MixinPhotoCopier extends StandardHorizontalBlock implements EntityBlock {
public MixinPhotoCopier(Properties properties) {
super(properties);
}
@Unique
private static final VoxelShape SHAPE_N = Stream.of(
Block.box(4, 15.999, 2, 10, 15.999, 16),
Block.box(0, 0, 0, 16, 8, 16),
Block.box(0, 11, 0, 16, 14, 16),
Block.box(0, 8, 13, 16, 11, 16),
Block.box(0, 8, 2, 4, 11, 13),
Block.box(10, 14, 2, 16, 16, 16)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(), SHAPE_E, SHAPE_S, SHAPE_W;
static {
SHAPE_E = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N);
SHAPE_S = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_E);
SHAPE_W = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
switch (bs.getValue(WallSocketBlock.FACING)) {
case SOUTH -> cir.setReturnValue(SHAPE_S);
case EAST -> cir.setReturnValue(SHAPE_E);
case WEST -> cir.setReturnValue(SHAPE_W);
default -> cir.setReturnValue(SHAPE_N);
}
}
@Inject(method = {"getMenuProvider"}, at = @At("HEAD"), cancellable = true)
public void getMenuProvider(BlockState blockState, Level level, BlockPos blockPos, CallbackInfoReturnable<MenuProvider> cir) {
cir.setReturnValue(new MenuProvider() {
@Override
public AbstractContainerMenu createMenu(int paramInt, @NotNull Inventory paramInventory, @NotNull Player paramPlayer) {
BlockEntity tileEntity = level.getBlockEntity(blockPos);
if (tileEntity instanceof PhotocopierBlockEntity photocopierBlockEntity) {
return new ChestMenu(MenuType.GENERIC_9x3, paramInt, paramInventory, photocopierBlockEntity, 3);
} else {
return null;
}
}
@Override
public @NotNull Component getDisplayName() {
return Component.translatable(ModLangKeyValue.PHOTOCOPIER_MENU_LABEL.getKey());
}
});
}
@Inject(method = {"appendHoverText"}, at= @At("HEAD"), cancellable = true)
public void appendHoverText(ItemStack itemStack, BlockGetter blockReader, List<Component> list, TooltipFlag tooltipFlag, CallbackInfo ci) {
list.add(Component.translatable(ModLangKeyValue.PHOTOCOPIER_HOVER_FIRST.getKey()));
list.add(Component.translatable(ModLangKeyValue.PHOTOCOPIER_HOVER_SECOND.getKey()));
ci.cancel();
}
}

View File

@ -0,0 +1,44 @@
package com.r3944realms.modernlifepatch.mixin.block.common;
import com.dairymoose.modernlife.blocks.PrinterBlock;
import com.dairymoose.modernlife.tileentities.PrinterBlockEntity;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.ChestMenu;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(PrinterBlock.class)
public class MixinPrinter {
@Inject(method = {"getMenuProvider"}, at = @At("HEAD"), cancellable = true)
public void getMenuProvider(BlockState blockState, Level level, BlockPos blockPos, CallbackInfoReturnable<MenuProvider> cir) {
cir.setReturnValue(new MenuProvider() {
public AbstractContainerMenu createMenu(int paramInt, @NotNull Inventory paramInventory, @NotNull Player paramPlayer) {
BlockEntity tileEntity = level.getBlockEntity(blockPos);
if (tileEntity instanceof PrinterBlockEntity printerBlockEntity) {
return new ChestMenu(MenuType.GENERIC_9x3, paramInt, paramInventory, printerBlockEntity, 3);
} else {
return null;
}
}
@Override
public @NotNull Component getDisplayName() {
return Component.translatable(ModLangKeyValue.PRINTER_MENU_LABEL.getKey());
}
});
}
}

View File

@ -0,0 +1,66 @@
package com.r3944realms.modernlifepatch.mixin.block.common;
import com.dairymoose.modernlife.blocks.RadiatorBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.List;
import java.util.stream.Stream;
import static com.dairymoose.modernlife.blocks.RadiatorBlock.FACING;
@Mixin(RadiatorBlock.class)
public class MixinRadiator {
@Unique
private static final VoxelShape SHAPE_N = Stream.of(
Block.box(1, 1, 4, 15, 3, 12),
Block.box(1, 3, 4, 3, 13, 12),
Block.box(4, 3, 4, 6, 13, 12),
Block.box(7, 3, 4, 9, 13, 12),
Block.box(10, 3, 4, 12, 13, 12),
Block.box(13, 3, 4, 15, 13, 12),
Block.box(1, 0, 10, 3, 1, 12),
Block.box(1, 0, 4, 3, 1, 6),
Block.box(13, 0, 10, 15, 1, 12),
Block.box(13, 0, 4, 15, 1, 6),
Block.box(3, 3, 5, 13, 12, 11)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(), SHAPE_E, SHAPE_S, SHAPE_W;
static {
SHAPE_E = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N);
SHAPE_S = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_E);
SHAPE_W = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
switch (bs.getValue(FACING)) {
case SOUTH -> cir.setReturnValue(SHAPE_S);
case EAST -> cir.setReturnValue(SHAPE_E);
case WEST -> cir.setReturnValue(SHAPE_W);
default -> cir.setReturnValue(SHAPE_N);
}
}
@Inject(method = {"appendHoverText"}, at= @At("HEAD"), cancellable = true)
public void appendHoverText(ItemStack itemStack, BlockGetter blockReader, List<Component> list, TooltipFlag tooltipFlag, CallbackInfo ci) {
list.add(Component.translatable(ModLangKeyValue.STEAM_RADIATOR_HOVER.getKey()));
ci.cancel();
}
}

View File

@ -0,0 +1,77 @@
package com.r3944realms.modernlifepatch.mixin.block.common;
import com.dairymoose.modernlife.blocks.SeedSpreaderBlock;
import com.dairymoose.modernlife.tileentities.SeedSpreaderBlockEntity;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.ChestMenu;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.List;
import java.util.stream.Stream;
@Mixin(SeedSpreaderBlock.class)
public class MixinSeedSpreader {
@Unique
private static final VoxelShape SHAPE_N = Stream.of(
Block.box(3, 11, 3, 13, 14, 13),
Block.box(4, 4, 4, 12, 11, 12),
Block.box(5, 4, 5, 11, 8, 11)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get();
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
cir.setReturnValue(SHAPE_N);
}
@Inject(method = {"appendHoverText"}, at= @At("HEAD"), cancellable = true)
public void appendHoverText(ItemStack itemStack, BlockGetter blockReader, List<Component> list, TooltipFlag tooltipFlag, CallbackInfo ci) {
list.add(Component.translatable(ModLangKeyValue.SEED_SPREADER_HOVER.getKey()));
ci.cancel();
}
@Inject(method = {"getMenuProvider"}, at = @At("HEAD"), cancellable = true)
public void getMenuProvider(BlockState blockState, Level level, BlockPos blockPos, CallbackInfoReturnable<MenuProvider> cir) {
cir.setReturnValue(new MenuProvider() {
@Override
public AbstractContainerMenu createMenu(int paramInt, @NotNull Inventory paramInventory, @NotNull Player paramPlayer) {
BlockEntity tileEntity = level.getBlockEntity(blockPos);
if (tileEntity instanceof SeedSpreaderBlockEntity seedSpreaderBlockEntity) {
return new ChestMenu(MenuType.GENERIC_9x1, paramInt, paramInventory, seedSpreaderBlockEntity, 1);
} else {
return null;
}
}
@Override
public @NotNull Component getDisplayName() {
return Component.translatable(ModLangKeyValue.SEED_SPREADER_MENU_LABEL.getKey());
}
});
}
}

View File

@ -0,0 +1,40 @@
package com.r3944realms.modernlifepatch.mixin.block.common;
import com.dairymoose.modernlife.blocks.TileLightBlock;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.List;
@Mixin(TileLightBlock.class)
public class MixinTileLight {
@Unique
private static final VoxelShape SHAPE_N = Shapes.join(Block.box(5, 15, 5, 11, 16, 11), Block.box(6, 14, 6, 10, 15, 10), BooleanOp.OR);
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
cir.setReturnValue(SHAPE_N);
}
@Inject(method = {"appendHoverText"}, at= @At("HEAD"), cancellable = true)
public void appendHoverText(ItemStack itemStack, BlockGetter blockReader, List<Component> list, TooltipFlag tooltipFlag, CallbackInfo ci) {
list.add(Component.translatable(ModLangKeyValue.NEED_RED_STONE_POWER_HOVER.getKey()));
ci.cancel();
}
}

View File

@ -0,0 +1,76 @@
package com.r3944realms.modernlifepatch.mixin.block.common;
import com.dairymoose.inventory.container.TrashCanContainer;
import com.dairymoose.modernlife.blocks.TrashCanBlock;
import com.dairymoose.modernlife.tileentities.TrashCanBlockEntity;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.List;
import java.util.stream.Stream;
@Mixin(TrashCanBlock.class)
public abstract class MixinTrashCan extends Block implements EntityBlock {
public MixinTrashCan(Properties properties) {
super(properties);
}
@Unique
private static final VoxelShape SHAPE_N = Stream.of(
Block.box(6, 17, 7.5, 10, 18, 8.5),
Block.box(2, 13, 2, 14, 16, 14),
Block.box(3, 0, 3, 13, 13, 13)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get();
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
cir.setReturnValue(SHAPE_N);
}
@Inject(method = {"getMenuProvider"}, at = @At("HEAD"), cancellable = true)
public void getMenuProvider(BlockState blockState, Level level, BlockPos blockPos, CallbackInfoReturnable<MenuProvider> cir) {
cir.setReturnValue(new MenuProvider() {
public AbstractContainerMenu createMenu(int paramInt, @NotNull Inventory paramInventory, @NotNull Player paramPlayer) {
BlockEntity tileEntity = level.getBlockEntity(blockPos);
if (tileEntity instanceof TrashCanBlockEntity trashCanBlockEntity) {
return new TrashCanContainer(paramInt, paramInventory, trashCanBlockEntity);
} else {
return null;
}
}
@Override
public @NotNull Component getDisplayName() {
return Component.translatable(ModLangKeyValue.TRASH_CAN_MENU_LABEL.getKey());
}
});
}
@Inject(method = {"appendHoverText"}, at= @At("HEAD"), cancellable = true)
public void appendHoverText(ItemStack itemStack, BlockGetter blockReader, List<Component> list, TooltipFlag tooltipFlag, CallbackInfo ci) {
list.add(Component.translatable(ModLangKeyValue.TRASH_CAN_HOVER.getKey()));
ci.cancel();
}
}

View File

@ -0,0 +1,26 @@
package com.r3944realms.modernlifepatch.mixin.block.common;
import com.dairymoose.modernlife.blocks.WallShelfBlock;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.List;
@Mixin(WallShelfBlock.class)
public class MixinWallShelf {
@Inject(method = {"appendHoverText"}, at= @At("HEAD"), cancellable = true)
public void appendHoverText(ItemStack itemStack, BlockGetter blockReader, List<Component> list, TooltipFlag tooltipFlag, CallbackInfo ci) {
list.add(Component.translatable(ModLangKeyValue.WALL_SHELF_HOVER_FIRST.getKey()));
list.add(Component.translatable(ModLangKeyValue.WALL_SHELF_HOVER_SECOND.getKey()));
ci.cancel();
}
}

View File

@ -0,0 +1,36 @@
package com.r3944realms.modernlifepatch.mixin.block.common;
import com.dairymoose.modernlife.blocks.WallSocketBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(WallSocketBlock.class)
public class MixinWallSocket {
@Unique
private static final VoxelShape SHAPE_S = Block.box(5, 4, 0, 11, 12, 1), SHAPE_E, SHAPE_N, SHAPE_W;
static {
SHAPE_W = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S);
SHAPE_N = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_W);
SHAPE_E = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
switch (bs.getValue(WallSocketBlock.FACING)) {
case SOUTH -> cir.setReturnValue(SHAPE_S);
case EAST -> cir.setReturnValue(SHAPE_E);
case WEST -> cir.setReturnValue(SHAPE_W);
default -> cir.setReturnValue(SHAPE_N);
}
}
}

View File

@ -0,0 +1,45 @@
package com.r3944realms.modernlifepatch.mixin.block.kitchen;
import com.dairymoose.modernlife.blocks.KitchenCabinetBlock;
import com.dairymoose.modernlife.blocks.NightStandBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import com.r3944realms.modernlifepatch.modInterface.IContainMenu;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@SuppressWarnings("AddedMixinMembersNamePattern")
@Mixin(KitchenCabinetBlock.class)
public class MixinKitchenCabinet extends NightStandBlock implements IContainMenu {
@Override
public String ContainMenuLabel() {
return ModLangKeyValue.KITCHEN_CABINET_MENU_LABEL.getKey();
}
@Unique
private static final VoxelShape SHAPE_S = Block.box(0, 0, 0, 16, 16, 15), SHAPE_E, SHAPE_N, SHAPE_W;
static {
SHAPE_W = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S);
SHAPE_N = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_W);
SHAPE_E = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
switch (bs.getValue(FACING)) {
case SOUTH -> cir.setReturnValue(SHAPE_S);
case EAST -> cir.setReturnValue(SHAPE_E);
case WEST -> cir.setReturnValue(SHAPE_W);
default -> cir.setReturnValue(SHAPE_N);
}
}
}

View File

@ -0,0 +1,49 @@
package com.r3944realms.modernlifepatch.mixin.block.kitchen;
import com.dairymoose.modernlife.blocks.KitchenDrawerCabinetBlock;
import com.dairymoose.modernlife.blocks.NightStandBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import com.r3944realms.modernlifepatch.modInterface.IContainMenu;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@SuppressWarnings("AddedMixinMembersNamePattern")
@Mixin(KitchenDrawerCabinetBlock.class)
public class MixinKitchenDrawerCabinet extends NightStandBlock implements IContainMenu {
public MixinKitchenDrawerCabinet(Properties properties) {
super(properties);
}
@Override
public String ContainMenuLabel() {
return ModLangKeyValue.KITCHEN_DRAWER_CABINET_MENU_LABEL.getKey();
}
@Unique
private static final VoxelShape SHAPE_S = Block.box(0, 0, 0, 16, 16, 15), SHAPE_E, SHAPE_N, SHAPE_W;
static {
SHAPE_W = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S);
SHAPE_N = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_W);
SHAPE_E = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
switch (bs.getValue(FACING)) {
case SOUTH -> cir.setReturnValue(SHAPE_S);
case EAST -> cir.setReturnValue(SHAPE_E);
case WEST -> cir.setReturnValue(SHAPE_W);
default -> cir.setReturnValue(SHAPE_N);
}
}
}

View File

@ -0,0 +1,58 @@
package com.r3944realms.modernlifepatch.mixin.block.kitchen;
import com.dairymoose.modernlife.blocks.KitchenSinkBlock;
import com.dairymoose.modernlife.blocks.StandardHorizontalBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.stream.Stream;
@Mixin(KitchenSinkBlock.class)
public class MixinKitchenSink extends StandardHorizontalBlock {
//这个居然是反的
public MixinKitchenSink(Properties properties) {
super(properties);
}
@Unique
private static final VoxelShape SHAPE_S = Stream.of(
Block.box(4, 3, 0, 12, 5, 3),
Block.box(5, 5, 1, 6, 6, 2),
Block.box(10, 5, 1, 11, 6, 2),
Block.box(7, 5, 0, 9, 8, 2),
Block.box(7, 8, 0, 9, 10, 7),
Block.box(7, 7, 5, 9, 8, 7),
Block.box(0, 0, 13, 16, 3, 16),
Block.box(0, 0, 0, 16, 3, 3),
Block.box(0, 0, 3, 3, 3, 13),
Block.box(13, 0, 3, 16, 3, 13),
Block.box(3, 0, 3, 13, 1, 13)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(), SHAPE_E, SHAPE_N, SHAPE_W;
static {
SHAPE_W = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S);
SHAPE_N = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_W);
SHAPE_E = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
switch (bs.getValue(FACING)) {
case SOUTH -> cir.setReturnValue(SHAPE_S);
case EAST -> cir.setReturnValue(SHAPE_E);
case WEST -> cir.setReturnValue(SHAPE_W);
default -> cir.setReturnValue(SHAPE_N);
}
}
}

View File

@ -0,0 +1,63 @@
package com.r3944realms.modernlifepatch.mixin.block.kitchen;
import com.dairymoose.modernlife.blocks.MicrowaveBlock;
import com.dairymoose.modernlife.blocks.StandardHorizontalBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.stream.Stream;
@Mixin(MicrowaveBlock.class)
public abstract class MixinMicrowave extends StandardHorizontalBlock implements EntityBlock {
@Unique
private static final VoxelShape SHAPE_N = Stream.of(
Block.box(1, 8, 2, 15, 10, 14),
Block.box(12, 2, 2, 15, 8, 14),
Block.box(1, 0, 2, 15, 2, 14),
Block.box(1, 2, 2, 3, 8, 14),
Block.box(3, 2, 2, 12, 8, 5),
Block.box(3, 2, 14, 12, 8, 14)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(), SHAPE_E, SHAPE_S, SHAPE_W,
SHAPE_N_O = Stream.of(
Block.box(3, 2, 2, 12, 8, 5),
Block.box(1, 8, 2, 15, 10, 14),
Block.box(12, 2, 2, 15, 8, 14),
Block.box(1, 0, 2, 15, 2, 14),
Block.box(1, 2, 2, 3, 8, 14)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(), SHAPE_E_O, SHAPE_S_O, SHAPE_W_O;
static {
SHAPE_E = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N);
SHAPE_S = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_E);
SHAPE_W = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S);
SHAPE_E_O = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N_O);
SHAPE_S_O = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_E_O);
SHAPE_W_O = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S_O);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
boolean isOpen = bs.getValue(MicrowaveBlock.OPEN_DOOR);
switch (bs.getValue(FACING)) {
case SOUTH -> cir.setReturnValue(isOpen ? SHAPE_S_O :SHAPE_S);
case EAST -> cir.setReturnValue(isOpen ? SHAPE_E_O : SHAPE_E);
case WEST -> cir.setReturnValue(isOpen ? SHAPE_W_O : SHAPE_W);
default -> cir.setReturnValue(isOpen? SHAPE_N_O : SHAPE_N);
}
}
public MixinMicrowave(Properties properties) {
super(properties);
}
}

View File

@ -0,0 +1,44 @@
package com.r3944realms.modernlifepatch.mixin.block.kitchen;
import com.dairymoose.modernlife.blocks.RefrigeratorBlock;
import com.dairymoose.modernlife.tileentities.SeedSpreaderBlockEntity;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.ChestMenu;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(RefrigeratorBlock.class)
public class MixinRefrigerator {
@Inject(method = {"getMenuProvider"}, at = @At("HEAD"), cancellable = true)
public void getMenuProvider(BlockState blockState, Level level, BlockPos blockPos, CallbackInfoReturnable<MenuProvider> cir) {
cir.setReturnValue(new MenuProvider() {
@Override
public AbstractContainerMenu createMenu(int paramInt, @NotNull Inventory paramInventory, @NotNull Player paramPlayer) {
BlockEntity tileEntity = level.getBlockEntity(blockPos);
if (tileEntity instanceof SeedSpreaderBlockEntity seedSpreaderBlockEntity) {
return new ChestMenu(MenuType.GENERIC_9x1, paramInt, paramInventory, seedSpreaderBlockEntity, 1);
} else {
return null;
}
}
public @NotNull Component getDisplayName() {
return Component.translatable(ModLangKeyValue.REFRIGERATOR_MENU_LABEL.getKey());
}
});
}
}

View File

@ -0,0 +1,76 @@
package com.r3944realms.modernlifepatch.mixin.block.kitchen;
import com.dairymoose.modernlife.blocks.StandardHorizontalBlock;
import com.dairymoose.modernlife.blocks.StoveBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.stream.Stream;
@Mixin(StoveBlock.class)
public abstract class MixinStove extends StandardHorizontalBlock implements EntityBlock {
public MixinStove(Properties properties) {
super(properties);
}
@Unique
private static final VoxelShape SHAPE_N = Stream.of(
Stream.of(
Block.box(0, 0, 15, 16, 2, 16),
Block.box(0, 8, 15, 16, 10, 16),
Block.box(13, 2, 15, 16, 8, 16),
Block.box(0, 2, 15, 3, 8, 16),
Block.box(3, 2, 16, 13, 8, 16)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(),
Block.box(0, 0, 0, 16, 2, 15),
Block.box(0, 9, 0, 16, 13, 15),
Block.box(0, 13, 0, 16, 16, 2),
Block.box(0, 10, 15, 16, 13, 16),
Block.box(3, 2, 0, 13, 9, 3),
Block.box(13, 2, 0, 16, 9, 15),
Block.box(0, 2, 0, 3, 9, 15),
Block.box(3, 6, 3, 13, 6, 14),
Block.box(3, 3, 3, 13, 3, 14)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(), SHAPE_E, SHAPE_S, SHAPE_W,
SHAPE_N_O = Stream.of(
Block.box(0, 0, 0, 16, 2, 15),
Block.box(0, 9, 0, 16, 13, 15),
Block.box(0, 13, 0, 16, 16, 2),
Block.box(0, 10, 15, 16, 13, 16),
Block.box(3, 2, 0, 13, 9, 3),
Block.box(13, 2, 0, 16, 9, 15),
Block.box(0, 2, 0, 3, 9, 15)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(), SHAPE_E_O, SHAPE_S_O, SHAPE_W_O;
static {
SHAPE_E = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N);
SHAPE_S = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_E);
SHAPE_W = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S);
SHAPE_E_O = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N_O);
SHAPE_S_O = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_E_O);
SHAPE_W_O = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S_O);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
boolean isOpen = bs.getValue(StoveBlock.OPEN_DOOR);
switch (bs.getValue(FACING)) {
case SOUTH -> cir.setReturnValue(isOpen ? SHAPE_S_O : SHAPE_S);
case EAST -> cir.setReturnValue(isOpen ? SHAPE_E_O : SHAPE_E);
case WEST -> cir.setReturnValue(isOpen ? SHAPE_W_O : SHAPE_W);
default -> cir.setReturnValue(isOpen ? SHAPE_N_O : SHAPE_N);
}
}
}

View File

@ -0,0 +1,119 @@
package com.r3944realms.modernlifepatch.mixin.block.lounge;
import com.dairymoose.modernlife.blocks.SofaBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.stream.Stream;
import static com.dairymoose.modernlife.blocks.SofaBlock.FACING;
import static com.dairymoose.modernlife.blocks.SofaBlock.TYPE;
@Mixin(SofaBlock.class)
public class MixinSofa {
@Unique
private static final VoxelShape SHAPE_N_SINGLE = Stream.of(
Block.box(0, 2, 13, 16, 17, 16),
Block.box(0, 2, 0, 3, 11, 13),
Block.box(13, 2, 0, 16, 11, 13),
Block.box(3, 2, 0, 13, 6, 13),
Block.box(3, 6, 3, 13, 8, 13),
Block.box(0, 0, 0, 16, 2, 16)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(), SHAPE_W_SINGLE, SHAPE_S_SINGLE, SHAPE_E_SINGLE, SHAPE_S_MIDDLE, SHAPE_W_MIDDLE, SHAPE_N_MIDDLE, SHAPE_E_MIDDLE, SHAPE_S_LEFT, SHAPE_W_LEFT, SHAPE_N_LEFT, SHAPE_E_LEFT, SHAPE_S_RIGHT, SHAPE_W_RIGHT, SHAPE_N_RIGHT, SHAPE_E_RIGHT, SHAPE_S_CORNER, SHAPE_W_CORNER, SHAPE_N_CORNER, SHAPE_E_CORNER;
static {
SHAPE_E_SINGLE = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N_SINGLE);
SHAPE_S_SINGLE = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_E_SINGLE);
SHAPE_W_SINGLE = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S_SINGLE);
SHAPE_N_MIDDLE = Stream.of(
Block.box(0, 2, 13, 16, 17, 16),
Block.box(0, 2, 0, 16, 6, 13),
Block.box(0, 6, 3, 16, 8, 13),
Block.box(0, 0, 0, 16, 2, 16)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get();
SHAPE_E_MIDDLE = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N_MIDDLE);
SHAPE_S_MIDDLE = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_E_MIDDLE);
SHAPE_W_MIDDLE = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S_MIDDLE);
SHAPE_N_LEFT = Stream.of(
Block.box(0, 2, 13, 16, 17, 16),
Block.box(13, 2, 0, 16, 11, 13),
Block.box(0, 2, 0, 13, 6, 13),
Block.box(0, 6, 3, 13, 8, 13),
Block.box(0, 0, 0, 16, 2, 16)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get();
SHAPE_E_LEFT = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N_LEFT);
SHAPE_S_LEFT = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_E_LEFT);
SHAPE_W_LEFT = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S_LEFT);
SHAPE_N_RIGHT = Stream.of(
Block.box(0, 2, 13, 16, 17, 16),
Block.box(0, 2, 0, 3, 11, 13),
Block.box(3, 2, 0, 16, 6, 13),
Block.box(3, 6, 3, 16, 8, 13),
Block.box(0, 0, 0, 16, 2, 16)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get();
SHAPE_E_RIGHT = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N_RIGHT);
SHAPE_S_RIGHT = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_E_RIGHT);
SHAPE_W_RIGHT = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S_RIGHT);
SHAPE_N_CORNER = Stream.of(
Block.box(0, 2, 13, 16, 17, 16),
Block.box(13, 2, 0, 16, 17, 13),
Block.box(0, 2, 0, 13, 6, 13),
Block.box(0, 6, 3, 13, 8, 13),
Block.box(3, 6, 0, 13, 8, 3),
Block.box(0, 0, 0, 16, 2, 16)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get();
SHAPE_E_CORNER = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N_CORNER);
SHAPE_S_CORNER = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_E_CORNER);
SHAPE_W_CORNER = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S_CORNER);
}
@Inject(method = {"getShape"}, at = @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
if (bs.getValue(TYPE) == SofaBlock.SofaType.single) {
if (MLP$SwitchInner(bs, cir, SHAPE_N_SINGLE, SHAPE_S_SINGLE, SHAPE_E_SINGLE, SHAPE_W_SINGLE)) return;
} else if (bs.getValue(TYPE) == SofaBlock.SofaType.middle) {
if (MLP$SwitchInner(bs, cir, SHAPE_N_MIDDLE, SHAPE_S_MIDDLE, SHAPE_E_MIDDLE, SHAPE_W_MIDDLE)) return;
} else if (bs.getValue(TYPE) == SofaBlock.SofaType.left) {
if (MLP$SwitchInner(bs, cir, SHAPE_N_LEFT, SHAPE_S_LEFT, SHAPE_E_LEFT, SHAPE_W_LEFT)) return;
} else if (bs.getValue(TYPE) == SofaBlock.SofaType.right) {
if (MLP$SwitchInner(bs, cir, SHAPE_N_RIGHT, SHAPE_S_RIGHT, SHAPE_E_RIGHT, SHAPE_W_RIGHT)) return;
} else if (bs.getValue(TYPE) == SofaBlock.SofaType.corner) {
if (MLP$SwitchInner(bs, cir, SHAPE_N_CORNER, SHAPE_S_CORNER, SHAPE_E_CORNER, SHAPE_W_CORNER)) return;
}
cir.setReturnValue(SHAPE_N_SINGLE);
}
@Unique
private boolean MLP$SwitchInner(BlockState bs, CallbackInfoReturnable<VoxelShape> cir, VoxelShape shapeNRight, VoxelShape shapeSRight, VoxelShape shapeERight, VoxelShape shapeWRight) {
switch (bs.getValue(FACING)) {
case NORTH -> {
cir.setReturnValue(shapeNRight);
return true;
}
case SOUTH -> {
cir.setReturnValue(shapeSRight);
return true;
}
case EAST -> {
cir.setReturnValue(shapeERight);
return true;
}
case WEST -> {
cir.setReturnValue(shapeWRight);
return true;
}
}
return false;
}
//咕咕咕~
}

View File

@ -0,0 +1,54 @@
package com.r3944realms.modernlifepatch.mixin.block.redstone;
import com.dairymoose.modernlife.blocks.ExtractorBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.List;
import java.util.stream.Stream;
@Mixin(ExtractorBlock.class)
public class MixinExtractor {
@Unique
private static final VoxelShape SHAPE_N = Stream.of(
Block.box(5, 4, 2, 11, 10, 14),
Block.box(3, 2, 14, 13, 12, 17),
Block.box(3, 2, -1, 13, 12, 2),
Block.box(4, 3, 4, 12, 11, 12)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(), SHAPE_E;
static {
SHAPE_E = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N);
}
@Inject(method = "getShape", at = @At("HEAD"), cancellable = true)
public void getShape(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, CollisionContext collisionContext, CallbackInfoReturnable<VoxelShape> cir) {
switch (blockState.getValue(ExtractorBlock.FACING)) {
case EAST,WEST -> cir.setReturnValue(SHAPE_E);
default -> cir.setReturnValue(SHAPE_N);
}
}
@Inject(method = {"appendHoverText"}, at= @At("HEAD"), cancellable = true)
public void appendHoverText(ItemStack itemStack, BlockGetter blockReader, List<Component> list, TooltipFlag tooltipFlag, CallbackInfo ci) {
list.add(Component.translatable(ModLangKeyValue.EXTRACTOR_HOVER.getKey()));
ci.cancel();
}
}

View File

@ -0,0 +1,48 @@
package com.r3944realms.modernlifepatch.mixin.block.redstone;
import com.dairymoose.modernlife.blocks.PowerReceiverBlock;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.List;
@SuppressWarnings("AddedMixinMembersNamePattern")
@Mixin(PowerReceiverBlock.class)
public class MixinPowerReceiver {
@Unique
private static final VoxelShape _SHAPE_ =
Shapes.join(
Block.box(5, 10, 5, 11, 16, 11),
Block.box(0, 0, 0, 16, 5, 16),
BooleanOp.OR);
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
cir.setReturnValue(_SHAPE_);
}
@Inject(method = {"appendHoverText"}, at= @At("HEAD"), cancellable = true)
public void appendHoverText(ItemStack itemStack, BlockGetter blockReader, List<Component> list, TooltipFlag tooltipFlag, CallbackInfo ci) {
list.add(Component.translatable(ModLangKeyValue.POWER_RECEIVER_HOVER_FIRST.getKey()));
list.add(Component.translatable(ModLangKeyValue.POWER_RECEIVER_AND_TRANSMITTER_HOVER_SECOND.getKey()));
ci.cancel();
}
}

View File

@ -0,0 +1,25 @@
package com.r3944realms.modernlifepatch.mixin.block.redstone;
import com.dairymoose.modernlife.blocks.PowerTransmitterBlock;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.List;
@Mixin(PowerTransmitterBlock.class)
public class MixinPowerTransmitter {
@Inject(method = {"appendHoverText"}, at = @At("HEAD"), cancellable = true)
private void appendHoverText(ItemStack itemStack, BlockGetter blockReader, List<Component> list, TooltipFlag tooltipFlag, CallbackInfo ci) {
list.add(Component.translatable(ModLangKeyValue.POWER_TRANSMITTER_FIRST.getKey()));
list.add(Component.translatable(ModLangKeyValue.POWER_RECEIVER_AND_TRANSMITTER_HOVER_SECOND.getKey()));
ci.cancel();
}
}

View File

@ -0,0 +1,60 @@
package com.r3944realms.modernlifepatch.mixin.block.redstone;
import com.dairymoose.modernlife.blocks.StandardHorizontalBlock;
import com.dairymoose.modernlife.blocks.TurntableBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.List;
import java.util.stream.Stream;
@Mixin(TurntableBlock.class)
public class MixinTurntableBlock extends StandardHorizontalBlock {
public MixinTurntableBlock(Properties properties) {
super(properties);
}
@Unique
private static final VoxelShape SHAPE_N = Stream.of(
Block.box(4, 0, 4, 12, 6, 12),
Block.box(0, 13, 0, 16, 16, 16),
Block.box(6, 6, 6, 10, 13, 10)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get(), SHAPE_E, SHAPE_S, SHAPE_W;
static {
SHAPE_E = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_N);
SHAPE_S = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_E);
SHAPE_W = ModernLifeUtil.RotateVoxelShapeClockwise(SHAPE_S);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
switch (bs.getValue(FACING)) {
case SOUTH -> cir.setReturnValue(SHAPE_S);
case EAST -> cir.setReturnValue(SHAPE_E);
case WEST -> cir.setReturnValue(SHAPE_W);
default -> cir.setReturnValue(SHAPE_N);
}
}
@Inject(method = {"appendHoverText"}, at = @At("HEAD"), cancellable = true)
private void appendHoverText(ItemStack itemStack, BlockGetter blockReader, List<Component> list, TooltipFlag tooltipFlag, CallbackInfo ci) {
list.add(Component.translatable(ModLangKeyValue.TURNTABLE_HOVER.getKey()));
ci.cancel();
}
}

View File

@ -0,0 +1,93 @@
package com.r3944realms.modernlifepatch.mixin.block.redstone;
import com.dairymoose.modernlife.blocks.WinchBlock;
import com.dairymoose.modernlife.util.ModernLifeUtil;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.List;
import java.util.stream.Stream;
@Mixin(WinchBlock.class)
public abstract class MixinWinch extends FaceAttachedHorizontalDirectionalBlock implements EntityBlock {
public MixinWinch(Properties properties) {
super(properties);
}
@Unique
private static final VoxelShape __SHAPE_FLOOR_SOUTH ,_SHAPE_FLOOR_WEST, _SHAPE_FLOOR_NORTH, _SHAPE_FLOOR_EAST, _SHAPE_WALL_SOUTH, _SHAPE_WALL_WEST, _SHAPE_WALL_NORTH, _SHAPE_WALL_EAST, _SHAPE_CEILING_SOUTH, _SHAPE_CEILING_WEST, _SHAPE_CEILING_NORTH, _SHAPE_CEILING_EAST;
static {
__SHAPE_FLOOR_SOUTH = Stream.of(
Block.box(2, 5, 5, 14, 11, 11),
Block.box(0, 4, 4, 2, 12, 12),
Block.box(0, 0, 6, 2, 4, 10),
Block.box(14, 0, 6, 16, 4, 10),
Block.box(14, 4, 4, 16, 12, 12)
).reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR)).get();
_SHAPE_FLOOR_WEST = ModernLifeUtil.RotateVoxelShapeClockwise(__SHAPE_FLOOR_SOUTH);
_SHAPE_FLOOR_NORTH = ModernLifeUtil.RotateVoxelShapeClockwise(_SHAPE_FLOOR_WEST);
_SHAPE_FLOOR_EAST = ModernLifeUtil.RotateVoxelShapeClockwise(_SHAPE_FLOOR_NORTH);
_SHAPE_WALL_SOUTH = ModernLifeUtil.RotateVoxelShapeXAxis(__SHAPE_FLOOR_SOUTH);
_SHAPE_WALL_WEST = ModernLifeUtil.RotateVoxelShapeClockwise(_SHAPE_WALL_SOUTH);
_SHAPE_WALL_NORTH = ModernLifeUtil.RotateVoxelShapeClockwise(_SHAPE_WALL_WEST);
_SHAPE_WALL_EAST = ModernLifeUtil.RotateVoxelShapeClockwise(_SHAPE_WALL_NORTH);
_SHAPE_CEILING_SOUTH = ModernLifeUtil.RotateVoxelShapeXAxis(_SHAPE_WALL_SOUTH);
_SHAPE_CEILING_WEST = ModernLifeUtil.RotateVoxelShapeClockwise(_SHAPE_CEILING_SOUTH);
_SHAPE_CEILING_NORTH = ModernLifeUtil.RotateVoxelShapeClockwise(_SHAPE_CEILING_WEST);
_SHAPE_CEILING_EAST = ModernLifeUtil.RotateVoxelShapeClockwise(_SHAPE_CEILING_NORTH);
}
@Inject(method = {"getShape"}, at= @At("HEAD"), cancellable = true)
public void getShape(BlockState bs, BlockGetter reader, BlockPos pos, CollisionContext sel, CallbackInfoReturnable<VoxelShape> cir) {
switch ((bs.getValue(FACE))) {
case CEILING: {
MH$SwitchInner(bs, cir, _SHAPE_CEILING_NORTH, _SHAPE_CEILING_EAST, _SHAPE_CEILING_WEST, _SHAPE_CEILING_SOUTH);
break;
}
case WALL: {
MH$SwitchInner(bs, cir, _SHAPE_WALL_NORTH, _SHAPE_WALL_EAST, _SHAPE_WALL_WEST, _SHAPE_WALL_SOUTH);
break;
}
case FLOOR: {
MH$SwitchInner(bs, cir, _SHAPE_FLOOR_NORTH, _SHAPE_FLOOR_EAST, _SHAPE_FLOOR_WEST, __SHAPE_FLOOR_SOUTH);
break;
}
default:
cir.setReturnValue(_SHAPE_FLOOR_NORTH);
}
}
@Inject(method = {"appendHoverText"}, at = @At("HEAD"), cancellable = true)
private void appendHoverText(ItemStack itemStack, BlockGetter blockReader, List<Component> list, TooltipFlag tooltipFlag, CallbackInfo ci) {
list.add(Component.translatable(ModLangKeyValue.NEED_RED_STONE_POWER_HOVER.getKey()));
ci.cancel();
}
@Unique
private void MH$SwitchInner(BlockState bs, CallbackInfoReturnable<VoxelShape> cir, VoxelShape shapeFloorNorth, VoxelShape shapeFloorEast, VoxelShape shapeFloorWest, VoxelShape shapeFloorSouth) {
switch (bs.getValue(FACING)) {
case NORTH -> cir.setReturnValue(shapeFloorNorth);
case EAST -> cir.setReturnValue(shapeFloorEast);
case WEST -> cir.setReturnValue(shapeFloorWest);
case SOUTH -> cir.setReturnValue(shapeFloorSouth);
}
}
}

View File

@ -0,0 +1,24 @@
package com.r3944realms.modernlifepatch.mixin.item;
import com.dairymoose.modernlife.items.BatteryItem;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.List;
@Mixin(BatteryItem.class)
public class MixinBattery {
@Inject(method = {"appendHoverText"}, at= @At("HEAD"), cancellable = true)
public void appendHoverText(ItemStack itemStack, Level world, List<Component> text, TooltipFlag flag, CallbackInfo ci) {
text.add(Component.translatable(ModLangKeyValue.BATTERY_HOVER.getKey()));
ci.cancel();
}
}

View File

@ -0,0 +1,24 @@
package com.r3944realms.modernlifepatch.mixin.item;
import com.dairymoose.modernlife.items.BicycleItem;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.List;
@Mixin(BicycleItem.class)
public class MixinBicycle {
@Inject(method = {"appendHoverText"}, at= @At("HEAD"), cancellable = true)
public void appendHoverText(ItemStack itemStack, Level world, List<Component> text, TooltipFlag flag, CallbackInfo ci) {
text.add(Component.translatable(ModLangKeyValue.BICYCLE_HOVER.getKey()));
ci.cancel();
}
}

View File

@ -0,0 +1,104 @@
package com.r3944realms.modernlifepatch.mixin.item;
import com.dairymoose.modernlife.items.CameraItem;
import com.dairymoose.modernlife.util.CanvasData;
import com.mojang.blaze3d.platform.NativeImage;
import com.r3944realms.modernlifepatch.ModernLifePatch;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.List;
@Mixin(CameraItem.class)
public abstract class MixinCamera {
@Unique
private static int modernLifePatch$toInternalRgbFormat(int nativeRgb) {
int r = nativeRgb & 255;
int g = (nativeRgb & '\uff00') >> 8;
int b = (nativeRgb & 16711680) >> 16;
return r << 16 | g << 8 | b;
}
@Inject(method = {"getAverageRgbAt"}, at = @At("HEAD"), remap = false, cancellable = true)
private static void getAverageRgbAt(NativeImage img, int x, int y, float pixelSampleWidth, float pixelSampleHeight, CallbackInfoReturnable<Integer> cir) {
try {
int destX = (int) ((float) x * pixelSampleWidth);
int destY = (int) ((float) y * pixelSampleHeight);
int rSum = 0;
int gSum = 0;
int bSum = 0;
int iterations = 0;
int hStart = (int) (-pixelSampleHeight / 2.0F);
int hEnd = (int) (pixelSampleHeight / 2.0F);
int wStart = (int) (-pixelSampleWidth / 2.0F);
int wEnd = (int) (pixelSampleWidth / 2.0F);
ModernLifePatch.logger.info("[ModernLifePatch.MixinCamera] pixelSampleHeight: {} , pixelSampleWidth: {}", pixelSampleHeight, pixelSampleWidth);
if (hStart == hEnd) {
hStart = 0;
hEnd = 1;
wStart = 0;
wEnd = 1;
}
int h;
int w;
int finalX;
ModernLifePatch.logger.info("[ModernLifePatch.MixinCamera] hEnd: {} , wEnd: {}", hEnd, wEnd);
for (h = hStart; h < hEnd; ++h) {
for (w = wStart; w < wEnd; ++w) {
finalX = destX + w;
int finalY = destY + h;
finalX = Math.max(finalX, 0);
finalY = Math.max(finalY, 0);
finalX = Math.min(finalX, img.getWidth() - 1);
finalY = Math.min(finalY, img.getHeight() - 1);
int rgb = modernLifePatch$toInternalRgbFormat(img.getPixelRGBA(finalX, finalY));
rSum += CanvasData.getRValue(rgb);
gSum += CanvasData.getGValue(rgb);
bSum += CanvasData.getBValue(rgb);
++iterations;
}
}
ModernLifePatch.logger.info("[ModernLifePatch.MixinCamera] rSum: {} , gSum: {}, bSum: {}", rSum, gSum, bSum);
ModernLifePatch.logger.info("[ModernLifePatch.MixinCamera] iterations: {} ", iterations);
h = rSum / iterations;
w = gSum / iterations;
finalX = bSum / iterations;
cir.setReturnValue(h << 16 | w << 8 | finalX);
} catch(ArrayIndexOutOfBoundsException e) {
cir.setReturnValue(0xffffffff);
}
}
@Inject(method = {"appendHoverText"}, at= @At("HEAD"), cancellable = true)
public void appendHoverText(ItemStack itemStack, Level world, List<Component> text, TooltipFlag flag, CallbackInfo ci) {
int photoCount = 0;
if (itemStack.getTag() != null && itemStack.getTag().contains("ImageList")) {
Tag imageListTag = itemStack.getTag().get("ImageList");
ListTag imageList;
if (imageListTag instanceof ListTag) {
imageList = (ListTag)imageListTag;
photoCount = imageList.size();
}
}
int maxPhotos = itemStack.getMaxDamage();
text.add(Component.translatable(ModLangKeyValue.CAMERA_HOVER_FIRST.getKey(),photoCount, maxPhotos));
text.add(Component.literal(""));
text.add(Component.translatable(ModLangKeyValue.CAMERA_HOVER_SECOND.getKey()));
text.add(Component.translatable(ModLangKeyValue.CAMERA_HOVER_THIRD.getKey()));
ci.cancel();
}
}

View File

@ -0,0 +1,25 @@
package com.r3944realms.modernlifepatch.mixin.item;
import com.dairymoose.modernlife.items.ChainsawItem;
import com.r3944realms.modernlifepatch.datagen.lang.ModLangKeyValue;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.List;
@Mixin(ChainsawItem.class)
public class MixinChainSaw {
@Inject(method = {"appendHoverText"}, at= @At("HEAD"), cancellable = true)
public void appendHoverText(ItemStack itemStack, Level world, List<Component> text, TooltipFlag flag, CallbackInfo ci) {
text.add(Component.translatable(ModLangKeyValue.CHAINSAW_HOVER_FIRST.getKey()));
text.add(Component.translatable(ModLangKeyValue.CHAINSAW_HOVER_SECOND.getKey()));
ci.cancel();
}
}

Some files were not shown because too many files have changed in this diff Show More