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


  • Posts

  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

hammy3502's Achievements

Tree Puncher

Tree Puncher (2/8)



  1. Nevermind, I was able to wrap my mind around https://forge.gemwire.uk/wiki/Capabilities#Accessing_a_Capability , and currently have it working!
  2. Hello! I'm trying to create a capability that reads a player's CompoundTag, and extracts some custom mod data from it to assemble an object, along with being given one of those mod objects and writing it to a Player's nbt. I've hopefully created the capability correctly, but I'm not sure how to go about having a `Player` read/write this data during a world save, and how I can go about retrieving the data from a given `Player` object on world join (I know I'd need to subscribe to the event, but I have no idea what I'd do from there). Additionally, this code results in "Invalid player data" whenever I join a world, and I don't know what's in here causes that (EDIT: Figured out this was due to my own bad serialization code. Does this mean that the NBT is automatically loaded on world join and saved on world leave?). My full repository can be found here: https://github.com/hammy3502/elementalism , and the relevant code snippets are below: Object with Custom Mod Data (PlayerProgressionData.java): public class PlayerProgressionData implements INBTSerializable<CompoundTag> { public static final String outerTag = "elementalism_data"; public ProgressionInfo.ElementType type; public ProgressionInfo.ElementType type2; public List<ProgressionInfo> powersUnlocked; public PlayerProgressionData() { this.type = ProgressionInfo.ElementType.NONE; this.type2 = ProgressionInfo.ElementType.NONE; this.powersUnlocked = new ArrayList<>(); } @Override public CompoundTag serializeNBT() { CompoundTag toRet = new CompoundTag(); CompoundTag data = new CompoundTag(); StringBuilder powersList = new StringBuilder(); for (int i = 0; i < powersUnlocked.size(); i++) { powersList.append(powersUnlocked.get(i).id); if (i != powersUnlocked.size() - 1) { powersList.append(","); } } data.putString("unlockedPowers", powersList.toString()); data.putString("element1", this.type.id); data.putString("element2", this.type2.id); toRet.put(outerTag, data); return toRet; } @Override public void deserializeNBT(CompoundTag nbt) { if (!nbt.contains(outerTag)) return; this.powersUnlocked.clear(); CompoundTag data = nbt.getCompound(outerTag); this.type = ProgressionInfo.ElementType.getElementById(data.getString("element1")); this.type2 = ProgressionInfo.ElementType.getElementById(data.getString("element2")); String[] powerIds = data.getString("unlockedPowers").split(","); for (String id : powerIds) { ProgressionInfo info = Objects.requireNonNull(ProgressionInfoInit.ALL_PROGRESSION_INFOS.get(id)); this.powersUnlocked.add(info); } } } Capability Registration (Elementalism.java): public void registerCapabilities(RegisterCapabilitiesEvent event) { event.register(PlayerProgressionData.class); } Capability Attaching (CommonSubscriber.java): @SubscribeEvent public void attachCapabilities(AttachCapabilitiesEvent<Entity> event) { if (!(event.getObject() instanceof Player)) return; PlayerProgressionData progressionData = new PlayerProgressionData(); LazyOptional<PlayerProgressionData> optionalProgressionData = LazyOptional.of(() -> progressionData); ICapabilityProvider provider = new ICapabilitySerializable<CompoundTag>() { @Override public CompoundTag serializeNBT() { return progressionData.serializeNBT(); } @Override public void deserializeNBT(CompoundTag nbt) { progressionData.deserializeNBT(nbt); } @Nonnull @Override public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) { if (cap == DATA_STORAGE_CAPABILITY) { return optionalProgressionData.cast(); } return LazyOptional.empty(); } }; event.addCapability(new ResourceLocation(Elementalism.MOD_ID, "data_storage"), provider); event.addListener(optionalProgressionData::invalidate); } Thank you so much for any help!
  3. Surprisingly enough, that did the trick! Thank you so much for all the help!
  4. Sorry, just made it public, forgot to do that.
  5. Latest commit from here should do the trick: https://github.com/hammy3502/survival-extras-2 . I haven't tested on a built JAR, only when using the runClient task.
  6. buildscript { repositories { maven { url = 'https://files.minecraftforge.net/maven' } jcenter() mavenCentral() } dependencies { classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true } } apply plugin: 'net.minecraftforge.gradle' // Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. apply plugin: 'eclipse' apply plugin: 'maven-publish' version = '2.0.0' group = 'net.blf02.survivalextras2' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'survival_extras_2' sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly. println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch')) minecraft { // The mappings can be changed at any time, and must be in the following format. // snapshot_YYYYMMDD Snapshot are built nightly. // stable_# Stables are built at the discretion of the MCP team. // Use non-default mappings at your own risk. they may not always work. // Simply re-run your setup task after changing the mappings to update your workspace. mappings channel: 'snapshot', version: '20201028-1.16.3' // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Default run configurations. // These can be tweaked, removed, or duplicated as needed. runs { client { workingDirectory project.file('run') // Recommended logging data for a userdev environment property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' // Recommended logging level for the console property 'forge.logging.console.level', 'debug' mods { examplemod { source sourceSets.main } } // For Patchouli property 'mixin.env.remapRefMap', 'true' property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" } server { workingDirectory project.file('run') // Recommended logging data for a userdev environment property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' // Recommended logging level for the console property 'forge.logging.console.level', 'debug' mods { examplemod { source sourceSets.main } } } data { workingDirectory project.file('run') // Recommended logging data for a userdev environment property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' // Recommended logging level for the console property 'forge.logging.console.level', 'debug' // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') mods { examplemod { source sourceSets.main } } } } } // Include resources generated by data generators. sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { maven { // location of the maven that hosts JEI files name = "Progwml6 maven" url = "https://dvs1.progwml6.com/files/maven/" } maven { // location of a maven mirror for JEI files, as a fallback name = "ModMaven" url = "https://modmaven.k-4u.nl" } maven { name = "Patchouli" url = "https://maven.blamejared.com" } flatDir { dirs 'libs' } } dependencies { // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied. // The userdev artifact is a special name and will get all sorts of transformations applied to it. minecraft 'net.minecraftforge:forge:1.16.4-35.1.37' // compile against the JEI API but do not include it at runtime compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // at runtime, use the full JEI jar runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") compileOnly fg.deobf("vazkii.patchouli:Patchouli:1.16.4-50:api") runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.16.4-50") compile fg.deobf("net.blf02.vivecraftapi:Vivecraft-API-1.16.4-0.1.0") // You may put jars on which you depend on in ./libs or you may define them like so.. // compile "some.group:artifact:version:classifier" // compile "some.group:artifact:version" // Real examples // compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env // compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env // The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime. // provided 'com.mod-buildcraft:buildcraft:6.0.8:dev' // These dependencies get remapped to your current MCP mappings // deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev' // For more info... // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html // http://www.gradle.org/docs/current/userguide/dependency_management.html } // Example for how to get properties into the manifest for reading by the runtime.. jar { manifest { attributes([ "Specification-Title": "examplemod", "Specification-Vendor": "examplemodsareus", "Specification-Version": "1", // We are version 1 of ourselves "Implementation-Title": project.name, "Implementation-Version": "${version}", "Implementation-Vendor" :"examplemodsareus", "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") ]) } } // Example configuration to allow publishing using the maven-publish task // This is the preferred method to reobfuscate your jar file jar.finalizedBy('reobfJar') // However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing //publish.dependsOn('reobfJar') publishing { publications { mavenJava(MavenPublication) { artifact jar } } repositories { maven { url "file:///${project.projectDir}/mcmodsrepo" } } } EDIT: The JAR is stored in libs/, and is named `Vivecraft-API-1.16.4-0.1.0.jar`
  7. My bad, I should have clarified before that I was using `fg.deobf`. If it helps, the crash report indicates that it can't find a method: `java.lang.NoSuchMethodError: net.minecraft.server.MinecraftServer.func_184103_al()Lnet/minecraft/server/management/PlayerList;` I have both mods using the same mappings (the mappings pre-Mojang, I'm forgetting what they're called off of the top of my head), and both mods report the actual method name as being getPlayerList(), rather than func_184103_al() when browsing through code in IntelliJ. EDIT: If it helps, the code to `apimod` is here (it fails on running PlayerTracker.tick() ). EDIT 2: To clarify a bit, the `apimod` is being built with the usual `gradlew build`, and being loaded into `examplemod` through the line you sent in your post. The `apimod` runs perfectly fine on its own in both SP and MP, so I know it's not reaching across sides. `examplemod` also makes no calls or references to `apimod`, only `apimod` is loaded alongside `examplemod` via the build.gradle line you sent.
  8. Hello! I have a mod (let's just call it `apimod`) that I want to have other mods depend on existing. For example, if I had a mod called `examplemod`, it would require `apimod` to be installed separately for it to work properly, similarly to how other mods can use JEI's API to do things within JEI. Assuming I have both mods fully working except for any interoperability from `examplemod` to `apimod`, how would I go about adding `apimod` into my workspace for `examplemod`, but making sure the mod needs to be installed separately when running a built version of `examplemod`? So far, my closest attempts to getting this to work have been adding a "libs" folder as a repository to `examplemod`, then adding as both `compileOnly` and `runtimeOnly` dependencies, the JAR for `apimod`. However, this seems to result in a `MethodNotFoundException` when first entering a world as `apimod` fails to run some of its own, internal logic. Thank you so much for any help!
  9. Was able to figure it out! For those stumbling across this, you need to Override the isEquivalentTo method in your fluid class to return true if the fluidIn matches your still fluid or your flowing fluid.
  10. Hello! I'm currently trying to add a custom fluid, however it seems to flow extremely weirdly. The source block only flows to some sides some of the time, and flowing blocks don't produce more flowing blocks of a lower level, and instead dissipate as if there were no source block! Any help would be greatly appreciated! MoltenSyrup.java public class MoltenSyrup extends FlowingFluid { @Override public Fluid getFlowingFluid() { return ModFluids.moltenSyrupFlowing.get(); } @Override public Fluid getStillFluid() { return ModFluids.moltenSyrup.get(); } @Override public boolean canSourcesMultiply() { return true; } @Override public void beforeReplacingBlock(IWorld worldIn, BlockPos pos, BlockState state) { worldIn.playEvent(1501, pos, 0); } @Override public int getSlopeFindDistance(IWorldReader worldIn) { return 4; } @Override public int getLevelDecreasePerBlock(IWorldReader worldIn) { return 1; } @Override public Item getFilledBucket() { return ModItems.moltenSyrupBucket.get(); } @Override public boolean canDisplace(FluidState fluidState, IBlockReader blockReader, BlockPos pos, Fluid fluid, Direction direction) { return false; } @Override public int getTickRate(IWorldReader p_205569_1_) { return 60; // Moves very slow, it's syrup after all. } @Override public float getExplosionResistance() { return 100.0F; } @Override public BlockState getBlockState(FluidState state) { return ModBlocks.moltenSyrupBlock.getBlock().get().getDefaultState() .with(FlowingFluidBlock.LEVEL, Integer.valueOf(getLevelFromState(state))); } @Override public boolean isSource(FluidState state) { return true; } @Override public int getLevel(FluidState state) { return 8; } @Override public FluidAttributes createAttributes() { return net.minecraftforge.fluids.FluidAttributes.builder( new ResourceLocation("block/molten_syrup_still"), new ResourceLocation("block/molten_syrup_flow")) .translationKey("block.survival_extras_2.molten_syrup") .luminosity(4).density(3000).viscosity(12000).temperature(775) .sound(SoundEvents.ITEM_BUCKET_FILL_LAVA, SoundEvents.ITEM_BUCKET_EMPTY_LAVA) .build(this); } public static class Flowing extends MoltenSyrup { protected void fillStateContainer(StateContainer.Builder<Fluid, FluidState> builder) { super.fillStateContainer(builder); builder.add(LEVEL_1_8); } public int getLevel(FluidState state) { return state.get(LEVEL_1_8); } public boolean isSource(FluidState state) { return false; } } public static class Source extends MoltenSyrup { public int getLevel(FluidState state) { return 8; } public boolean isSource(FluidState state) { return true; } } } Full repo is at https://github.com/hammy3502/survival-extras-2 Thank you for any help!
  11. Hello! I'm currently trying to add a custom brewing stand recipe, however it seems to output the wrong potion! Instead of giving me the extended levitation potion, it's giving me the extended jumpless potion. ModPotions.java public class ModPotions { public static final DeferredRegister<Effect> EFFECTS = DeferredRegister.create(ForgeRegistries.POTIONS, SurvivalExtras2.MOD_ID); public static final DeferredRegister<Potion> POTIONS = DeferredRegister.create(ForgeRegistries.POTION_TYPES, SurvivalExtras2.MOD_ID); private static ArrayList<BrewingRecipe> recipes = new ArrayList<>(); public static final RegistryObject<Effect> milkEffect = EFFECTS.register("milk", () -> new EffectMilk(EffectType.NEUTRAL, 0xFFFFFF)); public static final RegistryObject<Potion> milkPotion = POTIONS.register("milk_potion", () -> new Potion(new EffectInstance(milkEffect.get()))); public static final RegistryObject<Effect> starEffect = EFFECTS.register("star", () -> new EffectStar(EffectType.BENEFICIAL, 0xFFFF00)); public static final RegistryObject<Potion> baseStarPotion = POTIONS.register("base_star", () -> new Potion(new EffectInstance(starEffect.get(), 400, 0))); public static final RegistryObject<Effect> burntEffect = EFFECTS.register("burnt", () -> new EffectBlank(EffectType.HARMFUL, 0x1f1f1f)); public static final RegistryObject<Effect> challengeEffect = EFFECTS.register("food_kingdom_challenge", () -> new EffectChallenge(EffectType.BENEFICIAL, 0xFFFF00)); public static final RegistryObject<Effect> jumpless = EFFECTS.register("jumpless", () -> new EffectBlank(EffectType.HARMFUL, 0xDD00B3)); public static final RegistryObject<Potion> jumplessPotion = POTIONS.register("base_jumpless", () -> new Potion(new EffectInstance(jumpless.get(), 45*20))); public static final RegistryObject<Potion> jumplessPotionExtended = POTIONS.register("jumpless_extended", () -> new Potion(new EffectInstance(jumpless.get(), 90*20))); public static final RegistryObject<Potion> mysteriousPotion = POTIONS.register("se2_mysterious", Potion::new); public static final RegistryObject<Potion> levitationBase = POTIONS.register("base_levitation", () -> new Potion(new EffectInstance(Effects.LEVITATION, 90*20))); public static final RegistryObject<Potion> levitationExtended = POTIONS.register("levitation_extended", () -> new Potion(new EffectInstance(Effects.LEVITATION, 180*20))); public static final RegistryObject<Potion> levitationExtra = POTIONS.register("levitation_extra", () -> new Potion(new EffectInstance(Effects.LEVITATION, 45*20, 1))); public static void addRecipes(FMLCommonSetupEvent event) { initRecipes(); for (BrewingRecipe recipe : recipes) { event.enqueueWork(() -> BrewingRecipeRegistry.addRecipe(recipe)); } } public static void initRecipes() { addAwkwardRecipe(Items.MILK_BUCKET, milkPotion.get()); addAwkwardRecipe(ModItems.mysteriousCore.get(), mysteriousPotion.get()); addAwkwardRecipe(ModItems.flightEssence.get(), levitationBase.get()); addMysteriousRecipe(Items.NETHER_STAR, baseStarPotion.get()); addMysteriousRecipe(Items.RABBIT_FOOT, jumplessPotion.get()); addWaterRecipe(ModItems.enchantIngot.get(), new ItemStack(Items.EXPERIENCE_BOTTLE)); addRedstoneRecipe(jumplessPotion.get(), jumplessPotionExtended.get()); addRedstoneRecipe(levitationBase.get(), levitationExtended.get()); addGlowstoneRecipe(levitationBase.get(), levitationExtra.get()); } public static void addAwkwardRecipe(Item ingredient, Potion potion) { recipes.add(new BrewingRecipe( Ingredient.fromStacks(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.AWKWARD)), Ingredient.fromItems(ingredient), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), potion))); } public static void addMysteriousRecipe(Item ingredient, Potion potion) { recipes.add(new BrewingRecipe( Ingredient.fromStacks(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), ModPotions.mysteriousPotion.get())), Ingredient.fromItems(ingredient), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), potion))); } public static void addWaterRecipe(Item ingredient, ItemStack output) { recipes.add(new BrewingRecipe( Ingredient.fromStacks(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.WATER)), Ingredient.fromItems(ingredient), output )); } public static void addRedstoneRecipe(Potion potionIn, Potion potionOut) { recipes.add(new BrewingRecipe( Ingredient.fromStacks(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), potionIn)), Ingredient.fromItems(Items.REDSTONE), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), potionOut))); } public static void addGlowstoneRecipe(Potion potionIn, Potion potionOut) { recipes.add(new BrewingRecipe( Ingredient.fromStacks(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), potionIn)), Ingredient.fromItems(Items.GLOWSTONE_DUST), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), potionOut))); } } Full repo is at https://github.com/hammy3502/survival-extras-2 if you need to look anywhere else. Thank you so much for any help!
  12. I'm stupid, the RegistryObject's are suppliers. Swapping those in, and changing the code around a bit, and everything works now. Thank you so much for the help!
  13. I've put a quick temporary patch on registerTools to return a boolean, and simply register the items necessary without calling .get(), though the crash still occurs on the repairMaterial, as I'm not sure how to pass in a proper Supplier.
  14. Hello, and thank you so much for the help! I know it may not be clear from the code above, but the items are currently registered through the DeferredRegister. How would I go about getting the supplier for foodariumIngot? Just passing in the foodariumIngot is a RegistryObject<Item>, but I need a Supplier<Item>. Thank you so much for any help!
  15. Hello, and thank you for the help so far! It seems in 1.16, LazyLoadBase was moved to LazyValue, but even with that, it sadly still seems to crash. Tool Creation: public static final Item[] foodariumTools = ModToolsArmor.registerTools("foodarium", 2, 777, 8.0F, 2.5F, 16, -3.05F, ModItems.foodariumIngot.get()); Start of registerTools (rest of it is the same): public static Item[] registerTools(String materialName, int harvestLevel, int maxUses, float miningSpeed, float attackDamageExtraFromWood, int enchantability, float axeAttackSpeed, Item repairMaterial) { Item[] tools = new Item[5]; ModItemTier itemTier = new ModItemTier(harvestLevel, maxUses, miningSpeed, attackDamageExtraFromWood, enchantability, () -> Ingredient.fromItems(repairMaterial)); Modified ItemTier: public class ModItemTier implements IItemTier { private final int harvestLevel; private final int maxUses; private final float miningSpeed; private final float attackDamageExtraFromWood; private final int enchantability; private final LazyValue<Ingredient> repairMaterial; public ModItemTier(int harvestLevel, int maxUses, float miningSpeed, float attackDamageExtraFromWood, int enchantability, Supplier<Ingredient> repairMaterial) { this.harvestLevel = harvestLevel; this.maxUses = maxUses; this.miningSpeed = miningSpeed; this.attackDamageExtraFromWood = attackDamageExtraFromWood; this.repairMaterial = new LazyValue<>(repairMaterial); this.enchantability = enchantability; } @Override public int getMaxUses() { return this.maxUses; } @Override public float getEfficiency() { return this.miningSpeed; } @Override public float getAttackDamage() { return this.attackDamageExtraFromWood; } @Override public int getHarvestLevel() { return this.harvestLevel; } @Override public int getEnchantability() { return this.enchantability; } @Override public Ingredient getRepairMaterial() { return this.repairMaterial.getValue(); } } New Crash Log (seems to have the same error as before): https://pastebin.com/PSDVZaDE Thank you again for all the help so far!
  • Create New...

Important Information

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