mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-19 09:39:05 +00:00
Fix GlStateManager to GL11
This commit is contained in:
1 parent
21d0a41636
commit
651c8db576
1 file changed
+55
-62
@@ -1,7 +1,5 @@
|
||||
package noppes.npcs.client.renderer.blocks;
|
||||
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
import net.geckominecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
@@ -9,12 +7,8 @@ import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.ITickable;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -37,97 +31,96 @@ public class BlockScriptedRenderer extends BlockRendererInterface{
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTicks) {
|
||||
TileScripted tile = (TileScripted) te;
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.disableBlend();
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
GlStateManager.translate(x + 0.5, y, z + 0.5);
|
||||
if(overrideModel()){
|
||||
GlStateManager.translate(0, 0.5, 0);
|
||||
GL11.glTranslatef((float) (x + 0.5), (float) y, (float) (z + 0.5));
|
||||
if (overrideModel()) {
|
||||
GL11.glTranslatef(0, 0.5F, 0);
|
||||
renderItem(te, new ItemStack(CustomItems.scripted));
|
||||
}
|
||||
else{
|
||||
GlStateManager.rotate(tile.rotationY, 0, 1, 0);
|
||||
GlStateManager.rotate(tile.rotationX, 1, 0, 0);
|
||||
GlStateManager.rotate(tile.rotationZ, 0, 0, 1);
|
||||
GlStateManager.scale(tile.scaleX, tile.scaleY, tile.scaleZ);
|
||||
GlStateManager.translate(0, 0.5, 0);
|
||||
} else {
|
||||
GL11.glRotatef(tile.rotationY, 0, 1, 0);
|
||||
GL11.glRotatef(tile.rotationX, 1, 0, 0);
|
||||
GL11.glRotatef(tile.rotationZ, 0, 0, 1);
|
||||
GL11.glScalef(tile.scaleX, tile.scaleY, tile.scaleZ);
|
||||
GL11.glTranslatef(0, 0.5F, 0);
|
||||
renderItem(te, tile.itemModel);
|
||||
}
|
||||
GlStateManager.popMatrix();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if(!tile.text1.text.isEmpty()) {
|
||||
if (!tile.text1.text.isEmpty()) {
|
||||
drawText(tile.text1, x, y, z);
|
||||
}
|
||||
if(!tile.text2.text.isEmpty()) {
|
||||
if (!tile.text2.text.isEmpty()) {
|
||||
drawText(tile.text2, x, y, z);
|
||||
}
|
||||
if(!tile.text3.text.isEmpty()) {
|
||||
if (!tile.text3.text.isEmpty()) {
|
||||
drawText(tile.text3, x, y, z);
|
||||
}
|
||||
if(!tile.text4.text.isEmpty()) {
|
||||
if (!tile.text4.text.isEmpty()) {
|
||||
drawText(tile.text4, x, y, z);
|
||||
}
|
||||
if(!tile.text5.text.isEmpty()) {
|
||||
if (!tile.text5.text.isEmpty()) {
|
||||
drawText(tile.text5, x, y, z);
|
||||
}
|
||||
if(!tile.text6.text.isEmpty()) {
|
||||
if (!tile.text6.text.isEmpty()) {
|
||||
drawText(tile.text6, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawText(TextPlane text1, double x, double y, double z) {
|
||||
if(text1.textBlock == null || text1.textHasChanged){
|
||||
if (text1.textBlock == null || text1.textHasChanged) {
|
||||
text1.textBlock = new TextBlockClient(text1.text, 336, true, Minecraft.getMinecraft().thePlayer);
|
||||
text1.textHasChanged = false;
|
||||
}
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.enableLighting();
|
||||
GlStateManager.color(1, 1, 1);
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(x + 0.5, y + 0.5, z + 0.5);
|
||||
GlStateManager.rotate(text1.rotationY, 0, 1, 0);
|
||||
GlStateManager.rotate(text1.rotationX, 1, 0, 0);
|
||||
GlStateManager.rotate(text1.rotationZ, 0, 0, 1);
|
||||
GlStateManager.scale(text1.scale, text1.scale, 1);
|
||||
GlStateManager.translate(text1.offsetX, text1.offsetY, text1.offsetZ);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) (x + 0.5), (float) (y + 0.5), (float) (z + 0.5));
|
||||
GL11.glRotatef(text1.rotationY, 0, 1, 0);
|
||||
GL11.glRotatef(text1.rotationX, 1, 0, 0);
|
||||
GL11.glRotatef(text1.rotationZ, 0, 0, 1);
|
||||
GL11.glScalef(text1.scale, text1.scale, 1);
|
||||
GL11.glTranslatef(text1.offsetX, text1.offsetY, text1.offsetZ);
|
||||
float f1 = 0.6666667F;
|
||||
float f3 = 0.0133F * f1;
|
||||
GlStateManager.translate(0.0F, 0.5f, 0.01F);
|
||||
GlStateManager.scale(f3, -f3, f3);
|
||||
GlStateManager.glNormal3f(0.0F, 0.0F, -1.0F * f3);
|
||||
GlStateManager.depthMask(false);
|
||||
GL11.glTranslatef(0.0F, 0.5F, 0.01F);
|
||||
GL11.glScalef(f3, -f3, f3);
|
||||
GL11.glNormal3f(0.0F, 0.0F, -1.0F * f3);
|
||||
GL11.glDepthMask(false);
|
||||
FontRenderer fontrenderer = Minecraft.getMinecraft().fontRenderer;
|
||||
|
||||
float lineOffset = 0;
|
||||
if(text1.textBlock.lines.size() < 14)
|
||||
if (text1.textBlock.lines.size() < 14)
|
||||
lineOffset = (14f - text1.textBlock.lines.size()) / 2;
|
||||
for(int i = 0; i < text1.textBlock.lines.size(); i++){
|
||||
for (int i = 0; i < text1.textBlock.lines.size(); i++) {
|
||||
String text = text1.textBlock.lines.get(i).getFormattedText();
|
||||
fontrenderer.drawString(text, -fontrenderer.getStringWidth(text) / 2, (int)((lineOffset + i) * (fontrenderer.FONT_HEIGHT - 0.3)), 0);
|
||||
fontrenderer.drawString(text, -fontrenderer.getStringWidth(text) / 2, (int) ((lineOffset + i) * (fontrenderer.FONT_HEIGHT - 0.3)), 0);
|
||||
}
|
||||
|
||||
GlStateManager.depthMask(true);
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GlStateManager.popMatrix();
|
||||
GL11.glDepthMask(true);
|
||||
GL11.glColor3f(1.0F, 1.0F, 1.0F);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private void renderItem(TileEntity tile, ItemStack stack){
|
||||
private void renderItem(TileEntity tile, ItemStack stack) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if(stack != null) {
|
||||
if (stack != null) {
|
||||
mc.renderEngine.bindTexture(stack.getItem() instanceof ItemBlock ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture);
|
||||
|
||||
GL11.glScalef(2F, 2F, 2F);
|
||||
if(!ForgeHooksClient.renderEntityItem(new EntityItem(tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord, stack), stack, 0F, 0F, tile.getWorldObj().rand, mc.renderEngine, renderBlocks, 1)) {
|
||||
if (!ForgeHooksClient.renderEntityItem(new EntityItem(tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord, stack), stack, 0F, 0F, tile.getWorldObj().rand, mc.renderEngine, renderBlocks, 1)) {
|
||||
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
||||
if(stack.getItem() instanceof ItemBlock && (RenderBlocks.renderItemIn3d(Block.getBlockFromItem(stack.getItem()).getRenderType())
|
||||
if (stack.getItem() instanceof ItemBlock && (RenderBlocks.renderItemIn3d(Block.getBlockFromItem(stack.getItem()).getRenderType())
|
||||
|| Block.getBlockFromItem(stack.getItem()) instanceof BlockScripted)) {
|
||||
renderBlocks.renderBlockAsItem(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage(), 1F);
|
||||
} else {
|
||||
int renderPass = 0;
|
||||
do {
|
||||
IIcon icon = stack.getItem().getIcon(stack, renderPass);
|
||||
if(icon != null) {
|
||||
if (icon != null) {
|
||||
Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass));
|
||||
GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
|
||||
float f = icon.getMinU();
|
||||
@@ -145,23 +138,23 @@ public class BlockScriptedRenderer extends BlockRendererInterface{
|
||||
}
|
||||
}
|
||||
|
||||
private void renderBlock(TileScripted tile, Block b){
|
||||
GlStateManager.pushMatrix();
|
||||
private void renderBlock(TileScripted tile, Block b) {
|
||||
GL11.glPushMatrix();
|
||||
this.bindTexture(TextureMap.locationBlocksTexture);
|
||||
|
||||
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.disableCull();
|
||||
GlStateManager.translate(-0.5F, -0, 0.5F);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
GL11.glTranslatef(-0.5F, -0, 0.5F);
|
||||
renderBlocks.renderStandardBlock(b, tile.xCoord, tile.yCoord, tile.zCoord);
|
||||
if(b.getTickRandomly() && random.nextInt(12) == 1)
|
||||
b.randomDisplayTick(tile.getWorldObj(), tile.xCoord,tile.yCoord,tile.zCoord, random);
|
||||
GlStateManager.popMatrix();
|
||||
if (b.getTickRandomly() && random.nextInt(12) == 1)
|
||||
b.randomDisplayTick(tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord, random);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private boolean overrideModel(){
|
||||
private boolean overrideModel() {
|
||||
ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
|
||||
if(held == null)
|
||||
if (held == null)
|
||||
return false;
|
||||
|
||||
return held.getItem() == CustomItems.wand || held.getItem() == CustomItems.scripter;
|
||||
|
||||
Reference in new issue
Block a user