-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: move job models to generic system * fix: copy glowtexture in addition to normal texture for afrit * fix: removed debug line and extraneous override * refactor: move second generic into addition of first
- Loading branch information
1 parent
bac30e3
commit 28e43f2
Showing
19 changed files
with
1,124 additions
and
161 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
src/main/java/com/klikli_dev/occultism/client/entities/SpiritJobClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.klikli_dev.occultism.client.entities; | ||
|
||
import com.klikli_dev.occultism.Occultism; | ||
import net.minecraft.resources.ResourceLocation; | ||
|
||
|
||
public class SpiritJobClient { | ||
protected ResourceLocation modelID; | ||
|
||
public SpiritJobClient(ResourceLocation modelID) { | ||
this.modelID = modelID; | ||
} | ||
|
||
public ResourceLocation modelID() { | ||
return modelID; | ||
} | ||
|
||
public static SpiritJobClient create(ResourceLocation modelID) { | ||
return new SpiritJobClient(modelID); | ||
} | ||
|
||
public static SpiritJobClient create(String modelId) { | ||
return create(new ResourceLocation(Occultism.MODID,modelId)); | ||
} | ||
|
||
public static SpiritJobClient create() { | ||
return create("worker"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
src/main/java/com/klikli_dev/occultism/client/model/entity/DefaultedJobEntityModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.klikli_dev.occultism.client.model.entity; | ||
|
||
import com.klikli_dev.occultism.Occultism; | ||
import com.klikli_dev.occultism.common.entity.job.SpiritJobFactory; | ||
import com.klikli_dev.occultism.common.entity.spirit.DjinniEntity; | ||
import com.klikli_dev.occultism.common.entity.spirit.SpiritEntity; | ||
import com.klikli_dev.occultism.registry.OccultismSpiritJobs; | ||
import net.minecraft.client.renderer.RenderType; | ||
import net.minecraft.resources.ResourceLocation; | ||
import software.bernie.geckolib.cache.GeckoLibCache; | ||
import software.bernie.geckolib.core.animatable.GeoAnimatable; | ||
import software.bernie.geckolib.model.DefaultedEntityGeoModel; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public abstract class DefaultedJobEntityModel<T extends SpiritEntity & GeoAnimatable> extends DefaultedEntityGeoModel<T> { | ||
private final String entity_subpath; | ||
protected final Map<String, ModelData> jobModels; | ||
protected final ModelData worker; | ||
|
||
public DefaultedJobEntityModel(ResourceLocation assetSubpath, boolean turnsHead, String entity_subpath) { | ||
super(assetSubpath, turnsHead); | ||
this.entity_subpath = entity_subpath; | ||
jobModels = new HashMap<>(); | ||
this.worker = this.buildModelData("worker"); | ||
for(var job: OccultismSpiritJobs.JOBS.getEntries()) { | ||
SpiritJobFactory factory = job.get(); | ||
jobModels.put(job.getId().toString(), this.buildModelData(factory.client().modelID(),"_")); | ||
} | ||
} | ||
|
||
public ModelData getModelData(T animatable) { | ||
var job = animatable.getJobID(); | ||
var model = jobModels.getOrDefault(job, this.worker); | ||
if(!GeckoLibCache.getBakedModels().containsKey(model.model())) | ||
model=this.worker; | ||
return model; | ||
} | ||
public ModelData buildModelData(String job) { | ||
return this.buildModelData(job, "_"); | ||
} | ||
|
||
public ModelData buildModelData(ResourceLocation basePath) { | ||
return new ModelData( | ||
this.buildFormattedModelPath(basePath), | ||
this.buildFormattedTexturePath(basePath), | ||
this.buildFormattedAnimationPath(basePath) | ||
); | ||
} | ||
public ModelData buildModelData(ResourceLocation location, String separator) { | ||
return this.buildModelData(new ResourceLocation(location.getNamespace(), entity_subpath + separator + location.getPath())); | ||
} | ||
public ModelData buildModelData(String job, String separator) { | ||
return this.buildModelData(new ResourceLocation(Occultism.MODID, job),separator); | ||
} | ||
|
||
public record ModelData(ResourceLocation model, ResourceLocation texture, ResourceLocation animation) { | ||
} | ||
|
||
@Override | ||
public RenderType getRenderType(T animatable, ResourceLocation texture) { | ||
return RenderType.entityTranslucent(this.getTextureResource(animatable)); | ||
} | ||
|
||
@Override | ||
public ResourceLocation getModelResource(T animatable) { | ||
return this.getModelData(animatable).model(); | ||
} | ||
|
||
@Override | ||
public ResourceLocation getTextureResource(T animatable) { | ||
return this.getModelData(animatable).texture(); | ||
} | ||
|
||
@Override | ||
public ResourceLocation getAnimationResource(T animatable) { | ||
return this.getModelData(animatable).animation(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.