Skip to content

Commit 6f111af

Browse files
committed
Concise entity event naming
1 parent 3e5bdc8 commit 6f111af

File tree

5 files changed

+16
-23
lines changed

5 files changed

+16
-23
lines changed

common/src/main/java/com/lambda/mixin/entity/EntityMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private void changeLookDirection(double cursorDeltaX, double cursorDeltaY, Callb
130130
@Inject(method = "onTrackedDataSet(Lnet/minecraft/entity/data/TrackedData;)V", at = @At("TAIL"))
131131
public void onTrackedDataSet(TrackedData<?> data, CallbackInfo ci) {
132132
Entity entity = (Entity) (Object) this;
133-
EventFlow.post(new EntityEvent.EntityUpdate(entity, data));
133+
EventFlow.post(new EntityEvent.Update(entity, data));
134134
}
135135

136136
// ToDo: Does not trigger for some reason.

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,8 @@
2323
import com.lambda.module.modules.render.WorldColors;
2424
import com.lambda.util.math.ColorKt;
2525
import net.minecraft.block.BlockState;
26-
import net.minecraft.client.network.ClientPlayNetworkHandler;
27-
import net.minecraft.client.render.WorldRenderer;
2826
import net.minecraft.client.world.ClientWorld;
2927
import net.minecraft.entity.Entity;
30-
import net.minecraft.registry.RegistryKey;
31-
import net.minecraft.registry.entry.RegistryEntry;
3228
import net.minecraft.util.math.BlockPos;
3329
import net.minecraft.util.math.Vec3d;
3430
import org.spongepowered.asm.mixin.Mixin;
@@ -37,20 +33,18 @@
3733
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
3834
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
3935

40-
import java.util.function.Supplier;
41-
4236
@Mixin(ClientWorld.class)
4337
public class ClientWorldMixin {
4438
@Inject(method = "addEntity", at = @At("HEAD"), cancellable = true)
4539
private void onAddEntity(Entity entity, CallbackInfo ci) {
46-
if (EventFlow.post(new EntityEvent.EntitySpawn(entity)).isCanceled()) ci.cancel();
40+
if (EventFlow.post(new EntityEvent.Spawn(entity)).isCanceled()) ci.cancel();
4741
}
4842

4943
@Inject(method = "removeEntity", at = @At("HEAD"))
5044
private void onRemoveEntity(int entityId, Entity.RemovalReason removalReason, CallbackInfo ci) {
5145
Entity entity = ((ClientWorld) (Object) this).getEntityById(entityId);
5246
if (entity == null) return;
53-
EventFlow.post(new EntityEvent.EntityRemoval(entity, removalReason));
47+
EventFlow.post(new EntityEvent.Removal(entity, removalReason));
5448
}
5549

5650
@Inject(method = "getCloudsColor", at = @At("HEAD"), cancellable = true)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ sealed class EntityEvent {
5050
*
5151
* @property entity The entity that is being spawned.
5252
*/
53-
data class EntitySpawn(
53+
data class Spawn(
5454
val entity: Entity,
5555
) : ICancellable by Cancellable()
5656

@@ -60,7 +60,7 @@ sealed class EntityEvent {
6060
* @property entity The entity being removed from the world.
6161
* @property removalReason The reason for the removal of the entity.
6262
*/
63-
data class EntityRemoval(
63+
data class Removal(
6464
val entity: Entity,
6565
val removalReason: Entity.RemovalReason,
6666
) : Event
@@ -74,8 +74,8 @@ sealed class EntityEvent {
7474
* @property entity The entity whose tracked data is being updated.
7575
* @property data The tracked data being updated.
7676
*/
77-
data class EntityUpdate(
77+
data class Update(
7878
val entity: Entity,
7979
val data: TrackedData<*>,
8080
) : Event
81-
}
81+
}

common/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import com.lambda.threading.runSafe
4040
import com.lambda.threading.runSafeGameScheduled
4141
import com.lambda.util.BlockUtils.blockState
4242
import com.lambda.util.Communication.info
43+
import com.lambda.util.PacketUtils.sendPacket
4344
import com.lambda.util.Timer
4445
import com.lambda.util.collections.LimitedDecayQueue
4546
import com.lambda.util.combat.CombatUtils.crystalDamage
@@ -188,13 +189,13 @@ object CrystalAura : Module(
188189
}
189190

190191
// Update last received entity spawn
191-
listen<EntityEvent.EntitySpawn>(alwaysListen = true) { event ->
192+
listen<EntityEvent.Spawn>(alwaysListen = true) { event ->
192193
lastEntityId = event.entity.id
193194
predictionTimer.reset()
194195
}
195196

196197
// Prediction
197-
listen<EntityEvent.EntitySpawn> { event ->
198+
listen<EntityEvent.Spawn> { event ->
198199
val crystal = event.entity as? EndCrystalEntity ?: return@listen
199200
val pos = crystal.baseBlockPos
200201

@@ -217,7 +218,7 @@ object CrystalAura : Module(
217218
if (placePostPause) placeTimer.reset()
218219
}
219220

220-
listen<EntityEvent.EntityRemoval> { event ->
221+
listen<EntityEvent.Removal> { event ->
221222
val crystal = event.entity as? EndCrystalEntity ?: return@listen
222223
val pos = crystal.baseBlockPos
223224

@@ -272,21 +273,21 @@ object CrystalAura : Module(
272273
}
273274

274275
private fun SafeContext.placeInternal(opportunity: Opportunity, hand: Hand) {
275-
connection.sendPacket(
276+
connection.sendPacket {
276277
PlayerInteractBlockC2SPacket(
277278
hand, BlockHitResult(opportunity.crystalPosition, opportunity.side, opportunity.blockPos, false), 0
278279
)
279-
)
280+
}
280281

281282
player.swingHand(hand)
282283
}
283284

284285
private fun SafeContext.explodeInternal(id: Int) {
285-
connection.sendPacket(
286+
connection.sendPacket {
286287
PlayerInteractEntityC2SPacket(
287288
id, player.isSneaking, PlayerInteractEntityC2SPacket.ATTACK
288289
)
289-
)
290+
}
290291

291292
player.swingHand(Hand.MAIN_HAND)
292293
}

common/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ import com.lambda.interaction.material.transfer.TransactionExecutor.Companion.tr
4747
import com.lambda.module.modules.client.TaskFlowModule
4848
import com.lambda.task.Task
4949
import com.lambda.util.BaritoneUtils
50-
import com.lambda.util.BlockUtils
51-
import com.lambda.util.BlockUtils.blockState
5250
import com.lambda.util.Communication.info
5351
import com.lambda.util.Communication.warn
5452
import com.lambda.util.Formatting.string
@@ -237,7 +235,7 @@ class BuildTask @Ta5kBuilder constructor(
237235
}
238236

239237
// ToDo: Dependent on the tracked data order. When set stack is called after position it wont work
240-
listen<EntityEvent.EntityUpdate> {
238+
listen<EntityEvent.Update> {
241239
if (!collectDrops) return@listen
242240
if (it.entity !is ItemEntity) return@listen
243241
pendingInteractions.find { context ->

0 commit comments

Comments
 (0)