forked from Strangerrrs/Raven-bS
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
103 additions
and
50 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
src/main/java/keystrokesmod/mixins/impl/gui/MixinGuiMultiplayer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package keystrokesmod.mixins.impl.gui; | ||
|
||
|
||
import net.minecraft.client.gui.GuiMultiplayer; | ||
import net.minecraft.client.gui.GuiScreen; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(GuiMultiplayer.class) | ||
public class MixinGuiMultiplayer extends GuiScreen { | ||
|
||
@Redirect(method = "drawScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiMultiplayer;drawDefaultBackground()V")) | ||
public void onDrawDefaultBackground(GuiMultiplayer instance) { | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/keystrokesmod/mixins/impl/gui/MixinGuiSlot.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package keystrokesmod.mixins.impl.gui; | ||
|
||
|
||
import keystrokesmod.module.ModuleManager; | ||
import keystrokesmod.utility.render.BackgroundUtils; | ||
import net.minecraft.client.gui.GuiSlot; | ||
import net.minecraft.client.renderer.Tessellator; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(GuiSlot.class) | ||
public class MixinGuiSlot { | ||
|
||
@Inject(method = "drawContainerBackground", at = @At("HEAD"), cancellable = true, remap = false) | ||
public void onDrawContainerBackground(Tessellator p_drawContainerBackground_1_, CallbackInfo ci) { | ||
if (!ModuleManager.clientTheme.isEnabled() || !ModuleManager.clientTheme.background.isToggled()) | ||
return; | ||
|
||
BackgroundUtils.renderBackground((GuiSlot) (Object) this); | ||
|
||
ci.cancel(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 56 additions & 43 deletions
99
src/main/java/keystrokesmod/utility/render/BackgroundUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,75 @@ | ||
package keystrokesmod.utility.render; | ||
|
||
import keystrokesmod.Raven; | ||
import lombok.Getter; | ||
import it.unimi.dsi.fastutil.objects.ObjectArrayList; | ||
import keystrokesmod.utility.Utils; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.GuiScreen; | ||
import net.minecraft.client.gui.GuiSlot; | ||
import net.minecraft.client.gui.ScaledResolution; | ||
import net.minecraft.client.renderer.GlStateManager; | ||
import net.minecraft.client.renderer.Tessellator; | ||
import net.minecraft.client.renderer.WorldRenderer; | ||
import net.minecraft.client.renderer.texture.DynamicTexture; | ||
import net.minecraft.client.renderer.texture.TextureManager; | ||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats; | ||
import net.minecraft.client.shader.Framebuffer; | ||
import net.minecraft.util.ResourceLocation; | ||
import org.apache.commons.io.IOUtils; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import javax.imageio.ImageIO; | ||
import java.awt.*; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Objects; | ||
import java.util.List; | ||
|
||
import static keystrokesmod.Raven.mc; | ||
|
||
public class BackgroundUtils { | ||
private static final int BLOOM_COLOR = new Color(255, 255, 255, 50).getRGB(); | ||
public static final ResourceLocation RES_BG = new ResourceLocation("keystrokesmod:textures/backgrounds/bg.png"); | ||
public static final ResourceLocation RES_QI = new ResourceLocation("keystrokesmod:textures/backgrounds/qi.png"); | ||
public static final ResourceLocation RES_DIANXIAN = new ResourceLocation("keystrokesmod:textures/backgrounds/DianXian.png"); | ||
public static final ResourceLocation RES_HUOCHE = new ResourceLocation("keystrokesmod:textures/backgrounds/huoChe.png"); | ||
public static final ResourceLocation RES_DIANXIAN2 = new ResourceLocation("keystrokesmod:textures/backgrounds/DianXian2.png"); | ||
public static final ResourceLocation RES_CAO = new ResourceLocation("keystrokesmod:textures/backgrounds/cao.png"); | ||
public static final ResourceLocation RES_REN = new ResourceLocation("keystrokesmod:textures/backgrounds/ren.png"); | ||
public static final ResourceLocation RES_LOGO = new ResourceLocation("keystrokesmod:textures/backgrounds/ravenxd.png"); | ||
private static final List<ResourceLocation> BACKGROUNDS = new ObjectArrayList<>(); | ||
private static final int MAX_INDEX; | ||
|
||
private static long lastRenderTime = -1; | ||
private static ResourceLocation lastBackground; | ||
private static int shadow = 0; | ||
|
||
static { | ||
BACKGROUNDS.add(new ResourceLocation("keystrokesmod:textures/backgrounds/1.png")); | ||
BACKGROUNDS.add(new ResourceLocation("keystrokesmod:textures/backgrounds/2.png")); | ||
BACKGROUNDS.add(new ResourceLocation("keystrokesmod:textures/backgrounds/3.png")); | ||
BACKGROUNDS.add(new ResourceLocation("keystrokesmod:textures/backgrounds/4.png")); | ||
BACKGROUNDS.add(new ResourceLocation("keystrokesmod:textures/backgrounds/5.png")); | ||
MAX_INDEX = BACKGROUNDS.size() - 1; | ||
|
||
lastBackground = BACKGROUNDS.get(Utils.randomizeInt(0, MAX_INDEX)); | ||
} | ||
|
||
public static void renderBackground(@NotNull GuiScreen screen) { | ||
updateShadow(0); | ||
renderBackground(screen.width, screen.height); | ||
} | ||
|
||
public static void renderBackground(@NotNull GuiSlot slot) { | ||
updateShadow(200); | ||
renderBackground(slot.width, slot.height); | ||
} | ||
|
||
private static void renderBackground(final int width, final int height) { | ||
final long time = System.currentTimeMillis(); | ||
if (time - lastRenderTime > 30000) { | ||
lastBackground = BACKGROUNDS.get(Utils.randomizeInt(0, MAX_INDEX)); | ||
} | ||
lastRenderTime = time; | ||
|
||
RenderUtils.drawImage(lastBackground, 0, 0, width, height); | ||
|
||
if (shadow != 0) { | ||
ScaledResolution resolution = new ScaledResolution(mc); | ||
RenderUtils.drawBloomShadow(0, 0, resolution.getScaledWidth(), resolution.getScaledHeight(), 4, | ||
new Color(0, 0, 0, shadow), false | ||
); | ||
} | ||
} | ||
|
||
private static int huoCheX = -99999; | ||
|
||
public static void renderBackground(@NotNull GuiScreen gui) { | ||
final int width = gui.width; | ||
final int height = gui.height; | ||
|
||
if (huoCheX == -99999) | ||
huoCheX = -width; | ||
|
||
RenderUtils.drawImage(RES_BG, 0, 0, width, height); | ||
RenderUtils.drawImage(RES_QI, 0, 0, width, height); | ||
RenderUtils.drawImage(RES_DIANXIAN, 0, 0, width, height); | ||
RenderUtils.drawImage(RES_HUOCHE, huoCheX, height / 3F, width * 2F, height / 3F); | ||
RenderUtils.drawImage(RES_DIANXIAN2, 0, 0, width, height); | ||
RenderUtils.drawImage(RES_CAO, 0, 0, width, height); | ||
RenderUtils.drawBloomShadow(0, 0, width, height, 12, 6, BLOOM_COLOR, true); | ||
RenderUtils.drawImage(RES_REN, 0, 0, width, height); | ||
if (huoCheX >= 0) { | ||
huoCheX = -width; | ||
private static void updateShadow(final int shadowTarget) { | ||
if (shadowTarget > shadow) { | ||
shadow = (int) Math.min(shadow + 4.0 * 300 / Minecraft.getDebugFPS(), shadowTarget); | ||
} else if (shadowTarget < shadow) { | ||
shadow = (int) Math.max(shadow - 4.0 * 300 / Minecraft.getDebugFPS(), shadowTarget); | ||
} | ||
huoCheX++; | ||
} | ||
|
||
public static ResourceLocation getLogoPng() { | ||
return RES_LOGO; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed
BIN
-69.2 KB
src/main/resources/assets/keystrokesmod/textures/backgrounds/DianXian.png
Binary file not shown.
Binary file removed
BIN
-68.5 KB
src/main/resources/assets/keystrokesmod/textures/backgrounds/DianXian2.png
Binary file not shown.
Binary file removed
BIN
-2.03 MB
src/main/resources/assets/keystrokesmod/textures/backgrounds/bg.png
Binary file not shown.
Binary file removed
BIN
-483 KB
src/main/resources/assets/keystrokesmod/textures/backgrounds/cao.png
Binary file not shown.
Binary file removed
BIN
-217 KB
src/main/resources/assets/keystrokesmod/textures/backgrounds/huoChe.png
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-669 KB
src/main/resources/assets/keystrokesmod/textures/backgrounds/ren.png
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters