From 18424fb151987fd65e923c30513dfc59d8240e2e Mon Sep 17 00:00:00 2001 From: ictye Date: Sat, 20 Apr 2024 16:40:18 +0800 Subject: [PATCH] =?UTF-8?q?pref:=20=E6=9B=B4=E6=96=B0=E4=BA=86=E5=A4=9A?= =?UTF-8?q?=E4=B8=AA=E6=96=87=E4=BB=B6=EF=BC=8C=E5=8C=85=E6=8B=AC=E7=89=A9?= =?UTF-8?q?=E5=93=81=E3=80=81=E6=96=B9=E5=9D=97=E3=80=81=E7=BD=91=E7=BB=9C?= =?UTF-8?q?=E5=82=B3=E8=BC=B8=20packets=20=E5=92=8C=E5=90=91=E9=87=8F?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E7=B1=BB=E3=80=82=E4=BC=98=E5=8C=96=E4=BA=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=B3=A8=E9=87=8A=EF=BC=8C=E6=96=87=E6=AA=94?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E6=B7=BB=E5=8A=A0=E4=BA=86=E6=96=B0=E7=9A=84?= =?UTF-8?q?=E9=AD=94=E6=B3=95=E7=89=A9=E5=93=81=E5=92=8C=E5=AE=9E=E4=BD=93?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modified files: - src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/StdMagicItem.java - src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/LimiterItem/StdLimiterItem.java - src/main/java/com/ictye/the_origin_of_magic/utils/Vec3d_Util.java - src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Staff/StdStaff.java - src/main/java/com/ictye/the_origin_of_magic/Contents/AllBlockEntity.java - src/main/java/com/ictye/the_origin_of_magic/foundation/Blocks/MagicWorkstationBlockEntity.java - src/main/java/com/ictye/the_origin_of_magic/the_origin_of_magic_client.java - src/main/java/com/ictye/the_origin_of_magic/infrastructure/netWork/SyncHUDS2CPacket.java - src/main/generated/.cache/dc1d6e7286e7569a79007c10f809d49635ea1c49 - src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/PoisonThrownMagic.java --- .../89b86ab0e66f527166d98df92ddbcf5416ed58f6 | 4 +- .../dc1d6e7286e7569a79007c10f809d49635ea1c49 | 2 +- .../f3798f81c7b6fecad2cbfec741314f8a66c0eca3 | 7 +- .../the_origin_of_magic/lang/en_us.json | 5 +- .../models/item/hoglin_entity_limiter.json | 6 -- .../{test_magic.json => poison_magic.json} | 2 +- .../Contents/AllBlock.java | 20 +++-- .../Contents/AllBlockEntity.java | 7 +- .../Contents/AllEntity.java | 43 ++++++--- .../the_origin_of_magic/Contents/AllItem.java | 73 +++++++++------ .../foundation/Blocks/MagicWorkstation.java | 2 +- .../Blocks/MagicWorkstationBlockEntity.java | 4 +- .../Magics/EffectMagic/StdEffectMagic.java | 12 +++ .../Entitys/Magics/ExplosionThrownMagic.java | 31 +++---- .../Entitys/Magics/PoisonThrownMagic.java | 36 ++++++++ .../Entitys/Magics/StdThrownMagic.java | 84 +++++++++++++++--- .../Magic/EffectMagicItem/StdEffectItem.java | 14 +++ ...tem.java => ExplosionMagicEntityItem.java} | 10 +-- .../Magic/LimiterItem/StdLimiterItem.java | 6 +- .../LimiterItem/UndeadEntityLimiterItem.java | 3 +- .../Items/Magic/PoisonMagicEntityItem.java | 25 ++++++ .../foundation/Items/Magic/StdMagicItem.java | 15 +++- .../foundation/Items/Staff/StdStaff.java | 31 ++++--- .../foundation/mixin/HUD/PlayerHudMixin.java | 1 + .../mixin/PlayerEntity/ClientPlayerMixin.java | 3 +- .../mixin/PlayerEntity/PlayerEntityMixin.java | 3 +- ...ntityMixin.java => ServerEntityMixin.java} | 11 ++- .../infrastructure/GUI/MagicLevelHud.java | 2 +- .../netWork/SyncHUDS2CPacket.java | 2 +- .../the_origin_of_magic_client.java | 2 +- .../ImplementedInventory.java | 2 +- .../PlayerEntityMixinInterfaces.java | 2 +- .../the_origin_of_magic/utils/Vec3d_Util.java | 19 +++- .../{test_magic.png => explosion_magic.png} | Bin ...limiter.png => hostile_entity_limiter.png} | Bin .../resources/the_origin_of_magic.mixins.json | 2 +- 36 files changed, 359 insertions(+), 132 deletions(-) delete mode 100644 src/main/generated/assets/the_origin_of_magic/models/item/hoglin_entity_limiter.json rename src/main/generated/assets/the_origin_of_magic/models/item/{test_magic.json => poison_magic.json} (53%) create mode 100644 src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/EffectMagic/StdEffectMagic.java create mode 100644 src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/PoisonThrownMagic.java create mode 100644 src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/EffectMagicItem/StdEffectItem.java rename src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/{TestMagicEntityItem.java => ExplosionMagicEntityItem.java} (72%) create mode 100644 src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/PoisonMagicEntityItem.java rename src/main/java/com/ictye/the_origin_of_magic/foundation/mixin/PlayerEntity/{SeriverEntityMixin.java => ServerEntityMixin.java} (81%) rename src/main/java/com/ictye/the_origin_of_magic/utils/{ => InterFaces}/ImplementedInventory.java (98%) rename src/main/java/com/ictye/the_origin_of_magic/utils/{ => InterFaces}/PlayerEntityMixinInterfaces.java (79%) rename src/main/resources/assets/the_origin_of_magic/textures/item/{test_magic.png => explosion_magic.png} (100%) rename src/main/resources/assets/the_origin_of_magic/textures/item/{hoglin_entity_limiter.png => hostile_entity_limiter.png} (100%) diff --git a/src/main/generated/.cache/89b86ab0e66f527166d98df92ddbcf5416ed58f6 b/src/main/generated/.cache/89b86ab0e66f527166d98df92ddbcf5416ed58f6 index e2d652a..7082431 100644 --- a/src/main/generated/.cache/89b86ab0e66f527166d98df92ddbcf5416ed58f6 +++ b/src/main/generated/.cache/89b86ab0e66f527166d98df92ddbcf5416ed58f6 @@ -1,2 +1,2 @@ -// 1.19.2 2024-04-20T13:20:04.2533668 Language -cf9144aa31d03773d984551199f36d4c66351a1f assets\the_origin_of_magic\lang\en_us.json +// 1.19.2 2024-04-20T16:16:43.5788967 Language +e4957a0a0c98975bf4c2d8324cf2ff65b3281ca1 assets\the_origin_of_magic\lang\en_us.json diff --git a/src/main/generated/.cache/dc1d6e7286e7569a79007c10f809d49635ea1c49 b/src/main/generated/.cache/dc1d6e7286e7569a79007c10f809d49635ea1c49 index 8b7f784..c185556 100644 --- a/src/main/generated/.cache/dc1d6e7286e7569a79007c10f809d49635ea1c49 +++ b/src/main/generated/.cache/dc1d6e7286e7569a79007c10f809d49635ea1c49 @@ -1,2 +1,2 @@ -// 1.19.2 2024-04-20T13:20:04.2507738 Block Loot Tables +// 1.19.2 2024-04-20T16:16:43.57588 Block Loot Tables fe57f13449a11436bbede8c37e01bd0d1cd87191 data\the_origin_of_magic\loot_tables\blocks\magic_workbench.json diff --git a/src/main/generated/.cache/f3798f81c7b6fecad2cbfec741314f8a66c0eca3 b/src/main/generated/.cache/f3798f81c7b6fecad2cbfec741314f8a66c0eca3 index d3b7bff..f569a33 100644 --- a/src/main/generated/.cache/f3798f81c7b6fecad2cbfec741314f8a66c0eca3 +++ b/src/main/generated/.cache/f3798f81c7b6fecad2cbfec741314f8a66c0eca3 @@ -1,5 +1,6 @@ -// 1.19.2 2024-04-20T13:20:04.2558702 Models +// 1.19.2 2024-04-20T16:16:43.5723787 Models +50c992db06feb825ceb8fe3bd063a7d5fcc83264 assets\the_origin_of_magic\models\item\explosion_magic.json +ddf4e605ac73f757f76bbfe39d60312b7042e7d9 assets\the_origin_of_magic\models\item\hostile_entity_limiter.json 02d3ff4716d16f7c5a4dd4432d1b98f744a13f02 assets\the_origin_of_magic\models\item\blood_essence.json -b1555a32206034cd8f1b13891371182e88d9d40a assets\the_origin_of_magic\models\item\test_magic.json +681374800d5b4991c2e8d6304781b89089bd379c assets\the_origin_of_magic\models\item\poison_magic.json 03b1f5cc891077d36d38a8d98d2ffe49396f8229 assets\the_origin_of_magic\models\item\water_magic_element.json -a50a32a25dfc8a066cacf0c15ac0420396c0c5fc assets\the_origin_of_magic\models\item\hoglin_entity_limiter.json diff --git a/src/main/generated/assets/the_origin_of_magic/lang/en_us.json b/src/main/generated/assets/the_origin_of_magic/lang/en_us.json index 5345e8b..4dec277 100644 --- a/src/main/generated/assets/the_origin_of_magic/lang/en_us.json +++ b/src/main/generated/assets/the_origin_of_magic/lang/en_us.json @@ -2,8 +2,9 @@ "block.the_origin_of_magic.magic_workbench": "Magic Workbench", "item.the_origin_of_magic.blood_essence": "Blood Essence", "item.the_origin_of_magic.deadwood_staff": "Deadwood Staff", - "item.the_origin_of_magic.hoglin_entity_limiter": "Hoglin Entity Limiter", - "item.the_origin_of_magic.test_magic": "Test Magic", + "item.the_origin_of_magic.explosion_magic": "Explosion Magic", + "item.the_origin_of_magic.hostile_entity_limiter": "Hostile Entity Limiter", + "item.the_origin_of_magic.poison_magic": "Poison Magic", "item.the_origin_of_magic.test_staff": "Test Staff", "item.the_origin_of_magic.water_magic_element": "Water Magic Element", "itemGroup.the_origin_of_magic.normal": "The Origin Of The Magic", diff --git a/src/main/generated/assets/the_origin_of_magic/models/item/hoglin_entity_limiter.json b/src/main/generated/assets/the_origin_of_magic/models/item/hoglin_entity_limiter.json deleted file mode 100644 index 8a84741..0000000 --- a/src/main/generated/assets/the_origin_of_magic/models/item/hoglin_entity_limiter.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "parent": "minecraft:item/generated", - "textures": { - "layer0": "the_origin_of_magic:item/hoglin_entity_limiter" - } -} \ No newline at end of file diff --git a/src/main/generated/assets/the_origin_of_magic/models/item/test_magic.json b/src/main/generated/assets/the_origin_of_magic/models/item/poison_magic.json similarity index 53% rename from src/main/generated/assets/the_origin_of_magic/models/item/test_magic.json rename to src/main/generated/assets/the_origin_of_magic/models/item/poison_magic.json index cac2aa4..443c7c4 100644 --- a/src/main/generated/assets/the_origin_of_magic/models/item/test_magic.json +++ b/src/main/generated/assets/the_origin_of_magic/models/item/poison_magic.json @@ -1,6 +1,6 @@ { "parent": "minecraft:item/generated", "textures": { - "layer0": "the_origin_of_magic:item/test_magic" + "layer0": "the_origin_of_magic:item/poison_magic" } } \ No newline at end of file diff --git a/src/main/java/com/ictye/the_origin_of_magic/Contents/AllBlock.java b/src/main/java/com/ictye/the_origin_of_magic/Contents/AllBlock.java index 71fb8f9..a65199c 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/Contents/AllBlock.java +++ b/src/main/java/com/ictye/the_origin_of_magic/Contents/AllBlock.java @@ -17,11 +17,21 @@ public class AllBlock { public static HashMap BlockItems = new HashMap<>(); - public static Block MAGIC_WORKSTATION = new MagicWorkstation(FabricBlockSettings.of(Material.STONE).strength(50.0f, 1200.0f).luminance(state -> 10)); - @SuppressWarnings("SameParameterValue") - private static void registerBlock(String name, Block block){ - Registry.register(Registry.BLOCK,new Identifier(the_origin_of_magic.Mod_Id, name),block); - BlockItems.put(name,new BlockItem(block,new FabricItemSettings().group(AllItem.TheOriginOfMagicItemGroup))); + //魔法工作臺 + public static Block MAGIC_WORKSTATION = new MagicWorkstation(FabricBlockSettings. + of(Material.STONE) + .strength(50.0f, 1200.0f) + .luminance(state -> 10)); + + /** + * 注册方块 + * @param id 方塊ID + * @param block 方塊 + */ + @SuppressWarnings("SameParameterValue") // 防止IDE瞎TM嗶嗶,煩死了。。。。。。 + private static void registerBlock(String id, Block block){ + Registry.register(Registry.BLOCK,new Identifier(the_origin_of_magic.Mod_Id, id),block); + BlockItems.put(id,new BlockItem(block,new FabricItemSettings().group(AllItem.TheOriginOfMagicItemGroup))); } public static void register(){ diff --git a/src/main/java/com/ictye/the_origin_of_magic/Contents/AllBlockEntity.java b/src/main/java/com/ictye/the_origin_of_magic/Contents/AllBlockEntity.java index 84a03d5..acc0a53 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/Contents/AllBlockEntity.java +++ b/src/main/java/com/ictye/the_origin_of_magic/Contents/AllBlockEntity.java @@ -7,9 +7,14 @@ import net.minecraft.util.registry.Registry; public class AllBlockEntity { + /** + * 魔法工作臺 + */ public static final BlockEntityType MAGIC_WORK_STATION_BLOCK_ENTITIY = BlockEntityType.Builder.create(MagicWorkstationBlockEntity::new, AllBlock.MAGIC_WORKSTATION).build(null); public static void register(){ - Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier(the_origin_of_magic.Mod_Id,"magic_work_station"),MAGIC_WORK_STATION_BLOCK_ENTITIY); + Registry.register(Registry.BLOCK_ENTITY_TYPE, + new Identifier(the_origin_of_magic.Mod_Id,"magic_work_station"), + MAGIC_WORK_STATION_BLOCK_ENTITIY); } } diff --git a/src/main/java/com/ictye/the_origin_of_magic/Contents/AllEntity.java b/src/main/java/com/ictye/the_origin_of_magic/Contents/AllEntity.java index d455c14..5b4c901 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/Contents/AllEntity.java +++ b/src/main/java/com/ictye/the_origin_of_magic/Contents/AllEntity.java @@ -1,6 +1,7 @@ package com.ictye.the_origin_of_magic.Contents; import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.ExplosionThrownMagic; +import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.PoisonThrownMagic; import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.StdThrownMagic; import com.ictye.the_origin_of_magic.the_origin_of_magic; import net.fabricmc.api.EnvType; @@ -16,27 +17,47 @@ public class AllEntity { - public static final EntityType TEST_MAGIC_ENTITY_TYPE= FabricEntityTypeBuilder.create(SpawnGroup.MISC, ExplosionThrownMagic::new) + /** + * 爆炸魔法實體 + */ + public static final EntityType EXPOLOSION_MAGIC_ENTITY_TYPE = FabricEntityTypeBuilder + .create(SpawnGroup.MISC, ExplosionThrownMagic::new) .dimensions(EntityDimensions.fixed(0.25F, 0.25F)) .trackRangeBlocks(4).trackedUpdateRate(10) .build(); + /** + * 毒魔法實體 + */ + public static final EntityType POISON_MAGIC_ENTITY_TYPE = FabricEntityTypeBuilder + .create(SpawnGroup.MISC, PoisonThrownMagic::new) + .dimensions(EntityDimensions.fixed(0.25F, 0.25F)) + .trackRangeBlocks(4).trackedUpdateRate(10) + .build(); + + /** + * 注冊魔法實體 + */ public static void regEntity(){ - /* - * 注冊實體 - * */ + // 注冊實體 Registry.register(Registry.ENTITY_TYPE, new Identifier(the_origin_of_magic.Mod_Id,"test_magic"), - TEST_MAGIC_ENTITY_TYPE + EXPOLOSION_MAGIC_ENTITY_TYPE ); + + Registry.register(Registry.ENTITY_TYPE, + new Identifier(the_origin_of_magic.Mod_Id,"poison_magic"), + POISON_MAGIC_ENTITY_TYPE + ); } + /** + * 注冊魔法實體渲染器 + */ @Environment(EnvType.CLIENT) - public static void regEntityRunder(){ - /* - * 注冊實體渲染器 - * */ - EntityRendererRegistry.register(TEST_MAGIC_ENTITY_TYPE, FlyingItemEntityRenderer::new); - + public static void regEntityRenderer(){ + // 注冊實體渲染器 + EntityRendererRegistry.register(EXPOLOSION_MAGIC_ENTITY_TYPE, FlyingItemEntityRenderer::new); + EntityRendererRegistry.register(POISON_MAGIC_ENTITY_TYPE, FlyingItemEntityRenderer::new); } } diff --git a/src/main/java/com/ictye/the_origin_of_magic/Contents/AllItem.java b/src/main/java/com/ictye/the_origin_of_magic/Contents/AllItem.java index 3bdfad5..14ffe86 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/Contents/AllItem.java +++ b/src/main/java/com/ictye/the_origin_of_magic/Contents/AllItem.java @@ -1,7 +1,8 @@ package com.ictye.the_origin_of_magic.Contents; +import com.ictye.the_origin_of_magic.foundation.Items.Magic.ExplosionMagicEntityItem; import com.ictye.the_origin_of_magic.foundation.Items.Magic.LimiterItem.UndeadEntityLimiterItem; -import com.ictye.the_origin_of_magic.foundation.Items.Magic.TestMagicEntityItem; +import com.ictye.the_origin_of_magic.foundation.Items.Magic.PoisonMagicEntityItem; import com.ictye.the_origin_of_magic.foundation.Items.Staff.DeadwoodStaff; import com.ictye.the_origin_of_magic.foundation.Items.Staff.TestStaff; import com.ictye.the_origin_of_magic.the_origin_of_magic; @@ -23,18 +24,15 @@ */ public class AllItem { - /* - 所有物品組 - */ - + ////////////////////////////////////////////////// + // 所有物品組 /** * 主物品組 */ public static final ItemGroup TheOriginOfMagicItemGroup = FabricItemGroupBuilder.build(new Identifier(the_origin_of_magic.Mod_Id,"normal"), - () ->new ItemStack(AllBlock.BlockItems.get("magic_workbench"))); - /** - * 所有法杖 - */ + () ->new ItemStack(AllBlock.BlockItems.get("magic_workbench"))); + ///////////////////////////////////////////////// + // 所有法杖 public static final Item DEADWOOD_STAFF = new DeadwoodStaff(new FabricItemSettings() .maxCount(1) .group(TheOriginOfMagicItemGroup) @@ -45,42 +43,50 @@ public class AllItem { .group(TheOriginOfMagicItemGroup) .maxDamage(300) .rarity(Rarity.RARE)); // 測試法杖 - /** - * 所有魔法 - */ - public static final Item TEST_MAGIC = new TestMagicEntityItem(new FabricItemSettings() + ////////////////////////////////////////////// + //所有魔法 + public static final Item EXPLOSION_MAGIC = new ExplosionMagicEntityItem(new FabricItemSettings() .maxCount(1) - .group(TheOriginOfMagicItemGroup), AllEntity.TEST_MAGIC_ENTITY_TYPE); // 測試魔法 + .group(TheOriginOfMagicItemGroup), AllEntity.EXPOLOSION_MAGIC_ENTITY_TYPE); // 測試魔法 - public static final Item HOGLIN_ENTITY_LIMITER = new UndeadEntityLimiterItem(new FabricItemSettings() + public static final Item POISON_MAGIC = new PoisonMagicEntityItem(new FabricItemSettings() + .maxCount(1) + .group(TheOriginOfMagicItemGroup), AllEntity.POISON_MAGIC_ENTITY_TYPE); + + public static final Item HOSTILE_ENTITY_LIMITER = new UndeadEntityLimiterItem(new FabricItemSettings() .maxCount(1) .group(TheOriginOfMagicItemGroup) .maxDamage(100) .rarity(Rarity.COMMON),null); - + //////////////////////////////////////////////// + //所有材料 /** - * 所有材料 + * 血色寶石 */ - public static final Item BLOOD_ESSENCE = new Item(new FabricItemSettings() .group(TheOriginOfMagicItemGroup) .rarity(Rarity.COMMON)); + /** + * 水元素魔法 + */ public static final Item WATER_MAGIC_ELEMENT = new Item(new FabricItemSettings() .group(TheOriginOfMagicItemGroup) .rarity(Rarity.COMMON)); - + ////////////////////////////////////////////// + // 注冊列表 /** * 物品ID列表 */ public static final Map ItemMap = Map.of( "deadwood_staff",DEADWOOD_STAFF, "test_staff",TEST_STAFF, - "test_magic",TEST_MAGIC, - "hoglin_entity_limiter", HOGLIN_ENTITY_LIMITER, + "explosion_magic", EXPLOSION_MAGIC, + "hostile_entity_limiter", HOSTILE_ENTITY_LIMITER, "blood_essence",BLOOD_ESSENCE, - "water_magic_element",WATER_MAGIC_ELEMENT + "water_magic_element",WATER_MAGIC_ELEMENT, + "poison_magic",POISON_MAGIC ); /** @@ -89,10 +95,11 @@ public class AllItem { public static final Map ItemTransMap = Map.of( "Deadwood Staff",DEADWOOD_STAFF, "Test Staff",TEST_STAFF, - "Test Magic",TEST_MAGIC, - "Hoglin Entity Limiter", HOGLIN_ENTITY_LIMITER, + "Explosion Magic", EXPLOSION_MAGIC, + "Hostile Entity Limiter", HOSTILE_ENTITY_LIMITER, "Blood Essence", BLOOD_ESSENCE, - "Water Magic Element",WATER_MAGIC_ELEMENT + "Water Magic Element",WATER_MAGIC_ELEMENT, + "Poison Magic",POISON_MAGIC ); /** @@ -101,18 +108,30 @@ public class AllItem { public static final Map< Item,Model> ItemModelMap = Map.of( BLOOD_ESSENCE,Models.GENERATED, WATER_MAGIC_ELEMENT,Models.GENERATED, - TEST_MAGIC,Models.GENERATED, - HOGLIN_ENTITY_LIMITER,Models.GENERATED + EXPLOSION_MAGIC,Models.GENERATED, + HOSTILE_ENTITY_LIMITER,Models.GENERATED, + POISON_MAGIC,Models.GENERATED ); + /////////////////////////////////////// + /** + * 注冊物品 + * @param name 名稱 + * @param item 物品 + */ private static void registerItem(String name, Item item){ Registry.register(Registry.ITEM, new Identifier(the_origin_of_magic.Mod_Id, name), item); } + + /** + * 開始注冊物品 + */ public static void registerItems(){ // 注冊方塊物品 for (String name : AllBlock.BlockItems.keySet()) { registerItem(name, AllBlock.BlockItems.get(name)); } + // 注冊物品 for (String name : ItemMap.keySet()) { registerItem(name, ItemMap.get(name)); diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Blocks/MagicWorkstation.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Blocks/MagicWorkstation.java index 8431808..d1fa68b 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/foundation/Blocks/MagicWorkstation.java +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Blocks/MagicWorkstation.java @@ -15,6 +15,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; + /* * 魔法工作臺 * */ @@ -33,7 +34,6 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt return ActionResult.SUCCESS; } - @Nullable @Override public BlockEntity createBlockEntity(BlockPos pos, BlockState state) { diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Blocks/MagicWorkstationBlockEntity.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Blocks/MagicWorkstationBlockEntity.java index 76e0e2c..bc0f542 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/foundation/Blocks/MagicWorkstationBlockEntity.java +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Blocks/MagicWorkstationBlockEntity.java @@ -5,9 +5,11 @@ import net.minecraft.block.entity.BlockEntity; import net.minecraft.util.math.BlockPos; +/** + * 魔法工作臺的方塊實體 + */ public class MagicWorkstationBlockEntity extends BlockEntity { public MagicWorkstationBlockEntity(BlockPos pos, BlockState state) { super(AllBlockEntity.MAGIC_WORK_STATION_BLOCK_ENTITIY, pos, state); } - } diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/EffectMagic/StdEffectMagic.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/EffectMagic/StdEffectMagic.java new file mode 100644 index 0000000..ac1316d --- /dev/null +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/EffectMagic/StdEffectMagic.java @@ -0,0 +1,12 @@ +package com.ictye.the_origin_of_magic.foundation.Entitys.Magics.EffectMagic; + +import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.StdMagicInterface; +import net.minecraft.world.World; + +public abstract class StdEffectMagic implements StdMagicInterface { + /** + * 生產魔法特效 + * @param world 世界 + */ + public abstract void tick(World world); +} diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/ExplosionThrownMagic.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/ExplosionThrownMagic.java index e60094f..c995e19 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/ExplosionThrownMagic.java +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/ExplosionThrownMagic.java @@ -12,30 +12,36 @@ import net.minecraft.world.World; import net.minecraft.world.explosion.Explosion; +/** + * 爆炸法術 + */ public class ExplosionThrownMagic extends StdThrownMagic { - private float exolisionRate; + private float explosionRate; @Override protected float getGravity() { - return 0.0F; + return 0.0F; //讓它失去重力 } + ////////////////////// + //構造器(們?) public ExplosionThrownMagic(EntityType entityType, World world) { super(entityType, world); - this.exolisionRate = 1.0F; + this.explosionRate = 1.0F; } - public ExplosionThrownMagic(EntityType type, LivingEntity owner, World world) { + public ExplosionThrownMagic(EntityType type, LivingEntity owner, World world) { super(type, owner, world); - this.exolisionRate = 1.0F; + this.explosionRate = 1.0F; } - public ExplosionThrownMagic(EntityType type, LivingEntity owner, World world, float exolisionRate) { + // 創建魔法應該是用的這個我記得 + public ExplosionThrownMagic(EntityType type, LivingEntity owner, World world, float explosionRate) { this(type, owner, world); - this.exolisionRate = exolisionRate; + this.explosionRate = explosionRate; } - + ///////////////////// @Override protected void collision(HitResult hitResult) { @@ -46,18 +52,13 @@ protected void collision(HitResult hitResult) { return; } BlockPos pos = new BlockPos(hitResult.getPos()); - this.world.createExplosion(this, pos.getX(), pos.getY(), pos.getZ(), 5.0F * exolisionRate, Explosion.DestructionType.BREAK); + this.world.createExplosion(this, pos.getX(), pos.getY(), pos.getZ(), 3.0F * explosionRate, Explosion.DestructionType.BREAK); this.remove(RemovalReason.CHANGED_DIMENSION); } - @Override - protected void initDataTracker() { - super.initDataTracker(); - } - @Override public ItemStack getStack() { - return new ItemStack(AllItem.TEST_MAGIC,1); + return new ItemStack(AllItem.EXPLOSION_MAGIC,1); } @Override diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/PoisonThrownMagic.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/PoisonThrownMagic.java new file mode 100644 index 0000000..2a1dc1a --- /dev/null +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/PoisonThrownMagic.java @@ -0,0 +1,36 @@ +package com.ictye.the_origin_of_magic.foundation.Entitys.Magics; + +import com.ictye.the_origin_of_magic.Contents.AllItem; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.effect.StatusEffectInstance; +import net.minecraft.entity.effect.StatusEffects; +import net.minecraft.entity.projectile.thrown.ThrownEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.hit.EntityHitResult; +import net.minecraft.world.World; + +public class PoisonThrownMagic extends StdThrownMagic{ + public PoisonThrownMagic(EntityType entityType, World world) { + super(entityType, world); + magicRate = 3; + } + + public PoisonThrownMagic(EntityType type, LivingEntity owner, World world) { + super(type, owner, world); + magicRate = 3; + } + + @Override + public ItemStack getStack() { + return new ItemStack(AllItem.POISON_MAGIC); + } + + @Override + protected void onEntityHit(EntityHitResult entityHitResult) { + StatusEffectInstance poison = new StatusEffectInstance(StatusEffects.POISON, 200); + ((LivingEntity)entityHitResult.getEntity()).addStatusEffect(poison); + super.onEntityHit(entityHitResult); + this.remove(RemovalReason.CHANGED_DIMENSION); + } +} diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/StdThrownMagic.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/StdThrownMagic.java index 5eb3014..a7e4562 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/StdThrownMagic.java +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/StdThrownMagic.java @@ -1,14 +1,20 @@ package com.ictye.the_origin_of_magic.foundation.Entitys.Magics; +import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.EffectMagic.StdEffectMagic; import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.Limiters.StdMagicLimiter; +import com.ictye.the_origin_of_magic.utils.InterFaces.PlayerEntityMixinInterfaces; +import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.FlyingItemEntity; import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.projectile.thrown.ThrownEntity; import net.minecraft.nbt.NbtCompound; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.EntityHitResult; import net.minecraft.util.hit.HitResult; +import net.minecraft.util.math.Direction; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import java.util.ArrayList; @@ -24,20 +30,45 @@ public abstract class StdThrownMagic extends ThrownEntity implements FlyingItemE /** * 附加魔法列表 */ - private List magic; + private List additionMagicList; + private List effectMagicList = new ArrayList<>(); + + /** + * 添加法術效果 + * @param effectMagic 效果法術 + */ + public void addEffect(StdEffectMagic effectMagic) { + effectMagicList.add(effectMagic); + } + + /** + * 限制器列表 + */ private final List limiters = new ArrayList<>(); + /** + * 添加監聽 + * @param limiter 監聽器 + */ + public void addLimiter(StdMagicLimiter limiter){ + limiters.add(limiter); + } + /** * 爆炸傷害倍率 */ - private float exolisionRate; + private float explosionRate; + + public float getExplosionRate() { + return explosionRate; + } /** * 魔力扣除倍率 */ - private float magicRate = 5; + float magicRate = 5; public float getMagicRate() { return magicRate; @@ -55,7 +86,7 @@ public int getAdditionalTrigger() { * @param magics 魔法列表 */ public void setAdditionTrigger(List magics){ - this.magic = magics; + this.additionMagicList = magics; } protected StdThrownMagic(EntityType entityType, World world) { @@ -70,9 +101,9 @@ protected StdThrownMagic(EntityType type, LivingEntity o super(type, owner, world); } - public StdThrownMagic(EntityType type, LivingEntity owner, World world, float exolisionRate) { + public StdThrownMagic(EntityType type, LivingEntity owner, World world, float explosionRate) { this(type, owner, world); - this.exolisionRate = exolisionRate; + this.explosionRate = explosionRate; } /** @@ -97,18 +128,35 @@ protected void onCollision(HitResult hitResult) { } } } + + // 施放附加魔法 + //noinspection ConstantValue + if(additionalTrigger > 0){ + for (StdThrownMagic additionMagic : additionMagicList) { + Entity owner = this.getOwner(); + if(owner instanceof PlayerEntityMixinInterfaces player){ + + Vec3d v = this.getVelocity(); + if(hitResult instanceof BlockHitResult blockHitResult){ + Direction face = blockHitResult.getSide(); + if(face == Direction.UP || face == Direction.DOWN){ + additionMagic.setVelocity(new Vec3d(v.x,v.y,-v.z)); + }else if(face == Direction.NORTH || face == Direction.SOUTH){ + additionMagic.setVelocity(new Vec3d(v.x,-v.z,v.y)); + }else if(face == Direction.EAST || face == Direction.WEST){ + additionMagic.setVelocity(new Vec3d(-v.z,v.y,v.x)); + } + } else { + additionMagic.setVelocity(v); + } + player.the_origin_of_magic$getMagicAbilitiesManager().cast((PlayerEntity)player,additionMagic, this.world); + } + } + } collision(hitResult); super.onCollision(hitResult); } - /** - * 添加監聽 - * @param limiter 監聽器 - */ - public void addLimiter(StdMagicLimiter limiter){ - limiters.add(limiter); - } - /** * 對onCollision的包裝 * @param hitResult 撞擊結果 @@ -117,6 +165,14 @@ public void addLimiter(StdMagicLimiter limiter){ */ void collision(HitResult hitResult){} + @Override + public void tick() { + super.tick(); + for(StdEffectMagic effectMagic : effectMagicList){ + effectMagic.tick(this.world); + } + } + @Override protected void readCustomDataFromNbt(NbtCompound nbt) { super.readCustomDataFromNbt(nbt); diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/EffectMagicItem/StdEffectItem.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/EffectMagicItem/StdEffectItem.java new file mode 100644 index 0000000..a730d24 --- /dev/null +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/EffectMagicItem/StdEffectItem.java @@ -0,0 +1,14 @@ +package com.ictye.the_origin_of_magic.foundation.Items.Magic.EffectMagicItem; + +import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.StdThrownMagic; +import com.ictye.the_origin_of_magic.foundation.Items.Magic.StdMagicItem; +import net.minecraft.entity.EntityType; + +/** + * 效果魔法對應的標準魔法物品 + */ +public abstract class StdEffectItem extends StdMagicItem { + public StdEffectItem(Settings settings, EntityType entityType) { + super(settings, entityType); + } +} diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/TestMagicEntityItem.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/ExplosionMagicEntityItem.java similarity index 72% rename from src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/TestMagicEntityItem.java rename to src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/ExplosionMagicEntityItem.java index 49ce99b..0cbbdc9 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/TestMagicEntityItem.java +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/ExplosionMagicEntityItem.java @@ -7,15 +7,15 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.world.World; -public class TestMagicEntityItem extends StdMagicItem { +public class ExplosionMagicEntityItem extends StdMagicItem { - private final EntityType magicEntityType = AllEntity.TEST_MAGIC_ENTITY_TYPE; - public TestMagicEntityItem(Settings settings, EntityType entityType) { + private final EntityType magicEntityType = AllEntity.EXPOLOSION_MAGIC_ENTITY_TYPE; + public ExplosionMagicEntityItem(Settings settings, EntityType entityType) { super(settings, entityType); } @Override - public StdThrownMagic getMagic(PlayerEntity user, World world, float exolisionRate, int hartRate) { - return new ExplosionThrownMagic(magicEntityType,user,world,exolisionRate); + public StdThrownMagic getMagic(PlayerEntity user, World world, float explosionRate, int hartRate) { + return new ExplosionThrownMagic(magicEntityType,user,world,explosionRate); } } diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/LimiterItem/StdLimiterItem.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/LimiterItem/StdLimiterItem.java index b613814..d6623e4 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/LimiterItem/StdLimiterItem.java +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/LimiterItem/StdLimiterItem.java @@ -1,12 +1,12 @@ package com.ictye.the_origin_of_magic.foundation.Items.Magic.LimiterItem; -import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.Limiters.StdMagicLimiter; import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.StdThrownMagic; import com.ictye.the_origin_of_magic.foundation.Items.Magic.StdMagicItem; import net.minecraft.entity.EntityType; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.world.World; +/** + * 限制器魔法,用於對包含該魔法的物品進行限制 + */ public abstract class StdLimiterItem extends StdMagicItem { public StdLimiterItem(Settings settings, EntityType entityType) { super(settings, entityType); diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/LimiterItem/UndeadEntityLimiterItem.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/LimiterItem/UndeadEntityLimiterItem.java index 09bd023..e7a88dc 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/LimiterItem/UndeadEntityLimiterItem.java +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/LimiterItem/UndeadEntityLimiterItem.java @@ -1,7 +1,6 @@ package com.ictye.the_origin_of_magic.foundation.Items.Magic.LimiterItem; import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.Limiters.HostileEntityLimiter; -import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.Limiters.StdMagicLimiter; import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.StdMagicInterface; import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.StdThrownMagic; import net.minecraft.entity.EntityType; @@ -15,7 +14,7 @@ public UndeadEntityLimiterItem(Settings settings, EntityType ent @Override - public StdMagicInterface getMagic(PlayerEntity user, World world, float exolisionRate, int hartRate) { + public StdMagicInterface getMagic(PlayerEntity user, World world, float excisionRate, int hartRate) { return new HostileEntityLimiter(); } } diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/PoisonMagicEntityItem.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/PoisonMagicEntityItem.java new file mode 100644 index 0000000..9290bdd --- /dev/null +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/PoisonMagicEntityItem.java @@ -0,0 +1,25 @@ +package com.ictye.the_origin_of_magic.foundation.Items.Magic; + +import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.PoisonThrownMagic; +import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.StdMagicInterface; +import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.StdThrownMagic; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; + +import static com.ictye.the_origin_of_magic.Contents.AllEntity.POISON_MAGIC_ENTITY_TYPE; + +/** + * 中毒法術 + */ +public class PoisonMagicEntityItem extends StdMagicItem{ + + public PoisonMagicEntityItem(Settings settings, EntityType entityType) { + super(settings, entityType); + } + + @Override + public StdMagicInterface getMagic(PlayerEntity user, World world, float excisionRate, int hartRate) { + return new PoisonThrownMagic(POISON_MAGIC_ENTITY_TYPE,user,world); + } +} diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/StdMagicItem.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/StdMagicItem.java index 57026b0..7880bf7 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/StdMagicItem.java +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/StdMagicItem.java @@ -7,13 +7,26 @@ import net.minecraft.item.Item; import net.minecraft.world.World; +/** + * 魔法物品,用於創建魔法物品 + */ public abstract class StdMagicItem extends Item implements StdMagicInterface{ + @SuppressWarnings("FieldCanBeLocal") private final EntityType magicEntityType; + public StdMagicItem(Settings settings, EntityType entityType) { super(settings); this.magicEntityType = entityType; } - abstract public StdMagicInterface getMagic(PlayerEntity user, World world, float exolisionRate, int hartRate); + /** + * 獲取魔法 + * @param user 使用者 + * @param world 世界 + * @param excisionRate 爆炸率 + * @param hartRate 傷害倍率 + * @return 魔法(包含限制器或者效果器) + */ + abstract public StdMagicInterface getMagic(PlayerEntity user, World world, float excisionRate, int hartRate); } diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Staff/StdStaff.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Staff/StdStaff.java index 2acc29a..e92cf0c 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Staff/StdStaff.java +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Staff/StdStaff.java @@ -1,11 +1,12 @@ package com.ictye.the_origin_of_magic.foundation.Items.Staff; +import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.EffectMagic.StdEffectMagic; import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.Limiters.StdMagicLimiter; import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.StdThrownMagic; import com.ictye.the_origin_of_magic.foundation.Items.Magic.StdMagicItem; import com.ictye.the_origin_of_magic.foundation.PlayerAbilities.MagicAbilitiesManager; +import com.ictye.the_origin_of_magic.utils.InterFaces.PlayerEntityMixinInterfaces; import com.ictye.the_origin_of_magic.utils.MagicInventory; -import com.ictye.the_origin_of_magic.utils.PlayerEntityMixinInterfaces; import net.minecraft.block.BlockState; import net.minecraft.client.item.TooltipContext; import net.minecraft.entity.EquipmentSlot; @@ -243,20 +244,6 @@ public void appendTooltip(ItemStack stack, @Nullable World world, List too .getString()).copy().formatted(Formatting.GREEN)); } - /** - * 更新釋放計數,用於循環槽位的指針{@link #castCount} - */ - private void updateCastCount(){ - if (getSize() != 1){ - if (castCount + 1 > getSize()){ - castCount = -1; - updateCastCount(); - }else { - castCount = castCount + 1; - } - } - } - /** * 法術施放主方法 * @param world 世界 @@ -318,6 +305,7 @@ private List summonMagic(MagicInventory inventory, PlayerEntity List magicItemList = new ArrayList<>(); List limiterList = new ArrayList<>(); + List effectList = new ArrayList<>(); for(int i = inventory.size() + 1; i > 0 && count > 0 ;i --){ Item magicItem = inventory.next().getItem(); // 魔法物品 @@ -325,6 +313,7 @@ private List summonMagic(MagicInventory inventory, PlayerEntity continue; } if(((StdMagicItem)magicItem).getMagic(user,world,exolisionRate,hartRate) instanceof StdThrownMagic MagicEntity){ + //處理一般魔法 int addition = MagicEntity.getAdditionalTrigger(); // 處理有附加的法術 if(addition > 0){ @@ -332,17 +321,27 @@ private List summonMagic(MagicInventory inventory, PlayerEntity } magicItemList.add(MagicEntity); count--; - } if(((StdMagicItem)magicItem).getMagic(user,world,exolisionRate,hartRate) instanceof StdMagicLimiter limiter){ + }else if(((StdMagicItem)magicItem).getMagic(user,world,exolisionRate,hartRate) instanceof StdMagicLimiter limiter){ + //處理限制器 limiterList.add(limiter); count--; + } else if (((StdMagicItem) magicItem).getMagic(user, world, exolisionRate, hartRate) instanceof StdEffectMagic effect) { + effectList.add(effect); } } + // 添加限制器 for(StdMagicLimiter limiter :limiterList){ for(StdThrownMagic magic :magicItemList){ magic.addLimiter(limiter); } } + // 添加效果法術 + for (StdEffectMagic effect : effectList){ + for(StdThrownMagic magic :magicItemList){ + magic.addEffect(effect); + } + } return magicItemList; } diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/mixin/HUD/PlayerHudMixin.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/mixin/HUD/PlayerHudMixin.java index c206e0a..54befa9 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/foundation/mixin/HUD/PlayerHudMixin.java +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/mixin/HUD/PlayerHudMixin.java @@ -26,6 +26,7 @@ public abstract class PlayerHudMixin extends DrawableHelper{ @Shadow private int ticks; + // 渲染魔法等級條 @Inject(method = "renderStatusBars", at = @At(value = "HEAD")) private void renderStatusBars(MatrixStack matrices, CallbackInfo ci){ MagicLevelHud.renderThirstHud(matrices, client, this.getCameraPlayer(), ticks); diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/mixin/PlayerEntity/ClientPlayerMixin.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/mixin/PlayerEntity/ClientPlayerMixin.java index c1b6bcf..c301205 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/foundation/mixin/PlayerEntity/ClientPlayerMixin.java +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/mixin/PlayerEntity/ClientPlayerMixin.java @@ -1,7 +1,7 @@ package com.ictye.the_origin_of_magic.foundation.mixin.PlayerEntity; import com.ictye.the_origin_of_magic.foundation.PlayerAbilities.MagicAbilitiesManager; -import com.ictye.the_origin_of_magic.utils.PlayerEntityMixinInterfaces; +import com.ictye.the_origin_of_magic.utils.InterFaces.PlayerEntityMixinInterfaces; import com.mojang.authlib.GameProfile; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.entity.player.PlayerEntity; @@ -17,6 +17,7 @@ public ClientPlayerMixin(World world, BlockPos pos, float yaw, GameProfile gameP super(world, pos, yaw, gameProfile, publicKey); } + @SuppressWarnings("MissingUnique") private final MagicAbilitiesManager magicAbilitiesManager = ((PlayerEntityMixinInterfaces)this).the_origin_of_magic$getMagicAbilitiesManager(); diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/mixin/PlayerEntity/PlayerEntityMixin.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/mixin/PlayerEntity/PlayerEntityMixin.java index da54a1e..96372cb 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/foundation/mixin/PlayerEntity/PlayerEntityMixin.java +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/mixin/PlayerEntity/PlayerEntityMixin.java @@ -2,7 +2,7 @@ import com.ictye.the_origin_of_magic.foundation.PlayerAbilities.MagicAbilitiesManager; -import com.ictye.the_origin_of_magic.utils.PlayerEntityMixinInterfaces; +import com.ictye.the_origin_of_magic.utils.InterFaces.PlayerEntityMixinInterfaces; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; @@ -21,6 +21,7 @@ protected PlayerEntityMixin(EntityType entityType, World super(entityType, world); } + @SuppressWarnings("MissingUnique") private final MagicAbilitiesManager magicAbilitiesManager = new MagicAbilitiesManager(); @Override diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/mixin/PlayerEntity/SeriverEntityMixin.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/mixin/PlayerEntity/ServerEntityMixin.java similarity index 81% rename from src/main/java/com/ictye/the_origin_of_magic/foundation/mixin/PlayerEntity/SeriverEntityMixin.java rename to src/main/java/com/ictye/the_origin_of_magic/foundation/mixin/PlayerEntity/ServerEntityMixin.java index a548bca..6775fb2 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/foundation/mixin/PlayerEntity/SeriverEntityMixin.java +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/mixin/PlayerEntity/ServerEntityMixin.java @@ -2,7 +2,7 @@ import com.ictye.the_origin_of_magic.foundation.PlayerAbilities.MagicAbilitiesManager; import com.ictye.the_origin_of_magic.infrastructure.netWork.NetworkIDFinder; -import com.ictye.the_origin_of_magic.utils.PlayerEntityMixinInterfaces; +import com.ictye.the_origin_of_magic.utils.InterFaces.PlayerEntityMixinInterfaces; import com.mojang.authlib.GameProfile; import net.fabricmc.fabric.api.networking.v1.PacketByteBufs; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; @@ -19,21 +19,20 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ServerPlayerEntity.class) -public abstract class SeriverEntityMixin extends PlayerEntity { - public SeriverEntityMixin(World world, BlockPos pos, float yaw, GameProfile gameProfile, @Nullable PlayerPublicKey publicKey) { +public abstract class ServerEntityMixin extends PlayerEntity { + public ServerEntityMixin(World world, BlockPos pos, float yaw, GameProfile gameProfile, @Nullable PlayerPublicKey publicKey) { super(world, pos, yaw, gameProfile, publicKey); } + @SuppressWarnings("MissingUnique") private final MagicAbilitiesManager magicAbilitiesManager = ((PlayerEntityMixinInterfaces)this).the_origin_of_magic$getMagicAbilitiesManager(); @Inject(method = "playerTick", at = @At(value = "HEAD")) public void playerTick(CallbackInfo ci) { - // ServerPlayerEntity + // 同步客戶端和服務端的魔力等級值 ServerPlayerEntity serverPlayerEntity = (ServerPlayerEntity) (Object) this; PacketByteBuf buffer = PacketByteBufs.create(); buffer.writeFloat(this.magicAbilitiesManager.getMagicLevel()); ServerPlayNetworking.send(serverPlayerEntity, NetworkIDFinder.SYNC_MAGIC_HUD_ID, buffer); - } - } diff --git a/src/main/java/com/ictye/the_origin_of_magic/infrastructure/GUI/MagicLevelHud.java b/src/main/java/com/ictye/the_origin_of_magic/infrastructure/GUI/MagicLevelHud.java index b73f439..2d98c59 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/infrastructure/GUI/MagicLevelHud.java +++ b/src/main/java/com/ictye/the_origin_of_magic/infrastructure/GUI/MagicLevelHud.java @@ -1,7 +1,7 @@ package com.ictye.the_origin_of_magic.infrastructure.GUI; import com.ictye.the_origin_of_magic.foundation.PlayerAbilities.MagicAbilitiesManager; -import com.ictye.the_origin_of_magic.utils.PlayerEntityMixinInterfaces; +import com.ictye.the_origin_of_magic.utils.InterFaces.PlayerEntityMixinInterfaces; import com.mojang.blaze3d.systems.RenderSystem; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; diff --git a/src/main/java/com/ictye/the_origin_of_magic/infrastructure/netWork/SyncHUDS2CPacket.java b/src/main/java/com/ictye/the_origin_of_magic/infrastructure/netWork/SyncHUDS2CPacket.java index c3d4263..bc503fb 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/infrastructure/netWork/SyncHUDS2CPacket.java +++ b/src/main/java/com/ictye/the_origin_of_magic/infrastructure/netWork/SyncHUDS2CPacket.java @@ -1,7 +1,7 @@ package com.ictye.the_origin_of_magic.infrastructure.netWork; import com.ictye.the_origin_of_magic.foundation.PlayerAbilities.MagicAbilitiesManager; -import com.ictye.the_origin_of_magic.utils.PlayerEntityMixinInterfaces; +import com.ictye.the_origin_of_magic.utils.InterFaces.PlayerEntityMixinInterfaces; import net.fabricmc.fabric.api.networking.v1.PacketSender; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayNetworkHandler; diff --git a/src/main/java/com/ictye/the_origin_of_magic/the_origin_of_magic_client.java b/src/main/java/com/ictye/the_origin_of_magic/the_origin_of_magic_client.java index 8edc1cc..e600fe4 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/the_origin_of_magic_client.java +++ b/src/main/java/com/ictye/the_origin_of_magic/the_origin_of_magic_client.java @@ -22,7 +22,7 @@ public class the_origin_of_magic_client implements ClientModInitializer { @Environment(EnvType.CLIENT) public void onInitializeClient() { HandledScreens.register(MAGIC_WORKSTATION_SCREEN_HANDLER_SCREEN_HANDLER_TYPE, MagicWorkbenchScreen::new); - AllEntity.regEntityRunder(); + AllEntity.regEntityRenderer(); NetWorkReg.registerS2CPackets(); } diff --git a/src/main/java/com/ictye/the_origin_of_magic/utils/ImplementedInventory.java b/src/main/java/com/ictye/the_origin_of_magic/utils/InterFaces/ImplementedInventory.java similarity index 98% rename from src/main/java/com/ictye/the_origin_of_magic/utils/ImplementedInventory.java rename to src/main/java/com/ictye/the_origin_of_magic/utils/InterFaces/ImplementedInventory.java index 6806883..7eb06ea 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/utils/ImplementedInventory.java +++ b/src/main/java/com/ictye/the_origin_of_magic/utils/InterFaces/ImplementedInventory.java @@ -1,4 +1,4 @@ -package com.ictye.the_origin_of_magic.utils; +package com.ictye.the_origin_of_magic.utils.InterFaces; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.Inventories; diff --git a/src/main/java/com/ictye/the_origin_of_magic/utils/PlayerEntityMixinInterfaces.java b/src/main/java/com/ictye/the_origin_of_magic/utils/InterFaces/PlayerEntityMixinInterfaces.java similarity index 79% rename from src/main/java/com/ictye/the_origin_of_magic/utils/PlayerEntityMixinInterfaces.java rename to src/main/java/com/ictye/the_origin_of_magic/utils/InterFaces/PlayerEntityMixinInterfaces.java index 8c7e998..838d87d 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/utils/PlayerEntityMixinInterfaces.java +++ b/src/main/java/com/ictye/the_origin_of_magic/utils/InterFaces/PlayerEntityMixinInterfaces.java @@ -1,4 +1,4 @@ -package com.ictye.the_origin_of_magic.utils; +package com.ictye.the_origin_of_magic.utils.InterFaces; import com.ictye.the_origin_of_magic.foundation.PlayerAbilities.MagicAbilitiesManager; diff --git a/src/main/java/com/ictye/the_origin_of_magic/utils/Vec3d_Util.java b/src/main/java/com/ictye/the_origin_of_magic/utils/Vec3d_Util.java index da343d5..28c713c 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/utils/Vec3d_Util.java +++ b/src/main/java/com/ictye/the_origin_of_magic/utils/Vec3d_Util.java @@ -3,8 +3,18 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.util.math.Vec3d; +/** + * Vec3d 工具類 + */ +@SuppressWarnings("unused") public class Vec3d_Util { - public static Vec3d getLookVec(LivingEntity player, double length) { + /** + * 獲取玩家事先的單位向量 + * @param player 玩家 + * @param length 長度 + * @return 玩家的朝向 + */ + public static Vec3d getPlayerLookVec(LivingEntity player, double length) { float pitch = (float) Math.toRadians(player.getPitch()); float yaw = (float) Math.toRadians(player.getYaw()); @@ -17,6 +27,13 @@ public static Vec3d getLookVec(LivingEntity player, double length) { return vec.normalize().multiply(length); } + /** + * 軸向旋轉向量 + * @param vec 原始向量 + * @param angle 角度 + * @param axis 旋轉軸 + * @return 旋轉後的向量 + */ public static Vec3d RodriguesRotation(Vec3d vec, double angle, Vec3d axis){ double x = vec.x; diff --git a/src/main/resources/assets/the_origin_of_magic/textures/item/test_magic.png b/src/main/resources/assets/the_origin_of_magic/textures/item/explosion_magic.png similarity index 100% rename from src/main/resources/assets/the_origin_of_magic/textures/item/test_magic.png rename to src/main/resources/assets/the_origin_of_magic/textures/item/explosion_magic.png diff --git a/src/main/resources/assets/the_origin_of_magic/textures/item/hoglin_entity_limiter.png b/src/main/resources/assets/the_origin_of_magic/textures/item/hostile_entity_limiter.png similarity index 100% rename from src/main/resources/assets/the_origin_of_magic/textures/item/hoglin_entity_limiter.png rename to src/main/resources/assets/the_origin_of_magic/textures/item/hostile_entity_limiter.png diff --git a/src/main/resources/the_origin_of_magic.mixins.json b/src/main/resources/the_origin_of_magic.mixins.json index 0f9dddd..9557e7a 100644 --- a/src/main/resources/the_origin_of_magic.mixins.json +++ b/src/main/resources/the_origin_of_magic.mixins.json @@ -5,7 +5,7 @@ "compatibilityLevel": "JAVA_17", "mixins": [ "PlayerEntity.PlayerEntityMixin", - "PlayerEntity.SeriverEntityMixin" + "PlayerEntity.ServerEntityMixin" ], "client": [ "HUD.PlayerHudMixin",