Skip to content

Instantly share code, notes, and snippets.

@Densamisten
Created September 9, 2024 15:36
Show Gist options
  • Select an option

  • Save Densamisten/290929837c624db1bb227dac538178ad to your computer and use it in GitHub Desktop.

Select an option

Save Densamisten/290929837c624db1bb227dac538178ad to your computer and use it in GitHub Desktop.
package exonihility.client.mixin;
import exonihility.client.module.ModuleManager;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ClientWorld.class)
public class ClientWorldMixin {
@Inject(at = @At("RETURN"), method = "getEntities", cancellable = true)
private void getEntities(CallbackInfoReturnable<Iterable<Entity>> cir) {
if (ModuleManager.getInstance.getModuleByName("lookout").isEnabled()) {
Iterable<Entity> entities = cir.getReturnValue(); // Get the returned iterable of entities
for (Entity entity : entities) {
String entityName = entity.getDisplayName().getString();
System.out.println("Entity Name: " + entityName);
}
cir.setReturnValue(entities);
cir.cancel(); // Cancel to prevent further handling of this method
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment