Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/com/altnoir/poopsky/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Config {
private static final ModConfigSpec.BooleanValue SET_POOPSKY_DEFAULT = BUILDER
.comment("Whether the dedicated server level-type default should be set to poopsky")
.translation("poopsky.configuration.setPoopskyDefault")
.define("setPoopskyDefault", false);
.define("setPoopskyDefault", true);
private static final ModConfigSpec.BooleanValue VOID_NETHER_GENERATION = BUILDER
.comment("Whether the custom void generator should also keep the nether empty")
.translation("poopsky.configuration.voidNetherGeneration")
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/altnoir/poopsky/PoopSky.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.altnoir.poopsky.network.PSNetworking;
import com.altnoir.poopsky.villager.PSVillagers;
import com.altnoir.poopsky.worldgen.PSChunkGenerators;
import com.altnoir.poopsky.worldgen.PSStructures;
import com.altnoir.poopsky.worldgen.foliage.PSFoliagePlacerTypes;
import com.mojang.logging.LogUtils;
import net.minecraft.core.BlockPos;
Expand Down Expand Up @@ -52,6 +53,7 @@ public PoopSky(IEventBus modEventBus, ModContainer modContainer) {
PSItems.register(modEventBus);
PEntityType.register(modEventBus);
PSFoliagePlacerTypes.register(modEventBus);
PSStructures.register(modEventBus);
PSChunkGenerators.register(modEventBus);

PSItemGroups.register(modEventBus);
Expand Down
72 changes: 66 additions & 6 deletions src/main/java/com/altnoir/poopsky/entity/p/PoolimeEntity.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
package com.altnoir.poopsky.entity.p;

import com.altnoir.poopsky.PoopSky;
import com.altnoir.poopsky.block.PSBlocks;
import com.altnoir.poopsky.init.PParticles;
import com.altnoir.poopsky.init.PSoundEvents;
import net.minecraft.core.registries.Registries;
import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.util.RandomSource;
import net.minecraft.world.Difficulty;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
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.monster.Monster;
import net.minecraft.world.entity.monster.Slime;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.levelgen.structure.Structure;
import org.jetbrains.annotations.NotNull;

public class PoolimeEntity extends Slime {
Expand All @@ -28,10 +39,59 @@ public static AttributeSupplier.Builder createAttributes() {
return PParticles.POOP_PARTICLE.get();
}

public static boolean checkPoolimeSpawnRules(
EntityType<PoolimeEntity> poolime, LevelAccessor level, MobSpawnType spawnType, BlockPos pos, RandomSource random
) {
boolean flag = MobSpawnType.ignoresLightRequirements(spawnType);
return level.getBlockState(pos.below()).is(PSBlocks.POOLIME_POOP_BLOCK.get()) && flag;
@Override
protected SoundEvent getHurtSound(DamageSource damageSource) {
return this.isTiny() ? PSoundEvents.ENTITY_POOLIME_HURT_SMALL.get() : PSoundEvents.ENTITY_POOLIME_HURT.get();
}

@Override
protected SoundEvent getDeathSound() {
return this.isTiny() ? PSoundEvents.ENTITY_POOLIME_DEATH_SMALL.get() : PSoundEvents.ENTITY_POOLIME_DEATH.get();
}

@Override
protected SoundEvent getSquishSound() {
return this.isTiny() ? PSoundEvents.ENTITY_POOLIME_SQUISH_SMALL.get() : PSoundEvents.ENTITY_POOLIME_SQUISH.get();
}

@Override
protected SoundEvent getJumpSound() {
return this.isTiny() ? PSoundEvents.ENTITY_POOLIME_JUMP_SMALL.get() : PSoundEvents.ENTITY_POOLIME_JUMP.get();
}

@Override
protected void dealDamage(LivingEntity livingEntity) {
if (this.isAlive() && this.isWithinMeleeAttackRange(livingEntity) && this.hasLineOfSight(livingEntity)) {
DamageSource damageSource = this.damageSources().mobAttack(this);
if (livingEntity.hurt(damageSource, this.getAttackDamage())) {
this.playSound(PSoundEvents.ENTITY_POOLIME_ATTACK.get(), 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
if (this.level() instanceof ServerLevel serverLevel) {
EnchantmentHelper.doPostAttackEffects(serverLevel, livingEntity, damageSource);
}
}
}
}

public static boolean checkPoolimeSpawnRules(EntityType<PoolimeEntity> poolime, LevelAccessor level, MobSpawnType spawnType, BlockPos pos, RandomSource random) {
if (level.getDifficulty() == Difficulty.PEACEFUL || !Mob.checkMobSpawnRules(poolime, level, spawnType, pos, random)) {
return false;
}

if (MobSpawnType.ignoresLightRequirements(spawnType)) {
return true;
}

return level.getBlockState(pos.below()).is(PSBlocks.POOLIME_POOP_BLOCK.get()) || isInPoopIsland(level, pos);
}

private static boolean isInPoopIsland(LevelAccessor level, BlockPos pos) {
if (!(level instanceof ServerLevel serverLevel)) {
return false;
}

Structure structure = serverLevel.registryAccess()
.registryOrThrow(Registries.STRUCTURE)
.get(PoopSky.loc("poop_island"));
return structure != null && serverLevel.structureManager().getStructureAt(pos, structure).isValid();
}
}
}
10 changes: 9 additions & 1 deletion src/main/java/com/altnoir/poopsky/event/PSGameEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.altnoir.poopsky.villager.PSVillagerBehaviors;
import com.altnoir.poopsky.villager.PSVillagerTrades;
import com.altnoir.poopsky.worldgen.PSVoidChunkGenerator;
import com.altnoir.poopsky.worldgen.structure.PoopIslandStructure;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
Expand All @@ -26,6 +27,7 @@
import net.minecraft.world.item.*;
import net.minecraft.world.item.alchemy.PotionBrewing;
import net.minecraft.world.item.alchemy.Potions;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.ClipContext;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.Level;
Expand Down Expand Up @@ -147,8 +149,14 @@ public static void createSpawnToilet(LevelEvent.CreateSpawnPosition event) {
level.setBlock(pos, AllToiletBlocks.OAK_TOILET.get().defaultBlockState(), 2);

event.setCanceled(true);
event.getSettings().setSpawn(level.getHeightmapPos(Heightmap.Types.WORLD_SURFACE_WG, pos), 90.0F);
BlockPos spawn = level.getHeightmapPos(Heightmap.Types.WORLD_SURFACE_WG, pos);
event.getSettings().setSpawn(spawn, 90.0F);
level.getGameRules().getRule(GameRules.RULE_SPAWN_RADIUS).set(0, level.getServer());

PoopIslandStructure.registerGuaranteedSpawn(level.getSeed(), spawn);
BlockPos islandCenter = PoopIslandStructure.getGuaranteedSpawnIslandCenter(level.getSeed(), spawn);
ChunkPos islandChunk = new ChunkPos(islandCenter);
level.getChunk(islandChunk.x, islandChunk.z);
}
}
}
9 changes: 9 additions & 0 deletions src/main/java/com/altnoir/poopsky/init/PSoundEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ public class PSoundEvents {
public static final Supplier<SoundEvent> BLOCK_COMPOOPER_MAGGOTS = registerSoundEvent("block.compooper.maggots");
public static final Supplier<SoundEvent> ENTITY_VILLAGER_WORK_COMPOOPER = registerSoundEvent("entity.villager.work_compooper");
public static final Supplier<SoundEvent> ENTITY_VILLAGER_WORK_TOILET = registerSoundEvent("entity.villager.work_toilet");
public static final Supplier<SoundEvent> ENTITY_POOLIME_ATTACK = registerSoundEvent("entity.poolime.attack");
public static final Supplier<SoundEvent> ENTITY_POOLIME_DEATH = registerSoundEvent("entity.poolime.death");
public static final Supplier<SoundEvent> ENTITY_POOLIME_DEATH_SMALL = registerSoundEvent("entity.poolime.death_small");
public static final Supplier<SoundEvent> ENTITY_POOLIME_HURT = registerSoundEvent("entity.poolime.hurt");
public static final Supplier<SoundEvent> ENTITY_POOLIME_HURT_SMALL = registerSoundEvent("entity.poolime.hurt_small");
public static final Supplier<SoundEvent> ENTITY_POOLIME_JUMP = registerSoundEvent("entity.poolime.jump");
public static final Supplier<SoundEvent> ENTITY_POOLIME_JUMP_SMALL = registerSoundEvent("entity.poolime.jump_small");
public static final Supplier<SoundEvent> ENTITY_POOLIME_SQUISH = registerSoundEvent("entity.poolime.squish");
public static final Supplier<SoundEvent> ENTITY_POOLIME_SQUISH_SMALL = registerSoundEvent("entity.poolime.squish_small");

public static final Supplier<SoundEvent> LAWRENCE = registerSoundEvent("lawrence");
public static final ResourceKey<JukeboxSong> LAWRENCE_KEY = registerJukeboxSong("lawrence");
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/com/altnoir/poopsky/worldgen/PSStructures.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.altnoir.poopsky.worldgen;

import com.altnoir.poopsky.PoopSky;
import com.altnoir.poopsky.worldgen.structure.PoopIslandPiece;
import com.altnoir.poopsky.worldgen.structure.PoopIslandStructure;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.level.levelgen.structure.StructureType;
import net.minecraft.world.level.levelgen.structure.pieces.StructurePieceType;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredRegister;

public final class PSStructures {
public static final DeferredRegister<StructureType<?>> STRUCTURE_TYPES =
DeferredRegister.create(Registries.STRUCTURE_TYPE, PoopSky.MOD_ID);
public static final DeferredRegister<StructurePieceType> STRUCTURE_PIECES =
DeferredRegister.create(Registries.STRUCTURE_PIECE, PoopSky.MOD_ID);

public static final DeferredHolder<StructureType<?>, StructureType<PoopIslandStructure>> POOP_ISLAND =
STRUCTURE_TYPES.register("poop_island", () -> () -> PoopIslandStructure.CODEC);
public static final DeferredHolder<StructurePieceType, StructurePieceType> POOP_ISLAND_PIECE =
STRUCTURE_PIECES.register("poop_island", () -> (StructurePieceType.StructureTemplateType) PoopIslandPiece::new);

private PSStructures() {
}

public static void register(IEventBus eventBus) {
STRUCTURE_TYPES.register(eventBus);
STRUCTURE_PIECES.register(eventBus);
}
}
Loading