Skip to content

Commit

Permalink
stuffs
Browse files Browse the repository at this point in the history
  • Loading branch information
PinkGoosik committed Feb 25, 2024
1 parent f7651c4 commit b57641b
Show file tree
Hide file tree
Showing 36 changed files with 216 additions and 10 deletions.
14 changes: 9 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
plugins {
id "fabric-loom" version "1.4-SNAPSHOT"
id "fabric-loom" version "1.5-SNAPSHOT"
}

version = project.mod_version
group = project.maven_group

base {
archivesName = project.archives_base_name
}

repositories {
maven {
url "https://api.modrinth.com/maven"
content { includeGroup "maven.modrinth" }
}
maven { url "https://maven.ladysnake.org/releases" } //CCA
maven { url "https://maven.terraformersmc.com" } //trinkets
maven { url "https://maven.wispforest.io" } //owo-lib
}

dependencies {
Expand All @@ -21,6 +26,7 @@ dependencies {
modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api}"
modImplementation "dev.emi:trinkets:${project.trinkets_version}"
modImplementation "io.wispforest:owo-lib:${project.owo_lib}"

// modImplementation "dev.onyxstudios.cardinal-components-api:cardinal-components-api:${project.cca_version}"
modImplementation "dev.onyxstudios.cardinal-components-api:cardinal-components-base:${project.cca_version}"
Expand All @@ -29,16 +35,14 @@ dependencies {
modLocalRuntime "maven.modrinth:here-be-no-dragons:1.0.0"
modLocalRuntime "maven.modrinth:limitless-structure-block:1.0"
modLocalRuntime "dev.emi:emi-fabric:1.0.29+1.20.1"
modLocalRuntime "com.terraformersmc:modmenu:7.2.2"
modLocalRuntime "io.wispforest:gadget:0.2.2+1.20"
}

loom {
accessWidenerPath = file("src/main/resources/artifality.accesswidener")
}

base {
archivesName = project.archives_base_name
}

processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ yarn_mappings = 1.20.1+build.10
fabric_loader = 0.15.3
fabric_api = 0.91.0+1.20.1
trinkets_version = 3.7.1
cca_version = 5.2.2
cca_version = 5.2.2
owo_lib = 0.11.2+1.20
31 changes: 29 additions & 2 deletions src/main/java/artifality/ArtifalityMod.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package artifality;

import artifality.client.particle.ArtifalityParticles;
import artifality.command.ArtifalityCommands;
import artifality.compat.ArtifalityOwoLibIntegration;
import artifality.data.ArtifalityLootTables;
import artifality.registry.*;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.enchantment.EnchantmentLevelEntry;
import net.minecraft.item.EnchantedBookItem;
import net.minecraft.item.ItemGroup;
Expand All @@ -18,7 +21,7 @@
@SuppressWarnings("unused")
public class ArtifalityMod implements ModInitializer {
public static final String MOD_ID = "artifality";
public static final ItemGroup ITEM_GROUP = FabricItemGroup.builder()
public static ItemGroup itemGroup = FabricItemGroup.builder()
.displayName(Text.translatable("itemGroup.artifality.items"))
.entries((ctx, entries) -> {
ArtifalityItems.ITEMS.forEach((id, item) -> entries.add(item.getDefaultStack()));
Expand All @@ -44,8 +47,32 @@ public void onInitialize() {
ArtifalityLootTables.init();
ArtifalityEffects.init();
ArtifalityCommands.init();
ArtifalityParticles.register();
itemGroup = createItemGroup();
if(FabricLoader.getInstance().isModLoaded("owo")) {
ArtifalityOwoLibIntegration.initItemGroup();
}
}

Registry.register(Registries.ITEM_GROUP, id("items"), ITEM_GROUP);
private static ItemGroup createItemGroup() {
if(FabricLoader.getInstance().isModLoaded("owo")) {
return ArtifalityOwoLibIntegration.createItemGroup();
}
var group = FabricItemGroup.builder().displayName(Text.translatable("itemGroup.artifality.items"))
.icon(ArtifalityItems.FOREST_STAFF::getDefaultStack)
.entries((displayContext, entries) -> {
ArtifalityItems.ITEMS.forEach((id, item) -> entries.add(item.getDefaultStack()));
ArtifalityBlocks.ITEMS.forEach((id, item) -> entries.add(item.getDefaultStack()));
ArtifalityEnchants.ENCHANTMENTS.forEach((id, enchantment) -> {
for(int i = 1; i <= enchantment.getMaxLevel(); i++) {
ItemStack book = new ItemStack(Items.ENCHANTED_BOOK);
EnchantedBookItem.addEnchantment(book, new EnchantmentLevelEntry(enchantment, i));
entries.add(book);
}
});
}).build();
Registry.register(Registries.ITEM_GROUP, id("items"), group);
return group;
}

public static Identifier id(String path) {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/artifality/client/ArtifalityClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public void onInitializeClient() {
BlockEntityRendererFactories.register(ArtifalityBlockEntities.TRADING_PEDESTAL, ctx -> new TradingPedestalRenderer<>());

TradingPedestalHud.register();
ArtifalityParticles.register();

ArtifalityItems.ITEMS.forEach((id, item) -> {
if(item instanceof ArtifactItem artifact) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package artifality.client.particle;

import artifality.ArtifalityMod;
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes;
import net.minecraft.particle.DefaultParticleType;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;

public class ArtifalityParticles {
public static final DefaultParticleType LUNAR_CHAIN = add("lunar_chain");

public static void register() {
ParticleFactoryRegistry.getInstance().register(LUNAR_CHAIN, LunarChainParticle.Factory::new);
}

private static DefaultParticleType add(String name) {
Expand Down
85 changes: 85 additions & 0 deletions src/main/java/artifality/client/particle/LunarChainParticle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package artifality.client.particle;

import net.minecraft.client.particle.*;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.particle.DefaultParticleType;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import org.joml.Quaternionf;
import org.joml.Vector3f;

public class LunarChainParticle extends SpriteBillboardParticle {
private final SpriteProvider sprites;
private static final Quaternionf QUATERNION = new Quaternionf(0F, -0.7F, 0.7F, 0F);

public LunarChainParticle(ClientWorld world, double x, double y, double z, double color, SpriteProvider sprites) {
super(world, x, y, z, 0, 0, 0);
this.maxAge = 10;
this.setVelocity(0D, 0D, 0D);
if(color != 0) this.setColor((int) color);
this.scale = 0.5F;
this.sprites = sprites;
this.setSpriteForAge(sprites);
}

public void setColor(int rgbHex) {
float red = (float) ((rgbHex & 16711680) >> 16) / 255.0F;
float green = (float) ((rgbHex & '\uff00') >> 8) / 255.0F;
float blue = (float) ((rgbHex & 255)) / 255.0F;
this.setColor(red, green, blue);
}

@Override
public void tick() {
// if(this.age > this.maxAge / 2) {
// this.setAlpha(1.0F - ((float) this.age - (float) (this.maxAge / 2)) / (float) this.maxAge);
// }
if(this.age++ >= this.maxAge) {
this.markDead();
}
else {
this.setSpriteForAge(sprites);
}
}

@Override
public void buildGeometry(VertexConsumer buffer, Camera camera, float ticks) {
Vec3d vec3 = camera.getPos();
float x = (float) (MathHelper.lerp(ticks, this.prevPosX, this.x) - vec3.getX());
float y = (float) (MathHelper.lerp(ticks, this.prevPosY, this.y) - vec3.getY());
float z = (float) (MathHelper.lerp(ticks, this.prevPosZ, this.z) - vec3.getZ());

Vector3f[] vector3fs = new Vector3f[]{new Vector3f(-1.0F, -1.0F, 0.0F), new Vector3f(-1.0F, 1.0F, 0.0F), new Vector3f(1.0F, 1.0F, 0.0F), new Vector3f(1.0F, -1.0F, 0.0F)};
float f4 = this.getSize(ticks);

for(int i = 0; i < 4; ++i) {
Vector3f vector3f = vector3fs[i];
vector3f.rotate(QUATERNION);
vector3f.mul(f4);
vector3f.add(x, y, z);
}

float f7 = this.getMinU();
float f8 = this.getMaxU();
float f5 = this.getMinV();
float f6 = this.getMaxV();
int light = this.getBrightness(ticks);
buffer.vertex(vector3fs[0].x(), vector3fs[0].y(), vector3fs[0].z()).texture(f8, f6).color(this.red, this.green, this.blue, this.alpha).light(light).next();
buffer.vertex(vector3fs[1].x(), vector3fs[1].y(), vector3fs[1].z()).texture(f8, f5).color(this.red, this.green, this.blue, this.alpha).light(light).next();
buffer.vertex(vector3fs[2].x(), vector3fs[2].y(), vector3fs[2].z()).texture(f7, f5).color(this.red, this.green, this.blue, this.alpha).light(light).next();
buffer.vertex(vector3fs[3].x(), vector3fs[3].y(), vector3fs[3].z()).texture(f7, f6).color(this.red, this.green, this.blue, this.alpha).light(light).next();
}

@Override
public ParticleTextureSheet getType() {
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
}

public record Factory(SpriteProvider sprites) implements ParticleFactory<DefaultParticleType> {
public Particle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double velX, double velY, double velZ) {
return new LunarChainParticle(world, x, y, z, velX, sprites);
}
}
}
46 changes: 46 additions & 0 deletions src/main/java/artifality/compat/ArtifalityOwoLibIntegration.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package artifality.compat;

import artifality.ArtifalityMod;
import artifality.registry.ArtifalityBlocks;
import artifality.registry.ArtifalityEnchants;
import artifality.registry.ArtifalityItems;
import io.wispforest.owo.itemgroup.Icon;
import io.wispforest.owo.itemgroup.OwoItemGroup;
import io.wispforest.owo.itemgroup.gui.ItemGroupButton;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.enchantment.EnchantmentLevelEntry;
import net.minecraft.item.EnchantedBookItem;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
import net.minecraft.util.Identifier;

public class ArtifalityOwoLibIntegration {
public static final Identifier ICONS_TEXTURE = ArtifalityMod.id("textures/gui/icons.png");

public static ItemGroup createItemGroup() {
return OwoItemGroup.builder(ArtifalityMod.id("items"), () -> Icon.of(ArtifalityItems.FOREST_STAFF))
.initializer(group -> {
group.addButton(ItemGroupButton.link(group, Icon.of(ICONS_TEXTURE, 0, 0, 64, 64), "discord", "https://discord.gg/DcemWeskeZ"));
}).build();
}

public static void initItemGroup() {
if(ArtifalityMod.itemGroup instanceof OwoItemGroup owoItemGroup) {
owoItemGroup.initialize();
}

ItemGroupEvents.modifyEntriesEvent(Registries.ITEM_GROUP.getKey(ArtifalityMod.itemGroup).get()).register(entries -> {
ArtifalityItems.ITEMS.forEach((id, item) -> entries.add(item.getDefaultStack()));
ArtifalityBlocks.ITEMS.forEach((id, item) -> entries.add(item.getDefaultStack()));
ArtifalityEnchants.ENCHANTMENTS.forEach((id, enchantment) -> {
for(int i = 1; i <= enchantment.getMaxLevel(); i++) {
ItemStack book = new ItemStack(Items.ENCHANTED_BOOK);
EnchantedBookItem.addEnchantment(book, new EnchantmentLevelEntry(enchantment, i));
entries.add(book);
}
});
});
}
}
10 changes: 10 additions & 0 deletions src/main/java/artifality/mixin/common/PlayerMixin.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package artifality.mixin.common;

import artifality.client.particle.ArtifalityParticles;
import artifality.extension.PlayerExtension;
import artifality.registry.ArtifalityDimensions;
import artifality.registry.ArtifalityEnchants;
import artifality.registry.ArtifalityItems;
import artifality.item.BalloonItem;
Expand All @@ -17,6 +19,7 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Vec3d;
Expand Down Expand Up @@ -97,6 +100,13 @@ void tick(CallbackInfo ci) {
if(!self.isOnGround() && !self.isFallFlying() && !self.isTouchingWater() && !self.hasStatusEffect(StatusEffects.LEVITATION)) {
useBalloon();
}

if (!self.isCreative() && self.getWorld().getDimensionKey().getValue().equals(ArtifalityDimensions.LUNAR_BAZAAR.getValue())) {

if(self.isOnGround() && (self.age % 40) == 0) {
((ServerWorld)self.getWorld()).spawnParticles(ArtifalityParticles.LUNAR_CHAIN, self.getX(), self.getY() + 0.05D, self.getZ(), 0, 0, 0, 0, 0);
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/artifality/registry/ArtifalityBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import artifality.block.*;
import artifality.block.base.*;
import artifality.item.base.BaseBlockItem;
import artifality.list.ArtifactRarity;
import artifality.list.LensEffects;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
Expand Down Expand Up @@ -93,6 +92,7 @@ public class ArtifalityBlocks {
public static final Block EMPTY_LENS = lens("empty_lens", LensEffects.EMPTY);

public static final Block LUNASTONE = add("lunastone", new BaseBlock(copyOf(Blocks.STONE)));
public static final Block LUNALIGHT = add("lunalight", new BaseBlock(copyOf(GLOWSTONE)));
public static final Block LUNAR_PORTAL = add("lunar_portal", new LunarPortalBlock(copyOf(Blocks.STONE)));
public static final Block LUNAR_TRADING_PEDESTAL = add("lunar_trading_pedestal", new TradingPedestalBlock(copyOf(Blocks.STONE).nonOpaque().notSolid()));

Expand Down
1 change: 1 addition & 0 deletions src/main/java/artifality/registry/ArtifalityItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class ArtifalityItems {
// public static final Item WRATH_CRYSTAL = add("wrath_crystal", new BaseItem(settings()));

public static final Item INCREMENTAL_ORB = add("incremental_orb", new BaseItem(settings()));
public static final Item HAUNTING_SOUL = add("haunting_soul", new BaseItem(settings()));

private static Item add(String name, Item item) {
ITEMS.put(ArtifalityMod.id(name), item);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "artifality:block/lunalight" }
}
}
1 change: 1 addition & 0 deletions src/main/resources/assets/artifality/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"modmenu.descriptionTranslation.artifality": "Collection of new unique artifacts, blocks, enchantments, and other stuff.",

"itemGroup.artifality.items": "Artifality",
"itemGroup.artifality.items.button.discord": "Join our Discord server!",

"block.artifality.upgrading_pedestal": "Pedestal of Upgrading",
"tip.upgrading_pedestal.0": "Allows you to upgrade your",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "artifality:block/lunalight"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "artifality:item/haunting_soul"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "artifality:block/lunalight"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"textures": [
"artifality:lunar_chain_0",
"artifality:lunar_chain_1",
"artifality:lunar_chain_2",
"artifality:lunar_chain_3",
"artifality:lunar_chain_4"
]
}
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.
Binary file modified src/main/resources/assets/artifality/textures/item/balloon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
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.
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.
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 b57641b

Please sign in to comment.