From 9af5c760c166fe19f09594554bbf985505a44803 Mon Sep 17 00:00:00 2001 From: BlayTheNinth <1933180+BlayTheNinth@users.noreply.github.com> Date: Thu, 23 May 2024 09:46:05 +0200 Subject: [PATCH] fix: Apply implicit components (probably not necessary in my case but may as well) --- .../waystones/block/entity/WarpPlateBlockEntity.java | 8 ++++++++ .../block/entity/WaystoneBlockEntityBase.java | 10 +++++++++- .../waystones/client/gui/screen/WaystoneScreen.java | 2 -- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/net/blay09/mods/waystones/block/entity/WarpPlateBlockEntity.java b/common/src/main/java/net/blay09/mods/waystones/block/entity/WarpPlateBlockEntity.java index 535a49a7..d1ee9310 100644 --- a/common/src/main/java/net/blay09/mods/waystones/block/entity/WarpPlateBlockEntity.java +++ b/common/src/main/java/net/blay09/mods/waystones/block/entity/WarpPlateBlockEntity.java @@ -80,6 +80,14 @@ protected ResourceLocation getWaystoneType() { return WaystoneTypes.WARP_PLATE; } + @Override + protected void applyImplicitComponents(DataComponentInput input) { + super.applyImplicitComponents(input); + if (input.get(ModComponents.warpPlateCompletedFirstAttunement.get()) != null) { + completedFirstAttunement = true; + } + } + @Override protected void collectImplicitComponents(DataComponentMap.Builder builder) { super.collectImplicitComponents(builder); diff --git a/common/src/main/java/net/blay09/mods/waystones/block/entity/WaystoneBlockEntityBase.java b/common/src/main/java/net/blay09/mods/waystones/block/entity/WaystoneBlockEntityBase.java index c8d59909..6129afd2 100644 --- a/common/src/main/java/net/blay09/mods/waystones/block/entity/WaystoneBlockEntityBase.java +++ b/common/src/main/java/net/blay09/mods/waystones/block/entity/WaystoneBlockEntityBase.java @@ -65,7 +65,7 @@ public int getCount() { private final NonNullList items = NonNullList.withSize(5, ItemStack.EMPTY); private boolean readyForAttunement; - private boolean completedFirstAttunement; + protected boolean completedFirstAttunement; protected int attunementTicks; private Waystone waystone = InvalidWaystone.INSTANCE; @@ -109,6 +109,14 @@ public void loadAdditional(CompoundTag compound, HolderLookup.Provider provider) completedFirstAttunement = compound.getBoolean("CompletedFirstAttunement"); } + @Override + protected void applyImplicitComponents(DataComponentInput input) { + final var waystoneUidComponent = input.get(ModComponents.waystone.get()); + if (waystoneUidComponent != null) { + waystoneUid = waystoneUidComponent; + } + } + @Override protected void collectImplicitComponents(DataComponentMap.Builder builder) { builder.set(ModComponents.waystone.get(), waystone.isValid() ? waystone.getWaystoneUid() : waystoneUid); diff --git a/common/src/main/java/net/blay09/mods/waystones/client/gui/screen/WaystoneScreen.java b/common/src/main/java/net/blay09/mods/waystones/client/gui/screen/WaystoneScreen.java index 9dc9acb3..f68bebf0 100644 --- a/common/src/main/java/net/blay09/mods/waystones/client/gui/screen/WaystoneScreen.java +++ b/common/src/main/java/net/blay09/mods/waystones/client/gui/screen/WaystoneScreen.java @@ -3,7 +3,6 @@ import com.mojang.blaze3d.systems.RenderSystem; import net.blay09.mods.balm.api.Balm; import net.blay09.mods.waystones.Waystones; -import net.blay09.mods.waystones.api.WaystoneTypes; import net.blay09.mods.waystones.client.gui.widget.ITooltipProvider; import net.blay09.mods.waystones.client.gui.widget.WaystoneVisbilityButton; import net.blay09.mods.waystones.core.WaystoneVisibilities; @@ -18,7 +17,6 @@ import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.MutableComponent; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; import org.lwjgl.glfw.GLFW;