-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* emf compat * fix server
- Loading branch information
Showing
4 changed files
with
61 additions
and
0 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
34 changes: 34 additions & 0 deletions
34
...main/java/org/valkyrienskies/mod/mixin/mod_compat/emf/MixinEMFAnimationEntityContext.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,34 @@ | ||
package org.valkyrienskies.mod.mixin.mod_compat.emf; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.phys.Vec3; | ||
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.CallbackInfoReturnable; | ||
import org.valkyrienskies.mod.common.VSGameUtilsKt; | ||
import traben.entity_model_features.models.animation.EMFAnimationEntityContext; | ||
import traben.entity_model_features.utils.EMFEntity; | ||
|
||
@Mixin(EMFAnimationEntityContext.class) | ||
public class MixinEMFAnimationEntityContext { | ||
@Shadow | ||
private static EMFEntity IEMFEntity; | ||
|
||
@Inject( | ||
at = @At("HEAD"), | ||
method = "distanceOfEntityFrom", | ||
cancellable = true | ||
) | ||
private static void distanceOfEntityFrom(final BlockPos pos, final CallbackInfoReturnable<Integer> cir) { | ||
if (IEMFEntity != null) { | ||
final var level = Minecraft.getInstance().level; | ||
final var posW = VSGameUtilsKt.toWorldCoordinates(level, Vec3.atCenterOf(pos)); | ||
final var entityW = VSGameUtilsKt.toWorldCoordinates(level, Vec3.atCenterOf(IEMFEntity.etf$getBlockPos())); | ||
final var dist = posW.distanceTo(entityW); | ||
cir.setReturnValue((int) dist); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/etf/MixinBlockEntity.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,21 @@ | ||
package org.valkyrienskies.mod.mixin.mod_compat.etf; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.level.block.entity.BlockEntity; | ||
import net.minecraft.world.phys.Vec3; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.valkyrienskies.mod.common.VSGameUtilsKt; | ||
import traben.entity_texture_features.utils.ETFEntity; | ||
|
||
@Mixin(value = BlockEntity.class, priority = 1200) | ||
public abstract class MixinBlockEntity implements ETFEntity { | ||
@Override | ||
public float etf$distanceTo(final Entity entity) { | ||
final var level = Minecraft.getInstance().level; | ||
final var aW = VSGameUtilsKt.toWorldCoordinates(level, Vec3.atCenterOf(etf$getBlockPos())); | ||
final var bW = VSGameUtilsKt.toWorldCoordinates(level, entity.position()); | ||
final var dist = aW.distanceTo(bW); | ||
return (float) dist; | ||
} | ||
} |
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