-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Is everything broken yet (Room Upgrades WIP)
- Loading branch information
1 parent
0272e12
commit f607428
Showing
29 changed files
with
1,083 additions
and
378 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
22 changes: 1 addition & 21 deletions
22
core-api/src/main/java/dev/compactmods/machines/api/room/upgrade/RoomUpgrade.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
23 changes: 23 additions & 0 deletions
23
core-api/src/main/java/dev/compactmods/machines/api/room/upgrade/RoomUpgradeCodecs.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,23 @@ | ||
package dev.compactmods.machines.api.room.upgrade; | ||
|
||
import com.mojang.serialization.Codec; | ||
import dev.compactmods.machines.api.CompactMachines; | ||
import net.minecraft.core.Registry; | ||
import net.minecraft.core.registries.BuiltInRegistries; | ||
import net.minecraft.network.RegistryFriendlyByteBuf; | ||
import net.minecraft.network.codec.ByteBufCodecs; | ||
import net.minecraft.network.codec.StreamCodec; | ||
|
||
public interface RoomUpgradeCodecs { | ||
Codec<RoomUpgrade> DISPATCH_CODEC = Codec.lazyInitialized(() -> { | ||
@SuppressWarnings("unchecked") final var reg = (Registry<RoomUpgradeDefinition<?>>) BuiltInRegistries.REGISTRY.get(CompactMachines.modRL("room_upgrades")); | ||
|
||
if (reg != null) { | ||
var upgradeRegistry = reg.byNameCodec(); | ||
return upgradeRegistry.dispatchStable(RoomUpgrade::getType, RoomUpgradeDefinition::codec); | ||
} | ||
|
||
throw new RuntimeException("Room upgrade registry not registered yet; calling too early?"); | ||
}); | ||
StreamCodec<RegistryFriendlyByteBuf, RoomUpgrade> STREAM_CODEC = ByteBufCodecs.fromCodecWithRegistries(DISPATCH_CODEC); | ||
} |
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
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
Oops, something went wrong.