Skip to content

Commit

Permalink
哈啊♡~
Browse files Browse the repository at this point in the history
  • Loading branch information
CSneko committed Oct 26, 2024
1 parent 5def2c7 commit 9674c79
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 58 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'dev.architectury.loom' version '1.6-SNAPSHOT' apply false
id 'dev.architectury.loom' version '1.7-SNAPSHOT' apply false
id 'architectury-plugin' version '3.4-SNAPSHOT'
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package org.cneko.toneko.common.mod.entities;

import dev.architectury.injectables.annotations.ExpectPlatform;
import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
import net.fabricmc.fabric.api.biome.v1.BiomeSelectors;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityType;
import net.minecraft.core.DefaultedRegistry;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.level.biome.Biome;
Expand All @@ -20,52 +23,12 @@
import static org.cneko.toneko.common.Bootstrap.MODID;

public class ToNekoEntities {
private static final TagKey<Biome> IS_MOUNTAIN = TagKey.create(Registries.BIOME, ResourceLocation.fromNamespaceAndPath("c","is_mountain"));

public static final EntityType<AdventurerNeko> ADVENTURER_NEKO = Registry.register(
BuiltInRegistries.ENTITY_TYPE,
ResourceLocation.fromNamespaceAndPath(MODID,"adventurer_neko"),
FabricEntityType.Builder.createMob(AdventurerNeko::new, MobCategory.CREATURE, builder -> builder.defaultAttributes(AdventurerNeko::createAdventurerNekoAttributes)
// .spawnRestriction(SpawnPlacementTypes.ON_GROUND, Heightmap.Types.MOTION_BLOCKING, AdventurerNeko::checkMobSpawnRules)
).
sized(0.5f,1.7f).eyeHeight(1.6f).build()
);
public static final EntityType<CrystalNekoEntity> CRYSTAL_NEKO = Registry.register(
BuiltInRegistries.ENTITY_TYPE,
ResourceLocation.fromNamespaceAndPath(MODID,"crystal_neko"),
FabricEntityType.Builder.createMob(CrystalNekoEntity::new, MobCategory.CREATURE, builder -> builder.defaultAttributes(CrystalNekoEntity::createNekoAttributes)
// .spawnRestriction(SpawnPlacementTypes.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, CrystalNekoEntity::checkCrystalNekoSpawnRules)
)
.sized(0.5f,1.7f).eyeHeight(1.6f).clientTrackingRange(8).build()
);
public static EntityType<AdventurerNeko> ADVENTURER_NEKO;
public static EntityType<CrystalNekoEntity> CRYSTAL_NEKO;

public static void init() {
// 注册皮肤
NekoSkinRegistry.register(ADVENTURER_NEKO,AdventurerNeko.nekoSkins);
// 注册名字
Set<String> names = Set.of(
"Luna","Mochi","Poppy","Misty","Snowy","Coco","Peaches","Bubbles","Daisy","Cherry",
"ひなた","もふこ","ちゃちゃまる","ひめにゃん",
"Felicity","Purrin","Catrina","Fluffy","Meowgical","Felina","Ayame","Cinnamon","Momo"
);
NekoNameRegistry.register(names);

/*
不知道为什么喵,我测试的时候总是不生成,真的好奇怪的问题
后来测试了很多次喵,都没生成
这个我也是改来改去的喵,就是很奇怪
哪怕我看了其它模组的代码,和我的似乎也差不多,但是我的就是不生成喵
太她喵的奇怪了!
但是喵...
重新创建了个世界,它生成了喵!好逆天的Bug喵!
*/
// 设置生成条件
BiomeModifications.addSpawn(BiomeSelectors.foundInOverworld(), MobCategory.CREATURE, ADVENTURER_NEKO, 5, 1, 1); // 在主世界的高山会生成一只

if (ConfigUtil.IS_BIRTHDAY){
BiomeModifications.addSpawn(BiomeSelectors.all(), MobCategory.CREATURE, CRYSTAL_NEKO, 10, 1, 4); // 在所有世界生成一只
// SpawnPlacements.register(CRYSTAL_NEKO, SpawnPlacementTypes.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, CrystalNekoEntity::checkMobSpawnRules);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.ai.attributes.RangedAttribute;
import org.jetbrains.annotations.NotNull;

import static org.cneko.toneko.common.Bootstrap.MODID;

public class ToNekoAttributes {
public static final ResourceLocation NEKO_DEGREE_ID = ResourceLocation.fromNamespaceAndPath(MODID, "neko.degree");
public static final Holder<Attribute> NEKO_DEGREE = register(NEKO_DEGREE_ID,
public static final @NotNull Holder<Attribute> NEKO_DEGREE = register(NEKO_DEGREE_ID,
new RangedAttribute("attribute.name.neko.degree",
1.0, 0.0, 100.0
).setSyncable(true)
);

@ExpectPlatform
public static Holder<Attribute> register(ResourceLocation id, Attribute attribute) {
return null;
public static @NotNull Holder<Attribute> register(ResourceLocation id, Attribute attribute) {
throw new AssertionError();
}

public static void init() {

}
}
2 changes: 1 addition & 1 deletion fabric/src/main/java/org/cneko/toneko/fabric/ToNeko.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.cneko.toneko.common.mod.util.PermissionUtil;
import org.cneko.toneko.common.util.ConfigUtil;
import org.cneko.toneko.common.util.LanguageUtil;
import org.cneko.toneko.common.mod.entities.ToNekoEntities;
import org.cneko.toneko.fabric.entities.ToNekoEntities;
import org.cneko.toneko.fabric.items.ToNekoItems;
import org.cneko.toneko.common.mod.misc.ToNekoAttributes;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package org.cneko.toneko.fabric.entities;

import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
import net.fabricmc.fabric.api.biome.v1.BiomeSelectors;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityType;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import org.cneko.toneko.common.mod.api.NekoNameRegistry;
import org.cneko.toneko.common.mod.api.NekoSkinRegistry;
import org.cneko.toneko.common.mod.entities.AdventurerNeko;
import org.cneko.toneko.common.mod.entities.CrystalNekoEntity;
import org.cneko.toneko.common.util.ConfigUtil;

import java.util.Set;

import static org.cneko.toneko.common.Bootstrap.MODID;
import static org.cneko.toneko.common.mod.entities.ToNekoEntities.*;

public class ToNekoEntities {
public static void init(){
ADVENTURER_NEKO = Registry.register(
BuiltInRegistries.ENTITY_TYPE,
ResourceLocation.fromNamespaceAndPath(MODID,"adventurer_neko"),
FabricEntityType.Builder.createMob(AdventurerNeko::new, MobCategory.CREATURE, builder -> builder.defaultAttributes(AdventurerNeko::createAdventurerNekoAttributes)
).
sized(0.5f,1.7f).eyeHeight(1.6f).build()
);
CRYSTAL_NEKO = Registry.register(
BuiltInRegistries.ENTITY_TYPE,
ResourceLocation.fromNamespaceAndPath(MODID,"crystal_neko"),
FabricEntityType.Builder.createMob(CrystalNekoEntity::new, MobCategory.CREATURE, builder -> builder.defaultAttributes(CrystalNekoEntity::createNekoAttributes)
)
.sized(0.5f,1.7f).eyeHeight(1.6f).clientTrackingRange(8).build()
);

// 注册皮肤
NekoSkinRegistry.register(ADVENTURER_NEKO,AdventurerNeko.nekoSkins);
// 注册名字
Set<String> names = Set.of(
"Luna","Mochi","Poppy","Misty","Snowy","Coco","Peaches","Bubbles","Daisy","Cherry",
"ひなた","もふこ","ちゃちゃまる","ひめにゃん",
"Felicity","Purrin","Catrina","Fluffy","Meowgical","Felina","Ayame","Cinnamon","Momo"
);
NekoNameRegistry.register(names);

/*
不知道为什么喵,我测试的时候总是不生成,真的好奇怪的问题
后来测试了很多次喵,都没生成
这个我也是改来改去的喵,就是很奇怪
哪怕我看了其它模组的代码,和我的似乎也差不多,但是我的就是不生成喵
太她喵的奇怪了!
但是喵...
重新创建了个世界,它生成了喵!好逆天的Bug喵!
*/
// 设置生成条件
BiomeModifications.addSpawn(BiomeSelectors.foundInOverworld(), MobCategory.CREATURE, ADVENTURER_NEKO, 5, 1, 1); // 在主世界的高山会生成一只

if (ConfigUtil.IS_BIRTHDAY){
BiomeModifications.addSpawn(BiomeSelectors.all(), MobCategory.CREATURE, CRYSTAL_NEKO, 10, 1, 4); // 在所有世界生成一只
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.ArmorMaterial;
import net.minecraft.world.item.CreativeModeTab;
import net.neoforged.bus.api.IEventBus;
Expand All @@ -20,6 +21,8 @@
import org.cneko.toneko.common.mod.packets.ToNekoPackets;
import org.cneko.toneko.common.mod.packets.VehicleStopRidePayload;
import org.cneko.toneko.common.mod.packets.interactives.*;
import org.cneko.toneko.neoforge.client.ToNekoNeoForgeClient;
import org.cneko.toneko.neoforge.entities.ToNekoEntities;
import org.cneko.toneko.neoforge.msic.ToNekoAttributes;
import org.cneko.toneko.neoforge.items.ToNekoArmorMaterials;
import org.cneko.toneko.neoforge.items.ToNekoItems;
Expand All @@ -35,18 +38,21 @@ public final class ToNekoNeoForge {
public static final DeferredRegister<ArmorMaterial> ARMOR_MATERIALS = DeferredRegister.create(Registries.ARMOR_MATERIAL, MODID);
public static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MODID);
public static final DeferredRegister<Attribute> ATTRIBUTES = DeferredRegister.create(Registries.ATTRIBUTE, MODID);
public static final DeferredRegister<EntityType<?>> ENTITY_TYPES = DeferredRegister.create(Registries.ENTITY_TYPE, MODID);
public ToNekoNeoForge(IEventBus bus, ModContainer container) {
ITEMS.register(bus);
DATA_COMPONENTS.register(bus);
ARMOR_MATERIALS.register(bus);
ATTRIBUTES.register(bus);
ENTITY_TYPES.register(bus);
// 注册装备
ToNekoArmorMaterials.init();
ToNekoItems.init();
bus.addListener(ToNekoItems::buildContents);
ToNekoAttributes.init();
bus.addListener(ToNekoAttributes::onRegisterAttributes);
ToNekoEvents.init();
ToNekoEntities.init();

// 注册网络数据包
ToNekoPackets.init();
Expand All @@ -56,7 +62,5 @@ public ToNekoNeoForge(IEventBus bus, ModContainer container) {
NekoCommand.init();
QuirkCommand.init();
ToNekoAdminCommand.init();


}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.cneko.toneko.neoforge.entities;

import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityType;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.neoforged.neoforge.registries.DeferredHolder;
import org.cneko.toneko.common.mod.api.NekoNameRegistry;
import org.cneko.toneko.common.mod.api.NekoSkinRegistry;
import org.cneko.toneko.common.mod.entities.AdventurerNeko;
import org.cneko.toneko.common.mod.entities.CrystalNekoEntity;
import org.cneko.toneko.neoforge.ToNekoNeoForge;

import java.util.Set;

import static org.cneko.toneko.common.mod.entities.ToNekoEntities.*;
public class ToNekoEntities {
public static DeferredHolder<EntityType<?>, EntityType<?>> CRYSTAL_NEKO_HOLDER;
public static DeferredHolder<EntityType<?>, EntityType<?>> ADVENTURER_NEKO_HOLDER;
public static void init(){
CRYSTAL_NEKO_HOLDER = ToNekoNeoForge.ENTITY_TYPES.register("crystal_neko",
()-> EntityType.Builder.of(CrystalNekoEntity::new, MobCategory.CREATURE)
.sized(0.5f,1.7f).eyeHeight(1.6f).clientTrackingRange(8)
.build("crystal_neko")
);
ADVENTURER_NEKO_HOLDER = ToNekoNeoForge.ENTITY_TYPES.register("adventurer_neko",
()-> EntityType.Builder.of(AdventurerNeko::new, MobCategory.CREATURE)
.sized(0.5f,1.7f).eyeHeight(1.6f).clientTrackingRange(8)
.build("adventurer_neko")
);

// 注册皮肤
NekoSkinRegistry.register(ADVENTURER_NEKO,AdventurerNeko.nekoSkins);
// 注册名字
Set<String> names = Set.of(
"Luna","Mochi","Poppy","Misty","Snowy","Coco","Peaches","Bubbles","Daisy","Cherry",
"ひなた","もふこ","ちゃちゃまる","ひめにゃん",
"Felicity","Purrin","Catrina","Fluffy","Meowgical","Felina","Ayame","Cinnamon","Momo"
);
NekoNameRegistry.register(names);


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import org.cneko.toneko.common.mod.items.NekoCollectorItem;
import org.cneko.toneko.common.mod.items.NekoPotionItem;
import org.cneko.toneko.common.util.ConfigUtil;
import org.cneko.toneko.neoforge.ToNekoNeoForge;

import static org.cneko.toneko.common.mod.items.ToNekoItems.*;

import java.util.function.Supplier;
Expand All @@ -29,7 +31,14 @@ public class ToNekoItems {

public static ResourceKey<CreativeModeTab> TONEKO_ITEM_GROUP_KEY;
public static Supplier<CreativeModeTab> TONEKO_ITEM_GROUP;
public static DeferredSpawnEggItem ADVENTURER_NEKO_SPAWN_EGG;
public static DeferredHolder<Item,DeferredSpawnEggItem> ADVENTURER_NEKO_SPAWN_EGG_HOLDER;
public static DeferredHolder<Item,NekoPotionItem> NEKO_POTION_HOLDER;
public static DeferredHolder<Item,NekoCollectorItem> NEKO_COLLECTOR_HOLDER;
public static DeferredHolder<Item,FurryBoheItem> FURRY_BOHE_HOLDER;
public static DeferredHolder<Item,NekoArmor.NekoEarsItem> NEKO_EARS_HOLDER;
public static DeferredHolder<Item,NekoArmor.NekoTailItem> NEKO_TAIL_HOLDER;
public static DeferredHolder<CreativeModeTab,CreativeModeTab> TONEKO_ITEM_GROUP_HOLDER;

public static void init() {
registerWithOutConfig();
}
Expand All @@ -38,19 +47,31 @@ public static void init() {
* 强制注册物品,无论配置文件如何设置
*/
public static void registerWithOutConfig() {
NEKO_POTION = ITEMS.register(NekoPotionItem.ID, NekoPotionItem::new).get();
NEKO_COLLECTOR = ITEMS.register(NekoCollectorItem.ID, NekoCollectorItem::new).get();
FURRY_BOHE = ITEMS.register(FurryBoheItem.ID, FurryBoheItem::new).get();
NEKO_POTION_HOLDER = ITEMS.register(NekoPotionItem.ID, NekoPotionItem::new);
//NEKO_POTION = NEKO_POTION_HOLDER.get();

NEKO_COLLECTOR_HOLDER = ITEMS.register(NekoCollectorItem.ID, NekoCollectorItem::new);
//NEKO_COLLECTOR = NEKO_COLLECTOR_HOLDER.get();

FURRY_BOHE_HOLDER = ITEMS.register(FurryBoheItem.ID, FurryBoheItem::new);
//FURRY_BOHE = FURRY_BOHE_HOLDER.get();

NEKO_EARS_HOLDER = ITEMS.register(NekoArmor.NekoEarsItem.ID, NekoArmor.NekoEarsItem::new);
//NEKO_EARS = NEKO_EARS_HOLDER.get();

NEKO_EARS = ITEMS.register(NekoArmor.NekoEarsItem.ID, NekoArmor.NekoEarsItem::new).get();
NEKO_TAIL = ITEMS.register(NekoArmor.NekoTailItem.ID,NekoArmor.NekoTailItem::new).get();
NEKO_TAIL_HOLDER = ITEMS.register(NekoArmor.NekoTailItem.ID,NekoArmor.NekoTailItem::new);
//NEKO_TAIL = NEKO_TAIL_HOLDER.get();

ADVENTURER_NEKO_SPAWN_EGG = ITEMS.register("adventurer_neko_spawn_egg",()->new DeferredSpawnEggItem(()->ToNekoEntities.ADVENTURER_NEKO, 0x7e7e7e, 0xffffff,new Item.Properties())).get();
ADVENTURER_NEKO_SPAWN_EGG_HOLDER = ITEMS.register("adventurer_neko_spawn_egg",()->new DeferredSpawnEggItem(()->ToNekoEntities.ADVENTURER_NEKO, 0x7e7e7e, 0xffffff,new Item.Properties()));

ITEMS.register(NekoArmor.NekoPawsItem.ID, NekoArmor.NekoPawsItem::new); // 此物品暂不添加
// 注册物品组
TONEKO_ITEM_GROUP_KEY = ResourceKey.create(BuiltInRegistries.CREATIVE_MODE_TAB.key(), ResourceLocation.fromNamespaceAndPath(MODID, "item_group"));
Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, TONEKO_ITEM_GROUP_KEY,TONEKO_ITEM_GROUP.get());
TONEKO_ITEM_GROUP_HOLDER = ToNekoNeoForge.CREATIVE_MODE_TABS.register("toneko_group", ()-> CreativeModeTab.builder()
.icon(()->NEKO_EARS_HOLDER.get().getDefaultInstance())
.title(Component.translatable("itemGroup.toneko"))
.build()
);
}

public static boolean tryClass(String clazz){
Expand All @@ -70,6 +91,7 @@ public static void buildContents(BuildCreativeModeTabContentsEvent event) {
event.accept(FURRY_BOHE);
event.accept(NEKO_EARS);
event.accept(NEKO_TAIL);
event.accept(ADVENTURER_NEKO_SPAWN_EGG_HOLDER.get());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
public class ToNekoAttributes {

public static void init(){
org.cneko.toneko.common.mod.misc.ToNekoAttributes.init();
}


Expand Down

0 comments on commit 9674c79

Please sign in to comment.