-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add compatibility for Vampirism blood vision
- Loading branch information
Showing
4 changed files
with
48 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
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
41 changes: 41 additions & 0 deletions
41
src/main/java/meldexun/renderlib/integration/Vampirism.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,41 @@ | ||
package meldexun.renderlib.integration; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.Enumeration; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
import de.teamlapen.vampirism.client.render.RenderHandler; | ||
import net.minecraft.entity.EntityLivingBase; | ||
import net.minecraftforge.client.event.RenderLivingEvent; | ||
import net.minecraftforge.common.MinecraftForge; | ||
import net.minecraftforge.fml.common.eventhandler.EventBus; | ||
|
||
public class Vampirism { | ||
|
||
private static RenderHandler renderHandler; | ||
static { | ||
try { | ||
Field listenersField = EventBus.class.getDeclaredField("listeners"); | ||
listenersField.setAccessible(true); | ||
@SuppressWarnings("unchecked") | ||
Enumeration<Object> keys = ((ConcurrentHashMap<Object, ?>) listenersField.get(MinecraftForge.EVENT_BUS)).keys(); | ||
while (keys.hasMoreElements()) { | ||
Object key = keys.nextElement(); | ||
if (key instanceof RenderHandler) { | ||
renderHandler = (RenderHandler) key; | ||
break; | ||
} | ||
} | ||
if (renderHandler == null) { | ||
throw new NullPointerException(); | ||
} | ||
} catch (Exception e) { | ||
throw new UnsupportedOperationException("Failed to find de.teamlapen.vampirism.client.render.RenderHandler instance", e); | ||
} | ||
} | ||
|
||
public static void onRenderLivingPost(EntityLivingBase entity) { | ||
renderHandler.onRenderLivingPost(new RenderLivingEvent.Post<>(entity, null, 0.0F, 0.0D, 0.0D, 0.0D)); | ||
} | ||
|
||
} |
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