Skip to content

Commit

Permalink
WIP: maybe compiles now.
Browse files Browse the repository at this point in the history
Signed-off-by: 秋雨落 <[email protected]>
  • Loading branch information
qyl27 committed Feb 20, 2024
1 parent e5f825e commit fca6570
Show file tree
Hide file tree
Showing 19 changed files with 103 additions and 166 deletions.
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ allprojects {
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"

modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader_version}"
modApi "dev.architectury:architectury:${project.architectury_version}"
}

Expand All @@ -51,7 +53,6 @@ allprojects {
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
archivesBaseName = project.archives_base_name
withSourcesJar()
}

Expand Down Expand Up @@ -94,7 +95,7 @@ architectury {
}

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

sourceSets.main.resources.srcDir 'src/main/generated'
8 changes: 4 additions & 4 deletions catsplus-fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ loom {
data {
inherit client

name "Data Generation"
name 'Data Generation'

vmArg "-Dfabric-api.datagen"
vmArg '-Dfabric-api.datagen'
vmArg "-Dfabric-api.datagen.output-dir=${file("../src/main/generated")}"
vmArg "-Dfabric-api.datagen.modid=${project.mod_id}"
vmArg '-Dfabric-api.datagen.modid=catsplus'

runDir "build/datagen"
runDir 'build/datagen'
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,18 @@

import cuteneko.catsplus.CatsPlus;
import cuteneko.catsplus.fabric.platform.CatsPlusFabricPlatform;
import cuteneko.catsplus.fabric.registry.PotionRegistry;
import cuteneko.catsplus.fabric.registry.BlockRegistry;
import cuteneko.catsplus.fabric.registry.EffectRegistry;
import cuteneko.catsplus.fabric.registry.ItemGroupRegistry;
import cuteneko.catsplus.fabric.registry.ItemRegistry;
import net.fabricmc.api.ModInitializer;

public class CatsPlusFabric implements ModInitializer {
private final CatsPlus mod;

public CatsPlusFabric() {
new CatsPlus().setPlatform(new CatsPlusFabricPlatform());
mod = new CatsPlus();
mod.setPlatform(new CatsPlusFabricPlatform());
}

@Override
public void onInitialize() {
ItemRegistry.register();
ItemGroupRegistry.register();
EffectRegistry.register();
PotionRegistry.register();
BlockRegistry.register();
mod.init();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void generateTranslations(TranslationBuilder builder) {
builder.add(ModItems.FANG_LUO, "Paper Model of Fang_Luo");
builder.add(Constants.MESSAGE_FANG_LUO_DESCRIPTION, "Don't be sad, have a hug..."); // Don't change to other language when translating.

builder.add(ModBlocks.CAT_RESURRECTION_STATION, "Cat Resurrection Station");
builder.add(ModBlocks.CAT_RESURRECTION_STATION_BLOCK, "Cat Resurrection Station");

builder.add(ModEffects.CATTIFY, "Cattify");
builder.add(Constants.MESSAGE_CATTIFY_POTION, "Potion of Cattify");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void generateTranslations(TranslationBuilder builder) {
builder.add(ModItems.FANG_LUO, "坊洛纸模");
builder.add(Constants.MESSAGE_FANG_LUO_DESCRIPTION, "Don't be sad, have a hug...");

builder.add(ModBlocks.CAT_RESURRECTION_STATION, "猫咪复活台");
builder.add(ModBlocks.CAT_RESURRECTION_STATION_BLOCK, "猫咪复活台");

builder.add(ModEffects.CATTIFY, "猫咪化");
builder.add(Constants.MESSAGE_CATTIFY_POTION, "变猫药水");
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

13 changes: 13 additions & 0 deletions src/main/java/cuteneko/catsplus/CatsPlus.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package cuteneko.catsplus;

import cuteneko.catsplus.block.ModBlocks;
import cuteneko.catsplus.effect.ModEffects;
import cuteneko.catsplus.effect.potion.ModPotions;
import cuteneko.catsplus.item.ModItems;
import cuteneko.catsplus.item.group.ModItemGroups;
import cuteneko.catsplus.platform.ICatsPlusPlatform;

public class CatsPlus {
Expand All @@ -17,6 +22,14 @@ public static CatsPlus getInstance() {
return INSTANCE;
}

public void init() {
ModItemGroups.register();
ModBlocks.register();
ModItems.register();
ModEffects.register();
ModPotions.register();
}

public void setPlatform(ICatsPlusPlatform platform) {
this.platform = platform;
}
Expand Down
18 changes: 15 additions & 3 deletions src/main/java/cuteneko/catsplus/block/ModBlocks.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
package cuteneko.catsplus.block;

import cuteneko.catsplus.CatsPlus;
import cuteneko.catsplus.item.group.ModItemGroups;
import dev.architectury.registry.registries.DeferredRegister;
import dev.architectury.registry.registries.RegistrySupplier;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.util.Identifier;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.registry.RegistryKeys;

public class ModBlocks {
public static final Identifier ID_CAT_RESURRECTION_STATION = new Identifier(CatsPlus.MODID, "cat_resurrection_station");
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(CatsPlus.MODID, RegistryKeys.BLOCK);
public static final DeferredRegister<Item> BLOCK_ITEMS = DeferredRegister.create(CatsPlus.MODID, RegistryKeys.ITEM);

public static Block CAT_RESURRECTION_STATION = new CatResurrectionStationBlock(AbstractBlock.Settings.create().hardness(5f));
public static void register() {
BLOCKS.register();
BLOCK_ITEMS.register();
}

public static final RegistrySupplier<Block> CAT_RESURRECTION_STATION_BLOCK = BLOCKS.register("cat_resurrection_station", () -> new CatResurrectionStationBlock(AbstractBlock.Settings.create().hardness(5f)));
public static final RegistrySupplier<Item> CAT_RESURRECTION_STATION = BLOCK_ITEMS.register("cat_resurrection_station", () -> new BlockItem(CAT_RESURRECTION_STATION_BLOCK.get(), new Item.Settings().arch$tab(ModItemGroups.CATS_PLUS)));
}
12 changes: 9 additions & 3 deletions src/main/java/cuteneko/catsplus/effect/ModEffects.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package cuteneko.catsplus.effect;

import cuteneko.catsplus.CatsPlus;
import dev.architectury.registry.registries.DeferredRegister;
import dev.architectury.registry.registries.RegistrySupplier;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.util.Identifier;
import net.minecraft.registry.RegistryKeys;

public class ModEffects {
public static final Identifier ID_CATTIFY = new Identifier(CatsPlus.MODID, "cattify");
public static final DeferredRegister<StatusEffect> EFFECTS = DeferredRegister.create(CatsPlus.MODID, RegistryKeys.STATUS_EFFECT);

public static final StatusEffect CATTIFY = new CattifyEffect();
public static void register() {
EFFECTS.register();
}

public static final RegistrySupplier<StatusEffect> CATTIFY = EFFECTS.register("cattify", CattifyEffect::new);
}
15 changes: 10 additions & 5 deletions src/main/java/cuteneko/catsplus/effect/potion/ModPotions.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@

import cuteneko.catsplus.CatsPlus;
import cuteneko.catsplus.effect.ModEffects;
import dev.architectury.registry.registries.DeferredRegister;
import dev.architectury.registry.registries.RegistrySupplier;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.potion.Potion;
import net.minecraft.util.Identifier;
import net.minecraft.registry.RegistryKeys;

public class ModPotions {
public static final Identifier ID_CATTIFY = new Identifier(CatsPlus.MODID, "cattify");
public static final Identifier ID_LONG_CATTIFY = new Identifier(CatsPlus.MODID, "long_cattify");
public static final DeferredRegister<Potion> POTIONS = DeferredRegister.create(CatsPlus.MODID, RegistryKeys.POTION);

public static final Potion CATTIFY = new Potion(new StatusEffectInstance(ModEffects.CATTIFY, 1800));
public static final Potion LONG_CATTIFY = new Potion(ID_CATTIFY.getPath(), new StatusEffectInstance(ModEffects.CATTIFY, 4800));
public static void register() {
POTIONS.register();
}

public static final RegistrySupplier<Potion> CATTIFY = POTIONS.register("cattify", () -> new Potion(new StatusEffectInstance(ModEffects.CATTIFY.get(), 1800)));
public static final RegistrySupplier<Potion> LONG_CATTIFY = POTIONS.register("long_cattify", () -> new Potion("cattify", new StatusEffectInstance(ModEffects.CATTIFY.get(), 4800)));
}
10 changes: 7 additions & 3 deletions src/main/java/cuteneko/catsplus/item/CatBagItem.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cuteneko.catsplus.item;

import cuteneko.catsplus.item.group.ModItemGroups;
import cuteneko.catsplus.utility.Constants;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.EntityType;
Expand Down Expand Up @@ -30,8 +31,11 @@

public class CatBagItem extends Item implements DyeableItem {

public CatBagItem(Settings settings) {
super(settings);
public CatBagItem() {
super(new Item.Settings()
.fireproof()
.maxCount(1)
.arch$tab(ModItemGroups.CATS_PLUS));
}

@Override
Expand All @@ -44,7 +48,7 @@ public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> too
var cat = stack.getNbt().getCompound(Constants.TAG_CAT_BAG_CAT);
if (cat.contains(Constants.TAG_CUSTOM_NAME)) {
var name = cat.getString(Constants.TAG_CUSTOM_NAME);
var component = Text.Serializer.fromJson(name);
var component = Text.Serialization.fromJson(name);

if (component != null) {
tooltip.add(Text.translatable(Constants.MESSAGE_CAT_BAG_HAS_CAT_NAMED, component.getString()).formatted(Formatting.BLUE));
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/cuteneko/catsplus/item/CatSpiritItem.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package cuteneko.catsplus.item;

import net.minecraft.item.Item;
import net.minecraft.util.Rarity;

public class CatSpiritItem extends Item {
public CatSpiritItem(Settings settings) {
super(settings);
public CatSpiritItem() {
super(new Item.Settings()
.maxCount(1)
.fireproof()
.rarity(Rarity.EPIC));
}
}
8 changes: 6 additions & 2 deletions src/main/java/cuteneko/catsplus/item/FangLuoItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Rarity;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class FangLuoItem extends Item {
public FangLuoItem(Settings settings) {
super(settings);
public FangLuoItem() {
super(new Item.Settings()
.maxCount(1)
.fireproof()
.rarity(Rarity.EPIC));
}

@Override
Expand Down
Loading

0 comments on commit fca6570

Please sign in to comment.