use of software.bernie.geckolib3.geo.render.built.GeoModel in project geckolib by bernie-g.
the class GeoBuilder method constructGeoModel.
@Override
public GeoModel constructGeoModel(RawGeometryTree geometryTree) {
GeoModel model = new GeoModel();
model.properties = geometryTree.properties;
for (RawBoneGroup rawBone : geometryTree.topLevelBones.values()) {
model.topLevelBones.add(this.constructBone(rawBone, geometryTree.properties, null));
}
return model;
}
use of software.bernie.geckolib3.geo.render.built.GeoModel in project geckolib by bernie-g.
the class AnimatedGeoModel method getModel.
@Override
public GeoModel getModel(ResourceLocation location) {
GeoModel model = super.getModel(location);
if (model == null) {
throw new GeckoLibException(location, "Could not find model. If you are getting this with a built mod, please just restart your game.");
}
if (model != currentModel) {
this.animationProcessor.clearModelRendererList();
for (GeoBone bone : model.topLevelBones) {
registerBone(bone);
}
this.currentModel = model;
}
return model;
}
use of software.bernie.geckolib3.geo.render.built.GeoModel in project geckolib by bernie-g.
the class GeoModelLoader method loadModel.
public GeoModel loadModel(ResourceManager resourceManager, ResourceLocation location) {
try {
// Deserialize from json into basic json objects, bones are still stored as a
// flat list
RawGeoModel rawModel = Converter.fromJsonString(AnimationFileLoader.getResourceAsString(location, resourceManager));
if (rawModel.getFormatVersion() != FormatVersion.VERSION_1_12_0) {
throw new GeckoLibException(location, "Wrong geometry json version, expected 1.12.0");
}
// Parse the flat list of bones into a raw hierarchical tree of "BoneGroup"s
RawGeometryTree rawGeometryTree = RawGeometryTree.parseHierarchy(rawModel);
// rendered GeoModel
return GeoBuilder.getGeoBuilder(location.getNamespace()).constructGeoModel(rawGeometryTree);
} catch (Exception e) {
GeckoLib.LOGGER.error(String.format("Error parsing %S", location), e);
throw (new RuntimeException(e));
}
}
use of software.bernie.geckolib3.geo.render.built.GeoModel in project geckolib by bernie-g.
the class GeoArmorRenderer method render.
public void render(float partialTicks, PoseStack stack, VertexConsumer bufferIn, int packedLightIn) {
stack.translate(0.0D, 24 / 16F, 0.0D);
stack.scale(-1.0F, -1.0F, 1.0F);
GeoModel model = modelProvider.getModel(modelProvider.getModelLocation(currentArmorItem));
AnimationEvent itemEvent = new AnimationEvent(this.currentArmorItem, 0, 0, 0, false, Arrays.asList(this.itemStack, this.entityLiving, this.armorSlot));
modelProvider.setLivingAnimations(currentArmorItem, this.getUniqueID(this.currentArmorItem), itemEvent);
this.fitToBiped();
stack.pushPose();
RenderSystem.setShaderTexture(0, getTextureLocation(currentArmorItem));
Color renderColor = getRenderColor(currentArmorItem, partialTicks, stack, null, bufferIn, packedLightIn);
RenderType renderType = getRenderType(currentArmorItem, partialTicks, stack, null, bufferIn, packedLightIn, getTextureLocation(currentArmorItem));
render(model, currentArmorItem, partialTicks, renderType, stack, null, bufferIn, packedLightIn, OverlayTexture.NO_OVERLAY, (float) renderColor.getRed() / 255f, (float) renderColor.getGreen() / 255f, (float) renderColor.getBlue() / 255f, (float) renderColor.getAlpha() / 255);
if (ModList.get().isLoaded("patchouli")) {
PatchouliCompat.patchouliLoaded(stack);
}
stack.popPose();
stack.scale(-1.0F, -1.0F, 1.0F);
stack.translate(0.0D, -24 / 16F, 0.0D);
}
use of software.bernie.geckolib3.geo.render.built.GeoModel in project geckolib by bernie-g.
the class GeoEntityRenderer method render.
@SuppressWarnings("resource")
@Override
public void render(T entity, float entityYaw, float partialTicks, PoseStack stack, MultiBufferSource bufferIn, int packedLightIn) {
stack.pushPose();
boolean shouldSit = entity.isPassenger() && (entity.getVehicle() != null && entity.getVehicle().shouldRiderSit());
EntityModelData entityModelData = new EntityModelData();
entityModelData.isSitting = shouldSit;
entityModelData.isChild = entity.isBaby();
float f = Mth.rotLerp(partialTicks, entity.yBodyRotO, entity.yBodyRot);
float f1 = Mth.rotLerp(partialTicks, entity.yHeadRotO, entity.yHeadRot);
float netHeadYaw = f1 - f;
if (shouldSit && entity.getVehicle() instanceof LivingEntity) {
LivingEntity livingentity = (LivingEntity) entity.getVehicle();
f = Mth.rotLerp(partialTicks, livingentity.yBodyRotO, livingentity.yBodyRot);
netHeadYaw = f1 - f;
float f3 = Mth.wrapDegrees(netHeadYaw);
if (f3 < -85.0F) {
f3 = -85.0F;
}
if (f3 >= 85.0F) {
f3 = 85.0F;
}
f = f1 - f3;
if (f3 * f3 > 2500.0F) {
f += f3 * 0.2F;
}
netHeadYaw = f1 - f;
}
float headPitch = Mth.lerp(partialTicks, entity.getXRot(), entity.getXRot());
if (entity.getPose() == Pose.SLEEPING) {
Direction direction = entity.getBedOrientation();
if (direction != null) {
float f4 = entity.getEyeHeight(Pose.STANDING) - 0.1F;
stack.translate((double) ((float) (-direction.getStepX()) * f4), 0.0D, (double) ((float) (-direction.getStepZ()) * f4));
}
}
float f7 = this.handleRotationFloat(entity, partialTicks);
this.applyRotations(entity, stack, f7, f, partialTicks);
float limbSwingAmount = 0.0F;
float limbSwing = 0.0F;
if (!shouldSit && entity.isAlive()) {
limbSwingAmount = Mth.lerp(partialTicks, entity.animationSpeedOld, entity.animationSpeed);
limbSwing = entity.animationPosition - entity.animationSpeed * (1.0F - partialTicks);
if (entity.isBaby()) {
limbSwing *= 3.0F;
}
if (limbSwingAmount > 1.0F) {
limbSwingAmount = 1.0F;
}
}
entityModelData.headPitch = -headPitch;
entityModelData.netHeadYaw = -netHeadYaw;
AnimationEvent<T> predicate = new AnimationEvent<T>(entity, limbSwing, limbSwingAmount, partialTicks, !(limbSwingAmount > -0.15F && limbSwingAmount < 0.15F), Collections.singletonList(entityModelData));
GeoModel model = modelProvider.getModel(modelProvider.getModelLocation(entity));
if (modelProvider instanceof IAnimatableModel) {
((IAnimatableModel<T>) modelProvider).setLivingAnimations(entity, this.getUniqueID(entity), predicate);
}
stack.translate(0, 0.01f, 0);
RenderSystem.setShaderTexture(0, getTextureLocation(entity));
Color renderColor = getRenderColor(entity, partialTicks, stack, bufferIn, null, packedLightIn);
RenderType renderType = getRenderType(entity, partialTicks, stack, bufferIn, null, packedLightIn, getTextureLocation(entity));
boolean invis = entity.isInvisibleTo(Minecraft.getInstance().player);
render(model, entity, partialTicks, renderType, stack, bufferIn, null, packedLightIn, getPackedOverlay(entity, 0), (float) renderColor.getRed() / 255f, (float) renderColor.getGreen() / 255f, (float) renderColor.getBlue() / 255f, invis ? 0.0F : (float) renderColor.getAlpha() / 255);
if (!entity.isSpectator()) {
for (GeoLayerRenderer<T> layerRenderer : this.layerRenderers) {
layerRenderer.render(stack, bufferIn, packedLightIn, entity, limbSwing, limbSwingAmount, partialTicks, f7, netHeadYaw, headPitch);
}
}
if (ModList.get().isLoaded("patchouli")) {
PatchouliCompat.patchouliLoaded(stack);
}
stack.popPose();
super.render(entity, entityYaw, partialTicks, stack, bufferIn, packedLightIn);
}
Aggregations