Skip to content

Commit

Permalink
feat: 添加新的法术物品和实体,调整法术效果和生命周期。
Browse files Browse the repository at this point in the history
  • Loading branch information
northgreen committed Apr 23, 2024
1 parent 4d2c704 commit a9bcaae
Show file tree
Hide file tree
Showing 34 changed files with 435 additions and 64 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/main/generated/assets/the_origin_of_magic/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "the_origin_of_magic:item/instant_damage_magic"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "the_origin_of_magic:item/magic_bullet"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "the_origin_of_magic:item/magic_life_time_down"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "the_origin_of_magic:item/magic_life_time_up"
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -39,6 +38,24 @@ public class AllEntity {
"poison_magic"
);

public static final EntityType<StdThrownMagic> INSTANT_DAMAGE_ENTITY_TYPE = the_origin_of_magic.MOD_REGISTRATE.entityBuilder(
FabricEntityTypeBuilder
.<StdThrownMagic>create(SpawnGroup.MISC, InstantDamageItemMagic::new)
.dimensions(EntityDimensions.fixed(0.25F, 0.25F))
.trackRangeBlocks(4).trackedUpdateRate(10)
.build(),
"instant_damage_magic"
);

public static final EntityType<StdThrownMagic> MAGIC_BULLET_ENTITY_TYPE = the_origin_of_magic.MOD_REGISTRATE.entityBuilder(
FabricEntityTypeBuilder
.<StdThrownMagic>create(SpawnGroup.MISC, MagicBullet::new)
.dimensions(EntityDimensions.fixed(0.25F, 0.25F))
.trackRangeBlocks(4).trackedUpdateRate(10)
.build(),
"magic_bullet"
);


/**
* 注冊魔法實體渲染器
Expand All @@ -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);
}
}
82 changes: 58 additions & 24 deletions src/main/java/com/ictye/the_origin_of_magic/Contents/AllItem.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
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;
import com.ictye.the_origin_of_magic.infrastructure.ModRegistrate;
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;
Expand All @@ -18,9 +21,6 @@
import net.minecraft.util.Rarity;
import net.minecraft.util.registry.Registry;

import java.util.HashMap;
import java.util.Map;

/**
* 所有物品和物品組都應該寫在這個類裏方便管理和調用
*/
Expand Down Expand Up @@ -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
);


////////////////////////////////////////////////
//所有材料
/**
Expand Down Expand Up @@ -219,27 +273,7 @@ public class AllItem {
new FabricItemSettings()
.group(TheOriginOfMagicItemGroup)
.rarity(Rarity.COMMON));

//////////////////////////////////////////////
// 注冊列表
/**
* 物品ID列表
*/
public static Map<String, Item> ItemMap = new HashMap<>();

/**
* 物品英文翻譯列表
*/
public static Map<String, Item> ItemTransMap = new HashMap<>();

/**
* 物品模型列表
*/
public static Map< Item,Model> ItemModelMap = new HashMap<>();
///////////////////////////////////////



/**
* 注冊物品
* @param name 名稱
Expand Down
Original file line number Diff line number Diff line change
@@ -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());
}
Original file line number Diff line number Diff line change
@@ -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 {
}
Original file line number Diff line number Diff line change
@@ -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 {
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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<? extends ThrownEntity> entityType, World world) {
super(entityType, world);
}

public InstantDamageItemMagic(EntityType<? extends StdThrownMagic> 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);
}
}
Original file line number Diff line number Diff line change
@@ -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<? extends ThrownEntity> entityType, World world) {
super(entityType, world);
}

protected MagicBullet(EntityType<? extends ThrownEntity> type, double x, double y, double z, World world) {
super(type, x, y, z, world);
}

public MagicBullet(EntityType<? extends ThrownEntity> 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);
}
}
Loading

0 comments on commit a9bcaae

Please sign in to comment.