Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

LYXHAHA

Members
  • Posts

    6
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • URL
    writingwithfire.net
  • Location
    China
  • Personal Text
    I'm a Chinese modder, and I am not good at English. If my way of expression makes you feel uncomfortable, Please don't care, I just don’t know how to express it in English politely. Thinks for your help

Recent Profile Visitors

145 profile views

LYXHAHA's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I have found the answer, use serializeNBT#getInt can get right data, Is it because the data storage in the CapabilityProvider?
  2. Every time you restart the game or re-enter the map, the capability is reset. I don’t know if this is a problem with my code or is it the way it is. public class CapabilityAttachHandler { public CapabilityAttachHandler() {} public static void capabilityAttachHandler(AttachCapabilitiesEvent<Entity> event) { Entity entity = event.getObject(); if (entity instanceof PlayerEntity){ if (!entity.getCapability(LibCapabilities.MIND_CAPABILITY).isPresent()) { event.addCapability(SaintChapter.key("mind_strength"), new MindCapabilityProvider()); SaintChapter.LOGGER.info("Mind Capability attached"); } if (!entity.getCapability(LibCapabilities.SOUL_CAPABILITY).isPresent()){ event.addCapability(SaintChapter.key("soul_strength"), new SoulCapabilityProvider()); SaintChapter.LOGGER.info("Player Soul Capability attached"); } } if (entity instanceof MobEntity) { if (!entity.getCapability(LibCapabilities.SOUL_CAPABILITY).isPresent()){ event.addCapability(SaintChapter.key("soul_strength"), new SoulCapabilityProvider()); SaintChapter.LOGGER.info("Mob Soul Capability attached"); } } } } public interface ISoulCapability extends INBTSerializable<CompoundNBT> { int getSoulStrength (); boolean getInitialized(); } public class SoulCapability implements ISoulCapability { private int soulStrength; private boolean initialized; public SoulCapability(int soulStrength, boolean isInitialized) { this.soulStrength = soulStrength; this.initialized = isInitialized; } @Override public boolean getInitialized() { return this.initialized; } @Override public int getSoulStrength() { return soulStrength; } @Override public CompoundNBT serializeNBT() { CompoundNBT compoundNBT = new CompoundNBT(); compoundNBT.putInt("soulStrength", this.soulStrength); compoundNBT.putBoolean("initialized", this.initialized); return compoundNBT; } @Override public void deserializeNBT(CompoundNBT nbt) { this.soulStrength = nbt.getInt("soulStrength"); this.initialized = nbt.getBoolean("initialized"); } } public class SoulCapabilityProvider implements ICapabilityProvider, INBTSerializable<CompoundNBT> { private ISoulCapability soulCapability; @Nonnull @Override public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) { return cap == LibCapabilities.SOUL_CAPABILITY ? LazyOptional.of(this::getOrCreateCapability).cast() : LazyOptional.empty(); } @Nonnull private ISoulCapability getOrCreateCapability() { if (soulCapability == null) { this.soulCapability = new SoulCapability(888, false); } return this.soulCapability; } @Override public CompoundNBT serializeNBT() { return getOrCreateCapability().serializeNBT(); } @Override public void deserializeNBT(CompoundNBT nbt) { getOrCreateCapability().deserializeNBT(nbt); } }
  3. As the title said, I want to set NBT data tags for the recipe's output item.
  4. Access Transformers need SRG name of fields and methods. but I don't konw how to find them
  5. public class SCRecipeProvider extends RecipeProvider { public SCRecipeProvider(DataGenerator generator) { super(generator); } @Override protected void registerRecipes(@Nonnull Consumer<IFinishedRecipe> registrar) { VanillaTypeRecipeProvider.registerCookingRecipes(registrar); VanillaTypeRecipeProvider.registerCustomRecipes(registrar); registerShapedRecipes(registrar); VanillaTypeRecipeProvider.registerStoneCutterRecipes(registrar); } public static void registerShapedRecipes(Consumer<IFinishedRecipe> registrar) { ShapedRecipeBuilder.shapedRecipe(Objects.requireNonNull(ForgeRegistries.ITEMS.getValue(new ResourceLocation(SaintChapter.MODID, "book_of_truth")))) .patternLine("MMM") .patternLine("MBM") .patternLine("MMM") .key('M', RegistryItems.MIND_CRYSTAL.get()) .key('B', Items.BOOK) .addCriterion("has_item", hasItem(RegistryItems.MIND_CRYSTAL.get())) .build(registrar); } } I think it’s because Patchouli’s book was not registered during the data generation stage. But i don't know how to solve this problem. ForgeRegistries.ITEMS.getValue(new ResourceLocation(SaintChapter.MODID, "book_of_truth") This should return nothing, cause Patchouli’s book is registered to my mod's namespace during it is loaded, Patchouli API may not be loaded during the data generation stage. Sorry, I'm not good at English. I hope my statement is correct.
  6. I'm a Chinese modder, and I use language provider to provide the Chinese language file. This is the problem I encountered. The language file provided by LanguageProvider does not display Chinese correctly. there is my code public class SCLanguageProvider_en_us extends net.minecraftforge.common.data.LanguageProvider { public SCLanguageProvider_en_us(DataGenerator gen, String modid, String locale) { super(gen, modid, locale); } @Override protected void addTranslations() { add(RegistryItems.REVELATION_SCROLL.get(), "Try English: This is en_us"); add(RegistryItems.MIND_CRYSTAL.get(), "Try Chinese: 这是中文"); } } and there is the output { "item.saintchapter.mind_crystal": "Try Chinese: \u6769\u6B10\u69F8\u6D93\uE15F\u6783", "item.saintchapter.revelation_scroll": "Try English: This is en_us" } You can see the Chinese part is output as "\u6769\u6B10\u69F8\u6D93\uE15F\u6783" 😭I am not good at English, I hope my expression is correct.
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.