Skip to content

Commit c3e7283

Browse files
committed
Fix Chu Chu hitbox (Closes #132)
1 parent 1f4d5e0 commit c3e7283

2 files changed

Lines changed: 15 additions & 17 deletions

File tree

src/main/java/com/mrbysco/forcecraft/entities/ChuChuEntity.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@
33
import net.minecraft.core.BlockPos;
44
import net.minecraft.util.RandomSource;
55
import net.minecraft.world.Difficulty;
6+
import net.minecraft.world.DifficultyInstance;
67
import net.minecraft.world.entity.EntityType;
78
import net.minecraft.world.entity.MobSpawnType;
8-
import net.minecraft.world.entity.ai.attributes.Attributes;
9+
import net.minecraft.world.entity.SpawnGroupData;
910
import net.minecraft.world.entity.monster.Slime;
1011
import net.minecraft.world.level.ChunkPos;
1112
import net.minecraft.world.level.Level;
1213
import net.minecraft.world.level.LevelAccessor;
14+
import net.minecraft.world.level.ServerLevelAccessor;
1315
import net.minecraft.world.level.WorldGenLevel;
1416
import net.minecraft.world.level.biome.Biomes;
1517
import net.minecraft.world.level.levelgen.WorldgenRandom;
18+
import org.jetbrains.annotations.Nullable;
1619

1720
public class ChuChuEntity extends Slime {
1821

@@ -25,19 +28,14 @@ protected boolean isDealsDamage() {
2528
return true;
2629
}
2730

31+
@Nullable
2832
@Override
29-
public void setSize(int size, boolean resetHealth) {
30-
this.entityData.set(ID_SIZE, 1);
31-
this.reapplyPosition();
32-
this.refreshDimensions();
33-
this.getAttribute(Attributes.MAX_HEALTH).setBaseValue((double) (size));
34-
this.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue((double) (0.2F + 0.1F));
35-
this.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(((double) 1 + random.nextInt(2)));
36-
if (resetHealth) {
37-
this.setHealth(this.getMaxHealth());
38-
}
39-
40-
this.xpReward = 1;
33+
public SpawnGroupData finalizeSpawn(ServerLevelAccessor level, DifficultyInstance difficulty, MobSpawnType spawnType, @Nullable SpawnGroupData spawnGroupData) {
34+
SpawnGroupData data = super.finalizeSpawn(level, difficulty, spawnType, spawnGroupData);
35+
int newSize = 1 + random.nextInt(2);
36+
System.out.println(newSize);
37+
this.setSize(newSize, true);
38+
return data;
4139
}
4240

4341
public static boolean canSpawnHere(EntityType<ChuChuEntity> chuEntityEntityType, LevelAccessor level, MobSpawnType reason, BlockPos pos, RandomSource randomIn) {

src/main/java/com/mrbysco/forcecraft/registry/ForceEntities.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ public class ForceEntities {
5050

5151
public static final Supplier<EntityType<ChuChuEntity>> RED_CHU_CHU = ENTITY_TYPES.register("red_chu_chu", () ->
5252
register("red_chu_chu", EntityType.Builder.<ChuChuEntity>of(ChuChuEntity::new, MobCategory.MONSTER)
53-
.sized(2.04F, 2.04F).clientTrackingRange(10)));
53+
.sized(0.52F, 0.52F).eyeHeight(0.325F).spawnDimensionsScale(4.0F).clientTrackingRange(10)));
5454
public static final Supplier<EntityType<ChuChuEntity>> GREEN_CHU_CHU = ENTITY_TYPES.register("green_chu_chu", () ->
5555
register("green_chu_chu", EntityType.Builder.<ChuChuEntity>of(ChuChuEntity::new, MobCategory.MONSTER)
56-
.sized(2.04F, 2.04F).clientTrackingRange(10)));
56+
.sized(0.52F, 0.52F).eyeHeight(0.325F).spawnDimensionsScale(4.0F).clientTrackingRange(10)));
5757
public static final Supplier<EntityType<ChuChuEntity>> BLUE_CHU_CHU = ENTITY_TYPES.register("blue_chu_chu", () ->
5858
register("blue_chu_chu", EntityType.Builder.<ChuChuEntity>of(ChuChuEntity::new, MobCategory.MONSTER)
59-
.sized(2.04F, 2.04F).clientTrackingRange(10)));
59+
.sized(0.52F, 0.52F).eyeHeight(0.325F).spawnDimensionsScale(4.0F).clientTrackingRange(10)));
6060
public static final Supplier<EntityType<ChuChuEntity>> GOLD_CHU_CHU = ENTITY_TYPES.register("gold_chu_chu", () ->
6161
register("gold_chu_chu", EntityType.Builder.<ChuChuEntity>of(ChuChuEntity::new, MobCategory.MONSTER)
62-
.sized(2.04F, 2.04F).clientTrackingRange(10)));
62+
.sized(0.52F, 0.52F).eyeHeight(0.325F).spawnDimensionsScale(4.0F).clientTrackingRange(10)));
6363

6464
public static final Supplier<EntityType<CreeperTotEntity>> CREEPER_TOT = ENTITY_TYPES.register("creeper_tot", () ->
6565
register("creeper_tot", EntityType.Builder.<CreeperTotEntity>of(CreeperTotEntity::new, MobCategory.MONSTER)

0 commit comments

Comments
 (0)