Skip to content

Add Minecart / Rails - #718

Open
lucanero wants to merge 27 commits into
nbcraft-org:masterfrom
lucanero:entities
Open

lucanero wants to merge 27 commits into
nbcraft-org:masterfrom
lucanero:entities

Conversation

@lucanero

Copy link
Copy Markdown
Contributor

Split from Wilylcaro

  • Minecart
  • Rail
  • PoweredRail
  • DetectorRail

Refactored to work with current base and name variables/improve logic

Comment thread source/client/renderer/entity/MinecartRenderer.cpp Outdated
Comment thread source/client/renderer/entity/MinecartRenderer.cpp Outdated
Comment thread source/client/renderer/TileRenderer.cpp Outdated
Comment thread source/client/renderer/TileRenderer.cpp Outdated
Comment thread source/world/entity/Minecart.cpp Outdated
Comment thread source/world/tile/RailTile.cpp Outdated

int rot = Mth::floor(0.5f + (mob.m_rot.yaw * 4.0f / 360.0f)) & 3;
if (rot == 1 || rot == 3)
source.getLevel().setData(pos, 1);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic values

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the whole rot nonsense or setData? setData is corrected

Comment thread source/world/tile/RailTile.cpp Outdated
Comment thread source/world/tile/RailTile.cpp Outdated
Comment thread source/client/renderer/TileRenderer.cpp Outdated
bindTexture(C_TERRAIN_NAME);
constexpr float ss = 0.75f;
tileMatrix->scale(ss);
tileMatrix->translate(Vec3(0.0f, 0.3125f, 0.0f));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic values

@BrentDaMage BrentDaMage left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial review, because I got tired

Comment thread source/client/model/models/MinecartModel.cpp
Comment thread source/client/model/models/MinecartModel.cpp Outdated
Comment thread source/client/renderer/entity/MinecartRenderer.cpp Outdated
Comment thread source/client/renderer/entity/MinecartRenderer.cpp Outdated
m_shadowRadius = 0.5f;
}

void MinecartRenderer::render(const Entity& entity, const Vec3& pos, float rot, float a)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to abstract parts of this function out if possible. or just put comments explaining what each section is doing.

@lucanero lucanero Aug 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose the if (cart.getOnRailPos(...)) piece could be abstracted into its own function; or simply a comment 'adjust for positioning based on attached rail'

kind've seems self-explanatory to me but i've been single-mindedly fixing all of the minecart code

Comment thread source/world/entity/Minecart.cpp Outdated
Comment thread source/world/entity/Minecart.cpp Outdated
Comment thread source/world/entity/Minecart.cpp Outdated
Comment thread source/world/entity/Minecart.cpp Outdated
Comment thread source/world/entity/Minecart.cpp Outdated
@lucanero

Copy link
Copy Markdown
Contributor Author

Minecarts don't replicate velocity? Clientside check?
Minecarts don't replicate the inner chest/furnace tile.
Clients are unable to push minecarts. Clientside check?
Clients can right click to interact with them properly, but the riding aspect only appears on the host. Clientside check?

Need to compare with Java

@BrentDaMage BrentDaMage left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another partial review

Comment thread source/client/renderer/TileRenderer.cpp Outdated
float v0 = yt * C_RATIO;
float v1 = (yt + 15.99f) * C_RATIO;

float x0 = (float)(pos.x + 1);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can probably make this use TilePos::above() below, north, south, etc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe?

Comment thread source/world/entity/Minecart.cpp Outdated
Comment thread source/world/entity/Minecart.cpp Outdated
Comment thread source/world/entity/Minecart.cpp Outdated
Comment thread source/world/entity/Minecart.cpp Outdated
m_vel.z = velDist * var14 / var16;
if (RailTile::isPoweredRail(rail) && !hasPower)
{
float velDist = Mth::sqrt(m_vel.x * m_vel.x + m_vel.z * m_vel.z);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is distanceSqrt

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you referring to the Vec3 function or do you want the variable named 'distanceSqrt'? It seems less descriptive if the latter.

I have been changing my mind with variable names a bit after understanding more and more of what is going on in here though.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, as in there's a function in Vec3 somewhere

Comment thread source/world/entity/Minecart.cpp Outdated
Comment thread source/world/entity/Minecart.cpp Outdated
Comment thread source/world/entity/Minecart.cpp Outdated
Comment thread source/world/entity/Minecart.cpp Outdated
@lucanero
lucanero marked this pull request as ready for review August 25, 2026 04:50
@lucanero
lucanero requested a review from BrentDaMage August 25, 2026 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants