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

New Block Render Type?


Alix_The_Alicorn
 Share

Recommended Posts

I'm trying to make a new version of the lever, and like the lever it doesn't need a tile entity. So I need a way to custom render (like the lever) without making a TileEntity. I figured out that the lever is rendered by this code

public boolean renderBlockLever(Block p_147790_1_, int p_147790_2_, int p_147790_3_, int p_147790_4_)
    {
        int var5 = this.blockAccess.getBlockMetadata(p_147790_2_, p_147790_3_, p_147790_4_);
        int var6 = var5 & 7;
        boolean var7 = (var5 &  > 0;
        Tessellator var8 = Tessellator.instance;
        boolean var9 = this.hasOverrideBlockTexture();

        if (!var9)
        {
            this.setOverrideBlockTexture(this.getBlockIcon(Blocks.cobblestone));
        }

        float var10 = 0.25F;
        float var11 = 0.1875F;
        float var12 = 0.1875F;

        if (var6 == 5)
        {
            this.setRenderBounds((double)(0.5F - var11), 0.0D, (double)(0.5F - var10), (double)(0.5F + var11), (double)var12, (double)(0.5F + var10));
        }
        else if (var6 == 6)
        {
            this.setRenderBounds((double)(0.5F - var10), 0.0D, (double)(0.5F - var11), (double)(0.5F + var10), (double)var12, (double)(0.5F + var11));
        }
        else if (var6 == 4)
        {
            this.setRenderBounds((double)(0.5F - var11), (double)(0.5F - var10), (double)(1.0F - var12), (double)(0.5F + var11), (double)(0.5F + var10), 1.0D);
        }
        else if (var6 == 3)
        {
            this.setRenderBounds((double)(0.5F - var11), (double)(0.5F - var10), 0.0D, (double)(0.5F + var11), (double)(0.5F + var10), (double)var12);
        }
        else if (var6 == 2)
        {
            this.setRenderBounds((double)(1.0F - var12), (double)(0.5F - var10), (double)(0.5F - var11), 1.0D, (double)(0.5F + var10), (double)(0.5F + var11));
        }
        else if (var6 == 1)
        {
            this.setRenderBounds(0.0D, (double)(0.5F - var10), (double)(0.5F - var11), (double)var12, (double)(0.5F + var10), (double)(0.5F + var11));
        }
        else if (var6 == 0)
        {
            this.setRenderBounds((double)(0.5F - var10), (double)(1.0F - var12), (double)(0.5F - var11), (double)(0.5F + var10), 1.0D, (double)(0.5F + var11));
        }
        else if (var6 == 7)
        {
            this.setRenderBounds((double)(0.5F - var11), (double)(1.0F - var12), (double)(0.5F - var10), (double)(0.5F + var11), 1.0D, (double)(0.5F + var10));
        }

        this.renderStandardBlock(p_147790_1_, p_147790_2_, p_147790_3_, p_147790_4_);

        if (!var9)
        {
            this.clearOverrideBlockTexture();
        }

        var8.setBrightness(p_147790_1_.getBlockBrightness(this.blockAccess, p_147790_2_, p_147790_3_, p_147790_4_));
        var8.setColorOpaque_F(1.0F, 1.0F, 1.0F);
        IIcon var13 = this.getBlockIconFromSide(p_147790_1_, 0);

        if (this.hasOverrideBlockTexture())
        {
            var13 = this.overrideBlockTexture;
        }

        double var14 = (double)var13.getMinU();
        double var16 = (double)var13.getMinV();
        double var18 = (double)var13.getMaxU();
        double var20 = (double)var13.getMaxV();
        Vec3[] var22 = new Vec3[8];
        float var23 = 0.0625F;
        float var24 = 0.0625F;
        float var25 = 0.625F;
        var22[0] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)(-var23), 0.0D, (double)(-var24));
        var22[1] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)var23, 0.0D, (double)(-var24));
        var22[2] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)var23, 0.0D, (double)var24);
        var22[3] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)(-var23), 0.0D, (double)var24);
        var22[4] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)(-var23), (double)var25, (double)(-var24));
        var22[5] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)var23, (double)var25, (double)(-var24));
        var22[6] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)var23, (double)var25, (double)var24);
        var22[7] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)(-var23), (double)var25, (double)var24);

        for (int var26 = 0; var26 < 8; ++var26)
        {
            if (var7)
            {
                var22[var26].zCoord -= 0.0625D;
                var22[var26].rotateAroundX(((float)Math.PI * 2F / 9F));
            }
            else
            {
                var22[var26].zCoord += 0.0625D;
                var22[var26].rotateAroundX(-((float)Math.PI * 2F / 9F));
            }

            if (var6 == 0 || var6 == 7)
            {
                var22[var26].rotateAroundZ((float)Math.PI);
            }

            if (var6 == 6 || var6 == 0)
            {
                var22[var26].rotateAroundY(((float)Math.PI / 2F));
            }

            if (var6 > 0 && var6 < 5)
            {
                var22[var26].yCoord -= 0.375D;
                var22[var26].rotateAroundX(((float)Math.PI / 2F));

                if (var6 == 4)
                {
                    var22[var26].rotateAroundY(0.0F);
                }

                if (var6 == 3)
                {
                    var22[var26].rotateAroundY((float)Math.PI);
                }

                if (var6 == 2)
                {
                    var22[var26].rotateAroundY(((float)Math.PI / 2F));
                }

                if (var6 == 1)
                {
                    var22[var26].rotateAroundY(-((float)Math.PI / 2F));
                }

                var22[var26].xCoord += (double)p_147790_2_ + 0.5D;
                var22[var26].yCoord += (double)((float)p_147790_3_ + 0.5F);
                var22[var26].zCoord += (double)p_147790_4_ + 0.5D;
            }
            else if (var6 != 0 && var6 != 7)
            {
                var22[var26].xCoord += (double)p_147790_2_ + 0.5D;
                var22[var26].yCoord += (double)((float)p_147790_3_ + 0.125F);
                var22[var26].zCoord += (double)p_147790_4_ + 0.5D;
            }
            else
            {
                var22[var26].xCoord += (double)p_147790_2_ + 0.5D;
                var22[var26].yCoord += (double)((float)p_147790_3_ + 0.875F);
                var22[var26].zCoord += (double)p_147790_4_ + 0.5D;
            }
        }

        Vec3 var31 = null;
        Vec3 var27 = null;
        Vec3 var28 = null;
        Vec3 var29 = null;

        for (int var30 = 0; var30 < 6; ++var30)
        {
            if (var30 == 0)
            {
                var14 = (double)var13.getInterpolatedU(7.0D);
                var16 = (double)var13.getInterpolatedV(6.0D);
                var18 = (double)var13.getInterpolatedU(9.0D);
                var20 = (double)var13.getInterpolatedV(8.0D);
            }
            else if (var30 == 2)
            {
                var14 = (double)var13.getInterpolatedU(7.0D);
                var16 = (double)var13.getInterpolatedV(6.0D);
                var18 = (double)var13.getInterpolatedU(9.0D);
                var20 = (double)var13.getMaxV();
            }

            if (var30 == 0)
            {
                var31 = var22[0];
                var27 = var22[1];
                var28 = var22[2];
                var29 = var22[3];
            }
            else if (var30 == 1)
            {
                var31 = var22[7];
                var27 = var22[6];
                var28 = var22[5];
                var29 = var22[4];
            }
            else if (var30 == 2)
            {
                var31 = var22[1];
                var27 = var22[0];
                var28 = var22[4];
                var29 = var22[5];
            }
            else if (var30 == 3)
            {
                var31 = var22[2];
                var27 = var22[1];
                var28 = var22[5];
                var29 = var22[6];
            }
            else if (var30 == 4)
            {
                var31 = var22[3];
                var27 = var22[2];
                var28 = var22[6];
                var29 = var22[7];
            }
            else if (var30 == 5)
            {
                var31 = var22[0];
                var27 = var22[3];
                var28 = var22[7];
                var29 = var22[4];
            }

            var8.addVertexWithUV(var31.xCoord, var31.yCoord, var31.zCoord, var14, var20);
            var8.addVertexWithUV(var27.xCoord, var27.yCoord, var27.zCoord, var18, var20);
            var8.addVertexWithUV(var28.xCoord, var28.yCoord, var28.zCoord, var18, var16);
            var8.addVertexWithUV(var29.xCoord, var29.yCoord, var29.zCoord, var14, var16);
        }

        return true;
    }

in RenderBlocks.java, because render type 12 is specified in BlockLever.java. I have not been able to figure out how to add a new RenderBlocks type dealio and I also have not been able to figure out where it says returning 12 in func_149645_b (I'm in 1.7.2) makes it render the lever as that code up there. Any help with understanding how this works would help, but if anyone with experience doing something like I am trying to do, that would be even more helpful.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Currently, I'm trying to figure out how to read in data from a custom datapack.  The intention is to have the Item have a reference to this pack (IE "modname:material/materialname") as an NBT tag, and i would overwrite some use functions based off of that.  How should I go about reading in the data from the datapack?
    • Game version is 1.16.5, no mods were installed, using Java8 while it happened. And I have multiple different versions of Java including Java8, 11, 12, 13, 14, 15, 16, 18 were installed in my system, but there is only Java8's path inside the environment variable. Could them be one of the reasons? I'm new here so I almost don't know anythings about forge server. Please tell me if you need other files or logs. Following is the output inside CMD after I open the "start.bat": ECHO 处于打开状态。 C:\Users\30121\Desktop\N0u3_OL_server>"C:\Program Files\Java\jre1.8.0_321\bin\java.exe" -Xms2G -Xmx2G -jar forge-1.16.5-36.2.35.jar nogui 2022-05-25 12:42:52,637 main ERROR Error processing element Queue ([Appenders: null]): CLASS_NOT_FOUND 2022-05-25 12:42:52,670 main WARN Advanced terminal features are not available in this environment 2022-05-25 12:42:52,709 main ERROR Unable to locate appender "ServerGuiConsole" for logger config "root" [12:42:52] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher running: args [--gameDir, ., --launchTarget, fmlserver, --fml.forgeVersion, 36.2.35, --fml.mcpVersion, 20210115.111550, --fml.mcVersion, 1.16.5, --fml.forgeGroup, net.minecraftforge, nogui] [12:42:52] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher 8.1.3+8.1.3+main-8.1.x.c94d18ec starting: java version 1.8.0_321 by Oracle Corporation [12:42:53] [main/INFO] [ne.mi.fm.lo.FixSSL/CORE]: Added Lets Encrypt root certificates as additional trust Exception in thread "main" [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]: java.lang.NoClassDefFoundError: com/google/common/base/Preconditions [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at org.spongepowered.asm.service.modlauncher.MixinTransformationHandler.offer(MixinTransformationHandler.java:67) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at org.spongepowered.asm.service.modlauncher.MixinServiceModLauncher.offer(MixinServiceModLauncher.java:162) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at org.spongepowered.asm.launch.MixinBootstrap.offerInternals(MixinBootstrap.java:227) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at org.spongepowered.asm.launch.MixinBootstrap.start(MixinBootstrap.java:148) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at org.spongepowered.asm.launch.MixinTransformationServiceAbstract.initialize(MixinTransformationServiceAbstract.java:88) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.TransformationServiceDecorator.onInitialize(TransformationServiceDecorator.java:68) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.TransformationServicesHandler.lambda$initialiseTransformationServices$7(TransformationServicesHandler.java:107) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at java.util.HashMap$Values.forEach(Unknown Source) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.TransformationServicesHandler.initialiseTransformationServices(TransformationServicesHandler.java:107) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.TransformationServicesHandler.initializeTransformationServices(TransformationServicesHandler.java:59) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.Launcher.run(Launcher.java:76) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at net.minecraftforge.server.ServerMain$Runner.runLauncher(ServerMain.java:49) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at net.minecraftforge.server.ServerMain$Runner.access$100(ServerMain.java:46) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at net.minecraftforge.server.ServerMain.main(ServerMain.java:43) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]: Caused by: java.lang.ClassNotFoundException: com.google.common.base.Preconditions [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at java.net.URLClassLoader.findClass(Unknown Source) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at java.lang.ClassLoader.loadClass(Unknown Source) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at java.lang.ClassLoader.loadClass(Unknown Source) [12:42:53] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         ... 15 more C:\Users\30121\Desktop\N0u3_OL_server>pause 请按任意键继续. . .
    • Although I am not exactly sure how a try-finally block would help (i.e. what code I should run even if a runtime exception is thrown), I have made some progress. The custom mob renders, but it does not rotate--even when I apply rotations to it before calling render(). private static boolean renderingCustomEntity = false; private static CustomEntity customEntity; private static void initializeCustomEntityIfNull(LocalPlayer localPlayer) { if (customEntity == null) { customEntity = ModEntities.CUSTOM_ENTITY.get().create(localPlayer.clientLevel); } } @SubscribeEvent public static void replaceMobModel(RenderLivingEvent.Pre<LivingEntity, EntityModel<LivingEntity>> event) { LocalPlayer localPlayer = Minecraft.getInstance().player; if (localPlayer != null && event.getEntity() instanceof Mob mob) { try { if (!renderingCustomEntity) { renderingCustomEntity = true; event.setCanceled(true); initializeCustomEntityIfNull(localPlayer); // I try to apply rotations to the custom entity before it rendered, but it still does not rotate at all. customEntity.setYRot(mob.getYRot()); customEntity.setYHeadRot(mob.getYHeadRot()); customEntity.setPose(mob.getPose()); // For some reason, the custom mob did not render when I called EntityRenderDispatcher#render. // So I called render() from EntityRenderDispatcher#getRenderer instead. Minecraft.getInstance().getEntityRenderDispatcher().getRenderer(customEntity).render( customEntity, customEntity.getYRot(), event.getPartialTick(), event.getPoseStack(), event.getMultiBufferSource(), event.getPackedLight() ); } } finally { renderingCustomEntity = false; } } } What would I be missing? Thank you for the help.
    • https://ileanafilio.com/cong-ty-co-phan-dau-tu-lien-doanh-viet-anh/ https://ileanafilio.com/tu-dong-viet-hoa-dau-dong-trong-excel-2007/ https://ileanafilio.com/tai-bai-hat-yeu-lai-tu-dau/ https://ileanafilio.com/phan-ky-dau-tu-du-an/ https://ileanafilio.com/su-lua-chon-so-phan-tap-62/ https://ileanafilio.com/cong-ty-co-phan-thuong-mai-dau-tu-va-phat-trien-cong-nghe-sctt/ https://ileanafilio.com/karate-co-nguon-goc-tu-dau/ https://ileanafilio.com/tap-doan-co-khi-xay-dung-thuong-mai-dai-dung/ https://ileanafilio.com/cach-tinh-dau-tu-tai-san-co-dinh/
    • Yes, I used it. And when I deleted the unnecessary parts and ran it again, I got an error. Now when I repaired that error and ran it, it worked fine. Thanks!
  • Topics

×
×
  • Create New...

Important Information

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