Jump to content

kiou.23

Members
  • Posts

    444
  • Joined

  • Last visited

  • Days Won

    5

Posts posted by kiou.23

  1. This seems to be a little above my level (and by a little I mean a lot).

    I had given up on trying to understand what was going on and was just copy-pasting code, and now I've giving up on that too.

    Waiting until Forge implements their solution to facilitate this seems like the better option for me at least

     

    thanks anyhow

  2. 12 minutes ago, A Soulspark said:

    ok, I'll try that. but is it possible to have multiple block items for the same block, just with different states? last time I tried this, the Creative inventory got messed up and it just added one of the items multiple times.

    what comes to mind is that you could extend BlockItem, to make a KettleBlockItem, which places a block with a given blockstate, which you can set when creating a new instance of it in registration... look like the more elegant way of doing it, but I'm really not sure (and after looking at the BlockItem class for a few seconds trying to see wht you could override, I imagine it'd give a headache)

    and you could change what item the block drops based on blockstate as well

    • Thanks 1
  3. 14 minutes ago, A Soulspark said:

     

    That's true, but an empty kettle doesn't need a tile entity, whereas the other two do, and they have other states that are only necessary in each case.

    e.g. the boiling kettle has a fullness state, for how many uses it has left. this isn't necessary for empty or full kettles, as their "fullness" doesn't change: it's 0% or 100%.

    the method hasTileEntity, and createTileEntity, take the current blockstate as a parameter, so you can decide wether or not your block has a tile entity based on the blockstate. that solves this problem

     

    blockstates do seem like the easier way to do what you want...

  4. 8 minutes ago, than00ber1 said:

    I suppose you wouldn't create a new project repo to port from 1.16.4 to 1.16.5?

    correct, 1.16.4 mods are compatible with 1.16.5, you just need to add to the version range in mods.toml

     

    8 minutes ago, than00ber1 said:

    Would I need to create a new repo to make the mod compatible with different but still relevant game versions like 1.12.2?

    Yes, the vanilla and the forge code were entirely different, for 1.15 it would be easier (you'd still need a new repo), but for 1.12 you would be better off rewriting everything from scracth

     

    note that: the forum currently only supports 1.15 and 1.16, don't bother asking for help with other versions

     

    8 minutes ago, than00ber1 said:

    PS: I am not sure if this is the correct thread to ask this question.

    I believe this topic belongs under Modder Support, not Forge Gradle

    • Thanks 1
  5. 11 hours ago, Beethoven92 said:

    So, this is not at all a trivial task right now, and it is not one you can fully achieve without some mixin usage (until Forge provides a way of registering Nether an End biomes like we are already able to do with Overworld biomes). So you can look here to see how we added biomes to the End. Adding biomes to the Nether is a very similar process, you just need to explore a bit the NetherBiomeProvider class.

    Overriding the vanilla biome provider: https://github.com/Beethoven92/BetterEndForge/blob/master/src/main/java/mod/beethoven92/betterendforge/mixin/DimensionTypeMixin.java

    The custom biome provider class: https://github.com/Beethoven92/BetterEndForge/blob/master/src/main/java/mod/beethoven92/betterendforge/common/world/generator/BetterEndBiomeProvider.java

    Do note that some mods that add their own biomes to the Nether already exists (Biome o' plenty, biomes you'll go...). You may want to take a look at their nether biome provider to see how they handle this

    Okay, I took a look at the repository and the classes, I tried to specify it to my needs (which should be very simplistic), and ended up with the following code, is this how I should be doing this?

     

    Biome Provider:

    public class EffeteBiomeProvider extends BiomeProvider {
    
        public static final Codec<EffeteBiomeProvider> EFFETE_CODEC = RecordCodecBuilder.create(builder ->
            builder.group(
                RegistryLookupCodec.getLookUpCodec(Registry.BIOME_KEY).forGetter(provider -> provider.lookupRegistry),
                Codec.LONG.fieldOf("seed").stable().forGetter(provider -> provider.seed)
            ).apply(builder, builder.stable(EffeteBiomeProvider::new))
        );
    
        private final Registry<Biome> lookupRegistry;
        private final long seed;
    
        public EffeteBiomeProvider(Registry<Biome> lookupRegistry, long seed) {
            super(getBiomes(lookupRegistry));
    
            this.lookupRegistry = lookupRegistry;
            this.seed = seed;
        }
    
        private static List<Biome> getBiomes(Registry<Biome> biomeRegistry) {
            return biomeRegistry.stream()
                .filter(biome -> biome.getCategory() == Biome.Category.NETHER)
                .collect(Collectors.toList());
        }
    
        @Override
        public Biome getNoiseBiome(int x, int y, int z) {
            return ModBiomes.EFFETE_FOREST.get();
        }
    
        @Override
        protected Codec<? extends BiomeProvider> getBiomeProviderCodec() {
            return EFFETE_CODEC;
        }
    
        @Override
        public BiomeProvider getBiomeProvider(long seed) {
            return new EffeteBiomeProvider(lookupRegistry, seed);
        }
    
        public static void register() {
            Registry.register(Registry.BIOME_PROVIDER_CODEC, "effete_biome_provider", EFFETE_CODEC);
        }
    }

     

    DimensionTypeMixin:

    @Mixin(DimensionType.class)
    public class DimensionTypeMixin {
    
        @Inject(at = @At("HEAD"), method = "getNetherChunkGenerator(Lnet/minecraft/util/registry/Registry;Lnet/minecraft/util/registry/Registry;J)Lnet/minecraft/world/gen/ChunkGenerator;", cancellable = true)
        private static void effeteGenerator(Registry<Biome> registry, Registry<DimensionSettings> settings, long seed, CallbackInfoReturnable<ChunkGenerator> info) {
            info.setReturnValue(new NoiseChunkGenerator(
                new EffeteBiomeProvider(registry, seed), seed,
                () -> settings.getOrThrow(DimensionSettings.field_242736_e)
            ));
        }
    }

     

    some follow up question too: does this makes my biome spawn in the nether, and nether alone? and would this conflict with other mods that add nether biomes?

  6. Just now, daydream said:

    you mean that ther's a guide directly wrote in the code or tht's intuitive? sorry for my confused writng but i'm foreign

    you have the javadocs, which are comments written in the code which describe how that piece of code works.

    but even, you can just read the code itself, and walk through it, to get an understanding of how to do it

    for instance: if you want to make a new tile entity, you could look at the code of vanilla tile entities, such as the furnace, to get a grasp of what the code looks like, what classes to extend, what interfaces to use, what methods to override or call, all that...

  7. your documentation? what do you mean?

    for a guide look no further than the vanilla code itself. anything that you should do differently than how vanilla does it should be in the forge docs, and if yet you face some more specific problems, you can come to the forums or go to the discord for help

  8. by this topic I assume you're new to programming, what I can tell you is to dedicate some hours to go learn programming logic, and then Object Oriented Programming.

    you can't expect to find copy and paste solutions for everything you may want to do.

     

    but in case you already know programming: any tool is just a subclass of Item, you just need to register your own instances of it as you'd do with any item. (that's for custom shovels, axes, pickaxes... if you want to create a new tool type, then you'd have to implement your own custom logic and tool type for it (which I don't know how to do, but shouldn't be hard to figure out))

  9. I have a custom biome, and I want to add custom features to it. however, using ".withFeature()", in the biome generation settings isn't working, because the biome gets initialized before the features does, giving me a Null Pointer Exception

     

    Biome (gets initialized through a deferred register):

    @Mod.EventBusSubscriber(modid = Main.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
    public class ModBiomes {
    
        public static final DeferredRegister<Biome> BIOMES = DeferredRegister.create(ForgeRegistries.BIOMES, Main.MOD_ID);
    
        public static final RegistryObject<Biome> EFFETE_FOREST = BIOMES.register("effete_forest", Maker::EffeteForest);
    
        @SubscribeEvent
        public static void setupBiomes(FMLCommonSetupEvent event) {
            event.enqueueWork(() ->
                setupBiome(EFFETE_FOREST.get(), BiomeManager.BiomeType.WARM, 10000000, //1000
                    Type.NETHER, Type.FOREST, Type.HOT, Type.DRY)
            );
        }
    
        private static void setupBiome(Biome biome, BiomeManager.BiomeType type, int weight, Type... types) {
            RegistryKey<Biome> key = RegistryKey.getOrCreateKey(
                ForgeRegistries.Keys.BIOMES,
                Objects.requireNonNull(ForgeRegistries.BIOMES.getKey(biome), "Biome registry name was null")
            );
    
            BiomeDictionary.addTypes(key, types);
            BiomeManager.addBiome(type, new BiomeManager.BiomeEntry(key, weight));
        }
    
        private static class Maker {
    
            private static Biome EffeteForest() {
                BiomeGenerationSettings genset = new BiomeGenerationSettings.Builder()
                    .withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, ModFeatures.EFFETE_STEM_CONFIG)
                  	// Above line gives a null pointer exception since EFFETE_STEM_CONFIG hasn't been initialized yet
                    .withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Features.RED_MUSHROOM_NETHER)
                    .withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Features.NETHER_SPROUTS)
                    .withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Features.ORE_GOLD_NETHER)
                    .withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Features.ORE_QUARTZ_NETHER)
                    .withStructure(StructureFeatures.BASTION_REMNANT)
                    .withStructure(StructureFeatures.NETHER_FOSSIL)
                    .withStructure(StructureFeatures.RUINED_PORTAL_NETHER)
                    .withSurfaceBuilder(ModConfiguredSurfaceBuilders.EFFETE_SURFACE_BUILDER)
                    .build();
    
                MobSpawnInfo mobspawn = new MobSpawnInfo.Builder()
                    .withSpawner(EntityClassification.MONSTER, new MobSpawnInfo.Spawners(EntityType.CAT, 4, 2, 4))
                    .copy();
    
    
                BiomeAmbience ambience = new BiomeAmbience.Builder()
                    .withGrassColor(0xDA67C1)
                    .setFogColor(0xEEEEEE)
                    .setWaterColor(0xCF21B8)
                    .setWaterFogColor(0xCF78C5)
                    .withSkyColor(0xE83452)
                    .withFoliageColor(0xCA57C1)
                    .build();
    
                return new Biome.Builder()
                    .category(Biome.Category.NETHER)
                    .withTemperatureModifier(Biome.TemperatureModifier.NONE)
                    .withGenerationSettings(genset)
                    .withMobSpawnSettings(mobspawn)
                    .depth(0.09f)
                    .scale(0.2f)
                    .downfall(0.1f)
                    .precipitation(Biome.RainType.NONE)
                    .temperature(1.1f)
                    .setEffects(ambience)
                    .build();
            }
        }
    
    }

     

    Feature (gets initialized in Common setup):

    @Mod.EventBusSubscriber(modid = Main.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
    public class ModFeatures {
    
        public static ConfiguredFeature<?, ?> EFFETE_STEM_CONFIG;
    
        @SubscribeEvent
        public static void setup(FMLCommonSetupEvent e) {
            EFFETE_STEM_CONFIG = register("effete_stem_feature",
                Feature.RANDOM_PATCH
                    .withConfiguration(
                        (new BlockClusterFeatureConfig.Builder(
                            new SimpleBlockStateProvider(ModBlocks.EFFETE_STEM.get().getDefaultState()),
                            new EffeteColumnBlockPlacer(1, 2)
                        )).tries(3).ySpread(0).func_227317_b_().build()
                    ).withPlacement(
                        Placement.COUNT_MULTILAYER.configure(new FeatureSpreadConfig(5)).square()
                    )
            );
        }
    
        private static <FC extends IFeatureConfig> ConfiguredFeature<FC, ?> register(String key, ConfiguredFeature<FC, ?> configuredFeature) {
            return Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, key, configuredFeature);
        }
    }

     

  10. I have a custom biome I'm adding into the game, however, I want it to spawn in the Nether only.

    currently the biome only spawns in the overworld, and does not spawn in the nether.

     

    Biome Registration:

    @Mod.EventBusSubscriber(modid = Main.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
    public class ModBiomes {
    
        public static final DeferredRegister<Biome> BIOMES = DeferredRegister.create(ForgeRegistries.BIOMES, Main.MOD_ID);
    
        public static final RegistryObject<Biome> EFFETE_FOREST = BIOMES.register("effete_forest", Maker::EffeteForest);
    
        @SubscribeEvent
        public static void setupBiomes(FMLCommonSetupEvent event) {
            event.enqueueWork(() ->
                setupBiome(EFFETE_FOREST.get(), BiomeManager.BiomeType.WARM, 10000000, //1000
                    Type.NETHER, Type.FOREST, Type.HOT, Type.DRY)
            );
        }
    
        private static void setupBiome(Biome biome, BiomeManager.BiomeType type, int weight, Type... types) {
            RegistryKey<Biome> key = RegistryKey.getOrCreateKey(
                ForgeRegistries.Keys.BIOMES,
                Objects.requireNonNull(ForgeRegistries.BIOMES.getKey(biome), "Biome registry name was null")
            );
    
            BiomeDictionary.addTypes(key, types);
            BiomeManager.addBiome(type, new BiomeManager.BiomeEntry(key, weight));
        }
    
        private static class Maker {
    
            private static Biome EffeteForest() {
                BiomeGenerationSettings genset = new BiomeGenerationSettings.Builder()
                    .withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Features.RED_MUSHROOM_NETHER)
                    .withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Features.NETHER_SPROUTS)
                    .withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Features.ORE_GOLD_NETHER)
                    .withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Features.ORE_QUARTZ_NETHER)
                    .withStructure(StructureFeatures.BASTION_REMNANT)
                    .withStructure(StructureFeatures.NETHER_FOSSIL)
                    .withStructure(StructureFeatures.RUINED_PORTAL_NETHER)
                    .withSurfaceBuilder(ModConfiguredSurfaceBuilders.EFFETE_SURFACE_BUILDER)
                    .build();
    
                MobSpawnInfo mobspawn = new MobSpawnInfo.Builder()
                    .withSpawner(EntityClassification.MONSTER, new MobSpawnInfo.Spawners(EntityType.CAT, 4, 2, 4))
                    .copy();
    
    
                BiomeAmbience ambience = new BiomeAmbience.Builder()
                    .withGrassColor(0xDA67C1)
                    .setFogColor(0xEEEEEE)
                    .setWaterColor(0xCF21B8)
                    .setWaterFogColor(0xCF78C5)
                    .withSkyColor(0xE83452)
                    .withFoliageColor(0xCA57C1)
                    .build();
    
                return new Biome.Builder()
                    .category(Biome.Category.NETHER)
                    .withTemperatureModifier(Biome.TemperatureModifier.NONE)
                    .withGenerationSettings(genset)
                    .withMobSpawnSettings(mobspawn)
                    .depth(0.09f)
                    .scale(0.2f)
                    .downfall(0.1f)
                    .precipitation(Biome.RainType.NONE)
                    .temperature(1.1f)
                    .setEffects(ambience)
                    .build();
            }
        }
    
    }

     

  11. 6 hours ago, Brendanp01 said:

    Okay, I'm done arguing with idiotic people. I'll say it one more time, if you know what you're talking about, unlike some people (Draco18s), then tell me.

    Look, when I decided to get into modding C# was the only language I knew. I saw forge and minecraft, were programmed in Java, but I didn't want to learn Java because I loved C#. I looked everywhere for ways to do it and couldn't find none. it's a non-sensical task: you'd need to write wrappers for all the classes that minecraft and forge provides, and then you would need to keep updating it everytime a new mapping or forge/minecraft version came out. it's a lot of work, for very little benefit, the modding communnity isn't big enough for this to be a reasonable project.

    you could look into how to write c# that compiles to jar's, sure.. but you still would need access to classes that exist in Java code.

    What I can tell you is that it is not worth it. We, programmers, can't fall in love for a language and try do to everything with it, it's a very common programming sin. You need to recognize the best language for the job, and accept it. And if you just ahte the language so much you can't even think of writing in it, then maybe not doing the project is just a better option

     

    The best I could recommend you, if you really don't want to write Java, is to take a look at Kotlin or Scala, they are better versions of Java basically.

    Or do what I did, learned Java, it isn't even that bad. but having to do C programming really lowered my bars

     

    and also, maybe think a little bit before saying a Forum Moderator that has been contributing to the modding community for 8+ years, doesn't know what he's talking about. you're the newbie here, tyring to do something that is, honestly, idiotic

    • Thanks 1
  12. 4 hours ago, ehbean said:

    I'm using Eclipse, and that is the right key shortcut. Just gotta figure out how to get this to work now. Copy pasting the variables, and methods doesn't' seem to work outright so I'll need to do some tweaking. 

    That's usually the case, always try to understand the code before copy and pasting, or else you'll get a lot of headaches later in the code's life ;)

    • Thanks 1
  13. 18 minutes ago, ehbean said:

    I feel like looking at those files would be greatly beneficial. Where would I find those?

    in your own IDE you can search for the blocks.

    in IntelliJ you can use Ctrl + N, and type the name of the class you're looking for (RotatedPillarBlock, it's the class the logs use)

    in Eclipse I think it is Ctrl + Shift + T, but I'm not sure

     

    note that the vanilla and forge classes we'll be read-only, you can't edit them

    • Thanks 1
  14. 36 minutes ago, Luis_ST said:

    the method is wrong yes you have to change it to this one (edit: the reason why you get the error you are using the wrong import)

    
    	@Override
    	public BlockState rotate(BlockState state, net.minecraft.util.Rotation rot) {
    		return state.with(FACING, rot.rotate(state.get(FACING)));
    	}

    and you never set the default state in the block constructor

    you have to add:

    
    this.setDefaultState(this.stateContainer.getBaseState().with(FACING, Direction.NORTH));

    and if you want to create a block that works like the quartz pillar,

    then change the class that your block extends to RotatedPillarBlock so you don't have to overwrite the methods for the rotation

    don't give people copy'n'paste code, especially without any explanation as to way they should copy and paste

    • Sad 1
  15. Just now, ehbean said:

    Wouldn't I need to change how that is loaded during registry so it doesn't crash?

    what do you mean? we don't have your registration code, so we can't tell

×
×
  • Create New...

Important Information

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