Skip to content

Commit

Permalink
[wip] the rest of the owl
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamefrede committed Dec 12, 2023
1 parent 85ef344 commit 3f9806b
Show file tree
Hide file tree
Showing 97 changed files with 404 additions and 472 deletions.
5 changes: 2 additions & 3 deletions src/main/java/vazkii/psi/api/internal/DummyMethodHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
*/
package vazkii.psi.api.internal;

import com.mojang.blaze3d.vertex.PoseStack;

import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
Expand Down Expand Up @@ -70,7 +69,7 @@ public void setCrashData(CompiledSpell spell, SpellPiece piece) {

@Override
@OnlyIn(Dist.CLIENT)
public void renderTooltip(PoseStack ms, int x, int y, List<Component> tooltipData, int color, int color2, int width, int height) {
public void renderTooltip(GuiGraphics graphics, int x, int y, List<Component> tooltipData, int color, int color2, int width, int height) {
// NO-OP
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
*/
package vazkii.psi.api.internal;

import com.mojang.blaze3d.vertex.PoseStack;

import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
Expand Down Expand Up @@ -70,7 +69,7 @@ public interface IInternalMethodHandler {
* Renders a tooltip with the specified colors at the given x,y position
*/
@OnlyIn(Dist.CLIENT)
void renderTooltip(PoseStack ms, int x, int y, List<Component> tooltipData, int color, int color2, int width, int height);
void renderTooltip(GuiGraphics graphics, int x, int y, List<Component> tooltipData, int color, int color2, int width, int height);

/**
* Creates a CAD with the given components
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/vazkii/psi/api/internal/Vector3.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@ public Vec3 toVec3D() {
return new Vec3(x, y, z);
}

public Vec3i toVec3i() { return new Vec3i((int) x, (int) y, (int) z); }
public Vec3i toVec3i() {
return new Vec3i((int) x, (int) y, (int) z);
}

public BlockPos toBlockPos() {
return new BlockPos(toVec3i());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import net.minecraft.sounds.SoundEvent;
import net.minecraft.util.LazyLoadedValue;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.ArmorMaterial;
import net.minecraft.world.item.crafting.Ingredient;
Expand Down Expand Up @@ -41,7 +40,6 @@ public PsimetalArmorMaterial(String nameIn, int maxDamageFactorIn, int[] damageR
this.knockbackResistance = knockbackResistance;
}


@Override
public int getDurabilityForType(ArmorItem.Type pType) {
return MAX_DAMAGE_ARRAY[pType.ordinal()] * this.maxDamageFactor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/
package vazkii.psi.api.material;

import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.LazyLoadedValue;
import net.minecraft.world.item.Tier;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/vazkii/psi/api/recipe/ITrickRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
package vazkii.psi.api.recipe;

import net.minecraft.core.NonNullList;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/vazkii/psi/api/spell/Spell.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
*/
package vazkii.psi.api.spell;

import com.mojang.blaze3d.vertex.PoseStack;

import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
Expand Down Expand Up @@ -46,8 +45,8 @@ public Spell() {
}

@OnlyIn(Dist.CLIENT)
public void draw(PoseStack ms, MultiBufferSource buffers, int light) {
grid.draw(ms, buffers, light);
public void draw(GuiGraphics graphics, MultiBufferSource buffers, int light) {
grid.draw(graphics, buffers, light);
}

@Nullable
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/vazkii/psi/api/spell/SpellGrid.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.mojang.blaze3d.vertex.PoseStack;

import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
Expand Down Expand Up @@ -45,15 +45,15 @@ public final class SpellGrid {
private int leftmost, rightmost, topmost, bottommost;

@OnlyIn(Dist.CLIENT)
public void draw(PoseStack ms, MultiBufferSource buffers, int light) {
public void draw(GuiGraphics graphics, MultiBufferSource buffers, int light) {
for(int i = 0; i < GRID_SIZE; i++) {
for(int j = 0; j < GRID_SIZE; j++) {
SpellPiece p = gridData[i][j];
if(p != null) {
ms.pushPose();
ms.translate(i * 18, j * 18, 0);
p.draw(ms, buffers, light);
ms.popPose();
graphics.pose().pushPose();
graphics.pose().translate(i * 18, j * 18, 0);
p.draw(graphics, buffers, light);
graphics.pose().popPose();
}
}
}
Expand Down
52 changes: 26 additions & 26 deletions src/main/java/vazkii/psi/api/spell/SpellPiece.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.blaze3d.vertex.VertexFormat;

import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.MultiBufferSource;
Expand Down Expand Up @@ -279,19 +279,19 @@ public void setStatLabel(EnumSpellStat type, StatLabel descriptor) {
* To avoid z-fighting in the TE projection, translations are applied every step.
*/
@OnlyIn(Dist.CLIENT)
public void draw(PoseStack ms, MultiBufferSource buffers, int light) {
ms.pushPose();
drawBackground(ms, buffers, light);
ms.translate(0F, 0F, 0.1F);
drawAdditional(ms, buffers, light);
public void draw(GuiGraphics graphics, MultiBufferSource buffers, int light) {
graphics.pose().pushPose();
drawBackground(graphics, buffers, light);
graphics.pose().translate(0F, 0F, 0.1F);
drawAdditional(graphics, buffers, light);
if(isInGrid) {
ms.translate(0F, 0F, 0.1F);
drawParams(ms, buffers, light);
ms.translate(0F, 0F, 0.1F);
drawComment(ms, buffers, light);
graphics.pose().translate(0F, 0F, 0.1F);
drawParams(graphics, buffers, light);
graphics.pose().translate(0F, 0F, 0.1F);
drawComment(graphics, buffers, light);
}

ms.popPose();
graphics.pose().popPose();
}

@OnlyIn(Dist.CLIENT)
Expand Down Expand Up @@ -319,10 +319,10 @@ public static RenderType getLayer() {
* Draws this piece's background.
*/
@OnlyIn(Dist.CLIENT)
public void drawBackground(PoseStack ms, MultiBufferSource buffers, int light) {
public void drawBackground(GuiGraphics graphics, MultiBufferSource buffers, int light) {
Material material = ClientPsiAPI.getSpellPieceMaterial(registryKey);
VertexConsumer buffer = material.buffer(buffers, ignored -> getLayer());
Matrix4f mat = ms.last().pose();
Matrix4f mat = graphics.pose().last().pose();
// Cannot call .texture() on the chained object because SpriteAwareVertexBuilder is buggy
// and does not return itself, it returns the inner buffer
// This leads to .texture() using the implementation of the inner buffer,
Expand All @@ -346,15 +346,15 @@ public void drawBackground(PoseStack ms, MultiBufferSource buffers, int light) {
* to draw the lines.
*/
@OnlyIn(Dist.CLIENT)
public void drawAdditional(PoseStack ms, MultiBufferSource buffers, int light) {
public void drawAdditional(GuiGraphics graphics, MultiBufferSource buffers, int light) {
// NO-OP
}

/**
* Draws the little comment indicator in this piece, if one exists.
*/
@OnlyIn(Dist.CLIENT)
public void drawComment(PoseStack ms, MultiBufferSource buffers, int light) {
public void drawComment(GuiGraphics graphics, MultiBufferSource buffers, int light) {
if(comment != null && !comment.isEmpty()) {
VertexConsumer buffer = buffers.getBuffer(PsiAPI.internalHandler.getProgrammerLayer());

Expand All @@ -363,7 +363,7 @@ public void drawComment(PoseStack ms, MultiBufferSource buffers, int light) {
float minV = 184 / 256F;
float maxU = (150 + wh) / 256F;
float maxV = (184 + wh) / 256F;
Matrix4f mat = ms.last().pose();
Matrix4f mat = graphics.pose().last().pose();

buffer.vertex(mat, -2, 4, 0).color(1F, 1F, 1F, 1F).uv(minU, maxV).uv2(light).endVertex();
buffer.vertex(mat, 4, 4, 0).color(1F, 1F, 1F, 1F).uv(maxU, maxV).uv2(light).endVertex();
Expand All @@ -376,15 +376,15 @@ public void drawComment(PoseStack ms, MultiBufferSource buffers, int light) {
* Draws the parameters coming into this piece.
*/
@OnlyIn(Dist.CLIENT)
public void drawParams(PoseStack ms, MultiBufferSource buffers, int light) {
public void drawParams(GuiGraphics graphics, MultiBufferSource buffers, int light) {
VertexConsumer buffer = buffers.getBuffer(PsiAPI.internalHandler.getProgrammerLayer());
for(SpellParam<?> param : paramSides.keySet()) {
drawParam(ms, buffer, light, param);
drawParam(graphics, buffer, light, param);
}
}

@OnlyIn(Dist.CLIENT)
public void drawParam(PoseStack ms, VertexConsumer buffer, int light, SpellParam<?> param) {
public void drawParam(GuiGraphics graphics, VertexConsumer buffer, int light, SpellParam<?> param) {
SpellParam.Side side = paramSides.get(param);
if(!side.isEnabled() || param.getArrowType() == ArrowType.NONE) {
return;
Expand All @@ -405,11 +405,11 @@ public void drawParam(PoseStack ms, VertexConsumer buffer, int light, SpellParam
if(count > 1) {
percent = (float) index / (count - 1);
}
drawParam(ms, buffer, light, side, param.color, param.getArrowType(), percent);
drawParam(graphics, buffer, light, side, param.color, param.getArrowType(), percent);
}

@OnlyIn(Dist.CLIENT)
public void drawParam(PoseStack ms, VertexConsumer buffer, int light, SpellParam.Side side, int color, SpellParam.ArrowType arrowType, float percent) {
public void drawParam(GuiGraphics graphics, VertexConsumer buffer, int light, SpellParam.Side side, int color, SpellParam.ArrowType arrowType, float percent) {
if(arrowType == ArrowType.NONE) {
return;
}
Expand All @@ -432,7 +432,7 @@ public void drawParam(PoseStack ms, VertexConsumer buffer, int light, SpellParam
int g = PsiRenderHelper.g(color);
int b = PsiRenderHelper.b(color);
int a = 255;
Matrix4f mat = ms.last().pose();
Matrix4f mat = graphics.pose().last().pose();

buffer.vertex(mat, minX, maxY, 0).color(r, g, b, a).uv(minU, maxV).uv2(light).endVertex();
buffer.vertex(mat, maxX, maxY, 0).color(r, g, b, a).uv(maxU, maxV).uv2(light).endVertex();
Expand Down Expand Up @@ -470,16 +470,16 @@ public int getParamArrowIndex(SpellParam<?> param) {
* Draws this piece's tooltip.
*/
@OnlyIn(Dist.CLIENT)
public void drawTooltip(PoseStack ms, int tooltipX, int tooltipY, List<Component> tooltip, Screen screen) {
PsiAPI.internalHandler.renderTooltip(ms, tooltipX, tooltipY, tooltip, 0x505000ff, 0xf0100010, screen.width, screen.height);
public void drawTooltip(GuiGraphics graphics, int tooltipX, int tooltipY, List<Component> tooltip, Screen screen) {
PsiAPI.internalHandler.renderTooltip(graphics, tooltipX, tooltipY, tooltip, 0x505000ff, 0xf0100010, screen.width, screen.height);
}

/**
* Draws this piece's comment tooltip.
*/
@OnlyIn(Dist.CLIENT)
public void drawCommentText(PoseStack ms, int tooltipX, int tooltipY, List<Component> commentText, Screen screen) {
PsiAPI.internalHandler.renderTooltip(ms, tooltipX, tooltipY - 9 - commentText.size() * 10, commentText, 0x5000a000, 0xf0001e00, screen.width, screen.height);
public void drawCommentText(GuiGraphics graphics, int tooltipX, int tooltipY, List<Component> commentText, Screen screen) {
PsiAPI.internalHandler.renderTooltip(graphics, tooltipX, tooltipY - 9 - commentText.size() * 10, commentText, 0x5000a000, 0xf0001e00, screen.width, screen.height);
}

@OnlyIn(Dist.CLIENT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
package vazkii.psi.client.core.handler;

import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;

import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/vazkii/psi/client/core/proxy/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.resources.model.Material;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.resources.ResourceLocation;
Expand Down Expand Up @@ -111,8 +110,12 @@ private void addCADModels(ModelEvent.RegisterAdditional event) {
event.register(new ResourceLocation(LibMisc.MOD_ID, "item/" + LibItemNames.CAD_EBONY_PSIMETAL));
event.register(new ResourceLocation(LibMisc.MOD_ID, "item/" + LibItemNames.CAD_IVORY_PSIMETAL));
event.register(new ResourceLocation(LibMisc.MOD_ID, "item/" + LibItemNames.CAD_CREATIVE)); //TODO models
ModelBakery.UNREFERENCED_TEXTURES.addAll(ClientPsiAPI.getAllSpellPieceMaterial());
ModelBakery.UNREFERENCED_TEXTURES.add(new Material(ClientPsiAPI.PSI_PIECE_TEXTURE_ATLAS, PieceConnector.LINES_TEXTURE));
//ModelBakery.UNREFERENCED_TEXTURES.addAll(ClientPsiAPI.getAllSpellPieceMaterial());
//ModelBakery.UNREFERENCED_TEXTURES.add(new Material(ClientPsiAPI.PSI_PIECE_TEXTURE_ATLAS, PieceConnector.LINES_TEXTURE));
for(Material spellpieceMaterial : ClientPsiAPI.getAllSpellPieceMaterial()) {
event.register(spellpieceMaterial.texture());
}
event.register(PieceConnector.LINES_TEXTURE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.mojang.serialization.Codec;

import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.client.particle.TextureSheetParticle;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/vazkii/psi/client/fx/WispParticleType.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.mojang.serialization.Codec;

import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.client.particle.TextureSheetParticle;
Expand Down
Loading

0 comments on commit 3f9806b

Please sign in to comment.