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

Maciej916

Members
  • Posts

    52
  • Joined

  • Last visited

Posts posted by Maciej916

  1. So basically I want to register compatibility with TheOneProbe, something like that:

       private void onCommonSetup(final FMLCommonSetupEvent event) {
            ModNetworking.setup();
            ModGeneration.init();
    
    		// if the one probe is installed
            TOPPlugin.registerCompatibility();
        }

    I didn't test it without mod installed but i think it will fail when it's not present.

  2. 1 hour ago, diesieben07 said:

    You cannot do this, this will be shared between all instances of your item, client and server. I would recommend you use getGameTime instead, which will increase by 1 every tick.

    You can override shouldCauseReequipAnimation in your Item class to control this.

    That was easier than i expected, thank you for the advice, i'll use: 

    if (level.getGameTime() % 20 == 0)

     

  3. I have problem with item reapearing in players hand after changing capability value. Here is what I mean by reapearing:

     021017d319261196dc6e0e1c4408dfa9.gif 

    It only happens when item has tag "active" and energy.consumeEnergy is called. Does it have something to to with capability or im doing something wrong or do i need to sync it with client? Here is the code:

        int tickCounter = 0;
    
        @Override
        public void inventoryTick(ItemStack stack, Level level, Entity entity, int p_41407_, boolean p_41408_) {
            if (!level.isClientSide()) {
                if (++tickCounter == 20) {
                    tickCounter = 0;
    
                    stack.getCapability(ModCapabilities.ENERGY).ifPresent(energy -> {
                        CompoundTag tag = stack.getTag();
                        if (tag != null) {
                            if (tag.getBoolean("active")) {
                                energy.consumeEnergy(Math.min(energy.energyStored(), 100), false);
                            }
    
                            if (energy.energyStored() == 0) {
                                tag.putBoolean("active", false);
                                stack.setTag(tag);
                            }
                        }
                    });
                }
            }
    
            super.inventoryTick(stack, level, entity, p_41407_, p_41408_);
        }

     

  4. Hello, I'm having troubles with adding custom generation on 1.16.3. I used solution from this post https://forums.minecraftforge.net/topic/90560-1162-how-to-add-custom-ore-to-world-generation/ and it's working for ores but i also want to add new tree and Im getting cast error

    RubberTreeBlockStateProvider cannot be cast to net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider

     Code I use:

        public static void initGen() {
            Registry.register(
                    WorldGenRegistries.CONFIGURED_FEATURE,
                    ModBlocks.COPPER_ORE.getRegistryName(),
                    Feature.ORE
                            .withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.field_241882_a /* base_stone_overworld */, ModBlocks.COPPER_ORE.getDefaultState(), ModConfig.worldgen_copper_size))
                            .withPlacement(Placement.field_242907_l/* RANGE */.configure(new TopSolidRangeConfig(ModConfig.worldgen_copper_min_height, 0, ModConfig.worldgen_copper_max_height)))
                            .func_242728_a() /* spreadHorizontally */
                            .func_242731_b(ModConfig.worldgen_copper_size) /* repeat */
            );
    
    
            Registry.register(
                    WorldGenRegistries.CONFIGURED_FEATURE /* Feature Registering */,
                    ModBlocks.RUBBER_SAPLING.getRegistryName() /* Resource Location */,
                    Feature.TREE /* no_surface_ore */.withConfiguration(RUBBER_TREE_CONFIG)
                            .withPlacement(Placement.field_242902_f/* RANGE */.configure(new AtSurfaceWithExtraConfig(12, 12, 72)))
            );
    
        }
    
        public static void setupGen() {
            for (Map.Entry<RegistryKey<Biome>, Biome> biome : WorldGenRegistries.BIOME.getEntries() /* Collection of Biome Entries */) {
                if (!biome.getValue().getCategory().equals(Biome.Category.NETHER) && !biome.getValue().getCategory().equals(Biome.Category.THEEND)) {
    
                    addFeatureToBiome(
                            biome.getValue(),
                            GenerationStage.Decoration.UNDERGROUND_ORES,
                            WorldGenRegistries.CONFIGURED_FEATURE.getOrDefault(ModBlocks.COPPER_ORE.getRegistryName())
                    );
    
                    addFeatureToBiome(
                            biome.getValue(),
                            GenerationStage.Decoration.VEGETAL_DECORATION,
                            WorldGenRegistries.CONFIGURED_FEATURE.getOrDefault(ModBlocks.RUBBER_SAPLING.getRegistryName())
                    );
                }
            }
        }
    
        public static void addFeatureToBiome(Biome biome, GenerationStage.Decoration decoration, ConfiguredFeature<?, ?> configuredFeature) {
            List<List<Supplier<ConfiguredFeature<?, ?>>>> biomeFeatures = new ArrayList<>(
                    biome.getGenerationSettings().getFeatures()/* List of Configured Features */
            );
    
            while (biomeFeatures.size() <= decoration.ordinal()) {
                biomeFeatures.add(Lists.newArrayList());
            }
    
            List<Supplier<ConfiguredFeature<?, ?>>> features = new ArrayList<>(biomeFeatures.get(decoration.ordinal()));
            features.add(() -> configuredFeature);
            biomeFeatures.set(decoration.ordinal(), features);
    
            ObfuscationReflectionHelper.setPrivateValue(BiomeGenerationSettings.class, biome.getGenerationSettings(), biomeFeatures, "features");
        }

     

    Rubber tree:

    public class RubberTree extends Tree {
    
        public static final BaseTreeFeatureConfig RUBBER_TREE_CONFIG = (
                new BaseTreeFeatureConfig.Builder(
                        new RubberTreeBlockStateProvider(ModBlocks.RUBBER_LOG.getDefaultState()),
                        new SimpleBlockStateProvider(ModBlocks.RUBBER_LEAVES.getDefaultState()),
                        new RubberFoliagePlacer(2, 0),
                        new StraightTrunkPlacer(4, 2, 0),
                        new TwoLayerFeature(1, 0, 1))
        ).build();
    
        @Nullable
        @Override
        protected ConfiguredFeature<BaseTreeFeatureConfig, ?> getTreeFeature(Random randomIn, boolean p_225546_2_) {
            return Feature.TREE.withConfiguration(RUBBER_TREE_CONFIG);
        }
    }

     

    Is there a simple solution to fix this? I can add that tree is working correctly in game, Im only having troubles to add it to generation.

  5. Hello I want to save file in current world catalog and Im having problems how to get current world catalog. I tryed to use 

    String worldName = event.getServer().func_240793_aU_().getWorldName();

    But this only gives me world name not actual catalog and multiple worlds can have same name but different catalog. Any ideas how to get proper catalog?

  6. Every time i want to serialize or deserialize FluidTank in tile entity im getting StackOverflow issue, also when i run mod on dedicaded server and when I place block with FluidTank i'm also getting StackOverflow. Is this forge issue or i'm doing something wrong because on 1.15.2 it worked just fine.

     

    [19:45:14] [IO-Worker-18/ERROR] [minecraft/Util]: Caught exception in thread Thread[IO-Worker-18,5,SERVER]
    java.lang.StackOverflowError: null
    	at java.io.DataOutputStream.write(DataOutputStream.java:107) ~[?:1.8.0_251] {}
    	at java.io.DataOutputStream.writeUTF(DataOutputStream.java:401) ~[?:1.8.0_251] {}
    	at java.io.DataOutputStream.writeUTF(DataOutputStream.java:323) ~[?:1.8.0_251] {}
    	at net.minecraft.nbt.CompoundNBT.writeEntry(CompoundNBT.java:407) ~[?:?] {re:classloading}
    	at net.minecraft.nbt.CompoundNBT.write(CompoundNBT.java:84) ~[?:?] {re:classloading}
    	at net.minecraft.nbt.CompoundNBT.writeEntry(CompoundNBT.java:408) ~[?:?] {re:classloading}
    	at net.minecraft.nbt.CompoundNBT.write(CompoundNBT.java:84) ~[?:?] {re:classloading}
    	at net.minecraft.nbt.CompoundNBT.writeEntry(CompoundNBT.java:408) ~[?:?] {re:classloading}
    	at net.minecraft.nbt.CompoundNBT.write(CompoundNBT.java:84) ~[?:?] {re:classloading}
    	at net.minecraft.nbt.CompoundNBT.writeEntry(CompoundNBT.java:408) ~[?:?] {re:classloading}
    	at net.minecraft.nbt.CompoundNBT.write(CompoundNBT.java:84) ~[?:?] {re:classloading}
    	at net.minecraft.nbt.CompoundNBT.writeEntry(CompoundNBT.java:408) ~[?:?] {re:classloading}
    	at net.minecraft.nbt.CompoundNBT.write(CompoundNBT.java:84) ~[?:?] {re:classloading}
    	at net.minecraft.nbt.CompoundNBT.writeEntry(CompoundNBT.java:408) ~[?:?] {re:classloading}
    

     

    Also when I load save with FLuidTank tile im getting

    Caused by: java.lang.RuntimeException: Tried to read NBT tag with too high complexity, depth > 512

     

    My code:

        public final FluidTank tank = new FluidTank(10);
        
        @Override
        public void func_230337_a_(BlockState state, @Nonnull final CompoundNBT compound) {
            super.func_230337_a_(state, compound);
            this.tank.readFromNBT(compound.getCompound("tank"));
        }
    
        @Override
        public CompoundNBT write(CompoundNBT compound) {
            super.write(compound);
            compound.put("tank", this.tank.writeToNBT(compound));
            return compound;
        }

     

    Forge version: 32.0.41

  7. Hello I tryed to generate json resources but GatherDataEvent is never called and idk why because it worked before and now it's not beeing called, there is no error in console.

     

    DataGenerators.class

    @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
    public class DataGenerators {
    
        @SubscribeEvent
        public static void gatherData(GatherDataEvent event) {
            DataGenerator generator = event.getGenerator();
            if (event.includeServer()) {
                generator.addProvider(new Recipes(generator));
                generator.addProvider(new LootTables(generator));
            }
        }
    }

     

    build.gradle

            data {
                workingDirectory project.file('run')
    
                property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
                property 'forge.logging.console.level', 'debug'
    
                args '--mod', 'indreb', '--all', '--output', file('src/generated/resources/')
    
                environment 'target', 'fmluserdevdata'
    
                mods {
                    indreb {
                        source sourceSets.main
                    }
                }
            }

     

  8. On 2/2/2020 at 2:40 PM, Choonster said:

     

    That code creates the recipe in the minecraft namespace, you should use your mod ID as the namespace of the ResourceLocation (i.e. call the two-argument overload of the ResourceLocation constructor).

    Oh didn't know about that ty again

    new ResourceLocation(MODID,"...")

     

  9. 8 minutes ago, Choonster said:

    Use the build overload that takes a ResourceLocation argument to change the name of the generated recipe.

    Thank you it worked :)

     

            CookingRecipeBuilder.smeltingRecipe(Ingredient.fromItems(ModBlocks.COPPER_ORE.get()), ModItems.COPPER_INGOT.get(), 0.6f, 200)
                    .addCriterion("item", InventoryChangeTrigger.Instance.forItems(ModBlocks.COPPER_ORE.get()))
                    .build(consumer, new ResourceLocation("copper_ingot_smelting"));

     

  10. Hello Im trying to generate json recepies by using Receipe Provider and everything is working fine but when I want to add another recipe for same item is show "Duplicate recipe..." error. I want to add crafting and smelting recipe and second one will throw duplicate error.

     

    Im just started to use this method so probably it's easy to fix.

        protected void registerRecipes(Consumer<IFinishedRecipe> consumer) {
            ShapedRecipeBuilder.shapedRecipe(ModItems.COPPER_INGOT.get(), 9)
                    .patternLine("x  ")
                    .key('x', ModBlocks.COPPER_BLOCK.get())
                    .setGroup(MODID)
                    .addCriterion("item", InventoryChangeTrigger.Instance.forItems(ModBlocks.COPPER_BLOCK.get()))
                    .build(consumer);
    
            CookingRecipeBuilder.smeltingRecipe(Ingredient.fromItems(ModBlocks.COPPER_ORE.get()), ModItems.COPPER_INGOT.get(), 0.6f, 200)
                    .addCriterion("item", InventoryChangeTrigger.Instance.forItems(ModBlocks.COPPER_ORE.get()))
                    .build(consumer);
        }

     

    Error:

    Caused by: java.lang.IllegalStateException: Duplicate recipe indreb:copper_ingot

     

  11. This is basicly how the current code works. When you place a cable it looks for network around and possible outputs and inputs, if there is non eit create new network, if there is one it join that nrtwork and if there is more than on it merge all. Each network of cables know possible inputs and outputs and have little storage but can accept or output energy only if there is a valid machine connected. When you break cable it try to rebuild network if network split it create new ones and each new network also know inputs and outputs. 

  12. Hello, couple days ago I started making tech mod but after I add couple machines i realized that I need some sort of cables to transport energy from one machine to another. When I started i didn't know that it will be that hard to make but after some days I was able to make something that works. I know there is some bugs and issues with it and some things are still missing. There is many people on this forum that are more advanced in java programming that Im, If you one of this people you probably can help me improve my code. Im not asking you to code anything just look at my code and give me clues what i can improve or remake to make it better.

     

    Source: https://github.com/Maciej916/Test-Mod/tree/master/src/main/java/com/maciej916/testmod

  13. I don't think it's possibel because it want to load class from client, how can i tick this in other ways?

     

    Code: https://github.com/Maciej916/Test-Mod/blob/master/src/main/java/com/maciej916/testmod/common/capabilities/energy/EnergyNetworkList.java

    Error:

    java.lang.NoClassDefFoundError: net/minecraft/client/renderer/texture/ITickable
    	at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.8.0_211] {}
    	at java.lang.ClassLoader.defineClass(Unknown Source) ~[?:1.8.0_211] {}
    	at java.lang.ClassLoader.defineClass(Unknown Source) ~[?:1.8.0_211] {}
    	at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:127) ~[modlauncher-5.0.0-milestone.4.jar:?] {}
    	at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:96) ~[modlauncher-5.0.0-milestone.4.jar:?] {}
    	at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_211] {}
    	at com.maciej916.testmod.ForgeEventSubscriber.onAttachCapabilities(ForgeEventSubscriber.java:18) ~[?:1.15.1-0.1.0] {re:classloading}
    	at net.minecraftforge.eventbus.ASMEventHandler_5_ForgeEventSubscriber_onAttachCapabilities_AttachCapabilitiesEvent.invoke(.dynamic) ~[?:?] {}
    	at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:80) ~[eventbus-2.0.0-milestone.1-service.jar:?] {}
    	at net.minecraftforge.eventbus.EventBus.post(EventBus.java:258) ~[eventbus-2.0.0-milestone.1-service.jar:?] {}
    	at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:564) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
    	at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:558) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
    	at net.minecraftforge.common.capabilities.CapabilityProvider.gatherCapabilities(CapabilityProvider.java:48) ~[?:?] {re:classloading}
    	at net.minecraft.world.server.ServerWorld.initCapabilities(ServerWorld.java:1419) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
    	at net.minecraft.world.server.ServerWorld.<init>(ServerWorld.java:190) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
    	at net.minecraft.server.MinecraftServer.func_213194_a(MinecraftServer.java:372) ~[?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    	at net.minecraft.server.MinecraftServer.func_71247_a(MinecraftServer.java:361) ~[?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    	at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:210) ~[?:?] {re:classloading,pl:accesstransformer:B}
    	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:610) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    	at java.lang.Thread.run(Unknown Source) [?:1.8.0_211] {}
    Caused by: java.lang.ClassNotFoundException: net.minecraft.client.renderer.texture.ITickable
    	at java.lang.ClassLoader.findClass(Unknown Source) ~[?:1.8.0_211] {}
    	at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_211] {}
    	at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:101) ~[modlauncher-5.0.0-milestone.4.jar:?] {}
    	at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_211] {}
    	... 20 more

     

  14. How I can use multiple texture locations while drawing gui elements. I know how to use only one texture. Please be tolerant Im trying to learn something new.

     

        @Override
        protected void drawGuiContainerBackgroundLayer(final float partialTicks, final int mouseX, final int mouseY) {
            RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
            getMinecraft().getTextureManager().bindTexture(BACKGROUND_TEXTURE);
    
            int startX = this.guiLeft;
            int startY = this.guiTop;
            this.blit(startX, startY, 0, 0, this.xSize, this.ySize);
    
            this.blit(x, y, u, v, width, height);
    
    		// How can i draw another element here using other texture than "BACKGROUND_TEXTURE"
          
        }

     

×
×
  • Create New...

Important Information

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