Jump to content

Myxtro

Members
  • Posts

    35
  • Joined

  • Last visited

Everything posted by Myxtro

  1. @InvictusSlayer Thanks! Sadly that didn't solve it. I went looking through the vanilla code and found the BlockColors class which seems to set the colors of the leaves. I still have to figure out how to replicate this in a mod though but I thought you might want to know in case you want to look for yourself. If I happen to figure it out I'll reply to this thread.
  2. @InvictusSlayer I can't thank you enough! This was just what I needed. Thanks for the proper explaination as well, you are the best. Now that my trees can finally grow, I'm stuck with only one issue. The leaves don't have correct colors. I made them grey like the default tree textures and was hoping I could find a few to make them colored, but I haven't found something yet. Do you happen to have an example of that as well?
  3. I want to add trees to my mod but all the examples I've seen so far include data generation, and not json files. The json files for the blocks are not the issue here. Unless trees require certain json files as a structure, I'm certain I've got this part covered. The thing I'm looking for is probably a deferred register or any other way to register something as a tree so it will grow from a sapling. Here is what I currently have: public static final DeferredRegister<ConfiguredFeature<?, ?>> TREES = DeferredRegister.create(Registries.CONFIGURED_FEATURE, ExtinctionCraft.MOD_ID); // How do I register the tree? public static final ResourceKey<ConfiguredFeature<?, ?>> SEQUOIA_KEY = registerKey("sequoia"); public static void bootstrap(BootstapContext<ConfiguredFeature<?, ?>> context) { register(SEQUOIA_KEY, Feature.TREE, new TreeConfiguration.TreeConfigurationBuilder( BlockStateProvider.simple(ModBlocks.SEQUOIA_LOG.get()), new StraightTrunkPlacer(5, 4, 3), BlockStateProvider.simple(ModBlocks.SEQUOIA_LEAVES.get()), new PineFoliagePlacer(ConstantInt.of(3), ConstantInt.of(2), ConstantInt.of(3)), new TwoLayersFeatureSize(1, 0, 2)).build()); } public static ResourceKey<ConfiguredFeature<?, ?>> registerKey(String name) { return ResourceKey.create(Registries.CONFIGURED_FEATURE, new ResourceLocation(ExtinctionCraft.MOD_ID, name)); } private static <FC extends FeatureConfiguration, F extends Feature<FC>> void register(BootstapContext<ConfiguredFeature<?, ?>> context, ResourceKey<ConfiguredFeature<?, ?>> key, F feature, FC configuration) { context.register(key, new ConfiguredFeature<>(feature, configuration)); } I also have this Grower class: public class SequoiaGrower extends AbstractTreeGrower { @Nullable @Override protected ResourceKey<ConfiguredFeature<?, ?>> getConfiguredFeature(RandomSource pRandom, boolean pHasFlowers) { return ModConfiguredFeatures.SEQUOIA_KEY; } } And the registry of the blocks that make up the tree (excluding wood blocks that I have registered but that don't make up part of a tree): public static final RegistryObject<Block> SEQUOIA_LOG = registerBlock("sequoia_log", () -> new ModFlammableRotatedPillarBlock(BlockBehaviour.Properties.copy(Blocks.OAK_LOG).strength(3))); public static final RegistryObject<Block> SEQUOIA_LEAVES = registerBlock("sequoia_leaves", () -> new ModLeavesBlock(BlockBehaviour.Properties.copy(Blocks.OAK_LEAVES))); public static final RegistryObject<Block> SEQUOIA_SAPLING = registerBlock("sequoia_sapling", () -> new SaplingBlock(new SequoiaGrower(), BlockBehaviour.Properties.copy(Blocks.OAK_SAPLING))); How do I move on from here? Examples of your code are welcome too.
  4. I solved it, but maybe not in the correct way. The problem was that I needed to add file: file to the replaceProperties in build.gradle. I then added file=examplefile to gradle.properties. What would be a better value than "examplefile"? I don't really know what file it's looking for
  5. I've added some contents of my files to the original post of what I think is relevant. Hopefully that could help solving the issue.
  6. I get the following error when trying to run my mod. The processResources Gradle script doesn't seem to work. Execution failed for task ':processResources'. > Could not copy file 'D:\Minecraft Modding\mods\UnnamedMod\src\main\resources\META-INF\mods.toml' to 'D:\Minecraft Modding\mods\UnnamedMod\build\resources\main\META-INF\mods.toml'. > Missing property (file) for Groovy template expansion. Defined keys [minecraft_version, minecraft_version_range, forge_version, forge_version_range, loader_version_range, mod_id, mod_name, mod_license, mod_version, mod_authors, mod_description, project]. * Exception is: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':processResources'. at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:149) at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282) ... Caused by: org.gradle.api.internal.file.AbstractFileTreeElement$CopyFileElementException: Could not copy file 'D:\Minecraft Modding\mods\UnnamedMod\src\main\resources\META-INF\mods.toml' to 'D:\Minecraft Modding\mods\UnnamedMod\build\resources\main\META-INF\mods.toml'. at org.gradle.api.internal.file.AbstractFileTreeElement.copyTo(AbstractFileTreeElement.java:88) at org.gradle.api.internal.file.copy.DefaultFileCopyDetails.copyTo(DefaultFileCopyDetails.java:129) ... Caused by: org.gradle.api.GradleException: Missing property (file) for Groovy template expansion. Defined keys [minecraft_version, minecraft_version_range, forge_version, forge_version_range, loader_version_range, mod_id, mod_name, mod_license, mod_version, mod_authors, mod_description, project]. at org.gradle.api.internal.file.copy.FilterChain$3.transform(FilterChain.java:132) at org.gradle.api.internal.file.copy.FilterChain$3.transform(FilterChain.java:115) ... 146 more Caused by: groovy.lang.MissingPropertyException: No such property: file for class: SimpleTemplateScript1 at SimpleTemplateScript1.run(SimpleTemplateScript1.groovy:1) at org.gradle.api.internal.file.copy.FilterChain$3.transform(FilterChain.java:129) ... 155 more Some context: I originally made this mod in 1.17 and have updated it through every version since. This happened after the update to 1.20. Because my Gradle files where becoming outdated I opted to copy the gradle files from a newer project so they would be up to date. The "Load Gradle Changes" button works fine. It's just that this fails when I try to launch the game. The gradle files I updated were: build.gradle gradle.properties mods.toml settings.gradle gradle-wrapper.jar (from the folder gradle\wrapper) gradle-wrapper.properties (from the folder gradle\wrapper) EDIT: Here are some file fragments from what I think could be relevant. I've removed comments for readability. build.gradle (partially): def resourceTargets = ['META-INF/mods.toml', 'pack.mcmeta'] def replaceProperties = [ minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range, forge_version: forge_version, forge_version_range: forge_version_range, loader_version_range: loader_version_range, mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version, mod_authors: mod_authors, mod_description: mod_description ] processResources { inputs.properties replaceProperties replaceProperties.put 'project', project filesMatching(resourceTargets) { expand replaceProperties } } mods.toml: modLoader="javafml" loaderVersion="${loader_version_range}" license="${mod_license}" [[mods]] modId="${mod_id}" version="${mod_version}" displayName="${mod_name}" logoFile="example.png" credits="Thanks to you!" authors="${mod_authors}" description="${mod_description}" [[dependencies.unnamedmod]] modId="forge" mandatory=true versionRange="${forge_version_range}" ordering="NONE" side="BOTH" [[dependencies.unnamedmod]] modId="minecraft" mandatory=true versionRange="${minecraft_version_range}" ordering="NONE" side="BOTH" properties.gradle: org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false minecraft_version=1.20.1 minecraft_version_range=[1.20.1,1.21) forge_version=47.1.0 forge_version_range=[47,) loader_version_range=[47,) mapping_channel=parchment mapping_version=2023.08.13-1.20.1 mod_id=unnamedmod mod_name=UnnamedMod mod_license=All Rights Reserved mod_version=0.0.1-1.20.1 mod_group_id=net.unnamedmod mod_authors=Myxtro
  7. So this should work? public class LargeGridRecipe extends ShapedRecipe { @Override public RecipeType<?> getType() { return Type.INSTANCE; } public static class Type implements RecipeType<LargeGridRecipe> { private Type() { } public static final Type INSTANCE = new Type(); public static final String ID = "large_grid"; } } As a side question, do you perhaps know where I can find an example of how to check if a recipe is present in the BlockEntity? I know how to do this for shapeless recipes but it doesn't seem to work for a shaped recipe.
  8. Could you elaborate on what you mean by "reuse"? As there's a couple ways to interpret it. Do you mean registering it with ShapedRecipe as the registry object? like so: public static final RegistryObject<RecipeSerializer<ShapedRecipe>> LARGE_GRID_SERIALIZER = SERIALIZERS.register("large_grid", () -> ShapedRecipe.Serializer.SHAPED_RECIPE); //Do you mean to change ShapedRecipe.Serializer.SHAPED_RECIPE to something else? Or do you mean copying the ShapedRecipe class and renaming it, then using that to register? The way I currently do it is by having a custom class extend the ShapedRecipe class, but this comes with it's own set of problems which I rather avoid building crappy solutions for.
  9. The reason I'm doing this is because I don't want regular recipes to work on my custom 5 by 5 table. Only the recipes I create should be able to be crafted. Is there an easy way to achieve this?
  10. Like this? private void setup(final FMLCommonSetupEvent event) { event.enqueueWork(() -> { LargeCraftingRecipe.setCraftingSize(5, 5); }); }
  11. I want to create a custom recipe with a 5 by 5 grid. I extended the ShapedRecipe class as this seems to be the obivous route to take. (Or should I take a different approach perhaps?) The ShapedRecipe class has a setCraftingSize method. This is however a static method so I can't call it in the constructor of my custom recipe. Where and how should this method be called instead?
  12. I'm updating my project to 1.19.2 from 1.18.2. For this I changed my build.gradle. I changed the following things: I set my dependencies to: dependencies { minecraft 'net.minecraftforge:forge:1.19.2-43.1.25' implementation fg.deobf('software.bernie.geckolib:geckolib-forge-1.19:3.1.20') } And my mappings to: mappings channel: 'parchment', version: '2022.09.04-1.19.2' (I also tried version: 1.1.8.2-2022.05.02-1.19 but that had the same result) I get the following errors when I try to load the gradle changes: - java.lang.IllegalStateException: ProjectScopeServices has been closed - Start.java: - package net.minecraft.client.main does not exist - cannot find symbol variable Main - package net.minecraft.client.main does not exist - cannot find symbol variable Main - java.lang.IllegalStateException: ProjectScopeServices has been closed - Could not resolve net.minecraftforge:forge:1.19.2-43.1.25_mapped_parchment_2022.09.04-19.2 I have a feeling this is caused by the mappings but I'm not certain about this. Any idea what I could do?
  13. I'm making an incubator block in which you can put eggs which will then result in hatched eggs after some time. The block entity has 4 slots. Each slot should be able to make it's own progress independently of other slots. When you put an egg in slot 1, the progress of slot 1 should go up over time. I have the issue where the progress of slots 2 to 4 doesn't go up unless there's eggs in the slots that come before it. For example, slot 2's progress is stuck on 1 if there's no egg in slot 1. As soon as you put an egg in slot 1, the progress of both slots goes up. Here's the code inside the tick method: public static void tick(Level pLevel, BlockPos pPos, BlockState pState, IncubatorBlockEntity pBlockEntity) { if(!pLevel.isClientSide) { // Slot 1 if (hasRecipe(pBlockEntity, 0)) { // 0 references slot 1 which has index 0 pBlockEntity.slot1Progress++; setChanged(pLevel, pPos, pState); //System.out.println("Slot 1 progress: " + pBlockEntity.slot1Progress); if (pBlockEntity.slot1Progress > pBlockEntity.maxProgress) { craftItem(pBlockEntity, 0); // 0 references slot 1 which has index 0 pBlockEntity.resetProgress(0); // 0 references slot 1 which has index 0 setChanged(pLevel, pPos, pState); } } else { pBlockEntity.resetProgress(0); // 0 references slot 1 which has index 0 setChanged(pLevel, pPos, pState); } // Slot 2 if (hasRecipe(pBlockEntity, 1)) { // 1 references slot 2 which has index 1 pBlockEntity.slot2Progress++; setChanged(pLevel, pPos, pState); //System.out.println("Slot 2 progress: " + pBlockEntity.slot2Progress); if (pBlockEntity.slot2Progress > pBlockEntity.maxProgress) { craftItem(pBlockEntity, 1); // 1 references slot 2 which has index 1 pBlockEntity.resetProgress(1); // 1 references slot 2 which has index 1 setChanged(pLevel, pPos, pState); } } else { pBlockEntity.resetProgress(1); // 1 references slot 2 which has index 1 setChanged(pLevel, pPos, pState); } // Slot 3 and 4 The constructor with the containerData is as follows: public IncubatorBlockEntity(BlockPos pWorldPosition, BlockState pBlockState) { super(ModBlockEntities.INCUBATOR_BLOCK_ENTITY.get(), pWorldPosition, pBlockState); this.data = new ContainerData() { @Override public int get(int index) { return switch (index) { case 0 -> IncubatorBlockEntity.this.slot1Progress; case 1 -> IncubatorBlockEntity.this.slot2Progress; case 2 -> IncubatorBlockEntity.this.slot3Progress; case 3 -> IncubatorBlockEntity.this.slot4Progress; case 4 -> IncubatorBlockEntity.this.maxProgress; default -> 0; }; } @Override public void set(int index, int value) { switch (index) { case 0 -> IncubatorBlockEntity.this.slot1Progress = value; case 1 -> IncubatorBlockEntity.this.slot2Progress = value; case 2 -> IncubatorBlockEntity.this.slot3Progress = value; case 3 -> IncubatorBlockEntity.this.slot4Progress = value; case 4 -> IncubatorBlockEntity.this.maxProgress = value; } } @Override public int getCount() { return 5; } }; } The hasRecipe method simply returns a boolean to tell whether it contains an egg. I'm certain this method doesn't cause issues. I have determined that the resetProgress method doesn't get called at unintended times either. So what could be the problem?
  14. This is probably the way I want to go with. But how would I do this in the scenario where I have an abstract class where the field must be known (so methods can use it) but not yet have a value. Where in the implementing class should I assign a value to the field? I have tried this setup but it doesn't seem to work: //in the abstract class public static int maxFood; //In the constructor of the implementing class maxFood = 100000;
  15. I have a few questions regarding entities. Whenever I spawn an entity (with a spawn egg at least) the defineSynchedData() function can't read data values that are being set in the constructor. So I have two questions: 1) What is the proper way of defining data values which can change for each individual entity (like a hunger counter) 2) What is the proper way of defining data values that won't change, and are the same for each instance of the same entity class (like a max food level)
  16. Thanks guys, the problem was indeed that I had to change this.level.isClientSide To !this.level.isClientSide
  17. Could you please elaborate? Because I thought the readAdditionalSaveData and addAdditionalSaveData took care of that.
  18. What can I use to sync the data to the server instead?
  19. I have an issue with adding data to an entity (mob). I want it to have a boolean value to determine whether it has a tracking device or not. However, the data doesn't get saved when I exit the game. Does anyone have an explaination for this? The variant of this mob does work correctly (and gets saved properly) and I have no idea what I did differently. See the relevant code below: private static final EntityDataAccessor<Integer> DATA_ID_TYPE_VARIANT = SynchedEntityData.defineId(AllosaurusEntityExample.class, EntityDataSerializers.INT); private static final EntityDataAccessor<Boolean> HAS_TRACKER = SynchedEntityData.defineId(AllosaurusEntityExample.class, EntityDataSerializers.BOOLEAN); public boolean hasTracker() { return this.entityData.get(HAS_TRACKER); } public void setTracker(boolean tracker) { this.entityData.set(HAS_TRACKER, tracker); } public InteractionResult addTracker(Player player) { this.entityData.set(HAS_TRACKER, true); Component confirmationMsg = new TextComponent("This " + this.getDisplayName().getString() + " now has a tracker"); player.sendMessage(confirmationMsg, Util.NIL_UUID); return InteractionResult.SUCCESS; } /* ----- DATA SYNC ----- */ @Override public void readAdditionalSaveData(CompoundTag tag) { super.readAdditionalSaveData(tag); this.entityData.set(DATA_ID_TYPE_VARIANT, tag.getInt("variant")); this.entityData.set(HAS_TRACKER, tag.getBoolean("hasTracker")); this.setTracker(tag.getBoolean("hasTracker")); } @Override public void addAdditionalSaveData(CompoundTag tag) { super.addAdditionalSaveData(tag); tag.putInt("variant", this.getTypeVariant()); tag.putBoolean("hasTracker", this.hasTracker()); } @Override protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(DATA_ID_TYPE_VARIANT, 0); this.entityData.define(HAS_TRACKER, false); } /* ----- INTERACTION WITH ITEM ----- */ @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { Item item = player.getItemInHand(hand).getItem(); Item addTrackerItem = ModItems.TRACKER.get(); if (item == addTrackerItem && !this.hasTracker()) { if (this.level.isClientSide) { return this.addTracker(player); } } return super.mobInteract(player, hand); }
  20. I'm looking for a way to get an array of all items with a certain tag. Is this possible? Minecraft version 1.18.2
  21. How and where do I implement that? I've never used a matrix stack before. EDIT: nevermind I figured it out.
  22. I made an entity (mob) but I want to scale it down to about half the original size. How would I approach this? I'm using GeckoLib for animations, in case that's relevant.
  23. Is there a workaround for this? All I need is a list of mod blocks that certain mod tools can break.
  24. EFFECTIVE_ON is the name of the set. Here's the set for refference. private static Set<Block> EFFECTIVE_ON = Sets.newHashSet(BlockInit.AMBER_BLOCK.get()); I could ofcourse replace EFFECTIVE_ON with the set but I would then have to repeat this for each item it is applicable to.
  25. It is used when creating a ToolItem in the third argument. public static final RegistryObject<Item> IRON_GEO_HAMMER = ITEMS.register("iron_geo_hammer", () -> new ToolItem(1, 1, ItemTier.IRON, EFFECTIVE_ON, new Item.Properties())); Do I need to change anything here?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.