Jump to content

GhostGaming

Members
  • Posts

    23
  • Joined

  • Last visited

Everything posted by GhostGaming

  1. Is it possible to get partial ticks for rendering in the BlockEntityWithoutLevelRenderer::renderByItem method? I'm trying to render a block similar to the jeb_ sheep, but to achieve this I need access to the rendering ticks, which are sadly not given in the renderByItem method. Or should I just use an animated texture for this? (I would prefer not to for flexibility reasons)
  2. I finally got it working! For anyone wanting to achieve this in the future: public void render(CustomBlockEntity blockEntity, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight, int packedOverlay) { VertexConsumer vertexConsumer = VertexMultiConsumer.create(bufferSource.getBuffer(RenderType.glintDirect()), bufferSource.getBuffer(RenderType.solid())); BlockState blockState = CustomBlocks.CUSTOM_BLOCK.get().defaultBlockState(); Level level = blockEntity.getLevel(); BakedModel model = this.blockRenderer.getBlockModel(blockState); this.modelRenderer.tesselateBlock(level, model, blockState, blockEntity.getBlockPos(), poseStack, vertexConsumer, false, level.getRandom(), 0, packedOverlay); } @warjort, thank you so much again!
  3. Well, I'm actually trying to draw the enchanting glint over a block and that turned out way more difficult than it should be But I think your answer pushed me in the right direction. Thanks!
  4. I have a custom block entity and whenever it renders something it appears completely dark. In it's render method, the value of packedLight is always 0. @Override public void render(CustomBlockEntity blockEntity, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight, int packedOverlay) { // packedLight is always 0? } If I disable ambient occlusion in the corresponding block's properties, the block entity doesn't render dark anymore but the lighting still isn't correct. I'm basically only trying to render a solid block. Can anyone help me with this?
  5. I simply mean this effect: This effect is achieved by using TntMinecartRenderer.renderWhiteSolidBlock(this.blockRenderer, this.tntBlock.defaultBlockState(), poseStack, bufferSource, packedLight, i / 5 % 2 == 0); which executes following code int i; if (p_234667_) { i = OverlayTexture.pack(OverlayTexture.u(1.0F), 10); } else { i = OverlayTexture.NO_OVERLAY; } p_234662_.renderSingleBlock(p_234663_, p_234664_, p_234665_, p_234666_, i); but using OverlayTexture.pack(OverlayTexture.u(1.0F), 10); in ItemRenderer::renderStatic like so this.itemRenderer.renderStatic(stack, ItemTransforms.TransformType.FIXED, packedLight, OverlayTexture.pack(OverlayTexture.u(1.0F), 10), poseStack, bufferSource, pos); does not add a white overlay to the rendererd item. Would you know, how to achieve this?
  6. I have an entity that uses ItemRenderer::renderStatic to render an item. Now, how would I render an overlay effect, like the mob damage or TNT flashing effects, onto said item? I've tried a lot of different things from the OverlayTexture class but nothing worked.
  7. I'm currently trying to render the enchanting glint on a custom block model. Using the different enchanting glint RenderTypes on the model obviously doesn't work because they are not of type DefaultVertexFormat.BLOCK. Does anyone have an idea on how I would need to tackle this? Thanks in advance!
  8. I added a custom BlockItem for my block and now I want it to be enchantable with sword enchantments. I tried overwriting canApplyAtEnchantingTable but this doesn't work. Here is the whole class: public class SwordBlockItem extends BlockItem { public SwordBlockItem(Block block, Properties properties) { super(block, properties); } @Override public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) { return true; } @Override public boolean isEnchantable(ItemStack stack) { return true; } @Override public boolean isBookEnchantable(ItemStack stack, ItemStack book) { return true; } } For testing purposes I made all three of those methods return true. Applying books in an anvil works completely fine. It's just that no enchantment shows up in the enchantment table.
  9. Hi all, I have a problem with shrinking the player. I'm using EntityEvent.Size to shrink the player's bounding box and lower the eye height and therefore the camera position. This is really simple and all working fine (and basically all of the mod's code), but whenever I get close to blocks, the camera starts clipping through them. I have looked at other shrinking mods but all of them use mixin which I preferably don't want to use. I hope someone can help me, thanks!
  10. In the constructor of the block and by using DispenserBlock.registerDispenseBehavior() DispenserBlock.registerDispenseBehavior(this, new DefaultDispenseItemBehavior() { protected ItemStack dispenseStack(IBlockSource source, ItemStack stack) { World world = source.getWorld(); BlockPos blockpos = source.getBlockPos().offset(source.getBlockState().get(DispenserBlock.FACING)); BlockTNTGhostsExplosives block = (BlockTNTGhostsExplosives) ((BlockItem) stack.getItem()).getBlock(); if (block.getProperties().isIgnitableByDispensers()) { EntityTNTGhostsExplosives tntentity = new EntityTNTGhostsExplosives(world, (double) blockpos.getX() + 0.5D, (double) blockpos.getY(), (double) blockpos.getZ() + 0.5D, (LivingEntity) null, block.getProperties()); world.addEntity(tntentity); world.playSound(null, tntentity.getPosX(), tntentity.getPosY(), tntentity.getPosZ(), SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F); stack.shrink(1); } else { Direction direction = source.getBlockState().get(DispenserBlock.FACING); IPosition iposition = DispenserBlock.getDispensePosition(source); ItemStack itemstack = stack.split(1); doDispense(source.getWorld(), itemstack, 6, direction, iposition); } return stack; } });
  11. I've examined what exactly caused the problem and it had nothing to do with the registry event but instead with registering the dispense behavior. I don't understand why this is happening but as soon as I register any sort of dispense behavior, even the default one, it won't show up in the creative inventory anymore. Really weird
  12. Yes, I realized that as well, thank you anyways
  13. So my blocks are being registered again just by subscribing to the registry event? Interesting, I though that event was just called after all blocks have been registered. But anyways, thanks for your help ?
  14. Well... I got my project back running and the issue still exists. Here is the github repository
  15. I tried using GitHub Desktop to publish my repository but it looks like it completely wrecked my project because all my source files are gone, so I'm gonna cry now for a few days and maybe I'll come back here after I've implemented everything back ?
  16. Here is an image where I tried to add the block in the hotbar to my custom creative tab and set it as the tab icon My custom ItemGroup class: public class ModItemGroups { public static final ItemGroup ITEMGROUP_TNT_BLOCKS = new ModItemGroup("tnt_blocks", () -> new ItemStack(ModBlocks.TNT_X5.get())); public static final ItemGroup ITEMGROUP_TNT_MINECARTS = new ModItemGroup("tnt_minecarts", () -> new ItemStack(Items.TNT_MINECART)); public static final class ModItemGroup extends ItemGroup { @Nonnull private final Supplier<ItemStack> iconSupplier; public ModItemGroup(@Nonnull final String name, @Nonnull final Supplier<ItemStack> iconSupplier) { super(GhostsExplosives.MODID + "." + name); this.iconSupplier = iconSupplier; } @Override @Nonnull public ItemStack createIcon() { return iconSupplier.get(); } } }
  17. ItemGroup.SEARCH is the vanilla item group where you can search for items I believe
  18. Sorry, I was on my phone ? My Mod class constructor: public GhostsExplosives() { final ModLoadingContext modLoadingContext = ModLoadingContext.get(); final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); ModBlocks.BLOCKS.register(modEventBus); ModItems.ITEMS.register(modEventBus); ModEntityTypes.ENTITY_TYPES.register(modEventBus); modLoadingContext.registerConfig(ModConfig.Type.CLIENT, ConfigHolder.CLIENT_SPEC, "ghostsexplosives2-client.toml"); modLoadingContext.registerConfig(ModConfig.Type.SERVER, ConfigHolder.SERVER_SPEC, "ghostsexplosives2-server.toml"); } My ModBlocks class: public static final DeferredRegister<Block> BLOCKS = new DeferredRegister<>(ForgeRegistries.BLOCKS, GhostsExplosives.MODID); public static final RegistryObject<BlockTNTGhostsExplosives> TNT_X1_2 = registerBlockTNT(TNTProperties.TNT_X1_2); My ModEventBusSubscriber class: @Mod.EventBusSubscriber(modid = GhostsExplosives.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) public class ModEventBusSubscriber { @SubscribeEvent public static void onItemRegistry(RegistryEvent.Register<Item> event) { final IForgeRegistry<Item> registry = event.getRegistry(); ModBlocks.BLOCKS.getEntries().stream().map(RegistryObject::get).forEach(block -> { final Item.Properties properties = new Item.Properties().group(ItemGroup.SEARCH); final BlockItem blockItem = new BlockItem(block, properties); blockItem.setRegistryName(block.getRegistryName()); registry.register(blockItem); }); } I think this should be everything important
  19. Basically, I loop through all my blocks in the item registry event and create and register a new ItemBlock with the ItemGroup. The weird thing is, that even when using one of my blocks as the tab icon it doesn't show up
  20. Yes, I did. I used the code that Cadiboo used in his example mod
  21. I created a mod a few days ago but moved everything to a new project to tidy it up because I really wasn't happy with how unorganized everything was (although most things were working fine). For the most part, the code didn't change which is why I'm utterly confused on why the blocks are not being added to the creative inventory anymore. I tried it with a custom creative tab and also with the vanilla ones but it's not working in both cases. I checked whether the BlockItems are not being registered but they are. I can place the blocks down using /setblock, I can give them to myself using /give and place them down afterwards but they are not only not being rendered in the creative inv, they simply don't exist. Anyone has a clue why this could happen?
×
×
  • Create New...

Important Information

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