Skip to content

Commit

Permalink
feat: 新增魔法泡泡~
Browse files Browse the repository at this point in the history
  • Loading branch information
northgreen committed May 3, 2024
1 parent 8ac0a96 commit 0ae4d64
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.19.2 2024-05-02T22:02:14.9304597 Language
60fc1c17293eabeb679d8e91fb8244d3101fa2ec assets\the_origin_of_magic\lang\en_us.json
// 1.19.2 2024-05-03T18:41:12.8419321 Language
535557102a8725b94cf9f1e64baafcab703c53a0 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-05-02T22:02:14.9420947 Block Loot Tables
// 1.19.2 2024-05-03T18:41:12.8434661 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,4 +1,4 @@
// 1.19.2 2024-05-02T22:02:14.9132477 Models
// 1.19.2 2024-05-03T18:41:12.8404319 Models
e61b535cd7ab658695681160ffbc526e0b8655f4 assets\the_origin_of_magic\models\item\magic_bullet_with_trigger.json
982fb2d3ae94989d61be6d49ebcac381af5d841b assets\the_origin_of_magic\models\item\magic_energy_throw_boll.json
6e0df2c99a9c005ddce1ec13cf27aff50ee1081f assets\the_origin_of_magic\models\item\magic_bullet_with_time_trigger.json
Expand All @@ -20,3 +20,4 @@ da16015585e364c4561b91a3b83056d8c3646d1c assets\the_origin_of_magic\models\item\
7091cce590f8bb481903e0177866dfcb338f42c0 assets\the_origin_of_magic\models\item\magic_core.json
03b1f5cc891077d36d38a8d98d2ffe49396f8229 assets\the_origin_of_magic\models\item\water_magic_element.json
ab49fab583c552ecda70edd5fe49219c058481cb assets\the_origin_of_magic\models\item\evil_magic_element.json
de7930ec0ad1be6774fe46bb3cfe34d74c47d14e assets\the_origin_of_magic\models\item\magic_bubble.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"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.kind_magic_element": "Kind Magic Element",
"item.the_origin_of_magic.magic_bubble": "Magic Bubble",
"item.the_origin_of_magic.magic_bullet": "Magic Bullet",
"item.the_origin_of_magic.magic_bullet_with_time_trigger": "Magic Bullet With Time Trigger",
"item.the_origin_of_magic.magic_bullet_with_trigger": "Magic Bullet With Trigger",
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/magic_bubble"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ public class AllEntity {
);


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


/**
* 注冊魔法實體渲染器
*/
Expand All @@ -98,5 +108,6 @@ public static void regEntityRenderer(){
EntityRendererRegistry.register(MAGIC_BULLET_WITH_TRIGGER_ENTITY_TYPE, MagicRender::new);
EntityRendererRegistry.register(MAGIC_BULLET_WITH_TIME_TRIGGER_ENTITY_TYPE, MagicRender::new);
EntityRendererRegistry.register(MAGIC_ENERGY_THROW_BOLL_ENTITY_TYPE, MagicRender::new);
EntityRendererRegistry.register(MAGIC_BUBBLE_ENTITY_TYPE, MagicRender::new);
}
}
12 changes: 12 additions & 0 deletions src/main/java/com/ictye/the_origin_of_magic/Contents/AllItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,18 @@ public class AllItem {
AllEntity.MAGIC_ENERGY_THROW_BOLL_ENTITY_TYPE
);

public static final Item MAGIC_BUBBLE_ITEM = the_origin_of_magic.MOD_REGISTRATE.itemBuilder(
MagicBubbleItem::new,
"magic_bubble",
"Magic Bubble",
Models.GENERATED,
new FabricItemSettings()
.maxCount(1)
.group(TheOriginOfMagicItemGroup)
.rarity(Rarity.COMMON),
AllEntity.MAGIC_BUBBLE_ENTITY_TYPE
);

/**
* 魔法时间增加
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
package com.ictye.the_origin_of_magic.Contents;

import com.ictye.the_origin_of_magic.the_origin_of_magic;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes;
import net.minecraft.client.particle.FlameParticle;
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());

public static final DefaultParticleType MAGIC_BUBBLE_PARTICLE = (DefaultParticleType) the_origin_of_magic.MOD_REGISTRATE.particleBuilder(
"magic_bubble_particle",
FabricParticleTypes.simple());

@Environment(value= EnvType.CLIENT)
public static void register() {
ParticleFactoryRegistry.getInstance().register(AllParticle.MAGIC_BUBBLE_PARTICLE, FlameParticle.Factory::new);
ParticleFactoryRegistry.getInstance().register(AllParticle.MAGIC_BULLET_PARTICLE, FlameParticle.Factory::new);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.ictye.the_origin_of_magic.foundation.Entitys.Magics.StdMagic;

import com.ictye.the_origin_of_magic.Contents.AllParticle;
import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.MagicInterfaces.StdMagic.StdThrownMagic;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.hit.EntityHitResult;
import net.minecraft.world.World;

public class MagicBubble extends StdThrownMagic {
public MagicBubble(EntityType<? extends StdThrownMagic> entityType, World world) {
super(entityType, world);
}

public MagicBubble(EntityType<? extends StdThrownMagic> type, double x, double y, double z, World world) {
super(type, x, y, z, world);
}

public MagicBubble(EntityType<? extends StdThrownMagic> type, LivingEntity owner, World world) {
super(type, owner, world);
}

@Override
public void tick() {
world.addParticle(AllParticle.MAGIC_BUBBLE_PARTICLE, this.getX(), this.getY(), this.getZ(), 0, 0, 0);
super.tick();
}

@Override
protected float getGravity() {
return 0.005f;
}

@Override
public float getMagicRate() {
return 3;
}

@Override
protected void onEntityHit(EntityHitResult entityHitResult) {
if(prdRandom!=null){
prdRandom.setSP((float) (prdRandom.getP() + 0.5));
if(prdRandom.getBool()){
entityHitResult.getEntity().damage(DamageSource.thrownProjectile(this, this.getOwner()), 7);
}else {
entityHitResult.getEntity().damage(DamageSource.thrownProjectile(this, this.getOwner()), 4);
}
}else {
entityHitResult.getEntity().damage(DamageSource.thrownProjectile(this, this.getOwner()), 4);
}
super.onEntityHit(entityHitResult);
}

@Override
public ItemStack getStack() {
return new ItemStack(Items.AIR);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.ictye.the_origin_of_magic.foundation.Items.Magic.StdMagic;

import com.ictye.the_origin_of_magic.Contents.AllEntity;
import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.MagicInterfaces.StdMagic.StdThrownMagic;
import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.MagicInterfaces.StdMagicInterface;
import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.StdMagic.MagicBubble;
import com.ictye.the_origin_of_magic.foundation.Items.Magic.Interface.StdMagicItem;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class MagicBubbleItem extends StdMagicItem {
public MagicBubbleItem(Settings settings, EntityType<StdThrownMagic> entityType) {
super(settings, entityType);
}

@Override
public StdMagicInterface getMagic(PlayerEntity user, World world, ItemStack stack) {
return new MagicBubble(AllEntity.MAGIC_BUBBLE_ENTITY_TYPE,user, world);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@
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.client.rendering.v1.ColorProviderRegistry;
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;

Expand All @@ -33,14 +29,10 @@ public void onInitializeClient() {

HandledScreens.register(MAGIC_WORKSTATION_SCREEN_HANDLER_SCREEN_HANDLER_TYPE, MagicWorkbenchScreen::new);

AllEntity.regEntityRenderer();
NetWorkReg.registerS2CPackets();

ColorProviderRegistry.ITEM.register(MagicRay::getColor, AllItem.RAY_MAGIC_ITEM);

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);
AllEntity.regEntityRenderer();
NetWorkReg.registerS2CPackets();
AllParticle.register();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"textures": [
"the_origin_of_magic:magic_bubble_particle"
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0ae4d64

Please sign in to comment.