diff --git a/src/main/java/io/github/reoseah/magisterium/Magisterium.java b/src/main/java/io/github/reoseah/magisterium/Magisterium.java index 5bd6095..b5347fd 100644 --- a/src/main/java/io/github/reoseah/magisterium/Magisterium.java +++ b/src/main/java/io/github/reoseah/magisterium/Magisterium.java @@ -1,9 +1,6 @@ package io.github.reoseah.magisterium; -import io.github.reoseah.magisterium.block.ArcaneTableBlock; -import io.github.reoseah.magisterium.block.GlyphBlock; -import io.github.reoseah.magisterium.block.IllusoryWallBlock; -import io.github.reoseah.magisterium.block.IllusoryWallBlockEntity; +import io.github.reoseah.magisterium.block.*; import io.github.reoseah.magisterium.item.BookmarkItem; import io.github.reoseah.magisterium.item.SpellBookItem; import io.github.reoseah.magisterium.item.SpellPageItem; @@ -11,6 +8,7 @@ import io.github.reoseah.magisterium.network.StartUtterancePayload; import io.github.reoseah.magisterium.network.StopUtterancePayload; import io.github.reoseah.magisterium.network.UseBookmarkPayload; +import io.github.reoseah.magisterium.particle.MagisteriumParticles; import io.github.reoseah.magisterium.recipe.*; import io.github.reoseah.magisterium.screen.ArcaneTableScreenHandler; import io.github.reoseah.magisterium.screen.SpellBookScreenHandler; @@ -60,6 +58,8 @@ public void onInitialize() { Registry.register(Registries.BLOCK, "magisterium:glyph", GlyphBlock.INSTANCE); Registry.register(Registries.BLOCK, "magisterium:illusory_wall", IllusoryWallBlock.INSTANCE); + Registry.register(Registries.BLOCK, "magisterium:test", TestBlock.INSTANCE); + Registry.register(Registries.BLOCK_ENTITY_TYPE, "magisterium:illusory_wall", IllusoryWallBlockEntity.TYPE); Registry.register(Registries.ITEM, "magisterium:arcane_table", new BlockItem(ArcaneTableBlock.INSTANCE, new Item.Settings())); @@ -113,6 +113,11 @@ public void onInitialize() { Registry.register(Registries.SCREEN_HANDLER, "magisterium:spell_book", SpellBookScreenHandler.TYPE); Registry.register(Registries.SCREEN_HANDLER, "magisterium:arcane_table", ArcaneTableScreenHandler.TYPE); + Registry.register(Registries.PARTICLE_TYPE, "magisterium:energy", MagisteriumParticles.ENERGY); + Registry.register(Registries.PARTICLE_TYPE, "magisterium:glyph_a", MagisteriumParticles.GLYPH_A); + Registry.register(Registries.PARTICLE_TYPE, "magisterium:glyph_b", MagisteriumParticles.GLYPH_B); + Registry.register(Registries.PARTICLE_TYPE, "magisterium:glyph_c", MagisteriumParticles.GLYPH_C); + MagisteriumGameRules.initialize(); MagisteriumCommands.initialize(); diff --git a/src/main/java/io/github/reoseah/magisterium/MagisteriumClient.java b/src/main/java/io/github/reoseah/magisterium/MagisteriumClient.java index a6aa766..90f3a32 100644 --- a/src/main/java/io/github/reoseah/magisterium/MagisteriumClient.java +++ b/src/main/java/io/github/reoseah/magisterium/MagisteriumClient.java @@ -5,6 +5,9 @@ import io.github.reoseah.magisterium.block.IllusoryWallBlockEntity; import io.github.reoseah.magisterium.block.IllusoryWallBlockEntityRenderer; import io.github.reoseah.magisterium.item.SpellBookItem; +import io.github.reoseah.magisterium.particle.EnergyParticle; +import io.github.reoseah.magisterium.particle.GlyphParticle; +import io.github.reoseah.magisterium.particle.MagisteriumParticles; import io.github.reoseah.magisterium.screen.ArcaneTableScreen; import io.github.reoseah.magisterium.screen.ArcaneTableScreenHandler; import io.github.reoseah.magisterium.screen.SpellBookScreen; @@ -13,12 +16,12 @@ import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; import net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin; +import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry; import net.fabricmc.fabric.impl.resource.loader.ResourceManagerHelperImpl; import net.minecraft.client.gui.screen.ingame.HandledScreens; import net.minecraft.client.item.ModelPredicateProviderRegistry; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.block.entity.BlockEntityRendererFactories; -import net.minecraft.client.util.ModelIdentifier; import net.minecraft.resource.ResourceType; import net.minecraft.util.Identifier; @@ -41,5 +44,10 @@ public void onInitializeClient() { HandledScreens.register(ArcaneTableScreenHandler.TYPE, ArcaneTableScreen::new); BlockEntityRendererFactories.register(IllusoryWallBlockEntity.TYPE, IllusoryWallBlockEntityRenderer::new); + + ParticleFactoryRegistry.getInstance().register(MagisteriumParticles.ENERGY, EnergyParticle.Factory::new); + ParticleFactoryRegistry.getInstance().register(MagisteriumParticles.GLYPH_A, GlyphParticle.Factory::new); + ParticleFactoryRegistry.getInstance().register(MagisteriumParticles.GLYPH_B, GlyphParticle.Factory::new); + ParticleFactoryRegistry.getInstance().register(MagisteriumParticles.GLYPH_C, GlyphParticle.Factory::new); } } \ No newline at end of file diff --git a/src/main/java/io/github/reoseah/magisterium/MagisteriumBlockTags.java b/src/main/java/io/github/reoseah/magisterium/block/MagisteriumBlockTags.java similarity index 88% rename from src/main/java/io/github/reoseah/magisterium/MagisteriumBlockTags.java rename to src/main/java/io/github/reoseah/magisterium/block/MagisteriumBlockTags.java index 394a1a9..5f5f235 100644 --- a/src/main/java/io/github/reoseah/magisterium/MagisteriumBlockTags.java +++ b/src/main/java/io/github/reoseah/magisterium/block/MagisteriumBlockTags.java @@ -1,4 +1,4 @@ -package io.github.reoseah.magisterium; +package io.github.reoseah.magisterium.block; import net.minecraft.block.Block; import net.minecraft.registry.RegistryKeys; diff --git a/src/main/java/io/github/reoseah/magisterium/block/TestBlock.java b/src/main/java/io/github/reoseah/magisterium/block/TestBlock.java new file mode 100644 index 0000000..886373f --- /dev/null +++ b/src/main/java/io/github/reoseah/magisterium/block/TestBlock.java @@ -0,0 +1,49 @@ +package io.github.reoseah.magisterium.block; + +import io.github.reoseah.magisterium.particle.MagisteriumParticles; +import net.minecraft.block.Block; +import net.minecraft.block.BlockRenderType; +import net.minecraft.block.BlockState; +import net.minecraft.particle.ParticleTypes; +import net.minecraft.particle.SimpleParticleType; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.random.Random; +import net.minecraft.world.World; + +public class TestBlock extends Block { + public static final Block INSTANCE = new TestBlock(Settings.create().nonOpaque().noCollision()); + + public TestBlock(Settings settings) { + super(settings); + } + + @Override + protected BlockRenderType getRenderType(BlockState state) { + return BlockRenderType.INVISIBLE; + } + + @Override + public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) { + super.randomDisplayTick(state, world, pos, random); + + var types = new SimpleParticleType[]{ // + MagisteriumParticles.GLYPH_A, // + MagisteriumParticles.GLYPH_B, // + MagisteriumParticles.GLYPH_C // + }; + + for (int i = 0; i < 1; i++) { + double x = pos.getX() + .5 + random.nextGaussian(); + double y = pos.getY() + .5 + random.nextGaussian(); + double z = pos.getZ() + .5 + random.nextGaussian(); + world.addParticle(types[random.nextInt(types.length)], x, y, z, 0.0D, 0.0D, 0.0D); + } + + for (int i = 0; i < 4; i++) { + double x = pos.getX() + .5 + random.nextGaussian(); + double y = pos.getY() + .5 + random.nextGaussian(); + double z = pos.getZ() + .5 + random.nextGaussian(); + world.addParticle(MagisteriumParticles.ENERGY, x, y, z, 0.0D, 0.05D, 0.0D); + } + } +} diff --git a/src/main/java/io/github/reoseah/magisterium/MagisteriumItemTags.java b/src/main/java/io/github/reoseah/magisterium/item/MagisteriumItemTags.java similarity index 88% rename from src/main/java/io/github/reoseah/magisterium/MagisteriumItemTags.java rename to src/main/java/io/github/reoseah/magisterium/item/MagisteriumItemTags.java index 2b9839d..212487b 100644 --- a/src/main/java/io/github/reoseah/magisterium/MagisteriumItemTags.java +++ b/src/main/java/io/github/reoseah/magisterium/item/MagisteriumItemTags.java @@ -1,4 +1,4 @@ -package io.github.reoseah.magisterium; +package io.github.reoseah.magisterium.item; import net.minecraft.item.Item; import net.minecraft.registry.RegistryKeys; diff --git a/src/main/java/io/github/reoseah/magisterium/particle/EnergyParticle.java b/src/main/java/io/github/reoseah/magisterium/particle/EnergyParticle.java new file mode 100644 index 0000000..c23f6fb --- /dev/null +++ b/src/main/java/io/github/reoseah/magisterium/particle/EnergyParticle.java @@ -0,0 +1,62 @@ +package io.github.reoseah.magisterium.particle; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.particle.*; +import net.minecraft.client.world.ClientWorld; +import net.minecraft.particle.SimpleParticleType; + +public class EnergyParticle extends SpriteBillboardParticle { + protected EnergyParticle(ClientWorld clientWorld, double x, double y, double z, double velocityX, double velocityY, double velocityZ, SpriteProvider spriteProvider) { + super(clientWorld, x, y, z, velocityX, velocityY, velocityZ); + this.maxAge = 8 + this.random.nextInt(24); + this.setSprite(spriteProvider); + float brightness = this.random.nextFloat() * 0.6F + 0.4F; + this.red = brightness * 0.1F; + this.green = brightness * 0.5F; + this.blue = brightness; + this.gravityStrength = 0.01F; + this.scale = .25F; + this.velocityX = this.velocityX * 0.05 + velocityX; + this.velocityY = this.velocityY * 0.05 + velocityY; + this.velocityZ = this.velocityZ * 0.05 + velocityZ; + } + + @Override + public ParticleTextureSheet getType() { + return ParticleTextureSheet.PARTICLE_SHEET_OPAQUE; + } + + @Override + protected int getBrightness(float tint) { + return 240; + } + + @Override + public void tick() { + this.prevPosX = this.x; + this.prevPosY = this.y; + this.prevPosZ = this.z; + if (this.maxAge-- <= 0) { + this.markDead(); + return; + } + this.move(this.velocityX, this.velocityY, this.velocityZ); + this.velocityX *= 0.99D; + this.velocityY *= 0.99D; + this.velocityZ *= 0.99D; + } + + @Environment(EnvType.CLIENT) + public static class Factory implements ParticleFactory { + private final SpriteProvider spriteProvider; + + public Factory(SpriteProvider spriteProvider) { + this.spriteProvider = spriteProvider; + } + + public Particle createParticle(SimpleParticleType simpleParticleType, ClientWorld clientWorld, double x, double y, double z, double velocityX, double velocityY, double velocityZ) { + return new EnergyParticle(clientWorld, x, y, z, velocityX, velocityY, velocityZ, this.spriteProvider); + } + } +} diff --git a/src/main/java/io/github/reoseah/magisterium/particle/GlyphParticle.java b/src/main/java/io/github/reoseah/magisterium/particle/GlyphParticle.java new file mode 100644 index 0000000..c88ee9a --- /dev/null +++ b/src/main/java/io/github/reoseah/magisterium/particle/GlyphParticle.java @@ -0,0 +1,61 @@ +package io.github.reoseah.magisterium.particle; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.particle.*; +import net.minecraft.client.world.ClientWorld; +import net.minecraft.particle.SimpleParticleType; + +@Environment(EnvType.CLIENT) +public class GlyphParticle extends SpriteBillboardParticle { + private final SpriteProvider spriteProvider; + + public GlyphParticle(ClientWorld clientWorld, double x, double y, double z, double velocityX, double velocityY, double velocityZ, SpriteProvider spriteProvider) { + super(clientWorld, x, y, z, velocityX, velocityY, velocityZ); + this.spriteProvider = spriteProvider; + this.maxAge = 16; + this.setSpriteForAge(spriteProvider); + + this.scale = .5F; + this.velocityX = this.velocityX * 0.05 + velocityX; + this.velocityY = this.velocityY * 0.05 + velocityY; + this.velocityZ = this.velocityZ * 0.05 + velocityZ; + } + + @Override + public ParticleTextureSheet getType() { + return ParticleTextureSheet.PARTICLE_SHEET_OPAQUE; + } + + @Override + protected int getBrightness(float tint) { + return 0xFF; + } + + @Override + public void tick() { + this.prevPosX = this.x; + this.prevPosY = this.y; + this.prevPosZ = this.z; + if (this.age++ >= this.maxAge) { + this.markDead(); + } else { + this.velocityY = this.velocityY - this.gravityStrength; + this.move(this.velocityX, this.velocityY, this.velocityZ); + this.setSpriteForAge(this.spriteProvider); + } + } + + @Environment(EnvType.CLIENT) + public static class Factory implements ParticleFactory { + private final SpriteProvider spriteProvider; + + public Factory(SpriteProvider spriteProvider) { + this.spriteProvider = spriteProvider; + } + + public Particle createParticle(SimpleParticleType simpleParticleType, ClientWorld clientWorld, double x, double y, double z, double velocityX, double velocityY, double velocityZ) { + return new GlyphParticle(clientWorld, x, y, z, velocityX, velocityY, velocityZ, this.spriteProvider); + } + } +} diff --git a/src/main/java/io/github/reoseah/magisterium/particle/MagisteriumParticles.java b/src/main/java/io/github/reoseah/magisterium/particle/MagisteriumParticles.java new file mode 100644 index 0000000..da78b62 --- /dev/null +++ b/src/main/java/io/github/reoseah/magisterium/particle/MagisteriumParticles.java @@ -0,0 +1,17 @@ +package io.github.reoseah.magisterium.particle; + +import net.minecraft.particle.SimpleParticleType; + +public class MagisteriumParticles { + public static final SimpleParticleType ENERGY = new MagisteriumParticleType(true); + public static final SimpleParticleType GLYPH_A = new MagisteriumParticleType(true); + public static final SimpleParticleType GLYPH_B = new MagisteriumParticleType(true); + public static final SimpleParticleType GLYPH_C = new MagisteriumParticleType(true); + + // makes constructor public + public static class MagisteriumParticleType extends SimpleParticleType { + public MagisteriumParticleType(boolean alwaysShow) { + super(alwaysShow); + } + } +} diff --git a/src/main/java/io/github/reoseah/magisterium/recipe/AwakenFlameRecipe.java b/src/main/java/io/github/reoseah/magisterium/recipe/AwakenFlameRecipe.java index 2c3634c..fa703b4 100644 --- a/src/main/java/io/github/reoseah/magisterium/recipe/AwakenFlameRecipe.java +++ b/src/main/java/io/github/reoseah/magisterium/recipe/AwakenFlameRecipe.java @@ -1,6 +1,6 @@ package io.github.reoseah.magisterium.recipe; -import io.github.reoseah.magisterium.MagisteriumBlockTags; +import io.github.reoseah.magisterium.block.MagisteriumBlockTags; import io.github.reoseah.magisterium.world.MagisteriumPlaygrounds; import net.minecraft.block.BlockState; import net.minecraft.item.ItemStack; diff --git a/src/main/java/io/github/reoseah/magisterium/recipe/QuenchFlameRecipe.java b/src/main/java/io/github/reoseah/magisterium/recipe/QuenchFlameRecipe.java index d613bfc..b6b990c 100644 --- a/src/main/java/io/github/reoseah/magisterium/recipe/QuenchFlameRecipe.java +++ b/src/main/java/io/github/reoseah/magisterium/recipe/QuenchFlameRecipe.java @@ -1,6 +1,6 @@ package io.github.reoseah.magisterium.recipe; -import io.github.reoseah.magisterium.MagisteriumBlockTags; +import io.github.reoseah.magisterium.block.MagisteriumBlockTags; import io.github.reoseah.magisterium.world.MagisteriumPlaygrounds; import net.minecraft.block.BlockState; import net.minecraft.item.ItemStack; diff --git a/src/main/java/io/github/reoseah/magisterium/screen/ArcaneTableScreenHandler.java b/src/main/java/io/github/reoseah/magisterium/screen/ArcaneTableScreenHandler.java index 6696d9d..8d89bcc 100644 --- a/src/main/java/io/github/reoseah/magisterium/screen/ArcaneTableScreenHandler.java +++ b/src/main/java/io/github/reoseah/magisterium/screen/ArcaneTableScreenHandler.java @@ -1,7 +1,7 @@ package io.github.reoseah.magisterium.screen; import com.mojang.datafixers.util.Pair; -import io.github.reoseah.magisterium.MagisteriumItemTags; +import io.github.reoseah.magisterium.item.MagisteriumItemTags; import io.github.reoseah.magisterium.block.ArcaneTableBlock; import io.github.reoseah.magisterium.item.SpellBookItem; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/main/resources/assets/magisterium/particles/energy.json b/src/main/resources/assets/magisterium/particles/energy.json new file mode 100644 index 0000000..ca698ca --- /dev/null +++ b/src/main/resources/assets/magisterium/particles/energy.json @@ -0,0 +1,5 @@ +{ + "textures": [ + "minecraft:generic_0" + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/magisterium/particles/glyph_a.json b/src/main/resources/assets/magisterium/particles/glyph_a.json new file mode 100644 index 0000000..61f6dea --- /dev/null +++ b/src/main/resources/assets/magisterium/particles/glyph_a.json @@ -0,0 +1,12 @@ +{ + "textures": [ + "magisterium:glyph_a_1", + "magisterium:glyph_a_1", + "magisterium:glyph_a_1", + "magisterium:glyph_a_1", + "magisterium:glyph_a_0", + "magisterium:glyph_a_0", + "magisterium:glyph_1", + "magisterium:glyph_0" + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/magisterium/particles/glyph_b.json b/src/main/resources/assets/magisterium/particles/glyph_b.json new file mode 100644 index 0000000..ef37e6c --- /dev/null +++ b/src/main/resources/assets/magisterium/particles/glyph_b.json @@ -0,0 +1,12 @@ +{ + "textures": [ + "magisterium:glyph_b_1", + "magisterium:glyph_b_1", + "magisterium:glyph_b_1", + "magisterium:glyph_b_1", + "magisterium:glyph_b_0", + "magisterium:glyph_b_0", + "magisterium:glyph_1", + "magisterium:glyph_0" + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/magisterium/particles/glyph_c.json b/src/main/resources/assets/magisterium/particles/glyph_c.json new file mode 100644 index 0000000..63961b2 --- /dev/null +++ b/src/main/resources/assets/magisterium/particles/glyph_c.json @@ -0,0 +1,12 @@ +{ + "textures": [ + "magisterium:glyph_c_1", + "magisterium:glyph_c_1", + "magisterium:glyph_c_1", + "magisterium:glyph_c_1", + "magisterium:glyph_c_0", + "magisterium:glyph_c_0", + "magisterium:glyph_1", + "magisterium:glyph_0" + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/magisterium/textures/particle/glyph_0.png b/src/main/resources/assets/magisterium/textures/particle/glyph_0.png new file mode 100644 index 0000000..6bbc882 Binary files /dev/null and b/src/main/resources/assets/magisterium/textures/particle/glyph_0.png differ diff --git a/src/main/resources/assets/magisterium/textures/particle/glyph_1.png b/src/main/resources/assets/magisterium/textures/particle/glyph_1.png new file mode 100644 index 0000000..e9afeee Binary files /dev/null and b/src/main/resources/assets/magisterium/textures/particle/glyph_1.png differ diff --git a/src/main/resources/assets/magisterium/textures/particle/glyph_a_0.png b/src/main/resources/assets/magisterium/textures/particle/glyph_a_0.png new file mode 100644 index 0000000..6fce8fd Binary files /dev/null and b/src/main/resources/assets/magisterium/textures/particle/glyph_a_0.png differ diff --git a/src/main/resources/assets/magisterium/textures/particle/glyph_a_1.png b/src/main/resources/assets/magisterium/textures/particle/glyph_a_1.png new file mode 100644 index 0000000..3357313 Binary files /dev/null and b/src/main/resources/assets/magisterium/textures/particle/glyph_a_1.png differ diff --git a/src/main/resources/assets/magisterium/textures/particle/glyph_b_0.png b/src/main/resources/assets/magisterium/textures/particle/glyph_b_0.png new file mode 100644 index 0000000..c31de52 Binary files /dev/null and b/src/main/resources/assets/magisterium/textures/particle/glyph_b_0.png differ diff --git a/src/main/resources/assets/magisterium/textures/particle/glyph_b_1.png b/src/main/resources/assets/magisterium/textures/particle/glyph_b_1.png new file mode 100644 index 0000000..2c79a0e Binary files /dev/null and b/src/main/resources/assets/magisterium/textures/particle/glyph_b_1.png differ diff --git a/src/main/resources/assets/magisterium/textures/particle/glyph_c_0.png b/src/main/resources/assets/magisterium/textures/particle/glyph_c_0.png new file mode 100644 index 0000000..18a5f57 Binary files /dev/null and b/src/main/resources/assets/magisterium/textures/particle/glyph_c_0.png differ diff --git a/src/main/resources/assets/magisterium/textures/particle/glyph_c_1.png b/src/main/resources/assets/magisterium/textures/particle/glyph_c_1.png new file mode 100644 index 0000000..e6e2adb Binary files /dev/null and b/src/main/resources/assets/magisterium/textures/particle/glyph_c_1.png differ