From 6f9b119b8b45e3111e2a2effe0e5cbab017e0bda Mon Sep 17 00:00:00 2001 From: Kli Kli Date: Thu, 25 Jan 2024 07:17:36 +0100 Subject: [PATCH] feat: increase foliot size slightly --- .../client/render/entity/FoliotRenderer.java | 2 + .../common/entity/job/LumberjackJob.java | 9 ---- .../common/entity/spirit/DjinniEntity.java | 30 +++++------- .../common/entity/spirit/FoliotEntity.java | 47 +++++++++++++++++++ .../occultism/registry/OccultismEntities.java | 4 +- 5 files changed, 64 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/klikli_dev/occultism/client/render/entity/FoliotRenderer.java b/src/main/java/com/klikli_dev/occultism/client/render/entity/FoliotRenderer.java index 674a8eafe..63314ad86 100644 --- a/src/main/java/com/klikli_dev/occultism/client/render/entity/FoliotRenderer.java +++ b/src/main/java/com/klikli_dev/occultism/client/render/entity/FoliotRenderer.java @@ -45,6 +45,8 @@ public class FoliotRenderer extends GeoEntityRenderer { public FoliotRenderer(EntityRendererProvider.Context context) { super(context, new FoliotModel()); + this.withScale(1.5f); + this.addRenderLayer(new BlockAndItemGeoLayer<>(this, (bone, animatable) -> { if (Objects.equals(bone.getName(), "RARM")) //right hand return animatable.getItemInHand(InteractionHand.MAIN_HAND); diff --git a/src/main/java/com/klikli_dev/occultism/common/entity/job/LumberjackJob.java b/src/main/java/com/klikli_dev/occultism/common/entity/job/LumberjackJob.java index f9ab05a5c..ca5233512 100644 --- a/src/main/java/com/klikli_dev/occultism/common/entity/job/LumberjackJob.java +++ b/src/main/java/com/klikli_dev/occultism/common/entity/job/LumberjackJob.java @@ -53,12 +53,10 @@ public class LumberjackJob extends SpiritJob { - protected EntityDimensions lumberJackDimensions; protected List itemsToPickUp = new ArrayList<>(); public LumberjackJob(SpiritEntity entity) { super(entity); - this.lumberJackDimensions = EntityDimensions.scalable(0.8f, 0.8f); } @Override @@ -117,7 +115,6 @@ public void handleAdditionalBrainSetup(Brain brain) { @Override public void onInit() { - this.entity.refreshDimensions(); //will apply getDimensions() this.itemsToPickUp.add(Ingredient.of(ItemTags.LOGS)); this.itemsToPickUp.add(Ingredient.of(ItemTags.LEAVES)); this.itemsToPickUp.add(Ingredient.of(ItemTags.SAPLINGS)); @@ -127,7 +124,6 @@ public void onInit() { @Override public void cleanup() { - this.entity.refreshDimensions(); } @Override @@ -141,11 +137,6 @@ public List getItemsToPickUp() { return this.itemsToPickUp; } - @Override - public EntityDimensions getDimensions(Pose pPose, EntityDimensions original) { - return this.lumberJackDimensions; - } - @Override public void onChangeWorkArea() { BrainUtils.clearMemory(this.entity, OccultismMemoryTypes.NO_TREE_IN_WORK_AREA.get()); diff --git a/src/main/java/com/klikli_dev/occultism/common/entity/spirit/DjinniEntity.java b/src/main/java/com/klikli_dev/occultism/common/entity/spirit/DjinniEntity.java index e1078e665..65ba0f1ee 100644 --- a/src/main/java/com/klikli_dev/occultism/common/entity/spirit/DjinniEntity.java +++ b/src/main/java/com/klikli_dev/occultism/common/entity/spirit/DjinniEntity.java @@ -31,7 +31,6 @@ import net.minecraft.world.entity.Pose; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; -import net.minecraft.world.entity.animal.Pufferfish; import net.minecraft.world.level.Level; import software.bernie.geckolib.animatable.GeoEntity; import software.bernie.geckolib.core.animatable.GeoAnimatable; @@ -47,17 +46,24 @@ public class DjinniEntity extends SpiritEntity implements GeoEntity { - protected EntityDimensions t2CrusherDimensions = new EntityDimensions(1.2f, 2.4f, false); - - private static final EntityDataAccessor SIZE_STATE = SynchedEntityData.defineId(DjinniEntity.class, EntityDataSerializers.INT); - + protected EntityDimensions t2CrusherDimensions = new EntityDimensions(1.2f, 2.4f, false); AnimatableInstanceCache animatableInstanceCache = GeckoLibUtil.createInstanceCache(this); public DjinniEntity(EntityType type, Level level) { super(type, level); } + public static AttributeSupplier.Builder createAttributes() { + return SpiritEntity.createAttributes() + .add(Attributes.ATTACK_DAMAGE, 3.0) + .add(Attributes.MAX_HEALTH, 100.0) + .add(Attributes.MOVEMENT_SPEED, 0.30000001192092896) + .add(Attributes.ARMOR, 4.0) + .add(Attributes.ARMOR_TOUGHNESS, 5.0) + .add(Attributes.FOLLOW_RANGE, 50.0); + } + protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(SIZE_STATE, 0); @@ -77,7 +83,7 @@ public void onSyncedDataUpdated(EntityDataAccessor pKey) { } if (JOB_ID.equals(pKey)) { - if(Objects.equals(this.getJobID(), OccultismSpiritJobs.CRUSH_TIER2.getId().toString()) && this.getSizeState() != 1){ + if (Objects.equals(this.getJobID(), OccultismSpiritJobs.CRUSH_TIER2.getId().toString()) && this.getSizeState() != 1) { this.setSizeState(1); } } @@ -88,22 +94,12 @@ public void onSyncedDataUpdated(EntityDataAccessor pKey) { @Override public EntityDimensions getDimensions(Pose pPose) { - if(this.getSizeState() == 1) + if (this.getSizeState() == 1) return this.t2CrusherDimensions; return super.getDimensions(pPose); } - public static AttributeSupplier.Builder createAttributes() { - return SpiritEntity.createAttributes() - .add(Attributes.ATTACK_DAMAGE, 3.0) - .add(Attributes.MAX_HEALTH, 100.0) - .add(Attributes.MOVEMENT_SPEED, 0.30000001192092896) - .add(Attributes.ARMOR, 4.0) - .add(Attributes.ARMOR_TOUGHNESS, 5.0) - .add(Attributes.FOLLOW_RANGE, 50.0); - } - @Override public int getCurrentSwingDuration() { return 11; //to match our attack animation speed + 1 tick diff --git a/src/main/java/com/klikli_dev/occultism/common/entity/spirit/FoliotEntity.java b/src/main/java/com/klikli_dev/occultism/common/entity/spirit/FoliotEntity.java index 398910bf1..18fc1b263 100644 --- a/src/main/java/com/klikli_dev/occultism/common/entity/spirit/FoliotEntity.java +++ b/src/main/java/com/klikli_dev/occultism/common/entity/spirit/FoliotEntity.java @@ -22,7 +22,13 @@ package com.klikli_dev.occultism.common.entity.spirit; +import com.klikli_dev.occultism.registry.OccultismSpiritJobs; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.world.entity.EntityDimensions; import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.Pose; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.level.Level; @@ -36,8 +42,12 @@ import software.bernie.geckolib.core.object.PlayState; import software.bernie.geckolib.util.GeckoLibUtil; +import java.util.Objects; + public class FoliotEntity extends SpiritEntity implements GeoEntity { + private static final EntityDataAccessor SIZE_STATE = SynchedEntityData.defineId(DjinniEntity.class, EntityDataSerializers.INT); + protected EntityDimensions lumberJackDimensions = EntityDimensions.scalable(0.8f, 0.8f); AnimatableInstanceCache animatableInstanceCache = GeckoLibUtil.createInstanceCache(this); public FoliotEntity(EntityType type, Level level) { @@ -54,6 +64,43 @@ public static AttributeSupplier.Builder createAttributes() { .add(Attributes.FOLLOW_RANGE, 50.0); } + protected void defineSynchedData() { + super.defineSynchedData(); + this.entityData.define(SIZE_STATE, 0); + } + + public int getSizeState() { + return this.entityData.get(SIZE_STATE); + } + + public void setSizeState(int sizeState) { + this.entityData.set(SIZE_STATE, sizeState); + } + + public void onSyncedDataUpdated(EntityDataAccessor pKey) { + if (SIZE_STATE.equals(pKey)) { + this.refreshDimensions(); + } + + if (JOB_ID.equals(pKey)) { + if (Objects.equals(this.getJobID(), OccultismSpiritJobs.LUMBERJACK.getId().toString()) && this.getSizeState() != 1) { + this.setSizeState(1); + } + } + + super.onSyncedDataUpdated(pKey); + } + + @Override + public EntityDimensions getDimensions(Pose pPose) { + + if (this.getSizeState() == 1) + return this.lumberJackDimensions; + + return super.getDimensions(pPose); + } + + @Override public int getCurrentSwingDuration() { return 11; //to match our attack animation speed + 1 tick diff --git a/src/main/java/com/klikli_dev/occultism/registry/OccultismEntities.java b/src/main/java/com/klikli_dev/occultism/registry/OccultismEntities.java index 38d3018a7..255c6fdcb 100644 --- a/src/main/java/com/klikli_dev/occultism/registry/OccultismEntities.java +++ b/src/main/java/com/klikli_dev/occultism/registry/OccultismEntities.java @@ -44,12 +44,12 @@ public class OccultismEntities { public static final NonNullLazy> FOLIOT_TYPE = NonNullLazy.of(() -> EntityType.Builder.of(FoliotEntity::new, MobCategory.CREATURE) - .sized(0.6f, 0.7f) + .sized(0.6f, 1.2f) .clientTrackingRange(8) .build(StaticUtil.modLoc("foliot").toString())); public static final NonNullLazy> DJINNI_TYPE = NonNullLazy.of(() -> EntityType.Builder.of(DjinniEntity::new, MobCategory.CREATURE) - .sized(0.6f, 0.8f) + .sized(0.6f, 1.2f) .clientTrackingRange(8) .build(StaticUtil.modLoc("djinni").toString())); public static final NonNullLazy> AFRIT_TYPE =