From f00d9c356806a744ce90bbc0d857ff6f22724b0c Mon Sep 17 00:00:00 2001 From: cao-awa Date: Fri, 15 Nov 2024 06:54:27 +0800 Subject: [PATCH] Supported to short arise define. Add more samples. --- .../tests/data/awa/block/bedrock_block.json | 26 +++++++++ .../tests/data/awa/block/conium_block.json | 21 ++++++++ .../tests/data/awa/entity/bedrock_entity.json | 31 +++++++++++ .../tests/data/awa}/entity/conium_entity.json | 0 .../awa}/entity_geo/bedrock_entity.geo.json | 0 .../tests/data/awa/item/bedrock.json | 43 +++++++++++++++ .../datapacks/tests/data/awa/item/conium.json | 51 ++++++++++++++++++ .../tests/data/awa/property/item/flint.json | 9 ++++ .../tests/data/awa/recipe/test_furnace.json | 17 ++++++ .../tests/data/awa/recipe/test_recipe.json | 20 +++++++ .../tests/data/awa/recipe/test_recipe2.json | 16 ++++++ .../data/awa}/scripts/conium_fools_day.kts | 10 ++-- .../tests/data/awa}/scripts/test.ts | 0 sample/datapacks/tests/pack.mcmeta | 6 +++ .../tests/assets/awa/lang/en_us.json | 4 ++ .../tests/assets/awa/models/item/bedrock.json | 6 +++ .../tests/assets/awa/models/item/conium.json | 6 +++ .../assets/awa/textures/entity/bat_v2.png | Bin .../assets/awa/textures/item/bedrock.png | Bin 0 -> 229 bytes .../tests/assets/awa/textures/item/conium.png | Bin 0 -> 229 bytes sample/resourcepacks/tests/pack.mcmeta | 6 +++ sample/scripts/script.conium.kts | 8 --- .../context/ConiumEventContextBuilder.kt | 42 ++++++++++++--- .../conium/mixin/item/FuelRegistryMixin.java | 4 ++ 24 files changed, 305 insertions(+), 21 deletions(-) create mode 100644 sample/datapacks/tests/data/awa/block/bedrock_block.json create mode 100644 sample/datapacks/tests/data/awa/block/conium_block.json create mode 100644 sample/datapacks/tests/data/awa/entity/bedrock_entity.json rename sample/{ => datapacks/tests/data/awa}/entity/conium_entity.json (100%) rename sample/{ => datapacks/tests/data/awa}/entity_geo/bedrock_entity.geo.json (100%) create mode 100644 sample/datapacks/tests/data/awa/item/bedrock.json create mode 100644 sample/datapacks/tests/data/awa/item/conium.json create mode 100644 sample/datapacks/tests/data/awa/property/item/flint.json create mode 100644 sample/datapacks/tests/data/awa/recipe/test_furnace.json create mode 100644 sample/datapacks/tests/data/awa/recipe/test_recipe.json create mode 100644 sample/datapacks/tests/data/awa/recipe/test_recipe2.json rename sample/{ => datapacks/tests/data/awa}/scripts/conium_fools_day.kts (89%) rename sample/{ => datapacks/tests/data/awa}/scripts/test.ts (100%) create mode 100644 sample/datapacks/tests/pack.mcmeta create mode 100644 sample/resourcepacks/tests/assets/awa/lang/en_us.json create mode 100644 sample/resourcepacks/tests/assets/awa/models/item/bedrock.json create mode 100644 sample/resourcepacks/tests/assets/awa/models/item/conium.json rename bat_v2.png => sample/resourcepacks/tests/assets/awa/textures/entity/bat_v2.png (100%) create mode 100644 sample/resourcepacks/tests/assets/awa/textures/item/bedrock.png create mode 100644 sample/resourcepacks/tests/assets/awa/textures/item/conium.png create mode 100644 sample/resourcepacks/tests/pack.mcmeta delete mode 100644 sample/scripts/script.conium.kts diff --git a/sample/datapacks/tests/data/awa/block/bedrock_block.json b/sample/datapacks/tests/data/awa/block/bedrock_block.json new file mode 100644 index 0000000..81115e2 --- /dev/null +++ b/sample/datapacks/tests/data/awa/block/bedrock_block.json @@ -0,0 +1,26 @@ +{ + "minecraft:block": { + "description": { + "identifier": "awa:bedrock_block" + }, + "components": { + "minecraft:destructible_by_mining": { + "seconds_to_destroy": 3 + }, + "minecraft:map_color": "#ffffff", + "minecraft:light_emission": 15, + "minecraft:collision_box": { + "origin": [ + -8, + 0, + -8 + ], + "size": [ + 5, + 5, + 5 + ] + } + } + } +} \ No newline at end of file diff --git a/sample/datapacks/tests/data/awa/block/conium_block.json b/sample/datapacks/tests/data/awa/block/conium_block.json new file mode 100644 index 0000000..901c1ac --- /dev/null +++ b/sample/datapacks/tests/data/awa/block/conium_block.json @@ -0,0 +1,21 @@ +{ + "schema_style": "conium", + "identifier": "awa:conium_block", + "templates": { + "hardness": 10, + "map_color": "#FF0000", + "luminance": 5, + "collision": { + "origin": [ + 0, + 0, + 0 + ], + "size": [ + 5, + 5, + 5 + ] + } + } +} diff --git a/sample/datapacks/tests/data/awa/entity/bedrock_entity.json b/sample/datapacks/tests/data/awa/entity/bedrock_entity.json new file mode 100644 index 0000000..280912f --- /dev/null +++ b/sample/datapacks/tests/data/awa/entity/bedrock_entity.json @@ -0,0 +1,31 @@ +{ + "minecraft:entity" : { + "description": { + "identifier": "awa:bedrock_entity" + }, + "components": { + "minecraft:collision_box": { + "height": 1, + "width": 1 + }, + "minecraft:pushable": { + "is_pushable": true, + "is_pushable_by_piston": true + } + }, + "component_groups": { + "awa:g1": { + "minecraft:collision_box": { + "height": 2, + "width": 2 + } + }, + "awa:g2": { + "minecraft:collision_box": { + "height": 3, + "width": 3 + } + } + } + } +} \ No newline at end of file diff --git a/sample/entity/conium_entity.json b/sample/datapacks/tests/data/awa/entity/conium_entity.json similarity index 100% rename from sample/entity/conium_entity.json rename to sample/datapacks/tests/data/awa/entity/conium_entity.json diff --git a/sample/entity_geo/bedrock_entity.geo.json b/sample/datapacks/tests/data/awa/entity_geo/bedrock_entity.geo.json similarity index 100% rename from sample/entity_geo/bedrock_entity.geo.json rename to sample/datapacks/tests/data/awa/entity_geo/bedrock_entity.geo.json diff --git a/sample/datapacks/tests/data/awa/item/bedrock.json b/sample/datapacks/tests/data/awa/item/bedrock.json new file mode 100644 index 0000000..276b425 --- /dev/null +++ b/sample/datapacks/tests/data/awa/item/bedrock.json @@ -0,0 +1,43 @@ +{ + "minecraft:item": { + "description": { + "identifier": "awa:bedrock" + }, + "components": { + "minecraft:damage": 100, + "minecraft:durability": { + "damage_chance": { + "min": 0, + "max": 100 + }, + "max_durability": 50 + }, + "minecraft:can_destroy_in_creative": { + "value": true + }, + "minecraft:max_stack_size": { + "value": 64 + }, + "minecraft:food": { + "can_always_eat": false, + "nutrition": 10, + "saturation_modifier": 1.0, + "using_converts_to": "bowl" + }, + "minecraft:rarity": "uncommon", + "minecraft:use_animation": { + "value": "eat" + }, + "minecraft:fuel": { + "duration": 3.0 + }, + "minecraft:glint": { + "value": true + }, + "minecraft:wearable": { + "protection": 10, + "slot": "slot.armor.chest" + } + } + } +} diff --git a/sample/datapacks/tests/data/awa/item/conium.json b/sample/datapacks/tests/data/awa/item/conium.json new file mode 100644 index 0000000..f4f7957 --- /dev/null +++ b/sample/datapacks/tests/data/awa/item/conium.json @@ -0,0 +1,51 @@ +{ + "schema_style": "conium", + "identifier": "awa:conium", + "templates": { + "tool": { + "attack_damage": 100, + "attack_speed": -3.0, + "durability": 50, + "effective_blocks": "minecraft:mineable/pickaxe", + "material": "netherite", + "is_weapon": false, + "damage_chance": { + "min": 0, + "max": 0 + } + }, + "can_destroy_in_creative": true, + "max_count": 64, + "food": { + "can_always_eat": true, + "nutrition": 10, + "saturation": 1.0 + }, + "consumable": { + "convert_to": "bowl", + "apply_effects": { + "effects": [ + { + "id": "minecraft:nausea", + "amplifier": 1, + "duration": 200, + "show_particles": true, + "show_icon": true, + "ambient": true + } + ] + } + }, + "rarity": "epic", + "use_action": "eat", + "fuel": 60, + "glint": true, + "armor": { + "slot": "chest", + "defense": 10, + "knockback_resistance": 0.1, + "toughness": 10, + "enchantable": 22 + } + } +} diff --git a/sample/datapacks/tests/data/awa/property/item/flint.json b/sample/datapacks/tests/data/awa/property/item/flint.json new file mode 100644 index 0000000..6f99da7 --- /dev/null +++ b/sample/datapacks/tests/data/awa/property/item/flint.json @@ -0,0 +1,9 @@ +{ + "target": "minecraft:flint", + "components": [ + { + "type": "conium:test", + "value": 1234 + } + ] +} \ No newline at end of file diff --git a/sample/datapacks/tests/data/awa/recipe/test_furnace.json b/sample/datapacks/tests/data/awa/recipe/test_furnace.json new file mode 100644 index 0000000..6330763 --- /dev/null +++ b/sample/datapacks/tests/data/awa/recipe/test_furnace.json @@ -0,0 +1,17 @@ +{ + "minecraft:recipe_furnace": { + "description": { + "identifier": "awa:test_recipe2" + }, + "tags": [ + "furnace", + "blast_furnace" + ], + "group": "wood", + "input": "minecraft:bedrock", + "output": { + "item": "minecraft:grass_block", + "count": 4 + } + } +} diff --git a/sample/datapacks/tests/data/awa/recipe/test_recipe.json b/sample/datapacks/tests/data/awa/recipe/test_recipe.json new file mode 100644 index 0000000..3804436 --- /dev/null +++ b/sample/datapacks/tests/data/awa/recipe/test_recipe.json @@ -0,0 +1,20 @@ +{ + "minecraft:recipe_shaped": { + "description": { + "identifier": "awa:test_recipe" + }, + "group": "wood", + "pattern": [ + "###", + " # " + ], + "key": { + "#": { + "item": "minecraft:bedrock" + } + }, + "result": { + "item": "minecraft:grass_block" + } + } +} diff --git a/sample/datapacks/tests/data/awa/recipe/test_recipe2.json b/sample/datapacks/tests/data/awa/recipe/test_recipe2.json new file mode 100644 index 0000000..463d6aa --- /dev/null +++ b/sample/datapacks/tests/data/awa/recipe/test_recipe2.json @@ -0,0 +1,16 @@ +{ + "minecraft:recipe_shapeless": { + "description": { + "identifier": "awa:test_recipe2" + }, + "group": "wood", + "ingredients": [ + "minecraft:grass_block", + "minecraft:grass_block", + "minecraft:grass_block" + ], + "result": { + "item": "minecraft:diamond_block" + } + } +} diff --git a/sample/scripts/conium_fools_day.kts b/sample/datapacks/tests/data/awa/scripts/conium_fools_day.kts similarity index 89% rename from sample/scripts/conium_fools_day.kts rename to sample/datapacks/tests/data/awa/scripts/conium_fools_day.kts index 49343c0..f4d11e0 100644 --- a/sample/scripts/conium_fools_day.kts +++ b/sample/datapacks/tests/data/awa/scripts/conium_fools_day.kts @@ -8,7 +8,7 @@ val random = Random() request( SERVER_TICK, SERVER -).arise { _, server -> +) { _, server -> server.worlds.forEach { world -> world.iterateEntities().forEach { entity -> if (entity != null && entity !is ServerPlayerEntity) { @@ -37,7 +37,7 @@ request( request( PLACE_BLOCK, SERVER_WORLD -).arise { _, world -> +) { _, world -> println(world) true @@ -49,11 +49,11 @@ request( SERVER_WORLD, BLOCK_POS, BLOCK_STATE -).arise { _, world, pos, state -> +) { _, world, pos, state -> if (state.block === Blocks.BLUE_BED) { val vec3d: Vec3d = pos.toCenterPos() - world.createExplosion(null, world.getDamageSources().badRespawnPoint(vec3d), null, vec3d, 5.0f, true, World.ExplosionSourceType.BLOCK) + world.createExplosion(null, world.getDamageSources().badRespawnPoint(vec3d), null, vec3d, 200.0f, true, World.ExplosionSourceType.BLOCK) } true -} \ No newline at end of file +} diff --git a/sample/scripts/test.ts b/sample/datapacks/tests/data/awa/scripts/test.ts similarity index 100% rename from sample/scripts/test.ts rename to sample/datapacks/tests/data/awa/scripts/test.ts diff --git a/sample/datapacks/tests/pack.mcmeta b/sample/datapacks/tests/pack.mcmeta new file mode 100644 index 0000000..ec7c87f --- /dev/null +++ b/sample/datapacks/tests/pack.mcmeta @@ -0,0 +1,6 @@ +{ + "pack": { + "description": "Test pack", + "pack_format": 48 + } +} \ No newline at end of file diff --git a/sample/resourcepacks/tests/assets/awa/lang/en_us.json b/sample/resourcepacks/tests/assets/awa/lang/en_us.json new file mode 100644 index 0000000..b377735 --- /dev/null +++ b/sample/resourcepacks/tests/assets/awa/lang/en_us.json @@ -0,0 +1,4 @@ +{ + "item.awa.conium": "A conium", + "item.awa.bedrock": "A bedrock" +} \ No newline at end of file diff --git a/sample/resourcepacks/tests/assets/awa/models/item/bedrock.json b/sample/resourcepacks/tests/assets/awa/models/item/bedrock.json new file mode 100644 index 0000000..912ae2b --- /dev/null +++ b/sample/resourcepacks/tests/assets/awa/models/item/bedrock.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "awa:item/bedrock" + } +} \ No newline at end of file diff --git a/sample/resourcepacks/tests/assets/awa/models/item/conium.json b/sample/resourcepacks/tests/assets/awa/models/item/conium.json new file mode 100644 index 0000000..9957c59 --- /dev/null +++ b/sample/resourcepacks/tests/assets/awa/models/item/conium.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "awa:item/conium" + } +} \ No newline at end of file diff --git a/bat_v2.png b/sample/resourcepacks/tests/assets/awa/textures/entity/bat_v2.png similarity index 100% rename from bat_v2.png rename to sample/resourcepacks/tests/assets/awa/textures/entity/bat_v2.png diff --git a/sample/resourcepacks/tests/assets/awa/textures/item/bedrock.png b/sample/resourcepacks/tests/assets/awa/textures/item/bedrock.png new file mode 100644 index 0000000000000000000000000000000000000000..43b787ea834cb8681a10917f5ccd11a1ff103628 GIT binary patch literal 229 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ydl>XLo7}wCoEvsxSH_Gf7>%( z&8Gj(Ar}8HUoV@mR)Oad&n8(H;Zy;S%Wqu|{r~^Bo^6@qEXSmLzuiqgD|nkS>%Qv! z`M+I$@`1Jk1|9rD$Fn&$G2SpZA$p?ifeFJhfthWI680_}-fJ3sSS1;ZS)S!f$Un1M z#N%-61lz$q4Oba*)*VO_@H=b3oRHXf*7`w+ri(&olgI&{MpcbPrpnSx-T4JsET1~B c`DigPxC)9*D!3JS1L$rBPgg&ebxsLQ0G0MuFaQ7m literal 0 HcmV?d00001 diff --git a/sample/resourcepacks/tests/assets/awa/textures/item/conium.png b/sample/resourcepacks/tests/assets/awa/textures/item/conium.png new file mode 100644 index 0000000000000000000000000000000000000000..43b787ea834cb8681a10917f5ccd11a1ff103628 GIT binary patch literal 229 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ydl>XLo7}wCoEvsxSH_Gf7>%( z&8Gj(Ar}8HUoV@mR)Oad&n8(H;Zy;S%Wqu|{r~^Bo^6@qEXSmLzuiqgD|nkS>%Qv! z`M+I$@`1Jk1|9rD$Fn&$G2SpZA$p?ifeFJhfthWI680_}-fJ3sSS1;ZS)S!f$Un1M z#N%-61lz$q4Oba*)*VO_@H=b3oRHXf*7`w+ri(&olgI&{MpcbPrpnSx-T4JsET1~B c`DigPxC)9*D!3JS1L$rBPgg&ebxsLQ0G0MuFaQ7m literal 0 HcmV?d00001 diff --git a/sample/resourcepacks/tests/pack.mcmeta b/sample/resourcepacks/tests/pack.mcmeta new file mode 100644 index 0000000..0a96fed --- /dev/null +++ b/sample/resourcepacks/tests/pack.mcmeta @@ -0,0 +1,6 @@ +{ + "pack": { + "description": "Test resource pack", + "pack_format": 48 + } +} \ No newline at end of file diff --git a/sample/scripts/script.conium.kts b/sample/scripts/script.conium.kts deleted file mode 100644 index a798cd3..0000000 --- a/sample/scripts/script.conium.kts +++ /dev/null @@ -1,8 +0,0 @@ -request( - ITEM_USE_ON_BLOCK, - SERVER_WORLD -).trigger { _, world -> - println(world) - - true -} diff --git a/src/main/java/com/github/cao/awa/conium/event/context/ConiumEventContextBuilder.kt b/src/main/java/com/github/cao/awa/conium/event/context/ConiumEventContextBuilder.kt index df20047..e0b668e 100644 --- a/src/main/java/com/github/cao/awa/conium/event/context/ConiumEventContextBuilder.kt +++ b/src/main/java/com/github/cao/awa/conium/event/context/ConiumEventContextBuilder.kt @@ -90,13 +90,18 @@ object ConiumEventContextBuilder { @JvmStatic @SuppressWarnings("UNCHECKED_CAST") - fun request(eventType: ConiumEventType): ConiumEventContext> { + fun request( + eventType: ConiumEventType, + arising: ParameterSelective1 = ParameterSelective1 { _ -> false } + ): ConiumEventContext> { val context = ConiumEventContext( DynamicArgsBuilder.requires(false).lifecycle(DynamicArgsLifecycle.FOREVER) ) ConiumEvent.forever(eventType, context) + context.arising(arising) + return context } @@ -104,7 +109,8 @@ object ConiumEventContextBuilder { @SuppressWarnings("UNCHECKED_CAST") fun request( eventType: ConiumEventType, - arg1: DynamicArgType + arg1: DynamicArgType, + arising: ParameterSelective2 = ParameterSelective2 { _, _ -> false } ): ConiumEventContext> { val context = ConiumEventContext( DynamicArgsBuilder.requires( @@ -115,6 +121,8 @@ object ConiumEventContextBuilder { ConiumEvent.forever(eventType, context) + context.arising(arising) + return context } @@ -123,7 +131,8 @@ object ConiumEventContextBuilder { fun request( eventType: ConiumEventType, arg1: DynamicArgType, - arg2: DynamicArgType + arg2: DynamicArgType, + arising: ParameterSelective3 = ParameterSelective3 { _, _, _ -> false } ): ConiumEventContext> { val context = ConiumEventContext( DynamicArgsBuilder.requires( @@ -135,6 +144,8 @@ object ConiumEventContextBuilder { ConiumEvent.forever(eventType, context) + context.arising(arising) + return context } @@ -144,7 +155,8 @@ object ConiumEventContextBuilder { eventType: ConiumEventType, arg1: DynamicArgType, arg2: DynamicArgType, - arg3: DynamicArgType + arg3: DynamicArgType, + arising: ParameterSelective4 = ParameterSelective4 { _, _, _, _ -> false } ): ConiumEventContext> { val context = ConiumEventContext( DynamicArgsBuilder.requires( @@ -157,6 +169,8 @@ object ConiumEventContextBuilder { ConiumEvent.forever(eventType, context) + context.arising(arising) + return context } @@ -167,7 +181,8 @@ object ConiumEventContextBuilder { arg1: DynamicArgType, arg2: DynamicArgType, arg3: DynamicArgType, - arg4: DynamicArgType + arg4: DynamicArgType, + arising: ParameterSelective5 = ParameterSelective5 { _, _, _, _, _ -> false } ): ConiumEventContext> { val context = ConiumEventContext( DynamicArgsBuilder.requires( @@ -181,6 +196,8 @@ object ConiumEventContextBuilder { ConiumEvent.forever(eventType, context) + context.arising(arising) + return context } @@ -192,7 +209,8 @@ object ConiumEventContextBuilder { arg2: DynamicArgType, arg3: DynamicArgType, arg4: DynamicArgType, - arg5: DynamicArgType + arg5: DynamicArgType, + arising: ParameterSelective6 = ParameterSelective6 { _, _, _, _, _, _ -> false } ): ConiumEventContext> { val context = ConiumEventContext( DynamicArgsBuilder.requires( @@ -207,6 +225,8 @@ object ConiumEventContextBuilder { ConiumEvent.forever(eventType, context) + context.arising(arising) + return context } @@ -219,7 +239,8 @@ object ConiumEventContextBuilder { arg3: DynamicArgType, arg4: DynamicArgType, arg5: DynamicArgType, - arg6: DynamicArgType + arg6: DynamicArgType, + arising: ParameterSelective7 = ParameterSelective7 { _, _, _, _, _, _, _ -> false } ): ConiumEventContext> { val context = ConiumEventContext( DynamicArgsBuilder.requires( @@ -235,6 +256,8 @@ object ConiumEventContextBuilder { ConiumEvent.forever(eventType, context) + context.arising(arising) + return context } @@ -248,7 +271,8 @@ object ConiumEventContextBuilder { arg4: DynamicArgType, arg5: DynamicArgType, arg6: DynamicArgType, - arg7: DynamicArgType + arg7: DynamicArgType, + arising: ParameterSelective8 = ParameterSelective8 { _, _, _, _, _, _, _, _ -> false } ): ConiumEventContext> { val context = ConiumEventContext( DynamicArgsBuilder.requires( @@ -265,6 +289,8 @@ object ConiumEventContextBuilder { ConiumEvent.forever(eventType, context) + context.arising(arising) + return context } } diff --git a/src/main/java/com/github/cao/awa/conium/mixin/item/FuelRegistryMixin.java b/src/main/java/com/github/cao/awa/conium/mixin/item/FuelRegistryMixin.java index 16bf102..fc5cd58 100644 --- a/src/main/java/com/github/cao/awa/conium/mixin/item/FuelRegistryMixin.java +++ b/src/main/java/com/github/cao/awa/conium/mixin/item/FuelRegistryMixin.java @@ -20,6 +20,7 @@ public class FuelRegistryMixin { ) public void isFuel(ItemStack item, CallbackInfoReturnable cir) { if (!cir.getReturnValue()) { + // When the item are not registered fuel in vanilla, the find the fuel in conium registry. assert Conium.coniumItemManager != null; cir.setReturnValue(Conium.coniumItemManager.getFuels().contains(item.getItem())); } @@ -31,6 +32,7 @@ public void isFuel(ItemStack item, CallbackInfoReturnable cir) { cancellable = true ) public void getFuelItems(CallbackInfoReturnable> cir) { + // When the item are not registered fuel in vanilla, the find the fuel in conium registry. assert Conium.coniumItemManager != null; cir.setReturnValue(Conium.coniumItemManager.computeFuels(cir.getReturnValue())); } @@ -42,6 +44,8 @@ public void getFuelItems(CallbackInfoReturnable> cir) { ) public void getFuelTicks(ItemStack stack, CallbackInfoReturnable cir) { if (cir.getReturnValue() == 0) { + // When the item are not registered fuel in vanilla, the find the fuel ticks in conium registry. + assert Conium.coniumItemManager != null; cir.setReturnValue(Conium.coniumItemManager.getFuelTicks(stack)); } }