mirror of
https://github.com/FatherToast/SpecialMobs.git
synced 2025-07-19 16:11:43 +00:00
le puff puff
This commit is contained in:
parent
446aca860e
commit
037faab4f0
1 changed files with 27 additions and 18 deletions
|
@ -97,43 +97,42 @@ public class DrowningCreeperEntity extends _SpecialCreeperEntity {
|
||||||
final int radius = (int) Math.floor( explosionPower );
|
final int radius = (int) Math.floor( explosionPower );
|
||||||
final int rMinusOneSq = (radius - 1) * (radius - 1);
|
final int rMinusOneSq = (radius - 1) * (radius - 1);
|
||||||
final BlockPos center = new BlockPos( explosion.getPos() );
|
final BlockPos center = new BlockPos( explosion.getPos() );
|
||||||
|
|
||||||
// Track how many pufferfish have been spawned
|
// Track how many pufferfish have been spawned
|
||||||
int pufferCount = 0;
|
spawnPufferfish( center.above( 1 ) );
|
||||||
|
int pufferCount = 1;
|
||||||
|
|
||||||
for( int y = -radius; y <= radius; y++ ) {
|
for( int y = -radius; y <= radius; y++ ) {
|
||||||
for( int x = -radius; x <= radius; x++ ) {
|
for( int x = -radius; x <= radius; x++ ) {
|
||||||
for( int z = -radius; z <= radius; z++ ) {
|
for( int z = -radius; z <= radius; z++ ) {
|
||||||
final int distSq = x * x + y * y + z * z;
|
final int distSq = x * x + y * y + z * z;
|
||||||
|
|
||||||
if( distSq <= radius * radius ) {
|
if( distSq <= radius * radius ) {
|
||||||
final BlockPos pos = center.offset( x, y, z );
|
final BlockPos pos = center.offset( x, y, z );
|
||||||
final BlockState stateAtPos = level.getBlockState( pos );
|
final BlockState stateAtPos = level.getBlockState( pos );
|
||||||
|
|
||||||
if( stateAtPos.getMaterial().isReplaceable() || stateAtPos.is( BlockTags.LEAVES )) {
|
if( stateAtPos.getMaterial().isReplaceable() || stateAtPos.is( BlockTags.LEAVES ) ) {
|
||||||
if( distSq > rMinusOneSq ) {
|
if( distSq > rMinusOneSq ) {
|
||||||
// Cobblestone casing
|
// "Coral" casing
|
||||||
level.setBlock( pos, random.nextFloat() < 0.25F ? brainCoral : hornCoral, References.SET_BLOCK_FLAGS );
|
level.setBlock( pos, random.nextFloat() < 0.25F ? brainCoral : hornCoral, References.SET_BLOCK_FLAGS );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
float f = random.nextFloat();
|
final float fillChoice = random.nextFloat();
|
||||||
|
|
||||||
if ( f > 0.9F && seaPickle.canSurvive( level, pos )) {
|
if( fillChoice < 0.1F && seaPickle.canSurvive( level, pos ) ) {
|
||||||
level.setBlock( pos, seaPickle, References.SET_BLOCK_FLAGS );
|
level.setBlock( pos, seaPickle, References.SET_BLOCK_FLAGS );
|
||||||
}
|
}
|
||||||
else if ( f > 0.7F && seaGrass.canSurvive( level, pos )) {
|
else if( fillChoice < 0.3F && seaGrass.canSurvive( level, pos ) ) {
|
||||||
level.setBlock( pos, seaGrass, References.SET_BLOCK_FLAGS );
|
level.setBlock( pos, seaGrass, References.SET_BLOCK_FLAGS );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Water fill
|
// Water fill
|
||||||
level.setBlock(pos, water, References.SET_BLOCK_FLAGS);
|
level.setBlock( pos, water, References.SET_BLOCK_FLAGS );
|
||||||
|
|
||||||
// Prevent greater radiuses from spawning a bazillion pufferfish
|
// Prevent greater radiuses from spawning a bazillion pufferfish
|
||||||
if (random.nextDouble() > 0.97D && pufferCount < 50) {
|
if( random.nextFloat() < 0.01F && pufferCount < 10 ) {
|
||||||
PufferfishEntity pufferfish = EntityType.PUFFERFISH.create(level);
|
spawnPufferfish( pos );
|
||||||
pufferfish.setPos(pos.getX(), pos.getY(), pos.getZ());
|
pufferCount++;
|
||||||
level.addFreshEntity(pufferfish);
|
|
||||||
++pufferCount;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,6 +143,16 @@ public class DrowningCreeperEntity extends _SpecialCreeperEntity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Helper method to simplify spawning pufferfish. */
|
||||||
|
private void spawnPufferfish( BlockPos pos ) {
|
||||||
|
final PufferfishEntity lePuffPuff = EntityType.PUFFERFISH.create( level );
|
||||||
|
if( lePuffPuff != null ) {
|
||||||
|
lePuffPuff.setPos( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 );
|
||||||
|
level.addFreshEntity( lePuffPuff );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static final ResourceLocation[] TEXTURES = {
|
private static final ResourceLocation[] TEXTURES = {
|
||||||
GET_TEXTURE_PATH( "drowning" ),
|
GET_TEXTURE_PATH( "drowning" ),
|
||||||
GET_TEXTURE_PATH( "drowning_eyes" )
|
GET_TEXTURE_PATH( "drowning_eyes" )
|
||||||
|
|
Loading…
Add table
Reference in a new issue