Jump to content

Nephty

Members
  • Posts

    10
  • Joined

  • Last visited

Everything posted by Nephty

  1. Hello ! I am trying to display an information message above the hotbar. For example, Minecraft can display a messsage such as "You can only sleep at night". This is the kind of message I'm talking about. I don't know what class to use in order to do that, what method, what there's to know and I couldn't find any tutorial/explanation, but maybe I didn't search far enough. Thanks in advance for the help.
  2. Have you been able to generate them properly ? I'm struggling on that bit
  3. Damn this was a stupid topic to open. I'm sorry for making you lose time on such a dumb issue, I hadn't even seen the warning ! Thank you very much for your help.
  4. Actually, no error related to the topic shows up in the console nor in the debug.log. The on ly error is an authentication error. I attached it anyways but I doubt it contains any useful information, but would be glad to be wrong. Here is the code that I use : The block itself : package net.Nephty.rgbee.data.blocks; import net.Nephty.rgbee.setup.ModItems; import net.minecraft.block.BlockState; import net.minecraft.block.FlowerBlock; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.potion.Effect; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.World; public class CustomFlower extends FlowerBlock { public CustomFlower(Effect p_i49984_1_, int p_i49984_2_, Properties p_i49984_3_) { super(p_i49984_1_, p_i49984_2_, p_i49984_3_); } @SuppressWarnings("deprecation") @Override public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTrace) { if (world.isClientSide) { return ActionResultType.SUCCESS; } if (player.isHolding(ModItems.POLLEN_HARVESTER.get())) { if (player.inventory.getFreeSlot() != -1) { if (!player.isCreative()) { player.inventory.getSelected().hurtAndBreak(1, player, (p_226874_1_) -> p_226874_1_.broadcastBreakEvent(hand)); } player.inventory.add(new ItemStack(ModItems.POLLEN::get)); } else { if (!player.isCreative()) { player.inventory.getSelected().hurtAndBreak(1, player, (p_226874_1_) -> p_226874_1_.broadcastBreakEvent(hand)); } popResource(world, pos, new ItemStack(ModItems.POLLEN::get)); } return ActionResultType.SUCCESS; } return ActionResultType.PASS; } } Register the blocks : package net.Nephty.rgbee.setup; import net.Nephty.rgbee.data.blocks.CustomFlower; import net.minecraft.block.AbstractBlock; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.potion.Effects; import net.minecraftforge.common.ToolType; import net.minecraftforge.fml.RegistryObject; import java.util.function.Supplier; public class ModBlocks { public static final RegistryObject<Block> POLLEN_BLOCK = register("pollen_block", () -> new Block(AbstractBlock.Properties.of(Material.WOOL) .sound(SoundType.HONEY_BLOCK) .jumpFactor(0.8F) .harvestTool(ToolType.HOE) .strength(0.3F, 3))); public static final RegistryObject<Block> ENCHANTED_FLOWER = register("enchanted_flower", () -> new CustomFlower(Effects.HEAL, 1, AbstractBlock.Properties.of(Material.PLANT) .noCollission() .instabreak() .noOcclusion() .sound(SoundType.GRASS))); public static void register() {} private static <T extends Block> RegistryObject<T> registerNoItem(String name, Supplier<T> block) { return Registration.BLOCKS.register(name, block); } private static <T extends Block> RegistryObject<T> register(String name, Supplier<T> block) { RegistryObject<T> res = registerNoItem(name, block); Registration.ITEMS.register(name, () -> new BlockItem(res.get(), new Item.Properties().tab(ItemGroup.TAB_BUILDING_BLOCKS))); return res; } } Creation of the deferred register : public class Registration { public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, Rgbee.MOD_ID); public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, Rgbee.MOD_ID); public static void register() { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); BLOCKS.register(modEventBus); ITEMS.register(modEventBus); ModItems.register(); ModBlocks.register(); } } json file of the block located in assets\mod\models\block : { "parent": "minecraft:block/cross", "textures": { "all": "rgbee:block/enchanted_flower" } } I don't know if I need a json file for the texture itself, rather than the model ? I don't know why it wouldn't get created, since it works fine for other items and blocks. Thank you for your time. debug.log
  5. Hello ! I opened a topic earlier today about rendering a flower, and I kind of fixed my issue. As a new and different issue popped, I decided to make a new topic. The thing is now, it seems like the game can't find the texture for the flower (I get the purple/black squares instead of my custom texture). I have been trying to fix this new issue for a couple of hours but nothing to be found helpful. I don't really know why it can't find the texture. I don't get any compile or runtime exception, and every file seems to be in place. I've been messing around but couldn't find the issue. My resources file structure is attached below. I don't know if I need to share any json file, or any part of the code. If so, please ask and I'll gladly provide it. I'm pretty new to the modding field so maybe the issue is obvious. Thanks in advance for the help !
  6. Small update about this topic : whenever I change the string referring to the texture in the json file located in generated\resources\assets\mod\blockstates, there are three scenarios : 1. I use a texture located in the items folder instead of the blocks folder : the rendered block becomes a flat image, as if you simply put the item from your hand on the ground. Not a cross texture, neither a full block. 2. I use the correct texture in the blocks folder : the rendered block is a cross block but the texture is the "missing texture" one, purple and black squares. 3. I use the name of a texture that doesn't exite : the rendered block is a full block with the missing texture.
  7. I guess this is something I must modify in the json file ? I changed it by hand but I don't know how to make it automatic. I use the simpleBlock() method to create a block and I would assume this is what changes the parent. I've realized that no json file is being created when executing task runData or runClient. The thing is, I'm creating another block and it's "itemized" version, and everything works fine. I copied every single step for the flower, and yet it doesn't have any json file. I edited a few json files located in : assets\mod\blockstates and in : assets\mod\models and it seeems to do something. I know have a proper cross rendering, but the texture is still the purple and black squares one. It seems like it doesn't find the texture file. I am thinking that modifying the files by hand is not the best method. I wonder if executing the task runData will overwrite the previous file ? Or if the data is in any danger of potential erasure ? As an example, I said previously that I use the simpleBlock() method and that I think this is what tells the game to create a full block. If I runData, will it overwrite the parent and replace it with a full block again ? Sorry for the messy response, I tried to make it as clear as possible and I am very new to the modding area.
  8. I have found the methods noOcclusion and noCollision when looking at the source code, which was really helpful. What Material could I reference here ? I tried Plant, Decoration, Bamboo Sapling, Grass and Coral but the final result is always the same : the flower looks like what's shown in the picture. In the source code, a Poppy is created using Properties.of(Material.PLANT), so I guessed I'd go with that too. How can I access this json file ? And what can I do to modify the BlockState of my flower ? I found a json file in a ressource pack that has the parent block/cross, but I don't really know how to apply this to my flower. Thank you for the reply !
  9. Hello ! I am creating a custom flower for my mod, and I've encountered an issue. When rendering it, it seems to be rendered as a full block, whereas I'd like it to render as a flower. I've attached a picture showing how it looks like in the game and one that show the texture file, and the code is available below the message. Because it is rendering black faces, I sought and found out about a "isOpaqueBlock" method, yet I can't find it anywhere in the code and using the annotation @Override shows that no such method can be found is super-classes. My class extends FlowerBlock which extends BushBlock which extends Block, so I would assume I should encounter the method somewhere, but it is yet to be found. Also, I think the problem has a second part. The block is on a proper location (has a slight offset), I set the noCollision and stuff, but I can't seem to make it small enough, and use the texture accordingly. By that, I mean not use the texture on every face but the same way a flower does. I tried creating different types of blocks, I sought everywhere for rendering explanations but tutorials are 7 to 8 years old and looks nothing like today's modding. I've been stuck on this for a few days now and I'm quite new to modding, so please be kind Code : package net.Nephty.rgbee.data.blocks; import net.Nephty.rgbee.setup.ModItems; import net.minecraft.block.BlockState; import net.minecraft.block.FlowerBlock; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.potion.Effect; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.World; public class CustomFlower extends FlowerBlock { public CustomFlower(Effect p_i49984_1_, int p_i49984_2_, Properties p_i49984_3_) { super(p_i49984_1_, p_i49984_2_, p_i49984_3_); } @SuppressWarnings("deprecation") @Override public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTrace) { if (world.isClientSide) { return ActionResultType.SUCCESS; } super.use(state, world, pos, player, hand, rayTrace); if (player.isHolding(Items.GLASS_BOTTLE)) { // if the player has a free slot if (player.inventory.getFreeSlot() != -1) { // remove 1 glass bottle and add 1 liquid pollen player.inventory.removeItem(player.inventory.selected, 1); player.inventory.add(new ItemStack(ModItems.LIQUID_POLLEN::get)); } else { // no free slot, remove 1 glass bottle and drop the item on the ground player.inventory.removeItem(player.inventory.selected, 1); popResource(world, pos, new ItemStack(ModItems.LIQUID_POLLEN::get)); } return ActionResultType.SUCCESS; } return ActionResultType.PASS; } /* Tried this, but doesn't help : @Override public boolean isOpaqueBlock() { return false; } */ }
×
×
  • Create New...

Important Information

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