mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-07 22:16:44 +01:00
Fixed spellbook not repainting when its state is updated from the server
This commit is contained in:
parent
65c1c4289d
commit
598f4273da
2 changed files with 12 additions and 0 deletions
|
@ -134,6 +134,9 @@ public class SpellbookScreen extends HandledScreen<SpellbookScreenHandler> imple
|
|||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) {
|
||||
if (getState().isDirty()) {
|
||||
clearAndInit();
|
||||
}
|
||||
super.render(matrices, mouseX, mouseY, partialTicks);
|
||||
drawMouseoverTooltip(matrices, mouseX, mouseY);
|
||||
}
|
||||
|
|
|
@ -15,8 +15,16 @@ import net.minecraft.util.math.MathHelper;
|
|||
public class SpellbookState extends Synchronizable<SpellbookState> implements NbtSerialisable {
|
||||
private Optional<Identifier> currentPageId = Optional.empty();
|
||||
|
||||
private boolean dirty;
|
||||
|
||||
private final Map<Identifier, PageState> states = new HashMap<>();
|
||||
|
||||
public boolean isDirty() {
|
||||
boolean isDirty = dirty;
|
||||
dirty = false;
|
||||
return isDirty;
|
||||
}
|
||||
|
||||
public Optional<Identifier> getCurrentPageId() {
|
||||
return currentPageId;
|
||||
}
|
||||
|
@ -34,6 +42,7 @@ public class SpellbookState extends Synchronizable<SpellbookState> implements Nb
|
|||
public void copyFrom(SpellbookState state) {
|
||||
currentPageId = state.currentPageId;
|
||||
state.states.forEach((id, page) -> getState(id).copyFrom(page));
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
public void toPacket(PacketByteBuf buf) {
|
||||
|
|
Loading…
Reference in a new issue