From 3f9806bcb00caf1a17a24f2052161649d4d4a33c 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 | 5 +- .../api/internal/IInternalMethodHandler.java | 5 +- .../java/vazkii/psi/api/internal/Vector3.java | 4 +- .../api/material/PsimetalArmorMaterial.java | 2 - .../api/material/PsimetalToolMaterial.java | 1 - .../vazkii/psi/api/recipe/ITrickRecipe.java | 1 - src/main/java/vazkii/psi/api/spell/Spell.java | 7 +- .../java/vazkii/psi/api/spell/SpellGrid.java | 12 +-- .../java/vazkii/psi/api/spell/SpellPiece.java | 52 +++++----- .../psi/client/core/handler/HUDHandler.java | 1 - .../psi/client/core/proxy/ClientProxy.java | 9 +- .../psi/client/fx/SparkleParticleType.java | 1 - .../psi/client/fx/WispParticleType.java | 1 - .../psi/client/gui/GuiCADAssembler.java | 32 +++--- .../vazkii/psi/client/gui/GuiProgrammer.java | 6 +- .../psi/client/gui/GuiSocketSelect.java | 31 +++--- .../psi/client/gui/button/GuiButtonHelp.java | 13 +-- .../psi/client/gui/button/GuiButtonIO.java | 21 ++-- .../psi/client/gui/button/GuiButtonPage.java | 21 ++-- .../gui/button/GuiButtonSideConfig.java | 19 +--- .../gui/button/GuiButtonSpellPiece.java | 27 ++---- .../client/gui/widget/PiecePanelWidget.java | 4 +- .../client/gui/widget/SideConfigWidget.java | 20 ++-- .../client/gui/widget/SpellCostsWidget.java | 17 ++-- .../psi/client/gui/widget/StatusWidget.java | 20 ++-- .../java/vazkii/psi/client/jei/JEICompat.java | 8 +- .../jei/crafting/BulletToDriveExtension.java | 13 +-- .../jei/crafting/DriveDuplicateExtension.java | 5 +- .../psi/client/jei/tricks/DrawablePiece.java | 3 +- .../jei/tricks/TrickCraftingCategory.java | 2 - .../client/patchouli/SpellGridComponent.java | 3 +- .../client/patchouli/SpellPieceComponent.java | 3 +- .../render/entity/RenderSpellCircle.java | 4 +- .../render/tile/RenderTileProgrammer.java | 7 +- .../tile/container/slot/SlotCADOutput.java | 4 +- .../psi/common/core/PsiCreativeTab.java | 48 ++++----- .../capability/CapabilityTriggerSensor.java | 2 +- .../core/handler/AdditiveMotionHandler.java | 4 +- .../core/handler/DamageTypeHandler.java | 17 ---- .../core/handler/InternalMethodHandler.java | 9 +- .../common/core/handler/PsiSoundHandler.java | 18 ++-- .../crafting/recipe/BulletUpgradeRecipe.java | 15 ++- .../crafting/recipe/DimensionTrickRecipe.java | 9 +- .../common/crafting/recipe/TrickRecipe.java | 7 +- .../common/entity/EntitySpellProjectile.java | 7 +- .../java/vazkii/psi/common/item/ItemCAD.java | 17 ++-- .../vazkii/psi/common/item/ItemDetonator.java | 2 +- .../psi/common/item/ItemVectorRuler.java | 2 - .../common/item/armor/ItemPsimetalArmor.java | 6 +- .../item/armor/ItemPsimetalExosuitBoots.java | 6 +- .../armor/ItemPsimetalExosuitChestplate.java | 6 +- .../item/armor/ItemPsimetalExosuitHelmet.java | 5 +- .../armor/ItemPsimetalExosuitLeggings.java | 6 +- .../vazkii/psi/common/item/base/IHUDItem.java | 2 - .../vazkii/psi/common/item/base/ModItems.java | 13 ++- .../psi/common/item/tool/IPsimetalTool.java | 2 +- .../java/vazkii/psi/common/lib/ModTags.java | 3 +- .../network/message/MessageLoopcastSync.java | 2 +- .../network/message/MessageSpellModified.java | 2 +- .../spell/constant/PieceConstantNumber.java | 15 ++- .../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 | 12 +-- .../spell/other/PieceCrossConnector.java | 16 +-- .../selector/PieceSelectorBlockPresence.java | 2 +- .../selector/PieceSelectorItemCount.java | 2 +- .../spell/selector/PieceSelectorTickTime.java | 2 +- .../entity/PieceSelectorNearbySmeltables.java | 4 +- .../common/spell/trick/PieceTrickBlaze.java | 4 +- .../spell/trick/PieceTrickDetonate.java | 4 +- .../common/spell/trick/PieceTrickExplode.java | 9 +- .../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 | 6 +- .../psi/data/PsiDamageTypeTagsProvider.java | 1 - .../psi/data/PsiItemModelGenerator.java | 6 +- .../vazkii/psi/data/PsiItemTagProvider.java | 14 ++- .../vazkii/psi/data/PsiRecipeGenerator.java | 97 ++++++++++--------- .../psi/data/PsiTrickRecipeGenerator.java | 14 +-- .../java/vazkii/psi/data/WrapperResult.java | 4 +- 97 files changed, 404 insertions(+), 472 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..515e5f4f 100644 --- a/src/main/java/vazkii/psi/api/internal/DummyMethodHandler.java +++ b/src/main/java/vazkii/psi/api/internal/DummyMethodHandler.java @@ -8,8 +8,7 @@ */ package vazkii.psi.api.internal; -import com.mojang.blaze3d.vertex.PoseStack; - +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.RenderType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -70,7 +69,7 @@ public void setCrashData(CompiledSpell spell, SpellPiece piece) { @Override @OnlyIn(Dist.CLIENT) - public void renderTooltip(PoseStack ms, int x, int y, List 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..b3a196d8 100644 --- a/src/main/java/vazkii/psi/api/internal/IInternalMethodHandler.java +++ b/src/main/java/vazkii/psi/api/internal/IInternalMethodHandler.java @@ -8,8 +8,7 @@ */ package vazkii.psi.api.internal; -import com.mojang.blaze3d.vertex.PoseStack; - +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.RenderType; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -70,7 +69,7 @@ public interface IInternalMethodHandler { * Renders a tooltip with the specified colors at the given x,y position */ @OnlyIn(Dist.CLIENT) - void renderTooltip(PoseStack ms, int x, int y, List 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/internal/Vector3.java b/src/main/java/vazkii/psi/api/internal/Vector3.java index f6e07a80..405cef07 100644 --- a/src/main/java/vazkii/psi/api/internal/Vector3.java +++ b/src/main/java/vazkii/psi/api/internal/Vector3.java @@ -250,7 +250,9 @@ public Vec3 toVec3D() { return new Vec3(x, y, z); } - public Vec3i toVec3i() { return new Vec3i((int) x, (int) y, (int) z); } + public Vec3i toVec3i() { + return new Vec3i((int) x, (int) y, (int) z); + } public BlockPos toBlockPos() { return new BlockPos(toVec3i()); diff --git a/src/main/java/vazkii/psi/api/material/PsimetalArmorMaterial.java b/src/main/java/vazkii/psi/api/material/PsimetalArmorMaterial.java index 6a89f271..cc4241fe 100644 --- a/src/main/java/vazkii/psi/api/material/PsimetalArmorMaterial.java +++ b/src/main/java/vazkii/psi/api/material/PsimetalArmorMaterial.java @@ -10,7 +10,6 @@ import net.minecraft.sounds.SoundEvent; import net.minecraft.util.LazyLoadedValue; -import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.ArmorMaterial; import net.minecraft.world.item.crafting.Ingredient; @@ -41,7 +40,6 @@ public PsimetalArmorMaterial(String nameIn, int maxDamageFactorIn, int[] damageR this.knockbackResistance = knockbackResistance; } - @Override public int getDurabilityForType(ArmorItem.Type pType) { return MAX_DAMAGE_ARRAY[pType.ordinal()] * this.maxDamageFactor; diff --git a/src/main/java/vazkii/psi/api/material/PsimetalToolMaterial.java b/src/main/java/vazkii/psi/api/material/PsimetalToolMaterial.java index 7418284c..be8ff526 100644 --- a/src/main/java/vazkii/psi/api/material/PsimetalToolMaterial.java +++ b/src/main/java/vazkii/psi/api/material/PsimetalToolMaterial.java @@ -8,7 +8,6 @@ */ package vazkii.psi.api.material; -import net.minecraft.core.Registry; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.LazyLoadedValue; import net.minecraft.world.item.Tier; diff --git a/src/main/java/vazkii/psi/api/recipe/ITrickRecipe.java b/src/main/java/vazkii/psi/api/recipe/ITrickRecipe.java index 851c07ff..22580b2c 100644 --- a/src/main/java/vazkii/psi/api/recipe/ITrickRecipe.java +++ b/src/main/java/vazkii/psi/api/recipe/ITrickRecipe.java @@ -9,7 +9,6 @@ package vazkii.psi.api.recipe; import net.minecraft.core.NonNullList; -import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; diff --git a/src/main/java/vazkii/psi/api/spell/Spell.java b/src/main/java/vazkii/psi/api/spell/Spell.java index 1b8f4463..b4a5bae1 100644 --- a/src/main/java/vazkii/psi/api/spell/Spell.java +++ b/src/main/java/vazkii/psi/api/spell/Spell.java @@ -8,8 +8,7 @@ */ package vazkii.psi.api.spell; -import com.mojang.blaze3d.vertex.PoseStack; - +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; @@ -46,8 +45,8 @@ public Spell() { } @OnlyIn(Dist.CLIENT) - public void draw(PoseStack ms, MultiBufferSource buffers, int light) { - grid.draw(ms, buffers, light); + public void draw(GuiGraphics graphics, MultiBufferSource buffers, int light) { + grid.draw(graphics, buffers, light); } @Nullable diff --git a/src/main/java/vazkii/psi/api/spell/SpellGrid.java b/src/main/java/vazkii/psi/api/spell/SpellGrid.java index 20abb179..b3e1208e 100644 --- a/src/main/java/vazkii/psi/api/spell/SpellGrid.java +++ b/src/main/java/vazkii/psi/api/spell/SpellGrid.java @@ -10,8 +10,8 @@ import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; -import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; @@ -45,15 +45,15 @@ public final class SpellGrid { private int leftmost, rightmost, topmost, bottommost; @OnlyIn(Dist.CLIENT) - public void draw(PoseStack ms, MultiBufferSource buffers, int light) { + public void draw(GuiGraphics graphics, MultiBufferSource buffers, int light) { for(int i = 0; i < GRID_SIZE; i++) { for(int j = 0; j < GRID_SIZE; j++) { SpellPiece p = gridData[i][j]; if(p != null) { - ms.pushPose(); - ms.translate(i * 18, j * 18, 0); - p.draw(ms, buffers, light); - ms.popPose(); + graphics.pose().pushPose(); + graphics.pose().translate(i * 18, j * 18, 0); + p.draw(graphics, buffers, light); + graphics.pose().popPose(); } } } diff --git a/src/main/java/vazkii/psi/api/spell/SpellPiece.java b/src/main/java/vazkii/psi/api/spell/SpellPiece.java index a8bf9cf0..2b19cd77 100644 --- a/src/main/java/vazkii/psi/api/spell/SpellPiece.java +++ b/src/main/java/vazkii/psi/api/spell/SpellPiece.java @@ -12,11 +12,11 @@ import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.DefaultVertexFormat; -import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexFormat; import net.minecraft.ChatFormatting; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.MultiBufferSource; @@ -279,19 +279,19 @@ public void setStatLabel(EnumSpellStat type, StatLabel descriptor) { * To avoid z-fighting in the TE projection, translations are applied every step. */ @OnlyIn(Dist.CLIENT) - public void draw(PoseStack ms, MultiBufferSource buffers, int light) { - ms.pushPose(); - drawBackground(ms, buffers, light); - ms.translate(0F, 0F, 0.1F); - drawAdditional(ms, buffers, light); + public void draw(GuiGraphics graphics, MultiBufferSource buffers, int light) { + graphics.pose().pushPose(); + drawBackground(graphics, buffers, light); + graphics.pose().translate(0F, 0F, 0.1F); + drawAdditional(graphics, buffers, light); if(isInGrid) { - ms.translate(0F, 0F, 0.1F); - drawParams(ms, buffers, light); - ms.translate(0F, 0F, 0.1F); - drawComment(ms, buffers, light); + graphics.pose().translate(0F, 0F, 0.1F); + drawParams(graphics, buffers, light); + graphics.pose().translate(0F, 0F, 0.1F); + drawComment(graphics, buffers, light); } - ms.popPose(); + graphics.pose().popPose(); } @OnlyIn(Dist.CLIENT) @@ -319,10 +319,10 @@ public static RenderType getLayer() { * Draws this piece's background. */ @OnlyIn(Dist.CLIENT) - public void drawBackground(PoseStack ms, MultiBufferSource buffers, int light) { + public void drawBackground(GuiGraphics graphics, MultiBufferSource buffers, int light) { Material material = ClientPsiAPI.getSpellPieceMaterial(registryKey); VertexConsumer buffer = material.buffer(buffers, ignored -> getLayer()); - Matrix4f mat = ms.last().pose(); + Matrix4f mat = graphics.pose().last().pose(); // Cannot call .texture() on the chained object because SpriteAwareVertexBuilder is buggy // and does not return itself, it returns the inner buffer // This leads to .texture() using the implementation of the inner buffer, @@ -346,7 +346,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 +354,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 +363,7 @@ public void drawComment(PoseStack ms, MultiBufferSource buffers, int light) { float minV = 184 / 256F; float maxU = (150 + wh) / 256F; float maxV = (184 + wh) / 256F; - Matrix4f mat = ms.last().pose(); + Matrix4f mat = graphics.pose().last().pose(); buffer.vertex(mat, -2, 4, 0).color(1F, 1F, 1F, 1F).uv(minU, maxV).uv2(light).endVertex(); buffer.vertex(mat, 4, 4, 0).color(1F, 1F, 1F, 1F).uv(maxU, maxV).uv2(light).endVertex(); @@ -376,15 +376,15 @@ public void drawComment(PoseStack ms, MultiBufferSource buffers, int light) { * Draws the parameters coming into this piece. */ @OnlyIn(Dist.CLIENT) - public void drawParams(PoseStack ms, MultiBufferSource buffers, int light) { + public void drawParams(GuiGraphics graphics, MultiBufferSource buffers, int light) { VertexConsumer buffer = buffers.getBuffer(PsiAPI.internalHandler.getProgrammerLayer()); for(SpellParam param : paramSides.keySet()) { - drawParam(ms, buffer, light, param); + drawParam(graphics, buffer, light, param); } } @OnlyIn(Dist.CLIENT) - public void drawParam(PoseStack ms, VertexConsumer buffer, int light, SpellParam param) { + public void drawParam(GuiGraphics graphics, VertexConsumer buffer, int light, SpellParam param) { SpellParam.Side side = paramSides.get(param); if(!side.isEnabled() || param.getArrowType() == ArrowType.NONE) { return; @@ -405,11 +405,11 @@ public void drawParam(PoseStack ms, VertexConsumer buffer, int light, SpellParam if(count > 1) { percent = (float) index / (count - 1); } - drawParam(ms, buffer, light, side, param.color, param.getArrowType(), percent); + drawParam(graphics, buffer, light, side, param.color, param.getArrowType(), percent); } @OnlyIn(Dist.CLIENT) - public void drawParam(PoseStack ms, VertexConsumer buffer, int light, SpellParam.Side side, int color, SpellParam.ArrowType arrowType, float percent) { + public void drawParam(GuiGraphics graphics, VertexConsumer buffer, int light, SpellParam.Side side, int color, SpellParam.ArrowType arrowType, float percent) { if(arrowType == ArrowType.NONE) { return; } @@ -432,7 +432,7 @@ public void drawParam(PoseStack ms, VertexConsumer buffer, int light, SpellParam int g = PsiRenderHelper.g(color); int b = PsiRenderHelper.b(color); int a = 255; - Matrix4f mat = ms.last().pose(); + Matrix4f mat = graphics.pose().last().pose(); buffer.vertex(mat, minX, maxY, 0).color(r, g, b, a).uv(minU, maxV).uv2(light).endVertex(); buffer.vertex(mat, maxX, maxY, 0).color(r, g, b, a).uv(maxU, maxV).uv2(light).endVertex(); @@ -470,16 +470,16 @@ public int getParamArrowIndex(SpellParam param) { * Draws this piece's tooltip. */ @OnlyIn(Dist.CLIENT) - public void drawTooltip(PoseStack ms, int tooltipX, int tooltipY, List 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/handler/HUDHandler.java b/src/main/java/vazkii/psi/client/core/handler/HUDHandler.java index 40d79ca2..efd2c4df 100644 --- a/src/main/java/vazkii/psi/client/core/handler/HUDHandler.java +++ b/src/main/java/vazkii/psi/client/core/handler/HUDHandler.java @@ -9,7 +9,6 @@ package vazkii.psi.client.core.handler; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; 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..bbff4b83 100644 --- a/src/main/java/vazkii/psi/client/core/proxy/ClientProxy.java +++ b/src/main/java/vazkii/psi/client/core/proxy/ClientProxy.java @@ -15,7 +15,6 @@ import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.resources.model.Material; -import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.core.particles.ParticleOptions; import net.minecraft.resources.ResourceLocation; @@ -111,8 +110,12 @@ private void addCADModels(ModelEvent.RegisterAdditional event) { event.register(new ResourceLocation(LibMisc.MOD_ID, "item/" + LibItemNames.CAD_EBONY_PSIMETAL)); event.register(new ResourceLocation(LibMisc.MOD_ID, "item/" + LibItemNames.CAD_IVORY_PSIMETAL)); event.register(new ResourceLocation(LibMisc.MOD_ID, "item/" + LibItemNames.CAD_CREATIVE)); //TODO models - ModelBakery.UNREFERENCED_TEXTURES.addAll(ClientPsiAPI.getAllSpellPieceMaterial()); - ModelBakery.UNREFERENCED_TEXTURES.add(new Material(ClientPsiAPI.PSI_PIECE_TEXTURE_ATLAS, PieceConnector.LINES_TEXTURE)); + //ModelBakery.UNREFERENCED_TEXTURES.addAll(ClientPsiAPI.getAllSpellPieceMaterial()); + //ModelBakery.UNREFERENCED_TEXTURES.add(new Material(ClientPsiAPI.PSI_PIECE_TEXTURE_ATLAS, PieceConnector.LINES_TEXTURE)); + for(Material spellpieceMaterial : ClientPsiAPI.getAllSpellPieceMaterial()) { + event.register(spellpieceMaterial.texture()); + } + event.register(PieceConnector.LINES_TEXTURE); } @Override diff --git a/src/main/java/vazkii/psi/client/fx/SparkleParticleType.java b/src/main/java/vazkii/psi/client/fx/SparkleParticleType.java index 15ca980f..d0bf4ab0 100644 --- a/src/main/java/vazkii/psi/client/fx/SparkleParticleType.java +++ b/src/main/java/vazkii/psi/client/fx/SparkleParticleType.java @@ -11,7 +11,6 @@ import com.mojang.serialization.Codec; import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.ParticleProvider; import net.minecraft.client.particle.SpriteSet; import net.minecraft.client.particle.TextureSheetParticle; diff --git a/src/main/java/vazkii/psi/client/fx/WispParticleType.java b/src/main/java/vazkii/psi/client/fx/WispParticleType.java index ceb18c03..775a3f99 100644 --- a/src/main/java/vazkii/psi/client/fx/WispParticleType.java +++ b/src/main/java/vazkii/psi/client/fx/WispParticleType.java @@ -11,7 +11,6 @@ import com.mojang.serialization.Codec; import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.ParticleProvider; import net.minecraft.client.particle.SpriteSet; import net.minecraft.client.particle.TextureSheetParticle; diff --git a/src/main/java/vazkii/psi/client/gui/GuiCADAssembler.java b/src/main/java/vazkii/psi/client/gui/GuiCADAssembler.java index 5ec604da..6c7aec01 100644 --- a/src/main/java/vazkii/psi/client/gui/GuiCADAssembler.java +++ b/src/main/java/vazkii/psi/client/gui/GuiCADAssembler.java @@ -8,14 +8,11 @@ */ package vazkii.psi.client.gui; -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.screens.inventory.AbstractContainerScreen; import net.minecraft.client.resources.language.I18n; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.Style; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; @@ -44,19 +41,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 +63,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..30735990 100644 --- a/src/main/java/vazkii/psi/client/gui/GuiSocketSelect.java +++ b/src/main/java/vazkii/psi/client/gui/GuiSocketSelect.java @@ -13,13 +13,13 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.BufferBuilder; import com.mojang.blaze3d.vertex.DefaultVertexFormat; -import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.Tesselator; import com.mojang.blaze3d.vertex.VertexFormat; 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 +96,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 +118,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 +181,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 +205,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 +214,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 +251,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..91d48ec4 100644 --- a/src/main/java/vazkii/psi/client/gui/button/GuiButtonHelp.java +++ b/src/main/java/vazkii/psi/client/gui/button/GuiButtonHelp.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.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 +23,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..c8049cc9 100644 --- a/src/main/java/vazkii/psi/client/gui/button/GuiButtonPage.java +++ b/src/main/java/vazkii/psi/client/gui/button/GuiButtonPage.java @@ -8,9 +8,7 @@ */ package vazkii.psi.client.gui.button; -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 +19,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..82e401c7 100644 --- a/src/main/java/vazkii/psi/client/gui/button/GuiButtonSpellPiece.java +++ b/src/main/java/vazkii/psi/client/gui/button/GuiButtonSpellPiece.java @@ -8,10 +8,9 @@ */ package vazkii.psi.client.gui.button; -import com.mojang.blaze3d.systems.RenderSystem; -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 +22,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/PiecePanelWidget.java b/src/main/java/vazkii/psi/client/gui/widget/PiecePanelWidget.java index f0e32899..68dab964 100644 --- a/src/main/java/vazkii/psi/client/gui/widget/PiecePanelWidget.java +++ b/src/main/java/vazkii/psi/client/gui/widget/PiecePanelWidget.java @@ -69,7 +69,7 @@ public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float pTi graphics.fill(panelPieceX - 1, panelPieceY - 1, panelPieceX + 17, panelPieceY + 17, 0x559999FF); } - graphics.setColor(1f, 1f, 1f ,1f); + graphics.setColor(1f, 1f, 1f, 1f); graphics.blit(GuiProgrammer.texture, searchField.getX() - 14, searchField.getY() - 2, 0, parent.ySize + 16, 12, 12); String s = Math.min(Math.max(getPageCount(), 1), page + 1) + "/" + Math.max(getPageCount(), 1); @@ -241,7 +241,7 @@ public void updatePanelButtons() { } else if(button instanceof GuiButtonPage) { GuiButtonPage page = (GuiButtonPage) button; if(page.isRight() && this.page < getPageCount() - 1) { - page.setX( getX() + width - 22); + page.setX(getX() + width - 22); page.setY(getY() + height - 15); page.visible = true; page.active = true; 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..e655f54a 100644 --- a/src/main/java/vazkii/psi/client/gui/widget/SideConfigWidget.java +++ b/src/main/java/vazkii/psi/client/gui/widget/SideConfigWidget.java @@ -9,10 +9,9 @@ package vazkii.psi.client.gui.widget; import com.mojang.blaze3d.platform.InputConstants; -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.AbstractWidget; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.narration.NarrationElementOutput; @@ -45,15 +44,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 +67,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 +84,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..19458a45 100644 --- a/src/main/java/vazkii/psi/client/gui/widget/SpellCostsWidget.java +++ b/src/main/java/vazkii/psi/client/gui/widget/SpellCostsWidget.java @@ -8,10 +8,8 @@ */ package vazkii.psi.client.gui.widget; -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.AbstractWidget; import net.minecraft.client.gui.narration.NarrationElementOutput; import net.minecraft.network.chat.Component; @@ -41,7 +39,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 +65,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 +80,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..086465d6 100644 --- a/src/main/java/vazkii/psi/client/gui/widget/StatusWidget.java +++ b/src/main/java/vazkii/psi/client/gui/widget/StatusWidget.java @@ -8,10 +8,8 @@ */ package vazkii.psi.client.gui.widget; -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.AbstractWidget; import net.minecraft.client.gui.narration.NarrationElementOutput; import net.minecraft.network.chat.Component; @@ -20,7 +18,6 @@ import org.apache.commons.lang3.tuple.Pair; import vazkii.psi.api.PsiAPI; -import vazkii.psi.api.internal.PsiRenderHelper; import vazkii.psi.api.spell.SpellCompilationException; import vazkii.psi.client.gui.GuiProgrammer; @@ -39,11 +36,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 +61,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)); @@ -74,7 +70,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/jei/JEICompat.java b/src/main/java/vazkii/psi/client/jei/JEICompat.java index 57d7b05d..ad10ea5c 100644 --- a/src/main/java/vazkii/psi/client/jei/JEICompat.java +++ b/src/main/java/vazkii/psi/client/jei/JEICompat.java @@ -14,9 +14,7 @@ import mezz.jei.api.registration.*; import net.minecraft.client.Minecraft; -import net.minecraft.core.NonNullList; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.ItemStack; import vazkii.psi.client.jei.crafting.BulletToDriveExtension; @@ -25,11 +23,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 +61,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..c0ee8c02 100644 --- a/src/main/java/vazkii/psi/client/jei/crafting/BulletToDriveExtension.java +++ b/src/main/java/vazkii/psi/client/jei/crafting/BulletToDriveExtension.java @@ -9,7 +9,6 @@ package vazkii.psi.client.jei.crafting; import com.google.common.collect.ImmutableList; -import com.mojang.blaze3d.vertex.PoseStack; import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; @@ -17,11 +16,13 @@ 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.resources.language.I18n; -import net.minecraft.core.Registry; +import net.minecraft.client.gui.GuiGraphics; +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 +43,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,8 +65,8 @@ 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 } 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..a6749189 100644 --- a/src/main/java/vazkii/psi/client/jei/crafting/DriveDuplicateExtension.java +++ b/src/main/java/vazkii/psi/client/jei/crafting/DriveDuplicateExtension.java @@ -9,7 +9,6 @@ package vazkii.psi.client.jei.crafting; import com.google.common.collect.ImmutableList; -import com.mojang.blaze3d.vertex.PoseStack; import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; @@ -19,7 +18,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 +57,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..d73a33cb 100644 --- a/src/main/java/vazkii/psi/client/jei/tricks/DrawablePiece.java +++ b/src/main/java/vazkii/psi/client/jei/tricks/DrawablePiece.java @@ -8,7 +8,6 @@ */ package vazkii.psi.client.jei.tricks; -import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.Tesselator; import mezz.jei.api.gui.drawable.IDrawableStatic; @@ -32,7 +31,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/jei/tricks/TrickCraftingCategory.java b/src/main/java/vazkii/psi/client/jei/tricks/TrickCraftingCategory.java index 51ec02f4..ed2be2bb 100644 --- a/src/main/java/vazkii/psi/client/jei/tricks/TrickCraftingCategory.java +++ b/src/main/java/vazkii/psi/client/jei/tricks/TrickCraftingCategory.java @@ -8,8 +8,6 @@ */ package vazkii.psi.client.jei.tricks; -import com.mojang.blaze3d.vertex.PoseStack; - import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; import mezz.jei.api.gui.drawable.IDrawable; diff --git a/src/main/java/vazkii/psi/client/patchouli/SpellGridComponent.java b/src/main/java/vazkii/psi/client/patchouli/SpellGridComponent.java index 664db0cf..07454dae 100644 --- a/src/main/java/vazkii/psi/client/patchouli/SpellGridComponent.java +++ b/src/main/java/vazkii/psi/client/patchouli/SpellGridComponent.java @@ -54,7 +54,6 @@ public void build(int componentX, int componentY, int pageNum) { } } - @Override public void render(GuiGraphics graphics, IComponentRenderContext context, float pticks, int mouseX, int mouseY) { float scale = 0.65f; @@ -73,7 +72,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..252d1f84 100644 --- a/src/main/java/vazkii/psi/client/patchouli/SpellPieceComponent.java +++ b/src/main/java/vazkii/psi/client/patchouli/SpellPieceComponent.java @@ -8,7 +8,6 @@ */ package vazkii.psi.client.patchouli; -import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.Tesselator; import net.minecraft.client.gui.GuiGraphics; @@ -44,7 +43,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..073d024d 100644 --- a/src/main/java/vazkii/psi/client/render/entity/RenderSpellCircle.java +++ b/src/main/java/vazkii/psi/client/render/entity/RenderSpellCircle.java @@ -23,7 +23,7 @@ import net.minecraft.world.item.ItemStack; import org.joml.Matrix4f; -import org.joml.Vector3f; +import org.joml.Quaternionf; import vazkii.psi.api.internal.PsiRenderHelper; import vazkii.psi.client.model.ArmorModels; @@ -82,7 +82,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..6260f2cc 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); @@ -96,7 +99,7 @@ public void render(TileProgrammer te, float partialticks, PoseStack ms, MultiBuf int color = Psi.magical ? 0 : 0xFFFFFF; Minecraft mc = Minecraft.getInstance(); - mc.font.drawInBatch(I18n.get("psimisc.name"), 0, 164, color, false, ms.last().pose(), buffers, Font.DisplayMode.NORMAL, 0, 0xF000F0); + mc.font.drawInBatch(I18n.get("psimisc.name"), 0, 164, color, false, ms.last().pose(), buffers, Font.DisplayMode.NORMAL, 0, 0xF000F0); mc.font.drawInBatch(te.spell.name, 38, 164, color, false, ms.last().pose(), buffers, Font.DisplayMode.NORMAL, 0, 0xF000F0); ms.popPose(); 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..1102e8d7 100644 --- a/src/main/java/vazkii/psi/common/core/PsiCreativeTab.java +++ b/src/main/java/vazkii/psi/common/core/PsiCreativeTab.java @@ -8,36 +8,38 @@ */ 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/DamageTypeHandler.java b/src/main/java/vazkii/psi/common/core/handler/DamageTypeHandler.java index 038bd7a9..34bf3f7f 100644 --- a/src/main/java/vazkii/psi/common/core/handler/DamageTypeHandler.java +++ b/src/main/java/vazkii/psi/common/core/handler/DamageTypeHandler.java @@ -9,30 +9,13 @@ package vazkii.psi.common.core.handler; import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceLocation; import net.minecraft.world.damagesource.DamageType; -import net.minecraft.world.item.crafting.Recipe; -import net.minecraft.world.item.crafting.RecipeType; -import net.minecraftforge.common.crafting.CraftingHelper; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegisterEvent; -import net.minecraftforge.registries.RegistryManager; -import vazkii.psi.api.recipe.ITrickRecipe; -import vazkii.psi.common.crafting.recipe.AssemblyScavengeRecipe; -import vazkii.psi.common.crafting.recipe.BulletToDriveRecipe; -import vazkii.psi.common.crafting.recipe.BulletUpgradeRecipe; -import vazkii.psi.common.crafting.recipe.ColorizerChangeRecipe; -import vazkii.psi.common.crafting.recipe.DimensionTrickRecipe; -import vazkii.psi.common.crafting.recipe.DriveDuplicateRecipe; -import vazkii.psi.common.crafting.recipe.SensorAttachRecipe; -import vazkii.psi.common.crafting.recipe.SensorRemoveRecipe; -import vazkii.psi.common.crafting.recipe.TrickRecipe; import vazkii.psi.common.lib.LibMisc; import vazkii.psi.common.lib.LibResources; -import vazkii.psi.data.MagicalPsiCondition; @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, modid = LibMisc.MOD_ID) public class DamageTypeHandler { 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..5df9cf88 100644 --- a/src/main/java/vazkii/psi/common/core/handler/InternalMethodHandler.java +++ b/src/main/java/vazkii/psi/common/core/handler/InternalMethodHandler.java @@ -8,10 +8,9 @@ */ package vazkii.psi.common.core.handler; -import com.mojang.blaze3d.vertex.PoseStack; - 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 +65,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 +77,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..421b3ff5 100644 --- a/src/main/java/vazkii/psi/common/crafting/recipe/DimensionTrickRecipe.java +++ b/src/main/java/vazkii/psi/common/crafting/recipe/DimensionTrickRecipe.java @@ -10,7 +10,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 +36,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 +49,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 +57,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..71b691ac 100644 --- a/src/main/java/vazkii/psi/common/item/ItemCAD.java +++ b/src/main/java/vazkii/psi/common/item/ItemCAD.java @@ -10,7 +10,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; @@ -24,7 +24,6 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Rarity; @@ -317,7 +316,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 +338,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 +571,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 +613,7 @@ public void fillItemCategory(@Nonnull CreativeModeTab tab, @Nonnull NonNullList< new ItemStack(ModItems.cadSocketTransmissive), new ItemStack(ModItems.cadBatteryUltradense))); + return subItems; } @OnlyIn(Dist.CLIENT) @@ -657,7 +654,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/ItemVectorRuler.java b/src/main/java/vazkii/psi/common/item/ItemVectorRuler.java index ec140f00..1b7aa5c8 100644 --- a/src/main/java/vazkii/psi/common/item/ItemVectorRuler.java +++ b/src/main/java/vazkii/psi/common/item/ItemVectorRuler.java @@ -8,8 +8,6 @@ */ package vazkii.psi.common.item; -import com.mojang.blaze3d.vertex.PoseStack; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; 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..eb093a99 100644 --- a/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalExosuitBoots.java +++ b/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalExosuitBoots.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 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..dce61b97 100644 --- a/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalExosuitLeggings.java +++ b/src/main/java/vazkii/psi/common/item/armor/ItemPsimetalExosuitLeggings.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 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/IHUDItem.java b/src/main/java/vazkii/psi/common/item/base/IHUDItem.java index c84045f8..1c9985f1 100644 --- a/src/main/java/vazkii/psi/common/item/base/IHUDItem.java +++ b/src/main/java/vazkii/psi/common/item/base/IHUDItem.java @@ -8,8 +8,6 @@ */ package vazkii.psi.common.item.base; -import com.mojang.blaze3d.vertex.PoseStack; - import net.minecraft.client.gui.GuiGraphics; import net.minecraft.world.item.ItemStack; import net.minecraftforge.api.distmarker.Dist; 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..6b8aa9fa 100644 --- a/src/main/java/vazkii/psi/common/item/base/ModItems.java +++ b/src/main/java/vazkii/psi/common/item/base/ModItems.java @@ -9,7 +9,7 @@ package vazkii.psi.common.item.base; 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; @@ -17,7 +17,6 @@ import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegisterEvent; -import vazkii.psi.common.core.PsiCreativeTab; import vazkii.psi.common.item.*; import vazkii.psi.common.item.armor.ItemPsimetalExosuitBoots; import vazkii.psi.common.item.armor.ItemPsimetalExosuitChestplate; @@ -200,10 +199,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 +292,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/lib/ModTags.java b/src/main/java/vazkii/psi/common/lib/ModTags.java index ec5143fd..b85be694 100644 --- a/src/main/java/vazkii/psi/common/lib/ModTags.java +++ b/src/main/java/vazkii/psi/common/lib/ModTags.java @@ -8,14 +8,12 @@ */ package vazkii.psi.common.lib; -import net.minecraft.core.Registry; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; import net.minecraft.world.damagesource.DamageType; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; -import net.minecraftforge.registries.ForgeRegistries; public class ModTags { @@ -36,6 +34,7 @@ public class ModTags { public static final TagKey BLOCK_IVORY_PSIMETAL = forgeTag("storage_blocks/ivory_psimetal"); public static final TagKey PSI_OVERLOAD = damageTag(LibResources.PSI_DAMAGE_TYPE); + private static TagKey damageTag(ResourceLocation rl) { return TagKey.create(Registries.DAMAGE_TYPE, rl); } 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..2c4d53f7 100644 --- a/src/main/java/vazkii/psi/common/spell/constant/PieceConstantNumber.java +++ b/src/main/java/vazkii/psi/common/spell/constant/PieceConstantNumber.java @@ -8,9 +8,8 @@ */ package vazkii.psi.common.spell.constant; -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 +39,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 +54,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..aead4a90 100644 --- a/src/main/java/vazkii/psi/common/spell/other/PieceConnector.java +++ b/src/main/java/vazkii/psi/common/spell/other/PieceConnector.java @@ -8,9 +8,9 @@ */ package vazkii.psi.common.spell.other; -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 +54,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 +70,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 +99,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..4e840d42 100644 --- a/src/main/java/vazkii/psi/common/spell/other/PieceCrossConnector.java +++ b/src/main/java/vazkii/psi/common/spell/other/PieceCrossConnector.java @@ -8,9 +8,9 @@ */ package vazkii.psi.common.spell.other; -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 +80,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 +121,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..098a6d3d 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,12 +8,12 @@ */ 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; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.RecipeType; -import net.minecraft.world.item.crafting.SmeltingRecipe; import net.minecraft.world.level.Level; import vazkii.psi.api.spell.Spell; @@ -37,7 +37,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..d7f6fe76 100644 --- a/src/main/java/vazkii/psi/common/spell/trick/PieceTrickExplode.java +++ b/src/main/java/vazkii/psi/common/spell/trick/PieceTrickExplode.java @@ -9,7 +9,8 @@ package vazkii.psi.common.spell.trick; 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 +73,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..782a6128 100644 --- a/src/main/java/vazkii/psi/data/PsiBlockModelGenerator.java +++ b/src/main/java/vazkii/psi/data/PsiBlockModelGenerator.java @@ -8,7 +8,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 +21,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/PsiDamageTypeTagsProvider.java b/src/main/java/vazkii/psi/data/PsiDamageTypeTagsProvider.java index 510ff0ea..6728e0d5 100644 --- a/src/main/java/vazkii/psi/data/PsiDamageTypeTagsProvider.java +++ b/src/main/java/vazkii/psi/data/PsiDamageTypeTagsProvider.java @@ -26,7 +26,6 @@ protected void addTags(HolderLookup.Provider pProvider) { this.tag(DamageTypeTags.BYPASSES_ENCHANTMENTS).addTag(ModTags.PSI_OVERLOAD); } - @Override public String getName() { return "Psi damage type tags"; diff --git a/src/main/java/vazkii/psi/data/PsiItemModelGenerator.java b/src/main/java/vazkii/psi/data/PsiItemModelGenerator.java index 0e04b3d3..5b905231 100644 --- a/src/main/java/vazkii/psi/data/PsiItemModelGenerator.java +++ b/src/main/java/vazkii/psi/data/PsiItemModelGenerator.java @@ -8,7 +8,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 +22,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..e8357432 100644 --- a/src/main/java/vazkii/psi/data/PsiItemTagProvider.java +++ b/src/main/java/vazkii/psi/data/PsiItemTagProvider.java @@ -8,8 +8,11 @@ */ package vazkii.psi.data; -import net.minecraft.data.DataGenerator; +import net.minecraft.core.HolderLookup; +import net.minecraft.data.PackOutput; import net.minecraft.data.tags.ItemTagsProvider; +import net.minecraft.data.tags.TagsProvider; +import net.minecraft.world.level.block.Block; import net.minecraftforge.common.Tags; import net.minecraftforge.common.data.ExistingFileHelper; @@ -17,14 +20,16 @@ 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 +57,5 @@ protected void addTags() { public String getName() { return "Psi item tags"; } + } diff --git a/src/main/java/vazkii/psi/data/PsiRecipeGenerator.java b/src/main/java/vazkii/psi/data/PsiRecipeGenerator.java index 50ed301a..b7cc528e 100644 --- a/src/main/java/vazkii/psi/data/PsiRecipeGenerator.java +++ b/src/main/java/vazkii/psi/data/PsiRecipeGenerator.java @@ -47,6 +47,7 @@ public class PsiRecipeGenerator extends RecipeProvider implements IConditionBuil public PsiRecipeGenerator(PackOutput output) { super(output); } + @Override protected void buildRecipes(Consumer consumer) { specialRecipe(AssemblyScavengeRecipe.SERIALIZER, consumer); @@ -62,7 +63,7 @@ protected void buildRecipes(Consumer consumer) { CriterionTriggerInstance hasIvoryPsimetal = has(ModTags.INGOT_IVORY_PSIMETAL); CriterionTriggerInstance hasPsidust = has(ModTags.PSIDUST); - ShapedRecipeBuilder.shaped(RecipeCategory.MISC,ModBlocks.cadAssembler) + ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ModBlocks.cadAssembler) .define('I', Tags.Items.INGOTS_IRON) .define('P', Items.PISTON) .pattern("IPI") @@ -106,25 +107,25 @@ protected void buildRecipes(Consumer consumer) { .pattern("I ") .unlockedBy("has_gold", has(Tags.Items.INGOTS_GOLD)) .save(consumer, Psi.location("cad_assembly_gold")); - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.cadAssemblyPsimetal) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.cadAssemblyPsimetal) .define('I', ModTags.INGOT_PSIMETAL) .pattern("III") .pattern("I ") .unlockedBy("has_psimetal", hasPsimetal) .save(consumer, Psi.location("cad_assembly_psimetal")); - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.cadAssemblyEbony) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.cadAssemblyEbony) .define('I', ModTags.INGOT_EBONY_PSIMETAL) .pattern("III") .pattern("I ") .unlockedBy("has_ebony_psimetal", hasEbonyPsimetal) .save(consumer, Psi.location("cad_assembly_ebony")); - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.cadAssemblyIvory) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.cadAssemblyIvory) .define('I', ModTags.INGOT_IVORY_PSIMETAL) .pattern("III") .pattern("I ") .unlockedBy("has_ivory_psimetal", hasIvoryPsimetal) .save(consumer, Psi.location("cad_assembly_ivory")); - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.cadCoreBasic) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.cadCoreBasic) .define('I', Tags.Items.INGOTS_IRON) .define('D', ModTags.PSIDUST) .pattern(" I ") @@ -132,7 +133,7 @@ protected void buildRecipes(Consumer consumer) { .pattern(" I ") .unlockedBy("has_psidust", hasPsidust) .save(consumer, Psi.location("cad_core_basic")); - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.cadCoreOverclocked) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.cadCoreOverclocked) .define('I', ModTags.INGOT_PSIMETAL) .define('D', Tags.Items.DUSTS_REDSTONE) .pattern(" I ") @@ -140,7 +141,7 @@ protected void buildRecipes(Consumer consumer) { .pattern(" I ") .unlockedBy("has_psimetal", hasPsimetal) .save(consumer, Psi.location("cad_core_overclocked")); - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.cadCoreConductive) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.cadCoreConductive) .define('I', ModTags.INGOT_PSIMETAL) .define('D', Tags.Items.DUSTS_GLOWSTONE) .pattern(" I ") @@ -148,7 +149,7 @@ protected void buildRecipes(Consumer consumer) { .pattern(" I ") .unlockedBy("has_psimetal", hasPsimetal) .save(consumer, Psi.location("cad_core_conductive")); - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.cadCoreHyperClocked) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.cadCoreHyperClocked) .define('I', ModTags.INGOT_PSIMETAL) .define('D', Tags.Items.DUSTS_REDSTONE) .define('G', ModTags.GEM_PSIGEM) @@ -157,7 +158,7 @@ protected void buildRecipes(Consumer consumer) { .pattern(" G ") .unlockedBy("has_psimetal", hasPsimetal) .save(consumer, Psi.location("cad_core_hyperclocked")); - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.cadCoreRadiative) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.cadCoreRadiative) .define('I', ModTags.INGOT_PSIMETAL) .define('D', Tags.Items.DUSTS_GLOWSTONE) .define('G', ModTags.GEM_PSIGEM) @@ -166,28 +167,28 @@ protected void buildRecipes(Consumer consumer) { .pattern(" G ") .unlockedBy("has_psimetal", hasPsimetal) .save(consumer, Psi.location("cad_core_radiative")); - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.cadSocketBasic) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.cadSocketBasic) .define('I', Tags.Items.INGOTS_IRON) .define('D', ModTags.PSIDUST) .pattern("DI ") .pattern("I ") .unlockedBy("has_psidust", hasPsidust) .save(consumer, Psi.location("cad_socket_basic")); - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.cadSocketSignaling) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.cadSocketSignaling) .define('I', ModTags.INGOT_PSIMETAL) .define('D', Tags.Items.DUSTS_REDSTONE) .pattern("DI ") .pattern("I ") .unlockedBy("has_psimetal", hasPsimetal) .save(consumer, Psi.location("cad_socket_signaling")); - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.cadSocketLarge) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.cadSocketLarge) .define('I', ModTags.INGOT_PSIMETAL) .define('D', Tags.Items.DUSTS_GLOWSTONE) .pattern("DI ") .pattern("I ") .unlockedBy("has_psimetal", hasPsimetal) .save(consumer, Psi.location("cad_socket_large")); - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.cadSocketTransmissive) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.cadSocketTransmissive) .define('I', ModTags.INGOT_PSIMETAL) .define('D', Tags.Items.DUSTS_REDSTONE) .define('G', ModTags.GEM_PSIGEM) @@ -195,7 +196,7 @@ protected void buildRecipes(Consumer consumer) { .pattern("IG ") .unlockedBy("has_psimetal", hasPsimetal) .save(consumer, Psi.location("cad_socket_transmissive")); - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.cadSocketHuge) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.cadSocketHuge) .define('I', ModTags.INGOT_PSIMETAL) .define('D', Tags.Items.DUSTS_GLOWSTONE) .define('G', ModTags.GEM_PSIGEM) @@ -203,7 +204,7 @@ protected void buildRecipes(Consumer consumer) { .pattern("IG ") .unlockedBy("has_psimetal", hasPsimetal) .save(consumer, Psi.location("cad_socket_huge")); - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.cadBatteryBasic) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.cadBatteryBasic) .define('I', Tags.Items.INGOTS_IRON) .define('D', ModTags.PSIDUST) .define('G', Tags.Items.INGOTS_GOLD) @@ -212,7 +213,7 @@ protected void buildRecipes(Consumer consumer) { .pattern("G") .unlockedBy("has_psidust", hasPsidust) .save(consumer, Psi.location("cad_battery_basic")); - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.cadBatteryExtended) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.cadBatteryExtended) .define('I', Tags.Items.INGOTS_IRON) .define('D', ModTags.INGOT_PSIMETAL) .define('G', Tags.Items.INGOTS_GOLD) @@ -221,7 +222,7 @@ protected void buildRecipes(Consumer consumer) { .pattern("G") .unlockedBy("has_psimetal", hasPsimetal) .save(consumer, Psi.location("cad_battery_extended")); - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.cadBatteryUltradense) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.cadBatteryUltradense) .define('I', Tags.Items.INGOTS_IRON) .define('D', ModTags.GEM_PSIGEM) .define('G', Tags.Items.INGOTS_GOLD) @@ -245,7 +246,7 @@ protected void buildRecipes(Consumer consumer) { .save(consumer, Psi.location(LibItemNames.CAD_COLORIZER + color.getSerializedName())); } - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.cadColorizerRainbow) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.cadColorizerRainbow) .group("psi:colorizer") .define('D', ModTags.PSIDUST) .define('I', Tags.Items.INGOTS_IRON) @@ -256,7 +257,7 @@ protected void buildRecipes(Consumer consumer) { .pattern(" I ") .unlockedBy("has_psidust", hasPsidust) .save(consumer, Psi.location("cad_colorizer_rainbow")); - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.cadColorizerPsi) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.cadColorizerPsi) .group("psi:colorizer") .define('D', ModTags.PSIDUST) .define('I', Tags.Items.INGOTS_IRON) @@ -268,38 +269,38 @@ protected void buildRecipes(Consumer consumer) { .unlockedBy("has_psidust", hasPsidust) .save(consumer, Psi.location("cad_colorizer_psi")); - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.spellBullet) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.spellBullet) .define('I', Tags.Items.INGOTS_IRON) .define('D', ModTags.PSIDUST) .pattern("ID") .unlockedBy("has_psidust", hasPsidust) .save(consumer, Psi.location("spell_bullet_basic")); - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.projectileSpellBullet) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.projectileSpellBullet) .define('I', Tags.Items.INGOTS_IRON) .define('D', ModTags.PSIDUST) .define('A', ItemTags.ARROWS) .pattern("AID") .unlockedBy("has_psidust", hasPsidust) .save(consumer, Psi.location("spell_bullet_projectile")); - ShapelessRecipeBuilder.shapeless(RecipeCategory.TOOLS,ModItems.projectileSpellBullet) + ShapelessRecipeBuilder.shapeless(RecipeCategory.TOOLS, ModItems.projectileSpellBullet) .requires(ModItems.spellBullet) .requires(ItemTags.ARROWS) .unlockedBy("has_psidust", has(ModItems.psidust)) .save(WrapperResult.ofType(BulletUpgradeRecipe.SERIALIZER, consumer), Psi.location("spell_bullet_projectile_upgrade")); - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.loopSpellBullet) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.loopSpellBullet) .define('I', Tags.Items.INGOTS_IRON) .define('D', ModTags.PSIDUST) .define('A', Tags.Items.STRING) .pattern("AID") .unlockedBy("has_psidust", hasPsidust) .save(consumer, Psi.location("spell_bullet_loopcast")); - ShapelessRecipeBuilder.shapeless(RecipeCategory.TOOLS,ModItems.loopSpellBullet) + ShapelessRecipeBuilder.shapeless(RecipeCategory.TOOLS, ModItems.loopSpellBullet) .requires(ModItems.spellBullet) .requires(Tags.Items.STRING) .unlockedBy("has_psidust", has(ModItems.psidust)) .save(WrapperResult.ofType(BulletUpgradeRecipe.SERIALIZER, consumer), Psi.location("spell_bullet_loopcast_upgrade")); - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.circleSpellBullet) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.circleSpellBullet) .define('I', Tags.Items.INGOTS_IRON) .define('D', ModTags.PSIDUST) .define('A', Ingredient.fromValues(Stream.of( @@ -308,51 +309,51 @@ protected void buildRecipes(Consumer consumer) { .pattern("AID") .unlockedBy("has_psidust", hasPsidust) .save(consumer, Psi.location("spell_bullet_circle")); - ShapelessRecipeBuilder.shapeless(RecipeCategory.TOOLS,ModItems.circleSpellBullet) + ShapelessRecipeBuilder.shapeless(RecipeCategory.TOOLS, ModItems.circleSpellBullet) .requires(ModItems.spellBullet) .requires(Ingredient.fromValues(Stream.of( new Ingredient.TagValue(Tags.Items.SLIMEBALLS), new Ingredient.ItemValue(new ItemStack(Items.SNOWBALL))))) .unlockedBy("has_psidust", has(ModItems.psidust)) .save(WrapperResult.ofType(BulletUpgradeRecipe.SERIALIZER, consumer), Psi.location("spell_bullet_circle_upgrade")); - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.grenadeSpellBullet) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.grenadeSpellBullet) .define('I', Tags.Items.INGOTS_IRON) .define('D', ModTags.PSIDUST) .define('A', Tags.Items.GUNPOWDER) .pattern("AID") .unlockedBy("has_psidust", hasPsidust) .save(consumer, Psi.location("spell_bullet_grenade")); - ShapelessRecipeBuilder.shapeless(RecipeCategory.TOOLS,ModItems.grenadeSpellBullet) + ShapelessRecipeBuilder.shapeless(RecipeCategory.TOOLS, ModItems.grenadeSpellBullet) .requires(ModItems.spellBullet) .requires(Tags.Items.GUNPOWDER) .unlockedBy("has_psidust", has(ModItems.psidust)) .save(WrapperResult.ofType(BulletUpgradeRecipe.SERIALIZER, consumer), Psi.location("spell_bullet_grenade_upgrade")); - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.chargeSpellBullet) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.chargeSpellBullet) .define('I', Tags.Items.INGOTS_IRON) .define('D', ModTags.PSIDUST) .define('A', Tags.Items.DUSTS_REDSTONE) .pattern("AID") .unlockedBy("has_psidust", hasPsidust) .save(consumer, Psi.location("spell_bullet_charge")); - ShapelessRecipeBuilder.shapeless(RecipeCategory.TOOLS,ModItems.chargeSpellBullet) + ShapelessRecipeBuilder.shapeless(RecipeCategory.TOOLS, ModItems.chargeSpellBullet) .requires(ModItems.spellBullet) .requires(Tags.Items.DUSTS_REDSTONE) .unlockedBy("has_psidust", has(ModItems.psidust)) .save(WrapperResult.ofType(BulletUpgradeRecipe.SERIALIZER, consumer), Psi.location("spell_bullet_charge_upgrade")); - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.mineSpellBullet) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.mineSpellBullet) .define('I', Tags.Items.INGOTS_IRON) .define('D', ModTags.PSIDUST) .define('A', ItemTags.BUTTONS) .pattern("AID") .unlockedBy("has_psidust", hasPsidust) .save(consumer, Psi.location("spell_bullet_mine")); - ShapelessRecipeBuilder.shapeless(RecipeCategory.TOOLS,ModItems.mineSpellBullet) + ShapelessRecipeBuilder.shapeless(RecipeCategory.TOOLS, ModItems.mineSpellBullet) .requires(ModItems.spellBullet) .requires(ItemTags.BUTTONS) .unlockedBy("has_psidust", has(ModItems.psidust)) .save(WrapperResult.ofType(BulletUpgradeRecipe.SERIALIZER, consumer), Psi.location("spell_bullet_mine_upgrade")); - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.spellDrive) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.spellDrive) .define('I', ModTags.INGOT_PSIMETAL) .define('R', Tags.Items.DUSTS_REDSTONE) .pattern("I") @@ -360,7 +361,7 @@ protected void buildRecipes(Consumer consumer) { .pattern("I") .unlockedBy("has_psimetal", hasPsimetal) .save(consumer, Psi.location("spell_drive")); - ShapedRecipeBuilder.shaped(RecipeCategory.COMBAT,ModItems.psimetalShovel) + ShapedRecipeBuilder.shaped(RecipeCategory.COMBAT, ModItems.psimetalShovel) .define('P', ModTags.INGOT_PSIMETAL) .define('G', ModTags.GEM_PSIGEM) .define('I', Tags.Items.INGOTS_IRON) @@ -369,7 +370,7 @@ protected void buildRecipes(Consumer consumer) { .pattern(" I") .unlockedBy("has_psimetal", hasPsimetal) .save(consumer, Psi.location("psimetal_shovel")); - ShapedRecipeBuilder.shaped(RecipeCategory.COMBAT,ModItems.psimetalPickaxe) + ShapedRecipeBuilder.shaped(RecipeCategory.COMBAT, ModItems.psimetalPickaxe) .define('P', ModTags.INGOT_PSIMETAL) .define('G', ModTags.GEM_PSIGEM) .define('I', Tags.Items.INGOTS_IRON) @@ -378,7 +379,7 @@ protected void buildRecipes(Consumer consumer) { .pattern(" I ") .unlockedBy("has_psimetal", hasPsimetal) .save(consumer, Psi.location("psimetal_pickaxe")); - ShapedRecipeBuilder.shaped(RecipeCategory.COMBAT,ModItems.psimetalAxe) + ShapedRecipeBuilder.shaped(RecipeCategory.COMBAT, ModItems.psimetalAxe) .define('P', ModTags.INGOT_PSIMETAL) .define('G', ModTags.GEM_PSIGEM) .define('I', Tags.Items.INGOTS_IRON) @@ -387,7 +388,7 @@ protected void buildRecipes(Consumer consumer) { .pattern(" I") .unlockedBy("has_psimetal", hasPsimetal) .save(consumer, Psi.location("psimetal_axe")); - ShapedRecipeBuilder.shaped(RecipeCategory.COMBAT,ModItems.psimetalSword) + ShapedRecipeBuilder.shaped(RecipeCategory.COMBAT, ModItems.psimetalSword) .define('P', ModTags.INGOT_PSIMETAL) .define('G', ModTags.GEM_PSIGEM) .define('I', Tags.Items.INGOTS_IRON) @@ -443,7 +444,7 @@ protected void buildRecipes(Consumer consumer) { .pattern("I") .unlockedBy("has_psimetal", hasPsimetal) .save(consumer, Psi.location("exosuit_controller")); - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.vectorRuler) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.vectorRuler) .define('D', ModTags.PSIDUST) .define('I', Tags.Items.INGOTS_IRON) .pattern("D") @@ -451,7 +452,7 @@ protected void buildRecipes(Consumer consumer) { .pattern("I") .unlockedBy("has_psidust", hasPsidust) .save(consumer, Psi.location("vector_ruler")); - ShapedRecipeBuilder.shaped(RecipeCategory.MISC,ModItems.exosuitSensorLight) + ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ModItems.exosuitSensorLight) .define('M', Tags.Items.DUSTS_GLOWSTONE) .define('R', Tags.Items.INGOTS_IRON) .define('I', ModTags.INGOT_PSIMETAL) @@ -460,7 +461,7 @@ protected void buildRecipes(Consumer consumer) { .pattern(" R ") .unlockedBy("has_psimetal", hasPsimetal) .save(consumer, Psi.location("exosuit_sensor_light")); - ShapedRecipeBuilder.shaped(RecipeCategory.MISC,ModItems.exosuitSensorWater) + ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ModItems.exosuitSensorWater) .define('M', Tags.Items.GEMS_PRISMARINE) .define('R', Tags.Items.INGOTS_IRON) .define('I', ModTags.INGOT_PSIMETAL) @@ -469,7 +470,7 @@ protected void buildRecipes(Consumer consumer) { .pattern(" R ") .unlockedBy("has_psimetal", hasPsimetal) .save(consumer, Psi.location("exosuit_sensor_water")); - ShapedRecipeBuilder.shaped(RecipeCategory.MISC,ModItems.exosuitSensorHeat) + ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ModItems.exosuitSensorHeat) .define('M', Items.FIRE_CHARGE) .define('R', Tags.Items.INGOTS_IRON) .define('I', ModTags.INGOT_PSIMETAL) @@ -478,7 +479,7 @@ protected void buildRecipes(Consumer consumer) { .pattern(" R ") .unlockedBy("has_psimetal", hasPsimetal) .save(consumer, Psi.location("exosuit_sensor_heat")); - ShapedRecipeBuilder.shaped(RecipeCategory.MISC,ModItems.exosuitSensorStress) + ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ModItems.exosuitSensorStress) .define('M', Items.GLISTERING_MELON_SLICE) .define('R', Tags.Items.INGOTS_IRON) .define('I', ModTags.INGOT_PSIMETAL) @@ -487,7 +488,7 @@ protected void buildRecipes(Consumer consumer) { .pattern(" R ") .unlockedBy("has_psimetal", hasPsimetal) .save(consumer, Psi.location("exosuit_sensor_stress")); - ShapedRecipeBuilder.shaped(RecipeCategory.MISC,ModItems.exosuitSensorTrigger) + ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ModItems.exosuitSensorTrigger) .define('M', Items.GUNPOWDER) .define('R', Tags.Items.INGOTS_IRON) .define('I', ModTags.INGOT_PSIMETAL) @@ -496,7 +497,7 @@ protected void buildRecipes(Consumer consumer) { .pattern(" R ") .unlockedBy("has_psimetal", hasPsimetal) .save(consumer, Psi.location("exosuit_sensor_trigger")); - ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS,ModItems.cadColorizerEmpty) + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, ModItems.cadColorizerEmpty) .define('D', ModTags.PSIDUST) .define('G', Tags.Items.GLASS) .define('I', Tags.Items.INGOTS_IRON) @@ -505,7 +506,7 @@ protected void buildRecipes(Consumer consumer) { .pattern(" I ") .unlockedBy("has_psidust", hasPsidust) .save(consumer, Psi.location("cad_colorizer_empty")); - ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS,ModBlocks.psidustBlock.asItem()) + ShapedRecipeBuilder.shaped(RecipeCategory.BUILDING_BLOCKS, ModBlocks.psidustBlock.asItem()) .define('I', ModItems.psidust) .pattern("III") .pattern("III") @@ -568,7 +569,7 @@ protected void buildRecipes(Consumer consumer) { .pattern(" C ") .unlockedBy("has_psimetal", hasPsimetal) .save(consumer, Psi.location("psimetal_plate_black")); - ShapedRecipeBuilder.shaped(RecipeCategory.DECORATIONS,ModBlocks.psimetalPlateWhite.asItem()) + ShapedRecipeBuilder.shaped(RecipeCategory.DECORATIONS, ModBlocks.psimetalPlateWhite.asItem()) .define('C', Tags.Items.GEMS_QUARTZ) .define('I', ModTags.INGOT_PSIMETAL) .pattern(" C ") @@ -576,12 +577,12 @@ protected void buildRecipes(Consumer consumer) { .pattern(" C ") .unlockedBy("has_psimetal", hasPsimetal) .save(consumer, Psi.location("psimetal_plate_white")); - ShapelessRecipeBuilder.shapeless(RecipeCategory.DECORATIONS,ModBlocks.psimetalPlateBlackLight.asItem()) + ShapelessRecipeBuilder.shapeless(RecipeCategory.DECORATIONS, ModBlocks.psimetalPlateBlackLight.asItem()) .requires(Tags.Items.DUSTS_GLOWSTONE) .requires(ModBlocks.psimetalPlateBlack.asItem()) .unlockedBy("has_psimetal", hasPsimetal) .save(consumer, Psi.location("psimetal_plate_black_light")); - ShapelessRecipeBuilder.shapeless(RecipeCategory.DECORATIONS,ModBlocks.psimetalPlateWhiteLight.asItem()) + ShapelessRecipeBuilder.shapeless(RecipeCategory.DECORATIONS, ModBlocks.psimetalPlateWhiteLight.asItem()) .requires(Tags.Items.DUSTS_GLOWSTONE) .requires(ModBlocks.psimetalPlateWhite.asItem()) .unlockedBy("has_psimetal", hasPsimetal) diff --git a/src/main/java/vazkii/psi/data/PsiTrickRecipeGenerator.java b/src/main/java/vazkii/psi/data/PsiTrickRecipeGenerator.java index dd0cd843..2d47f99b 100644 --- a/src/main/java/vazkii/psi/data/PsiTrickRecipeGenerator.java +++ b/src/main/java/vazkii/psi/data/PsiTrickRecipeGenerator.java @@ -10,7 +10,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 +35,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,12 +73,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) { parent.accept(new DimensionResult(id, builder, dimensionKey)); diff --git a/src/main/java/vazkii/psi/data/WrapperResult.java b/src/main/java/vazkii/psi/data/WrapperResult.java index 1b8a65e6..d48306c3 100644 --- a/src/main/java/vazkii/psi/data/WrapperResult.java +++ b/src/main/java/vazkii/psi/data/WrapperResult.java @@ -10,10 +10,10 @@ import com.google.gson.JsonObject; -import net.minecraft.core.Registry; 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 +63,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; }