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

Fix explosions being different from vanilla #98

Merged
merged 5 commits into from
Aug 18, 2020

Conversation

2No2Name
Copy link
Member

@2No2Name 2No2Name commented Aug 4, 2020

Vanilla changed how explosions work: Air blocks now have no effect on the blast rays, and each explosion has its own context that can adjust the explosion resistance of blocks or decide if a block can be destroyed at all (Respawn anchor and entities have their own special context)

* @author 2No2Name
*/
public class TypeCast {
public static Explosion toExplosion(Object returnValue) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just inline this cast?

Copy link
Member Author

Choose a reason for hiding this comment

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

I usually get problems when trying to cast to the mixined class. Either intellij, mcdev or the compiler complains, or it crashes when applying the mixin

Copy link
Member Author

Choose a reason for hiding this comment

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

inconvertible types, because ExplosionMixin doesn't extend Explosion.
This can be circumvented by casting like this: (Explosion)(Object)this
But I had problems with that approach in the past, but I don't recall when exactly they occur.

Copy link
Contributor

@Kroppeb Kroppeb Aug 4, 2020

Choose a reason for hiding this comment

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

Why is it cast to the Mixin in the first place? I thought you should cast it to an interface which the mixin implements?

Edit: nvm that wouldn't work for passing it as an argument, would it?
Can the mixin extend the class it's mixing in to? I can't recall.

Copy link
Contributor

Choose a reason for hiding this comment

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

Even then, I would have made it a private function in the mixin, instead of making a static class just for this.


// Get the explosion resistance like vanilla
blastResistance = this.behavior.getBlastResistance((Explosion) (Object) this, this.world, pos, blockState, fluidState);
break labelGetBlastResistance;
Copy link
Contributor

Choose a reason for hiding this comment

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

Possibly cleaner to have this be a separate function to avoid the label and break

@2No2Name 2No2Name force-pushed the 1.16.x/pull/fixExplosions branch from f162964 to 6260673 Compare August 18, 2020 22:48
@2No2Name 2No2Name merged commit 003e3ce into CaffeineMC:1.16.x/dev Aug 18, 2020
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.

5 participants