Skip to content

Commit fefad70

Browse files
committed
Underp insects
1 parent 39aea73 commit fefad70

File tree

5 files changed

+28
-14
lines changed

5 files changed

+28
-14
lines changed

src/main/java/drzhark/mocreatures/entity/MoCEntityInsect.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,20 @@ public float getEyeHeight() {
6060

6161
@Override
6262
public boolean getIsFlying() {
63-
return (isOnAir() || !onGround) && (motionX != 0 || motionY != 0 || motionZ != 0);
63+
return this.isOnAir() && !this.isOnLadder();
6464
}
6565

6666
@Override
6767
public void onLivingUpdate() {
6868
super.onLivingUpdate();
6969

70-
if (!this.onGround && this.motionY < 0.0D) {
70+
if (this.isInWater()) {
7171
this.motionY *= 0.6D;
7272
}
7373

7474
if (!this.world.isRemote) {
75-
if (isAttractedToLight() && this.rand.nextInt(50) == 0) {
76-
int[] ai = MoCTools.returnNearestBlockCoord(this, Blocks.TORCH, 8D);
75+
if (this.rand.nextInt(50) == 0) {
76+
int[] ai = MoCTools.returnNearestBlockCoord(this, this.isAttractedToLight() ? Blocks.TORCH : Blocks.TALLGRASS, 8D);
7777
if (ai[0] > -1000) {
7878
this.getNavigator().tryMoveToXYZ(ai[0], ai[1], ai[2], 1.0D);
7979
}
@@ -85,9 +85,6 @@ public void onLivingUpdate() {
8585
}
8686
}
8787

88-
/**
89-
* Is this insect attracted to light?
90-
*/
9188
public boolean isAttractedToLight() {
9289
return false;
9390
}
@@ -106,7 +103,7 @@ public boolean isOnLadder() {
106103
}
107104

108105
public boolean climbing() {
109-
return (this.climbCounter != 0);
106+
return this.climbCounter != 0;
110107
}
111108

112109
@Override

src/main/java/drzhark/mocreatures/entity/ambient/MoCEntityAnt.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ public void setHasFood(boolean flag) {
6262
public void onLivingUpdate() {
6363
super.onLivingUpdate();
6464

65+
if (this.isInWater()) {
66+
this.motionY *= 0.6D;
67+
}
68+
6569
if (!this.world.isRemote) {
6670
if (!getHasFood()) {
6771
EntityItem entityitem = MoCTools.getClosestFood(this, 8D);

src/main/java/drzhark/mocreatures/entity/ambient/MoCEntityCrab.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ public int nameYOffset() {
156156
}
157157

158158
@Override
159-
public boolean isReadyToFollowOwnerPlayer() { return !this.isMovementCeased(); }
159+
public boolean isReadyToFollowOwnerPlayer() {
160+
return !this.isMovementCeased();
161+
}
160162

161163
@Override
162164
protected SoundEvent getDeathSound() {

src/main/java/drzhark/mocreatures/entity/ambient/MoCEntityCricket.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import drzhark.mocreatures.MoCreatures;
77
import drzhark.mocreatures.entity.MoCEntityAmbient;
8+
import drzhark.mocreatures.entity.ai.EntityAIWanderMoC2;
89
import drzhark.mocreatures.init.MoCLootTables;
910
import drzhark.mocreatures.init.MoCSoundEvents;
1011
import net.minecraft.entity.SharedMonsterAttributes;
@@ -24,6 +25,11 @@ public MoCEntityCricket(World world) {
2425
setSize(0.4F, 0.3F);
2526
}
2627

28+
@Override
29+
protected void initEntityAI() {
30+
this.tasks.addTask(1, new EntityAIWanderMoC2(this, 1.2D));
31+
}
32+
2733
@Override
2834
protected void applyEntityAttributes() {
2935
super.applyEntityAttributes();
@@ -56,6 +62,11 @@ public ResourceLocation getTexture() {
5662
@Override
5763
public void onLivingUpdate() {
5864
super.onLivingUpdate();
65+
66+
if (this.isInWater()) {
67+
this.motionY *= 0.6D;
68+
}
69+
5970
if (!this.world.isRemote) {
6071
if (this.jumpCounter > 0 && ++this.jumpCounter > 30) {
6172
this.jumpCounter = 0;
@@ -113,9 +124,4 @@ public float getAIMoveSpeed() {
113124
public float getEyeHeight() {
114125
return 0.15F;
115126
}
116-
117-
@Override
118-
public int getMaxSpawnedInChunk() {
119-
return 4;
120-
}
121127
}

src/main/java/drzhark/mocreatures/entity/ambient/MoCEntityFly.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ public MoCEntityFly(World world) {
2626
this.texture = "fly.png";
2727
}
2828

29+
@Override
30+
public boolean isAttractedToLight() {
31+
return true;
32+
}
33+
2934
@Override
3035
public void onLivingUpdate() {
3136
super.onLivingUpdate();

0 commit comments

Comments
 (0)