Skip to content

Commit

Permalink
feat: increase foliot size slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
klikli-dev committed Jan 25, 2024
1 parent 78b0dde commit f295c7a
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class FoliotRenderer extends GeoEntityRenderer<FoliotEntity> {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,10 @@

public class LumberjackJob extends SpiritJob {

protected EntityDimensions lumberJackDimensions;
protected List<Ingredient> itemsToPickUp = new ArrayList<>();

public LumberjackJob(SpiritEntity entity) {
super(entity);
this.lumberJackDimensions = EntityDimensions.scalable(0.8f, 0.8f);
}

@Override
Expand Down Expand Up @@ -117,7 +115,6 @@ public void handleAdditionalBrainSetup(Brain<? extends SpiritEntity> 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));
Expand All @@ -127,7 +124,6 @@ public void onInit() {

@Override
public void cleanup() {
this.entity.refreshDimensions();
}

@Override
Expand All @@ -141,11 +137,6 @@ public List<Ingredient> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Integer> 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<? extends SpiritEntity> 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);
Expand All @@ -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);
}
}
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Integer> 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<? extends SpiritEntity> type, Level level) {
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ public class OccultismEntities {

public static final NonNullLazy<EntityType<FoliotEntity>> FOLIOT_TYPE =
NonNullLazy.of(() -> EntityType.Builder.of(FoliotEntity::new, MobCategory.CREATURE)
.sized(0.6f, 0.7f)
.sized(0.6f, 1.2f)
.clientTrackingRange(8)
.build(new ResourceLocation(Occultism.MODID, "foliot").toString()));
public static final NonNullLazy<EntityType<DjinniEntity>> DJINNI_TYPE =
NonNullLazy.of(() -> EntityType.Builder.of(DjinniEntity::new, MobCategory.CREATURE)
.sized(0.6f, 0.8f)
.sized(0.6f, 1.2f)
.clientTrackingRange(8)
.build(new ResourceLocation(Occultism.MODID, "djinni").toString()));
public static final NonNullLazy<EntityType<AfritEntity>> AFRIT_TYPE =
Expand Down

0 comments on commit f295c7a

Please sign in to comment.