Skip to content

Commit

Permalink
Banners :3
Browse files Browse the repository at this point in the history
  • Loading branch information
SammySemicolon committed Dec 15, 2024
1 parent 40ccdb1 commit 6ae3676
Show file tree
Hide file tree
Showing 72 changed files with 472 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"variants": {
"banner_type=hanging_x": {
"model": "malum:block/soulwoven_banner",
"y": 90
},
"banner_type=hanging_z": {
"model": "malum:block/soulwoven_banner",
"y": 180
},
"banner_type=mounted_east": {
"model": "malum:block/soulwoven_banner_mounted",
"y": 270
},
"banner_type=mounted_north": {
"model": "malum:block/soulwoven_banner_mounted",
"y": 180
},
"banner_type=mounted_south": {
"model": "malum:block/soulwoven_banner_mounted"
},
"banner_type=mounted_west": {
"model": "malum:block/soulwoven_banner_mounted",
"y": 90
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"variants": {
"banner_type=hanging_x": {
"model": "malum:block/soulwoven_banner",
"y": 90
},
"banner_type=hanging_z": {
"model": "malum:block/soulwoven_banner",
"y": 180
},
"banner_type=mounted_east": {
"model": "malum:block/soulwoven_banner_mounted",
"y": 270
},
"banner_type=mounted_north": {
"model": "malum:block/soulwoven_banner_mounted",
"y": 180
},
"banner_type=mounted_south": {
"model": "malum:block/soulwoven_banner_mounted"
},
"banner_type=mounted_west": {
"model": "malum:block/soulwoven_banner_mounted",
"y": 90
}
}
}
4 changes: 3 additions & 1 deletion src/generated/resources/assets/malum/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@
"block.malum.soulwood_totem_base": "Soulwood Totem Base",
"block.malum.soulwood_totem_pole": "Soulwood Totem Pole",
"block.malum.soulwood_trapdoor": "Soulwood Trapdoor",
"block.malum.soulwoven_banner_horns": "Soulwoven Banner Horns",
"block.malum.soulwoven_banner_sigil": "Soulwoven Banner Sigil",
"block.malum.spirit_altar": "Spirit Altar",
"block.malum.spirit_catalyzer": "Spirit Catalyzer",
"block.malum.spirit_catalyzer_component": "Spirit Catalyzer Component",
Expand Down Expand Up @@ -572,9 +574,9 @@
"item.malum.soul_stained_steel_shovel": "Soulstained Steel Shovel",
"item.malum.soul_stained_steel_sword": "Soulstained Steel Sword",
"item.malum.soulwood_boat": "Soulwood Boat",
"item.malum.soulwoven_silk": "Soulwoven Silk",
"item.malum.spectral_lens": "Spectral Lens",
"item.malum.spectral_optic": "Spectral Optic",
"item.malum.spirit_fabric": "Spirit Fabric",
"item.malum.spirit_pouch": "Spirit Pouch",
"item.malum.splash_of_gluttony": "Splash of Gluttony",
"item.malum.staff_of_the_auric_flame": "Staff of the Auric Flame",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "malum:item/soulwoven_banner_horns"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "malum:item/soulwoven_banner_sigil"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "malum:item/spirit_fabric"
"layer0": "malum:item/soulwoven_silk"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"conditions": {
"items": [
{
"items": "malum:spirit_fabric"
"items": "malum:soulwoven_silk"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"criteria": {
"has_the_recipe": {
"conditions": {
"recipe": "malum:spirit_fabric"
"recipe": "malum:soulwoven_silk"
},
"trigger": "minecraft:recipe_unlocked"
}
Expand All @@ -15,7 +15,7 @@
],
"rewards": {
"recipes": [
"malum:spirit_fabric"
"malum:soulwoven_silk"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"type": "minecraft:item",
"name": "malum:soulwoven_banner_horns"
}
],
"rolls": 1.0
}
],
"random_sequence": "malum:blocks/soulwoven_banner_horns"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"type": "minecraft:item",
"name": "malum:soulwoven_banner_sigil"
}
],
"rolls": 1.0
}
],
"random_sequence": "malum:blocks/soulwoven_banner_sigil"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"extraIngredients": [
{
"count": 4,
"item": "malum:spirit_fabric"
"item": "malum:soulwoven_silk"
},
{
"count": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"extraIngredients": [
{
"count": 4,
"item": "malum:spirit_fabric"
"item": "malum:soulwoven_silk"
},
{
"count": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"extraIngredients": [
{
"count": 4,
"item": "malum:spirit_fabric"
"item": "malum:soulwoven_silk"
},
{
"count": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"extraIngredients": [
{
"count": 4,
"item": "malum:spirit_fabric"
"item": "malum:soulwoven_silk"
},
{
"count": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"output": {
"count": 4,
"id": "malum:spirit_fabric"
"id": "malum:soulwoven_silk"
},
"spirits": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
],
"repairMaterial": {
"count": 2,
"item": "malum:spirit_fabric"
"item": "malum:soulwoven_silk"
},
"spirits": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"tag": "c:strings"
},
"Y": {
"item": "malum:spirit_fabric"
"item": "malum:soulwoven_silk"
},
"Z": {
"tag": "minecraft:soul_fire_base_blocks"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"malum:runewood_totem_pole",
"malum:soulwood_totem_base",
"malum:soulwood_totem_pole",
"malum:soulwoven_banner_sigil",
"malum:soulwoven_banner_horns",
"malum:stripped_runewood_log",
"malum:runewood_log",
"malum:stripped_runewood",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.sammy.malum.client.renderer.block;

import com.mojang.blaze3d.vertex.*;
import com.mojang.math.*;
import com.sammy.malum.*;
import com.sammy.malum.client.*;
import com.sammy.malum.common.block.curiosities.banner.*;
import com.sammy.malum.common.block.curiosities.mana_mote.*;
import com.sammy.malum.core.systems.spirit.*;
import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.blockentity.*;
import net.minecraft.core.*;
import net.minecraft.util.*;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.state.*;
import org.joml.*;
import team.lodestar.lodestone.registry.client.*;
import team.lodestar.lodestone.systems.rendering.*;
import team.lodestar.lodestone.systems.rendering.rendeertype.*;

import java.lang.Math;

import static com.sammy.malum.client.RenderUtils.*;


public class SoulwovenBannerRenderer implements BlockEntityRenderer<SoulwovenBannerBlockEntity> {

public SoulwovenBannerRenderer(BlockEntityRendererProvider.Context context) {
}

@Override
public void render(SoulwovenBannerBlockEntity blockEntityIn, float partialTicks, PoseStack poseStack, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) {
var blockState = blockEntityIn.getBlockState();
if (!(blockState.getBlock() instanceof SoulwovenBannerBlock block)) {
return;
}
var pos = blockEntityIn.getBlockPos();
var type = blockState.getValue(SoulwovenBannerBlock.BANNER_TYPE);
var direction = type.direction.getAxis().isVertical() ? type.equals(SoulwovenBannerBlock.BannerType.HANGING_Z) ? Direction.NORTH : Direction.WEST : type.direction;
var builder = VFXBuilders.createWorld()
.setRenderType(LodestoneRenderTypes.TRANSPARENT_TEXTURE.applyWithModifierAndCache(RenderTypeToken.createCachedToken(block.texture), b -> b.setCullState(RenderStateShard.NO_CULL)));
float sway = ((float) Math.floorMod((pos.getX() * 7L + pos.getY() * 9L + pos.getZ() * 13L) + blockEntityIn.getLevel().getGameTime(), 100L) + partialTicks) / 100.0F;
float swayRotation = (0.01F * Mth.cos((float) (Math.PI * 2) * sway)) * (float) Math.PI;

poseStack.pushPose();
poseStack.translate(0.5f, 0.5f, 0.5f);
poseStack.mulPose(Axis.YN.rotationDegrees(direction.toYRot()));
poseStack.translate(-0.5f, -0.5f, -0.5f);
if (type.direction.getAxis().isHorizontal()) {
poseStack.translate(0, -0.25f, 0.0625f);
swayRotation -= 0.0125f;
} else {
poseStack.translate(0, 0, 0.5f);
swayRotation = swayRotation - 0.0157f;
}
poseStack.translate(0, 1f, 0);
poseStack.mulPose(Axis.XP.rotation(swayRotation));
float xStart = 0;
float xEnd = 1;
float yStart = -2;
float yEnd = 0;
Vector3f[] vertices = new Vector3f[]{new Vector3f(xEnd, yStart, 0), new Vector3f(xStart, yStart, 0), new Vector3f(xStart, yEnd, 0), new Vector3f(xEnd, yEnd, 0)};
builder.renderQuad(poseStack, vertices, 1f);

poseStack.popPose();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public static Runnable renderItemFrames(GuiGraphics guiGraphics, @Nullable Compo
return () -> {
if (hoverComponent != null) {
if (isHovering(mouseX, mouseY, crownLeft + 3, plaqueTop + 2, 10, 11)) {
guiGraphics.renderTooltip(Minecraft.getInstance().font, hoverComponent, (int) mouseX, (int) mouseY);
guiGraphics.renderComponentTooltip(Minecraft.getInstance().font, wrapComponent(hoverComponent, 180), (int) mouseX, (int) mouseY);
}
}
};
Expand Down Expand Up @@ -385,9 +385,33 @@ public static MutableComponent convertToComponent(String text, UnaryOperator<Sty
return raw;
}

public static void renderWrappingText(GuiGraphics guiGraphics, String text, int x, int y, int w) {
public static void renderTooltip() {

}

public static void renderWrappingText(GuiGraphics guiGraphics, String text, int x, int y, int width) {
renderWrappingText(guiGraphics, Component.translatable(text), x, y, width);
}
public static void renderWrappingText(GuiGraphics guiGraphics, Component text, int x, int y, int width) {
Font font = Minecraft.getInstance().font;
final List<String> lines = wrapText(text, width);
for (int i = 0; i < lines.size(); i++) {
String currentLine = lines.get(i);
renderRawText(guiGraphics, currentLine, x, y + i * (font.lineHeight + 1), 0.2f);
}
}
public static List<Component> wrapComponent(String text, int width) {
return wrapText(text, width).stream().map(Component::literal).map(Component.class::cast).toList();
}
public static List<Component> wrapComponent(Component component, int width) {
return wrapText(component, width).stream().map(Component::literal).map(Component.class::cast).toList();
}
public static List<String> wrapText(String text, int width) {
return wrapText(Component.translatable(text), width);
}
public static List<String> wrapText(Component component, int width) {
Font font = Minecraft.getInstance().font;
text = Component.translatable(text).getString() + "\n";
String text = component.getString() + "\n";
List<String> lines = new ArrayList<>();

boolean italic = false;
Expand All @@ -402,7 +426,7 @@ public static void renderWrappingText(GuiGraphics guiGraphics, String text, int
char chr = text.charAt(i);
if (chr == ' ' || chr == '\n') {
if (!word.isEmpty()) {
if (font.width(line.toString()) + font.width(word.toString()) > w) {
if (font.width(line.toString()) + font.width(word.toString()) > width) {
line = newLine(lines, italic, bold, strikethrough, underline, obfuscated, line);
}
line.append(word).append(' ');
Expand Down Expand Up @@ -463,11 +487,7 @@ public static void renderWrappingText(GuiGraphics guiGraphics, String text, int
word.append(chr);
}
}

for (int i = 0; i < lines.size(); i++) {
String currentLine = lines.get(i);
renderRawText(guiGraphics, currentLine, x, y + i * (font.lineHeight + 1), 0.2f);
}
return lines;
}

private static StringBuilder commitComponent(MutableComponent component, boolean italic, boolean bold, boolean strikethrough, boolean underline, boolean obfuscated, StringBuilder line, UnaryOperator<Style> styleModifier) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ public static void setupEntries(ArcanaProgressionScreen screen) {
);

screen.addEntry("spirit_fabric", 4, 5, b -> b
.configureWidget(w -> w.setIcon(SPIRIT_FABRIC))
.configureWidget(w -> w.setIcon(SOULWOVEN_SILK))
.addPage(new HeadlineTextPage("spirit_fabric", "spirit_fabric.1"))
.addPage(SpiritInfusionPage.fromOutput(SPIRIT_FABRIC.get()))
.addPage(SpiritInfusionPage.fromOutput(SOULWOVEN_SILK.get()))
.addPage(new HeadlineTextPage("spirit_fabric.pouch", "spirit_fabric.pouch.1"))
.addPage(new CraftingPage(SPIRIT_POUCH.get(), EMPTY, STRING, EMPTY, SPIRIT_FABRIC.get(), SOUL_SAND, SPIRIT_FABRIC.get(), EMPTY, SPIRIT_FABRIC.get(), EMPTY))
.addPage(new CraftingPage(SPIRIT_POUCH.get(), EMPTY, STRING, EMPTY, SOULWOVEN_SILK.get(), SOUL_SAND, SOULWOVEN_SILK.get(), EMPTY, SOULWOVEN_SILK.get(), EMPTY))
);

screen.addEntry("soulhunter_gear", 4, 7, b -> b
Expand Down
Loading

0 comments on commit 6ae3676

Please sign in to comment.