-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
11 additions
and
9 deletions.
There are no files selected for viewing
20 changes: 11 additions & 9 deletions
20
src/main/java/com/klikli_dev/occultism/integration/emi/render/SpiritRenderable.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 |
---|---|---|
@@ -1,27 +1,29 @@ | ||
package com.klikli_dev.occultism.integration.emi.render; | ||
|
||
import com.klikli_dev.occultism.client.gui.spirit.SpiritGui; | ||
import com.klikli_dev.occultism.common.entity.spirit.FoliotEntity; | ||
import com.klikli_dev.occultism.common.entity.spirit.SpiritEntity; | ||
import com.klikli_dev.occultism.registry.OccultismEntities; | ||
import dev.emi.emi.api.render.EmiRenderable; | ||
import dev.emi.emi.api.widget.DrawableWidget; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.GuiGraphics; | ||
import net.minecraft.world.entity.EntityType; | ||
|
||
import java.lang.ref.WeakReference; | ||
|
||
public class SpiritRenderable<T extends SpiritEntity> implements EmiRenderable{ | ||
T spiritEntity; | ||
|
||
public class SpiritRenderable<T extends SpiritEntity> implements EmiRenderable { | ||
WeakReference<T> spiritEntity; | ||
EntityType<T> spiritType; | ||
|
||
public SpiritRenderable(EntityType<T> spiritType) { | ||
this.spiritType=spiritType; | ||
this.spiritType = spiritType; | ||
} | ||
|
||
@Override | ||
public void render(GuiGraphics draw, int x, int y, float delta) { | ||
if(spiritEntity==null) | ||
spiritEntity= (T) spiritType.create(Minecraft.getInstance().level); | ||
SpiritGui.drawEntityToGui(draw, (int) (x+8),(int)(y+(spiritEntity.getEyeHeight()*15)+5),15,1,1,spiritEntity); | ||
if (this.spiritEntity == null || this.spiritEntity.get() == null) | ||
this.spiritEntity = new WeakReference<>(this.spiritType.create(Minecraft.getInstance().level)); | ||
|
||
|
||
SpiritGui.drawEntityToGui(draw, x + 8, (int) (y + (this.spiritEntity.get().getEyeHeight() * 15) + 5), 15, 1, 1, this.spiritEntity.get()); | ||
} | ||
} |