mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-23 13:40:11 +00:00
Fix boss bar renderer, konami renderer, give particles codecs, fix sky renderer
This commit is contained in:
1 parent
cf7ef9a96f
commit
15ad0ed530
9 files changed
+67
-17
No files matched your search
@@ -8,11 +8,13 @@
|
||||
*/
|
||||
package vazkii.botania.client.core.handler;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -42,35 +44,36 @@ public final class BossBarHandler {
|
||||
UUID infoUuid = evt.getBossInfo().getUniqueId();
|
||||
for (EntityDoppleganger currentBoss : bosses) {
|
||||
if (currentBoss.getBossInfoUuid().equals(infoUuid)) {
|
||||
MatrixStack ms = evt.getMatrixStack();
|
||||
evt.setCanceled(true);
|
||||
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
Rectangle bgRect = currentBoss.getBossBarTextureRect();
|
||||
Rectangle fgRect = currentBoss.getBossBarHPTextureRect();
|
||||
String name = evt.getBossInfo().getName().getFormattedText();
|
||||
ITextComponent name = evt.getBossInfo().getName();
|
||||
int c = Minecraft.getInstance().getMainWindow().getScaledWidth() / 2;
|
||||
int x = evt.getX();
|
||||
int y = evt.getY();
|
||||
int xf = x + (bgRect.width - fgRect.width) / 2;
|
||||
int yf = y + (bgRect.height - fgRect.height) / 2;
|
||||
int fw = (int) ((double) fgRect.width * evt.getBossInfo().getPercent());
|
||||
int tx = c - mc.fontRenderer.getStringWidth(name) / 2;
|
||||
int tx = c - mc.fontRenderer.func_238414_a_(name) / 2;
|
||||
|
||||
RenderSystem.color4f(1F, 1F, 1F, 1F);
|
||||
int auxHeight = currentBoss.bossBarRenderCallback(x, y);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
mc.textureManager.bindTexture(currentBoss.getBossBarTexture());
|
||||
drawBar(currentBoss, x, y, bgRect.x, bgRect.y, bgRect.width, bgRect.height, true);
|
||||
drawBar(currentBoss, xf, yf, fgRect.x, fgRect.y, fw, fgRect.height, false);
|
||||
mc.fontRenderer.func_238405_a_(name, tx, y - 10, 0xA2018C);
|
||||
drawBar(ms, currentBoss, x, y, bgRect.x, bgRect.y, bgRect.width, bgRect.height, true);
|
||||
drawBar(ms, currentBoss, xf, yf, fgRect.x, fgRect.y, fw, fgRect.height, false);
|
||||
mc.fontRenderer.func_238407_a_(ms, name, tx, y - 10, 0xA2018C);
|
||||
RenderSystem.enableBlend();
|
||||
evt.setIncrement(Math.max(bgRect.height, fgRect.height) + auxHeight + mc.fontRenderer.FONT_HEIGHT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void drawBar(EntityDoppleganger currentBoss, int x, int y, int u, int v, int w, int h, boolean bg) {
|
||||
private static void drawBar(MatrixStack ms, EntityDoppleganger currentBoss, int x, int y, int u, int v, int w, int h, boolean bg) {
|
||||
ShaderHelper.BotaniaShader program = currentBoss.getBossBarShaderProgram(bg);
|
||||
|
||||
if (program != null) {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
package vazkii.botania.client.core.handler;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -61,18 +62,19 @@ public class KonamiHandler {
|
||||
|
||||
public static void renderBook(BookDrawScreenEvent evt) {
|
||||
if (konamiTime > 0) {
|
||||
MatrixStack ms = evt.matrixStack;
|
||||
String meme = I18n.format("botania.subtitle.way");
|
||||
RenderSystem.disableDepthTest();
|
||||
RenderSystem.pushMatrix();
|
||||
ms.push();
|
||||
int fullWidth = Minecraft.getInstance().fontRenderer.getStringWidth(meme);
|
||||
int left = evt.gui.width;
|
||||
double widthPerTick = (fullWidth + evt.gui.width) / 240;
|
||||
int left = evt.gui.field_230708_k_;
|
||||
double widthPerTick = (fullWidth + evt.gui.field_230708_k_) / 240;
|
||||
double currWidth = left - widthPerTick * (240 - (konamiTime - evt.partialTicks)) * 3.2;
|
||||
|
||||
RenderSystem.translated(currWidth, evt.gui.height / 2 - 10, 0);
|
||||
RenderSystem.scalef(4, 4, 4);
|
||||
Minecraft.getInstance().fontRenderer.func_238405_a_(meme, 0, 0, 0xFFFFFF);
|
||||
RenderSystem.popMatrix();
|
||||
ms.translate(currWidth, evt.gui.field_230709_l_ / 2 - 10, 0);
|
||||
ms.scale(4, 4, 4);
|
||||
Minecraft.getInstance().fontRenderer.func_238405_a_(evt.matrixStack, meme, 0, 0, 0xFFFFFF);
|
||||
ms.pop();
|
||||
RenderSystem.enableDepthTest();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ package vazkii.botania.client.fx;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.particles.IParticleData;
|
||||
import net.minecraft.particles.ParticleType;
|
||||
@@ -21,6 +23,16 @@ import javax.annotation.Nonnull;
|
||||
import java.util.Locale;
|
||||
|
||||
public class SparkleParticleData implements IParticleData {
|
||||
public static final Codec<SparkleParticleData> CODEC = RecordCodecBuilder.create(instance -> instance.group(
|
||||
Codec.FLOAT.fieldOf("size").forGetter(d -> d.size),
|
||||
Codec.FLOAT.fieldOf("r").forGetter(d -> d.r),
|
||||
Codec.FLOAT.fieldOf("g").forGetter(d -> d.g),
|
||||
Codec.FLOAT.fieldOf("b").forGetter(d -> d.b),
|
||||
Codec.INT.fieldOf("m").forGetter(d -> d.m),
|
||||
Codec.BOOL.fieldOf("noClip").forGetter(d -> d.noClip),
|
||||
Codec.BOOL.fieldOf("fake").forGetter(d -> d.fake),
|
||||
Codec.BOOL.fieldOf("corrupt").forGetter(d -> d.corrupt)
|
||||
).apply(instance, SparkleParticleData::new));
|
||||
public final float size;
|
||||
public final float r, g, b;
|
||||
public final int m;
|
||||
|
||||
@@ -8,17 +8,26 @@
|
||||
*/
|
||||
package vazkii.botania.client.fx;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.client.particle.IAnimatedSprite;
|
||||
import net.minecraft.client.particle.IParticleFactory;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.particles.ParticleType;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class SparkleParticleType extends ParticleType<SparkleParticleData> {
|
||||
public SparkleParticleType() {
|
||||
super(false, SparkleParticleData.DESERIALIZER);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Codec<SparkleParticleData> func_230522_e_() {
|
||||
return SparkleParticleData.CODEC;
|
||||
}
|
||||
|
||||
public static class Factory implements IParticleFactory<SparkleParticleData> {
|
||||
private final IAnimatedSprite sprite;
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ package vazkii.botania.client.fx;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.particles.IParticleData;
|
||||
import net.minecraft.particles.ParticleType;
|
||||
@@ -21,6 +23,16 @@ import javax.annotation.Nonnull;
|
||||
import java.util.Locale;
|
||||
|
||||
public class WispParticleData implements IParticleData {
|
||||
public static final Codec<WispParticleData> CODEC = RecordCodecBuilder.create(instance -> instance.group(
|
||||
Codec.FLOAT.fieldOf("size").forGetter(d -> d.size),
|
||||
Codec.FLOAT.fieldOf("r").forGetter(d -> d.r),
|
||||
Codec.FLOAT.fieldOf("g").forGetter(d -> d.g),
|
||||
Codec.FLOAT.fieldOf("b").forGetter(d -> d.b),
|
||||
Codec.FLOAT.fieldOf("maxAgeMul").forGetter(d -> d.maxAgeMul),
|
||||
Codec.BOOL.fieldOf("depthTest").forGetter(d -> d.depthTest),
|
||||
Codec.BOOL.fieldOf("noClip").forGetter(d -> d.noClip)
|
||||
)
|
||||
.apply(instance, WispParticleData::new));
|
||||
public final float size;
|
||||
public final float r, g, b;
|
||||
public final float maxAgeMul;
|
||||
|
||||
@@ -8,17 +8,27 @@
|
||||
*/
|
||||
package vazkii.botania.client.fx;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.client.particle.IAnimatedSprite;
|
||||
import net.minecraft.client.particle.IParticleFactory;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.particles.ParticleType;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class WispParticleType extends ParticleType<WispParticleData> {
|
||||
public WispParticleType() {
|
||||
super(false, WispParticleData.DESERIALIZER);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Codec<WispParticleData> func_230522_e_() {
|
||||
return WispParticleData.CODEC;
|
||||
}
|
||||
|
||||
public static class Factory implements IParticleFactory<WispParticleData> {
|
||||
private final IAnimatedSprite sprite;
|
||||
|
||||
|
||||
@@ -23,9 +23,11 @@ public final class SkyblockRenderEvents {
|
||||
&& world.func_234923_W_() == World.field_234918_g_
|
||||
&& (ConfigHandler.CLIENT.enableFancySkyboxInNormalWorlds.get()
|
||||
|| WorldTypeSkyblock.isWorldSkyblock(world))) {
|
||||
/* todo 1.16
|
||||
if (!(world.getDimension().getSkyRenderer() instanceof SkyblockSkyRenderer)) {
|
||||
world.getDimension().setSkyRenderer(new SkyblockSkyRenderer());
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ public class SkyblockSkyRenderer implements SkyRenderHandler {
|
||||
RenderSystem.disableAlphaTest();
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
float[] afloat = world.dimension.calcSunriseSunsetColors(world.getCelestialAngle(partialTicks), partialTicks);
|
||||
float[] afloat = world.func_239132_a_().func_230492_a_(world.getCelestialAngle(partialTicks), partialTicks);
|
||||
if (afloat != null) {
|
||||
RenderSystem.disableTexture();
|
||||
RenderSystem.shadeModel(7425);
|
||||
|
||||
Reference in new issue
Block a user