Jump to content

Recommended Posts

Posted (edited)

Does anyone know what the 1.12.2 replacement for the 1.7 method world.getWorldVec3Pool().getVecFromPool(double, double, double) is or what it was used for? I assume memory optimisations for vectors

Edited by Cadiboo

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted
42 minutes ago, Cadiboo said:

is or what it was used for? I assume memory optimisations for vectors

Maybe not sure.

42 minutes ago, Cadiboo said:

Does anyone know what the 1.12.2 replacement for the 1.7 method world.getWorldVec3Pool().getVecFromPool(double, double, double)

Well in 1.7.10 it was Vec3.createVectorHelper however this doesn't appear to exist in 1.12.2. Maybe it isn't used anymore. What are you using it for?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
3 hours ago, Animefan8888 said:

Well in 1.7.10 it was Vec3.createVectorHelper however this doesn't appear to exist in 1.12.2. Maybe it isn't used anymore. What are you using it for?

I'm porting someones mod to 1.12.2, I can show you a snippet the original code, but thats it (the mod was never open source, and this is the only snippet that the author shared).

Spoiler

 public boolean renderSoftBlock(Block block, int x, int y, int z, RenderBlocks renderer, IBlockAccess world) {
     // Used for the drawing of the block's sides.
     Tessellator tessellator = Tessellator.instance;

     // The block's metadata.
     int meta = world.getBlockMetadata(x, y, z);

     // The basic block color.
     int color = block.colorMultiplier(world, x, y, z);
     float colorRed = (float) (color >> 16 & 255) / 255.0F;
     float colorGreen = (float) (color >> 8 & 255) / 255.0F;
     float colorBlue = (float) (color & 255) / 255.0F;

     // The shadow values.
     float shadowBottom = 0.6F;
     float shadowTop = 1.0F;
     float shadowLeft = 0.9F;
     float shadowRight = 0.8F;

     // The block's icon
     IIcon icon;
     if (!renderer.hasOverrideBlockTexture())
        icon = renderer.getBlockIconFromSideAndMetadata(block, 1, meta);
     else
        // Used for the crack texture
        icon = renderer.overrideBlockTexture;

     // The icon's UVs
     double minU = (double) icon.getMinU();
     double minV = (double) icon.getMinV();
     double maxU = (double) icon.getMaxU();
     double maxV = (double) icon.getMaxV();

     // The 8 points that make the block.
     Vec3[] points = new Vec3[8];
     points[0] = world.getWorldVec3Pool().getVecFromPool(0.0D, 0.0D, 0.0D);
     points[1] = world.getWorldVec3Pool().getVecFromPool(1.0D, 0.0D, 0.0D);
     points[2] = world.getWorldVec3Pool().getVecFromPool(1.0D, 0.0D, 1.0D);
     points[3] = world.getWorldVec3Pool().getVecFromPool(0.0D, 0.0D, 1.0D);
     points[4] = world.getWorldVec3Pool().getVecFromPool(0.0D, 1.0D, 0.0D);
     points[5] = world.getWorldVec3Pool().getVecFromPool(1.0D, 1.0D, 0.0D);
     points[6] = world.getWorldVec3Pool().getVecFromPool(1.0D, 1.0D, 1.0D);
     points[7] = world.getWorldVec3Pool().getVecFromPool(0.0D, 1.0D, 1.0D);

     // Loop through all the points:
     // Here everything will be 'smoothed'.
     for (int point = 0; point < 8; point++) {
         // Give the point the block's coordinates.
         points[point].xCoord += (double) x;
         points[point].yCoord += (double) y;
         points[point].zCoord += (double) z;

         // Check if the point is NOT intersecting with a manufactured block.
         if (!doesPointIntersectWithManufactured(world, points[point])) {
             // Check if the block's bottom side intersects with air.
             if (point < 4 && doesPointBottomIntersectWithAir(world, points[point]))
                 points[point].yCoord = (double) y + 1.0D;
             // Check if the block's top side intersects with air.
             else if (point >= 4 && doesPointTopIntersectWithAir(world, points[point]))
                 points[point].yCoord = (double) y;

             // Give the point some random offset.
             points[point] = givePointRoughness(points[point]);
         }
     }

     // Loop through all the sides of the block:
     for (int side = 0; side < 6; side++) {
         // The coordinates the side is facing to.
         int facingX = x;
         int facingY = y;
         int facingZ = z;
         if (side == 0)
            facingY--;
         else if (side == 1)
            facingY++;
         else if (side == 2)
            facingZ--;
         else if (side == 3)
            facingX++;
         else if (side == 4)
            facingZ++;
         else if (side == 5)
            facingX--;

         // Check if the side should be rendered:
         // This prevents a lot of lag!
         if (renderer.renderAllFaces || block.shouldSideBeRendered(world, facingX, facingY, facingZ, side)) {
             // When you lower this value the block will become darker.
             float colorFactor = 1.0F;

             // This are the vertices used for the side.
             Vec3 vertex0 = null;
             Vec3 vertex1 = null;
             Vec3 vertex2 = null;
             Vec3 vertex3 = null;
             if (side == 0) {
                 // Side 0 is the bottom side.
                 colorFactor = shadowBottom;
                 vertex0 = points[0];
                 vertex1 = points[1];
                 vertex2 = points[2];
                 vertex3 = points[3];

             } else if (side == 1) {
                 // Side 1 is the top side.
                 colorFactor = shadowTop;
                 vertex0 = points[7];
                 vertex1 = points[6];
                 vertex2 = points[5];
                 vertex3 = points[4];

             } else if (side == 2) {
                 colorFactor = shadowLeft;
                 vertex0 = points[1];
                 vertex1 = points[0];
                 vertex2 = points[4];
                 vertex3 = points[5];

             } else if (side == 3) {
                 colorFactor = shadowRight;
                 vertex0 = points[2];
                 vertex1 = points[1];
                 vertex2 = points[5];
                 vertex3 = points[6];
             } else if (side == 4) {
                 colorFactor = shadowLeft;
                 vertex0 = points[3];
                 vertex1 = points[2];
                 vertex2 = points[6];
                 vertex3 = points[7];
             } else if (side == 5) {
                 colorFactor = shadowRight;
                 vertex0 = points[0];
                 vertex1 = points[3];
                 vertex2 = points[7];
                 vertex3 = points[4];
             }

             // Here is the brightness of the block being set.
             tessellator.setBrightness(block.getMixedBrightnessForBlock(world, facingX, facingY, facingZ));
             // Here is the color of the block being set.
             tessellator.setColorOpaque_F(shadowTop * colorFactor * colorRed, shadowTop * colorFactor * colorGreen,
             shadowTop * colorFactor * colorBlue);

             // And finally the side is going to be rendered!
             tessellator.addVertexWithUV(vertex0.xCoord, vertex0.yCoord, vertex0.zCoord, minU, maxV);
             tessellator.addVertexWithUV(vertex1.xCoord, vertex1.yCoord, vertex1.zCoord, maxU, maxV);
             tessellator.addVertexWithUV(vertex2.xCoord, vertex2.yCoord, vertex2.zCoord, maxU, minV);
             tessellator.addVertexWithUV(vertex3.xCoord, vertex3.yCoord, vertex3.zCoord, minU, minV);
         }
     }

     return true;
 }

 

I'm currently making a new class called Vec3 and just instantiating new objects instead of using a pool. The code is currently super performance intensive, and I'm not worried about memory optimisations yet.

Spoiler

public static class Vec3 {

	public double xCoord;
	public double yCoord;
	public double zCoord;

	public Vec3(final double xCoord, final double yCoord, final double zCoord) {
		this.xCoord = xCoord;
		this.yCoord = yCoord;
		this.zCoord = zCoord;
	}

}

 

 

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted (edited)
53 minutes ago, Cadiboo said:

I'm currently making a new class called Vec3

Why? What's wrong with mojang's Vec3d? Or lwjgl's Vector3? You should not be reinventing the wheel.

53 minutes ago, Cadiboo said:

The code is currently super performance intensive

Unless you mean some other code instantinating an object that consists out of 3 primitives is nearly instant.

Edited by V0idWa1k3r
Posted (edited)

Mojangs Vec3d is immutable, the code needs changeable vectors.

I also just got an out of memory error so I might need to start doing some optimising, though that could be due to something else. It had to do with shaders

That code I linked is being run for every block in a render chunk (it’s not as performance intensive as I thought, intelliJ hotswap seems to absolutely kill FPS tho)

Edited by Cadiboo

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted
3 hours ago, Cadiboo said:

I'm currently making a new class called Vec3 and just instantiating new objects instead of using a pool.

Using a pool might be a good optimization later. But I don't see a reason for your Vec3 class to store doubles. The values dont ever seem to have decimals. 

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
8 hours ago, Cadiboo said:

givePointRoughness(points[point]);

This adds a random float value, sorry for not posting it, but I hadn’t reconstructed it yet and it wasn’t part of the original snippet. I’ll change the Vec3s to use floats.

 

Did the order of EnumFacing change since 1.7.10? 

8 hours ago, Cadiboo said:

int facingX = x; int facingY = y; int facingZ = z; if (side == 0) facingY--; else if (side == 1) facingY++; else if (side == 2) facingZ--; else if (side == 3) facingX++; else if (side == 4) facingZ++; else if (side == 5) facingX--;

This isn’t working at all

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted (edited)
On 12/3/2018 at 9:04 PM, Cadiboo said:

Did the order of EnumFacing change since 1.7.10? 

This isn’t working at all

EnumFacing order is DUNSWE (which I'm pretty sure is the same as ForgeDirection from 1.7.10).

 

But EnumFacing and/or BlockPos provide all the methods you might need to get rid of that ugly (and wrong) bit of code.  Assuming the side int is in the expected DUNSWE order:

BlockPos newPos = new BlockPos(x, y, z).offset(EnumFacing.byIndex(side));
// then use newPos.getX() etc.

 

Edited by desht
Posted (edited)
21 hours ago, desht said:

EnumFacing order is DUNSWE (which I'm pretty sure is the same as ForgeDirection from 1.7.10).

 

But EnumFacing and/or BlockPos provide all the methods you might need to get rid of that ugly (and wrong) bit of code.  Assuming the side int is in the expected DUNSWE order:


BlockPos newPos = new BlockPos(x, y, z).offset(EnumFacing.byIndex(side));
// then use newPos.getX() etc.

 

All of that code was apparently completely useless and unnecessary in 1.12.2, and now I'm just using the original BlockPos.
The problem with the EnumFacings was actually that the vertices I had taken from the old code (and expected to be perfect) were completely broken for South and West.

Edited by Cadiboo

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

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



×
×
  • Create New...

Important Information

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