mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-21 12:42:19 +00:00
Updated Banners
This commit is contained in:
1 parent
2f5d5f84c2
commit
4d2ced4528
25 files changed
+314
-85
No files matched your search
@@ -10,6 +10,7 @@ import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.blocks.BlockBanner;
|
||||
@@ -19,6 +20,7 @@ import noppes.npcs.client.model.blocks.banner.ModelBannerFloorFlag;
|
||||
import noppes.npcs.client.model.blocks.legacy.ModelLegacyBanner;
|
||||
import noppes.npcs.client.model.blocks.legacy.ModelLegacyBannerFlag;
|
||||
import noppes.npcs.config.ConfigClient;
|
||||
import noppes.npcs.constants.EnumBannerVariant;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
@@ -30,9 +32,13 @@ public class BlockBannerRenderer extends BlockRendererInterface{
|
||||
private final ModelBannerFloor banner = new ModelBannerFloor();
|
||||
private final ModelBannerFloorFlag flag = new ModelBannerFloorFlag();
|
||||
|
||||
|
||||
public static final ResourceLocation legacyFlagResource = new ResourceLocation("customnpcs","textures/models/BannerFlag.png");
|
||||
public static final ResourceLocation flagResource = new ResourceLocation("customnpcs","textures/models/banner/flag/BannerFlag1.png");
|
||||
|
||||
public static final ResourceLocation normalFlag = new ResourceLocation("customnpcs","textures/models/banner/flag/normal.png");
|
||||
public static final ResourceLocation pointyFlag = new ResourceLocation("customnpcs","textures/models/banner/flag/pointy.png");
|
||||
public static final ResourceLocation triangleFlag = new ResourceLocation("customnpcs","textures/models/banner/flag/triangle.png");
|
||||
public static final ResourceLocation tornFlag = new ResourceLocation("customnpcs","textures/models/banner/flag/torn.png");
|
||||
public static final ResourceLocation curvedFlag = new ResourceLocation("customnpcs","textures/models/banner/flag/curved.png");
|
||||
|
||||
protected static final ResourceLocation BannerWood = new ResourceLocation("customnpcs","textures/models/banner/BannerFloorWood.png");
|
||||
protected static final ResourceLocation BannerStone = new ResourceLocation("customnpcs","textures/models/banner/BannerFloorStone.png");
|
||||
@@ -66,31 +72,56 @@ public class BlockBannerRenderer extends BlockRendererInterface{
|
||||
float[] color = colorTable[tile.color];
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
legacyFlag.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
if(tile.icon != null && !this.playerTooFar(tile)){
|
||||
doRender(var2, var4, var6, tile.rotation, tile.icon, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
long worldTime = tile.getWorldObj() != null ? tile.getWorldObj().getTotalWorldTime() : 0;
|
||||
// 100 is one full revolution, so we can just mod by 100 without affecting the result
|
||||
int animationProgress100 = (((tile.xCoord % 100) * 7 + (tile.yCoord % 100) * 9 + (tile.zCoord % 100) * 13) + (int) (worldTime % 100)) % 100;
|
||||
float f3 = (float) animationProgress100 + var8;
|
||||
float angle_x = (-0.0125F + 0.01F * MathHelper.cos(f3 * 0.01F * 2F * (float) Math.PI)) * (float) Math.PI;
|
||||
flag.BannerFlag.rotateAngleX = angle_x;
|
||||
|
||||
setBannerMaterial(var1.getBlockMetadata());
|
||||
banner.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
|
||||
this.bindTexture(flagResource);
|
||||
setFlagType(tile.variant);
|
||||
float[] color = colorTable[tile.color];
|
||||
GL11.glPushMatrix();
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
flag.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
}
|
||||
flag.render(null, 0, 0, 0, f3, 0.0F, 0.0625F);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
if(tile.icon != null && !this.playerTooFar(tile)){
|
||||
doRender(var2, var4, var6, tile.rotation, tile.icon);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
if(tile.icon != null && !this.playerTooFar(tile)){
|
||||
doRender(var2, var4, var6, tile.rotation, tile.icon, angle_x);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void doRender(double par2, double par4, double par6, int meta, ItemStack iicon)
|
||||
public void doRender(double par2, double par4, double par6, int meta, ItemStack iicon, float rotate)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
bindTexture(TextureMap.locationItemsTexture);
|
||||
GL11.glTranslatef((float)par2 + 0.5f, (float)par4 +1.3f, (float)par6 + 0.5f);
|
||||
GL11.glRotatef(180, 0, 0, 1);
|
||||
GL11.glRotatef(90 * meta, 0, 1, 0);
|
||||
GL11.glTranslatef(0, 0, -0.14f);
|
||||
if(ConfigClient.LegacyBanner){
|
||||
GL11.glTranslatef(0, 0, -0.14f);
|
||||
}
|
||||
else {
|
||||
GL11.glTranslatef(0, 0, -0.075f);
|
||||
|
||||
GL11.glTranslatef(0, -0.6f, 0); // Translate to pivot point
|
||||
GL11.glRotatef((float) Math.toDegrees(rotate), 1, 0, 0); // Apply sway rotation
|
||||
GL11.glTranslatef(0, 0.6f, 0); // Translate back after rotation
|
||||
}
|
||||
|
||||
GL11.glDepthMask(false);
|
||||
float f2 = 0.05f;
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
@@ -156,14 +187,26 @@ public class BlockBannerRenderer extends BlockRendererInterface{
|
||||
GL11.glRotatef(180, 0, 0, 1);
|
||||
GL11.glRotatef(180, 0, 1, 0);
|
||||
|
||||
setMaterialTexture(metadata);
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
legacyBanner.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
if(ConfigClient.LegacyBanner){
|
||||
setMaterialTexture(metadata);
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
legacyBanner.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
|
||||
this.bindTexture(legacyFlagResource);
|
||||
float[] color = colorTable[15 - metadata];
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
legacyFlag.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
}
|
||||
else {
|
||||
setBannerMaterial(metadata);
|
||||
banner.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
|
||||
this.bindTexture(normalFlag);
|
||||
float[] color = colorTable[15 - metadata];
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
flag.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
}
|
||||
|
||||
this.bindTexture(legacyFlagResource);
|
||||
float[] color = colorTable[15 - metadata];
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
legacyFlag.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@@ -176,7 +219,7 @@ public class BlockBannerRenderer extends BlockRendererInterface{
|
||||
return 26;
|
||||
}
|
||||
|
||||
public void setBannerMaterial(int meta){
|
||||
public static void setBannerMaterial(int meta){
|
||||
TextureManager manager = Minecraft.getMinecraft().getTextureManager();
|
||||
if(meta == 1)
|
||||
manager.bindTexture(BannerStone);
|
||||
@@ -189,4 +232,25 @@ public class BlockBannerRenderer extends BlockRendererInterface{
|
||||
else
|
||||
manager.bindTexture(BannerWood);
|
||||
}
|
||||
|
||||
public static void setFlagType(EnumBannerVariant variant){
|
||||
TextureManager manager = Minecraft.getMinecraft().getTextureManager();
|
||||
switch (variant){
|
||||
case Pointy:
|
||||
manager.bindTexture(pointyFlag);
|
||||
break;
|
||||
case Triangle:
|
||||
manager.bindTexture(triangleFlag);
|
||||
break;
|
||||
case Torn:
|
||||
manager.bindTexture(tornFlag);
|
||||
break;
|
||||
case Curved:
|
||||
manager.bindTexture(curvedFlag);
|
||||
break;
|
||||
default:
|
||||
manager.bindTexture(normalFlag);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,9 +40,11 @@ public class BlockCarpentryBenchRenderer extends TileEntitySpecialRenderer imple
|
||||
this.bindTexture(anvilTexture);
|
||||
anvil.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
this.bindTexture(carpentryBench);
|
||||
model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@@ -34,11 +34,13 @@ public class BlockChairRenderer extends BlockRendererInterface{
|
||||
GL11.glRotatef(90 * tile.rotation, 0, 1, 0);
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
setWoodTexture(var1.getBlockMetadata());
|
||||
if(ConfigClient.LegacyChair)
|
||||
legacyModel.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
else
|
||||
model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@@ -38,14 +38,22 @@ public class BlockStoolRenderer extends BlockRendererInterface{
|
||||
GL11.glRotatef(180, 0, 0, 1);
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
|
||||
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
if(ConfigClient.LegacyStool){
|
||||
setWoodTexture(var1.getBlockMetadata());
|
||||
legacyStool.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
}
|
||||
else {
|
||||
setStoolTexture(var1.getBlockMetadata());
|
||||
if(ConfigClient.WoodTextures) {
|
||||
setWoodTexture(var1.getBlockMetadata());
|
||||
}
|
||||
else {
|
||||
setStoolTexture(var1.getBlockMetadata());
|
||||
}
|
||||
stool.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
}
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
@@ -11,19 +11,26 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.blocks.BlockWallBanner;
|
||||
import noppes.npcs.blocks.tiles.TileWallBanner;
|
||||
import noppes.npcs.client.model.blocks.banner.ModelBannerWall;
|
||||
import noppes.npcs.client.model.blocks.banner.ModelBannerWallFlag;
|
||||
import noppes.npcs.client.model.blocks.legacy.ModelLegacyWallBanner;
|
||||
import noppes.npcs.client.model.blocks.legacy.ModelLegacyWallBannerFlag;
|
||||
import noppes.npcs.config.ConfigClient;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
public class BlockWallBannerRenderer extends BlockRendererInterface{
|
||||
|
||||
private final ModelLegacyWallBanner model = new ModelLegacyWallBanner();
|
||||
private final ModelLegacyWallBannerFlag flag = new ModelLegacyWallBannerFlag();
|
||||
private final ModelLegacyWallBanner modelLegacyWallBanner = new ModelLegacyWallBanner();
|
||||
private final ModelLegacyWallBannerFlag modelLegacyWallBannerFlag = new ModelLegacyWallBannerFlag();
|
||||
|
||||
private final ModelBannerWall model = new ModelBannerWall();
|
||||
private final ModelBannerWallFlag flag = new ModelBannerWallFlag();
|
||||
|
||||
public BlockWallBannerRenderer(){
|
||||
((BlockWallBanner)CustomItems.wallBanner).renderId = RenderingRegistry.getNextAvailableRenderId();
|
||||
@@ -42,29 +49,66 @@ public class BlockWallBannerRenderer extends BlockRendererInterface{
|
||||
GL11.glRotatef(180, 0, 0, 1);
|
||||
GL11.glRotatef(90 * tile.rotation, 0, 1, 0);
|
||||
|
||||
setMaterialTexture(var1.getBlockMetadata());
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
if(ConfigClient.LegacyBanner){
|
||||
setMaterialTexture(var1.getBlockMetadata());
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
modelLegacyWallBanner.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
|
||||
this.bindTexture(BlockBannerRenderer.legacyFlagResource);
|
||||
float[] color = BlockBannerRenderer.colorTable[tile.color];
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
flag.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
this.bindTexture(BlockBannerRenderer.legacyFlagResource);
|
||||
float[] color = BlockBannerRenderer.colorTable[tile.color];
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
modelLegacyWallBannerFlag.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
if(tile.icon != null && !this.playerTooFar(tile)){
|
||||
doRender(var2, var4, var6, tile.rotation, tile.icon);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
if(tile.icon != null && !this.playerTooFar(tile)){
|
||||
doRender(var2, var4, var6, tile.rotation, tile.icon, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
long worldTime = tile.getWorldObj() != null ? tile.getWorldObj().getTotalWorldTime() : 0;
|
||||
// 100 is one full revolution, so we can just mod by 100 without affecting the result
|
||||
int animationProgress100 = (((tile.xCoord % 100) * 7 + (tile.yCoord % 100) * 9 + (tile.zCoord % 100) * 13) + (int) (worldTime % 100)) % 100;
|
||||
float f3 = (float) animationProgress100 + var8;
|
||||
float angle_x = (-0.0125F + 0.01F * MathHelper.cos(f3 * 0.01F * 2F * (float) Math.PI)) * (float) Math.PI;
|
||||
flag.BannerFlag.rotateAngleX = angle_x;
|
||||
|
||||
BlockBannerRenderer.setBannerMaterial(var1.getBlockMetadata());
|
||||
model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
|
||||
BlockBannerRenderer.setFlagType(tile.variant);
|
||||
float[] color = colorTable[tile.color];
|
||||
GL11.glPushMatrix();
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
flag.render(null, 0, 0, 0, f3, 0.0F, 0.0625F);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
if(tile.icon != null && !this.playerTooFar(tile)){
|
||||
doRender(var2, var4, var6, tile.rotation, tile.icon, angle_x);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void doRender(double par2, double par4, double par6, int meta, ItemStack iicon)
|
||||
public void doRender(double par2, double par4, double par6, int meta, ItemStack iicon, float rotate)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
bindTexture(TextureMap.locationItemsTexture);
|
||||
GL11.glTranslatef((float)par2 + 0.5f, (float)par4 +0.2f, (float)par6 + 0.5f);
|
||||
GL11.glTranslatef((float)par2 + 0.5f, (float)par4 + 0.2f, (float)par6 + 0.5f);
|
||||
GL11.glRotatef(180, 0, 0, 1);
|
||||
GL11.glRotatef(90 * meta, 0, 1, 0);
|
||||
GL11.glTranslatef(0, 0, 0.26f);
|
||||
|
||||
if(ConfigClient.LegacyBanner){
|
||||
GL11.glTranslatef(0, 0, 0.26f);
|
||||
}
|
||||
else {
|
||||
GL11.glTranslatef(0, 0, 0.3f);
|
||||
|
||||
GL11.glTranslatef(0, -0.6f, 0); // Translate to pivot point
|
||||
GL11.glRotatef((float) Math.toDegrees(rotate), 1, 0, 0); // Apply sway rotation
|
||||
GL11.glTranslatef(0, 0.6f, 0); // Translate to pivot point
|
||||
}
|
||||
|
||||
GL11.glDepthMask(false);
|
||||
float f2 = 0.05f;
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
@@ -148,14 +192,25 @@ public class BlockWallBannerRenderer extends BlockRendererInterface{
|
||||
GL11.glRotatef(180, 0, 0, 1);
|
||||
GL11.glRotatef(180, 0, 1, 0);
|
||||
|
||||
setMaterialTexture(metadata);
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
if(ConfigClient.LegacyBanner){
|
||||
setMaterialTexture(metadata);
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
modelLegacyWallBanner.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
|
||||
this.bindTexture(BlockBannerRenderer.legacyFlagResource);
|
||||
float[] color = BlockBannerRenderer.colorTable[15 - metadata];
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
flag.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
this.bindTexture(BlockBannerRenderer.legacyFlagResource);
|
||||
float[] color = BlockBannerRenderer.colorTable[15 - metadata];
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
modelLegacyWallBannerFlag.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
}
|
||||
else {
|
||||
BlockBannerRenderer.setBannerMaterial(metadata);
|
||||
model.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
|
||||
this.bindTexture(BlockBannerRenderer.normalFlag);
|
||||
float[] color = colorTable[15 - metadata];
|
||||
GL11.glColor3f(color[0], color[1], color[2]);
|
||||
flag.render(null, 0, 0, 0, 0, 0.0F, 0.0625F);
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user