Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Platform Random, use Level Random wherever applicable #7685

Merged
merged 3 commits into from Feb 29, 2024
Merged

Conversation

62832
Copy link
Member

@62832 62832 commented Feb 28, 2024

Closes #7684.

@@ -359,7 +358,8 @@ public boolean addHitEffects(BlockState state, Level level, HitResult target,
CableBusRenderState renderState = cb.getRenderState();

// Spawn a particle for one of the particle textures
TextureAtlasSprite texture = Platform.pickRandom(cableBusModel.getParticleTextures(renderState));
var textures = cableBusModel.getParticleTextures(renderState);
var texture = textures.get(level.getRandom().nextInt(textures.size()));
Copy link
Member

Choose a reason for hiding this comment

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

We should probably keep a util-method in Platform, but make it take the random source.
What do you think?

Copy link
Member Author

@62832 62832 Feb 28, 2024

Choose a reason for hiding this comment

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

That might work, though I figured it was probably worth just stripping that away altogether since the only place that method was used is in this class.

@@ -246,7 +246,7 @@ public void breakCluster() {
}

for (var entry : inv.list) {
var position = places.get(Platform.getRandomInt() % places.size());
var position = places.get(Math.abs(level.getRandom().nextInt()) % places.size());
Copy link
Member

Choose a reason for hiding this comment

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

This is probably also a place for randomly chosing an element (?)

Copy link
Member Author

Choose a reason for hiding this comment

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

You'd be right. That method could probably be brought back, then.

@shartte shartte enabled auto-merge (squash) February 29, 2024 12:08
@shartte shartte merged commit 0d8998b into main Feb 29, 2024
6 checks passed
@shartte shartte deleted the fix-7684 branch February 29, 2024 12:14
shartte added a commit that referenced this pull request Apr 1, 2024
Closes #7684.

---------

Co-authored-by: Sebastian Hartte <shartte@users.noreply.github.com>
(cherry picked from commit 0d8998b)
shartte added a commit that referenced this pull request Apr 1, 2024
Closes #7684.

---------

Co-authored-by: Sebastian Hartte <shartte@users.noreply.github.com>
(cherry picked from commit 0d8998b)
shartte added a commit that referenced this pull request Apr 2, 2024
Closes #7684.

---------

Co-authored-by: Sebastian Hartte <shartte@users.noreply.github.com>
(cherry picked from commit 0d8998b)
(cherry picked from commit e8db2b1)
shartte added a commit that referenced this pull request Apr 2, 2024
Closes #7684.

---------

Co-authored-by: Sebastian Hartte <shartte@users.noreply.github.com>
(cherry picked from commit 0d8998b)
(cherry picked from commit e8db2b1)
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.

Remove Platform Random and use Random from Level instead
2 participants