Skip to content

Commit

Permalink
好耶!
Browse files Browse the repository at this point in the history
  • Loading branch information
CSneko committed Nov 1, 2024
1 parent d1ac960 commit cae16bf
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ public AdventurerNeko(EntityType<? extends NekoEntity> entityType, Level level)
super(entityType, level);
}

@Override
public String getSkin() {
// 你问我为啥要这样干? 啊我也不知道我为啥要这样干
String u = this.uuid.toString();
if (u.startsWith("a") || u.startsWith("b") || u.startsWith("c") || u.startsWith("d")
|| u.startsWith("e") || u.startsWith("f")
){
return "aquarter";
}
return "grmmy";
}

@Override
public Set<Item> getFavoriteItems() {
Set<Item> i = super.getFavoriteItems();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,55 +64,56 @@ public abstract class NekoEntity extends AgeableMob implements GeoEntity, INeko
private final AnimatableInstanceCache cache;
private boolean isSitting = false;

public static final EntityDataAccessor<String> SKIN_DATA_ID = SynchedEntityData.defineId(NekoEntity.class, EntityDataSerializers.STRING);
//public static final EntityDataAccessor<String> SKIN_DATA_ID = SynchedEntityData.defineId(NekoEntity.class, EntityDataSerializers.STRING);

public NekoEntity(EntityType<? extends NekoEntity> entityType, Level level) {
super(entityType, level);
NekoQuery.getNeko(this.getUUID()).setNeko(true);
this.cache = GeckoLibUtil.createInstanceCache(this);
randomize(new CompoundTag());
}

@Override
public void readAdditionalSaveData(@NotNull CompoundTag nbt) {
super.readAdditionalSaveData(nbt);
if(nbt.contains("Skin")) {
this.setSkin(nbt.getString("Skin"));
}
randomize(nbt);
}
// @Override
// public void readAdditionalSaveData(@NotNull CompoundTag nbt) {
// super.readAdditionalSaveData(nbt);
// if(nbt.contains("Skin")) {
// this.setSkin(nbt.getString("Skin"));
// }
// randomize(nbt);
// }

// @Override
// public void addAdditionalSaveData(@NotNull CompoundTag nbt) {
// super.addAdditionalSaveData(nbt);
// nbt.putString("Skin", getSkin());
// }

@Override
public @NotNull CompoundTag saveWithoutId(CompoundTag compound) {
compound.putString("Skin", getSkin());
return super.saveWithoutId(compound);
}

@Override
public void load(@NotNull CompoundTag nbt) {
super.load(nbt);
if (nbt.contains("Skin")) {
this.setSkin(nbt.getString("Skin"));
}
}
// @Override
// public @NotNull CompoundTag saveWithoutId(CompoundTag compound) {
// compound.putString("Skin", getSkin());
// return super.saveWithoutId(compound);
// }

@Override
protected void defineSynchedData(SynchedEntityData.@NotNull Builder builder) {
super.defineSynchedData(builder);
builder.define(SKIN_DATA_ID,this.getSkin());
}
// @Override
// public void load(@NotNull CompoundTag nbt) {
// super.load(nbt);
// if (nbt.contains("Skin")) {
// this.setSkin(nbt.getString("Skin"));
// }
// }

public void onSyncedDataUpdated(EntityDataAccessor<?> dataAccessor) {
if (dataAccessor.equals(SKIN_DATA_ID)) {
this.setSkin(getEntityData().get(SKIN_DATA_ID));
}
super.onSyncedDataUpdated(dataAccessor);
}
// @Override
// protected void defineSynchedData(SynchedEntityData.@NotNull Builder builder) {
// super.defineSynchedData(builder);
// builder.define(SKIN_DATA_ID,this.getSkin());
// }
//
// public void onSyncedDataUpdated(EntityDataAccessor<?> dataAccessor) {
// if (dataAccessor.equals(SKIN_DATA_ID)) {
// this.setSkin(getEntityData().get(SKIN_DATA_ID));
// }
// super.onSyncedDataUpdated(dataAccessor);
// }

public void randomize(CompoundTag nbt){
// 设置名字(如果没有)
Expand Down Expand Up @@ -168,13 +169,15 @@ public GoalSelector getGoalSelector() {
return this.goalSelector;
}

public String getSkin() {
if (this.entityData == null)
return this.getRandomSkin();
return this.entityData.get(SKIN_DATA_ID);
}
// public String getSkin() {
//// if (this.entityData == null)
//// return this.getRandomSkin();
//// return this.entityData.get(SKIN_DATA_ID);
// return
// }
public abstract String getSkin();
public void setSkin(String skin) {
this.entityData.set(SKIN_DATA_ID, skin);
//this.entityData.set(SKIN_DATA_ID, skin);
}
public String getRandomSkin(){
return NekoSkinRegistry.getRandomSkin(this.getType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ public <T extends LivingEntity> HumanoidModel<?> getGeoArmorRenderer(@Nullable T

public static class NekoTailItem extends NekoArmor<NekoTailItem> {
public static final String ID = "neko_tail";
public NekoTailItem() {
super(ToNekoArmorMaterials.NEKO,Type.CHESTPLATE,new Properties().stacksTo(1));
public NekoTailItem(Holder<ArmorMaterial> material) {
super(material,Type.CHESTPLATE,new Properties().stacksTo(1));
}

@Override
Expand All @@ -111,8 +111,8 @@ public InteractionResultHolder<ItemStack> swapWithEquipmentSlot(Item item, Level

public static class NekoEarsItem extends NekoArmor<NekoEarsItem> {
public static final String ID = "neko_ears";
public NekoEarsItem() {
super(ToNekoArmorMaterials.NEKO,Type.HELMET,new Properties().stacksTo(1));
public NekoEarsItem(Holder<ArmorMaterial> material) {
super(material,Type.HELMET,new Properties().stacksTo(1));
}

@Override
Expand All @@ -124,8 +124,8 @@ public NekoArmorRenderer.NekoEarsRenderer getRenderer() {

public static class NekoPawsItem extends NekoArmor<NekoPawsItem> {
public static final String ID = "neko_paws";
public NekoPawsItem() {
super(ToNekoArmorMaterials.NEKO,Type.BOOTS,new Properties().stacksTo(1));
public NekoPawsItem(Holder<ArmorMaterial> material) {
super(material,Type.BOOTS,new Properties().stacksTo(1));
}

@Override
Expand Down
7 changes: 1 addition & 6 deletions fabric/src/main/java/org/cneko/toneko/fabric/ToNeko.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
import org.cneko.toneko.common.Bootstrap;
import org.cneko.toneko.common.mod.ModMeta;
import org.cneko.toneko.common.mod.commands.NekoCommand;
Expand All @@ -13,12 +12,8 @@
import org.cneko.toneko.common.mod.events.ToNekoNetworkEvents;
import org.cneko.toneko.common.mod.impl.FabricConfigImpl;
import org.cneko.toneko.common.mod.impl.FabricLanguageImpl;
import org.cneko.toneko.common.mod.items.ToNekoArmorMaterials;
import org.cneko.toneko.common.mod.packets.EntityPosePayload;
import org.cneko.toneko.fabric.items.ToNekoArmorMaterials;
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.common.mod.packets.QuirkQueryPayload;
import org.cneko.toneko.common.mod.quirks.ToNekoQuirks;
import org.cneko.toneko.common.mod.util.PermissionUtil;
import org.cneko.toneko.common.util.ConfigUtil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static void init() {
}
public static class NekoTailTrinketItem extends NekoArmor.NekoTailItem implements Trinket {
public NekoTailTrinketItem() {
super();
super(ToNekoArmorMaterials.NEKO);
}
@Override
public boolean canEquipFromUse(ItemStack stack, LivingEntity entity) {
Expand All @@ -55,7 +55,7 @@ public Multimap<Holder<Attribute>, AttributeModifier> getModifiers(ItemStack sta

public static class NekoEarsTrinketItem extends NekoArmor.NekoEarsItem implements Trinket{
public NekoEarsTrinketItem() {
super();
super(ToNekoArmorMaterials.NEKO);
}
@Override
public boolean canEquipFromUse(ItemStack stack, LivingEntity entity) {
Expand All @@ -75,7 +75,7 @@ public Multimap<Holder<Attribute>, AttributeModifier> getModifiers(ItemStack sta
}
public static class NekoPawsTrinketItem extends NekoArmor.NekoPawsItem implements Trinket {
public NekoPawsTrinketItem() {
super();
super(ToNekoArmorMaterials.NEKO);
}
@Override
public boolean canEquipFromUse(ItemStack stack, LivingEntity entity) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.cneko.toneko.common.mod.items;
package org.cneko.toneko.fabric.items;

import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
Expand All @@ -10,7 +10,6 @@
import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.ArmorMaterial;
import net.minecraft.world.item.crafting.Ingredient;
import org.cneko.toneko.common.util.ConfigUtil;

import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public static void registerWithOutConfig() {
if (isTrinketsInstalled){
NekoArmorTrinkets.init();
}else {
NEKO_EARS = new NekoArmor.NekoEarsItem();
NEKO_TAIL = new NekoArmor.NekoTailItem();
NEKO_PAWS = new NekoArmor.NekoPawsItem();
NEKO_EARS = new NekoArmor.NekoEarsItem(ToNekoArmorMaterials.NEKO);
NEKO_TAIL = new NekoArmor.NekoTailItem(ToNekoArmorMaterials.NEKO);
NEKO_PAWS = new NekoArmor.NekoPawsItem(ToNekoArmorMaterials.NEKO);
}
Registry.register(BuiltInRegistries.ITEM, ResourceLocation.fromNamespaceAndPath(MODID, NekoArmor.NekoEarsItem.ID), NEKO_EARS);
Registry.register(BuiltInRegistries.ITEM, ResourceLocation.fromNamespaceAndPath(MODID, NekoArmor.NekoTailItem.ID), NEKO_TAIL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public static DeferredHolder<ArmorMaterial,ArmorMaterial> register(
// Register the material within the ArmorMaterials registry.
DeferredHolder<ArmorMaterial,ArmorMaterial> materialHolder = ToNekoNeoForge.ARMOR_MATERIALS.register(id, () -> material);

// 大多数时候,您会需要材质的 RegistryEntry - 尤其是对于 ArmorItem 构造函数。
return materialHolder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ public static void registerWithOutConfig() {

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

NEKO_EARS_HOLDER = ITEMS.register(NekoArmor.NekoEarsItem.ID, NekoArmor.NekoEarsItem::new);
NEKO_EARS_HOLDER = ITEMS.register(NekoArmor.NekoEarsItem.ID, ()->new NekoArmor.NekoEarsItem(ToNekoArmorMaterials.NEKO));

NEKO_TAIL_HOLDER = ITEMS.register(NekoArmor.NekoTailItem.ID, NekoArmor.NekoTailItem::new);
NEKO_TAIL_HOLDER = ITEMS.register(NekoArmor.NekoTailItem.ID, ()->new NekoArmor.NekoTailItem(ToNekoArmorMaterials.NEKO));

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

ITEMS.register(NekoArmor.NekoPawsItem.ID, NekoArmor.NekoPawsItem::new); // 此物品暂不添加
ITEMS.register(NekoArmor.NekoPawsItem.ID, ()->new NekoArmor.NekoPawsItem(ToNekoArmorMaterials.NEKO)); // 此物品暂不添加
// 注册物品组
TONEKO_ITEM_GROUP_HOLDER = ToNekoNeoForge.CREATIVE_MODE_TABS.register("toneko_group", ()-> CreativeModeTab.builder()
.icon(()->NEKO_EARS_HOLDER.get().getDefaultInstance())
Expand Down

0 comments on commit cae16bf

Please sign in to comment.