Skip to content

Commit

Permalink
- added spawning in all types of taigas and more rarely in snowy plai…
Browse files Browse the repository at this point in the history
…ns, frozen rivers, ice spikes and windswept gravelly hills

- added sound to braking plushie
- removed broken particles of plushie
- plushie now drops itself when broken
- Fixed animations and models
- added plushie to functional itemgroup
- added translations
  • Loading branch information
rotgruengelb committed Apr 16, 2024
1 parent 21bf430 commit a0b2475
Show file tree
Hide file tree
Showing 16 changed files with 186 additions and 11 deletions.
6 changes: 2 additions & 4 deletions src/main/java/net/rotgruengelb/forestal/Forestal.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package net.rotgruengelb.forestal;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry;
import net.rotgruengelb.forestal.block.ForestalBlocks;
import net.rotgruengelb.forestal.entity.ForestalEntities;
import net.rotgruengelb.forestal.entity.GrizzlyBearEntity;
import net.rotgruengelb.forestal.item.ForestalItems;
import net.rotgruengelb.forestal.world.gen.ForestalWorldGeneration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -19,7 +18,6 @@ public void onInitialize() {
ForestalBlocks.registerModBlocks();
ForestalEntities.registerModEntities();
ForestalItems.registerModItems();

FabricDefaultAttributeRegistry.register(ForestalEntities.GRIZZLY_BEAR, GrizzlyBearEntity.createGrizzlyBearAttributes());
ForestalWorldGeneration.generateModWorldGeneration();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import net.minecraft.item.BlockItem;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.Identifier;
import net.rotgruengelb.forestal.Forestal;

public class ForestalBlocks {

public static final Block GRIZZLY_PLUSHIE = registerBlock("grizzly_plushie",
new PlushieBlock(FabricBlockSettings.create()
.nonOpaque()));
public static final Block GRIZZLY_PLUSHIE = registerBlock("grizzly_plushie", new PlushieBlock(FabricBlockSettings.create()
.nonOpaque().breakInstantly().noBlockBreakParticles().sounds(BlockSoundGroup.WOOL)));

private static Block registerBlockNoItem(String name, Block block) {
return Registry.register(Registries.BLOCK, new Identifier(Forestal.MOD_ID, name), block);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.rotgruengelb.forestal.entity;

import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityType;
Expand All @@ -16,5 +17,7 @@ public class ForestalEntities {

public static void registerModEntities() {
Forestal.LOGGER.debug("Registering ForestalEntities for " + Forestal.MOD_ID);

FabricDefaultAttributeRegistry.register(ForestalEntities.GRIZZLY_BEAR, GrizzlyBearEntity.createGrizzlyBearAttributes());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.block.BlockState;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.ai.goal.*;
import net.minecraft.entity.attribute.DefaultAttributeContainer;
import net.minecraft.entity.attribute.EntityAttributes;
Expand All @@ -13,10 +14,13 @@
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.recipe.Ingredient;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.ServerWorldAccess;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import software.bernie.geckolib.animatable.GeoEntity;
Expand All @@ -40,6 +44,13 @@ public static DefaultAttributeContainer.Builder createGrizzlyBearAttributes() {
.add(EntityAttributes.GENERIC_ATTACK_DAMAGE, 6.0);
}

public static boolean isValidGrizzlyBearSpawn(EntityType<GrizzlyBearEntity> grizzlyBearEntityEntityType, ServerWorldAccess world, SpawnReason spawnReason, BlockPos pos, Random random) {
boolean bl = SpawnReason.isTrialSpawner(spawnReason) || AnimalEntity.isLightLevelValidForNaturalSpawn(world, pos);
return (world.getBlockState(pos.down())
.isIn(BlockTags.ANIMALS_SPAWNABLE_ON) || world.getBlockState(pos.down())
.isIn(BlockTags.ICE)) && bl;
}

@Nullable
@Override
public PassiveEntity createChild(ServerWorld world, PassiveEntity entity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import net.rotgruengelb.forestal.Forestal;
import net.rotgruengelb.forestal.entity.ForestalEntities;

import static net.rotgruengelb.forestal.block.ForestalBlocks.GRIZZLY_PLUSHIE;

public class ForestalItems {
public static final Item GRIZZLY_BEAR_SPAWN_EGG = registerItem("grizzly_bear_spawn_egg", new SpawnEggItem(ForestalEntities.GRIZZLY_BEAR, 0x966240, 0x553a28, new FabricItemSettings()));

Expand All @@ -22,6 +24,7 @@ private static Item registerItem(String name, Item item) {

public static void addItemsToItemGroup() {
addToItemGroup(ItemGroups.SPAWN_EGGS, GRIZZLY_BEAR_SPAWN_EGG);
addToItemGroup(ItemGroups.FUNCTIONAL, GRIZZLY_PLUSHIE.asItem());
}

private static void addToItemGroup(RegistryKey<ItemGroup> group, Item item) {
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/net/rotgruengelb/forestal/util/ForestalTags.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package net.rotgruengelb.forestal.util;

import net.minecraft.item.Item;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.util.Identifier;
import net.minecraft.world.biome.Biome;
import net.rotgruengelb.forestal.Forestal;

public class ForestalTags {
public static class Biomes {
private static TagKey<Biome> of(String id) {
return TagKey.of(RegistryKeys.BIOME, new Identifier(Forestal.MOD_ID, id));
}

public static class SPAWNS_GRIZZLY_BEAR {
public static final TagKey<Biome> COMMON = of("spawns_entity/grizzly_bear/common");
public static final TagKey<Biome> RARE = of("spawns_entity/grizzly_bear/rare");
public static final TagKey<Biome> ALL = of("spawns_entity/grizzly_bear");
}
}

public static class Items {

private static TagKey<Item> of(String id) {
return TagKey.of(RegistryKeys.ITEM, new Identifier(Forestal.MOD_ID, id));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package net.rotgruengelb.forestal.world.gen;

import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
import net.fabricmc.fabric.api.biome.v1.BiomeSelectors;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.entity.SpawnRestriction;
import net.minecraft.world.Heightmap;
import net.rotgruengelb.forestal.entity.ForestalEntities;
import net.rotgruengelb.forestal.entity.GrizzlyBearEntity;
import net.rotgruengelb.forestal.util.ForestalTags;

public class ForestalEntityGeneration {
public static void addSpawns() {
BiomeModifications.addSpawn(BiomeSelectors.tag(ForestalTags.Biomes.SPAWNS_GRIZZLY_BEAR.COMMON), SpawnGroup.CREATURE, ForestalEntities.GRIZZLY_BEAR, 30, 1, 2);

BiomeModifications.addSpawn(BiomeSelectors.tag(ForestalTags.Biomes.SPAWNS_GRIZZLY_BEAR.RARE), SpawnGroup.CREATURE, ForestalEntities.GRIZZLY_BEAR, 7, 1, 1);

SpawnRestriction.register(ForestalEntities.GRIZZLY_BEAR, SpawnRestriction.Location.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, GrizzlyBearEntity::isValidGrizzlyBearSpawn);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package net.rotgruengelb.forestal.world.gen;

public class ForestalWorldGeneration {

public static void generateModWorldGeneration() {
ForestalEntityGeneration.addSpawns();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
"vector": ["Math.sin((query.anim_time + 0.1) * 180) * 1.5", 0, 0]
},
"position": {
"vector": [0, "Math.sin((query.anim_time - 0.0) * 180) * 0.4", 0]
"vector": [0, "-1+Math.sin((query.anim_time - 0.0) * 180) * 0.4", 0]
}
},
"body": {
"position": {
"vector": [0, "Math.sin((query.anim_time - 0.0) * 180) * 0.4", 0]
"vector": [0, "-1+Math.sin((query.anim_time - 0.0) * 180) * 0.4", 0]
}
}
}
Expand Down Expand Up @@ -113,6 +113,11 @@
"position": {
"vector": [0, -7, 0]
}
},
"body": {
"position": {
"vector": [0, "Math.sin((query.anim_time - 0.0) * 120) * 0.4", 0]
}
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/assets/forestal/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"block.forestal.grizzly_plushie": "Grizzly Bear Plushie",
"entity.forestal.grizzly_bear": "Grizzly Bear",
"item.forestal.grizzly_bear_spawn_egg": "Grizzly Bear Spawn Egg"
}
Loading

0 comments on commit a0b2475

Please sign in to comment.