forked from ValkyrienSkies/Valkyrien-Skies-2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Another banger of a linter config change
- Loading branch information
Showing
32 changed files
with
447 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[*] | ||
insert_final_newline = true | ||
insert_final_newline=true | ||
|
||
[*.{kt,kts,java}] | ||
indent_size=4 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# Physics-and-Ships | ||
|
||
Valkyrien Skies remake part 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
common/src/main/java/org/valkyrienskies/mod/mixin/block/MixinBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.valkyrienskies.mod.mixin.block; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.entity.ItemEntity; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import org.joml.Vector3d; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
import org.valkyrienskies.core.game.ships.ShipData; | ||
import org.valkyrienskies.mod.common.VSGameUtilsKt; | ||
|
||
@Mixin(Block.class) | ||
public class MixinBlock { | ||
|
||
/** | ||
* Ensure that items drop in the world and not in the shipyard. | ||
*/ | ||
@Redirect( | ||
method = "dropStack", | ||
at = @At( | ||
value = "NEW", | ||
target = "net/minecraft/entity/ItemEntity", | ||
ordinal = 0 | ||
) | ||
) | ||
private static ItemEntity moveItemDrops( | ||
// Constructor arguments | ||
final World world, final double x, final double y, final double z, final ItemStack stack, | ||
// dropStack arguments | ||
final World ignore, final BlockPos pos, final ItemStack ignore2 | ||
) { | ||
final ShipData ship = VSGameUtilsKt.getShipManagingPos(world, pos); | ||
if (ship == null) { | ||
// Vanilla behaviour | ||
return new ItemEntity(world, x, y, z, stack); | ||
} | ||
|
||
// Extract random offset | ||
final double dx = x - pos.getX(); | ||
final double dy = y - pos.getY(); | ||
final double dz = z - pos.getZ(); | ||
|
||
// Real position of item drop in world | ||
final Vector3d p = VSGameUtilsKt.toWorldCoordinates(ship, pos); | ||
|
||
return new ItemEntity(world, p.x + dx, p.y + dy, p.z + dz, stack); | ||
} | ||
|
||
} |
81 changes: 81 additions & 0 deletions
81
common/src/main/java/org/valkyrienskies/mod/mixin/client/particle/ParticleMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package org.valkyrienskies.mod.mixin.client.particle; | ||
|
||
import net.minecraft.client.particle.Particle; | ||
import net.minecraft.client.world.ClientWorld; | ||
import org.joml.Matrix4dc; | ||
import org.joml.Vector3d; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.valkyrienskies.core.game.ships.ShipObject; | ||
import org.valkyrienskies.mod.common.VSGameUtilsKt; | ||
|
||
@Mixin(Particle.class) | ||
public abstract class ParticleMixin { | ||
|
||
@Shadow | ||
public abstract void setPos(double x, double y, double z); | ||
|
||
@Shadow | ||
protected double velocityX; | ||
|
||
@Shadow | ||
protected double velocityY; | ||
|
||
@Shadow | ||
protected double velocityZ; | ||
|
||
/** | ||
* See also {@link org.valkyrienskies.mod.mixin.client.render.MixinWorldRenderer} | ||
*/ | ||
@Inject( | ||
method = "Lnet/minecraft/client/particle/Particle;<init>(Lnet/minecraft/client/world/ClientWorld;DDD)V", | ||
at = @At("TAIL") | ||
) | ||
public void checkShipCoords(final ClientWorld world, final double x, final double y, final double z, | ||
final CallbackInfo ci) { | ||
final ShipObject ship = VSGameUtilsKt.getShipObjectManagingPos(world, (int) x >> 4, (int) z >> 4); | ||
if (ship == null) { | ||
return; | ||
} | ||
|
||
// in-world position | ||
final Vector3d p = ship.getRenderTransform().getShipToWorldMatrix().transformPosition(new Vector3d(x, y, z)); | ||
this.setPos(p.x, p.y, p.z); | ||
} | ||
|
||
/** | ||
* See also {@link org.valkyrienskies.mod.mixin.client.render.MixinWorldRenderer} | ||
*/ | ||
@Inject( | ||
method = "Lnet/minecraft/client/particle/Particle;<init>(Lnet/minecraft/client/world/ClientWorld;DDDDDD)V", | ||
at = @At("TAIL") | ||
) | ||
public void checkShipPosAndVelocity(final ClientWorld world, final double x, final double y, final double z, | ||
final double velocityX, | ||
final double velocityY, final double velocityZ, final CallbackInfo ci) { | ||
|
||
final ShipObject ship = VSGameUtilsKt.getShipObjectManagingPos(world, (int) x >> 4, (int) z >> 4); | ||
if (ship == null) { | ||
return; | ||
} | ||
|
||
final Matrix4dc transform = ship.getRenderTransform().getShipToWorldMatrix(); | ||
// in-world position | ||
final Vector3d p = transform.transformPosition(new Vector3d(x, y, z)); | ||
// in-world velocity | ||
final Vector3d v = transform | ||
// Rotate velocity wrt ship transform | ||
.transformDirection(new Vector3d(this.velocityX, this.velocityY, this.velocityZ)) | ||
// Tack on the ships linear velocity (no angular velocity param unfortunately) | ||
.add(ship.getShipData().getPhysicsData().getLinearVelocity()); | ||
|
||
this.setPos(p.x, p.y, p.z); | ||
this.velocityX = v.x; | ||
this.velocityY = v.y; | ||
this.velocityZ = v.z; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.