Skip to content

Commit 1bba52a

Browse files
committed
CrystalAura exploding
1 parent da168c0 commit 1bba52a

File tree

7 files changed

+198
-67
lines changed

7 files changed

+198
-67
lines changed

common/src/main/java/com/lambda/mixin/network/ClientPlayNetworkHandlerMixin.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@
1919

2020
import com.lambda.event.EventFlow;
2121
import com.lambda.event.events.InventoryEvent;
22+
import com.lambda.event.events.WorldEvent;
2223
import net.minecraft.client.network.ClientPlayNetworkHandler;
2324
import net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket;
2425
import net.minecraft.network.packet.s2c.play.UpdateSelectedSlotS2CPacket;
26+
import net.minecraft.world.explosion.Explosion;
2527
import org.spongepowered.asm.mixin.Mixin;
2628
import org.spongepowered.asm.mixin.injection.At;
2729
import org.spongepowered.asm.mixin.injection.Inject;
30+
import org.spongepowered.asm.mixin.injection.Redirect;
2831
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
2932

3033
@Mixin(ClientPlayNetworkHandler.class)

common/src/main/java/com/lambda/mixin/world/ClientWorldMixin.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,17 @@
3333
@Mixin(ClientWorld.class)
3434
public class ClientWorldMixin {
3535
@Inject(method = "addEntity", at = @At("HEAD"), cancellable = true)
36-
private void addEntity(Entity entity, CallbackInfo ci) {
36+
private void onAddEntity(Entity entity, CallbackInfo ci) {
3737
if (EventFlow.post(new EntityEvent.EntitySpawn(entity)).isCanceled()) ci.cancel();
3838
}
3939

40+
@Inject(method = "removeEntity", at = @At("HEAD"))
41+
private void onRemoveEntity(int entityId, Entity.RemovalReason removalReason, CallbackInfo ci) {
42+
Entity entity = ((ClientWorld) (Object) this).getEntityById(entityId);
43+
if (entity == null) return;
44+
EventFlow.post(new EntityEvent.EntityRemoval(entity, removalReason));
45+
}
46+
4047
@Inject(method = "getCloudsColor", at = @At("HEAD"), cancellable = true)
4148
private void getCloudsColorInject(float tickDelta, CallbackInfoReturnable<Vec3d> cir) {
4249
if (WorldColors.INSTANCE.isEnabled() && WorldColors.getCustomClouds()) {

common/src/main/kotlin/com/lambda/config/groups/Targeting.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ abstract class Targeting(
174174
}
175175

176176
private val illegalTargets = setOf(
177-
UUID(5706954458220675710L, -6736729783554821869L),
177+
UUID(5706954458220675710, -6736729783554821869),
178178
UUID(-6114492090883684892, -8539188786807016414)
179179
)
180180
}

common/src/main/kotlin/com/lambda/event/events/EntityEvent.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ sealed class EntityEvent {
5454
val entity: Entity,
5555
) : ICancellable by Cancellable()
5656

57+
/**
58+
* Represents an event triggered when an entity is removed from the game world.
59+
*
60+
* @property entity The entity being removed from the world.
61+
* @property removalReason The reason for the removal of the entity.
62+
*/
63+
data class EntityRemoval(
64+
val entity: Entity,
65+
val removalReason: Entity.RemovalReason,
66+
) : Event
67+
5768
/**
5869
* Represents an event triggered when an entity's tracked data is updated.
5970
*

common/src/main/kotlin/com/lambda/interaction/rotation/RotationRequest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ data class RotationRequest(
2929
val checkedResult: HitResult? = null,
3030
val verify: HitResult.() -> Boolean = { true },
3131
) {
32+
val cast: HitResult? get() = runSafe { RotationManager.currentRotation.rayCast(10.0, player.eyePos) }
3233
val isValid: Boolean get() = runSafe {
3334
// ToDo: Use proper reach
34-
val result = RotationManager.currentRotation.rayCast(10.0, player.eyePos)
35+
val result = cast
3536
verify(result.orMiss)
3637
} ?: false
3738
}

common/src/main/kotlin/com/lambda/interaction/visibilty/VisibilityChecker.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ object VisibilityChecker {
5555
* @return A [RotationRequest] if a valid rotation was found; otherwise, null.
5656
*/
5757
fun SafeContext.lookAtEntity(
58-
rotationConfig: RotationConfig,
59-
interactionConfig: InteractionConfig,
6058
entity: Entity,
59+
rotationConfig: RotationConfig = TaskFlowModule.rotation,
60+
interactionConfig: InteractionConfig = TaskFlowModule.interact,
6161
) = findRotation(listOf(entity.boundingBox), rotationConfig, interactionConfig) {
6262
entityResult?.entity == entity
6363
}
@@ -100,8 +100,8 @@ object VisibilityChecker {
100100
*/
101101
fun SafeContext.findRotation(
102102
boxes: List<Box>,
103-
rotationConfig: RotationConfig,
104-
interact: InteractionConfig,
103+
rotationConfig: RotationConfig = TaskFlowModule.rotation,
104+
interact: InteractionConfig = TaskFlowModule.interact,
105105
sides: Set<Direction> = Direction.entries.toSet(),
106106
reach: Double = interact.reach,
107107
eye: Vec3d = player.getCameraPosVec(1f),

0 commit comments

Comments
 (0)