Skip to content

Commit

Permalink
burial dirt, holler AI & correct stone tablet lang keys
Browse files Browse the repository at this point in the history
  • Loading branch information
PssbleTrngle committed Oct 31, 2024
1 parent 67b0439 commit 5378b47
Show file tree
Hide file tree
Showing 22 changed files with 192 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// 1.20.1 2024-10-29T21:45:26.5470397 Oreganized Block Tags
// 1.20.1 2024-10-31T10:50:07.0060003 Oreganized Block Tags
25423f94c07158f094e4e9733efc1d1814551369 data/doom_and_gloom/tags/blocks/burial_dirt_convertible.json
589cbf5d60b97fd78f711d832bfddf03263777f2 data/doom_and_gloom/tags/blocks/gravetender_lightables.json
09f2b6ffb4a23fce3358928616260d7ffaa73074 data/doom_and_gloom/tags/blocks/vigil_candles.json
01bff27953e934409d6d1175c4932c12a6f535c7 data/minecraft/tags/blocks/candles.json
422eaf060e2279ae1bb4992ab5b94a47f193a3d8 data/minecraft/tags/blocks/mineable/pickaxe.json
6e91c0be5e5b3d50cf0d1a8dec3e23c0ee042c05 data/minecraft/tags/blocks/dirt.json
734c9c36a0d0f32caf72e941b2f0d14e9f0b5b6d data/minecraft/tags/blocks/mineable/pickaxe.json
6b73bb0ce38222c428d54ee64e82ffa1d96c64d7 data/oreganized/tags/blocks/fire_source.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "doom_and_gloom:block/burial_dirt"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"block.doom_and_gloom.blue_vigil_candle": "Blue Vigil Candle",
"block.doom_and_gloom.bone_pile": "Pile of Bones",
"block.doom_and_gloom.brown_vigil_candle": "Brown Vigil Candle",
"block.doom_and_gloom.burial_dirt": "Burial Dirt",
"block.doom_and_gloom.coral_vigil_candle": "Coral Vigil Candle",
"block.doom_and_gloom.cyan_vigil_candle": "Cyan Vigil Candle",
"block.doom_and_gloom.forest_vigil_candle": "Forest Vigil Candle",
Expand Down Expand Up @@ -42,6 +43,8 @@
"effect.doom_and_gloom.warding.description": "Wards against evil spirits",
"entity.doom_and_gloom.dirt_mound": "Dirt Mound",
"entity.doom_and_gloom.holler": "Holler",
"gui.doom_and_gloom.stone_tablet.cancel": "Cancel",
"gui.doom_and_gloom.stone_tablet.engrave": "Engrave",
"item.doom_and_gloom.bush_hammer": "Bush Hammer",
"item.doom_and_gloom.holler_spawn_egg": "Holler Spawn Egg",
"item.doom_and_gloom.music_disc_afterlife": "Music Disc",
Expand All @@ -53,7 +56,7 @@
"subtitles.block.sepulcher.sealing": "Sepulcher sealed",
"subtitles.block.sepulcher.unsealing": "Sepulcher opened",
"subtitles.entity.holler_death": "Holler dies",
"subtitles.entity.holler_hollers": "Holler hollers",
"subtitles.entity.holler_hollers": "Holler wails",
"subtitles.entity.holler_hurt": "Holler hurts",
"subtitles.entity.holler_shrieks": "Holler shrieks"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parent": "minecraft:block/cube_top",
"textures": {
"side": "minecraft:block/dirt",
"top": "doom_and_gloom:block/burial_dirt"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "doom_and_gloom:block/burial_dirt"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:dirt"
}
],
"rolls": 1.0
}
],
"random_sequence": "doom_and_gloom:blocks/burial_dirt"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"values": [
"#minecraft:candles",
{
"id": "#amendments:skull_candles",
"required": false
}
]
}
5 changes: 5 additions & 0 deletions src/generated/resources/data/minecraft/tags/blocks/dirt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"doom_and_gloom:burial_dirt"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"values": [
"doom_and_gloom:sepulcher",
"doom_and_gloom:bone_pile",
"#doom_and_gloom:vigil_candles"
"#doom_and_gloom:vigil_candles",
"doom_and_gloom:sepulcher"
]
}
7 changes: 7 additions & 0 deletions src/main/java/galena/doom_and_gloom/DoomAndGloom.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,16 @@ public void buildCreativeModeTabContents(BuildCreativeModeTabContentsEvent event

putAfter(entries, Blocks.BONE_BLOCK, OBlocks.BONE_PILE);

putAfter(entries, Blocks.INFESTED_DEEPSLATE, OBlocks.BURIAL_DIRT);

if (tab == CreativeModeTabs.SPAWN_EGGS) {
event.accept(new ItemStack(OItems.HOLLER_SPAWN_EGG.get()));
}

if (tab == CreativeModeTabs.TOOLS_AND_UTILITIES) {
event.accept(new ItemStack(OBlocks.STONE_TABLET.get()));
}

}

private static void putAfter(MutableHashedLinkedMap<ItemStack, CreativeModeTab.TabVisibility> entries, ItemLike after, Supplier<? extends ItemLike> supplier) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package galena.doom_and_gloom.content.block;

import galena.doom_and_gloom.index.OTags;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;

public class BurialDirtBlock extends Block {

public BurialDirtBlock(Properties properties) {
super(properties.randomTicks());
}

@Override
public void spawnAfterBreak(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack, boolean pDropExperience) {
spawnMonster(level, pos);
}

private EntityType<? extends Mob> randomMonster(RandomSource random) {
if (random.nextDouble() < 0.3) return EntityType.SKELETON;
return EntityType.ZOMBIE;
}

public void spawnMonster(Level level, BlockPos pos) {
if (!(level instanceof ServerLevel serverLevel)) return;

var monster = randomMonster(level.random).create(level);
if (monster != null) {
monster.moveTo(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, 0, 0);
monster.addEffect(new MobEffectInstance(MobEffects.LEVITATION, 14, 2, false, false));
serverLevel.addFreshEntity(monster);
monster.finalizeSpawn(serverLevel, serverLevel.getCurrentDifficultyAt(pos), MobSpawnType.NATURAL, null, null);
monster.spawnAnim();
}
}

private void discard(ServerLevel level, BlockPos pos) {
level.setBlockAndUpdate(pos, Blocks.DIRT.defaultBlockState());
}

@Override
public void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) {
if(random.nextInt(64) == 0) return;

if (level.isNight() && random.nextInt(32) == 0) {
spawnMonster(level, pos);
discard(level, pos);
return;
}

if (!level.getBlockState(pos.above()).canBeReplaced()) {
discard(level, pos);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private static VoxelShape[] createShapes(boolean hanging) {
private static final VoxelShape[] SHAPES = createShapes(false);
private static final VoxelShape[] HANGING_SHAPES = createShapes(true);

public static final ToIntFunction<BlockState> LIGHT_EMISSION = state -> state.getValue(LIT) ? 4 * state.getValue(CANDLES) : 0;
public static final ToIntFunction<BlockState> LIGHT_EMISSION = state -> state.getValue(LIT) ? (4 * state.getValue(CANDLES) - 1) : 0;

public VigilCandleBlock(Properties properties) {
super(properties);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package galena.doom_and_gloom.content.entity.holler;

import galena.doom_and_gloom.index.OBlocks;
import galena.doom_and_gloom.index.OEffects;
import galena.doom_and_gloom.index.OEntityTypes;
import galena.doom_and_gloom.index.OItems;
Expand Down Expand Up @@ -37,17 +38,18 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.LightLayer;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.JukeboxBlock;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.pathfinder.BlockPathTypes;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;

import java.time.LocalDate;
import java.time.temporal.ChronoField;
import java.util.List;
import java.util.function.Supplier;

public class Holler extends PathfinderMob {

Expand Down Expand Up @@ -94,7 +96,7 @@ protected Brain.Provider<?> brainProvider() {
protected void customServerAiStep() {
super.customServerAiStep();
if (tickCount % 20 == 0) {
applyFogAround((ServerLevel) level(), position(), this, 20);
applyFogAround((ServerLevel) level(), position(), this, 20);
}
}

Expand Down Expand Up @@ -208,7 +210,7 @@ protected float getSoundVolume() {
return 0.4F;
}

private void disappear(ServerLevel level) {
void disappear() {
playSound(OSoundEvents.HOLLER_SHRIEKS.get(), 1F, 1F);
discard();
}
Expand All @@ -220,7 +222,7 @@ public void panicFinish(Vec3 target) {
var state = level.getBlockState(blockPosition());

if (state.is(Blocks.JUKEBOX)) {
disappear(level);
disappear();

if (state.getValue(JukeboxBlock.HAS_RECORD)) return;

Expand All @@ -235,29 +237,31 @@ public void panicFinish(Vec3 target) {
});
} else {
curseGround(level, blockPosition());
disappear(level);
disappear();
}
}

private void curseBlock(ServerLevel level, BlockPos pos) {
var dirtMound = OEntityTypes.DIRT_MOUND.get().create(level);
if (dirtMound == null) return;
if (level.random.nextDouble() > 0.3) return;

dirtMound.setPos(Vec3.upFromBottomCenterOf(pos, 1));
level.addFreshEntity(dirtMound);
if (level.random.nextBoolean()) {
level.setBlockAndUpdate(pos, OBlocks.BURIAL_DIRT.get().defaultBlockState());
} else if (level.random.nextBoolean()) {
level.setBlockAndUpdate(pos, Blocks.DIRT.defaultBlockState());
} else {
level.setBlockAndUpdate(pos, Blocks.COARSE_DIRT.defaultBlockState());
}

var vec = Vec3.atCenterOf(blockPosition()).add(Math.random() * 0.5 - 0.25, 1 + Math.random() * 0.2, Math.random() * 0.5 - 0.25);
level.sendParticles(OParticleTypes.HOLLERING_SOUL.get(), vec.x, vec.y, vec.z, 1, 0, 0, 0, 0);
var vec = Vec3.atCenterOf(pos.above());
level.sendParticles(OParticleTypes.HOLLERING_SOUL.get(), vec.x, vec.y, vec.z, 4, 0.5, 0.5, 0.5, 0.01);
}

private void curseGround(ServerLevel level, BlockPos center) {
var aabb = new AABB(center).inflate(2, 1, 2);
BlockPos.betweenClosedStream(aabb).forEach(pos -> {
if (level.random.nextDouble() > 0.2) return;
if (!level.getBlockState(pos.above()).canBeReplaced()) return;

var state = level.getBlockState(pos);
if (state.is(OTags.Blocks.CAN_TURN_INTO_BURIAL_DIRT)) {
var above = level.getBlockState(pos.above());
if (state.is(OTags.Blocks.CAN_TURN_INTO_BURIAL_DIRT) && above.canBeReplaced()) {
curseBlock(level, pos);
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package galena.doom_and_gloom.content.entity.holler;

import galena.doom_and_gloom.index.OEffects;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.ai.goal.Goal;
import net.minecraft.world.entity.ai.targeting.TargetingConditions;
import net.minecraft.world.entity.ai.util.AirRandomPos;
Expand All @@ -13,26 +16,37 @@ public class HollerAvoidGoal extends Goal {
private final float speedModifier;
private final TargetingConditions targetingCondition;
private Path path = null;

private boolean disapearAfterwards = false;

public HollerAvoidGoal(Holler mob, double atDistance, float speedModifier) {
this.mob = mob;
this.atDistance = atDistance;
this.speedModifier = speedModifier;
this.targetingCondition = TargetingConditions.forNonCombat().range(atDistance);
this.targetingCondition = TargetingConditions.forNonCombat().range(atDistance).ignoreLineOfSight()
.selector(it -> it instanceof ServerPlayer player && player.gameMode.isSurvival());
}

@Override
public void stop() {
mob.getNavigation().stop();
if (disapearAfterwards) {
mob.disappear();
}
}

@Override
public boolean canUse() {
var avoid = mob.level().getNearestEntity(mob.level().getEntitiesOfClass(Player.class, mob.getBoundingBox().inflate(atDistance)), targetingCondition, mob, mob.getX(), mob.getY(), mob.getZ());
var avoid = mob.getTarget();

if (avoid == null) {
avoid = mob.level().getNearestEntity(mob.level().getEntitiesOfClass(Player.class, mob.getBoundingBox().inflate(atDistance)), targetingCondition, mob, mob.getX(), mob.getY(), mob.getZ());
}

if (avoid != null) {
disapearAfterwards = avoid.hasEffect(OEffects.WARDING.get());
var target = mob.position().subtract(avoid.position());
var away = AirRandomPos.getPosTowards(mob, 4, 1, 0, target, 1F);
var radius = disapearAfterwards ? 24 : 4;
var away = AirRandomPos.getPosTowards(mob, radius, 1, 0, target, 1F);
if (away != null) path = mob.getNavigation().createPath(away.x, away.y, away.z, 0);
} else {
path = null;
Expand All @@ -42,12 +56,12 @@ public boolean canUse() {

@Override
public boolean canContinueToUse() {
return !mob.getNavigation().isDone() || canUse();
return !mob.getNavigation().isDone();
}

@Override
public void start() {
mob.getNavigation().moveTo(path, speedModifier);
mob.getNavigation().moveTo(path, disapearAfterwards ? speedModifier : 1F);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package galena.doom_and_gloom.content.entity.holler;

import galena.doom_and_gloom.index.OEffects;
import net.minecraft.world.entity.PathfinderMob;
import net.minecraft.world.entity.ai.behavior.EntityTracker;
import net.minecraft.world.entity.ai.goal.Goal;
Expand Down Expand Up @@ -36,6 +37,11 @@ private boolean tooClose() {
var target = mob.getTarget();
if(target == null) return false;
var distanceSquared = mob.distanceToSqr(target);

if(target.hasEffect(OEffects.FOG.get())) {
return false;
}

return distanceSquared < panicDistanceSquared;
}

Expand Down
Loading

0 comments on commit 5378b47

Please sign in to comment.