Added missing model and animation protection

This commit is contained in:
Goodbird committed 2024-05-27 10:45:48 +03:00
1 parent 3479cb1e0f
commit 185e8579c7
6 files changed
+697

No files matched your search

@@ -6,20 +6,36 @@ import software.bernie.geckolib3.core.event.predicate.AnimationEvent;
import software.bernie.geckolib3.core.processor.IBone;
import software.bernie.geckolib3.model.AnimatedGeoModel;
import software.bernie.geckolib3.model.provider.data.EntityModelData;
import software.bernie.geckolib3.resource.GeckoLibCache;
public class ModelCustom extends AnimatedGeoModel<EntityCustomModel> {
@Override
public ResourceLocation getAnimationFileLocation(EntityCustomModel entity) {
if(!GeckoLibCache.getInstance().getAnimations().containsKey(entity.animResLoc)){
return new ResourceLocation("npcgecko","animations/none.animations.json");
}
return entity.animResLoc;
}
@Override
public ResourceLocation getModelLocation(EntityCustomModel entity) {
if(!GeckoLibCache.getInstance().getGeoModels().containsKey(entity.modelResLoc)){
return new ResourceLocation("npcgecko","geo/modelnotfound.geo.json");
}
if(!GeckoLibCache.getInstance().getAnimations().containsKey(entity.animResLoc)){
return new ResourceLocation("npcgecko","geo/animfilenotfound.geo.json");
}
return entity.modelResLoc;
}
@Override
public ResourceLocation getTextureLocation(EntityCustomModel entity) {
if(!GeckoLibCache.getInstance().getGeoModels().containsKey(entity.modelResLoc)){
return new ResourceLocation("npcgecko","textures/model/alphabet.png");
}
if(!GeckoLibCache.getInstance().getAnimations().containsKey(entity.animResLoc)){
return new ResourceLocation("npcgecko","textures/model/alphabet.png");
}
return entity.textureResLoc;
}
@@ -3,20 +3,36 @@ package com.goodbird.npcgecko.client.model;
import com.goodbird.npcgecko.tile.TileEntityCustomModel;
import net.minecraft.util.ResourceLocation;
import software.bernie.geckolib3.model.AnimatedGeoModel;
import software.bernie.geckolib3.resource.GeckoLibCache;
public class TileModelCustom extends AnimatedGeoModel<TileEntityCustomModel> {
@Override
public ResourceLocation getAnimationFileLocation(TileEntityCustomModel entity) {
if(!GeckoLibCache.getInstance().getAnimations().containsKey(entity.animResLoc)){
return new ResourceLocation("npcgecko","animations/none.animations.json");
}
return entity.animResLoc;
}
@Override
public ResourceLocation getModelLocation(TileEntityCustomModel animatable) {
if(!GeckoLibCache.getInstance().getGeoModels().containsKey(animatable.modelResLoc)){
return new ResourceLocation("npcgecko","geo/modelnotfound.geo.json");
}
if(!GeckoLibCache.getInstance().getAnimations().containsKey(animatable.animResLoc)){
return new ResourceLocation("npcgecko","geo/animfilenotfound.geo.json");
}
return animatable.modelResLoc;
}
@Override
public ResourceLocation getTextureLocation(TileEntityCustomModel entity) {
if(!GeckoLibCache.getInstance().getGeoModels().containsKey(entity.modelResLoc)){
return new ResourceLocation("npcgecko","textures/model/alphabet.png");
}
if(!GeckoLibCache.getInstance().getAnimations().containsKey(entity.animResLoc)){
return new ResourceLocation("npcgecko","textures/model/alphabet.png");
}
return entity.textureResLoc;
}
}