generated from nanite/Custom-MultiLoader-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
146 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 0 additions & 93 deletions
93
common/src/main/java/dev/wuffs/ifly/client/gui/screen/PlayerListScreen.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
common/src/main/java/dev/wuffs/ifly/network/C2SGUIInteract.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package dev.wuffs.ifly.network; | ||
|
||
import dev.architectury.networking.NetworkManager; | ||
import dev.wuffs.ifly.blocks.TbdBlockEntity; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.level.block.entity.BlockEntity; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
import java.util.function.Supplier; | ||
|
||
public class C2SGUIInteract { | ||
|
||
BlockPos blockPos; | ||
UUID playerUUID; | ||
boolean added; | ||
|
||
public C2SGUIInteract(FriendlyByteBuf buf) { | ||
blockPos = buf.readBlockPos(); | ||
playerUUID = buf.readUUID(); | ||
added = buf.readBoolean(); | ||
} | ||
|
||
public C2SGUIInteract(BlockPos pos, UUID playerUUID, boolean added) { | ||
// Message creation | ||
this.blockPos = pos; | ||
this.playerUUID = playerUUID; | ||
this.added = added; | ||
|
||
} | ||
|
||
public void encode(FriendlyByteBuf buf) { | ||
// Encode data into the buf | ||
buf.writeBlockPos(blockPos); | ||
buf.writeUUID(playerUUID); | ||
buf.writeBoolean(added); | ||
} | ||
|
||
public void apply(Supplier<NetworkManager.PacketContext> contextSupplier) { | ||
// On receive | ||
contextSupplier.get().queue(() -> { | ||
BlockEntity blockEntity = contextSupplier.get().getPlayer().level().getBlockEntity(blockPos); | ||
if (blockEntity instanceof TbdBlockEntity tbdBlockEntity) { | ||
if (!tbdBlockEntity.ownerUUID.equals(contextSupplier.get().getPlayer().getUUID())) { | ||
return; | ||
} | ||
Player playerByUUID = contextSupplier.get().getPlayer().level().getPlayerByUUID(playerUUID); | ||
if (playerByUUID == null) { | ||
return; | ||
} | ||
|
||
List<TbdBlockEntity.StoredPlayers> storedPlayers = tbdBlockEntity.storedPlayers; | ||
if (added) { | ||
if (storedPlayers.stream().anyMatch(storedPlayer -> storedPlayer.playerUUID().equals(playerUUID))) { | ||
return; | ||
} | ||
storedPlayers.add(new TbdBlockEntity.StoredPlayers(playerUUID, playerByUUID.getDisplayName(), true)); | ||
} else { | ||
storedPlayers.removeIf(storedPlayer -> storedPlayer.playerUUID().equals(playerUUID)); | ||
} | ||
tbdBlockEntity.setChanged(); | ||
} | ||
}); | ||
} | ||
} |
Oops, something went wrong.