Skip to content
This repository was archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamesuta committed Sep 10, 2016
1 parent ad005e6 commit 6dcd015
Show file tree
Hide file tree
Showing 20 changed files with 321 additions and 254 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ buildscript {
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT'
classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT'
classpath 'com.matthewprenger:CurseGradle:1.0-SNAPSHOT'
}
}
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version_major=2
version_minor=1
version_micro=2.beta
version_minecraft=1.8
version_forge=11.14.4.1563
version_mappings=snapshot_20141130
version_minecraft=1.9
version_forge=12.16.1.1887
version_mappings=snapshot_20160312
127 changes: 63 additions & 64 deletions src/main/java/com/kamesuta/mc/bnnwidget/WGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.client.FMLClientHandler;

public class WGui extends Gui {
public static final Minecraft mc;
public static final Tessellator t = Tessellator.getInstance();
public static final WorldRenderer w = t.getWorldRenderer();
public static final VertexBuffer w = t.getBuffer();
public static final StencilClip clip = StencilClip.instance;
static {
mc = FMLClientHandler.instance().getClient();
Expand Down Expand Up @@ -58,13 +59,13 @@ public static void drawRect(final float x1, final float y1, final float x2, fina
final float b = (color & 255) / 255.0F;
GlStateManager.enableBlend();
GlStateManager.disableTexture2D();
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.color(r, g, b, a);
w.startDrawingQuads();;
w.addVertex(Math.min(x1, x2), Math.max(y1, y2), 0.0D);
w.addVertex(Math.max(x1, x2), Math.max(y1, y2), 0.0D);
w.addVertex(Math.max(x1, x2), Math.min(y1, y2), 0.0D);
w.addVertex(Math.min(x1, x2), Math.min(y1, y2), 0.0D);
w.begin(GL_QUADS, DefaultVertexFormats.POSITION);
w.pos(Math.min(x1, x2), Math.max(y1, y2), 0.0D).endVertex();
w.pos(Math.max(x1, x2), Math.max(y1, y2), 0.0D).endVertex();
w.pos(Math.max(x1, x2), Math.min(y1, y2), 0.0D).endVertex();
w.pos(Math.min(x1, x2), Math.min(y1, y2), 0.0D).endVertex();
t.draw();
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
Expand All @@ -73,30 +74,28 @@ public static void drawRect(final float x1, final float y1, final float x2, fina
/**
* Draws a rectangle with a vertical gradient between the specified colors.
*/
public static void drawGradientRect(final float x1, final float y1, final float x2, final float y2, final int color1, final int color2)
public static void drawGradientRect(final float left, final float top, final float right, final float bottom, final int startColor, final int endColor)
{
final float a1 = (color1 >> 24 & 255) / 255.0F;
final float r1 = (color1 >> 16 & 255) / 255.0F;
final float g1 = (color1 >> 8 & 255) / 255.0F;
final float b1 = (color1 & 255) / 255.0F;
final float a2 = (color2 >> 24 & 255) / 255.0F;
final float r2 = (color2 >> 16 & 255) / 255.0F;
final float g2 = (color2 >> 8 & 255) / 255.0F;
final float b2 = (color2 & 255) / 255.0F;
final float f = (startColor >> 24 & 255) / 255.0F;
final float f1 = (startColor >> 16 & 255) / 255.0F;
final float f2 = (startColor >> 8 & 255) / 255.0F;
final float f3 = (startColor & 255) / 255.0F;
final float f4 = (endColor >> 24 & 255) / 255.0F;
final float f5 = (endColor >> 16 & 255) / 255.0F;
final float f6 = (endColor >> 8 & 255) / 255.0F;
final float f7 = (endColor & 255) / 255.0F;
GlStateManager.disableTexture2D();
GlStateManager.enableBlend();
GlStateManager.disableAlpha();
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GlStateManager.shadeModel(GL_SMOOTH);
w.startDrawingQuads();
w.setColorRGBA_F(r1, g1, b1, a1);
w.addVertex(x2, y1, 0);
w.addVertex(x1, y1, 0);
w.setColorRGBA_F(r2, g2, b2, a2);
w.addVertex(x1, y2, 0);
w.addVertex(x2, y2, 0);
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.shadeModel(7425);
w.begin(7, DefaultVertexFormats.POSITION_COLOR);
w.pos(right, top, 0).color(f1, f2, f3, f).endVertex();
w.pos(left, top, 0).color(f1, f2, f3, f).endVertex();
w.pos(left, bottom, 0).color(f5, f6, f7, f4).endVertex();
w.pos(right, bottom, 0).color(f5, f6, f7, f4).endVertex();
t.draw();
GlStateManager.shadeModel(GL_FLAT);
GlStateManager.shadeModel(7424);
GlStateManager.disableBlend();
GlStateManager.enableAlpha();
GlStateManager.enableTexture2D();
Expand Down Expand Up @@ -131,54 +130,54 @@ public static void drawTexturedModalRect(final float x, final float y, final flo
{
final float f = 0.00390625F;
final float f1 = 0.00390625F;
w.startDrawingQuads();
w.addVertexWithUV(x + 0, y + height, 0, (u + 0) * f, (v + height) * f1);
w.addVertexWithUV(x + width, y + height, 0, (u + width) * f, (v + height) * f1);
w.addVertexWithUV(x + width, y + 0, 0, (u + width) * f, (v + 0) * f1);
w.addVertexWithUV(x + 0, y + 0, 0, (u + 0) * f, (v + 0) * f1);
w.begin(GL_QUADS, DefaultVertexFormats.POSITION_TEX);
w.pos(x + 0, y + height, 0).tex((u + 0) * f, (v + height) * f1).endVertex();
w.pos(x + width, y + height, 0).tex((u + width) * f, (v + height) * f1).endVertex();
w.pos(x + width, y + 0, 0).tex((u + width) * f, (v + 0) * f1).endVertex();
w.pos(x + 0, y + 0, 0).tex((u + 0) * f, (v + 0) * f1).endVertex();
t.draw();
}

public static void drawTexturedModelRectFromIcon(final float x, final float y, final TextureAtlasSprite image, final float width, final float height)
{
w.startDrawingQuads();
w.addVertexWithUV(x + 0, y + height, 0, image.getMinU(), image.getMaxV());
w.addVertexWithUV(x + width, y + height, 0, image.getMaxU(), image.getMaxV());
w.addVertexWithUV(x + width, y + 0, 0, image.getMaxU(), image.getMinV());
w.addVertexWithUV(x + 0, y + 0, 0, image.getMinU(), image.getMinV());
w.begin(GL_QUADS, DefaultVertexFormats.POSITION_TEX);
w.pos(x + 0, y + height, 0).tex(image.getMinU(), image.getMaxV()).endVertex();
w.pos(x + width, y + height, 0).tex(image.getMaxU(), image.getMaxV()).endVertex();
w.pos(x + width, y + 0, 0).tex(image.getMaxU(), image.getMinV()).endVertex();
w.pos(x + 0, y + 0, 0).tex(image.getMinU(), image.getMinV()).endVertex();
t.draw();
}

public static void drawTexturedModelRect(final float x, final float y, final float u, final float v, final float width, final float height, final float divu, final float divv)
{
final float mulu = 1.0F / divu;
final float mulv = 1.0F / divv;
w.startDrawingQuads();
w.addVertexWithUV(x, y + height, 0.0D, u * mulu, (v + height) * mulv);
w.addVertexWithUV(x + width, y + height, 0.0D, (u + width) * mulu, (v + height) * mulv);
w.addVertexWithUV(x + width, y, 0.0D, (u + width) * mulu, v * mulv);
w.addVertexWithUV(x, y, 0.0D, u * mulu, v * mulv);
w.begin(GL_QUADS, DefaultVertexFormats.POSITION_TEX);
w.pos(x, y + height, 0.0D).tex(u * mulu, (v + height) * mulv).endVertex();
w.pos(x + width, y + height, 0.0D).tex((u + width) * mulu, (v + height) * mulv).endVertex();
w.pos(x + width, y, 0.0D).tex((u + width) * mulu, v * mulv).endVertex();
w.pos(x, y, 0.0D).tex(u * mulu, v * mulv).endVertex();
t.draw();
}

public static void drawModalRectWithCustomSizedTexture(final float x, final float y, final float u, final float v, final float uwidth, final float vheight, final float width, final float height, final float divu, final float divv)
{
final float mulu = 1.0F / divu;
final float mulv = 1.0F / divv;
w.startDrawingQuads();
w.addVertexWithUV(x, y + height, 0.0D, u * mulu, (v + vheight) * mulv);
w.addVertexWithUV(x + width, y + height, 0.0D, (u + uwidth) * mulu, (v + vheight) * mulv);
w.addVertexWithUV(x + width, y, 0.0D, (u + uwidth) * mulu, v * mulv);
w.addVertexWithUV(x, y, 0.0D, u * mulu, v * mulv);
w.begin(GL_QUADS, DefaultVertexFormats.POSITION_TEX);
w.pos(x, y + height, 0.0D).tex(u * mulu, (v + vheight) * mulv).endVertex();
w.pos(x + width, y + height, 0.0D).tex((u + uwidth) * mulu, (v + vheight) * mulv).endVertex();
w.pos(x + width, y, 0.0D).tex((u + uwidth) * mulu, v * mulv).endVertex();
w.pos(x, y, 0.0D).tex(u * mulu, v * mulv).endVertex();
t.draw();
}

public static void draw(final Area p, final int mode) {
w.startDrawing(mode);
w.addVertex(p.x1(), p.y1(), 0);
w.addVertex(p.x1(), p.y2(), 0);
w.addVertex(p.x2(), p.y2(), 0);
w.addVertex(p.x2(), p.y1(), 0);
w.begin(mode, DefaultVertexFormats.POSITION);
w.pos(p.x1(), p.y1(), 0);
w.pos(p.x1(), p.y2(), 0);
w.pos(p.x2(), p.y2(), 0);
w.pos(p.x2(), p.y1(), 0);
t.draw();
}

Expand All @@ -199,11 +198,11 @@ public static void drawRect(final Area a)
GlStateManager.enableBlend();
GlStateManager.disableTexture2D();
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
w.startDrawingQuads();
w.addVertex(a.x1(), a.y2(), .0);
w.addVertex(a.x2(), a.y2(), .0);
w.addVertex(a.x2(), a.y1(), .0);
w.addVertex(a.x1(), a.y1(), .0);
w.begin(7, DefaultVertexFormats.POSITION);
w.pos(a.x1(), a.y2(), .0);
w.pos(a.x2(), a.y2(), .0);
w.pos(a.x2(), a.y1(), .0);
w.pos(a.x1(), a.y1(), .0);
t.draw();
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
Expand Down Expand Up @@ -253,11 +252,11 @@ public static void drawTexturedModalRect(final Area a, final Area texture)
{
final float f = 0.00390625F;
final float f1 = 0.00390625F;
w.startDrawingQuads();
w.addVertexWithUV(a.x1(), a.y2(), 0, texture.x1() * f, texture.y2() * f1);
w.addVertexWithUV(a.x2(), a.y2(), 0, texture.x2() * f, texture.y2() * f1);
w.addVertexWithUV(a.x2(), a.y1(), 0, texture.x2() * f, texture.y1() * f1);
w.addVertexWithUV(a.x1(), a.y1(), 0, texture.x1() * f, texture.y1() * f1);
w.begin(GL_QUADS, DefaultVertexFormats.POSITION_TEX);
w.pos(a.x1(), a.y2(), 0).tex(texture.x1() * f, texture.y2() * f1).endVertex();
w.pos(a.x2(), a.y2(), 0).tex(texture.x2() * f, texture.y2() * f1).endVertex();
w.pos(a.x2(), a.y1(), 0).tex(texture.x2() * f, texture.y1() * f1).endVertex();
w.pos(a.x1(), a.y1(), 0).tex(texture.x1() * f, texture.y1() * f1).endVertex();
t.draw();
}

Expand Down Expand Up @@ -308,6 +307,6 @@ public static void drawStringR(final String text, final int x, final int y, fina
public static int getStringWidth(final String s) {
if (StringUtils.isEmpty(s))
return 0;
return font().getStringWidth(EnumChatFormatting.getTextWithoutFormattingCodes(s));
return font().getStringWidth(TextFormatting.getTextWithoutFormattingCodes(s));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.init.SoundEvents;
import net.minecraft.util.ResourceLocation;

public class MButton extends WBase {
Expand Down Expand Up @@ -43,7 +44,7 @@ public void mouseClicked(final WEvent ev, final Area pgp, final Point p, final i
if (this.actionCommand != null)
ev.eventDispatch(this.actionCommand, Integer.valueOf(button));
mc.getSoundHandler()
.playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
.playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.ui_button_click, 1.0F));
}
}
}
Expand Down
Loading

0 comments on commit 6dcd015

Please sign in to comment.