From 8108c6cb279bbe2a53d2698ee0659933f7afe004 Mon Sep 17 00:00:00 2001 From: Emanuel Ferraz Date: Tue, 12 Dec 2023 23:43:28 +0000 Subject: [PATCH] [wip] the rest of the owl --- .../psi/api/internal/DummyMethodHandler.java | 3 +- .../api/internal/IInternalMethodHandler.java | 3 +- src/main/java/vazkii/psi/api/spell/Spell.java | 5 +- .../java/vazkii/psi/api/spell/SpellGrid.java | 11 ++-- .../java/vazkii/psi/api/spell/SpellPiece.java | 51 ++++++++++--------- .../psi/client/core/proxy/ClientProxy.java | 9 +++- .../psi/client/gui/GuiCADAssembler.java | 28 +++++----- .../vazkii/psi/client/gui/GuiProgrammer.java | 6 +-- .../psi/client/gui/GuiSocketSelect.java | 30 +++++------ .../psi/client/gui/button/GuiButtonHelp.java | 10 ++-- .../psi/client/gui/button/GuiButtonIO.java | 21 +++----- .../psi/client/gui/button/GuiButtonPage.java | 18 +++---- .../gui/button/GuiButtonSideConfig.java | 19 ++----- .../gui/button/GuiButtonSpellPiece.java | 25 ++++----- .../client/gui/widget/SideConfigWidget.java | 18 +++---- .../client/gui/widget/SpellCostsWidget.java | 14 ++--- .../psi/client/gui/widget/StatusWidget.java | 17 ++++--- .../java/vazkii/psi/client/jei/JEICompat.java | 6 ++- .../jei/crafting/BulletToDriveExtension.java | 11 ++-- .../jei/crafting/DriveDuplicateExtension.java | 3 +- .../psi/client/jei/tricks/DrawablePiece.java | 2 +- .../client/patchouli/SpellGridComponent.java | 2 +- .../client/patchouli/SpellPieceComponent.java | 2 +- .../render/entity/RenderSpellCircle.java | 3 +- .../render/tile/RenderTileProgrammer.java | 5 +- .../tile/container/slot/SlotCADOutput.java | 4 +- .../psi/common/core/PsiCreativeTab.java | 47 ++++++++--------- .../capability/CapabilityTriggerSensor.java | 2 +- .../core/handler/AdditiveMotionHandler.java | 4 +- .../core/handler/InternalMethodHandler.java | 7 +-- .../common/core/handler/PsiSoundHandler.java | 18 +++---- .../crafting/recipe/BulletUpgradeRecipe.java | 15 ++++-- .../crafting/recipe/DimensionTrickRecipe.java | 8 +-- .../common/crafting/recipe/TrickRecipe.java | 7 +-- .../common/entity/EntitySpellProjectile.java | 7 +-- .../java/vazkii/psi/common/item/ItemCAD.java | 15 +++--- .../vazkii/psi/common/item/ItemDetonator.java | 2 +- .../common/item/armor/ItemPsimetalArmor.java | 6 +-- .../item/armor/ItemPsimetalExosuitBoots.java | 5 +- .../armor/ItemPsimetalExosuitChestplate.java | 6 +-- .../item/armor/ItemPsimetalExosuitHelmet.java | 5 +- .../armor/ItemPsimetalExosuitLeggings.java | 5 +- .../vazkii/psi/common/item/base/ModItems.java | 11 ++-- .../psi/common/item/tool/IPsimetalTool.java | 2 +- .../network/message/MessageLoopcastSync.java | 2 +- .../network/message/MessageSpellModified.java | 2 +- .../spell/constant/PieceConstantNumber.java | 13 ++--- .../PieceOperatorBlockComparatorStrength.java | 2 +- .../block/PieceOperatorBlockHardness.java | 4 +- .../block/PieceOperatorBlockLightLevel.java | 2 +- .../block/PieceOperatorBlockMiningLevel.java | 2 +- .../block/PieceOperatorBlockSideSolidity.java | 4 +- .../entity/PieceOperatorEntityRaycast.java | 2 +- .../vector/PieceOperatorVectorRaycast.java | 2 +- .../common/spell/other/PieceConnector.java | 11 ++-- .../spell/other/PieceCrossConnector.java | 15 +++--- .../selector/PieceSelectorBlockPresence.java | 2 +- .../selector/PieceSelectorItemCount.java | 2 +- .../spell/selector/PieceSelectorTickTime.java | 2 +- .../entity/PieceSelectorNearbySmeltables.java | 3 +- .../common/spell/trick/PieceTrickBlaze.java | 4 +- .../spell/trick/PieceTrickDetonate.java | 4 +- .../common/spell/trick/PieceTrickExplode.java | 8 ++- .../spell/trick/PieceTrickOvergrow.java | 2 +- .../spell/trick/PieceTrickPlaySound.java | 2 +- .../common/spell/trick/PieceTrickSmite.java | 2 +- .../common/spell/trick/PieceTrickTorrent.java | 2 +- .../PieceTrickCollapseBlockSequence.java | 2 +- .../trick/block/PieceTrickConjureBlock.java | 2 +- .../trick/block/PieceTrickMoveBlock.java | 2 +- .../block/PieceTrickMoveBlockSequence.java | 18 +++---- .../trick/block/PieceTrickPlaceBlock.java | 4 +- .../trick/block/PieceTrickSmeltBlock.java | 2 +- .../block/PieceTrickSmeltBlockSequence.java | 2 +- .../spell/trick/block/PieceTrickTill.java | 2 +- .../trick/block/PieceTrickTillSequence.java | 2 +- .../java/vazkii/psi/data/DataGenerator.java | 8 +-- .../psi/data/PsiBlockModelGenerator.java | 5 +- .../psi/data/PsiItemModelGenerator.java | 5 +- .../vazkii/psi/data/PsiItemTagProvider.java | 15 ++++-- .../psi/data/PsiTrickRecipeGenerator.java | 12 ++--- .../java/vazkii/psi/data/WrapperResult.java | 4 +- 82 files changed, 353 insertions(+), 324 deletions(-) diff --git a/src/main/java/vazkii/psi/api/internal/DummyMethodHandler.java b/src/main/java/vazkii/psi/api/internal/DummyMethodHandler.java index 25ffc3ae..a0ffa3a2 100644 --- a/src/main/java/vazkii/psi/api/internal/DummyMethodHandler.java +++ b/src/main/java/vazkii/psi/api/internal/DummyMethodHandler.java @@ -10,6 +10,7 @@ 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; @@ -70,7 +71,7 @@ public void setCrashData(CompiledSpell spell, SpellPiece piece) { @Override @OnlyIn(Dist.CLIENT) - public void renderTooltip(PoseStack ms, int x, int y, List tooltipData, int color, int color2, int width, int height) { + public void renderTooltip(GuiGraphics graphics, int x, int y, List tooltipData, int color, int color2, int width, int height) { // NO-OP } diff --git a/src/main/java/vazkii/psi/api/internal/IInternalMethodHandler.java b/src/main/java/vazkii/psi/api/internal/IInternalMethodHandler.java index fb392323..65ec9c37 100644 --- a/src/main/java/vazkii/psi/api/internal/IInternalMethodHandler.java +++ b/src/main/java/vazkii/psi/api/internal/IInternalMethodHandler.java @@ -10,6 +10,7 @@ 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; @@ -70,7 +71,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 tooltipData, int color, int color2, int width, int height); + void renderTooltip(GuiGraphics graphics, int x, int y, List tooltipData, int color, int color2, int width, int height); /** * Creates a CAD with the given components diff --git a/src/main/java/vazkii/psi/api/spell/Spell.java b/src/main/java/vazkii/psi/api/spell/Spell.java index 1b8f4463..f9984058 100644 --- a/src/main/java/vazkii/psi/api/spell/Spell.java +++ b/src/main/java/vazkii/psi/api/spell/Spell.java @@ -10,6 +10,7 @@ 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; @@ -46,8 +47,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 diff --git a/src/main/java/vazkii/psi/api/spell/SpellGrid.java b/src/main/java/vazkii/psi/api/spell/SpellGrid.java index 20abb179..e9c83892 100644 --- a/src/main/java/vazkii/psi/api/spell/SpellGrid.java +++ b/src/main/java/vazkii/psi/api/spell/SpellGrid.java @@ -12,6 +12,7 @@ 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; @@ -45,15 +46,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(); } } } diff --git a/src/main/java/vazkii/psi/api/spell/SpellPiece.java b/src/main/java/vazkii/psi/api/spell/SpellPiece.java index a8bf9cf0..38f6b889 100644 --- a/src/main/java/vazkii/psi/api/spell/SpellPiece.java +++ b/src/main/java/vazkii/psi/api/spell/SpellPiece.java @@ -17,6 +17,7 @@ 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; @@ -279,19 +280,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) @@ -319,10 +320,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, @@ -346,7 +347,7 @@ 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 } @@ -354,7 +355,7 @@ public void drawAdditional(PoseStack ms, MultiBufferSource buffers, int light) { * 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()); @@ -363,7 +364,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(); @@ -376,15 +377,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; @@ -405,11 +406,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; } @@ -432,7 +433,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(); @@ -470,16 +471,16 @@ public int getParamArrowIndex(SpellParam param) { * Draws this piece's tooltip. */ @OnlyIn(Dist.CLIENT) - public void drawTooltip(PoseStack ms, int tooltipX, int tooltipY, List 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 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 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 commentText, Screen screen) { + PsiAPI.internalHandler.renderTooltip(graphics, tooltipX, tooltipY - 9 - commentText.size() * 10, commentText, 0x5000a000, 0xf0001e00, screen.width, screen.height); } @OnlyIn(Dist.CLIENT) diff --git a/src/main/java/vazkii/psi/client/core/proxy/ClientProxy.java b/src/main/java/vazkii/psi/client/core/proxy/ClientProxy.java index 9c865909..1ab6677a 100644 --- a/src/main/java/vazkii/psi/client/core/proxy/ClientProxy.java +++ b/src/main/java/vazkii/psi/client/core/proxy/ClientProxy.java @@ -111,8 +111,13 @@ 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 diff --git a/src/main/java/vazkii/psi/client/gui/GuiCADAssembler.java b/src/main/java/vazkii/psi/client/gui/GuiCADAssembler.java index 5ec604da..315c4f13 100644 --- a/src/main/java/vazkii/psi/client/gui/GuiCADAssembler.java +++ b/src/main/java/vazkii/psi/client/gui/GuiCADAssembler.java @@ -12,6 +12,7 @@ import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.ChatFormatting; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.resources.language.I18n; import net.minecraft.network.chat.Component; @@ -44,19 +45,19 @@ public GuiCADAssembler(ContainerCADAssembler containerCADAssembler, Inventory in } @Override - public void render(PoseStack ms, int x, int y, float pTicks) { - this.renderBackground(ms); - super.render(ms, x, y, pTicks); - this.renderTooltip(ms, x, y); - this.renderComponentHoverEffect(ms, Style.EMPTY, x, y); + public void render(GuiGraphics graphics, int x, int y, float pTicks) { + this.renderBackground(graphics); + super.render(graphics, x, y, pTicks); + this.renderTooltip(graphics, x, y); + //this.renderComponentHoverEffect(ms, Style.EMPTY, x, y); TODO(Kamefrede): 1.20 figure out what this breaks } @Override - protected void renderLabels(PoseStack ms, int mouseX, int mouseY) { + protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) { int color = 4210752; String name = new ItemStack(ModBlocks.cadAssembler).getHoverName().getString(); - font.draw(ms, name, imageWidth / 2 - font.width(name) / 2, 10, color); + graphics.drawString(this.font, name, imageWidth / 2 - font.width(name) / 2, 10, color); ItemStack cad = assembler.getCachedCAD(player); if(!cad.isEmpty()) { @@ -66,27 +67,26 @@ protected void renderLabels(PoseStack ms, int mouseX, int mouseY) { ICAD cadItem = (ICAD) cad.getItem(); String stats = I18n.get("psimisc.stats"); String s = ChatFormatting.BOLD + stats; - font.drawShadow(ms, s, 213 - font.width(s) / 2f, 32, color); + graphics.drawString(this.font, s, 213 - font.width(s) / 2f, 32, color, true); for(EnumCADStat stat : EnumCADStat.class.getEnumConstants()) { s = (Psi.magical ? ChatFormatting.LIGHT_PURPLE : ChatFormatting.AQUA) + I18n.get(stat.getName()) + ChatFormatting.RESET + ": " + cadItem.getStatValue(cad, stat); - font.drawShadow(ms, s, 179, 45 + i * 10, color); + graphics.drawString(this.font, s, 179, 45 + i * 10, color, true); i++; } } } @Override - protected void renderBg(PoseStack ms, float partialTicks, int mouseX, int mouseY) { - RenderSystem.setShaderColor(1F, 1F, 1F, 1F); - RenderSystem.setShaderTexture(0, texture); + protected void renderBg(GuiGraphics graphics, float partialTicks, int mouseX, int mouseY) { + graphics.setColor(1F, 1F, 1F, 1F); int x = (width - imageWidth) / 2; int y = (height - imageHeight) / 2; - blit(ms, x, y, 0, 0, imageWidth, imageHeight); + graphics.blit(texture, x, y, 0, 0, imageWidth, imageHeight); for(int i = 0; i < 12; i++) { if(!assembler.isBulletSlotEnabled(i)) { - blit(ms, x + 17 + i % 3 * 18, y + 57 + i / 3 * 18, 16, imageHeight, 16, 16); + graphics.blit(texture, x + 17 + i % 3 * 18, y + 57 + i / 3 * 18, 16, imageHeight, 16, 16); } } } diff --git a/src/main/java/vazkii/psi/client/gui/GuiProgrammer.java b/src/main/java/vazkii/psi/client/gui/GuiProgrammer.java index d8d21f8c..11569f85 100644 --- a/src/main/java/vazkii/psi/client/gui/GuiProgrammer.java +++ b/src/main/java/vazkii/psi/client/gui/GuiProgrammer.java @@ -332,7 +332,7 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTi tooltip.clear(); graphics.pose().translate(gridLeft, gridTop, 0); MultiBufferSource.BufferSource buffers = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder()); - spell.draw(graphics.pose(), buffers, 0xF000F0); + spell.draw(graphics, buffers, 0xF000F0); buffers.endBatch(); compileResult.right().ifPresent(ex -> { @@ -454,12 +454,12 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTi } if(!takingScreenshot && pieceAtCursor != null && mouseMoved) { if(tooltip != null && !tooltip.isEmpty()) { - pieceAtCursor.drawTooltip(graphics.pose(), mouseX, mouseY, tooltip, this); + pieceAtCursor.drawTooltip(graphics, mouseX, mouseY, tooltip, this); } if(comment != null && !comment.isEmpty()) { List commentList = Arrays.stream(comment.split(";")).map(Component::literal).collect(Collectors.toList()); - pieceAtCursor.drawCommentText(graphics.pose(), mouseX, mouseY, commentList, this); + pieceAtCursor.drawCommentText(graphics, mouseX, mouseY, commentList, this); } } diff --git a/src/main/java/vazkii/psi/client/gui/GuiSocketSelect.java b/src/main/java/vazkii/psi/client/gui/GuiSocketSelect.java index 8f429f2f..99fcaeda 100644 --- a/src/main/java/vazkii/psi/client/gui/GuiSocketSelect.java +++ b/src/main/java/vazkii/psi/client/gui/GuiSocketSelect.java @@ -20,6 +20,7 @@ import net.minecraft.ChatFormatting; import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.resources.language.I18n; @@ -96,8 +97,8 @@ public void setSocketable(ItemStack stack) { } @Override - public void render(PoseStack ms, int mx, int my, float delta) { - super.render(ms, mx, my, delta); + public void render(GuiGraphics graphics, int mx, int my, float delta) { + super.render(graphics, mx, my, delta); timeIn += delta; @@ -118,7 +119,7 @@ public void render(PoseStack ms, int mx, int my, float delta) { BufferBuilder buf = tess.getBuilder(); RenderSystem.disableCull(); - RenderSystem.disableTexture(); + //RenderSystem.disableTexture(); TODO(Kamefrede): 1.20 figure out what this breaks RenderSystem.enableBlend(); RenderSystem.setShader(GameRenderer::getPositionColorShader); @@ -181,7 +182,7 @@ public void render(PoseStack ms, int mx, int my, float delta) { } tess.end(); - RenderSystem.enableTexture(); + // RenderSystem.enableTexture(); TODO(Kamefrede): 1.20 figure out what this breaks for(int seg = 0; seg < segments; seg++) { boolean mouseInSector = degPer * seg < angle && angle < degPer * (seg + 1); @@ -205,7 +206,7 @@ public void render(PoseStack ms, int mx, int my, float delta) { int xdp = (int) ((xp - x) * mod + x); int ydp = (int) ((yp - y) * mod + y); - mc.getItemRenderer().renderGuiItem(stack, xdp - 8, ydp - 8); + graphics.renderFakeItem(stack, xdp - 8, ydp - 8); if(xsp < x) { xsp -= width - 8; @@ -214,21 +215,20 @@ public void render(PoseStack ms, int mx, int my, float delta) { ysp -= 9; } - font.drawShadow(ms, name, xsp, ysp, 0xFFFFFF); + graphics.drawString(this.font, name, xsp, ysp, 0xFFFFFF, true); if(seg == socketable.getSelectedSlot()) { int color = 0x00FF00; if(!cadStack.isEmpty()) { color = 0xFF0000 - Psi.proxy.getColorForCAD(cadStack); } - font.drawShadow(ms, I18n.get("psimisc.selected"), xsp + width / 4, ysp + font.lineHeight, color); + graphics.drawString(this.font, I18n.get("psimisc.selected"), xsp + width / 4, ysp + font.lineHeight, color, true); } mod = 0.8; xdp = (int) ((xp - x) * mod + x); ydp = (int) ((yp - y) * mod + y); - RenderSystem.setShaderTexture(0, signs.get(seg)); - blit(ms, xdp - 8, ydp - 8, 0, 0, 16, 16, 16, 16); + graphics.blit(signs.get(seg), xdp - 8, ydp - 8, 0, 0, 16, 16, 16, 16); } } @@ -252,17 +252,17 @@ public void render(PoseStack ms, int mx, int my, float delta) { ItemStack stack = controlledStacks[i]; int rx = xs + i * 18; float ry = ys + (-yoff * shift); - PsiRenderHelper.transferMsToGl(ms, () -> mc.getItemRenderer().renderAndDecorateItem(stack, rx, (int) ry)); + graphics.renderFakeItem(stack, rx, (int) ry); } } if(!socketableStack.isEmpty()) { - ms.pushPose(); - ms.scale(scale, scale, scale); - PsiRenderHelper.transferMsToGl(ms, () -> mc.getItemRenderer().renderAndDecorateItem(socketableStack, - (int) (x / scale) - 8, (int) (y / scale) - 8)); - ms.popPose(); + graphics.pose().pushPose(); + graphics.pose().scale(scale, scale, scale); + graphics.renderFakeItem(socketableStack, + (int) (x / scale) - 8, (int) (y / scale) - 8); + graphics.pose().popPose(); } //Lighting.turnOff(); RenderSystem.disableBlend(); diff --git a/src/main/java/vazkii/psi/client/gui/button/GuiButtonHelp.java b/src/main/java/vazkii/psi/client/gui/button/GuiButtonHelp.java index 0e838464..3ab2d688 100644 --- a/src/main/java/vazkii/psi/client/gui/button/GuiButtonHelp.java +++ b/src/main/java/vazkii/psi/client/gui/button/GuiButtonHelp.java @@ -12,6 +12,7 @@ import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.resources.language.I18n; @@ -25,16 +26,15 @@ public class GuiButtonHelp extends Button { final GuiProgrammer gui; public GuiButtonHelp(int x, int y, GuiProgrammer gui) { - super(x, y, 12, 12, Component.empty(), button -> {}); + super(x, y, 12, 12, Component.empty(), button -> {}, DEFAULT_NARRATION); this.gui = gui; } @Override - public void renderButton(PoseStack ms, int mouseX, int mouseY, float pTicks) { + public void render(GuiGraphics graphics, int mouseX, int mouseY, float pTicks) { if(!gui.takingScreenshot) { - boolean overHelp = mouseX > x && mouseY > y && mouseX < x + 12 && mouseY < y + 12; - RenderSystem.setShaderTexture(0, GuiProgrammer.texture); - blit(ms, x, y, gui.xSize + (overHelp ? 12 : 0), gui.ySize + 9, 12, 12); + boolean overHelp = mouseX > getX() && mouseY > getY() && mouseX < getX() + 12 && mouseY < getY() + 12; + graphics.blit(GuiProgrammer.texture, getX(), getY(), gui.xSize + (overHelp ? 12 : 0), gui.ySize + 9, 12, 12); if(overHelp && !Screen.hasAltDown()) { gui.tooltip.add(Component.translatable("psimisc.programmer_help")); String ctrl = I18n.get(Minecraft.ON_OSX ? "psimisc.ctrl_mac" : "psimisc.ctrl_windows"); diff --git a/src/main/java/vazkii/psi/client/gui/button/GuiButtonIO.java b/src/main/java/vazkii/psi/client/gui/button/GuiButtonIO.java index 1e2a7a27..3c1b734a 100644 --- a/src/main/java/vazkii/psi/client/gui/button/GuiButtonIO.java +++ b/src/main/java/vazkii/psi/client/gui/button/GuiButtonIO.java @@ -8,10 +8,8 @@ */ package vazkii.psi.client.gui.button; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; - import net.minecraft.ChatFormatting; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.network.chat.Component; @@ -22,26 +20,19 @@ public class GuiButtonIO extends Button { public final boolean out; final GuiProgrammer gui; - public GuiButtonIO(int x, int y, boolean out, GuiProgrammer gui) { - super(x, y, 12, 12, Component.empty(), button -> {}); - this.out = out; - this.gui = gui; - } - public GuiButtonIO(int x, int y, boolean out, GuiProgrammer gui, OnPress pressable) { - super(x, y, 12, 12, Component.empty(), pressable); + super(x, y, 12, 12, Component.empty(), pressable, DEFAULT_NARRATION); this.out = out; this.gui = gui; } @Override - public void renderButton(PoseStack ms, int par2, int par3, float pticks) { + public void render(GuiGraphics graphics, int par2, int par3, float pticks) { if(active && !gui.takingScreenshot) { - boolean hover = par2 >= x && par3 >= y && par2 < x + width && par3 < y + height; + boolean hover = par2 >= getX() && par3 >= getY() && par2 < getX() + width && par3 < getY() + height; - RenderSystem.setShaderTexture(0, GuiProgrammer.texture); - RenderSystem.setShaderColor(1F, 1F, 1F, 1F); - blit(ms, x, y, hover ? 186 : 174, out ? 169 : 181, width, height); + graphics.setColor(1F, 1F, 1F, 1F); + graphics.blit(GuiProgrammer.texture, getX(), getY(), hover ? 186 : 174, out ? 169 : 181, width, height); if(hover) { String key = out ? "psimisc.export_to_clipboard" : "psimisc.import_from_clipboard"; diff --git a/src/main/java/vazkii/psi/client/gui/button/GuiButtonPage.java b/src/main/java/vazkii/psi/client/gui/button/GuiButtonPage.java index 622200d8..6678d8a8 100644 --- a/src/main/java/vazkii/psi/client/gui/button/GuiButtonPage.java +++ b/src/main/java/vazkii/psi/client/gui/button/GuiButtonPage.java @@ -11,6 +11,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.network.chat.Component; @@ -21,26 +22,19 @@ public class GuiButtonPage extends Button { public final boolean right; final GuiProgrammer gui; - public GuiButtonPage(int x, int y, boolean right, GuiProgrammer gui) { - super(x, y, 18, 10, Component.empty(), button -> {}); - this.gui = gui; - this.right = right; - } - public GuiButtonPage(int x, int y, boolean right, GuiProgrammer gui, Button.OnPress pressable) { - super(x, y, 18, 10, Component.empty(), pressable); + super(x, y, 18, 10, Component.empty(), pressable, DEFAULT_NARRATION); this.gui = gui; this.right = right; } @Override - public void renderButton(PoseStack ms, int par2, int par3, float pTicks) { + public void render(GuiGraphics graphics, int par2, int par3, float pTicks) { if(active) { - boolean hover = par2 >= x && par3 >= y && par2 < x + width && par3 < y + height; + boolean hover = par2 >= getX() && par3 >= getY() && par2 < getX() + width && par3 < getY() + height; - RenderSystem.setShaderTexture(0, GuiProgrammer.texture); - RenderSystem.setShaderColor(1F, 1F, 1F, 1F); - blit(ms, x, y, hover ? 216 : 198, right ? 145 : 155, width, height); + graphics.setColor(1F, 1F, 1F, 1F); + graphics.blit(GuiProgrammer.texture, getX(), getY(), hover ? 216 : 198, right ? 145 : 155, width, height); if(hover) { gui.tooltip.add(Component.translatable(right ? "psimisc.next_page" : "psimisc.prev_page")); diff --git a/src/main/java/vazkii/psi/client/gui/button/GuiButtonSideConfig.java b/src/main/java/vazkii/psi/client/gui/button/GuiButtonSideConfig.java index 43e16cee..c1c8ebe0 100644 --- a/src/main/java/vazkii/psi/client/gui/button/GuiButtonSideConfig.java +++ b/src/main/java/vazkii/psi/client/gui/button/GuiButtonSideConfig.java @@ -11,6 +11,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.*; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.network.chat.Component; @@ -28,18 +29,8 @@ public class GuiButtonSideConfig extends Button { final int paramIndex; final SpellParam.Side side; - public GuiButtonSideConfig(GuiProgrammer gui, int gridX, int gridY, int paramIndex, String paramName, SpellParam.Side side, int x, int y) { - super(x, y, 8, 8, Component.empty(), Button::onPress); - this.gui = gui; - this.gridX = gridX; - this.gridY = gridY; - this.paramIndex = paramIndex; - this.paramName = paramName; - this.side = side; - } - public GuiButtonSideConfig(GuiProgrammer gui, int gridX, int gridY, int paramIndex, String paramName, SpellParam.Side side, int x, int y, OnPress pressable) { - super(x, y, 8, 8, Component.empty(), pressable); + super(x, y, 8, 8, Component.empty(), pressable, DEFAULT_NARRATION); this.gui = gui; this.gridX = gridX; this.gridY = gridY; @@ -49,10 +40,10 @@ public GuiButtonSideConfig(GuiProgrammer gui, int gridX, int gridY, int paramInd } @Override - public void renderButton(PoseStack ms, int par2, int par3, float pTicks) { + public void render(GuiGraphics graphics, int par2, int par3, float pTicks) { if(active && visible && !gui.takingScreenshot) { - int minX = x; - int minY = y; + int minX = getX(); + int minY = getY(); int maxX = minX + 8; int maxY = minY + 8; diff --git a/src/main/java/vazkii/psi/client/gui/button/GuiButtonSpellPiece.java b/src/main/java/vazkii/psi/client/gui/button/GuiButtonSpellPiece.java index 38e86ff9..2d792c1b 100644 --- a/src/main/java/vazkii/psi/client/gui/button/GuiButtonSpellPiece.java +++ b/src/main/java/vazkii/psi/client/gui/button/GuiButtonSpellPiece.java @@ -12,6 +12,7 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.Tesselator; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.network.chat.Component; @@ -23,33 +24,27 @@ public class GuiButtonSpellPiece extends Button { public SpellPiece piece; final GuiProgrammer gui; - public GuiButtonSpellPiece(GuiProgrammer gui, SpellPiece piece, int x, int y) { - super(x, y, 16, 16, Component.empty(), button -> {}); - this.gui = gui; - this.piece = piece; - } - public GuiButtonSpellPiece(GuiProgrammer gui, SpellPiece piece, int x, int y, Button.OnPress pressable) { - super(x, y, 16, 16, Component.empty(), pressable); + super(x, y, 16, 16, Component.empty(), pressable, DEFAULT_NARRATION); this.gui = gui; this.piece = piece; } @Override - public void renderButton(PoseStack ms, int mouseX, int mouseY, float pTicks) { + public void render(GuiGraphics graphics, int mouseX, int mouseY, float pTicks) { if(active && visible) { - boolean hover = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height; + boolean hover = mouseX >= getX() && mouseY >= getY() && mouseX < getX() + width && mouseY < getY() + height; MultiBufferSource.BufferSource buffers = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder()); - ms.pushPose(); - ms.translate(x, y, 0); - piece.draw(ms, buffers, 0xF000F0); + graphics.pose().pushPose(); + graphics.pose().translate(getX(), getY(), 0); + piece.draw(graphics, buffers, 0xF000F0); buffers.endBatch(); - ms.popPose(); - RenderSystem.setShaderTexture(0, GuiProgrammer.texture); + graphics.pose().popPose(); + if(hover) { piece.getTooltip(gui.tooltip); - blit(ms, x, y, 16, gui.ySize, 16, 16); + graphics.blit(GuiProgrammer.texture, getX(), getY(), 16, gui.ySize, 16, 16); } } diff --git a/src/main/java/vazkii/psi/client/gui/widget/SideConfigWidget.java b/src/main/java/vazkii/psi/client/gui/widget/SideConfigWidget.java index 70bddec2..1275d54a 100644 --- a/src/main/java/vazkii/psi/client/gui/widget/SideConfigWidget.java +++ b/src/main/java/vazkii/psi/client/gui/widget/SideConfigWidget.java @@ -13,6 +13,7 @@ import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.ChatFormatting; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.narration.NarrationElementOutput; @@ -45,15 +46,15 @@ protected boolean isValidClickButton(int p_isValidClickButton_1_) { } @Override - public void renderButton(PoseStack ms, int mouseX, int mouseY, float pTicks) { + public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float pTicks) { SpellPiece piece = null; if(SpellGrid.exists(GuiProgrammer.selectedX, GuiProgrammer.selectedY)) { piece = parent.spell.grid.gridData[GuiProgrammer.selectedX][GuiProgrammer.selectedY]; } if(configEnabled && !parent.takingScreenshot) { - blit(ms, parent.left - 81, parent.top + 55, parent.xSize, 30, 81, 115); + graphics.blit(GuiProgrammer.texture, parent.left - 81, parent.top + 55, parent.xSize, 30, 81, 115); // TODO(Kamefrede): 1.20 check if this is correct String configStr = I18n.get("psimisc.config"); - parent.getMinecraft().font.draw(ms, configStr, parent.left - parent.getMinecraft().font.width(configStr) - 2, parent.top + 45, 0xFFFFFF); + graphics.drawString(this.parent.getMinecraft().font, configStr, parent.left - parent.getMinecraft().font.width(configStr) - 2, parent.top + 45, 0xFFFFFF); int i = 0; if(piece != null) { @@ -68,16 +69,15 @@ public void renderButton(PoseStack ms, int mouseX, int mouseY, float pTicks) { int x = parent.left - 75; int y = parent.top + 70 + i * 26; - RenderSystem.setShaderColor(1F, 1F, 1F, 1F); - RenderSystem.setShaderTexture(0, GuiProgrammer.texture); - blit(ms, x + 50, y - 8, parent.xSize, 145, 24, 24); + graphics.setColor(1F, 1F, 1F, 1F); + graphics.blit(GuiProgrammer.texture, x + 50, y - 8, parent.xSize, 145, 24, 24); String localized = I18n.get(s); if(i == param) { localized = ChatFormatting.UNDERLINE + localized; } - parent.getMinecraft().font.draw(ms, localized, x, y, 0xFFFFFF); + graphics.drawString(this.parent.getMinecraft().font, localized, x, y, 0xFFFFFF); i++; } @@ -86,7 +86,7 @@ public void renderButton(PoseStack ms, int mouseX, int mouseY, float pTicks) { } @Override - public void updateNarration(NarrationElementOutput p_169152_) { - + protected void updateWidgetNarration(NarrationElementOutput pNarrationElementOutput) { + this.defaultButtonNarrationText(pNarrationElementOutput); } } diff --git a/src/main/java/vazkii/psi/client/gui/widget/SpellCostsWidget.java b/src/main/java/vazkii/psi/client/gui/widget/SpellCostsWidget.java index ac0bd58c..b347533a 100644 --- a/src/main/java/vazkii/psi/client/gui/widget/SpellCostsWidget.java +++ b/src/main/java/vazkii/psi/client/gui/widget/SpellCostsWidget.java @@ -12,6 +12,7 @@ import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.ChatFormatting; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.narration.NarrationElementOutput; import net.minecraft.network.chat.Component; @@ -41,7 +42,7 @@ protected boolean isValidClickButton(int p_isValidClickButton_1_) { } @Override - public void renderButton(PoseStack ms, int mouseX, int mouseY, float pTicks) { + public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float pTicks) { parent.compileResult.left().ifPresent(compiledSpell -> { int i = 0; int statX = parent.left + parent.xSize + 3; @@ -67,10 +68,9 @@ public void renderButton(PoseStack ms, int mouseX, int mouseY, float pTicks) { s += "/" + (cadVal == -1 ? "\u221E" : cadVal); } - RenderSystem.setShaderColor(1f, 1f, 1f, 1F); - RenderSystem.setShaderTexture(0, GuiProgrammer.texture); - blit(ms, statX, statY, (stat.ordinal() + 1) * 12, parent.ySize + 16, 12, 12); - parent.getMinecraft().font.draw(ms, s, statX + 16, statY + 2, cadStat != null && cadVal < val && cadVal != -1 ? 0xFF6666 : 0xFFFFFF); + graphics.setColor(1f, 1f, 1f, 1F); + graphics.blit(GuiProgrammer.texture, statX, statY, (stat.ordinal() + 1) * 12, parent.ySize + 16, 12, 12); + graphics.drawString(this.parent.getMinecraft().font, s, statX + 16, statY + 2, cadStat != null && cadVal < val && cadVal != -1 ? 0xFF6666 : 0xFFFFFF); if(mouseX > statX && mouseY > statY && mouseX < statX + 12 && mouseY < statY + 12 && !parent.panelWidget.panelEnabled) { parent.tooltip.add(Component.translatable(stat.getName()).withStyle(Psi.magical ? ChatFormatting.LIGHT_PURPLE : ChatFormatting.AQUA)); @@ -83,7 +83,7 @@ public void renderButton(PoseStack ms, int mouseX, int mouseY, float pTicks) { } @Override - public void updateNarration(NarrationElementOutput p_169152_) { - //TODO Narration? + protected void updateWidgetNarration(NarrationElementOutput pNarrationElementOutput) { + this.defaultButtonNarrationText(pNarrationElementOutput); } } diff --git a/src/main/java/vazkii/psi/client/gui/widget/StatusWidget.java b/src/main/java/vazkii/psi/client/gui/widget/StatusWidget.java index 7ba0dda2..3172267b 100644 --- a/src/main/java/vazkii/psi/client/gui/widget/StatusWidget.java +++ b/src/main/java/vazkii/psi/client/gui/widget/StatusWidget.java @@ -12,6 +12,7 @@ import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.ChatFormatting; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.narration.NarrationElementOutput; import net.minecraft.network.chat.Component; @@ -39,11 +40,10 @@ protected boolean isValidClickButton(int p_isValidClickButton_1_) { } @Override - public void renderButton(PoseStack ms, int mouseX, int mouseY, float pTicks) { - RenderSystem.setShaderColor(1f, 1f, 1f, 1F); - RenderSystem.setShaderTexture(0, GuiProgrammer.texture); - blit(ms, parent.left - 48, parent.top + 5, parent.xSize, 0, 48, 30); - blit(ms, parent.left - 16, parent.top + 13, parent.compileResult.right().isPresent() ? 12 : 0, parent.ySize + 28, 12, 12); + public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float pTicks) { + graphics.setColor(1f, 1f, 1f, 1F); + graphics.blit(GuiProgrammer.texture, parent.left - 48, parent.top + 5, parent.xSize, 0, 48, 30); + graphics.blit(GuiProgrammer.texture, parent.left - 16, parent.top + 13, parent.compileResult.right().isPresent() ? 12 : 0, parent.ySize + 28, 12, 12); if(mouseX > parent.left - 16 - 1 && mouseY > parent.top + 13 - 1 && mouseX < parent.left - 16 + 13 && mouseY < parent.top + 13 + 13) { if(parent.compileResult.right().isPresent()) { @@ -65,7 +65,7 @@ public void renderButton(PoseStack ms, int mouseX, int mouseY, float pTicks) { int cadX = parent.left - 42; int cadY = parent.top + 12; - PsiRenderHelper.transferMsToGl(ms, () -> parent.getMinecraft().getItemRenderer().renderAndDecorateItem(cad, cadX, cadY)); + graphics.renderFakeItem(cad, cadX, cadY); if(mouseX > cadX && mouseY > cadY && mouseX < cadX + 16 && mouseY < cadY + 16) { parent.tooltip.addAll(cad.getTooltipLines(parent.getMinecraft().player, parent.tooltipFlag)); @@ -73,8 +73,9 @@ public void renderButton(PoseStack ms, int mouseX, int mouseY, float pTicks) { } } + @Override - public void updateNarration(NarrationElementOutput p_169152_) { - //TODO Narration? + protected void updateWidgetNarration(NarrationElementOutput pNarrationElementOutput) { + this.defaultButtonNarrationText(pNarrationElementOutput); } } diff --git a/src/main/java/vazkii/psi/client/jei/JEICompat.java b/src/main/java/vazkii/psi/client/jei/JEICompat.java index 57d7b05d..fa0e5a4c 100644 --- a/src/main/java/vazkii/psi/client/jei/JEICompat.java +++ b/src/main/java/vazkii/psi/client/jei/JEICompat.java @@ -25,11 +25,14 @@ import vazkii.psi.common.crafting.ModCraftingRecipes; import vazkii.psi.common.crafting.recipe.BulletToDriveRecipe; import vazkii.psi.common.crafting.recipe.DriveDuplicateRecipe; +import vazkii.psi.common.item.ItemCAD; import vazkii.psi.common.item.base.ModItems; import vazkii.psi.common.lib.LibMisc; import javax.annotation.Nonnull; +import java.util.List; + @JeiPlugin public class JEICompat implements IModPlugin { private static final ResourceLocation UID = new ResourceLocation(LibMisc.MOD_ID, "main"); @@ -60,8 +63,7 @@ public void registerRecipes(IRecipeRegistration registration) { @Override public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) { - NonNullList stacks = NonNullList.create(); - ModItems.cad.fillItemCategory(CreativeModeTab.TAB_SEARCH, stacks); + List stacks = ItemCAD.getCreativeTabItems(); for(ItemStack stack : stacks) { registration.addRecipeCatalyst(stack, TrickCraftingCategory.TYPE); } diff --git a/src/main/java/vazkii/psi/client/jei/crafting/BulletToDriveExtension.java b/src/main/java/vazkii/psi/client/jei/crafting/BulletToDriveExtension.java index 543df2b8..a28f06ff 100644 --- a/src/main/java/vazkii/psi/client/jei/crafting/BulletToDriveExtension.java +++ b/src/main/java/vazkii/psi/client/jei/crafting/BulletToDriveExtension.java @@ -17,11 +17,15 @@ import mezz.jei.api.recipe.IFocusGroup; import mezz.jei.api.recipe.category.extensions.vanilla.crafting.ICraftingCategoryExtension; +import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.resources.language.I18n; import net.minecraft.core.Registry; +import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; +import net.minecraftforge.registries.ForgeRegistries; import vazkii.psi.api.spell.ISpellAcceptor; import vazkii.psi.common.crafting.recipe.BulletToDriveRecipe; @@ -42,7 +46,7 @@ public BulletToDriveExtension(BulletToDriveRecipe recipe) { inputs = ImmutableList.of( ImmutableList.of(new ItemStack(ModItems.spellDrive)), - Registry.ITEM.stream() + ForgeRegistries.ITEMS.getValues().stream() .filter(item -> item instanceof ItemSpellBullet) .map(ItemStack::new) .collect(Collectors.toList())); @@ -64,11 +68,12 @@ public void setRecipe(IRecipeLayoutBuilder builder, ICraftingGridHelper helper, } @Override - public void drawInfo(int recipeWidth, int recipeHeight, PoseStack matrixStack, double mouseX, double mouseY) { - Minecraft.getInstance().font.draw(matrixStack, I18n.get("jei.psi.spell_copy"), 57, 46, 0x808080); + public void drawInfo(int recipeWidth, int recipeHeight, GuiGraphics guiGraphics, double mouseX, double mouseY) { + guiGraphics.renderTooltip(Minecraft.getInstance().font, Component.translatable("jei.psi.spell_copy").withStyle(ChatFormatting.GRAY), 57, 46); // no color sadge 0x808080 //RenderSystem.enableAlphaTest(); // Prevents state leak affecting the shapeless icon } + @Override public ResourceLocation getRegistryName() { return recipe.getId(); diff --git a/src/main/java/vazkii/psi/client/jei/crafting/DriveDuplicateExtension.java b/src/main/java/vazkii/psi/client/jei/crafting/DriveDuplicateExtension.java index 5e09c8a8..3ebda9dc 100644 --- a/src/main/java/vazkii/psi/client/jei/crafting/DriveDuplicateExtension.java +++ b/src/main/java/vazkii/psi/client/jei/crafting/DriveDuplicateExtension.java @@ -20,6 +20,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.resources.language.I18n; +import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; @@ -58,7 +59,7 @@ public ResourceLocation getRegistryName() { @Override public void drawInfo(int recipeWidth, int recipeHeight, GuiGraphics graphics, double mouseX, double mouseY) { - graphics.drawString(this, I18n.get("jei.psi.spell_copy"), 57, 46, 0x808080); + graphics.drawString(Minecraft.getInstance().font, Component.translatable("jei.psi.spell_copy"), 57, 46, 0x808080); //RenderSystem.enableAlphaTest(); // Prevents state leak affecting the shapeless icon } } diff --git a/src/main/java/vazkii/psi/client/jei/tricks/DrawablePiece.java b/src/main/java/vazkii/psi/client/jei/tricks/DrawablePiece.java index 5e3a254c..45880124 100644 --- a/src/main/java/vazkii/psi/client/jei/tricks/DrawablePiece.java +++ b/src/main/java/vazkii/psi/client/jei/tricks/DrawablePiece.java @@ -32,7 +32,7 @@ public void draw(GuiGraphics graphics, int xOffset, int yOffset, int maskTop, in graphics.pose().translate(xOffset, yOffset, 0); MultiBufferSource.BufferSource buffers = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder()); - piece.drawBackground(graphics.pose(), buffers, 0xF000F0); + piece.drawBackground(graphics, buffers, 0xF000F0); buffers.endBatch(); diff --git a/src/main/java/vazkii/psi/client/patchouli/SpellGridComponent.java b/src/main/java/vazkii/psi/client/patchouli/SpellGridComponent.java index 664db0cf..7fa32239 100644 --- a/src/main/java/vazkii/psi/client/patchouli/SpellGridComponent.java +++ b/src/main/java/vazkii/psi/client/patchouli/SpellGridComponent.java @@ -73,7 +73,7 @@ public void render(GuiGraphics graphics, IComponentRenderContext context, float // Pad the spell pieces and draw them graphics.pose().translate(7f, 7f, 0f); MultiBufferSource.BufferSource buffer = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder()); - grid.draw(graphics.pose(), buffer, 0xF000F0); + grid.draw(graphics, buffer, 0xF000F0); buffer.endBatch(); float scaledSize = 18 * scale; diff --git a/src/main/java/vazkii/psi/client/patchouli/SpellPieceComponent.java b/src/main/java/vazkii/psi/client/patchouli/SpellPieceComponent.java index 52b232e6..cffb2164 100644 --- a/src/main/java/vazkii/psi/client/patchouli/SpellPieceComponent.java +++ b/src/main/java/vazkii/psi/client/patchouli/SpellPieceComponent.java @@ -44,7 +44,7 @@ public void render(GuiGraphics graphics, IComponentRenderContext context, float MultiBufferSource.BufferSource buffer = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder()); graphics.pose().pushPose(); graphics.pose().translate(x, y, 0); - piece.draw(graphics.pose(), buffer, 0xF000F0); + piece.draw(graphics, buffer, 0xF000F0); buffer.endBatch(); if(context.isAreaHovered(mouseX, mouseY, x - 1, y - 1, 16, 16)) { diff --git a/src/main/java/vazkii/psi/client/render/entity/RenderSpellCircle.java b/src/main/java/vazkii/psi/client/render/entity/RenderSpellCircle.java index 4c308e5f..b18372f0 100644 --- a/src/main/java/vazkii/psi/client/render/entity/RenderSpellCircle.java +++ b/src/main/java/vazkii/psi/client/render/entity/RenderSpellCircle.java @@ -23,6 +23,7 @@ import net.minecraft.world.item.ItemStack; import org.joml.Matrix4f; +import org.joml.Quaternionf; import org.joml.Vector3f; import vazkii.psi.api.internal.PsiRenderHelper; @@ -82,7 +83,7 @@ public static void renderSpellCircle(float alive, float scale, float horizontalS if(zDir == -1) { ms.mulPose(Axis.XP.rotationDegrees(180)); } else if(zDir != 1) { - ms.mulPose(new Vector3f(-yDir / mag, xDir / mag, 0).rotate((float) (Math.acos(zDir) * 180 / Math.PI))); + ms.mulPose(new Quaternionf().rotateAxis((float) (Math.acos(zDir) * 180 / Math.PI), -yDir / mag, xDir / mag, 0)); //TODO(Kamefrede): 1.20 new Vector3f(-yDir / mag, xDir / mag, 0).rotate((float) (Math.acos(zDir) * 180 / Math.PI) check if this is equivalent } ms.translate(0, 0, 0.1); ms.scale((float) ratio * scale, (float) ratio * scale, (float) ratio); diff --git a/src/main/java/vazkii/psi/client/render/tile/RenderTileProgrammer.java b/src/main/java/vazkii/psi/client/render/tile/RenderTileProgrammer.java index ccbb1d5b..f421d4fe 100644 --- a/src/main/java/vazkii/psi/client/render/tile/RenderTileProgrammer.java +++ b/src/main/java/vazkii/psi/client/render/tile/RenderTileProgrammer.java @@ -9,11 +9,13 @@ package vazkii.psi.client.render.tile; import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.Tesselator; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Axis; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -76,7 +78,8 @@ public void render(TileProgrammer te, float partialticks, PoseStack ms, MultiBuf ms.translate(70F, 0F, -200F); } - te.spell.draw(ms, buffers, light); + GuiGraphics guigraphics = new GuiGraphics(Minecraft.getInstance(), MultiBufferSource.immediate(Tesselator.getInstance().getBuilder())); // TODO(Kamefrede): 1.20 check if this is correct + te.spell.draw(guigraphics, buffers, light); ms.pushPose(); ms.translate(0F, 0F, -0.01F); diff --git a/src/main/java/vazkii/psi/common/block/tile/container/slot/SlotCADOutput.java b/src/main/java/vazkii/psi/common/block/tile/container/slot/SlotCADOutput.java index 9c1abfa6..13f6e83d 100644 --- a/src/main/java/vazkii/psi/common/block/tile/container/slot/SlotCADOutput.java +++ b/src/main/java/vazkii/psi/common/block/tile/container/slot/SlotCADOutput.java @@ -49,11 +49,11 @@ public boolean mayPickup(Player playerIn) { if(MinecraftForge.EVENT_BUS.post(event)) { BlockPos assemblerPos = this.assembler.getBlockPos(); String cancelMessage = event.getCancellationMessage(); - if(!playerIn.level.isClientSide) { + if(!playerIn.level().isClientSide) { if(cancelMessage != null && !cancelMessage.isEmpty()) { playerIn.sendSystemMessage(Component.translatable(cancelMessage).setStyle(Style.EMPTY.withColor(ChatFormatting.RED))); } - playerIn.level.playSound(null, assemblerPos.getX(), assemblerPos.getY(), assemblerPos.getZ(), PsiSoundHandler.compileError, SoundSource.BLOCKS, sound, 1F); + playerIn.level().playSound(null, assemblerPos.getX(), assemblerPos.getY(), assemblerPos.getZ(), PsiSoundHandler.compileError, SoundSource.BLOCKS, sound, 1F); } return false; } diff --git a/src/main/java/vazkii/psi/common/core/PsiCreativeTab.java b/src/main/java/vazkii/psi/common/core/PsiCreativeTab.java index 2d43a106..26d269a0 100644 --- a/src/main/java/vazkii/psi/common/core/PsiCreativeTab.java +++ b/src/main/java/vazkii/psi/common/core/PsiCreativeTab.java @@ -8,36 +8,37 @@ */ package vazkii.psi.common.core; -import net.minecraft.core.NonNullList; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.ItemStack; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.registries.RegisterEvent; +import vazkii.psi.common.item.ItemCAD; import vazkii.psi.common.item.base.ModItems; import vazkii.psi.common.lib.LibMisc; import vazkii.psi.common.lib.LibResources; -import javax.annotation.Nonnull; - -public class PsiCreativeTab extends CreativeModeTab { - - public static final PsiCreativeTab INSTANCE = new PsiCreativeTab(); - private NonNullList list; - - public PsiCreativeTab() { - super(LibMisc.MOD_ID); - hideTitle(); - setBackgroundSuffix(LibResources.GUI_CREATIVE); - } - - @Nonnull - @Override - public ItemStack makeIcon() { - return new ItemStack(ModItems.cadAssemblyIron); - } - - @Override - public boolean hasSearchBar() { - return true; +@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) +public class PsiCreativeTab { + + public static final ResourceKey PSI_CREATIVE_TAB = ResourceKey.create(Registries.CREATIVE_MODE_TAB, new ResourceLocation(LibMisc.MOD_ID, "creative_tab")); + @SubscribeEvent + public static void register(RegisterEvent evt) { + evt.register(Registries.CREATIVE_MODE_TAB, creativeModeTabRegisterHelper -> { + CreativeModeTab psiCreativeTab = CreativeModeTab.builder() + .icon(() -> new ItemStack(ModItems.cadAssemblyIron)) + .displayItems((parameters, output) -> { + output.acceptAll(ItemCAD.getCreativeTabItems()); + }) + .hideTitle() + .withBackgroundLocation(new ResourceLocation(LibMisc.MOD_ID, LibResources.GUI_CREATIVE)) + .build(); + creativeModeTabRegisterHelper.register(PSI_CREATIVE_TAB, psiCreativeTab); + }); } } diff --git a/src/main/java/vazkii/psi/common/core/capability/CapabilityTriggerSensor.java b/src/main/java/vazkii/psi/common/core/capability/CapabilityTriggerSensor.java index 19d4c4bb..d9646f33 100644 --- a/src/main/java/vazkii/psi/common/core/capability/CapabilityTriggerSensor.java +++ b/src/main/java/vazkii/psi/common/core/capability/CapabilityTriggerSensor.java @@ -43,7 +43,7 @@ public LazyOptional getCapability(@Nonnull Capability capability, @Nul public void detonate() { CompoundTag playerData = player.getPersistentData(); long detonated = playerData.getLong(TRIGGER_TICK); - long worldTime = player.level.getGameTime(); + long worldTime = player.level().getGameTime(); if(detonated != worldTime) { playerData.putLong(TRIGGER_TICK, worldTime); diff --git a/src/main/java/vazkii/psi/common/core/handler/AdditiveMotionHandler.java b/src/main/java/vazkii/psi/common/core/handler/AdditiveMotionHandler.java index 89f5649e..3d4c9034 100644 --- a/src/main/java/vazkii/psi/common/core/handler/AdditiveMotionHandler.java +++ b/src/main/java/vazkii/psi/common/core/handler/AdditiveMotionHandler.java @@ -32,7 +32,7 @@ public static void addMotion(Entity entity, double x, double y, double z) { if(x == 0 && y == 0 && z == 0) { return; } - if(!entity.level.isClientSide) { + if(!entity.level().isClientSide) { Vec3 base = toUpdate.getOrDefault(entity, Vec3.ZERO); toUpdate.put(entity, base.add(x, y, z)); } @@ -53,7 +53,7 @@ public static void onPlayerTick(TickEvent.LevelTickEvent e) { } else { entity.push(vec.x, vec.y, vec.z); } - if(entity.level instanceof ServerLevel) { + if(entity.level() instanceof ServerLevel) { MessageRegister.HANDLER.send(PacketDistributor.TRACKING_ENTITY.with(() -> entity), motion); } diff --git a/src/main/java/vazkii/psi/common/core/handler/InternalMethodHandler.java b/src/main/java/vazkii/psi/common/core/handler/InternalMethodHandler.java index 7c255d83..3b6b81d4 100644 --- a/src/main/java/vazkii/psi/common/core/handler/InternalMethodHandler.java +++ b/src/main/java/vazkii/psi/common/core/handler/InternalMethodHandler.java @@ -12,6 +12,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.renderer.RenderType; import net.minecraft.network.chat.Component; @@ -66,7 +67,7 @@ public ISpellCache getSpellCache() { @Override public void delayContext(SpellContext context) { - if(!context.caster.level.isClientSide) { + if(!context.caster.level().isClientSide) { PlayerDataHandler.delayedContexts.add(context); } } @@ -78,12 +79,12 @@ public void setCrashData(CompiledSpell spell, SpellPiece piece) { @Override @OnlyIn(Dist.CLIENT) - public void renderTooltip(PoseStack ms, int x, int y, List tooltipData, int color, int color2, int width, int height) { + public void renderTooltip(GuiGraphics graphics, int x, int y, List tooltipData, int color, int color2, int width, int height) { if(!tooltipData.isEmpty()) { Font fontRenderer = Minecraft.getInstance().font; Screen screen = Minecraft.getInstance().screen; assert screen != null; - screen.renderTooltip(ms, tooltipData, java.util.Optional.empty(), x, y, fontRenderer);//TODO Fix color/color2? Is it needed? + graphics.renderTooltip( fontRenderer,tooltipData, java.util.Optional.empty(), x, y);//TODO Fix color/color2? Is it needed? //GuiUtils.drawHoveringText(ms, tooltipData, x, y, width, height, -1, color2, color, color, fontRenderer); } } diff --git a/src/main/java/vazkii/psi/common/core/handler/PsiSoundHandler.java b/src/main/java/vazkii/psi/common/core/handler/PsiSoundHandler.java index 58f3f7d2..e0a32ca9 100644 --- a/src/main/java/vazkii/psi/common/core/handler/PsiSoundHandler.java +++ b/src/main/java/vazkii/psi/common/core/handler/PsiSoundHandler.java @@ -20,15 +20,15 @@ @Mod.EventBusSubscriber(modid = LibMisc.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) public final class PsiSoundHandler { - public static final SoundEvent bulletCreate = new SoundEvent(new ResourceLocation(LibMisc.MOD_ID, "bullet_create")); - public static final SoundEvent cadCreate = new SoundEvent(new ResourceLocation(LibMisc.MOD_ID, "cad_create")); - public static final SoundEvent cadShoot = new SoundEvent(new ResourceLocation(LibMisc.MOD_ID, "cad_shoot")); - public static final SoundEvent compileError = new SoundEvent(new ResourceLocation(LibMisc.MOD_ID, "compile_error")); - public static final SoundEvent levelUp = new SoundEvent(new ResourceLocation(LibMisc.MOD_ID, "level_up")); - public static final SoundEvent loopcast = new SoundEvent(new ResourceLocation(LibMisc.MOD_ID, "loopcast")); - public static final SoundEvent book = new SoundEvent(new ResourceLocation(LibMisc.MOD_ID, "book")); - public static final SoundEvent bookFlip = new SoundEvent(new ResourceLocation(LibMisc.MOD_ID, "book_flip")); - public static final SoundEvent bookOpen = new SoundEvent(new ResourceLocation(LibMisc.MOD_ID, "book_open")); + public static final SoundEvent bulletCreate = SoundEvent.createVariableRangeEvent(new ResourceLocation(LibMisc.MOD_ID, "bullet_create")); + public static final SoundEvent cadCreate = SoundEvent.createVariableRangeEvent(new ResourceLocation(LibMisc.MOD_ID, "cad_create")); + public static final SoundEvent cadShoot = SoundEvent.createVariableRangeEvent(new ResourceLocation(LibMisc.MOD_ID, "cad_shoot")); + public static final SoundEvent compileError = SoundEvent.createVariableRangeEvent(new ResourceLocation(LibMisc.MOD_ID, "compile_error")); + public static final SoundEvent levelUp = SoundEvent.createVariableRangeEvent(new ResourceLocation(LibMisc.MOD_ID, "level_up")); + public static final SoundEvent loopcast = SoundEvent.createVariableRangeEvent(new ResourceLocation(LibMisc.MOD_ID, "loopcast")); + public static final SoundEvent book = SoundEvent.createVariableRangeEvent(new ResourceLocation(LibMisc.MOD_ID, "book")); + public static final SoundEvent bookFlip = SoundEvent.createVariableRangeEvent(new ResourceLocation(LibMisc.MOD_ID, "book_flip")); + public static final SoundEvent bookOpen = SoundEvent.createVariableRangeEvent(new ResourceLocation(LibMisc.MOD_ID, "book_open")); @SubscribeEvent public static void registerSounds(RegisterEvent evt) { diff --git a/src/main/java/vazkii/psi/common/crafting/recipe/BulletUpgradeRecipe.java b/src/main/java/vazkii/psi/common/crafting/recipe/BulletUpgradeRecipe.java index 14f97655..4d0f4133 100644 --- a/src/main/java/vazkii/psi/common/crafting/recipe/BulletUpgradeRecipe.java +++ b/src/main/java/vazkii/psi/common/crafting/recipe/BulletUpgradeRecipe.java @@ -11,10 +11,12 @@ import com.google.gson.JsonObject; import net.minecraft.core.NonNullList; +import net.minecraft.core.RegistryAccess; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.inventory.CraftingContainer; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.CraftingBookCategory; import net.minecraft.world.item.crafting.CraftingRecipe; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.RecipeSerializer; @@ -38,8 +40,8 @@ public boolean matches(CraftingContainer inv, Level worldIn) { } @Override - public ItemStack assemble(CraftingContainer inv) { - ItemStack output = compose.assemble(inv); + public ItemStack assemble(CraftingContainer inv, RegistryAccess access) { + ItemStack output = compose.assemble(inv, access); for(int i = 0; i < inv.getContainerSize(); i++) { ItemStack stack = inv.getItem(i); if(stack.getItem() instanceof ItemSpellBullet) { @@ -55,8 +57,8 @@ public boolean canCraftInDimensions(int width, int height) { } @Override - public ItemStack getResultItem() { - return compose.getResultItem(); + public ItemStack getResultItem(RegistryAccess access) { + return compose.getResultItem(access); } @Override @@ -94,6 +96,11 @@ public RecipeSerializer getSerializer() { return SERIALIZER; } + @Override + public CraftingBookCategory category() { + return CraftingBookCategory.MISC; + } + private static class Serializer implements RecipeSerializer { @Override public BulletUpgradeRecipe fromJson(ResourceLocation recipeId, JsonObject json) { diff --git a/src/main/java/vazkii/psi/common/crafting/recipe/DimensionTrickRecipe.java b/src/main/java/vazkii/psi/common/crafting/recipe/DimensionTrickRecipe.java index badbf297..c3bf5bb7 100644 --- a/src/main/java/vazkii/psi/common/crafting/recipe/DimensionTrickRecipe.java +++ b/src/main/java/vazkii/psi/common/crafting/recipe/DimensionTrickRecipe.java @@ -11,6 +11,8 @@ import com.google.gson.JsonObject; import net.minecraft.core.Registry; +import net.minecraft.core.RegistryAccess; +import net.minecraft.core.registries.Registries; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; @@ -35,7 +37,7 @@ public DimensionTrickRecipe(ResourceLocation id, @Nullable PieceCraftingTrick pi } public DimensionTrickRecipe(ResourceLocation id, @Nullable PieceCraftingTrick piece, Ingredient input, ItemStack output, ItemStack cad, ResourceLocation dimensionKey) { - this(id, piece, input, output, cad, ResourceKey.create(Registry.DIMENSION_REGISTRY, dimensionKey)); + this(id, piece, input, output, cad, ResourceKey.create(Registries.DIMENSION, dimensionKey)); } @Override @@ -48,7 +50,7 @@ public static class Serializer implements RecipeSerializer public DimensionTrickRecipe fromJson(ResourceLocation id, JsonObject json) { TrickRecipe recipe = TrickRecipe.SERIALIZER.fromJson(id, json); ResourceLocation dimensionId = new ResourceLocation(GsonHelper.getAsString(json, "dimension")); - return new DimensionTrickRecipe(id, recipe.getPiece(), recipe.getInput(), recipe.getResultItem(), recipe.getAssembly(), dimensionId); + return new DimensionTrickRecipe(id, recipe.getPiece(), recipe.getInput(), recipe.getResultItem(RegistryAccess.EMPTY), recipe.getAssembly(), dimensionId); } @Nullable @@ -56,7 +58,7 @@ public DimensionTrickRecipe fromJson(ResourceLocation id, JsonObject json) { public DimensionTrickRecipe fromNetwork(ResourceLocation id, FriendlyByteBuf buf) { TrickRecipe recipe = TrickRecipe.SERIALIZER.fromNetwork(id, buf); ResourceLocation dimensionId = buf.readResourceLocation(); - return new DimensionTrickRecipe(id, recipe.getPiece(), recipe.getInput(), recipe.getResultItem(), recipe.getAssembly(), dimensionId); + return new DimensionTrickRecipe(id, recipe.getPiece(), recipe.getInput(), recipe.getResultItem(RegistryAccess.EMPTY), recipe.getAssembly(), dimensionId); } @Override diff --git a/src/main/java/vazkii/psi/common/crafting/recipe/TrickRecipe.java b/src/main/java/vazkii/psi/common/crafting/recipe/TrickRecipe.java index 3af6f995..2df53b37 100644 --- a/src/main/java/vazkii/psi/common/crafting/recipe/TrickRecipe.java +++ b/src/main/java/vazkii/psi/common/crafting/recipe/TrickRecipe.java @@ -10,6 +10,7 @@ import com.google.gson.JsonObject; +import net.minecraft.core.RegistryAccess; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.GsonHelper; @@ -62,7 +63,7 @@ public Ingredient getInput() { } @Override - public ItemStack getResultItem() { + public ItemStack getResultItem(RegistryAccess access) { return output; } @@ -77,8 +78,8 @@ public boolean matches(RecipeWrapper inv, Level world) { } @Override - public ItemStack assemble(RecipeWrapper inv) { - return getResultItem(); + public ItemStack assemble(RecipeWrapper inv, RegistryAccess access) { + return getResultItem(access); } @Override diff --git a/src/main/java/vazkii/psi/common/entity/EntitySpellProjectile.java b/src/main/java/vazkii/psi/common/entity/EntitySpellProjectile.java index 458d6a58..4b6fcdce 100755 --- a/src/main/java/vazkii/psi/common/entity/EntitySpellProjectile.java +++ b/src/main/java/vazkii/psi/common/entity/EntitySpellProjectile.java @@ -10,6 +10,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.network.protocol.Packet; +import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; @@ -185,7 +186,7 @@ public void tick() { look.normalize().multiply(dist); - if(level.isClientSide()) { + if(level().isClientSide()) { Psi.proxy.sparkleFX(x, y, z, r, g, b, (float) look.x, (float) look.y, (float) look.z, 1.2F, 12); } @@ -265,7 +266,7 @@ public LivingEntity getAttackTarget() { return entityData.get(ATTACKTARGET_UUID) .map(u -> { List a = getCommandSenderWorld().getEntitiesOfClass(LivingEntity.class, axis, (Entity e) -> e.getUUID().equals(u)); - if(a.size() > 0) { + if(!a.isEmpty()) { return a.get(0); } return null; @@ -285,7 +286,7 @@ public boolean isIgnoringBlockTriggers() { @Nonnull @Override - public Packet getAddEntityPacket() { + public Packet getAddEntityPacket() { return NetworkHooks.getEntitySpawningPacket(this); } } diff --git a/src/main/java/vazkii/psi/common/item/ItemCAD.java b/src/main/java/vazkii/psi/common/item/ItemCAD.java index f81f7ff8..1edc9003 100644 --- a/src/main/java/vazkii/psi/common/item/ItemCAD.java +++ b/src/main/java/vazkii/psi/common/item/ItemCAD.java @@ -11,6 +11,7 @@ import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; import net.minecraft.core.NonNullList; +import net.minecraft.core.RegistryAccess; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.Tag; import net.minecraft.network.chat.Component; @@ -317,7 +318,7 @@ public static Optional> cast(Level world, Player player, Playe @Override public boolean craft(ItemStack cad, Player player, PieceCraftingTrick craftingTrick) { - Level world = player.level; + Level world = player.level(); if(world.isClientSide) { return false; } @@ -339,7 +340,7 @@ public boolean craft(ItemStack cad, Player player, PieceCraftingTrick craftingTr Optional recipe = world.getRecipeManager().getRecipeFor(ModCraftingRecipes.TRICK_RECIPE_TYPE, inv, world) .filter(predicate); if(recipe.isPresent()) { - ItemStack outCopy = recipe.get().getResultItem().copy(); + ItemStack outCopy = recipe.get().getResultItem(RegistryAccess.EMPTY).copy(); int count = stack.getCount() * outCopy.getCount(); while(count > 64) { int dropCount = world.getRandom().nextInt(32) + 32; @@ -572,11 +573,8 @@ public boolean isCorrectToolForDrops(ItemStack stack, @Nonnull BlockState state) return false; } - @Override - public void fillItemCategory(@Nonnull CreativeModeTab tab, @Nonnull NonNullList subItems) { - if(!allowedIn(tab)) { - return; - } + public static List getCreativeTabItems() { + List subItems = new ArrayList<>(); // Basic Iron CAD subItems.add(makeCAD(new ItemStack(ModItems.cadAssemblyIron))); @@ -617,6 +615,7 @@ public void fillItemCategory(@Nonnull CreativeModeTab tab, @Nonnull NonNullList< new ItemStack(ModItems.cadSocketTransmissive), new ItemStack(ModItems.cadBatteryUltradense))); + return subItems; } @OnlyIn(Dist.CLIENT) @@ -657,7 +656,7 @@ public Rarity getRarity(ItemStack stack) { @Override public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) { - return !oldStack.sameItem(newStack); + return !ItemStack.isSameItem(oldStack, newStack); } } diff --git a/src/main/java/vazkii/psi/common/item/ItemDetonator.java b/src/main/java/vazkii/psi/common/item/ItemDetonator.java index 254a4cc8..4932027f 100644 --- a/src/main/java/vazkii/psi/common/item/ItemDetonator.java +++ b/src/main/java/vazkii/psi/common/item/ItemDetonator.java @@ -35,7 +35,7 @@ public InteractionResultHolder use(Level worldIn, Player playerIn, @N if(!worldIn.isClientSide) { IDetonationHandler.performDetonation(worldIn, playerIn); - worldIn.playSound(null, playerIn.getX(), playerIn.getY(), playerIn.getZ(), SoundEvents.UI_BUTTON_CLICK, SoundSource.PLAYERS, 1F, 1F); + worldIn.playSound(null, playerIn.getX(), playerIn.getY(), playerIn.getZ(), SoundEvents.UI_BUTTON_CLICK.value(), SoundSource.PLAYERS, 1F, 1F); } else { diff --git a/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalArmor.java b/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalArmor.java index 885eb9a5..c3a10ae7 100644 --- a/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalArmor.java +++ b/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalArmor.java @@ -59,13 +59,13 @@ public class ItemPsimetalArmor extends ArmorItem implements IPsimetalTool, IPsiE private static final String TAG_TIMES_CAST = "timesCast"; - public ItemPsimetalArmor(EquipmentSlot type, Properties props) { + public ItemPsimetalArmor(ArmorItem.Type type, Properties props) { this(type, PsiAPI.PSIMETAL_ARMOR_MATERIAL, props); } - public ItemPsimetalArmor(EquipmentSlot type, ArmorMaterial mat, Properties props) { + public ItemPsimetalArmor(ArmorItem.Type type, ArmorMaterial mat, Properties props) { super(mat, type, props); - this.type = type; + this.type = type.getSlot(); /*this.model = DistExecutor.runForDist(() -> () -> new LazyLoadedValue<>(() -> this.provideArmorModelForSlot(type)), () -> () -> null);*/ } diff --git a/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalExosuitBoots.java b/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalExosuitBoots.java index 51a34c59..800c0007 100644 --- a/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalExosuitBoots.java +++ b/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalExosuitBoots.java @@ -9,6 +9,7 @@ package vazkii.psi.common.item.armor; import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -16,8 +17,8 @@ public class ItemPsimetalExosuitBoots extends ItemPsimetalArmor { - public ItemPsimetalExosuitBoots(EquipmentSlot slotType, Item.Properties properties) { - super(slotType, properties); + public ItemPsimetalExosuitBoots(ArmorItem.Type type, Item.Properties properties) { + super(type, properties); } @Override diff --git a/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalExosuitChestplate.java b/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalExosuitChestplate.java index 0d331473..a3aba101 100644 --- a/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalExosuitChestplate.java +++ b/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalExosuitChestplate.java @@ -8,7 +8,7 @@ */ package vazkii.psi.common.item.armor; -import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -16,8 +16,8 @@ public class ItemPsimetalExosuitChestplate extends ItemPsimetalArmor { - public ItemPsimetalExosuitChestplate(EquipmentSlot slotType, Item.Properties properties) { - super(slotType, properties); + public ItemPsimetalExosuitChestplate(ArmorItem.Type type, Item.Properties properties) { + super(type, properties); } @Override diff --git a/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalExosuitHelmet.java b/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalExosuitHelmet.java index 71cde010..53f5f819 100644 --- a/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalExosuitHelmet.java +++ b/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalExosuitHelmet.java @@ -11,6 +11,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.DyeableLeatherItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -27,8 +28,8 @@ public class ItemPsimetalExosuitHelmet extends ItemPsimetalArmor implements ISen private static final String TAG_SENSOR = "sensor"; - public ItemPsimetalExosuitHelmet(EquipmentSlot slotType, Item.Properties properties) { - super(slotType, properties); + public ItemPsimetalExosuitHelmet(ArmorItem.Type type, Item.Properties properties) { + super(type, properties); } @Override diff --git a/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalExosuitLeggings.java b/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalExosuitLeggings.java index 3d37d84e..e2a32325 100644 --- a/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalExosuitLeggings.java +++ b/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalExosuitLeggings.java @@ -9,6 +9,7 @@ package vazkii.psi.common.item.armor; import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -16,8 +17,8 @@ public class ItemPsimetalExosuitLeggings extends ItemPsimetalArmor { - public ItemPsimetalExosuitLeggings(EquipmentSlot slotType, Item.Properties properties) { - super(slotType, properties); + public ItemPsimetalExosuitLeggings(ArmorItem.Type type, Item.Properties properties) { + super(type, properties); } @Override diff --git a/src/main/java/vazkii/psi/common/item/base/ModItems.java b/src/main/java/vazkii/psi/common/item/base/ModItems.java index 03731a69..0b1b93a8 100644 --- a/src/main/java/vazkii/psi/common/item/base/ModItems.java +++ b/src/main/java/vazkii/psi/common/item/base/ModItems.java @@ -10,6 +10,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.DyeColor; import net.minecraft.world.item.Item; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -200,10 +201,10 @@ public static void register(RegisterEvent evt) { psimetalPickaxe = new ItemPsimetalPickaxe(defaultBuilder()); psimetalAxe = new ItemPsimetalAxe(defaultBuilder()); psimetalSword = new ItemPsimetalSword(defaultBuilder()); - psimetalExosuitHelmet = new ItemPsimetalExosuitHelmet(EquipmentSlot.HEAD, defaultBuilder()); - psimetalExosuitChestplate = new ItemPsimetalExosuitChestplate(EquipmentSlot.CHEST, defaultBuilder()); - psimetalExosuitLeggings = new ItemPsimetalExosuitLeggings(EquipmentSlot.LEGS, defaultBuilder()); - psimetalExosuitBoots = new ItemPsimetalExosuitBoots(EquipmentSlot.FEET, defaultBuilder()); + psimetalExosuitHelmet = new ItemPsimetalExosuitHelmet(ArmorItem.Type.HELMET, defaultBuilder()); + psimetalExosuitChestplate = new ItemPsimetalExosuitChestplate(ArmorItem.Type.CHESTPLATE, defaultBuilder()); + psimetalExosuitLeggings = new ItemPsimetalExosuitLeggings(ArmorItem.Type.LEGGINGS, defaultBuilder()); + psimetalExosuitBoots = new ItemPsimetalExosuitBoots(ArmorItem.Type.BOOTS, defaultBuilder()); ModSpellPieces.init(); @@ -293,7 +294,7 @@ public static void register(RegisterEvent evt) { } public static Item.Properties defaultBuilder() { - return new Item.Properties().tab(PsiCreativeTab.INSTANCE); + return new Item.Properties(); // TODO(Kamefrede): 1.20 add to tab } } diff --git a/src/main/java/vazkii/psi/common/item/tool/IPsimetalTool.java b/src/main/java/vazkii/psi/common/item/tool/IPsimetalTool.java index 417751cd..462f520e 100644 --- a/src/main/java/vazkii/psi/common/item/tool/IPsimetalTool.java +++ b/src/main/java/vazkii/psi/common/item/tool/IPsimetalTool.java @@ -51,7 +51,7 @@ default void castOnBlockBreak(ItemStack itemstack, Player player) { ItemStack bullet = sockets.getSelectedBullet(); ItemCAD.cast(player.getCommandSenderWorld(), player, data, bullet, playerCad, 5, 10, 0.05F, (SpellContext context) -> { context.tool = itemstack; - context.positionBroken = raytraceFromEntity(player.getCommandSenderWorld(), player, ClipContext.Fluid.NONE, player.getAttributes().getValue(ForgeMod.REACH_DISTANCE.get())); + context.positionBroken = raytraceFromEntity(player.getCommandSenderWorld(), player, ClipContext.Fluid.NONE, player.getAttributes().getValue(ForgeMod.BLOCK_REACH.get())); }); } } diff --git a/src/main/java/vazkii/psi/common/network/message/MessageLoopcastSync.java b/src/main/java/vazkii/psi/common/network/message/MessageLoopcastSync.java index b29d384b..7558e635 100644 --- a/src/main/java/vazkii/psi/common/network/message/MessageLoopcastSync.java +++ b/src/main/java/vazkii/psi/common/network/message/MessageLoopcastSync.java @@ -50,7 +50,7 @@ public boolean receive(Supplier context) { if(mcPlayer == null) { return; } - Level world = mcPlayer.level; + Level world = mcPlayer.level(); Entity player = null; if(world != null) { diff --git a/src/main/java/vazkii/psi/common/network/message/MessageSpellModified.java b/src/main/java/vazkii/psi/common/network/message/MessageSpellModified.java index bddc983c..c2251cfc 100644 --- a/src/main/java/vazkii/psi/common/network/message/MessageSpellModified.java +++ b/src/main/java/vazkii/psi/common/network/message/MessageSpellModified.java @@ -56,7 +56,7 @@ public void encode(FriendlyByteBuf buf) { public void receive(Supplier context) { context.get().enqueueWork(() -> { - BlockEntity te = context.get().getSender().level.getBlockEntity(pos); + BlockEntity te = context.get().getSender().level().getBlockEntity(pos); if(te instanceof TileProgrammer) { TileProgrammer tile = (TileProgrammer) te; if(tile.playerLock == null || tile.playerLock.isEmpty() || tile.playerLock.equals(context.get().getSender().getName().getString())) { diff --git a/src/main/java/vazkii/psi/common/spell/constant/PieceConstantNumber.java b/src/main/java/vazkii/psi/common/spell/constant/PieceConstantNumber.java index aec75326..68796a67 100644 --- a/src/main/java/vazkii/psi/common/spell/constant/PieceConstantNumber.java +++ b/src/main/java/vazkii/psi/common/spell/constant/PieceConstantNumber.java @@ -11,6 +11,7 @@ import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.nbt.CompoundTag; @@ -40,7 +41,7 @@ public void initParams() { } @Override - public void drawAdditional(PoseStack ms, MultiBufferSource buffers, int light) { + public void drawAdditional(GuiGraphics graphics, MultiBufferSource buffers, int light) { if(valueStr == null || valueStr.isEmpty() || valueStr.length() > 5) { valueStr = "0"; } @@ -55,11 +56,11 @@ public void drawAdditional(PoseStack ms, MultiBufferSource buffers, int light) { efflen = mc.font.width(valueStr) / scale; } - ms.pushPose(); - ms.scale(1F / scale, 1F / scale, 1F); - ms.translate((9 - efflen / 2) * scale, 4 * scale, 0); - mc.font.drawInBatch(valueStr, 0, 0, color, false, ms.last().pose(), buffers, false, 0, light); - ms.popPose(); + graphics.pose().pushPose(); + graphics.pose().scale(1F / scale, 1F / scale, 1F); + graphics.pose().translate((9 - efflen / 2) * scale, 4 * scale, 0); + graphics.drawString(mc.font, valueStr, 0, 0, color, false); // TODO(Kamefrede): 1.20 check if this is ruight + graphics.pose().popPose(); } @Override diff --git a/src/main/java/vazkii/psi/common/spell/operator/block/PieceOperatorBlockComparatorStrength.java b/src/main/java/vazkii/psi/common/spell/operator/block/PieceOperatorBlockComparatorStrength.java index 21390385..53094a7e 100644 --- a/src/main/java/vazkii/psi/common/spell/operator/block/PieceOperatorBlockComparatorStrength.java +++ b/src/main/java/vazkii/psi/common/spell/operator/block/PieceOperatorBlockComparatorStrength.java @@ -51,7 +51,7 @@ public Object execute(SpellContext context) throws SpellRuntimeException { BlockState state = Blocks.COMPARATOR.defaultBlockState() .setValue(HorizontalDirectionalBlock.FACING, whichWay.getOpposite()); - return ((ComparatorBlock) Blocks.COMPARATOR).getInputSignal(context.focalPoint.level, pos.relative(whichWay), state) * 1.0; + return ((ComparatorBlock) Blocks.COMPARATOR).getInputSignal(context.focalPoint.level(), pos.relative(whichWay), state) * 1.0; } @Override diff --git a/src/main/java/vazkii/psi/common/spell/operator/block/PieceOperatorBlockHardness.java b/src/main/java/vazkii/psi/common/spell/operator/block/PieceOperatorBlockHardness.java index 82c8fed6..51ca6dea 100644 --- a/src/main/java/vazkii/psi/common/spell/operator/block/PieceOperatorBlockHardness.java +++ b/src/main/java/vazkii/psi/common/spell/operator/block/PieceOperatorBlockHardness.java @@ -35,8 +35,8 @@ public void initParams() { @Override public Object execute(SpellContext context) throws SpellRuntimeException { BlockPos pos = SpellHelpers.getBlockPos(this, context, target, false, false); - BlockState state = context.focalPoint.level.getBlockState(pos); - return state.getDestroySpeed(context.focalPoint.level, pos) * 1.0D; + BlockState state = context.focalPoint.level().getBlockState(pos); + return state.getDestroySpeed(context.focalPoint.level(), pos) * 1.0D; } @Override diff --git a/src/main/java/vazkii/psi/common/spell/operator/block/PieceOperatorBlockLightLevel.java b/src/main/java/vazkii/psi/common/spell/operator/block/PieceOperatorBlockLightLevel.java index a9baaf90..8c98e8ae 100644 --- a/src/main/java/vazkii/psi/common/spell/operator/block/PieceOperatorBlockLightLevel.java +++ b/src/main/java/vazkii/psi/common/spell/operator/block/PieceOperatorBlockLightLevel.java @@ -35,7 +35,7 @@ public void initParams() { @Override public Object execute(SpellContext context) throws SpellRuntimeException { BlockPos pos = SpellHelpers.getBlockPos(this, context, target, false, false); - int j = context.focalPoint.level.getMaxLocalRawBrightness(pos); + int j = context.focalPoint.level().getMaxLocalRawBrightness(pos); return j * 1.0; } diff --git a/src/main/java/vazkii/psi/common/spell/operator/block/PieceOperatorBlockMiningLevel.java b/src/main/java/vazkii/psi/common/spell/operator/block/PieceOperatorBlockMiningLevel.java index 28b27fff..c51d8e84 100644 --- a/src/main/java/vazkii/psi/common/spell/operator/block/PieceOperatorBlockMiningLevel.java +++ b/src/main/java/vazkii/psi/common/spell/operator/block/PieceOperatorBlockMiningLevel.java @@ -37,7 +37,7 @@ public void initParams() { @Override public Object execute(SpellContext context) throws SpellRuntimeException { BlockPos pos = SpellHelpers.getBlockPos(this, context, position, false, false); - BlockState state = context.focalPoint.level.getBlockState(pos); + BlockState state = context.focalPoint.level().getBlockState(pos); //TODO Fix low mining level items returning 1 return PieceTrickBreakBlock.getHarvestLevel(state); diff --git a/src/main/java/vazkii/psi/common/spell/operator/block/PieceOperatorBlockSideSolidity.java b/src/main/java/vazkii/psi/common/spell/operator/block/PieceOperatorBlockSideSolidity.java index d4e47189..86e682f1 100644 --- a/src/main/java/vazkii/psi/common/spell/operator/block/PieceOperatorBlockSideSolidity.java +++ b/src/main/java/vazkii/psi/common/spell/operator/block/PieceOperatorBlockSideSolidity.java @@ -40,8 +40,8 @@ public Object execute(SpellContext context) throws SpellRuntimeException { BlockPos pos = SpellHelpers.getBlockPos(this, context, target, false, false); Direction facing = SpellHelpers.getFacing(this, context, axisParam); - BlockState state = context.focalPoint.level.getBlockState(pos); - return state.isFaceSturdy(context.focalPoint.level, pos, facing) ? 1.0D : 0.D; + BlockState state = context.focalPoint.level().getBlockState(pos); + return state.isFaceSturdy(context.focalPoint.level(), pos, facing) ? 1.0D : 0.D; } @Override diff --git a/src/main/java/vazkii/psi/common/spell/operator/entity/PieceOperatorEntityRaycast.java b/src/main/java/vazkii/psi/common/spell/operator/entity/PieceOperatorEntityRaycast.java index 63751de3..8d6faeee 100644 --- a/src/main/java/vazkii/psi/common/spell/operator/entity/PieceOperatorEntityRaycast.java +++ b/src/main/java/vazkii/psi/common/spell/operator/entity/PieceOperatorEntityRaycast.java @@ -55,7 +55,7 @@ public Object execute(SpellContext context) throws SpellRuntimeException { double maxLen = SpellHelpers.rangeLimitParam(this, context, max, SpellContext.MAX_DISTANCE); - Entity entity = rayTraceEntities(context.focalPoint.level, originVal.toVec3D(), rayVal.toVec3D(), + Entity entity = rayTraceEntities(context.focalPoint.level(), originVal.toVec3D(), rayVal.toVec3D(), pred -> !pred.isSpectator() && pred.isAlive() && pred.isPickable() && !(pred instanceof ISpellImmune), maxLen); if(entity == null) { throw new SpellRuntimeException(SpellRuntimeException.NULL_TARGET); diff --git a/src/main/java/vazkii/psi/common/spell/operator/vector/PieceOperatorVectorRaycast.java b/src/main/java/vazkii/psi/common/spell/operator/vector/PieceOperatorVectorRaycast.java index 35778fbb..c3111d67 100644 --- a/src/main/java/vazkii/psi/common/spell/operator/vector/PieceOperatorVectorRaycast.java +++ b/src/main/java/vazkii/psi/common/spell/operator/vector/PieceOperatorVectorRaycast.java @@ -71,7 +71,7 @@ public static BlockHitResult raycast(Entity e, double len) { public static BlockHitResult raycast(Entity entity, Vector3 origin, Vector3 ray, double len) { Vector3 end = origin.copy().add(ray.copy().normalize().multiply(len)); - return entity.level.clip(new ClipContext(origin.toVec3D(), end.toVec3D(), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)); + return entity.level().clip(new ClipContext(origin.toVec3D(), end.toVec3D(), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)); } @Override diff --git a/src/main/java/vazkii/psi/common/spell/other/PieceConnector.java b/src/main/java/vazkii/psi/common/spell/other/PieceConnector.java index debeb4ef..c48fa665 100644 --- a/src/main/java/vazkii/psi/common/spell/other/PieceConnector.java +++ b/src/main/java/vazkii/psi/common/spell/other/PieceConnector.java @@ -11,6 +11,7 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.resources.model.Material; import net.minecraft.network.chat.Component; @@ -54,15 +55,15 @@ public Component getEvaluationTypeString() { @Override @OnlyIn(Dist.CLIENT) - public void drawAdditional(PoseStack ms, MultiBufferSource buffers, int light) { - drawSide(ms, buffers, light, paramSides.get(target)); + public void drawAdditional(GuiGraphics graphics, MultiBufferSource buffers, int light) { + drawSide(graphics, buffers, light, paramSides.get(target)); if(isInGrid) { for(SpellParam.Side side : SpellParam.Side.class.getEnumConstants()) { if(side.isEnabled()) { SpellPiece piece = spell.grid.getPieceAtSideSafely(x, y, side); if(piece != null && piece.isInputSide(side.getOpposite())) { - drawSide(ms, buffers, light, side); + drawSide(graphics, buffers, light, side); } } } @@ -70,7 +71,7 @@ public void drawAdditional(PoseStack ms, MultiBufferSource buffers, int light) { } @OnlyIn(Dist.CLIENT) - private void drawSide(PoseStack ms, MultiBufferSource buffers, int light, SpellParam.Side side) { + private void drawSide(GuiGraphics graphics, MultiBufferSource buffers, int light, SpellParam.Side side) { if(side.isEnabled()) { Material material = new Material(ClientPsiAPI.PSI_PIECE_TEXTURE_ATLAS, LINES_TEXTURE); VertexConsumer buffer = material.buffer(buffers, ignored -> SpellPiece.getLayer()); @@ -99,7 +100,7 @@ private void drawSide(PoseStack ms, MultiBufferSource buffers, int light, SpellP /* See note in SpellPiece#drawBackground for why this chain needs to be split */ - Matrix4f mat = ms.last().pose(); + Matrix4f mat = graphics.pose().last().pose(); buffer.vertex(mat, 0, 16, 0).color(1F, 1F, 1F, 1F); buffer.uv(minU, maxV).uv2(light).endVertex(); buffer.vertex(mat, 16, 16, 0).color(1F, 1F, 1F, 1F); diff --git a/src/main/java/vazkii/psi/common/spell/other/PieceCrossConnector.java b/src/main/java/vazkii/psi/common/spell/other/PieceCrossConnector.java index 803c12f7..f5f5d143 100644 --- a/src/main/java/vazkii/psi/common/spell/other/PieceCrossConnector.java +++ b/src/main/java/vazkii/psi/common/spell/other/PieceCrossConnector.java @@ -11,6 +11,7 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.resources.model.Material; import net.minecraft.network.chat.Component; @@ -80,16 +81,16 @@ public void addToMetadata(SpellMetadata meta) throws SpellCompilationException { } @Override - public void drawAdditional(PoseStack ms, MultiBufferSource buffers, int light) { - drawSide(ms, buffers, paramSides.get(in1), light, LINE_ONE); - drawSide(ms, buffers, paramSides.get(out1), light, LINE_ONE); + public void drawAdditional(GuiGraphics graphics, MultiBufferSource buffers, int light) { + drawSide(graphics, buffers, paramSides.get(in1), light, LINE_ONE); + drawSide(graphics, buffers, paramSides.get(out1), light, LINE_ONE); - drawSide(ms, buffers, paramSides.get(in2), light, LINE_TWO); - drawSide(ms, buffers, paramSides.get(out2), light, LINE_TWO); + drawSide(graphics, buffers, paramSides.get(in2), light, LINE_TWO); + drawSide(graphics, buffers, paramSides.get(out2), light, LINE_TWO); } @OnlyIn(Dist.CLIENT) - private void drawSide(PoseStack ms, MultiBufferSource buffers, SpellParam.Side side, int light, int color) { + private void drawSide(GuiGraphics graphics, MultiBufferSource buffers, SpellParam.Side side, int light, int color) { if(side.isEnabled()) { Material material = new Material(ClientPsiAPI.PSI_PIECE_TEXTURE_ATLAS, new ResourceLocation(LibResources.SPELL_CONNECTOR_LINES)); VertexConsumer buffer = material.buffer(buffers, ignored -> SpellPiece.getLayer()); @@ -121,7 +122,7 @@ private void drawSide(PoseStack ms, MultiBufferSource buffers, SpellParam.Side s /* See note in SpellPiece#drawBackground for why this chain needs to be split */ - Matrix4f mat = ms.last().pose(); + Matrix4f mat = graphics.pose().last().pose(); buffer.vertex(mat, 0, 16, 0).color(r, g, b, 1F); buffer.uv(minU, maxV).uv2(light).endVertex(); buffer.vertex(mat, 16, 16, 0).color(r, g, b, 1F); diff --git a/src/main/java/vazkii/psi/common/spell/selector/PieceSelectorBlockPresence.java b/src/main/java/vazkii/psi/common/spell/selector/PieceSelectorBlockPresence.java index 583fef7f..d7ae3582 100644 --- a/src/main/java/vazkii/psi/common/spell/selector/PieceSelectorBlockPresence.java +++ b/src/main/java/vazkii/psi/common/spell/selector/PieceSelectorBlockPresence.java @@ -46,7 +46,7 @@ public Object execute(SpellContext context) throws SpellRuntimeException { BlockState state = context.caster.getCommandSenderWorld().getBlockState(pos); Block block = state.getBlock(); - if(state.isAir() || state.getMaterial().isReplaceable()) { + if(state.isAir() || state.canBeReplaced()) { return 0.0; } else if(state.getCollisionShape(context.caster.getCommandSenderWorld(), pos, CollisionContext.of(context.caster)).isEmpty()) { return 1.0; diff --git a/src/main/java/vazkii/psi/common/spell/selector/PieceSelectorItemCount.java b/src/main/java/vazkii/psi/common/spell/selector/PieceSelectorItemCount.java index beb5d241..e73b47bc 100644 --- a/src/main/java/vazkii/psi/common/spell/selector/PieceSelectorItemCount.java +++ b/src/main/java/vazkii/psi/common/spell/selector/PieceSelectorItemCount.java @@ -24,7 +24,7 @@ public PieceSelectorItemCount(Spell spell) { @Override public Object execute(SpellContext context) throws SpellRuntimeException { ItemStack toCount = context.caster.getInventory().items.get(context.getTargetSlot()); - return context.caster.getInventory().items.stream().filter(stack -> stack.sameItem(toCount)).mapToInt(ItemStack::getCount).reduce(Integer::sum).orElse(0); + return context.caster.getInventory().items.stream().filter(stack -> ItemStack.isSameItem(stack, toCount)).mapToInt(ItemStack::getCount).reduce(Integer::sum).orElse(0); } @Override diff --git a/src/main/java/vazkii/psi/common/spell/selector/PieceSelectorTickTime.java b/src/main/java/vazkii/psi/common/spell/selector/PieceSelectorTickTime.java index 8f2fdcff..dca5d314 100644 --- a/src/main/java/vazkii/psi/common/spell/selector/PieceSelectorTickTime.java +++ b/src/main/java/vazkii/psi/common/spell/selector/PieceSelectorTickTime.java @@ -29,7 +29,7 @@ public Object execute(SpellContext context) { } public static double getMspt(SpellContext context) { - long[] tickTimes = context.focalPoint.getServer().getTickTime(context.focalPoint.level.dimension()); + long[] tickTimes = context.focalPoint.getServer().getTickTime(context.focalPoint.level().dimension()); if(tickTimes == null) { return 0; } diff --git a/src/main/java/vazkii/psi/common/spell/selector/entity/PieceSelectorNearbySmeltables.java b/src/main/java/vazkii/psi/common/spell/selector/entity/PieceSelectorNearbySmeltables.java index 58d4bf76..4b468221 100644 --- a/src/main/java/vazkii/psi/common/spell/selector/entity/PieceSelectorNearbySmeltables.java +++ b/src/main/java/vazkii/psi/common/spell/selector/entity/PieceSelectorNearbySmeltables.java @@ -8,6 +8,7 @@ */ package vazkii.psi.common.spell.selector.entity; +import net.minecraft.core.RegistryAccess; import net.minecraft.world.SimpleContainer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.item.ItemEntity; @@ -37,7 +38,7 @@ public static ItemStack simulateSmelt(Level world, ItemStack input) { DUMMY_INV.clearContent(); DUMMY_INV.setItem(0, input); return world.getRecipeManager().getRecipeFor(RecipeType.SMELTING, DUMMY_INV, world) - .map(SmeltingRecipe::getResultItem) + .map(foo -> foo.getResultItem(RegistryAccess.EMPTY)) .orElse(ItemStack.EMPTY); } diff --git a/src/main/java/vazkii/psi/common/spell/trick/PieceTrickBlaze.java b/src/main/java/vazkii/psi/common/spell/trick/PieceTrickBlaze.java index 867f2c16..1ee023c0 100644 --- a/src/main/java/vazkii/psi/common/spell/trick/PieceTrickBlaze.java +++ b/src/main/java/vazkii/psi/common/spell/trick/PieceTrickBlaze.java @@ -70,12 +70,12 @@ public Object execute(SpellContext context) throws SpellRuntimeException { if(placeEvent.isCanceled()) { return null; } - if(state.isAir() || state.getMaterial().isReplaceable()) { + if(state.isAir() || state.canBeReplaced()) { context.focalPoint.getCommandSenderWorld().setBlockAndUpdate(pos, Blocks.FIRE.defaultBlockState()); } else { pos = pos.above(); state = context.focalPoint.getCommandSenderWorld().getBlockState(pos); - if(state.isAir() || state.getMaterial().isReplaceable()) { + if(state.isAir() || state.canBeReplaced()) { context.focalPoint.getCommandSenderWorld().setBlockAndUpdate(pos, Blocks.FIRE.defaultBlockState()); } } diff --git a/src/main/java/vazkii/psi/common/spell/trick/PieceTrickDetonate.java b/src/main/java/vazkii/psi/common/spell/trick/PieceTrickDetonate.java index 547dd43e..3b860a5e 100644 --- a/src/main/java/vazkii/psi/common/spell/trick/PieceTrickDetonate.java +++ b/src/main/java/vazkii/psi/common/spell/trick/PieceTrickDetonate.java @@ -56,10 +56,10 @@ public Object execute(SpellContext context) throws SpellRuntimeException { double radiusVal = Math.min(MAX_DISTANCE, this.getNonnullParamValue(context, radius).doubleValue()); if(radiusVal == 0.0) { - IDetonationHandler.performDetonation(context.focalPoint.level, context.caster, 0, entity -> entity == context.caster); + IDetonationHandler.performDetonation(context.focalPoint.level(), context.caster, 0, entity -> entity == context.caster); return null; } - IDetonationHandler.performDetonation(context.focalPoint.level, context.caster, context.focalPoint, radiusVal); + IDetonationHandler.performDetonation(context.focalPoint.level(), context.caster, context.focalPoint, radiusVal); return null; } } diff --git a/src/main/java/vazkii/psi/common/spell/trick/PieceTrickExplode.java b/src/main/java/vazkii/psi/common/spell/trick/PieceTrickExplode.java index 4d5bc669..2dd5e037 100644 --- a/src/main/java/vazkii/psi/common/spell/trick/PieceTrickExplode.java +++ b/src/main/java/vazkii/psi/common/spell/trick/PieceTrickExplode.java @@ -10,6 +10,8 @@ import net.minecraft.core.BlockPos; import net.minecraft.world.level.Explosion; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import vazkii.psi.api.internal.Vector3; @@ -72,8 +74,12 @@ public Object execute(SpellContext context) throws SpellRuntimeException { BlockPos pos = positionVal.toBlockPos(); BlockState state = context.focalPoint.getCommandSenderWorld().getBlockState(pos); - context.focalPoint.getCommandSenderWorld().explode(context.focalPoint, positionVal.x, positionVal.y, positionVal.z, (float) powerVal, state.getMaterial().isLiquid() ? Explosion.BlockInteraction.NONE : Explosion.BlockInteraction.BREAK); + context.focalPoint.getCommandSenderWorld().explode(context.focalPoint, positionVal.x, positionVal.y, positionVal.z, (float) powerVal, isLiquid(state) ? Level.ExplosionInteraction.NONE : Level.ExplosionInteraction.TNT); return null; } + private static boolean isLiquid(BlockState pState) { + return pState == Blocks.WATER.defaultBlockState() || pState == Blocks.LAVA.defaultBlockState(); + } + } diff --git a/src/main/java/vazkii/psi/common/spell/trick/PieceTrickOvergrow.java b/src/main/java/vazkii/psi/common/spell/trick/PieceTrickOvergrow.java index 0ba37d05..4839ba55 100644 --- a/src/main/java/vazkii/psi/common/spell/trick/PieceTrickOvergrow.java +++ b/src/main/java/vazkii/psi/common/spell/trick/PieceTrickOvergrow.java @@ -58,7 +58,7 @@ public void addToMetadata(SpellMetadata meta) throws SpellCompilationException { @Override public Object execute(SpellContext context) throws SpellRuntimeException { BlockPos pos = SpellHelpers.getBlockPos(this, context, position, true, false); - return bonemeal(context.caster, context.focalPoint.level, pos); + return bonemeal(context.caster, context.focalPoint.level(), pos); } public InteractionResult bonemeal(Player player, Level world, BlockPos pos) { diff --git a/src/main/java/vazkii/psi/common/spell/trick/PieceTrickPlaySound.java b/src/main/java/vazkii/psi/common/spell/trick/PieceTrickPlaySound.java index 0a108c2d..28a17d6a 100644 --- a/src/main/java/vazkii/psi/common/spell/trick/PieceTrickPlaySound.java +++ b/src/main/java/vazkii/psi/common/spell/trick/PieceTrickPlaySound.java @@ -69,7 +69,7 @@ public Object execute(SpellContext context) throws SpellRuntimeException { int instrumentId = Mth.clamp((int) instrumentVal, 0, Psi.noteblockSoundEvents.size() - 1); float f = (float) Math.pow(2, (pitchVal - 12) / 12.0); - context.focalPoint.level.playSound(null, pos, Psi.noteblockSoundEvents.get(instrumentId), SoundSource.RECORDS, (float) volVal, f); + context.focalPoint.level().playSound(null, pos, Psi.noteblockSoundEvents.get(instrumentId), SoundSource.RECORDS, (float) volVal, f); return null; } } diff --git a/src/main/java/vazkii/psi/common/spell/trick/PieceTrickSmite.java b/src/main/java/vazkii/psi/common/spell/trick/PieceTrickSmite.java index 3d29130b..429bcd6a 100644 --- a/src/main/java/vazkii/psi/common/spell/trick/PieceTrickSmite.java +++ b/src/main/java/vazkii/psi/common/spell/trick/PieceTrickSmite.java @@ -68,7 +68,7 @@ public Object execute(SpellContext context) throws SpellRuntimeException { } if(context.focalPoint.getCommandSenderWorld() instanceof ServerLevel) { - LightningBolt lightning = new LightningBolt(EntityType.LIGHTNING_BOLT, context.focalPoint.level); + LightningBolt lightning = new LightningBolt(EntityType.LIGHTNING_BOLT, context.focalPoint.level()); lightning.setPosRaw(positionVal.x, positionVal.y, positionVal.z); context.focalPoint.getCommandSenderWorld().addFreshEntity(lightning); } diff --git a/src/main/java/vazkii/psi/common/spell/trick/PieceTrickTorrent.java b/src/main/java/vazkii/psi/common/spell/trick/PieceTrickTorrent.java index bc2135e9..c83163ed 100644 --- a/src/main/java/vazkii/psi/common/spell/trick/PieceTrickTorrent.java +++ b/src/main/java/vazkii/psi/common/spell/trick/PieceTrickTorrent.java @@ -71,7 +71,7 @@ public Object execute(SpellContext context) throws SpellRuntimeException { if(placeEvent.isCanceled()) { return null; } - return placeWater(context.caster, context.focalPoint.level, pos); + return placeWater(context.caster, context.focalPoint.level(), pos); } // [VanillaCopy] BucketItem.tryPlaceContainingLiquid because buckets are dumb diff --git a/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickCollapseBlockSequence.java b/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickCollapseBlockSequence.java index 1af70a64..07d77b79 100644 --- a/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickCollapseBlockSequence.java +++ b/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickCollapseBlockSequence.java @@ -71,7 +71,7 @@ public Object execute(SpellContext context) throws SpellRuntimeException { tool = PsiAPI.getPlayerCAD(context.caster); } - Level world = context.focalPoint.level; + Level world = context.focalPoint.level(); Vector3 targetNorm = targetVal.copy().normalize(); for(BlockPos blockPos : MathHelper.getBlocksAlongRay(positionVal.toVec3D(), positionVal.copy().add(targetNorm.copy().multiply(maxBlocksInt)).toVec3D(), maxBlocksInt)) { if(!context.isInRadius(Vector3.fromBlockPos(blockPos))) { diff --git a/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickConjureBlock.java b/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickConjureBlock.java index cb1a8da0..d9d07c73 100644 --- a/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickConjureBlock.java +++ b/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickConjureBlock.java @@ -114,7 +114,7 @@ public static boolean conjure(Level world, BlockPos pos, Player player, BlockSta } BlockState inWorld = world.getBlockState(pos); - if(inWorld.isAir() || inWorld.getMaterial().isReplaceable()) { + if(inWorld.isAir() || inWorld.canBeReplaced()) { return world.setBlockAndUpdate(pos, state); } return false; diff --git a/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickMoveBlock.java b/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickMoveBlock.java index 9fb90fa9..4ffed123 100644 --- a/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickMoveBlock.java +++ b/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickMoveBlock.java @@ -109,7 +109,7 @@ public Object execute(SpellContext context) throws SpellRuntimeException { return null; } - if(state1.isAir() || state1.getMaterial().isReplaceable()) { + if(state1.isAir() || state1.canBeReplaced()) { world.setBlock(pos1, state, 1 | 2); world.removeBlock(pos, false); world.levelEvent(2001, pos, Block.getId(state)); diff --git a/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickMoveBlockSequence.java b/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickMoveBlockSequence.java index 4b9d28a7..ba0e0a8a 100644 --- a/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickMoveBlockSequence.java +++ b/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickMoveBlockSequence.java @@ -71,7 +71,7 @@ public Object execute(SpellContext context) throws SpellRuntimeException { Vector3 positionVal = SpellHelpers.getVector3(this, context, position, true, false); Vector3 targetVal = SpellHelpers.getVector3(this, context, target, false, false); int maxBlocksVal = this.getParamValue(context, maxBlocks).intValue(); - Level world = context.focalPoint.level; + Level world = context.focalPoint.level(); Map toSet = new HashMap<>(); Map toRemove = new HashMap<>(); @@ -112,7 +112,7 @@ public Object execute(SpellContext context) throws SpellRuntimeException { continue; } - BlockPos pushToPos = blockPos.offset(directNorm.x, directNorm.y, directNorm.z); + BlockPos pushToPos = blockPos.offset((int) directNorm.x, (int) directNorm.y, (int) directNorm.z); boolean isOffWorld = pushToPos.getY() < 0 || pushToPos.getY() > 256; if(isOffWorld) { immovableBlocks.add(blockPos); @@ -130,7 +130,7 @@ public Object execute(SpellContext context) throws SpellRuntimeException { outer: for(BlockPos blockPos : moveableBlocks) { BlockState state = world.getBlockState(blockPos); - BlockPos pushToPos = blockPos.offset(directNorm.x, directNorm.y, directNorm.z); + BlockPos pushToPos = blockPos.offset((int) directNorm.x, (int) directNorm.y, (int) directNorm.z); BlockState pushToState = world.getBlockState(pushToPos); if(immovableBlocks.contains(pushToPos) || immovableBlocks.contains(blockPos)) { continue; @@ -138,7 +138,7 @@ public Object execute(SpellContext context) throws SpellRuntimeException { if(moveableBlocks.contains(pushToPos)) { BlockPos nextPos = pushToPos; while(moveableBlocks.contains(nextPos)) { - BlockPos nextPosPushPos = nextPos.offset(directNorm.x, directNorm.y, directNorm.z); + BlockPos nextPosPushPos = nextPos.offset((int) directNorm.x, (int) directNorm.y, (int) directNorm.z); BlockState nextPosPushPosState = world.getBlockState(nextPosPushPos); if(moveableBlocks.contains(nextPosPushPos)) { @@ -146,12 +146,12 @@ public Object execute(SpellContext context) throws SpellRuntimeException { continue; } - if(immovableBlocks.contains(nextPosPushPos) || !(world.isEmptyBlock(nextPosPushPos) || nextPosPushPosState.getMaterial().isReplaceable())) { + if(immovableBlocks.contains(nextPosPushPos) || !(world.isEmptyBlock(nextPosPushPos) || nextPosPushPosState.canBeReplaced())) { continue outer; } break; } - } else if(!(world.isEmptyBlock(pushToPos) || pushToState.getMaterial().isReplaceable())) { + } else if(!(world.isEmptyBlock(pushToPos) || pushToState.canBeReplaced())) { continue; } toRemove.put(blockPos, state); @@ -159,12 +159,12 @@ public Object execute(SpellContext context) throws SpellRuntimeException { } for(Map.Entry pairtoRemove : toRemove.entrySet()) { - context.focalPoint.level.removeBlock(pairtoRemove.getKey(), true); - context.focalPoint.level.levelEvent(2001, pairtoRemove.getKey(), Block.getId(pairtoRemove.getValue())); + context.focalPoint.level().removeBlock(pairtoRemove.getKey(), true); + context.focalPoint.level().levelEvent(2001, pairtoRemove.getKey(), Block.getId(pairtoRemove.getValue())); } for(Map.Entry pairToSet : toSet.entrySet()) { - context.focalPoint.level.setBlockAndUpdate(pairToSet.getKey(), pairToSet.getValue()); + context.focalPoint.level().setBlockAndUpdate(pairToSet.getKey(), pairToSet.getValue()); } return null; diff --git a/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickPlaceBlock.java b/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickPlaceBlock.java index 1186028a..84d1e87a 100644 --- a/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickPlaceBlock.java +++ b/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickPlaceBlock.java @@ -103,7 +103,7 @@ public static void placeBlock(Player player, Level world, BlockPos pos, int slot BlockState state = world.getBlockState(pos); BlockEvent.EntityPlaceEvent placeEvent = new BlockEvent.EntityPlaceEvent(BlockSnapshot.create(world.dimension(), world, pos), world.getBlockState(pos.relative(Direction.UP)), player); MinecraftForge.EVENT_BUS.post(placeEvent); - if(state.isAir() || state.getMaterial().isReplaceable() && !placeEvent.isCanceled()) { + if(state.isAir() || state.canBeReplaced() && !placeEvent.isCanceled()) { if(conjure) { @@ -153,7 +153,7 @@ public static ItemStack removeFromInventory(Player player, ItemStack stack, bool Inventory inv = player.getInventory(); for(int i = inv.getContainerSize() - 1; i >= 0; i--) { ItemStack invStack = inv.getItem(i); - if(!invStack.isEmpty() && invStack.sameItem(stack) && ItemStack.matches(stack, invStack)) { + if(!invStack.isEmpty() && ItemStack.isSameItem(invStack, stack) && ItemStack.matches(stack, invStack)) { ItemStack retStack = invStack.copy(); if(!copy) { invStack.shrink(1); diff --git a/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickSmeltBlock.java b/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickSmeltBlock.java index 15209cb7..9fdff655 100644 --- a/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickSmeltBlock.java +++ b/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickSmeltBlock.java @@ -71,7 +71,7 @@ public Object execute(SpellContext context) throws SpellRuntimeException { BlockState state = context.focalPoint.getCommandSenderWorld().getBlockState(pos); Block block = state.getBlock(); ItemStack stack = new ItemStack(block); - BlockEvent.BreakEvent event = PieceTrickBreakBlock.createBreakEvent(state, context.caster, context.focalPoint.level, pos, tool); + BlockEvent.BreakEvent event = PieceTrickBreakBlock.createBreakEvent(state, context.caster, context.focalPoint.level(), pos, tool); MinecraftForge.EVENT_BUS.post(event); if(event.isCanceled()) { return null; diff --git a/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickSmeltBlockSequence.java b/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickSmeltBlockSequence.java index 8f70f161..78455c39 100644 --- a/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickSmeltBlockSequence.java +++ b/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickSmeltBlockSequence.java @@ -85,7 +85,7 @@ public Object execute(SpellContext context) throws SpellRuntimeException { BlockState state = context.focalPoint.getCommandSenderWorld().getBlockState(blockPos); Block block = state.getBlock(); ItemStack stack = new ItemStack(block); - BlockEvent.BreakEvent event = PieceTrickBreakBlock.createBreakEvent(state, context.caster, context.focalPoint.level, blockPos, tool); + BlockEvent.BreakEvent event = PieceTrickBreakBlock.createBreakEvent(state, context.caster, context.focalPoint.level(), blockPos, tool); MinecraftForge.EVENT_BUS.post(event); if(event.isCanceled()) { return null; diff --git a/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickTill.java b/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickTill.java index 006a6c77..b5f24880 100644 --- a/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickTill.java +++ b/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickTill.java @@ -70,7 +70,7 @@ public void addToMetadata(SpellMetadata meta) throws SpellCompilationException { public Object execute(SpellContext context) throws SpellRuntimeException { BlockPos pos = SpellHelpers.getBlockPos(this, context, position, true, false); - return tillBlock(context.caster, context.focalPoint.level, pos); + return tillBlock(context.caster, context.focalPoint.level(), pos); } } diff --git a/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickTillSequence.java b/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickTillSequence.java index c0fba440..305bbaad 100644 --- a/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickTillSequence.java +++ b/src/main/java/vazkii/psi/common/spell/trick/block/PieceTrickTillSequence.java @@ -65,7 +65,7 @@ public Object execute(SpellContext context) throws SpellRuntimeException { for(BlockPos blockPos : MathHelper.getBlocksAlongRay(positionVal.toVec3D(), positionVal.copy().add(targetNorm.copy().multiply(maxBlocksInt)).toVec3D(), maxBlocksInt)) { if(SpellHelpers.isBlockPosInRadius(context, blockPos)) { - PieceTrickTill.tillBlock(context.caster, context.focalPoint.level, blockPos); + PieceTrickTill.tillBlock(context.caster, context.focalPoint.level(), blockPos); } } diff --git a/src/main/java/vazkii/psi/data/DataGenerator.java b/src/main/java/vazkii/psi/data/DataGenerator.java index f79778f5..75591551 100644 --- a/src/main/java/vazkii/psi/data/DataGenerator.java +++ b/src/main/java/vazkii/psi/data/DataGenerator.java @@ -26,14 +26,14 @@ public static void gatherData(GatherDataEvent event) { PsiBlockTagProvider blockTagProvider = new PsiBlockTagProvider(event.getGenerator().getPackOutput(), event.getLookupProvider(), existingFileHelper); event.getGenerator().addProvider(true, blockTagProvider); event.getGenerator().addProvider(true, new PsiDamageTypeTagsProvider(event.getGenerator().getPackOutput(), event.getLookupProvider(), existingFileHelper)); - event.getGenerator().addProvider(true, new PsiItemTagProvider(event.getGenerator(), blockTagProvider, existingFileHelper)); + event.getGenerator().addProvider(true, new PsiItemTagProvider(event.getGenerator().getPackOutput(), event.getLookupProvider(), blockTagProvider.contentsGetter(), existingFileHelper)); event.getGenerator().addProvider(true, new PsiRecipeGenerator(event.getGenerator().getPackOutput())); - event.getGenerator().addProvider(true, new PsiTrickRecipeGenerator(event.getGenerator())); + event.getGenerator().addProvider(true, new PsiTrickRecipeGenerator(event.getGenerator().getPackOutput())); } if(event.includeClient()) { - event.getGenerator().addProvider(true, new PsiBlockModelGenerator(event.getGenerator(), event.getExistingFileHelper())); - event.getGenerator().addProvider(true, new PsiItemModelGenerator(event.getGenerator(), event.getExistingFileHelper())); + event.getGenerator().addProvider(true, new PsiBlockModelGenerator(event.getGenerator().getPackOutput(), event.getExistingFileHelper())); + event.getGenerator().addProvider(true, new PsiItemModelGenerator(event.getGenerator().getPackOutput(), event.getExistingFileHelper())); } } } diff --git a/src/main/java/vazkii/psi/data/PsiBlockModelGenerator.java b/src/main/java/vazkii/psi/data/PsiBlockModelGenerator.java index 1d694cae..eb09b5bc 100644 --- a/src/main/java/vazkii/psi/data/PsiBlockModelGenerator.java +++ b/src/main/java/vazkii/psi/data/PsiBlockModelGenerator.java @@ -9,6 +9,7 @@ package vazkii.psi.data; import net.minecraft.data.DataGenerator; +import net.minecraft.data.PackOutput; import net.minecraftforge.client.model.generators.BlockStateProvider; import net.minecraftforge.common.data.ExistingFileHelper; import net.minecraftforge.registries.ForgeRegistries; @@ -21,8 +22,8 @@ import static vazkii.psi.common.Psi.location; public class PsiBlockModelGenerator extends BlockStateProvider { - public PsiBlockModelGenerator(DataGenerator gen, ExistingFileHelper exFileHelper) { - super(gen, LibMisc.MOD_ID, exFileHelper); + public PsiBlockModelGenerator(PackOutput output, ExistingFileHelper exFileHelper) { + super(output, LibMisc.MOD_ID, exFileHelper); } @Override diff --git a/src/main/java/vazkii/psi/data/PsiItemModelGenerator.java b/src/main/java/vazkii/psi/data/PsiItemModelGenerator.java index 0e04b3d3..262a99d7 100644 --- a/src/main/java/vazkii/psi/data/PsiItemModelGenerator.java +++ b/src/main/java/vazkii/psi/data/PsiItemModelGenerator.java @@ -9,6 +9,7 @@ package vazkii.psi.data; import net.minecraft.data.DataGenerator; +import net.minecraft.data.PackOutput; import net.minecraft.world.item.Item; import net.minecraftforge.client.model.generators.ItemModelProvider; import net.minecraftforge.client.model.generators.ModelFile; @@ -22,8 +23,8 @@ import javax.annotation.Nonnull; public class PsiItemModelGenerator extends ItemModelProvider { - public PsiItemModelGenerator(DataGenerator generator, ExistingFileHelper existingFileHelper) { - super(generator, LibMisc.MOD_ID, existingFileHelper); + public PsiItemModelGenerator(PackOutput output, ExistingFileHelper existingFileHelper) { + super(output, LibMisc.MOD_ID, existingFileHelper); } private void pointToBlock(Item item) { diff --git a/src/main/java/vazkii/psi/data/PsiItemTagProvider.java b/src/main/java/vazkii/psi/data/PsiItemTagProvider.java index f1649d0d..6570c916 100644 --- a/src/main/java/vazkii/psi/data/PsiItemTagProvider.java +++ b/src/main/java/vazkii/psi/data/PsiItemTagProvider.java @@ -8,8 +8,13 @@ */ package vazkii.psi.data; +import net.minecraft.core.HolderLookup; import net.minecraft.data.DataGenerator; +import net.minecraft.data.PackOutput; import net.minecraft.data.tags.ItemTagsProvider; +import net.minecraft.data.tags.TagsProvider; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; import net.minecraftforge.common.Tags; import net.minecraftforge.common.data.ExistingFileHelper; @@ -17,14 +22,17 @@ import vazkii.psi.common.lib.LibMisc; import vazkii.psi.common.lib.ModTags; +import java.util.concurrent.CompletableFuture; + public class PsiItemTagProvider extends ItemTagsProvider { - public PsiItemTagProvider(DataGenerator generator, PsiBlockTagProvider blockTagProvider, ExistingFileHelper existingFileHelper) { - super(generator, blockTagProvider, LibMisc.MOD_ID, existingFileHelper); + + public PsiItemTagProvider(PackOutput output, CompletableFuture pLookupProvider, CompletableFuture> pBlockTags, ExistingFileHelper existingFileHelper) { + super(output, pLookupProvider, pBlockTags, LibMisc.MOD_ID, existingFileHelper); } @Override - protected void addTags() { + protected void addTags(HolderLookup.Provider pProvider) { tag(Tags.Items.DUSTS).add(ModItems.psidust); tag(Tags.Items.INGOTS).add(ModItems.psimetal); tag(Tags.Items.INGOTS).add(ModItems.ebonyPsimetal); @@ -52,4 +60,5 @@ protected void addTags() { public String getName() { return "Psi item tags"; } + } diff --git a/src/main/java/vazkii/psi/data/PsiTrickRecipeGenerator.java b/src/main/java/vazkii/psi/data/PsiTrickRecipeGenerator.java index dd0cd843..1ca61f49 100644 --- a/src/main/java/vazkii/psi/data/PsiTrickRecipeGenerator.java +++ b/src/main/java/vazkii/psi/data/PsiTrickRecipeGenerator.java @@ -11,6 +11,7 @@ import com.google.gson.JsonObject; import net.minecraft.data.DataGenerator; +import net.minecraft.data.PackOutput; import net.minecraft.data.recipes.FinishedRecipe; import net.minecraft.data.recipes.RecipeProvider; import net.minecraft.resources.ResourceKey; @@ -35,12 +36,12 @@ import java.util.function.Consumer; public class PsiTrickRecipeGenerator extends RecipeProvider { - public PsiTrickRecipeGenerator(DataGenerator generator) { - super(generator); + public PsiTrickRecipeGenerator(PackOutput output) { + super(output); } @Override - protected void buildCraftingRecipes(Consumer consumer) { + protected void buildRecipes(Consumer consumer) { TrickRecipeBuilder.of(ModItems.psidust).input(Tags.Items.DUSTS_REDSTONE).cad(ModItems.cadAssemblyIron).build(consumer); TrickRecipeBuilder.of(PatchouliAPI.get().getBookStack(LibResources.PATCHOULI_BOOK)).input(Items.BOOK).cad(ModItems.cadAssemblyIron).build(consumer); @@ -73,11 +74,6 @@ protected void buildCraftingRecipes(Consumer consumer) { dimension(builder, consumer, ForgeRegistries.ITEMS.getKey(ModItems.ivorySubstance), Level.END); } - @Nonnull - @Override - public String getName() { - return "Psi trick crafting recipes"; - } public static void dimension(TrickRecipeBuilder builder, Consumer parent, ResourceLocation id, ResourceKey dimensionKey) { diff --git a/src/main/java/vazkii/psi/data/WrapperResult.java b/src/main/java/vazkii/psi/data/WrapperResult.java index 1b8a65e6..d62c564e 100644 --- a/src/main/java/vazkii/psi/data/WrapperResult.java +++ b/src/main/java/vazkii/psi/data/WrapperResult.java @@ -11,9 +11,11 @@ import com.google.gson.JsonObject; import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; import net.minecraft.data.recipes.FinishedRecipe; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraftforge.registries.ForgeRegistries; import javax.annotation.Nullable; @@ -63,7 +65,7 @@ public JsonObject serializeRecipe() { return FinishedRecipe.super.serializeRecipe(); } JsonObject jsonobject = new JsonObject(); - jsonobject.addProperty("type", Registry.RECIPE_SERIALIZER.getKey(this.type).toString()); + jsonobject.addProperty("type", ForgeRegistries.RECIPE_SERIALIZERS.getKey(this.type).toString()); this.serializeRecipeData(jsonobject); return jsonobject; }