mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 11:36:43 +01:00
You can now see which traits are unread and mark them read by clicking
This commit is contained in:
parent
d45c1aa146
commit
5bb982ab85
5 changed files with 59 additions and 4 deletions
|
@ -11,6 +11,7 @@ import org.jetbrains.annotations.Nullable;
|
|||
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.network.Channel;
|
||||
import com.minelittlepony.unicopia.network.MsgMarkTraitRead;
|
||||
import com.minelittlepony.unicopia.network.MsgUnlockTraits;
|
||||
import com.minelittlepony.unicopia.util.NbtSerialisable;
|
||||
|
||||
|
@ -48,10 +49,16 @@ public class TraitDiscovery implements NbtSerialisable {
|
|||
pony.setDirty();
|
||||
}
|
||||
|
||||
public void markRead() {
|
||||
unreadTraits.clear();
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void markRead(Trait trait) {
|
||||
Channel.MARK_TRAIT_READ.send(new MsgMarkTraitRead(Set.of(trait)));
|
||||
}
|
||||
|
||||
public void markRead(Set<Trait> traits) {
|
||||
if (unreadTraits.removeAll(traits)) {
|
||||
pony.setDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public void unlock(Item item) {
|
||||
if (item == Items.AIR) {
|
||||
|
|
|
@ -238,6 +238,8 @@ public class SpellbookScreen extends HandledScreen<SpellbookScreenHandler> {
|
|||
.append("\n")
|
||||
.append(new TranslatableText("gui.unicopia.trait.corruption", ItemStack.MODIFIER_FORMAT.format(trait.getGroup().getCorruption())).formatted(Formatting.ITALIC, corruptionColor)))
|
||||
, 200));
|
||||
|
||||
onClick(sender -> Pony.of(client.player).getDiscoveries().markRead(trait));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -249,7 +251,14 @@ public class SpellbookScreen extends HandledScreen<SpellbookScreenHandler> {
|
|||
RenderSystem.setShaderTexture(0, TEXTURE);
|
||||
RenderSystem.enableBlend();
|
||||
drawTexture(matrices, x - 2, y - 8, 204, 219, 22, 32, 512, 256);
|
||||
|
||||
if (!active) {
|
||||
drawTexture(matrices, x - 2, y - 1, 74, 223, 18, 18, 512, 256);
|
||||
}
|
||||
|
||||
if (discoveries.isUnread(trait)) {
|
||||
drawTexture(matrices, x - 8, y - 8, 225, 219, 35, 32, 512, 256);
|
||||
}
|
||||
|
||||
super.renderButton(matrices, mouseX, mouseY, partialTicks);
|
||||
hovered &= active;
|
||||
|
|
|
@ -12,6 +12,7 @@ import net.minecraft.util.Identifier;
|
|||
public interface Channel {
|
||||
C2SPacketType<MsgPlayerAbility<?>> CLIENT_PLAYER_ABILITY = SimpleNetworking.clientToServer(new Identifier("unicopia", "player_ability"), MsgPlayerAbility::new);
|
||||
C2SPacketType<MsgRequestSpeciesChange> CLIENT_REQUEST_SPECIES_CHANGE = SimpleNetworking.clientToServer(new Identifier("unicopia", "request_capabilities"), MsgRequestSpeciesChange::new);
|
||||
C2SPacketType<MsgMarkTraitRead> MARK_TRAIT_READ = SimpleNetworking.clientToServer(new Identifier("unicopia", "mark_trait_read"), MsgMarkTraitRead::new);
|
||||
|
||||
S2CPacketType<MsgPlayerCapabilities> SERVER_PLAYER_CAPABILITIES = SimpleNetworking.serverToClient(new Identifier("unicopia", "player_capabilities"), MsgPlayerCapabilities::new);
|
||||
S2CPacketType<MsgSpawnProjectile> SERVER_SPAWN_PROJECTILE = SimpleNetworking.serverToClient(new Identifier("unicopia", "projectile_entity"), MsgSpawnProjectile::new);
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package com.minelittlepony.unicopia.network;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.util.network.Packet;
|
||||
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
|
||||
public class MsgMarkTraitRead implements Packet<ServerPlayerEntity> {
|
||||
|
||||
public final Set<Trait> traits = new HashSet<>();
|
||||
|
||||
MsgMarkTraitRead(PacketByteBuf buffer) {
|
||||
int length = buffer.readInt();
|
||||
for (int i = 0; i < length; i++) {
|
||||
Trait.fromId(buffer.readIdentifier()).ifPresent(traits::add);
|
||||
}
|
||||
}
|
||||
|
||||
public MsgMarkTraitRead(Set<Trait> traits) {
|
||||
this.traits.addAll(traits);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBuffer(PacketByteBuf buffer) {
|
||||
buffer.writeInt(traits.size());
|
||||
traits.forEach(trait -> buffer.writeIdentifier(trait.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(ServerPlayerEntity sender) {
|
||||
Pony.of(sender).getDiscoveries().markRead(traits);
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 41 KiB |
Loading…
Reference in a new issue