mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 17:47:32 +00:00
Refactor Overlays to support URL
This commit is contained in:
1 parent
f1b7f2dac7
commit
d8097368cc
5 files changed
+52
-62
No files matched your search
@@ -11,11 +11,13 @@ import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import noppes.npcs.*;
|
||||
import noppes.npcs.api.ISkinOverlay;
|
||||
import noppes.npcs.client.ClientCacheHandler;
|
||||
import noppes.npcs.client.model.animation.AniCrawling;
|
||||
import noppes.npcs.client.model.animation.AniHug;
|
||||
import noppes.npcs.client.model.part.*;
|
||||
import noppes.npcs.client.model.util.ModelPartInterface;
|
||||
import noppes.npcs.client.model.util.ModelScaleRenderer;
|
||||
import noppes.npcs.client.renderer.ImageData;
|
||||
import noppes.npcs.client.renderer.RenderNPCInterface;
|
||||
import noppes.npcs.constants.EnumAnimation;
|
||||
import noppes.npcs.constants.EnumAnimationPart;
|
||||
@@ -376,21 +378,15 @@ public class ModelMPM extends ModelNPCMale{
|
||||
if (!npc.display.skinOverlayData.overlayList.isEmpty()) {
|
||||
for (ISkinOverlay overlayData : npc.display.skinOverlayData.overlayList.values()) {
|
||||
try {
|
||||
if (((SkinOverlay)overlayData).getLocation() == null) {
|
||||
((SkinOverlay)overlayData).setLocation(new ResourceLocation(overlayData.getTexture()));
|
||||
} else {
|
||||
String str = ((SkinOverlay)npc.display.skinOverlayData.overlayList.get(0)).getLocation().getResourceDomain()+":"+((SkinOverlay)npc.display.skinOverlayData.overlayList.get(0)).getLocation().getResourcePath();
|
||||
if (!str.equals(overlayData.getTexture())) {
|
||||
((SkinOverlay)overlayData).setLocation(new ResourceLocation(overlayData.getTexture()));
|
||||
}
|
||||
}
|
||||
if (((SkinOverlay)overlayData).texture.isEmpty())
|
||||
continue;
|
||||
|
||||
if (overlayData.getTexture().isEmpty() || ((SkinOverlay)overlayData).getLocation() == null
|
||||
|| ((SkinOverlay)overlayData).getLocation().getResourcePath().isEmpty())
|
||||
ImageData imageData = ClientCacheHandler.getImageData(((SkinOverlay)overlayData).texture);
|
||||
if (!imageData.imageLoaded())
|
||||
continue;
|
||||
|
||||
try {
|
||||
RenderNPCInterface.staticRenderManager.renderEngine.bindTexture(((SkinOverlay)overlayData).getLocation());
|
||||
imageData.renderEngineBind();
|
||||
} catch (Exception e) { continue; }
|
||||
|
||||
// Overlay & Glow
|
||||
|
||||
@@ -74,6 +74,17 @@ public class ImageData {
|
||||
}
|
||||
}
|
||||
|
||||
public void renderEngineBind() {
|
||||
ResourceLocation location = this.getLocation();
|
||||
if (location != null && !this.invalid) {
|
||||
try {
|
||||
RenderNPCInterface.staticRenderManager.renderEngine.bindTexture(location);
|
||||
} catch (Exception exception) {
|
||||
this.invalid = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ResourceLocation getLocation() {
|
||||
return this.isUrl && this.imageDownloadAlt.getBufferedImage() == null ? null : this.location;
|
||||
}
|
||||
|
||||
@@ -44,12 +44,16 @@ public class RenderCNPCPlayer extends RenderPlayer {
|
||||
}
|
||||
|
||||
private boolean preRenderOverlay(SkinOverlay overlayData, EntityPlayer player) {
|
||||
if (overlayData.location.getResourcePath().isEmpty())
|
||||
if (overlayData.texture.isEmpty())
|
||||
return false;
|
||||
|
||||
ImageData imageData = ClientCacheHandler.getImageData(((SkinOverlay)overlayData).texture);
|
||||
if (!imageData.imageLoaded())
|
||||
return false;
|
||||
|
||||
try {
|
||||
this.bindTexture(overlayData.location);
|
||||
} catch (Exception exception) {
|
||||
imageData.bindTexture();
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -108,17 +112,12 @@ public class RenderCNPCPlayer extends RenderPlayer {
|
||||
{
|
||||
if (ClientCacheHandler.skinOverlays.containsKey(player.getUniqueID())) {
|
||||
for (SkinOverlay overlayData : ClientCacheHandler.skinOverlays.get(player.getUniqueID()).values()) {
|
||||
if (overlayData.texture.isEmpty())
|
||||
if (((SkinOverlay)overlayData).texture.isEmpty())
|
||||
continue;
|
||||
|
||||
if (overlayData.location == null) {
|
||||
overlayData.location = new ResourceLocation(overlayData.texture);
|
||||
} else {
|
||||
String str = overlayData.location.getResourceDomain()+":"+overlayData.location.getResourcePath();
|
||||
if (!str.equals(overlayData.texture)) {
|
||||
overlayData.location = new ResourceLocation(overlayData.texture);
|
||||
}
|
||||
}
|
||||
ImageData imageData = ClientCacheHandler.getImageData(((SkinOverlay)overlayData).texture);
|
||||
if (!imageData.imageLoaded())
|
||||
continue;
|
||||
|
||||
if (!this.preRenderOverlay(overlayData, player))
|
||||
continue;
|
||||
@@ -273,17 +272,12 @@ public class RenderCNPCPlayer extends RenderPlayer {
|
||||
|
||||
if (ClientCacheHandler.skinOverlays.containsKey(player.getUniqueID())) {
|
||||
for (SkinOverlay overlayData : ClientCacheHandler.skinOverlays.get(player.getUniqueID()).values()) {
|
||||
if (overlayData.texture.isEmpty())
|
||||
if (((SkinOverlay)overlayData).texture.isEmpty())
|
||||
continue;
|
||||
|
||||
if (overlayData.location == null) {
|
||||
overlayData.location = new ResourceLocation(overlayData.texture);
|
||||
} else {
|
||||
String str = overlayData.location.getResourceDomain()+":"+overlayData.location.getResourcePath();
|
||||
if (!str.equals(overlayData.texture)) {
|
||||
overlayData.location = new ResourceLocation(overlayData.texture);
|
||||
}
|
||||
}
|
||||
ImageData imageData = ClientCacheHandler.getImageData(((SkinOverlay)overlayData).texture);
|
||||
if (!imageData.imageLoaded())
|
||||
continue;
|
||||
|
||||
if (!this.preRenderOverlay(overlayData, player))
|
||||
continue;
|
||||
@@ -400,17 +394,16 @@ public class RenderCNPCPlayer extends RenderPlayer {
|
||||
try {
|
||||
if (ClientCacheHandler.skinOverlays.containsKey(player.getUniqueID())) {
|
||||
for (SkinOverlay overlayData : ClientCacheHandler.skinOverlays.get(player.getUniqueID()).values()) {
|
||||
if (overlayData.texture.isEmpty())
|
||||
if (((SkinOverlay)overlayData).texture.isEmpty())
|
||||
continue;
|
||||
|
||||
if (overlayData.location == null) {
|
||||
overlayData.location = new ResourceLocation(overlayData.texture);
|
||||
} else {
|
||||
String str = overlayData.location.getResourceDomain() + ":" + overlayData.location.getResourcePath();
|
||||
if (!str.equals(overlayData.texture)) {
|
||||
overlayData.location = new ResourceLocation(overlayData.texture);
|
||||
}
|
||||
}
|
||||
ImageData imageData = ClientCacheHandler.getImageData(((SkinOverlay)overlayData).texture);
|
||||
if (!imageData.imageLoaded())
|
||||
continue;
|
||||
|
||||
try {
|
||||
imageData.bindTexture();
|
||||
} catch (Exception e) { continue; }
|
||||
|
||||
if (!this.preRenderOverlay(overlayData, player))
|
||||
continue;
|
||||
|
||||
@@ -226,21 +226,15 @@ public class RenderNPCInterface extends RenderLiving{
|
||||
if (!npc.display.skinOverlayData.overlayList.isEmpty()) {
|
||||
for (ISkinOverlay overlayData : npc.display.skinOverlayData.overlayList.values()) {
|
||||
try {
|
||||
if (((SkinOverlay)overlayData).getLocation() == null) {
|
||||
((SkinOverlay)overlayData).setLocation(new ResourceLocation(overlayData.getTexture()));
|
||||
} else {
|
||||
String str = ((SkinOverlay)npc.display.skinOverlayData.overlayList.get(0)).getLocation().getResourceDomain()+":"+((SkinOverlay)npc.display.skinOverlayData.overlayList.get(0)).getLocation().getResourcePath();
|
||||
if (!str.equals(overlayData.getTexture())) {
|
||||
((SkinOverlay)overlayData).setLocation(new ResourceLocation(overlayData.getTexture()));
|
||||
}
|
||||
}
|
||||
if (((SkinOverlay)overlayData).texture.isEmpty())
|
||||
continue;
|
||||
|
||||
if (overlayData.getTexture().isEmpty() || ((SkinOverlay)overlayData).getLocation() == null
|
||||
|| ((SkinOverlay)overlayData).getLocation().getResourcePath().isEmpty())
|
||||
ImageData imageData = ClientCacheHandler.getImageData(((SkinOverlay)overlayData).texture);
|
||||
if (!imageData.imageLoaded())
|
||||
continue;
|
||||
|
||||
try {
|
||||
this.bindTexture(((SkinOverlay)overlayData).getLocation());
|
||||
imageData.bindTexture();
|
||||
} catch (Exception e) { continue; }
|
||||
|
||||
// Overlay & Glow
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
package noppes.npcs.controllers.data;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import noppes.npcs.api.ISkinOverlay;
|
||||
import noppes.npcs.client.ClientCacheHandler;
|
||||
import noppes.npcs.client.renderer.ImageData;
|
||||
import noppes.npcs.entity.data.DataSkinOverlays;
|
||||
|
||||
public class SkinOverlay implements ISkinOverlay {
|
||||
public DataSkinOverlays parent;
|
||||
public ResourceLocation location = null;
|
||||
public String texture;
|
||||
|
||||
public boolean glow = true;
|
||||
public boolean blend = true;
|
||||
public float alpha = 1.0F;
|
||||
@@ -39,7 +43,7 @@ public class SkinOverlay implements ISkinOverlay {
|
||||
this.updateClient();
|
||||
}
|
||||
public String getTexture() {
|
||||
return texture;
|
||||
return this.texture;
|
||||
}
|
||||
|
||||
public void setGlow(boolean glow) {
|
||||
@@ -114,14 +118,6 @@ public class SkinOverlay implements ISkinOverlay {
|
||||
return offsetZ;
|
||||
}
|
||||
|
||||
public void setLocation(ResourceLocation location) {
|
||||
this.location = location;
|
||||
this.updateClient();
|
||||
}
|
||||
public ResourceLocation getLocation() {
|
||||
return this.location;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
this.texture = compound.getString("SkinOverlayTexture");
|
||||
this.glow = compound.getBoolean("SkinOverlayGlow");
|
||||
|
||||
Reference in new issue
Block a user