Skip to content

Commit

Permalink
Update doll.
Browse files Browse the repository at this point in the history
Fix bugs.
Add cat spirit.

Signed-off-by: 秋雨落 <[email protected]>
  • Loading branch information
qyl27 committed Feb 21, 2024
1 parent efba7be commit ee68a32
Show file tree
Hide file tree
Showing 45 changed files with 424 additions and 224 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cuteneko.catsplus.fabric;

import cuteneko.catsplus.fabric.data.CatPlayerFabric;
import cuteneko.catsplus.fabric.data.GeniusCatFabric;
import cuteneko.catsplus.data.ICatPlayer;
import cuteneko.catsplus.data.IGeniusCat;
import net.minecraft.entity.passive.CatEntity;
import net.minecraft.entity.player.PlayerEntity;

public class CatsPlusDataImpl {
public static ICatPlayer getCatPlayer(PlayerEntity player) {
return new CatPlayerFabric(player);
}

public static IGeniusCat getGeniusCat(CatEntity cat) {
return new GeniusCatFabric(cat);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package cuteneko.catsplus.fabric.platform;
package cuteneko.catsplus.fabric.data;

import cuteneko.catsplus.effect.ModEffects;
import cuteneko.catsplus.fabric.mixins.impl.IPlayerEntityMixin;
import cuteneko.catsplus.platform.ICatPlayer;
import cuteneko.catsplus.data.ICatPlayer;
import net.minecraft.entity.passive.CatEntity;
import net.minecraft.entity.player.PlayerEntity;

public class CatPlayer implements ICatPlayer {
public class CatPlayerFabric implements ICatPlayer {
private final PlayerEntity player;

public CatPlayer(PlayerEntity player) {
public CatPlayerFabric(PlayerEntity player) {
this.player = player;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package cuteneko.catsplus.fabric.platform;
package cuteneko.catsplus.fabric.data;

import cuteneko.catsplus.fabric.mixins.impl.ICatEntityMixin;
import cuteneko.catsplus.platform.IGeniusCat;
import cuteneko.catsplus.data.IGeniusCat;
import net.minecraft.advancement.criterion.Criteria;
import net.minecraft.entity.EntityStatuses;
import net.minecraft.entity.passive.CatEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.math.BlockPos;

public class GeniusCat implements IGeniusCat {
public class GeniusCatFabric implements IGeniusCat {
private final CatEntity cat;

public GeniusCat(CatEntity cat) {
public GeniusCatFabric(CatEntity cat) {
this.cat = cat;
}

Expand All @@ -28,12 +28,7 @@ public void setTotem(boolean totem) {

@Override
public boolean canRespawn() {
return ((ICatEntityMixin) cat).catsplus$canRespawn();
}

@Override
public void setCanRespawn(boolean canRespawn) {
((ICatEntityMixin) cat).catsplus$setCanRespawn(canRespawn);
return hasTotem() || getLives() > 0;
}

@Override
Expand All @@ -45,17 +40,14 @@ public int getFavorability(PlayerEntity player) {
public void setFavorability(int favorability, PlayerEntity player) {
((ICatEntityMixin) cat).catsplus$setFavorability(favorability, player);

if(getFavorability(player) <= 0) {
if (cat.isOwner(player) && getFavorability(player) <= 0) {
cat.tryAttack(player);
cat.setOwnerUuid(null);
cat.setTamed(false);
cat.setSitting(false);
setCanRespawn(false);
setLives(0);
cat.onTamedChanged();
cat.getWorld().sendEntityStatus(cat, EntityStatuses.ADD_VILLAGER_ANGRY_PARTICLES);
if (player instanceof ServerPlayerEntity) {
Criteria.TAME_ANIMAL.trigger((ServerPlayerEntity)player, cat);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cuteneko.catsplus.fabric.data;
package cuteneko.catsplus.fabric.data.gen;

import cuteneko.catsplus.fabric.data.lang.ModLangProviderENUS;
import cuteneko.catsplus.fabric.data.lang.ModLangProviderZHCN;
import cuteneko.catsplus.fabric.data.gen.lang.ModLangProviderENUS;
import cuteneko.catsplus.fabric.data.gen.lang.ModLangProviderZHCN;
import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cuteneko.catsplus.fabric.data;
package cuteneko.catsplus.fabric.data.gen;

import cuteneko.catsplus.item.ModItems;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cuteneko.catsplus.fabric.data;
package cuteneko.catsplus.fabric.data.gen;

import cuteneko.catsplus.item.ModItems;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package cuteneko.catsplus.fabric.data.lang;
package cuteneko.catsplus.fabric.data.gen.lang;

import cuteneko.catsplus.block.ModBlocks;
import cuteneko.catsplus.effect.ModEffects;
import cuteneko.catsplus.item.ModItems;
import cuteneko.catsplus.item.group.ModItemGroups;
import cuteneko.catsplus.utility.Constants;
import dev.architectury.registry.registries.DeferredSupplier;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricLanguageProvider;
import net.minecraft.item.ItemGroup;

public class ModLangProviderENUS extends FabricLanguageProvider {
public ModLangProviderENUS(FabricDataOutput dataOutput) {
Expand All @@ -18,8 +21,8 @@ public void generateTranslations(TranslationBuilder builder) {
builder.add(ModItems.TOTEMEOW.get(), "Totemeow");
builder.add(ModItems.CAT_SPIRIT.get(), "Cat Spirit");
builder.add(ModItems.FANG_LUO.get(), "Doll of Fang_Luo");
builder.add(Constants.MESSAGE_FANG_LUO_DESCRIPTION_1, "In memory of Fang_Luo, a girl who was passed away because of cancer.");
builder.add(Constants.MESSAGE_FANG_LUO_DESCRIPTION_2, "Rest in peace.");
builder.add(Constants.MESSAGE_FANG_LUO_DESCRIPTION_1, "In memory of Fang_Luo, a girl who passed away because of cancer.");
builder.add(Constants.MESSAGE_FANG_LUO_DESCRIPTION_2, "Rest in peace, my friend.");

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

Expand All @@ -29,9 +32,15 @@ public void generateTranslations(TranslationBuilder builder) {
builder.add(Constants.MESSAGE_CATTIFY_LINGERING_POTION, "Lingering Potion of Cattify");
builder.add(Constants.MESSAGE_CATTIFY_POTION_ARROW, "Arrow of Cattify");

builder.add(Constants.MESSAGE_CATS_GROUP_TITLE, "Cats+!");
builder.add(Constants.MESSAGE_CAT_BAG_NO_CAT, "Empty.");
builder.add(Constants.MESSAGE_CAT_BAG_HAS_CAT, "Cat Inside!");
builder.add(Constants.MESSAGE_CAT_BAG_HAS_CAT_NAMED, "%1$s Inside!");
builder.add(((DeferredSupplier<ItemGroup>) ModItemGroups.CATS_PLUS).getKey(), "Cats+!");
builder.add(Constants.MESSAGE_CAT_BAG_DESCRIPTION_NO_CAT, "Empty.");
builder.add(Constants.MESSAGE_CAT_BAG_DESCRIPTION_HAS_CAT, "Cat Inside!");
builder.add(Constants.MESSAGE_CAT_BAG_DESCRIPTION_HAS_NAMED_CAT, "%1$s Inside!");

builder.add(Constants.MESSAGE_CAT_SPIRIT_NAME, "Spirit of %1$s");
builder.add(Constants.MESSAGE_CAT_SPIRIT_DESCRIPTION_MESSAGE, "");
builder.add(Constants.MESSAGE_CAT_SPIRIT_DESCRIPTION_TIME_LABEL, "Dead at: ");
builder.add(Constants.MESSAGE_CAT_SPIRIT_DESCRIPTION_TIME_PATTERN, "%2$s/%3$s/%1$s %4$s:%5$s:%6$s");
builder.add(Constants.MESSAGE_CAT_SPIRIT_DESCRIPTION_TIME_LONG_TIME_AGO, "Long time ago");
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package cuteneko.catsplus.fabric.data.lang;
package cuteneko.catsplus.fabric.data.gen.lang;

import cuteneko.catsplus.block.ModBlocks;
import cuteneko.catsplus.effect.ModEffects;
import cuteneko.catsplus.item.ModItems;
import cuteneko.catsplus.item.group.ModItemGroups;
import cuteneko.catsplus.utility.Constants;
import dev.architectury.registry.registries.DeferredSupplier;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricLanguageProvider;
import net.minecraft.item.ItemGroup;

public class ModLangProviderZHCN extends FabricLanguageProvider {
public ModLangProviderZHCN(FabricDataOutput dataOutput) {
Expand All @@ -29,9 +32,15 @@ public void generateTranslations(TranslationBuilder builder) {
builder.add(Constants.MESSAGE_CATTIFY_LINGERING_POTION, "滞留型变猫药水");
builder.add(Constants.MESSAGE_CATTIFY_POTION_ARROW, "变猫药水箭");

builder.add(Constants.MESSAGE_CATS_GROUP_TITLE, "Cats+!");
builder.add(Constants.MESSAGE_CAT_BAG_NO_CAT, "空的。");
builder.add(Constants.MESSAGE_CAT_BAG_HAS_CAT, "内含猫猫!");
builder.add(Constants.MESSAGE_CAT_BAG_HAS_CAT_NAMED, "%1$s 在里面!");
builder.add(((DeferredSupplier<ItemGroup>) ModItemGroups.CATS_PLUS).getKey(), "Cats+!");
builder.add(Constants.MESSAGE_CAT_BAG_DESCRIPTION_NO_CAT, "空的。");
builder.add(Constants.MESSAGE_CAT_BAG_DESCRIPTION_HAS_CAT, "内含猫猫!");
builder.add(Constants.MESSAGE_CAT_BAG_DESCRIPTION_HAS_NAMED_CAT, "%1$s 在里面!");

builder.add(Constants.MESSAGE_CAT_SPIRIT_NAME, "%1$s 的灵魂");
builder.add(Constants.MESSAGE_CAT_SPIRIT_DESCRIPTION_MESSAGE, "");
builder.add(Constants.MESSAGE_CAT_SPIRIT_DESCRIPTION_TIME_LABEL, "卒于:");
builder.add(Constants.MESSAGE_CAT_SPIRIT_DESCRIPTION_TIME_PATTERN, "%1$s年%2$s月%3$s日 %4$s:%5$s:%6$s");
builder.add(Constants.MESSAGE_CAT_SPIRIT_DESCRIPTION_TIME_LONG_TIME_AGO, "很久以前");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ public interface ICatEntityMixin {
int catsplus$getLives();
void catsplus$setLives(int lives);

boolean catsplus$canRespawn();
void catsplus$setCanRespawn(boolean canRespawn);

boolean catsplus$isSongPlaying();
void catsplus$setSongPlaying(boolean playing);
BlockPos catsplus$getSongSource();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public abstract class CatEntityMixin implements ICatEntityMixin {
private int catsplus$lives = 0;
@Unique
private boolean catsplus$hasTotem = false;
@Unique
private boolean catsplus$canRespawn = false;

@Unique
private boolean catsplus$songPlaying = false;
Expand Down Expand Up @@ -70,16 +68,6 @@ public abstract class CatEntityMixin implements ICatEntityMixin {
catsplus$lives = lives;
}

@Override
public boolean catsplus$canRespawn() {
return catsplus$canRespawn;
}

@Override
public void catsplus$setCanRespawn(boolean canRespawn) {
catsplus$canRespawn = canRespawn;
}

@Override
public boolean catsplus$isSongPlaying() {
return catsplus$songPlaying;
Expand All @@ -106,7 +94,6 @@ private void write(NbtCompound nbt, CallbackInfo ci) {

tag.putInt(Constants.TAG_GENIUS_CAT_LIVES, catsplus$lives);
tag.putBoolean(Constants.TAG_GENIUS_CAT_TOTEM, catsplus$hasTotem);
tag.putBoolean(Constants.TAG_GENIUS_CAT_CAN_RESPAWN, catsplus$canRespawn);

var dancing = new NbtCompound();
dancing.putBoolean(Constants.TAG_GENIUS_CAT_DANCING_SOUND_PLAYING, catsplus$songPlaying);
Expand All @@ -131,7 +118,6 @@ private void read(NbtCompound nbt, CallbackInfo ci) {

catsplus$lives = tag.getInt(Constants.TAG_GENIUS_CAT_LIVES);
catsplus$hasTotem = tag.getBoolean(Constants.TAG_GENIUS_CAT_TOTEM);
catsplus$canRespawn = tag.getBoolean(Constants.TAG_GENIUS_CAT_CAN_RESPAWN);

var dancing = tag.getCompound(Constants.TAG_GENIUS_CAT_DANCING);
catsplus$songPlaying = dancing.getBoolean(Constants.TAG_GENIUS_CAT_DANCING_SOUND_PLAYING);
Expand Down
2 changes: 1 addition & 1 deletion catsplus-fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"cuteneko.catsplus.fabric.CatsPlusFabric"
],
"fabric-datagen": [
"cuteneko.catsplus.fabric.data.ModDataGen"
"cuteneko.catsplus.fabric.data.gen.ModDataGen"
]
},
"mixins": [
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ shadow_plugin_version=8.1.1
unified_publishing_version=0.1.+

# Architectury
enabled_platforms=fabric,forge,neoforge
enabled_platforms=forge,fabric,neoforge,quilt

# Mod
mod_version=0.1.7
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.20.4 2024-02-21T08:45:46.2924207 Cats+/Language (en_us)
8e251fab5ce5c3f45ea9ac58c25f48ec8466f03f assets\catsplus\lang\en_us.json
// 1.20.4 2024-02-21T21:09:29.4662143 Cats+/Language (en_us)
d6583927b847b4b2a3794090b7ac5fceccb13c82 assets\catsplus\lang\en_us.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.20.4 2024-02-21T08:45:46.2934204 Cats+/Language (zh_cn)
06df21f6ac57e8fe479a3cec1a60e08adbdf3cdb assets\catsplus\lang\zh_cn.json
// 1.20.4 2024-02-21T21:09:29.4682147 Cats+/Language (zh_cn)
7931bcf23f857507e9bead0a1e1f3d793d6d5915 assets\catsplus\lang\zh_cn.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.4 2024-02-21T08:45:46.2934204 Cats+/Recipes
// 1.20.4 2024-02-21T21:09:29.4682147 Cats+/Recipes
241ff3a315e1d01731c5b1b8f98108af0ab6656b data\catsplus\advancements\recipes\tools\cat_bag.json
10847e82ba25bc5c21abff40e303a1c023a77613 data\catsplus\recipes\totemeow.json
561f81e965a426c518aba9734d7fb823257b8eb5 data\catsplus\recipes\cat_bag.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.20.4 2024-02-21T08:45:46.2924207 Cats+/Model Definitions
// 1.20.4 2024-02-21T21:09:29.4682147 Cats+/Model Definitions
882a1bd93aa3b1750ec3f9e2176a49e5561f45a9 assets\catsplus\models\item\totemeow.json
15 changes: 10 additions & 5 deletions src/main/generated/assets/catsplus/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
"block.catsplus.cat_resurrection_station": "Cat Resurrection Station",
"effect.catsplus.cattify": "Cattify",
"item.catsplus.cat_bag": "Cat Bag",
"item.catsplus.cat_bag.has_cat": "Cat Inside!",
"item.catsplus.cat_bag.has_cat_named": "%1$s Inside!",
"item.catsplus.cat_bag.no_cat": "Empty.",
"item.catsplus.cat_bag.desc.has_cat": "Cat Inside!",
"item.catsplus.cat_bag.desc.has_named_cat": "%1$s Inside!",
"item.catsplus.cat_bag.desc.no_cat": "Empty.",
"item.catsplus.cat_spirit": "Cat Spirit",
"item.catsplus.cat_spirit.desc.long_time_ago": "Long time ago",
"item.catsplus.cat_spirit.desc.message": "",
"item.catsplus.cat_spirit.desc.time_label": "Dead at: ",
"item.catsplus.cat_spirit.desc.time_pattern": "%2$s/%3$s/%1$s %4$s:%5$s:%6$s",
"item.catsplus.cat_spirit.with_name": "Spirit of %1$s",
"item.catsplus.fang_luo": "Doll of Fang_Luo",
"item.catsplus.fang_luo.desc.1": "In memory of Fang_Luo, a girl who was passed away because of cancer.",
"item.catsplus.fang_luo.desc.2": "Rest in peace.",
"item.catsplus.fang_luo.desc.1": "In memory of Fang_Luo, a girl who passed away because of cancer.",
"item.catsplus.fang_luo.desc.2": "Rest in peace, my friend.",
"item.catsplus.totemeow": "Totemeow",
"item.minecraft.lingering_potion.effect.cattify": "Lingering Potion of Cattify",
"item.minecraft.potion.effect.cattify": "Potion of Cattify",
Expand Down
11 changes: 8 additions & 3 deletions src/main/generated/assets/catsplus/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
"block.catsplus.cat_resurrection_station": "猫咪复活台",
"effect.catsplus.cattify": "猫咪化",
"item.catsplus.cat_bag": "猫包",
"item.catsplus.cat_bag.has_cat": "内含猫猫!",
"item.catsplus.cat_bag.has_cat_named": "%1$s 在里面!",
"item.catsplus.cat_bag.no_cat": "空的。",
"item.catsplus.cat_bag.desc.has_cat": "内含猫猫!",
"item.catsplus.cat_bag.desc.has_named_cat": "%1$s 在里面!",
"item.catsplus.cat_bag.desc.no_cat": "空的。",
"item.catsplus.cat_spirit": "猫魂",
"item.catsplus.cat_spirit.desc.long_time_ago": "很久以前",
"item.catsplus.cat_spirit.desc.message": "",
"item.catsplus.cat_spirit.desc.time_label": "卒于:",
"item.catsplus.cat_spirit.desc.time_pattern": "%1$s年%2$s月%3$s日 %4$s:%5$s:%6$s",
"item.catsplus.cat_spirit.with_name": "%1$s 的灵魂",
"item.catsplus.fang_luo": "坊洛玩偶",
"item.catsplus.fang_luo.desc.1": "纪念因肿瘤离去的坊洛。",
"item.catsplus.fang_luo.desc.2": "缅怀……",
Expand Down
41 changes: 41 additions & 0 deletions src/main/java/cuteneko/catsplus/CatsPlusData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package cuteneko.catsplus;

import cuteneko.catsplus.data.ICatSpirit;
import cuteneko.catsplus.data.impl.CatSpirit;
import cuteneko.catsplus.item.ModItems;
import cuteneko.catsplus.data.ICatBag;
import cuteneko.catsplus.data.ICatPlayer;
import cuteneko.catsplus.data.IGeniusCat;
import cuteneko.catsplus.data.impl.CatBag;
import dev.architectury.injectables.annotations.ExpectPlatform;
import net.minecraft.entity.passive.CatEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;

public class CatsPlusData {
@ExpectPlatform
public static ICatPlayer getCatPlayer(PlayerEntity player) {
throw new UnsupportedOperationException();
}

@ExpectPlatform
public static IGeniusCat getGeniusCat(CatEntity cat) {
throw new UnsupportedOperationException();
}

public static ICatBag getCatBag(ItemStack bag) {
if (!bag.isOf(ModItems.CAT_BAG.get())) {
throw new IllegalArgumentException();
}

return new CatBag(bag);
}

public static ICatSpirit getCatSpirit(ItemStack spirit) {
if (!spirit.isOf(ModItems.CAT_SPIRIT.get())) {
throw new IllegalArgumentException();
}

return new CatSpirit(spirit);
}
}
Loading

0 comments on commit ee68a32

Please sign in to comment.