Skip to content

Commit

Permalink
Fishing net now uses its own tag to check for valid fish.
Browse files Browse the repository at this point in the history
critters now have "can breathe underwater" tag
  • Loading branch information
Ivan-Khar committed Feb 7, 2024
1 parent d1db116 commit 9af864e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider
import net.minecraft.entity.EntityType
import net.minecraft.registry.RegistryWrapper
import net.minecraft.registry.tag.EntityTypeTags
import java.util.concurrent.CompletableFuture

class EntityTypeTagProvider(output: FabricDataOutput, registriesFuture: CompletableFuture<RegistryWrapper.WrapperLookup>) : FabricTagProvider.EntityTypeTagProvider(output, registriesFuture) {
Expand Down Expand Up @@ -207,6 +208,11 @@ class EntityTypeTagProvider(output: FabricDataOutput, registriesFuture: Completa
HybridAquaticEntityTypes.STARFISH,
)

getOrCreateTagBuilder(EntityTypeTags.CAN_BREATHE_UNDER_WATER)
.addTag(HybridAquaticEntityTags.CRAB)
.addTag(HybridAquaticEntityTags.CRITTER)
.addTag(HybridAquaticEntityTags.SHRIMP)

// jellyfish
getOrCreateTagBuilder(HybridAquaticEntityTags.JELLYFISH)
.add(
Expand All @@ -220,5 +226,12 @@ class EntityTypeTagProvider(output: FabricDataOutput, registriesFuture: Completa
HybridAquaticEntityTypes.COMPASS_JELLYFISH,
HybridAquaticEntityTypes.BLUE_JELLYFISH,
)

// fishing net
getOrCreateTagBuilder(HybridAquaticEntityTags.CAN_USE_FISHING_NET_ON)
.addTag(HybridAquaticEntityTags.JELLYFISH)
.addTag(HybridAquaticEntityTags.CRITTER)
.addTag(HybridAquaticEntityTags.SMALL_PREY)
.addTag(HybridAquaticEntityTags.MEDIUM_PREY)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import java.util.*
class FishingNetItem(settings: Settings?): Item(settings) {

override fun useOnEntity(stack: ItemStack, user: PlayerEntity, entity: LivingEntity, hand: Hand): ActionResult {
val validFishForNet = entity.type.isIn(HybridAquaticEntityTags.JELLYFISH) || entity.type.isIn(HybridAquaticEntityTags.CRITTER) || entity.type.isIn(HybridAquaticEntityTags.SMALL_PREY) || entity.type.isIn(HybridAquaticEntityTags.MEDIUM_PREY)
val validFishForNet = entity.type.isIn(HybridAquaticEntityTags.CAN_USE_FISHING_NET_ON)

if (!alreadyHasFish(stack) && validFishForNet) {
writeEntityToNet(entity, user, hand)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class MessageInABottleItemEntry(
*/
val CODEC: Codec<MessageInABottleItemEntry> = RecordCodecBuilder.create { instance ->
val default = addLeafFields(instance)

instance.group(
default.t1(),
default.t2(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ object HybridAquaticEntityTags {
val FISHES = create("fishes")
val SHARKS = create("sharks")

val CAN_USE_FISHING_NET_ON = create("can_use_fishing_net_on")

private fun create(id: String): TagKey<EntityType<*>> {
return TagKey.of(RegistryKeys.ENTITY_TYPE, Identifier(HybridAquatic.MOD_ID, id))
}
Expand Down

0 comments on commit 9af864e

Please sign in to comment.