mirror of
https://github.com/TheClashFruit/CreatePissAndShit.git
synced 2024-09-19 17:36:47 +00:00
feat: hud elements rendering proof of concept
This commit is contained in:
parent
de31e7c6a2
commit
55931d1db4
|
@ -12,7 +12,6 @@ import net.fabricmc.api.ModInitializer;
|
|||
import net.fabricmc.fabric.api.gamerule.v1.GameRuleFactory;
|
||||
import net.fabricmc.fabric.api.gamerule.v1.GameRuleRegistry;
|
||||
import net.fabricmc.fabric.api.loot.v2.LootTableEvents;
|
||||
import net.minecraft.data.Main;
|
||||
import net.minecraft.loot.LootPool;
|
||||
import net.minecraft.loot.condition.RandomChanceLootCondition;
|
||||
import net.minecraft.loot.entry.ItemEntry;
|
||||
|
@ -29,6 +28,8 @@ public class PissAndShit implements ModInitializer {
|
|||
|
||||
public static final GameRules.Key<GameRules.BooleanRule> PISS_SOURCE_CONVERSION = GameRuleRegistry.register("pissSourceConversion", GameRules.Category.UPDATES, GameRuleFactory.createBooleanRule(false));
|
||||
|
||||
public static MainConfig CONFIG;
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
LOGGER.info("I pissed & shat my pants! (Create Version: {})", Create.VERSION);
|
||||
|
@ -41,6 +42,8 @@ public class PissAndShit implements ModInitializer {
|
|||
|
||||
AutoConfig.register(MainConfig.class, Toml4jConfigSerializer::new);
|
||||
|
||||
CONFIG = AutoConfig.getConfigHolder(MainConfig.class).getConfig();
|
||||
|
||||
Identifier jungleTemple = new Identifier("minecraft", "chests/jungle_temple");
|
||||
Identifier desertPyramid = new Identifier("minecraft", "chests/desert_pyramid");
|
||||
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package me.theclashfruit.pissnshit.client;
|
||||
|
||||
import me.theclashfruit.pissnshit.client.gui.ProofOfConceptHudOverlay;
|
||||
import me.theclashfruit.pissnshit.registry.Fluids;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
|
||||
import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry;
|
||||
import net.fabricmc.fabric.api.client.render.fluid.v1.SimpleFluidRenderHandler;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
|
@ -18,5 +21,15 @@ public class PissAndShitClient implements ClientModInitializer {
|
|||
));
|
||||
|
||||
BlockRenderLayerMap.INSTANCE.putFluids(RenderLayer.getTranslucent(), Fluids.STILL_PISS, Fluids.FLOWING_PISS);
|
||||
|
||||
// will be transferred to a mixin to InGameHud.java
|
||||
MinecraftClient client = MinecraftClient.getInstance();
|
||||
ProofOfConceptHudOverlay hudOverlay = new ProofOfConceptHudOverlay(client);
|
||||
|
||||
HudRenderCallback.EVENT.register((matrices, tickDelta) -> {
|
||||
if (client.player != null) {
|
||||
hudOverlay.render(matrices, 0, 0, tickDelta);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
package me.theclashfruit.pissnshit.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.Drawable;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import static me.theclashfruit.pissnshit.PissAndShit.MOD_ID;
|
||||
|
||||
public class ProofOfConceptHudOverlay implements Drawable {
|
||||
private static final Identifier ICONS = new Identifier(MOD_ID, "textures/gui/icons.png");
|
||||
|
||||
private final MinecraftClient client;
|
||||
|
||||
private final int randFirst;
|
||||
private final int randSecond;
|
||||
|
||||
public ProofOfConceptHudOverlay(MinecraftClient client) {
|
||||
this.client = client;
|
||||
|
||||
this.randFirst = (int) (Math.random() * 100);
|
||||
this.randSecond = (int) (Math.random() * 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
int x = context.getScaledWindowWidth() / 2 + 91;
|
||||
int y = context.getScaledWindowHeight() - 49;
|
||||
|
||||
RenderSystem.setShaderTexture(0, ICONS);
|
||||
|
||||
int pissLevel = this.randFirst;
|
||||
int fullPissIcons = pissLevel / 10;
|
||||
int remainingPissLevel = pissLevel - (fullPissIcons * 10);
|
||||
|
||||
int shitLevel = this.randSecond;
|
||||
int fullShitIcons = shitLevel / 10;
|
||||
int remainingShitLevel = shitLevel - (fullShitIcons * 10);
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
int iconX = x - (9 - i) * 8 - 9;
|
||||
|
||||
if (i < fullPissIcons)
|
||||
context.drawTexture(ICONS, iconX, y - 9, 45, 0, 9, 9);
|
||||
else if (i == fullPissIcons) {
|
||||
if (remainingPissLevel >= 8)
|
||||
context.drawTexture(ICONS, iconX, y - 9, 36, 0, 9, 9);
|
||||
else if (remainingPissLevel >= 6)
|
||||
context.drawTexture(ICONS, iconX, y - 9, 27, 0, 9, 9);
|
||||
else if (remainingPissLevel >= 4)
|
||||
context.drawTexture(ICONS, iconX, y - 9, 18, 0, 9, 9);
|
||||
else if (remainingPissLevel >= 2)
|
||||
context.drawTexture(ICONS, iconX, y - 9, 9, 0, 9, 9);
|
||||
else
|
||||
context.drawTexture(ICONS, iconX, y - 9, 0, 0, 9, 9);
|
||||
} else
|
||||
context.drawTexture(ICONS, iconX, y - 9, 0, 0, 9, 9);
|
||||
|
||||
if (i < fullShitIcons)
|
||||
context.drawTexture(ICONS, iconX, y, 45, 9, 9, 9);
|
||||
else if (i == fullShitIcons) {
|
||||
if (remainingShitLevel >= 8)
|
||||
context.drawTexture(ICONS, iconX, y, 36, 9, 9, 9);
|
||||
else if (remainingShitLevel >= 6)
|
||||
context.drawTexture(ICONS, iconX, y, 27, 9, 9, 9);
|
||||
else if (remainingShitLevel >= 4)
|
||||
context.drawTexture(ICONS, iconX, y, 18, 9, 9, 9);
|
||||
else if (remainingShitLevel >= 2)
|
||||
context.drawTexture(ICONS, iconX, y, 9, 9, 9, 9);
|
||||
else
|
||||
context.drawTexture(ICONS, iconX, y, 0, 9, 9, 9);
|
||||
} else
|
||||
context.drawTexture(ICONS, iconX, y, 0, 9, 9, 9);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,25 +7,25 @@ import me.shedaniel.autoconfig.annotation.ConfigEntry;
|
|||
@Config(name = "pissnshit")
|
||||
public class MainConfig implements ConfigData {
|
||||
@ConfigEntry.Gui.Excluded
|
||||
int configVersion = 1;
|
||||
public int configVersion = 1;
|
||||
|
||||
@ConfigEntry.Gui.CollapsibleObject
|
||||
ShittingMechanics shittingMechanics = new ShittingMechanics();
|
||||
public ShittingMechanics shittingMechanics = new ShittingMechanics();
|
||||
|
||||
@ConfigEntry.Gui.CollapsibleObject
|
||||
PissingMechanics pissingMechanics = new PissingMechanics();
|
||||
public PissingMechanics pissingMechanics = new PissingMechanics();
|
||||
|
||||
static class ShittingMechanics {
|
||||
boolean isMandatory = true;
|
||||
public static class ShittingMechanics {
|
||||
public boolean isMandatory = true;
|
||||
|
||||
int maxIntervalTicks = 72000;
|
||||
int minIntervalTicks = 12000;
|
||||
public int maxIntervalTicks = 72000;
|
||||
public int minIntervalTicks = 12000;
|
||||
}
|
||||
|
||||
static class PissingMechanics {
|
||||
boolean isMandatory = true;
|
||||
public static class PissingMechanics {
|
||||
public boolean isMandatory = true;
|
||||
|
||||
int maxIntervalTicks = 24000;
|
||||
int minIntervalTicks = 3000;
|
||||
public int maxIntervalTicks = 24000;
|
||||
public int minIntervalTicks = 3000;
|
||||
}
|
||||
}
|
||||
|
|
BIN
src/main/resources/assets/pissnshit/textures/gui/icons.png
Normal file
BIN
src/main/resources/assets/pissnshit/textures/gui/icons.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 816 B |
Loading…
Reference in a new issue