Jump to content

Recommended Posts

Posted

Okay, this is how I registered it:

    public static final Block MARBLEGRASS = new GrassBlock(Block.Properties.create(Material.ORGANIC)
            .tickRandomly().hardnessAndResistance(4.0F).sound(SoundType.PLANT)).setRegistryName("marble_grass");
event.getRegistry().register(MoreStuff.MARBLEGRASS);
event.getRegistry().register(new MarbleDirt_BlockItem(MoreStuff.MARBLEGRASS, properties.group(MoreStuff.morestuff_rock.GroupRock).maxStackSize(32)).setRegistryName("marble_grass"));

I made the model files just like the vanilla ones, the BlockItem has a texture where the "grass" part is grey, just like the texture file.

When I place my block it has the error texture and I have no idea why, could you help me or give me any reference?

 

Here are my model files:

 

morestuff/blockstates/marble_grass

{
  "variants": {
    "snowy=false": [
      { "model": "morestuff:block/soil/marble_grass" },
      { "model": "morestuff:block/soil/marble_grass", "y": 90 },
      { "model": "morestuff:block/soil/marble_grass", "y": 180 },
      { "model": "morestuff:block/soil/marble_grass", "y": 270 }
    ],
    "snowy=true":  { "model": "morestuff:block/soil/marble_grass_snowy" }
  }
}

 

morestuff/models/block/soil/marble_grass

{   "parent": "block/block",
  "textures": {
    "particle": "morestuff:block/soil/dirt_marble",
    "bottom": "morestuff:block/soil/dirt_marble",
    "top": "block/grass_block_top",
    "side": "morestuff:block/soil/dirt_marble",
    "overlay": "block/grass_block_side_overlay"
  },
  "elements": [
    {   "from": [ 0, 0, 0 ],
      "to": [ 16, 16, 16 ],
      "faces": {
        "down":  { "uv": [ 0, 0, 16, 16 ], "texture": "#bottom", "cullface": "down" },
        "up":    { "uv": [ 0, 0, 16, 16 ], "texture": "#top",    "cullface": "up", "tintindex": 0 },
        "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#side",   "cullface": "north" },
        "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#side",   "cullface": "south" },
        "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "#side",   "cullface": "west" },
        "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "#side",   "cullface": "east" }
      }
    },
    {   "from": [ 0, 0, 0 ],
      "to": [ 16, 16, 16 ],
      "faces": {
        "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "north" },
        "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "south" },
        "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "west" },
        "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay", "tintindex": 0, "cullface": "east" }
      }
    }
  ]
}

 

morestuff/models/block/soil/marble_grass_snowy

{
  "parent": "block/cube_bottom_top",
  "textures": {
    "particle": "morestuff:block/soil/dirt_marble",
    "bottom": "morestuff:block/soil/dirt_marble",
    "top": "block/grass_block_top",
    "side": "morestuff:block/soil/marble_grass_snowy"
  }
}

 

morestuff/models/item/marble_grass

{
  "parent": "morestuff:block/soil/marble_grass"
}
Posted

Could you post the log? In the meantime, you can try and use vanilla Minecraft's grass model and see if that works (minecraft:block/grass_block).

And I would recommend creating a different block class for your grass block if you are going to add more blocks in your mod, it can get cluttered pretty easily.

Posted (edited)
2 minutes ago, Simon_kungen said:

Could you post the log? In the meantime, you can try and use vanilla Minecraft's grass model and see if that works (minecraft:block/grass_block).

And I would recommend creating a different block class for your grass block if you are going to add more blocks in your mod, it can get cluttered pretty easily.

I found out what the problem is, I need a ColorHandler.

Edited by MatsCraft1
  • Like 1
Posted

Okay, I got this far now

package com.aug15.morestuff.blocks;


import com.aug15.morestuff.MoreStuff;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.color.BlockColors;
import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.client.renderer.color.ItemColors;
import net.minecraft.item.BlockItem;
import net.minecraft.world.GrassColors;
import net.minecraft.world.biome.BiomeColors;
import net.minecraftforge.client.event.ColorHandlerEvent;
import net.minecraftforge.event.terraingen.BiomeEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

@Mod.EventBusSubscriber(modid = MoreStuff.MODID)
public class ModColourManager {

    @SubscribeEvent
    public static void registerBlockColourHandlers(final ColorHandlerEvent.Block event) {
        final BlockColors blockColors = event.getBlockColors();

        final IBlockColor grassColourHandler = (state, blockAccess, pos, tintIndex) -> {
            if (blockAccess != null && pos != null) {
                return BiomeEvent.BiomeColor.GetGrassColor(biome, original);
            }

            return GrassColors.get(0.5D, 1.0D);
        };

        blockColors.register(grassColourHandler, MoreStuff.MARBLEGRASS);
    }

    @SubscribeEvent
    public static void registerItemColourHandlers(final ColorHandlerEvent.Item event) {
        final BlockColors blockColors = event.getBlockColors();
        final ItemColors itemColors = event.getItemColors();

        final IItemColor itemBlockColourHandler = (stack, tintIndex) -> {
            @SuppressWarnings("deprecation")
            final BlockState state = ((BlockItem) stack.getItem()).getBlock().getDefaultState();
            return blockColors.getColor(state, null, null, tintIndex);
        };

        itemColors.register(itemBlockColourHandler, MoreStuff.MARBLEGRASS);
    }
}

 

but I have no idea what to put here

return BiomeEvent.BiomeColor.GetGrassColor(biome, original);

"biome, original" is marked as wrong "cannot resolve symbol"

Posted
2 hours ago, diesieben07 said:

I don't know what you are trying to achieve there. You need to reigster an instance of IBlockColor to the instance of BlockColors thats provided to you by the event.

IBlockColor is a simple interface that takes in information about a block position and produces the color that that block si supposed to have.

like this?

        @OnlyIn(Dist.CLIENT)
        @SubscribeEvent
        public static void registerBlockColorHandlers(final ColorHandlerEvent.Block event) {
            event.getBlockColors().register((x, reader, pos, u) -> reader != null
                    && pos != null ? BiomeColors.getGrassColor(reader, pos)
                    : GrassColors.get(0.5D, 1.0D), MoreStuff.MARBLEGRASS);
        }

 

Posted (edited)
6 minutes ago, diesieben07 said:

For a start you should not be creating your block in a static intializer.

Use the proper registry event.

If I did that, how would I make it have its own custom BlockItem?

Edited by MatsCraft1
Posted (edited)

 

27 minutes ago, diesieben07 said:

For a start you should not be creating your block in a static intializer.

Use the proper registry event.

Oh my god, thank you! That was the problem!

Edited by MatsCraft1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • logs too big for one pastebin https://pastebin.com/ZjUGHu3u  https://pastebin.com/RqCUZf3X  https://pastebin.com/6ZPS99nD
    • You probably used jd-gui to open it, didn't you? Nothing wrong with that, I also made that mistake, except that Notch was a smart guy and he obfuscated the code. That's why you only see files called "a", "b", "c" and then a file that combines them all. As I said, use RetroMCP to deobfuscate the code so that you will 100% understand it and be able to navigate it.
    • Decompiling minecraft indev, infdev, alpha, beta or whichever legacy version is really easy. I'm not a plug, I just also got interested in modding legacy versions (Infdev to be specific). Use https://github.com/MCPHackers/RetroMCP-Java Once you install their client and the Zulu Architecture that they say they recommend (or use your own Java). I encountered some problems, so I run it with: "java -jar RetroMCP-Java-CLI.jar". You should run it in a seperate folder (not in downloads), otherwise the files and folders will go all over the place. How to use RetroMCP: Type setup (every time you want change version), copy-paste the version number from their list (they support indev), write "decompile" and done! The code will now be deobfuscated and filenames will be normal, instead of "a", "b" and "c"! Hope I helped you, but I don't expect you to reply, as this discussion is 9 years old! What a piece of history!  
    • I know that this may be a basic question, but I am very new to modding. I am trying to have it so that I can create modified Vanilla loot tables that use a custom enchantment as a condition (i.e. enchantment present = item). However, I am having trouble trying to implement this; the LootItemRandomChanceWithEnchantedBonusCondition constructor needs a Holder<Enchantment> and I am unable to use the getOrThrow() method on the custom enchantment declared in my mod's enchantments class. Here is what I have so far in the GLM:   protected void start(HolderLookup.Provider registries) { HolderLookup.RegistryLookup<Enchantment> registrylookup = registries.lookupOrThrow(Registries.ENCHANTMENT); LootItemRandomChanceWithEnchantedBonusCondition lootItemRandomChanceWithEnchantedBonusCondition = new LootItemRandomChanceWithEnchantedBonusCondition(0.0f, LevelBasedValue.perLevel(0.07f), registrylookup.getOrThrow(*enchantment here*)); this.add("nebu_from_deepslate", new AddItemModifier(new LootItemCondition[]{ LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.DEEPSLATE).build(), LootItemRandomChanceCondition.randomChance(0.25f).build(), lootItemRandomChanceWithEnchantedBonusCondition }, OrichalcumItems.NEBU.get())); }   Inserting Enchantments.[vanilla enchantment here] actually works but trying to declare an enchantment from my custom enchantments class as [mod enchantment class].[custom enchantment] does not work even though they are both a ResourceKey and are registered in Registries.ENCHANTMENT. Basically, how would I go about making it so that a custom enchantment declared as a ResourceKey<Enchantment> of value ResourceKey.create(Registries.ENCHANTMENT, ResourceLocation.fromNamespaceAndPath([modid], [name])), declared in a seperate enchantments class, can be used in the LootItemRandomChanceWithEnchantedBonusCondition constructor as a Holder? I can't use getOrThrow() because there is no level or block entity/entity in the start() method and it is running as datagen. It's driving me nuts.
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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