Skip to content

Commit

Permalink
Made fish spawn block require water on each side, instead of just 1
Browse files Browse the repository at this point in the history
  • Loading branch information
GirafiStudios committed Apr 22, 2020
1 parent 7572278 commit e2ab670
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ protected SoundEvent getFlopSound() {

@Override
@Nonnull
public EntitySize getSize(Pose pose) {
public EntitySize getSize(@Nonnull Pose pose) {
return super.getSize(pose);
}

@Override
public void onCollideWithPlayer(PlayerEntity player) {
public void onCollideWithPlayer(@Nonnull PlayerEntity player) {
super.onCollideWithPlayer(player);
if (Objects.equals(this.getType().getRegistryName(), AquaItems.JELLYFISH.getRegistryName())) {
if (this.isAlive()) {
Expand All @@ -88,8 +88,9 @@ public void onCollideWithPlayer(PlayerEntity player) {
}

public static boolean canSpawnHere(EntityType<? extends AbstractFishEntity> fish, IWorld world, SpawnReason spawnReason, BlockPos pos, Random random) {
boolean isNeighborWater = isSourceBlock(world, pos.north()) || isSourceBlock(world, pos.south()) || isSourceBlock(world, pos.west()) || isSourceBlock(world, pos.east());
return isSourceBlock(world, pos) && isNeighborWater;
boolean isAllNeighborsSource = isSourceBlock(world, pos.north()) && isSourceBlock(world, pos.south()) && isSourceBlock(world, pos.west()) && isSourceBlock(world, pos.east());
System.out.println(isSourceBlock(world, pos) && isAllNeighborsSource);
return isSourceBlock(world, pos) && isAllNeighborsSource;
}

private static boolean isSourceBlock(IWorld world, BlockPos pos) {
Expand Down

0 comments on commit e2ab670

Please sign in to comment.