Skip to content

Commit

Permalink
生成条件和json
Browse files Browse the repository at this point in the history
(高度限制了,还差白天也能生成
  • Loading branch information
MagicHarp committed Oct 11, 2024
1 parent f695ddb commit 145be3e
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package org.confluence.mod.entity.BloodCrawler;

import net.minecraft.core.BlockPos;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.goal.*;
Expand All @@ -10,6 +14,7 @@
import net.minecraft.world.entity.monster.Spider;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import org.confluence.mod.entity.boss.TerraBossBase;
import software.bernie.geckolib.animatable.GeoEntity;
import software.bernie.geckolib.constant.DataTickets;
Expand Down Expand Up @@ -56,10 +61,25 @@ public static AttributeSupplier.Builder createAttributes() {
.add(Attributes.SPAWN_REINFORCEMENTS_CHANCE, 0.01) // 召唤物品的几率
.add(Attributes.KNOCKBACK_RESISTANCE, 0.5); // 击退抗性
}
public static boolean checkBloodCrawlerSpawn(EntityType<? extends Mob> type, LevelAccessor pLevel, MobSpawnType pSpawnType, BlockPos pPos, RandomSource pRandom) {
if (!(pLevel instanceof Level level)) {
return false; // 如果 pLevel 不是 Level 的实例,返回 false
}

if (!checkMobSpawnRules(type, pLevel, pSpawnType, pPos, pRandom)) {
return false; // 如果不满足基本生成规则,返回 false
}

int y = pPos.getY();
if (y >= 260) {
return false; // 不能生成在 y = 260 或更高的位置
}

private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
return true;
}


private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
@Override
public AnimatableInstanceCache getAnimatableInstanceCache() {
return cache;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/confluence/mod/event/ModEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ public static void spawnPlacementRegister(SpawnPlacementRegisterEvent event) {
event.register(ModEntities.BLACK_SLIME.get(), SpawnPlacements.Type.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, BaseSlime::checkSlimeSpawn, SpawnPlacementRegisterEvent.Operation.REPLACE);

event.register(ModEntities.DEMON_EYE.get(), SpawnPlacements.Type.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, DemonEye::checkDemonEyeSpawn, SpawnPlacementRegisterEvent.Operation.REPLACE);
event.register(ModEntities.BLOOD_CRAWLER.get(), SpawnPlacements.Type.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, BloodCrawler::checkBloodCrawlerSpawn, SpawnPlacementRegisterEvent.Operation.REPLACE);
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"type": "forge:add_spawns",
"biomes": [
"confluence:tr_crimson"
],
"spawners": {
"type": "confluence:blood_crawler",
"weight": 60,
"minCount": 1,
"maxCount": 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"type": "minecraft:entity",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "confluence:vertebra",
"weight": 33,
"functions": [
{
"function": "set_count",
"count": {
"min": 1,
"max": 1
}
}
]
},
{
"type": "minecraft:empty",
"weight": 67
}
]
}
],
"random_sequence": "confluence:entity/blood_crawler"
}

0 comments on commit 145be3e

Please sign in to comment.