Jump to content

Recommended Posts

Posted (edited)

I am trying to make custom block that looks like a type of plush of a player and make it work just like the skulls.

The block already works but for some reason i cant seem to get past the consumer.accept in the initializeClient

The Item class

public class PlushItem extends BlockItem {

    public PlushItem(Block block) {
        super(block, new Item.Properties().tab(FurniatureItemGroup.FURNIATURE));
    }

    @Override
    public void initializeClient(Consumer<IItemRenderProperties> consumer) {
        consumer.accept(new IItemRenderProperties() {
            @Override
            public BlockEntityWithoutLevelRenderer getItemStackRenderer() {
                return new ItemStackRenderer();
            }
        });
    }
}

The item stack renderer

public class ItemStackRenderer extends BlockEntityWithoutLevelRenderer {
    private static HashMap<Plush.Type, PlushModelBase> plushModels;

    public ItemStackRenderer() {
        super(Minecraft.getInstance().getBlockEntityRenderDispatcher(), Minecraft.getInstance().getEntityModels());
    }

    private static void init() {
        plushModels = new HashMap<>();
        for (Plush.Type type : Plush.Types.values()) {
            PlushModelBase plushModelBase = new PlushModelBase();
            plushModels.put(type, plushModelBase);
        }
    }

    @Override
    public void renderByItem(ItemStack stack, ItemTransforms.TransformType transformType, PoseStack matrixStackIn, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) {
        if (plushModels == null) init();
        Furniature.LOGGER.info(plushModels + " :Render By Item");
        Item[] items = {FurniatureItems.HEATH_PLUSH.get(), FurniatureItems.PLAYER_PLUSH.get()};
        for (Item item : items) {
            if (item instanceof BlockItem) {
                Block block = ((BlockItem) item).getBlock();
                if (block instanceof PlushBlock) {
                    GameProfile gameprofile = null;
                    if (stack.hasTag()) {
                        CompoundTag compoundtag = stack.getTag();
                        if (compoundtag.contains("SkullOwner", 10)) {
                            gameprofile = NbtUtils.readGameProfile(compoundtag.getCompound("SkullOwner"));
                        } else if (compoundtag.contains("SkullOwner", 8) && !StringUtils.isBlank(compoundtag.getString("SkullOwner"))) {
                            gameprofile = new GameProfile(null, compoundtag.getString("SkullOwner"));
                            compoundtag.remove("SkullOwner");
                            SkullBlockEntity.updateGameprofile(gameprofile, (p_172560_) -> {
                                compoundtag.put("SkullOwner", NbtUtils.writeGameProfile(new CompoundTag(), p_172560_));
                            });
                        }
                    }

                    Plush.Type PlushType = ((PlushBlock) block).getType();
                    PlushModelBase modelBase = plushModels.get(PlushType);
                    RenderType rendertype = PlushBlockRenderer.getRenderType(PlushType, gameprofile);
                    PlushBlockRenderer.renderPlush((Direction) null, 180.0F, 0.0F, matrixStackIn, bufferIn, combinedLightIn, modelBase, rendertype);
                }
            }
        }
    }
}

I am fully aware that is probably still wont work but i am just not sure on how to go further.

 

Edited by Aligatetcolt
Posted

Alright but it keeps saying Method call expected with Insert New.

Even if i do this.

    @Override
    public void initializeClient(Consumer<IItemRenderProperties> consumer) {
        ItemStackRenderer plushItemRender = new ItemStackRenderer();
        consumer.accept(new IItemRenderProperties() {
            @Override
            public BlockEntityWithoutLevelRenderer getItemStackRenderer() {
                Furniature.LOGGER.info("But does it get here?");
                return plushItemRender;
            }
        });
    }

 

Posted (edited)

Alright. i was just confused then. but weirdly enough it still does not get past the consumer.accept. at least the logger i put in never is triggered. so its not in the logs.

 

Also sorry i have been on this problem for a few while now and i just completely blank out sometimes.

Edited by Aligatetcolt
To make it look a bit better and expain some things
Posted

Well i put this (Furniature.LOGGER.info("But does it get here?");) in the BlockEntityWithoutLevelRenderer.  But i cant find it in the log. so what i thought was that it never reached that point as you can see in the code i send earlier.

28 minutes ago, Aligatetcolt said:
    @Override
    public void initializeClient(Consumer<IItemRenderProperties> consumer) {
        ItemStackRenderer plushItemRender = new ItemStackRenderer();
        consumer.accept(new IItemRenderProperties() {
            @Override
            public BlockEntityWithoutLevelRenderer getItemStackRenderer() {
                Furniature.LOGGER.info("But does it get here?");
                return plushItemRender;
            }
        });
    }

 

Posted

Yeah it seems like i did make a mistake and now it does go to the code. there is still one other problem and that is that the items are invisible. i guess something is wrong with my item render class.

Posted

I got it working.

 

I had to still use the Minecraft.getInstance().getEntityModels() And use that in plushRenderer.

 

public class ItemStackRenderer extends BlockEntityWithoutLevelRenderer{
    private EntityModelSet entityModelSet;

    private Map<Plush.Type, PlushModelBase> plushModelBaseMap;

    public ItemStackRenderer(BlockEntityRenderDispatcher RenderDispatcher, EntityModelSet ModelSet) {
        super(RenderDispatcher, ModelSet);

    }

@Override
    public void onResourceManagerReload(ResourceManager resourceManager) {

    }

    @Override
    public void renderByItem(ItemStack stack, ItemTransforms.TransformType transformType, PoseStack matrixStackIn, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) {
        Item item = stack.getItem();
            if (item instanceof BlockItem) {
                Block block = ((BlockItem) item).getBlock();
                if (block instanceof PlushBlock) {
                    GameProfile gameprofile = null;
                    if (stack.hasTag()) {
                        CompoundTag compoundtag = stack.getTag();
                        if (compoundtag.contains("SkullOwner", 10)) {
                            gameprofile = NbtUtils.readGameProfile(compoundtag.getCompound("SkullOwner"));
                        } else if (compoundtag.contains("SkullOwner", 8) && !StringUtils.isBlank(compoundtag.getString("SkullOwner"))) {
                            gameprofile = new GameProfile(null, compoundtag.getString("SkullOwner"));
                            compoundtag.remove("SkullOwner");
                            SkullBlockEntity.updateGameprofile(gameprofile, (p_172560_) -> {
                                compoundtag.put("SkullOwner", NbtUtils.writeGameProfile(new CompoundTag(), p_172560_));
                            });
                        }
                    }

                    Plush.Type PlushType = ((PlushBlock) block).getType();
                    this.entityModelSet = Minecraft.getInstance().getEntityModels();
                    plushModelBaseMap = PlushBlockRenderer.createPlushRenderers(this.entityModelSet);;
                    PlushModelBase modelBase = plushModelBaseMap.get(PlushType);
                    RenderType rendertype = PlushBlockRenderer.getRenderType(PlushType, gameprofile);
                    Furniature.LOGGER.info(gameprofile +" :Gameprofile");
                    Furniature.LOGGER.info(PlushType+" :Plush Type");
                    Furniature.LOGGER.info(modelBase+" :Model Base");
                    PlushBlockRenderer.renderPlush((Direction) null, 180.0F, 0.0F, matrixStackIn, bufferIn, combinedLightIn, modelBase, rendertype);
                }
            }
        }
    }

 

  • Aligatetcolt changed the title to [FIXED] [1.18.2] Problems with BlockEntityWithoutLevelRenderer

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

    • There is an issue with Create - maybe a conflict with randompatches
    • Honestly, the forums are a back burner thing. Not many people use it. Best option is discord. I know that I haven't looked at the forums for more then admin tasks in quite a while. You're also best off not following tutorials which give you code. Knowing programming and reading the MC/Forge code yourself would be the best way to go.
    • on my last computer, i had a similar problem with forge/ neoforge mods but instead them launcher screen was black
    • I am trying to make a mod, all it is, a config folder that tells another mod to not require a dependency, pretty simple right.. well, I dont want whoever downloads my mod to have to download 4 other mods and then decide if they want 2 more that they kinda really need.. i want to make my mod basically implement all of these mods, i really dont care how it does it, ive tried putting them in every file location you can think of, ive downloaded intellij, mcreator, and tried vmware but thats eh (had it from school). I downloaded them in hopes theyd create the correct file i needed but honestly im only more lost now. I have gotten my config file to work, if i put all these mods into my own mods folder and the config file into the config and it works (unvbelievably) but i want to share this to everyone else, lets just say this mod will legitimately get 7M downloads.  I tried putting them in a run folder then having it create all the contents in that for a game (mods,config..etc) then i drop the mods in and all the sudden i cant even open the game, like it literally works with my own world i play on, but i cant get it to work on any coding platform, they all have like built in java versions you cant switch, its a nightmare. I am on 1.20.1 I need Java 17 (i dont think the specific versions of 17 matter) I have even tried recreating the mods i want to implement and deleting import things like net.adamsandler.themodsname and replacing it with what mine is. that only creates other problems, where im at right now is i got the thing to start opening then it crashes, closest ive gotten it, then it just says this  exception in thread "main" cpw.mods.niofs.union.unionfilesystem$uncheckedioexception: java.util.zip.zipexception: zip end header not found caused by: java.util.zip.zipexception: zip end header not found basically saying theres something wrong with my java.exe file, so i tried downloading so many different versions of java and putting them all in so many different spots, nothing, someone online says its just a mod that isnt built right so i put the mod into an editor and bunch of errors came up, id post it but i deleted it on accident, i just need help integrating mods
    • Vanilla 1.16.5 Crash Report [#L2KYKaK] - mclo.gs  
  • Topics

×
×
  • Create New...

Important Information

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