-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from FTBTeam/1.20.1/dev
1.20.1/dev
- Loading branch information
Showing
9 changed files
with
94 additions
and
7 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
39 changes: 39 additions & 0 deletions
39
common/src/main/java/dev/ftb/mods/ftblibrary/config/StringMapValue.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,39 @@ | ||
package dev.ftb.mods.ftblibrary.config; | ||
|
||
import dev.ftb.mods.ftblibrary.snbt.SNBTCompoundTag; | ||
import dev.ftb.mods.ftblibrary.snbt.config.BaseValue; | ||
import dev.ftb.mods.ftblibrary.snbt.config.SNBTConfig; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class StringMapValue extends BaseValue<Map<String, String>> { | ||
public StringMapValue(@Nullable SNBTConfig c, String n, Map<String, String> def) { | ||
super(c, n, def); | ||
super.set(new HashMap<>(def)); | ||
} | ||
|
||
@Override | ||
public void write(SNBTCompoundTag tag) { | ||
Map<String, String> map = get(); | ||
SNBTCompoundTag mapTag = new SNBTCompoundTag(); | ||
|
||
for (Map.Entry<String, String> entry : map.entrySet()) { | ||
mapTag.putString(entry.getKey(), entry.getValue()); | ||
} | ||
|
||
tag.put(key, mapTag); | ||
} | ||
|
||
@Override | ||
public void read(SNBTCompoundTag tag) { | ||
Map<String, String> map = new HashMap<>(); | ||
|
||
for (String key : tag.getAllKeys()) { | ||
map.put(key, tag.getString(key)); | ||
} | ||
|
||
set(map); | ||
} | ||
} |
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
12 changes: 12 additions & 0 deletions
12
common/src/main/java/dev/ftb/mods/ftblibrary/util/NetworkHelper.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,12 @@ | ||
package dev.ftb.mods.ftblibrary.util; | ||
|
||
import dev.architectury.networking.NetworkManager; | ||
import dev.architectury.networking.simple.MessageType; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraft.server.MinecraftServer; | ||
|
||
public class NetworkHelper { | ||
public static void sendToAll(MessageType type, MinecraftServer server, FriendlyByteBuf buffer) { | ||
NetworkManager.sendToPlayers(server.getPlayerList().getPlayers(), type.getId(), buffer); | ||
} | ||
} |
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
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