Skip to content

Commit

Permalink
Merge pull request #10 from Akinesis/1.21.1-more-foxes
Browse files Browse the repository at this point in the history
1.21.1 more foxes
  • Loading branch information
TalonFloof authored Nov 17, 2024
2 parents dc7b2d6 + 253e8e1 commit 384949b
Show file tree
Hide file tree
Showing 55 changed files with 558 additions and 59 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Add more foxes variant, both of vanillia spawnable foxes and new biome specifics foxes (E.G.: Nether or End).

Additional foxes Texures from : <br />
https://modrinth.com/resourcepack/formidable-foxes <br />
https://www.planetminecraft.com/member/arianwyn/ <br />
https://www.planetminecraft.com/texture-pack/more-foxes/ <br />
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ yarn_mappings=1.21.1+build.3
loader_version=0.16.9

# Mod Properties
mod_version=2.0.0
mod_version=2.1.0
maven_group=sh.talonfox.vulpine
archives_base_name=vulpine

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"values": [
"minecraft:netherrack",
"minecraft:sculk",
"minecraft:sculk_vein",
"minecraft:end_stone",
"#minecraft:nylium",
"minecraft:soul_sand",
"minecraft:soul_soil",
"#minecraft:sand"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"values": [
"#c:is_desert",
"minecraft:badlands"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"values": [
"#c:is_outer_end_island",
"minecraft:the_end"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"values": [
"#c:is_nether_forest",
"minecraft:soul_sand_valley",
"minecraft:nether_wastes"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"minecraft:deep_dark"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"#minecraft:spawns_snow_foxes"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"#c:is_taiga"
]
}
114 changes: 114 additions & 0 deletions src/main/java/sh/talonfox/vulpine/FoxVariantSelector.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package sh.talonfox.vulpine;

import net.fabricmc.fabric.api.tag.convention.v2.ConventionalBiomeTags;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.NbtComponent;
import net.minecraft.entity.EntityData;
import net.minecraft.entity.passive.FoxEntity;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.registry.tag.BiomeTags;
import net.minecraft.registry.tag.EntityTypeTags;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeKeys;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.dimension.DimensionTypes;
import sh.talonfox.vulpine.registry.ModMobTags;

import javax.swing.plaf.ViewportUI;
import java.util.ArrayList;
import java.util.List;

public abstract class FoxVariantSelector {

private static Random rand = Random.create();

public static List<FoxEntity.Type> SNOW_VARIANT = new ArrayList();
public static List<FoxEntity.Type> DEFAULT_VARIANT = new ArrayList();
public static List<FoxEntity.Type> DESERT_VARIANT = new ArrayList();
public static List<FoxEntity.Type> TAIGA_VARIANT = new ArrayList();
public static List<FoxEntity.Type> NETHER_VARIANT = new ArrayList();
public static List<FoxEntity.Type> ENDER_VARIANT = new ArrayList();
public static List<FoxEntity.Type> SCULK_VARIANT = new ArrayList();
public static List<FoxEntity.Type> MONSTER_VARIANT = new ArrayList();

private static FoxEntity.Type randomDefaultVariant(){
return DEFAULT_VARIANT.get(rand.nextInt(DEFAULT_VARIANT.size()));
}

private static FoxEntity.Type randomSnowVariant(){
return SNOW_VARIANT.get(rand.nextInt(SNOW_VARIANT.size()));
}

private static FoxEntity.Type randomTaigaVariant(){
return TAIGA_VARIANT.get(rand.nextInt(TAIGA_VARIANT.size()));
}

private static FoxEntity.Type randomNetherVariant(){
return NETHER_VARIANT.get(rand.nextInt(NETHER_VARIANT.size()));
}

private static FoxEntity.Type randomDesertVariant(){
return DESERT_VARIANT.get(rand.nextInt(DESERT_VARIANT.size()));
}

private static FoxEntity.Type randomEnderVariant(){
if(rand.nextInt(100) < 10)
return Vulpine.TALON; //10% Chance to spawn TALON variant. I think it fit well in the END
return ENDER_VARIANT.get(rand.nextInt(ENDER_VARIANT.size()));
}

private static FoxEntity.Type randomMonsterVariant(){
return MONSTER_VARIANT.get(rand.nextInt(MONSTER_VARIANT.size()));
}

private static FoxEntity.Type randomSculkVariant(){
return SCULK_VARIANT.get(rand.nextInt(SCULK_VARIANT.size()));
}

private static boolean shouldSpawnMonster(World foxWorld){
DimensionType dim = foxWorld.getDimensionEntry().value();
boolean shouldSpawnMonster = foxWorld.getRegistryKey() == World.OVERWORLD;
shouldSpawnMonster = shouldSpawnMonster & foxWorld.isNight();
return shouldSpawnMonster & rand.nextInt(100)<15; //15% to spawn monster version at night in overwolrd.
}

public static FoxEntity.Type selectFoxVariant(FoxEntity foxEntity, RegistryEntry<Biome> foxBiome){

if(shouldSpawnMonster(foxEntity.getEntityWorld()))
return randomMonsterVariant();

if(foxBiome.isIn(ModMobTags.HAS_NETHER_FOX)){
return randomNetherVariant();
}

if(foxBiome.isIn(ModMobTags.HAS_DESERT_FOX)){
return randomDesertVariant();
}

if(foxBiome.isIn(ModMobTags.HAS_SNOW_FOX)){
return randomSnowVariant();
}

if(foxBiome.isIn(ModMobTags.HAS_TAIGA_FOX)){
if(foxBiome.isIn(ConventionalBiomeTags.IS_SNOWY))
return randomSnowVariant();
else
return randomTaigaVariant();
}

if(foxBiome.isIn(ModMobTags.HAS_SCULK_FOX)){
return randomSculkVariant();
}

if(foxBiome.isIn(ModMobTags.HAS_ENDER_FOX)){
return randomEnderVariant();
}

return randomDefaultVariant();
}
}
22 changes: 15 additions & 7 deletions src/main/java/sh/talonfox/vulpine/FoxVariantTexture.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,40 @@
import net.minecraft.util.Identifier;

import java.util.HashMap;
import java.util.Map;

public class FoxVariantTexture {
public static HashMap<FoxEntity.Type, FoxVariantTexture> foxTextures = new HashMap<>();
public static HashMap<FoxEntity.Type, ModFoxType> foxTextures = new HashMap<>();
public static final FoxVariantTexture TALON = new FoxVariantTexture(Identifier.of("vulpine","talon"), Identifier.of("vulpine","talon_seep"));

public final Identifier normalTexture;
public final Identifier sleepTexture;

private FoxVariantTexture(Identifier normalTexture, Identifier sleepTexture) {
public FoxVariantTexture(Identifier normalTexture, Identifier sleepTexture) {
this.normalTexture = Identifier.of(normalTexture.getNamespace(), "textures/entity/fox/" + normalTexture.getPath() + ".png");
this.sleepTexture = Identifier.of(sleepTexture.getNamespace(), "textures/entity/fox/" + sleepTexture.getPath() + ".png");
}

public static Identifier getTexture(FoxEntity fox) {
if("Talon".equals(fox.getName().getString())) {
return fox.isSleeping()?TALON.sleepTexture :TALON.normalTexture;
return foxTextures.get(Vulpine.TALON).getTextureIdentifier(fox.isSleeping());
}
if(foxTextures.containsKey(fox.getVariant())) {
return fox.isSleeping()?foxTextures.get(fox.getVariant()).sleepTexture :foxTextures.get(fox.getVariant()).normalTexture;
return foxTextures.get(fox.getVariant()).getTextureIdentifier(fox.isSleeping());
}
return null;
}

public static void addTexture(FoxEntity.Type type, String name){
foxTextures.put(type, new ModFoxType(name));
}

public static void init() {
foxTextures.put(Vulpine.SILVER_FOX,new FoxVariantTexture(Identifier.of("vulpine","silver"),Identifier.of("vulpine","silver_sleep")));
foxTextures.put(Vulpine.GRAY_FOX,new FoxVariantTexture(Identifier.of("vulpine","gray"),Identifier.of("vulpine","gray_sleep")));
foxTextures.put(Vulpine.CROSS_FOX,new FoxVariantTexture(Identifier.of("vulpine","cross"),Identifier.of("vulpine","cross_sleep")));
foxTextures.put(Vulpine.SILVER_FOX,new ModFoxType("silver"));
foxTextures.put(Vulpine.GRAY_FOX,new ModFoxType("gray"));
foxTextures.put(Vulpine.CROSS_FOX,new ModFoxType("cross"));
foxTextures.put(Vulpine.TALON,new ModFoxType("talon"));
foxTextures.put(Vulpine.FENNEC_FOX,new ModFoxType("fennec"));
foxTextures.put(Vulpine.NETHER_FOX,new ModFoxType("nether"));
}
}
2 changes: 1 addition & 1 deletion src/main/java/sh/talonfox/vulpine/IFoxTypeCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import net.minecraft.entity.passive.FoxEntity;

public interface IFoxTypeCreator {
FoxEntity.Type vulpine$newFoxVariant(String enumName, int ordinal, int id, String typeName);
FoxEntity.Type vulpine$newFoxVariant(String enumName, int ordinal, String typeName);


}
19 changes: 19 additions & 0 deletions src/main/java/sh/talonfox/vulpine/ModFoxType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package sh.talonfox.vulpine;

import net.minecraft.util.Identifier;

public class ModFoxType {
private String variantName;
private Identifier textureIdentifier;
private Identifier sleepingTextureIdentifier;

public ModFoxType(String variantName) {
this.variantName = variantName;
textureIdentifier = Identifier.of(Vulpine.MOD_ID,"textures/entity/fox/"+variantName+".png");
sleepingTextureIdentifier = Identifier.of(Vulpine.MOD_ID,"textures/entity/fox/"+variantName+"_sleep.png");
; }

public Identifier getTextureIdentifier(boolean isSleepling) {
return isSleepling?sleepingTextureIdentifier:textureIdentifier;
}
}
Loading

0 comments on commit 384949b

Please sign in to comment.