diff --git a/src/main/generated/.cache/89b86ab0e66f527166d98df92ddbcf5416ed58f6 b/src/main/generated/.cache/89b86ab0e66f527166d98df92ddbcf5416ed58f6 index 5e466c8..604a091 100644 --- a/src/main/generated/.cache/89b86ab0e66f527166d98df92ddbcf5416ed58f6 +++ b/src/main/generated/.cache/89b86ab0e66f527166d98df92ddbcf5416ed58f6 @@ -1,2 +1,2 @@ -// 1.19.2 2024-04-22T21:56:57.611898 Language -6470396c45f41baaa6f0da503628087520ede6ce assets\the_origin_of_magic\lang\en_us.json +// 1.19.2 2024-04-23T16:27:26.7336147 Language +d04d40d92f525332cba17675dca053783f282d5b assets\the_origin_of_magic\lang\en_us.json diff --git a/src/main/generated/.cache/dc1d6e7286e7569a79007c10f809d49635ea1c49 b/src/main/generated/.cache/dc1d6e7286e7569a79007c10f809d49635ea1c49 index 5026e9e..f20439c 100644 --- a/src/main/generated/.cache/dc1d6e7286e7569a79007c10f809d49635ea1c49 +++ b/src/main/generated/.cache/dc1d6e7286e7569a79007c10f809d49635ea1c49 @@ -1,2 +1,2 @@ -// 1.19.2 2024-04-22T21:56:57.615127 Block Loot Tables +// 1.19.2 2024-04-23T16:27:26.736128 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 bcee452..a96fb9f 100644 --- a/src/main/generated/.cache/f3798f81c7b6fecad2cbfec741314f8a66c0eca3 +++ b/src/main/generated/.cache/f3798f81c7b6fecad2cbfec741314f8a66c0eca3 @@ -1,11 +1,15 @@ -// 1.19.2 2024-04-22T21:56:57.6182753 Models +// 1.19.2 2024-04-23T16:27:26.7391245 Models +181423bcaae52ae5cf7cee43b878159bada3a241 assets\the_origin_of_magic\models\item\instant_damage_magic.json 02d3ff4716d16f7c5a4dd4432d1b98f744a13f02 assets\the_origin_of_magic\models\item\blood_essence.json +105ea751d9d55fefa41f158e8e462c2e69f451ed assets\the_origin_of_magic\models\item\magic_life_time_up.json 781092579f171cf0db8317aa6267ad8e5cfbbd1f assets\the_origin_of_magic\models\item\fire_magic_element.json f54d22f024ca8dbc5f81e759c90de28d15c18b17 assets\the_origin_of_magic\models\item\kind_magic_element.json 52dda52229d5e92e940848b91862d354edf37ef0 assets\the_origin_of_magic\models\item\nature_magic_element.json 76b58d78d6d9e28c4af4f02ff147ddab4ff36cba assets\the_origin_of_magic\models\item\empty_magic_element.json +447283703163864ca6d75c2a189161ab17a04dd6 assets\the_origin_of_magic\models\item\magic_bullet.json 50c992db06feb825ceb8fe3bd063a7d5fcc83264 assets\the_origin_of_magic\models\item\explosion_magic.json ddf4e605ac73f757f76bbfe39d60312b7042e7d9 assets\the_origin_of_magic\models\item\hostile_entity_limiter.json +43e2c3caac7463f02d4048ca73f166772b1e1cb3 assets\the_origin_of_magic\models\item\magic_life_time_down.json 14f7b54096acc0b1b7b588d72bd80df62d566018 assets\the_origin_of_magic\models\item\earth_magic_element.json da16015585e364c4561b91a3b83056d8c3646d1c assets\the_origin_of_magic\models\item\gold_magic_element.json 681374800d5b4991c2e8d6304781b89089bd379c assets\the_origin_of_magic\models\item\poison_magic.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 2c6ce1c..2e2074b 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 @@ -9,8 +9,12 @@ "item.the_origin_of_magic.fire_magic_element": "Fire Magic Element", "item.the_origin_of_magic.gold_magic_element": "Gold Magic Element", "item.the_origin_of_magic.hostile_entity_limiter": "Hostile Entity Limiter", + "item.the_origin_of_magic.instant_damage_magic": "Instant Damage Magic", "item.the_origin_of_magic.kind_magic_element": "Kind Magic Element", + "item.the_origin_of_magic.magic_bullet": "Magic Bullet", "item.the_origin_of_magic.magic_core": "Magic Core", + "item.the_origin_of_magic.magic_life_time_down": "Magic Life Time Down", + "item.the_origin_of_magic.magic_life_time_up": "Magic Life Time Up", "item.the_origin_of_magic.nature_magic_element": "Nature Magic Element", "item.the_origin_of_magic.poison_magic": "Poison Magic", "item.the_origin_of_magic.test_staff": "Test Staff", diff --git a/src/main/generated/assets/the_origin_of_magic/models/item/instant_damage_magic.json b/src/main/generated/assets/the_origin_of_magic/models/item/instant_damage_magic.json new file mode 100644 index 0000000..969ed83 --- /dev/null +++ b/src/main/generated/assets/the_origin_of_magic/models/item/instant_damage_magic.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "the_origin_of_magic:item/instant_damage_magic" + } +} \ No newline at end of file diff --git a/src/main/generated/assets/the_origin_of_magic/models/item/magic_bullet.json b/src/main/generated/assets/the_origin_of_magic/models/item/magic_bullet.json new file mode 100644 index 0000000..7005463 --- /dev/null +++ b/src/main/generated/assets/the_origin_of_magic/models/item/magic_bullet.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "the_origin_of_magic:item/magic_bullet" + } +} \ No newline at end of file diff --git a/src/main/generated/assets/the_origin_of_magic/models/item/magic_life_time_down.json b/src/main/generated/assets/the_origin_of_magic/models/item/magic_life_time_down.json new file mode 100644 index 0000000..097daf7 --- /dev/null +++ b/src/main/generated/assets/the_origin_of_magic/models/item/magic_life_time_down.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "the_origin_of_magic:item/magic_life_time_down" + } +} \ No newline at end of file diff --git a/src/main/generated/assets/the_origin_of_magic/models/item/magic_life_time_up.json b/src/main/generated/assets/the_origin_of_magic/models/item/magic_life_time_up.json new file mode 100644 index 0000000..ab87a29 --- /dev/null +++ b/src/main/generated/assets/the_origin_of_magic/models/item/magic_life_time_up.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "the_origin_of_magic:item/magic_life_time_up" + } +} \ No newline at end of file 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 be66e50..0e88f7e 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,8 +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.foundation.Entitys.Magics.*; +import com.ictye.the_origin_of_magic.infrastructure.Renders.MagicsRender.MagicRender; import com.ictye.the_origin_of_magic.the_origin_of_magic; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @@ -39,6 +38,24 @@ public class AllEntity { "poison_magic" ); + public static final EntityType INSTANT_DAMAGE_ENTITY_TYPE = the_origin_of_magic.MOD_REGISTRATE.entityBuilder( + FabricEntityTypeBuilder + .create(SpawnGroup.MISC, InstantDamageItemMagic::new) + .dimensions(EntityDimensions.fixed(0.25F, 0.25F)) + .trackRangeBlocks(4).trackedUpdateRate(10) + .build(), + "instant_damage_magic" + ); + + public static final EntityType MAGIC_BULLET_ENTITY_TYPE = the_origin_of_magic.MOD_REGISTRATE.entityBuilder( + FabricEntityTypeBuilder + .create(SpawnGroup.MISC, MagicBullet::new) + .dimensions(EntityDimensions.fixed(0.25F, 0.25F)) + .trackRangeBlocks(4).trackedUpdateRate(10) + .build(), + "magic_bullet" + ); + /** * 注冊魔法實體渲染器 @@ -48,5 +65,7 @@ public static void regEntityRenderer(){ // 注冊實體渲染器 EntityRendererRegistry.register(EXPOLOSION_MAGIC_ENTITY_TYPE, FlyingItemEntityRenderer::new); EntityRendererRegistry.register(POISON_MAGIC_ENTITY_TYPE, FlyingItemEntityRenderer::new); + EntityRendererRegistry.register(INSTANT_DAMAGE_ENTITY_TYPE, FlyingItemEntityRenderer::new); + EntityRendererRegistry.register(MAGIC_BULLET_ENTITY_TYPE, MagicRender::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 3415ce0..c17c935 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,11 @@ package com.ictye.the_origin_of_magic.Contents; +import com.ictye.the_origin_of_magic.foundation.Items.Magic.CorrectionMagic.MagicLIfeTimeDownItem; +import com.ictye.the_origin_of_magic.foundation.Items.Magic.CorrectionMagic.MagicLifeTimeUpItem; import com.ictye.the_origin_of_magic.foundation.Items.Magic.ExplosionMagicEntityItem; +import com.ictye.the_origin_of_magic.foundation.Items.Magic.InstantDamageMagicItem; import com.ictye.the_origin_of_magic.foundation.Items.Magic.LimiterItem.UndeadEntityLimiterItem; +import com.ictye.the_origin_of_magic.foundation.Items.Magic.MagicBulletItem; 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; @@ -9,7 +13,6 @@ import com.ictye.the_origin_of_magic.the_origin_of_magic; import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder; import net.fabricmc.fabric.api.item.v1.FabricItemSettings; -import net.minecraft.data.client.Model; import net.minecraft.data.client.Models; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; @@ -18,9 +21,6 @@ import net.minecraft.util.Rarity; import net.minecraft.util.registry.Registry; -import java.util.HashMap; -import java.util.Map; - /** * 所有物品和物品組都應該寫在這個類裏方便管理和調用 */ @@ -94,6 +94,60 @@ public class AllItem { .rarity(Rarity.COMMON), null ); + + public static final Item INSTANT_DAMAGE_MAGIC_ITEM = the_origin_of_magic.MOD_REGISTRATE.itemBuilder( + InstantDamageMagicItem::new, + "instant_damage_magic", + "Instant Damage Magic", + Models.GENERATED, + new FabricItemSettings() + .maxCount(1) + .group(TheOriginOfMagicItemGroup) + .maxDamage(100) + .rarity(Rarity.COMMON), + AllEntity.INSTANT_DAMAGE_ENTITY_TYPE + ); + + public static final Item MAGIC_BULLET_ITEM = the_origin_of_magic.MOD_REGISTRATE.itemBuilder( + MagicBulletItem::new, + "magic_bullet", + "Magic Bullet", + Models.GENERATED, + new FabricItemSettings() + .maxCount(1) + .group(TheOriginOfMagicItemGroup) + .maxDamage(100) + .rarity(Rarity.COMMON), + AllEntity.MAGIC_BULLET_ENTITY_TYPE + ); + + public static final Item MAGIC_LIFE_TIME_UP = the_origin_of_magic.MOD_REGISTRATE.itemBuilder( + MagicLifeTimeUpItem::new, + "magic_life_time_up", + "Magic Life Time Up", + Models.GENERATED, + new FabricItemSettings() + .maxCount(1) + .group(TheOriginOfMagicItemGroup) + .maxDamage(100) + .rarity(Rarity.COMMON), + null + ); + + public static final Item MAGIC_LIFE_TIME_DOWN = the_origin_of_magic.MOD_REGISTRATE.itemBuilder( + MagicLIfeTimeDownItem::new, + "magic_life_time_down", + "Magic Life Time Down", + Models.GENERATED, + new FabricItemSettings() + .maxCount(1) + .group(TheOriginOfMagicItemGroup) + .maxDamage(100) + .rarity(Rarity.COMMON), + null + ); + + //////////////////////////////////////////////// //所有材料 /** @@ -219,27 +273,7 @@ public class AllItem { new FabricItemSettings() .group(TheOriginOfMagicItemGroup) .rarity(Rarity.COMMON)); - - ////////////////////////////////////////////// - // 注冊列表 - /** - * 物品ID列表 - */ - public static Map ItemMap = new HashMap<>(); - - /** - * 物品英文翻譯列表 - */ - public static Map ItemTransMap = new HashMap<>(); - - /** - * 物品模型列表 - */ - public static Map< Item,Model> ItemModelMap = new HashMap<>(); /////////////////////////////////////// - - - /** * 注冊物品 * @param name 名稱 diff --git a/src/main/java/com/ictye/the_origin_of_magic/Contents/AllParticle.java b/src/main/java/com/ictye/the_origin_of_magic/Contents/AllParticle.java new file mode 100644 index 0000000..3244c51 --- /dev/null +++ b/src/main/java/com/ictye/the_origin_of_magic/Contents/AllParticle.java @@ -0,0 +1,11 @@ +package com.ictye.the_origin_of_magic.Contents; + +import com.ictye.the_origin_of_magic.the_origin_of_magic; +import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes; +import net.minecraft.particle.DefaultParticleType; + +public class AllParticle { + public static final DefaultParticleType MAGIC_BULLET_PARTICLE = (DefaultParticleType) the_origin_of_magic.MOD_REGISTRATE.particleBuilder( + "magic_bullet_particle", + FabricParticleTypes.simple()); +} diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/CorrectionMagic/MagicLifeTimeDown.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/CorrectionMagic/MagicLifeTimeDown.java new file mode 100644 index 0000000..40d714e --- /dev/null +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/CorrectionMagic/MagicLifeTimeDown.java @@ -0,0 +1,6 @@ +package com.ictye.the_origin_of_magic.foundation.Entitys.Magics.CorrectionMagic; + +import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.StdMagicInterface; + +public class MagicLifeTimeDown implements StdMagicInterface { +} diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/CorrectionMagic/MagicLifeTimeUp.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/CorrectionMagic/MagicLifeTimeUp.java new file mode 100644 index 0000000..c9c6b43 --- /dev/null +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/CorrectionMagic/MagicLifeTimeUp.java @@ -0,0 +1,6 @@ +package com.ictye.the_origin_of_magic.foundation.Entitys.Magics.CorrectionMagic; + +import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.StdMagicInterface; + +public class MagicLifeTimeUp implements StdMagicInterface { +} 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 c995e19..78f9b95 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 @@ -7,7 +7,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.particle.ParticleTypes; import net.minecraft.util.hit.HitResult; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import net.minecraft.world.explosion.Explosion; @@ -51,11 +50,18 @@ protected void collision(HitResult hitResult) { if (this.world.isClient){ return; } - BlockPos pos = new BlockPos(hitResult.getPos()); - this.world.createExplosion(this, pos.getX(), pos.getY(), pos.getZ(), 3.0F * explosionRate, Explosion.DestructionType.BREAK); this.remove(RemovalReason.CHANGED_DIMENSION); } + @Override + public void remove(RemovalReason reason) { + Vec3d pos = this.getPos(); + if(reason != RemovalReason.KILLED){ + this.world.createExplosion(this, pos.getX(), pos.getY(), pos.getZ(), 3.0F * explosionRate, Explosion.DestructionType.BREAK); + } + super.remove(reason); + } + @Override public ItemStack getStack() { return new ItemStack(AllItem.EXPLOSION_MAGIC,1); diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/InstantDamageItemMagic.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/InstantDamageItemMagic.java new file mode 100644 index 0000000..70961d9 --- /dev/null +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/InstantDamageItemMagic.java @@ -0,0 +1,46 @@ +package com.ictye.the_origin_of_magic.foundation.Entitys.Magics; + +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.item.Items; +import net.minecraft.particle.ParticleTypes; +import net.minecraft.util.hit.EntityHitResult; +import net.minecraft.world.World; + +public class InstantDamageItemMagic extends StdThrownMagic{ + public InstantDamageItemMagic(EntityType entityType, World world) { + super(entityType, world); + } + + public InstantDamageItemMagic(EntityType type, LivingEntity owner, World world) { + super(type, owner, world); + } + + @Override + protected float getGravity() { + return 0; + } + + @Override + protected void onEntityHit(EntityHitResult entityHitResult) { + StatusEffectInstance poison = new StatusEffectInstance(StatusEffects.INSTANT_DAMAGE, 10); + ((LivingEntity)entityHitResult.getEntity()).addStatusEffect(poison); + super.onEntityHit(entityHitResult); + this.remove(RemovalReason.CHANGED_DIMENSION); + } + + @Override + public void tick() { + this.world.addParticle(ParticleTypes.DAMAGE_INDICATOR, this.getX(), this.getY(), this.getZ(), 0.0D, 0.0D, 0.0D); + super.tick(); + } + + @Override + public ItemStack getStack() { + return new ItemStack(Items.AIR); + } +} diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/MagicBullet.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/MagicBullet.java new file mode 100644 index 0000000..79b923a --- /dev/null +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/MagicBullet.java @@ -0,0 +1,57 @@ +package com.ictye.the_origin_of_magic.foundation.Entitys.Magics; + +import com.ictye.the_origin_of_magic.Contents.AllParticle; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.damage.DamageSource; +import net.minecraft.entity.projectile.thrown.ThrownEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.util.hit.EntityHitResult; +import net.minecraft.world.World; + +public class MagicBullet extends StdThrownMagic{ + public MagicBullet(EntityType entityType, World world) { + super(entityType, world); + } + + protected MagicBullet(EntityType type, double x, double y, double z, World world) { + super(type, x, y, z, world); + } + + public MagicBullet(EntityType type, LivingEntity owner, World world) { + super(type, owner, world); + } + + @Override + public float getMagicRate() { + return 2; + } + + @Override + public int getLit() { + return super.getLit(); + } + + @Override + protected float getGravity() { + return 0; + } + + @Override + public void tick() { + super.tick(); + world.addParticle(AllParticle.MAGIC_BULLET_PARTICLE, getX(), getY(), getZ(), 0, 0, 0); + } + + @Override + protected void onEntityHit(EntityHitResult entityHitResult) { + entityHitResult.getEntity().damage(DamageSource.thrownProjectile(this, this.getOwner()), 4); + super.onEntityHit(entityHitResult); + } + + @Override + public ItemStack getStack() { + return new ItemStack(Items.AIR); + } +} 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 2991ef0..7a038a5 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 @@ -32,7 +32,7 @@ public abstract class StdThrownMagic extends ThrownEntity implements FlyingItemE */ private List additionMagicList; - private List effectMagicList = new ArrayList<>(); + private final List effectMagicList = new ArrayList<>(); /** * 添加法術效果 @@ -71,6 +71,16 @@ public float getExplosionRate() { private int reflectCount = 5; + private int lit = 15; + + private int age = 0; + + private int ageRate = 1; + + public int getLit() { + return lit; + } + public void setReflect(int count) { isReflect = true; reflectCount = count; @@ -86,6 +96,18 @@ public float getMagicRate() { return magicRate; } + public int getAge(){ + return 200; + } + + public void setAge(int age) { + this.age = age; + } + + public void setAgeRate(int ageRate) { + this.ageRate = ageRate; + } + /** * 獲取附加魔法計數 * */ @@ -101,20 +123,21 @@ public void setAdditionTrigger(List magics){ this.additionMagicList = magics; } - protected StdThrownMagic(EntityType entityType, World world) { + public StdThrownMagic(EntityType entityType, World world) { super(entityType, world); } - protected StdThrownMagic(EntityType type, double x, double y, double z, World world) { + public StdThrownMagic(EntityType type, double x, double y, double z, World world) { super(type, x, y, z, world); } - protected StdThrownMagic(EntityType type, LivingEntity owner, World world) { + public StdThrownMagic(EntityType type, LivingEntity owner, World world) { super(type, owner, world); } - public StdThrownMagic(EntityType type, LivingEntity owner, World world, float explosionRate) { + public StdThrownMagic(EntityType type, LivingEntity owner, World world, float explosionRate , int ageRate) { this(type, owner, world); + this.ageRate = ageRate; this.explosionRate = explosionRate; } @@ -158,8 +181,7 @@ protected void onCollision(HitResult hitResult) { } // 施放附加魔法 - //noinspection ConstantValue - if(additionalTrigger > 0){ + if(getAdditionalTrigger() > 0){ for (StdThrownMagic additionMagic : additionMagicList) { Entity owner = this.getOwner(); if(owner instanceof PlayerEntityMixinInterfaces player){ @@ -196,6 +218,10 @@ void collision(HitResult hitResult){} @Override public void tick() { super.tick(); + age++; + if (age>=getAge() * this.ageRate){ + this.remove(RemovalReason.CHANGED_DIMENSION); + } for(StdEffectMagic effectMagic : effectMagicList){ effectMagic.tick(this.world); } diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/CorrectionMagic/MagicLIfeTimeDownItem.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/CorrectionMagic/MagicLIfeTimeDownItem.java new file mode 100644 index 0000000..afb78c0 --- /dev/null +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/CorrectionMagic/MagicLIfeTimeDownItem.java @@ -0,0 +1,20 @@ +package com.ictye.the_origin_of_magic.foundation.Items.Magic.CorrectionMagic; + +import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.CorrectionMagic.MagicLifeTimeDown; +import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.StdMagicInterface; +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 class MagicLIfeTimeDownItem extends StdMagicItem { + public MagicLIfeTimeDownItem(Settings settings, EntityType entityType) { + super(settings, entityType); + } + + @Override + public StdMagicInterface getMagic(PlayerEntity user, World world, float excisionRate, int hartRate) { + return new MagicLifeTimeDown(); + } +} diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/CorrectionMagic/MagicLifeTimeUpItem.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/CorrectionMagic/MagicLifeTimeUpItem.java new file mode 100644 index 0000000..77be7b7 --- /dev/null +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/CorrectionMagic/MagicLifeTimeUpItem.java @@ -0,0 +1,20 @@ +package com.ictye.the_origin_of_magic.foundation.Items.Magic.CorrectionMagic; + +import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.CorrectionMagic.MagicLifeTimeUp; +import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.StdMagicInterface; +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 class MagicLifeTimeUpItem extends StdMagicItem { + public MagicLifeTimeUpItem(Settings settings, EntityType entityType) { + super(settings, entityType); + } + + @Override + public StdMagicInterface getMagic(PlayerEntity user, World world, float excisionRate, int hartRate) { + return new MagicLifeTimeUp(); + } +} diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/InstantDamageMagicItem.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/InstantDamageMagicItem.java new file mode 100644 index 0000000..be25705 --- /dev/null +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/InstantDamageMagicItem.java @@ -0,0 +1,20 @@ +package com.ictye.the_origin_of_magic.foundation.Items.Magic; + +import com.ictye.the_origin_of_magic.Contents.AllEntity; +import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.InstantDamageItemMagic; +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; + +public class InstantDamageMagicItem extends StdMagicItem { + public InstantDamageMagicItem(Settings settings, EntityType entityType) { + super(settings, entityType); + } + + @Override + public StdMagicInterface getMagic(PlayerEntity user, World world, float excisionRate, int hartRate) { + return new InstantDamageItemMagic(AllEntity.INSTANT_DAMAGE_ENTITY_TYPE,user, world); + } +} diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/MagicBulletItem.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/MagicBulletItem.java new file mode 100644 index 0000000..c43d2e7 --- /dev/null +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/MagicBulletItem.java @@ -0,0 +1,20 @@ +package com.ictye.the_origin_of_magic.foundation.Items.Magic; + +import com.ictye.the_origin_of_magic.Contents.AllEntity; +import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.MagicBullet; +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; + +public class MagicBulletItem extends StdMagicItem{ + public MagicBulletItem(Settings settings, EntityType entityType) { + super(settings, entityType); + } + + @Override + public StdMagicInterface getMagic(PlayerEntity user, World world, float excisionRate, int hartRate) { + return new MagicBullet(AllEntity.MAGIC_BULLET_ENTITY_TYPE, user, world); + } +} 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 b3b3ab2..d0c18d9 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,5 +1,7 @@ package com.ictye.the_origin_of_magic.foundation.Items.Staff; +import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.CorrectionMagic.MagicLifeTimeDown; +import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.CorrectionMagic.MagicLifeTimeUp; 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; @@ -124,6 +126,8 @@ public abstract class StdStaff extends Item { */ int enchantability; + int staffAgeRate; + public StdStaff(Settings settings) { super(settings); // 初始化各個參數 @@ -142,6 +146,7 @@ public StdStaff(Settings settings) { this.coolingTime = 5; this.coolingTimeRate = 1; this.enchantability = 3; + this.staffAgeRate = 1; this.inventory = new MagicInventory(this.size); } @@ -281,6 +286,7 @@ public TypedActionResult use(World world, PlayerEntity user, Hand han MagicEntity.setVelocity(user, user.getPitch(), user.getYaw(), 0.0F, finalSpeed, finalScattering); // 設置參數 MagicAbilitiesManager magicAbilitiesManager = ((PlayerEntityMixinInterfaces)user).the_origin_of_magic$getMagicAbilitiesManager(); + MagicEntity.setAgeRate(this.staffAgeRate); if (magicAbilitiesManager.cast(user, MagicEntity, world)) { // 生成法術實體并且破壞物品 @@ -304,6 +310,8 @@ private List summonMagic(MagicInventory inventory, PlayerEntity List magicItemList = new ArrayList<>(); List limiterList = new ArrayList<>(); List effectList = new ArrayList<>(); + boolean isLifeUp = false; + boolean isLifeDown = false; for(int i = inventory.size() + 1; i > 0 && count > 0 ;i --){ Item magicItem = inventory.next().getItem(); // 魔法物品 @@ -325,6 +333,12 @@ private List summonMagic(MagicInventory inventory, PlayerEntity count--; } else if (((StdMagicItem) magicItem).getMagic(user, world, exolisionRate, hartRate) instanceof StdEffectMagic effect) { effectList.add(effect); + } else if (((StdMagicItem) magicItem).getMagic(user, world, exolisionRate, hartRate) instanceof MagicLifeTimeUp){ + isLifeUp = true; + isLifeDown = false; + } else if (((StdMagicItem) magicItem).getMagic(user, world, exolisionRate, hartRate) instanceof MagicLifeTimeDown){ + isLifeUp = false; + isLifeDown = true; } } @@ -340,6 +354,19 @@ private List summonMagic(MagicInventory inventory, PlayerEntity magic.addEffect(effect); } } + + if(isLifeUp){ + for(StdThrownMagic magic :magicItemList){ + magic.setAge(magic.getAge() + 75); + } + } + + if(isLifeDown){ + for(StdThrownMagic magic :magicItemList){ + magic.setAge(magic.getAge() - 75); + } + } + return magicItemList; } diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Staff/TestStaff.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Staff/TestStaff.java index 52da8d8..7459d72 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Staff/TestStaff.java +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Staff/TestStaff.java @@ -21,6 +21,7 @@ public void appendTooltip(ItemStack stack, @Nullable World world, List too public TestStaff(Settings settings) { super(settings); size = 9; + this.staffAgeRate = 5; this.inventory = new MagicInventory(this.size); } } diff --git a/src/main/java/com/ictye/the_origin_of_magic/infrastructure/ModRegistrate.java b/src/main/java/com/ictye/the_origin_of_magic/infrastructure/ModRegistrate.java index d61fde7..dea197d 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/infrastructure/ModRegistrate.java +++ b/src/main/java/com/ictye/the_origin_of_magic/infrastructure/ModRegistrate.java @@ -6,6 +6,7 @@ import net.minecraft.entity.EntityType; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; +import net.minecraft.particle.ParticleType; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; @@ -164,6 +165,11 @@ public EntityType entityBuilder(EntityType entityType,String id){ return entityType; } + public ParticleType particleBuilder(String id,ParticleType particleType){ + Registry.register(Registry.PARTICLE_TYPE, new Identifier(the_origin_of_magic.Mod_Id, id), particleType); + return particleType; + } + static class BlockType{ public static final int NORMAL_BLOCK = 1; diff --git a/src/main/java/com/ictye/the_origin_of_magic/infrastructure/Renders/MagicsRender/MagicRender.java b/src/main/java/com/ictye/the_origin_of_magic/infrastructure/Renders/MagicsRender/MagicRender.java new file mode 100644 index 0000000..8170f17 --- /dev/null +++ b/src/main/java/com/ictye/the_origin_of_magic/infrastructure/Renders/MagicsRender/MagicRender.java @@ -0,0 +1,22 @@ +package com.ictye.the_origin_of_magic.infrastructure.Renders.MagicsRender; + +import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.StdThrownMagic; +import net.minecraft.client.render.entity.EntityRendererFactory; +import net.minecraft.client.render.entity.FlyingItemEntityRenderer; +import net.minecraft.util.math.BlockPos; + +public class MagicRender extends FlyingItemEntityRenderer { + + public MagicRender(EntityRendererFactory.Context ctx, float scale, boolean lit) { + super(ctx, scale, true); + } + + public MagicRender(EntityRendererFactory.Context context) { + super(context); + } + + @Override + protected int getBlockLight(StdThrownMagic entity, BlockPos pos) { + return 15; + } +} diff --git a/src/main/java/com/ictye/the_origin_of_magic/infrastructure/Renders/MagicsRender/TestMagicRender.java b/src/main/java/com/ictye/the_origin_of_magic/infrastructure/Renders/MagicsRender/TestMagicRender.java deleted file mode 100644 index a04f8c5..0000000 --- a/src/main/java/com/ictye/the_origin_of_magic/infrastructure/Renders/MagicsRender/TestMagicRender.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.ictye.the_origin_of_magic.infrastructure.Renders.MagicsRender; - -import net.minecraft.client.render.entity.EntityRenderer; -import net.minecraft.client.render.entity.EntityRendererFactory; -import net.minecraft.entity.Entity; -import net.minecraft.util.Identifier; - -public class TestMagicRender extends EntityRenderer { - protected TestMagicRender(EntityRendererFactory.Context ctx) { - super(ctx); - } - - @Override - protected boolean hasLabel(Entity entity) { - return false; - } - - @Override - public Identifier getTexture(Entity entity) { - return null; - } -} diff --git a/src/main/java/com/ictye/the_origin_of_magic/the_origin_of_magic.java b/src/main/java/com/ictye/the_origin_of_magic/the_origin_of_magic.java index 70934a1..767e53c 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/the_origin_of_magic.java +++ b/src/main/java/com/ictye/the_origin_of_magic/the_origin_of_magic.java @@ -19,7 +19,6 @@ public class the_origin_of_magic implements ModInitializer { public void onInitialize() { AllItem.registerItems(); AllBlockEntity.register(); - // AllEntity.regEntity(); NetWorkReg.registerC2SPackets(); } 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 812db14..731e655 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 @@ -1,14 +1,19 @@ package com.ictye.the_origin_of_magic; import com.ictye.the_origin_of_magic.Contents.AllEntity; +import com.ictye.the_origin_of_magic.Contents.AllParticle; import com.ictye.the_origin_of_magic.infrastructure.GUI.MagicWorkbench.MagicWorkbenchScreen; import com.ictye.the_origin_of_magic.infrastructure.GUI.MagicWorkbench.MagicWorkbenchScreenHandler; import com.ictye.the_origin_of_magic.infrastructure.netWork.NetWorkReg; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry; +import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry; import net.minecraft.client.gui.screen.ingame.HandledScreens; +import net.minecraft.client.particle.FlameParticle; +import net.minecraft.screen.PlayerScreenHandler; import net.minecraft.screen.ScreenHandlerType; import net.minecraft.util.Identifier; @@ -24,5 +29,10 @@ public void onInitializeClient() { HandledScreens.register(MAGIC_WORKSTATION_SCREEN_HANDLER_SCREEN_HANDLER_TYPE, MagicWorkbenchScreen::new); AllEntity.regEntityRenderer(); NetWorkReg.registerS2CPackets(); + + ClientSpriteRegistryCallback.event(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE).register(((atlasTexture, registry) -> { + registry.register(new Identifier(the_origin_of_magic.Mod_Id,"particles/magic_bullet_particle")); + })); + ParticleFactoryRegistry.getInstance().register(AllParticle.MAGIC_BULLET_PARTICLE, FlameParticle.Factory::new); } } diff --git a/src/main/resources/assets/the_origin_of_magic/particles/magic_bullet_particle.json b/src/main/resources/assets/the_origin_of_magic/particles/magic_bullet_particle.json new file mode 100644 index 0000000..72b240c --- /dev/null +++ b/src/main/resources/assets/the_origin_of_magic/particles/magic_bullet_particle.json @@ -0,0 +1,5 @@ +{ + "textures": [ + "the_origin_of_magic:magic_bullet_particle" + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/the_origin_of_magic/textures/item/instant_damage_magic.png b/src/main/resources/assets/the_origin_of_magic/textures/item/instant_damage_magic.png new file mode 100644 index 0000000..1fa4f87 Binary files /dev/null and b/src/main/resources/assets/the_origin_of_magic/textures/item/instant_damage_magic.png differ diff --git a/src/main/resources/assets/the_origin_of_magic/textures/item/magic_bullet.png b/src/main/resources/assets/the_origin_of_magic/textures/item/magic_bullet.png new file mode 100644 index 0000000..9a8e50b Binary files /dev/null and b/src/main/resources/assets/the_origin_of_magic/textures/item/magic_bullet.png differ diff --git a/src/main/resources/assets/the_origin_of_magic/textures/item/magic_life_time_down.png b/src/main/resources/assets/the_origin_of_magic/textures/item/magic_life_time_down.png new file mode 100644 index 0000000..76352b5 Binary files /dev/null and b/src/main/resources/assets/the_origin_of_magic/textures/item/magic_life_time_down.png differ diff --git a/src/main/resources/assets/the_origin_of_magic/textures/item/magic_life_time_up.png b/src/main/resources/assets/the_origin_of_magic/textures/item/magic_life_time_up.png new file mode 100644 index 0000000..201a86b Binary files /dev/null and b/src/main/resources/assets/the_origin_of_magic/textures/item/magic_life_time_up.png differ diff --git a/src/main/resources/assets/the_origin_of_magic/textures/particle/magic_bullet_particle.png b/src/main/resources/assets/the_origin_of_magic/textures/particle/magic_bullet_particle.png new file mode 100644 index 0000000..548836e Binary files /dev/null and b/src/main/resources/assets/the_origin_of_magic/textures/particle/magic_bullet_particle.png differ