Skip to content

Commit 1dd745d

Browse files
Merge branch '1.21' into 1.21
2 parents 9c1647b + fecdd84 commit 1dd745d

39 files changed

+626
-225
lines changed

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Requires <a href="https://modrinth.com/mod/connector">Connector</a> and <a href=
1111

1212
**Scattered Shards** adds a system of collectible "shards" that can be created via a UI and placed in-world.
1313

14-
Type `/shards` or use a *Shard Tablet* any time to view which shards you've collected, and which ones are left! There is also a keybind to open the tablet;
14+
Type `/shards` or use a *Shard Tablet* any time to view shows obtained and missing shards. There is also a keybind to open the tablet;
1515
it is not bound by default, so you may want to create a default setting for your modpack!
1616

1717
**Features:**
@@ -21,7 +21,6 @@ it is not bound by default, so you may want to create a default setting for your
2121
- Shard types can have custom names, textures, and collection sounds (resource-driven)
2222
- Shards are arranged into "sets" which can have one shard of each type
2323
- Suggested as **installed mod IDs** by default, but can be completely arbitrary (locations, skillsets, etc)
24-
- Tracks global collection statistics, displayed to players when holding shift in the shards screen
2524

2625
![shards screen preview](https://cdn.modrinth.com/data/DB9GU3tx/images/ba00e12bef9b8d90d096a71bba11d71c14f6e01f.png)
2726

build.gradle

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ dependencies {
3232
include libs.fpapi
3333
}
3434

35+
loom {
36+
accessWidenerPath = file("src/main/resources/${modId}.accesswidener")
37+
}
38+
3539
processResources {
3640
final Map<String, String> meta = [
3741
version : version,

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ authors=Falkreon, acikek
1717
contributors=Trudle, Tomate0613, afamiliarquiet, FoundationGames, TheEpicBlock, hama
1818
license=MIT
1919
# Mod Version
20-
baseVersion=1.8.0
20+
baseVersion=1.8.1
2121
# Branch Metadata
2222
branch=1.21
2323
tagBranch=1.21

src/main/java/net/modfest/scatteredshards/ScatteredShardsContent.java

+11
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import net.minecraft.block.Block;
66
import net.minecraft.block.entity.BlockEntityType;
77
import net.minecraft.client.render.block.entity.BlockEntityRendererFactories;
8+
import net.minecraft.component.ComponentType;
89
import net.minecraft.item.BlockItem;
910
import net.minecraft.item.Item;
1011
import net.minecraft.registry.Registries;
@@ -13,24 +14,34 @@
1314
import net.modfest.scatteredshards.block.ShardBlock;
1415
import net.modfest.scatteredshards.block.ShardBlockEntity;
1516
import net.modfest.scatteredshards.client.render.ShardBlockEntityRenderer;
17+
import net.modfest.scatteredshards.item.ShardItem;
1618
import net.modfest.scatteredshards.item.ShardTablet;
1719

1820
public class ScatteredShardsContent {
1921
public static final Identifier SHARD_BLOCK_ID = ScatteredShards.id("shard_block");
2022
public static final Identifier SHARD_TABLET_ID = ScatteredShards.id("shard_tablet");
23+
public static final Identifier SHARD_ITEM_ID = ScatteredShards.id("shard_item");
2124

2225
public static final Block SHARD_BLOCK = new ShardBlock();
2326
public static final Item SHARD_BLOCK_ITEM = new BlockItem(SHARD_BLOCK, new Item.Settings());
2427

2528
public static final Item SHARD_TABLET = new ShardTablet(new Item.Settings());
29+
public static final Item SHARD_ITEM = new ShardItem(new Item.Settings());
2630

2731
public static final BlockEntityType<ShardBlockEntity> SHARD_BLOCKENTITY = BlockEntityType.Builder.create(ShardBlockEntity::new, SHARD_BLOCK).build();
2832

33+
public static final ComponentType<Identifier> SHARD_ID_COMPONENT = Registry.register(
34+
Registries.DATA_COMPONENT_TYPE,
35+
ScatteredShards.id("shard_id"),
36+
ComponentType.<Identifier>builder().codec(Identifier.CODEC).build()
37+
);
38+
2939
public static void register() {
3040
Registry.register(Registries.BLOCK, SHARD_BLOCK_ID, SHARD_BLOCK);
3141
Registry.register(Registries.ITEM, SHARD_BLOCK_ID, SHARD_BLOCK_ITEM);
3242
Registry.register(Registries.BLOCK_ENTITY_TYPE, SHARD_BLOCK_ID, SHARD_BLOCKENTITY);
3343
Registry.register(Registries.ITEM, SHARD_TABLET_ID, SHARD_TABLET);
44+
Registry.register(Registries.ITEM, SHARD_ITEM_ID, SHARD_ITEM);
3445
}
3546

3647
@Environment(EnvType.CLIENT)

src/main/java/net/modfest/scatteredshards/api/GlobalCollection.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import net.minecraft.util.Identifier;
77

88
import java.util.HashMap;
9+
import java.util.Objects;
910

1011
public class GlobalCollection {
1112
int totalPlayers;
@@ -31,8 +32,7 @@ public HashMap<Identifier, Integer> collectionTracker() {
3132
);
3233

3334
public int getCount(Identifier shard) {
34-
var count = collectionTracker.get(shard);
35-
return count != null ? count : 0;
35+
return Objects.requireNonNullElse(collectionTracker.get(shard), 0);
3636
}
3737

3838
public void update(Identifier shard, int change, int playerCount) {

src/main/java/net/modfest/scatteredshards/api/MiniRegistry.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public void syncFromJson(JsonObject obj) {
9999
public static <T> PacketCodec<RegistryByteBuf, MiniRegistry<T>> createPacketCodec(Codec<T> valueCodec) {
100100
return PacketCodecs.map(HashMap::new, Identifier.PACKET_CODEC, PacketCodecs.codec(valueCodec)).xmap(
101101
map -> {
102-
var registry = new MiniRegistry<>(valueCodec);
102+
MiniRegistry<T> registry = new MiniRegistry<>(valueCodec);
103103
registry.putAll(map);
104104
return registry;
105105
},

src/main/java/net/modfest/scatteredshards/api/ScatteredShardsAPI.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public static void updateClientShardLibrary(ShardLibrary library) {
5555
}
5656

5757
public static ShardCollection getServerCollection(UUID uuid) {
58-
var collection = serverCollections.get(uuid);
58+
ShardCollection collection = serverCollections.get(uuid);
5959
if (collection == null) {
6060
collection = new ShardCollectionImpl();
6161
serverCollections.put(uuid, collection);
@@ -74,8 +74,8 @@ public static GlobalCollection getServerGlobalCollection() {
7474

7575
public static void calculateShardProgress() {
7676
if (serverGlobalCollection != null) return;
77-
var shardCountMap = new HashMap<Identifier, Integer>();
78-
var totalCount = serverCollections.size();
77+
HashMap<Identifier, Integer> shardCountMap = new HashMap<>();
78+
int totalCount = serverCollections.size();
7979

8080
serverCollections.forEach(((uuid, identifiers) -> identifiers.forEach(identifier -> shardCountMap.compute(identifier, (k, count) -> count != null ? 1 + count : 1))));
8181

@@ -117,7 +117,7 @@ public static void updateClientGlobalCollection(GlobalCollection collection) {
117117
}
118118

119119
public static boolean triggerShardCollection(ServerPlayerEntity player, Identifier shardId) {
120-
var collection = getServerCollection(player);
120+
ShardCollection collection = getServerCollection(player);
121121
if (collection.add(shardId)) {
122122
if (player.getServer() != null) collectionPersistentState.markDirty();
123123

@@ -130,7 +130,7 @@ public static boolean triggerShardCollection(ServerPlayerEntity player, Identifi
130130
}
131131

132132
public static boolean triggerShardUncollection(ServerPlayerEntity player, Identifier shardId) {
133-
var collection = getServerCollection(player);
133+
ShardCollection collection = getServerCollection(player);
134134
if (collection.remove(shardId)) {
135135
if (player.getServer() != null) collectionPersistentState.markDirty();
136136

src/main/java/net/modfest/scatteredshards/api/ShardLibrary.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
import net.modfest.scatteredshards.api.shard.ShardType;
1212

1313
import java.util.ArrayList;
14+
import java.util.Collection;
1415
import java.util.HashMap;
16+
import java.util.Map;
1517
import java.util.stream.Stream;
1618

1719
/**
@@ -41,14 +43,14 @@ public interface ShardLibrary {
4143
PacketCodecs.map(HashMap::new, Identifier.PACKET_CODEC, PacketCodecs.collection(ArrayList::new, Identifier.PACKET_CODEC)).xmap(
4244
map -> {
4345
SetMultimap<Identifier, Identifier> multimap = MultimapBuilder.hashKeys().hashSetValues(3).build();
44-
for (var entry : map.entrySet()) {
46+
for (Map.Entry<Identifier, ArrayList<Identifier>> entry : map.entrySet()) {
4547
multimap.putAll(entry.getKey(), entry.getValue());
4648
}
4749
return multimap;
4850
},
4951
multimap -> {
5052
HashMap<Identifier, ArrayList<Identifier>> map = new HashMap<>();
51-
for (var entry : multimap.asMap().entrySet()) {
53+
for (Map.Entry<Identifier, Collection<Identifier>> entry : multimap.asMap().entrySet()) {
5254
map.put(entry.getKey(), new ArrayList<>(entry.getValue()));
5355
}
5456
return map;

src/main/java/net/modfest/scatteredshards/api/impl/ShardCollectionPersistentState.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class ShardCollectionPersistentState extends PersistentState {
2424
);
2525

2626
public static ShardCollectionPersistentState get(MinecraftServer server) {
27-
var result = server.getOverworld().getPersistentStateManager().getOrCreate(TYPE, ScatteredShards.ID + "_collections");
27+
ShardCollectionPersistentState result = server.getOverworld().getPersistentStateManager().getOrCreate(TYPE, ScatteredShards.ID + "_collections");
2828
ScatteredShardsAPI.register(result);
2929
return result;
3030
}

src/main/java/net/modfest/scatteredshards/client/ScatteredShardsClient.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import net.modfest.scatteredshards.ScatteredShards;
1616
import net.modfest.scatteredshards.ScatteredShardsContent;
1717
import net.modfest.scatteredshards.api.ScatteredShardsAPI;
18+
import net.modfest.scatteredshards.api.ShardCollection;
19+
import net.modfest.scatteredshards.api.ShardLibrary;
1820
import net.modfest.scatteredshards.api.shard.Shard;
1921
import net.modfest.scatteredshards.api.shard.ShardType;
2022
import net.modfest.scatteredshards.client.command.ClientShardCommand;
@@ -76,13 +78,12 @@ public static void triggerShardModificationToast(Identifier shardId, boolean suc
7678
}
7779

7880
public static void openShardTablet() {
79-
final var client = MinecraftClient.getInstance();
80-
client.send(() -> {
81-
final var library = ScatteredShardsAPI.getClientLibrary();
82-
final var collection = ScatteredShardsAPI.getClientCollection();
81+
MinecraftClient.getInstance().send(() -> {
82+
final ShardLibrary library = ScatteredShardsAPI.getClientLibrary();
83+
final ShardCollection collection = ScatteredShardsAPI.getClientCollection();
8384

84-
client.setScreen(new ShardTabletGuiDescription.Screen(collection, library));
85-
client.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.ITEM_BOOK_PAGE_TURN, 1.0f, 1.0f));
85+
MinecraftClient.getInstance().setScreen(new ShardTabletGuiDescription.Screen(collection, library));
86+
MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.ITEM_BOOK_PAGE_TURN, 1.0f, 1.0f));
8687
});
8788
}
8889

0 commit comments

Comments
 (0)