generated from NeoForgeMDKs/MDK-1.21-NeoGradle
-
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
1 parent
eb068a6
commit b1dce77
Showing
10 changed files
with
125 additions
and
128 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
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
src/main/java/com/portingdeadmods/nautec/api/bacteria/BacteriaSerializer.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 com.portingdeadmods.nautec.api.bacteria; | ||
|
||
import com.mojang.serialization.MapCodec; | ||
import io.netty.buffer.ByteBuf; | ||
import net.minecraft.network.RegistryFriendlyByteBuf; | ||
import net.minecraft.network.codec.StreamCodec; | ||
|
||
public interface BacteriaSerializer<T extends Bacteria> { | ||
MapCodec<T> mapCodec(); | ||
|
||
StreamCodec<RegistryFriendlyByteBuf, T> streamCodec(); | ||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/com/portingdeadmods/nautec/api/bacteria/BacteriaStats.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,45 @@ | ||
package com.portingdeadmods.nautec.api.bacteria; | ||
|
||
import com.mojang.serialization.Codec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
import com.portingdeadmods.nautec.Nautec; | ||
import com.portingdeadmods.nautec.utils.codec.CodecUtils; | ||
import net.minecraft.network.RegistryFriendlyByteBuf; | ||
import net.minecraft.network.codec.ByteBufCodecs; | ||
import net.minecraft.network.codec.StreamCodec; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.Item; | ||
|
||
public record BacteriaStats(Item type, | ||
float growthRate, | ||
float mutationResistance, | ||
float productionRate, | ||
int lifespan, | ||
int color) { | ||
public static final Codec<BacteriaStats> CODEC = RecordCodecBuilder.create( | ||
instance -> instance.group( | ||
CodecUtils.ITEM_CODEC.fieldOf("type").forGetter(BacteriaStats::type), | ||
Codec.FLOAT.fieldOf("growth_rate").forGetter(BacteriaStats::growthRate), | ||
Codec.FLOAT.fieldOf("mutation_resistance").forGetter(BacteriaStats::mutationResistance), | ||
Codec.FLOAT.fieldOf("production_rate").forGetter(BacteriaStats::productionRate), | ||
Codec.INT.fieldOf("lifespan").forGetter(BacteriaStats::lifespan), | ||
Codec.INT.fieldOf("color").forGetter(BacteriaStats::color) | ||
).apply(instance, BacteriaStats::new) | ||
); | ||
|
||
public static final StreamCodec<RegistryFriendlyByteBuf, BacteriaStats> STREAM_CODEC = StreamCodec.composite( | ||
CodecUtils.ITEM_STREAM_CODEC, | ||
BacteriaStats::type, | ||
ByteBufCodecs.FLOAT, | ||
BacteriaStats::growthRate, | ||
ByteBufCodecs.FLOAT, | ||
BacteriaStats::mutationResistance, | ||
ByteBufCodecs.FLOAT, | ||
BacteriaStats::productionRate, | ||
ByteBufCodecs.INT, | ||
BacteriaStats::lifespan, | ||
ByteBufCodecs.INT, | ||
BacteriaStats::color, | ||
BacteriaStats::new | ||
); | ||
} |
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
12 changes: 12 additions & 0 deletions
12
src/main/java/com/portingdeadmods/nautec/utils/BacteriaHelper.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 com.portingdeadmods.nautec.utils; | ||
|
||
import com.portingdeadmods.nautec.NTRegistries; | ||
import com.portingdeadmods.nautec.api.bacteria.Bacteria; | ||
import net.minecraft.core.HolderLookup; | ||
import net.minecraft.resources.ResourceKey; | ||
|
||
public final class BacteriaHelper { | ||
public static Bacteria getBacteria(HolderLookup.Provider lookup, ResourceKey<Bacteria> bacteriaType) { | ||
return lookup.asGetterLookup().lookupOrThrow(NTRegistries.BACTERIA_KEY).getOrThrow(bacteriaType).value(); | ||
} | ||
} |