use of net.minecraft.client.util.ModelIdentifier in project artifality by PinkGoosik.
the class ItemRendererMixin method twoModelsItemImplementation.
@Inject(method = "renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformation$Mode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/world/World;III)V", at = @At("HEAD"))
void twoModelsItemImplementation(LivingEntity entity, ItemStack stack, ModelTransformation.Mode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, World world, int light, int overlay, int seed, CallbackInfo ci) {
if (!stack.isEmpty() && entity != null) {
TwoModelsItemRegistry.ENTRIES.forEach((id, item) -> {
if (stack.isOf(item)) {
BakedModel model = models.getModelManager().getModel(new ModelIdentifier(id + "_in_hand#inventory"));
renderItem(stack, renderMode, leftHanded, matrices, vertexConsumers, light, overlay, model);
matrices.scale(0, 0, 0);
}
});
}
/*
replaces the default enchanted book model
with the custom one if a book has a lunar
enchantment
*/
// if(!stack.isEmpty() && stack.isOf(Items.ENCHANTED_BOOK)) {
// NbtList enchantments = EnchantedBookItem.getEnchantmentNbt(stack);
//
// for(int i = 0; i < enchantments.size(); ++i) {
// NbtCompound nbtCompound = enchantments.getCompound(i);
//
// Registry.ENCHANTMENT.getOrEmpty(Identifier.tryParse(nbtCompound.getString("id"))).ifPresent((enchantment) -> {
// if(enchantment instanceof LunarEnchantment) {
// BakedModel model = models.getModelManager().getModel(new ModelIdentifier("artifality:lunar_enchanted_book#inventory"));
// renderItem(stack, renderMode, leftHanded, matrices, vertexConsumers, light, overlay, model);
// matrices.scale(0, 0, 0);
// }
// });
// }
// }
}
use of net.minecraft.client.util.ModelIdentifier in project CITResewn by SHsuperCM.
the class ModelLoaderMixin method initCITs.
@Inject(method = "addModel", at = @At("TAIL"))
public void initCITs(ModelIdentifier eventModelId, CallbackInfo ci) {
if (eventModelId != ModelLoader.MISSING_ID)
return;
if (CITResewn.INSTANCE.activeCITs != null) {
info("Clearing active CITs..");
CITResewn.INSTANCE.activeCITs.dispose();
CITResewn.INSTANCE.activeCITs = null;
}
if (!CITResewnConfig.INSTANCE().enabled)
return;
info("Parsing CITs...");
List<CITPack> parsedPacks = CITParser.parseCITs(resourceManager.streamResourcePacks().collect(Collectors.toCollection(ArrayList::new)));
List<CIT> parsed = parsedPacks.stream().flatMap(pack -> pack.cits.stream()).collect(Collectors.toCollection(ArrayList::new));
if (parsed.size() > 0) {
info("Activating CITs...");
CITResewn.INSTANCE.activeCITs = new ActiveCITs(parsedPacks, parsed);
} else
info("No cit packs found.");
}
use of net.minecraft.client.util.ModelIdentifier in project fabric by FabricMC.
the class ModelModClient method onInitializeClient.
@Override
public void onInitializeClient() {
ModelLoadingRegistry.INSTANCE.registerAppender((manager, out) -> {
System.out.println("--- ModelAppender called! ---");
out.accept(new ModelIdentifier("fabric:model#custom"));
});
ModelLoadingRegistry.INSTANCE.registerVariantProvider(manager -> ((modelId, context) -> {
if (modelId.getVariant().equals("custom") && modelId.getNamespace().equals("fabric")) {
System.out.println("--- ModelVariantProvider called! ---");
return context.loadModel(new Identifier("fabric:custom"));
} else {
return null;
}
}));
ModelLoadingRegistry.INSTANCE.registerResourceProvider(manager -> ((id, context) -> {
if (id.toString().equals("fabric:custom")) {
return context.loadModel(new Identifier("fabric:custom2"));
} else if (id.toString().equals("fabric:custom2")) {
System.out.println("--- ModelResourceProvider called! ---");
return new UnbakedModel() {
@Override
public Collection<Identifier> getModelDependencies() {
return Collections.emptyList();
}
@Override
public Collection<Identifier> getTextureDependencies(Function<Identifier, UnbakedModel> var1, Set<String> var2) {
return Collections.emptyList();
}
@Override
public BakedModel bake(ModelLoader var1, Function<Identifier, Sprite> var2, ModelBakeSettings var3) {
System.out.println("--- Model baked! ---");
return bakedModel = new BakedModel() {
@Override
public List<BakedQuad> getQuads(BlockState var1, Direction var2, Random var3) {
return Collections.emptyList();
}
@Override
public boolean useAmbientOcclusion() {
return false;
}
@Override
public boolean hasDepthInGui() {
return false;
}
@Override
public boolean isBuiltin() {
return false;
}
@Override
public Sprite getSprite() {
return MinecraftClient.getInstance().getSpriteAtlas().getSprite("missingno");
}
@Override
public ModelTransformation getTransformation() {
return ModelTransformation.NONE;
}
@Override
public ModelItemPropertyOverrideList getItemPropertyOverrides() {
return ModelItemPropertyOverrideList.EMPTY;
}
};
}
};
} else {
return null;
}
}));
ClientTickCallback.EVENT.register((client) -> {
if (client.getBakedModelManager().getModel(new ModelIdentifier("fabric:model#custom")) == bakedModel && bakedModel != null) {
System.out.println("--- MODEL LOADED! ---");
} else {
System.out.println("--- MODEL NOT LOADED! ---");
}
});
}
use of net.minecraft.client.util.ModelIdentifier in project artifality by PinkGoosik.
the class BalloonRenderer method render.
@Override
public void render(ItemStack stack, SlotReference slotReference, EntityModel<? extends LivingEntity> contextModel, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, LivingEntity entity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) {
ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer();
matrices.push();
if (entity.isInSneakingPose())
matrices.translate(0D, -1.25D, 0D);
else
matrices.translate(0D, -1.5D, 0D);
matrices.scale(0.8F, 0.8F, 0.8F);
matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(180.0F));
String modelId = "artifality:balloon_in_hand#inventory";
itemRenderer.renderItem(stack, ModelTransformation.Mode.FIXED, false, matrices, vertexConsumers, light, OverlayTexture.DEFAULT_UV, itemRenderer.getModels().getModelManager().getModel(new ModelIdentifier(modelId)));
matrices.pop();
}
Aggregations